PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.4
VikBooking Hotel Booking Engine & PMS v1.6.4
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / admin / helpers / src / autoload.php

autoload.php in VikBooking Hotel Booking Engine & PMS 1.6.4, at admin/helpers/src/autoload.php

93 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
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 /**
15 * Register CMS HTML helpers.
16 *
17 * @since 1.5
18 */
19 JHtml::addIncludePath(VBO_ADMIN_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'html');
20
21 /**
22 * Libraries autoloader.
23 *
24 * @since 1.5
25 */
26 spl_autoload_register(function($class)
27 {
28 // handle base VCM library
29 if ($class === 'VikChannelManager')
30 {
31 require_once implode(DIRECTORY_SEPARATOR, [VCM_SITE_PATH, 'helpers', 'lib.vikchannelmanager.php']);
32
33 return true;
34 }
35
36 // handle config VCM library
37 if ($class === 'VikChannelManagerConfig')
38 {
39 require_once implode(DIRECTORY_SEPARATOR, [VCM_SITE_PATH, 'helpers', 'vcm_config.php']);
40
41 return true;
42 }
43
44 // handle base VBO library
45 if ($class === 'VikBooking')
46 {
47 require_once implode(DIRECTORY_SEPARATOR, [VBO_SITE_PATH, 'helpers', 'lib.vikbooking.php']);
48
49 return true;
50 }
51
52 $guess_vbo = stripos($class, 'VBO');
53 $guess_vcm = stripos($class, 'VCM');
54
55 if ($guess_vbo !== 0 && $guess_vcm !== 0)
56 {
57 // ignore if we are loading an outsider
58 return false;
59 }
60
61 // get the class prefix and base path
62 if ($guess_vbo === 0)
63 {
64 $class_prefix = 'VBO';
65 $class_bpath = dirname(__FILE__);
66 }
67 else
68 {
69 $class_prefix = 'VCM';
70 $class_bpath = str_replace('vikbooking', 'vikchannelmanager', dirname(__FILE__));
71 }
72
73 // remove prefix from class
74 $tmp = preg_replace("/^$class_prefix/", '', $class);
75 // separate camel-case intersections
76 $tmp = preg_replace("/([a-z])([A-Z])/", addslashes('$1' . DIRECTORY_SEPARATOR . '$2'), $tmp);
77
78 // build path from which the class should be loaded
79 $path = $class_bpath . DIRECTORY_SEPARATOR . strtolower($tmp) . '.php';
80
81 // make sure the file exists
82 if (is_file($path))
83 {
84 // include file and check if the class is now available
85 if ((include_once $path) && (class_exists($class) || interface_exists($class) || trait_exists($class)))
86 {
87 return true;
88 }
89 }
90
91 return false;
92 });
93