forked from ylabio/ylab.likes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinclude.php
34 lines (30 loc) · 1.09 KB
/
include.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
spl_autoload_register(function ($className) {
preg_match('/^(.*?)([\w]+)$/i', $className, $matches);
if (count($matches) < 3) {
return;
}
$filePath = implode(DIRECTORY_SEPARATOR, array(
__DIR__,
"lib",
str_replace('\\', DIRECTORY_SEPARATOR, trim($matches[1], '\\')),
str_replace('_', DIRECTORY_SEPARATOR, $matches[2]) . '.php'
));
$filePath = str_replace('Ylab\Likes' . DIRECTORY_SEPARATOR, '', $filePath);
$filePath = preg_replace('#Ylab/\Likes\/#', '', $filePath);
$filePath = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $filePath);
if (is_readable($filePath) && is_file($filePath)) {
/** @noinspection PhpIncludeInspection */
require_once $filePath;
}
});
$arJsLibs = [
'YlabLikesForm' => [
'js' => '/bitrix/themes/ylab.likes/js/YlabLikesForm.js',
'lang' => '/bitrix/themes/ylab.likes/lang/' . LANGUAGE_ID . '/YlabLikesForm.php',
'rel' => ['ajax']
],
];
foreach ($arJsLibs as $jsLib => $arJsLib) {
CJSCore::RegisterExt($jsLib, $arJsLib);
}