action
2 days ago
adapter
2 days ago
api
2 days ago
archive
2 days ago
availability
2 days ago
backup
2 days ago
banking
2 days ago
calendar
2 days ago
cart
2 days ago
cartpack
2 days ago
config
2 days ago
controllers
2 days ago
cron
2 days ago
crypt
2 days ago
currency
2 days ago
customfields
2 days ago
employee
2 days ago
event
2 days ago
helpers
2 days ago
html
2 days ago
http
2 days ago
ical
2 days ago
image
2 days ago
import
2 days ago
invoice
2 days ago
language
2 days ago
loader
2 days ago
mail
2 days ago
menu
2 days ago
models
2 days ago
mvc
2 days ago
order
2 days ago
payment
2 days ago
sef
2 days ago
statistics
2 days ago
system
2 days ago
tax
2 days ago
update
2 days ago
vendor
2 days ago
view
2 days ago
webhook
2 days ago
widget
2 days ago
wizard
2 days ago
worktime
2 days ago
autoload.php
2 days ago
composer.json
2 days ago
defines.php
2 days ago
index.html
2 days ago
autoload.php
116 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | // require only once the file containing all the defines |
| 15 | require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'defines.php'; |
| 16 | |
| 17 | // if VAPLoader does not exist, include it |
| 18 | if (!class_exists('VAPLoader')) |
| 19 | { |
| 20 | include VAPLIB . DIRECTORY_SEPARATOR . 'loader' . DIRECTORY_SEPARATOR . 'loader.php'; |
| 21 | // append helpers folder to the base path |
| 22 | VAPLoader::$base .= DIRECTORY_SEPARATOR . 'helpers'; |
| 23 | } |
| 24 | |
| 25 | // fix filenames with dots |
| 26 | VAPLoader::registerAlias('lib.vikappointments', 'lib_vikappointments'); |
| 27 | |
| 28 | // load factory |
| 29 | VAPLoader::import('libraries.system.factory'); |
| 30 | VAPLoader::import('libraries.system.error'); |
| 31 | |
| 32 | // load adapters |
| 33 | VAPLoader::import('libraries.adapter.version.listener'); |
| 34 | VAPLoader::import('libraries.adapter.application'); |
| 35 | VAPLoader::import('libraries.adapter.bc'); |
| 36 | |
| 37 | // load mvc |
| 38 | VAPLoader::import('libraries.mvc.controller'); |
| 39 | VAPLoader::import('libraries.mvc.table'); |
| 40 | VAPLoader::import('libraries.mvc.view'); |
| 41 | VAPLoader::import('libraries.mvc.model'); |
| 42 | |
| 43 | // load dependencies |
| 44 | VAPLoader::import('libraries.employee.auth'); |
| 45 | VAPLoader::import('libraries.helpers.date'); |
| 46 | VAPLoader::import('libraries.models.customfields'); |
| 47 | VAPLoader::import('libraries.models.locations'); |
| 48 | VAPLoader::import('libraries.models.orderstatus'); |
| 49 | VAPLoader::import('libraries.models.specialrates'); |
| 50 | |
| 51 | // load component helper |
| 52 | VAPLoader::import('lib_vikappointments'); |
| 53 | |
| 54 | $app = JFactory::getApplication(); |
| 55 | |
| 56 | // configure HTML helpers |
| 57 | if ($app->isClient('administrator')) |
| 58 | { |
| 59 | JHtml::addIncludePath(VAPADMIN . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'html'); |
| 60 | } |
| 61 | |
| 62 | if ($app->isClient('site') || $app->input->get('option') !== 'com_vikappointments') |
| 63 | { |
| 64 | // load admin models for front-end client or if we are outside the component |
| 65 | JModelLegacy::addIncludePath(VAPADMIN . DIRECTORY_SEPARATOR . 'models', 'VikAppointmentsModel'); |
| 66 | } |
| 67 | |
| 68 | JTable::addIncludePath(VAPADMIN . DIRECTORY_SEPARATOR . 'tables'); |
| 69 | JHtml::addIncludePath(VAPLIB . DIRECTORY_SEPARATOR . 'html'); |
| 70 | |
| 71 | /** |
| 72 | * Classes autoloader. |
| 73 | * |
| 74 | * The following class "VAPFooBarBaz" will be |
| 75 | * loaded from "site/helpers/libraries/foo/bar/baz.php". |
| 76 | * |
| 77 | * @since 1.7.3 |
| 78 | */ |
| 79 | spl_autoload_register(function($class) |
| 80 | { |
| 81 | $prefix = 'VAP'; |
| 82 | |
| 83 | if (strpos($class, $prefix) !== 0) |
| 84 | { |
| 85 | // ignore if we are loading an outsider |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | // remove prefix from class |
| 90 | $tmp = preg_replace("/^{$prefix}/", '', $class); |
| 91 | // separate camel-case intersections |
| 92 | $tmp = preg_replace("/([a-z0-9])([A-Z])/", addslashes('$1' . DIRECTORY_SEPARATOR . '$2'), $tmp); |
| 93 | |
| 94 | // build path from which the class should be loaded |
| 95 | $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . strtolower($tmp) . '.php'; |
| 96 | |
| 97 | // make sure the file exists |
| 98 | if (is_file($path)) |
| 99 | { |
| 100 | // include file and check if the class is now available |
| 101 | if ((include_once $path) && (class_exists($class) || interface_exists($class) || trait_exists($class))) |
| 102 | { |
| 103 | return true; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | return false; |
| 108 | }); |
| 109 | |
| 110 | /** |
| 111 | * Composer autoloader. |
| 112 | * |
| 113 | * @since 1.7.3 |
| 114 | */ |
| 115 | VAPLoader::import('libraries.vendor.autoload'); |
| 116 |