PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.7
VikBooking Hotel Booking Engine & PMS v1.6.7
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.7, at admin/helpers/src/autoload.php

87 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 return (bool) @include_once implode(DIRECTORY_SEPARATOR, [VCM_SITE_PATH, 'helpers', 'lib.vikchannelmanager.php']);
32 }
33
34 // handle config VCM library
35 if ($class === 'VikChannelManagerConfig')
36 {
37 return (bool) @include_once implode(DIRECTORY_SEPARATOR, [VCM_SITE_PATH, 'helpers', 'vcm_config.php']);
38 }
39
40 // handle base VBO library
41 if ($class === 'VikBooking')
42 {
43 return (bool) require_once implode(DIRECTORY_SEPARATOR, [VBO_SITE_PATH, 'helpers', 'lib.vikbooking.php']);
44 }
45
46 $guess_vbo = stripos($class, 'VBO');
47 $guess_vcm = stripos($class, 'VCM');
48
49 if ($guess_vbo !== 0 && $guess_vcm !== 0)
50 {
51 // ignore if we are loading an outsider
52 return false;
53 }
54
55 // get the class prefix and base path
56 if ($guess_vbo === 0)
57 {
58 $class_prefix = 'VBO';
59 $class_bpath = dirname(__FILE__);
60 }
61 else
62 {
63 $class_prefix = 'VCM';
64 $class_bpath = str_replace('vikbooking', 'vikchannelmanager', dirname(__FILE__));
65 }
66
67 // remove prefix from class
68 $tmp = preg_replace("/^$class_prefix/", '', $class);
69 // separate camel-case intersections
70 $tmp = preg_replace("/([a-z])([A-Z])/", addslashes('$1' . DIRECTORY_SEPARATOR . '$2'), $tmp);
71
72 // build path from which the class should be loaded
73 $path = $class_bpath . DIRECTORY_SEPARATOR . strtolower($tmp) . '.php';
74
75 // make sure the file exists
76 if (is_file($path))
77 {
78 // include file and check if the class is now available
79 if ((include_once $path) && (class_exists($class) || interface_exists($class) || trait_exists($class)))
80 {
81 return true;
82 }
83 }
84
85 return false;
86 });
87