Файловый менеджер - Редактировать - /home/lmsyaran/public_html/joomla5/libraries/fabrik/fabrik/include.php
Назад
<?php /** * Fabrik Autoloader Class * * @package Fabrik * @copyright Copyright (C) 2014 fabrikar.com - All rights reserved. * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html */ // No direct access defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\Factory; use Joomla\String\Inflector; use Joomla\String\Normalise; /**' * Autoloader Class * * @package Fabble * @since 1.0 */ class FabrikAutoloader { public function __construct() { spl_autoload_register(array($this, 'controller')); spl_autoload_register(array($this, 'helper')); spl_autoload_register(array($this, 'document')); spl_autoload_register(array($this, 'view')); // @TODO - at some point allow auto-loading of these as per Fabble /* spl_autoload_register(array($this, 'model')); spl_autoload_register(array($this, 'view')); spl_autoload_register(array($this, 'library')); spl_autoload_register(array($this, 'plugin'));*/ } /** * Load plugin class * * @param string $class Class name */ private function plugin($class) { if (!strstr(strtolower($class), 'fabble\form\plugin\\') && !strstr(strtolower($class), 'fabble\lizt\plugin\\')) { return; } $class = str_replace('\\', '/', str_replace('Fabble\\', '', $class)); $file = explode('/', $class); $file = array_pop($file); $path = JPATH_SITE . '/libraries/fabble/' . $class . '/' . $file . '.php'; require_once $path; } /** * Load model class * * @param string $class Class name */ private function model($class) { if (!strstr(strtolower($class), 'model')) { return; } $kls = explode('\\', $class); $class = array_pop($kls); $scope = Factory::getApplication()->scope; $isFabble = strtolower(substr($class, 0, 11)) === 'fabblemodel'; if ($this->appName($class) === $scope || $isFabble) { $path = JPATH_SITE . '/libraries/fabble/'; $defaultPath = JPATH_SITE . '/libraries/fabble/'; $plural = Inflector::getInstance(); $parts = Normalise::fromCamelCase($class, true); unset($parts[0]); $parts = array_values($parts); foreach ($parts as &$part) { $part = strtolower($part); if ($plural->isPlural($part)) { $part = $plural->toSingular($part); } $part = StringHelper::ucfirst(strtolower($part)); } $path .= implode('/', $parts) . '.php'; if (file_exists($path)) { require_once $path; $type = array_pop($parts); if (!$isFabble) { class_alias('\\Fabble\\Model\\FabbleModel' . StringHelper::ucfirst($type), $class); } return; } // IF no actual model name found try loading default model $parts[count($parts) - 1] = 'Default'; $defaultPath .= implode('/', $parts) . '.php'; if (file_exists($defaultPath)) { require_once $defaultPath; $type = array_pop($parts); class_alias("\\Fabble\\Model\\FabbleModel" . StringHelper::ucfirst($type), $class); return; } } } /** * Load view class * * @param string $class Class name */ private function view($class) { /* if (!strstr(strtolower($class), 'view')) { return; } $scope = Factory::getApplication()->scope; // Load component specific files if ($this->appName($class) === $scope) { $parts = Normalise::fromCamelCase($class, true); $type = array_pop($parts); $path = JPATH_SITE . '/libraries/fabble/Views/' . StringHelper::ucfirst($type) . '.php'; $original = $type; if (file_exists($path)) { require_once $path; class_alias('\\Fabble\\Views\\' . $original, $class); return; } } */ if ($class !== 'FabrikView') { return; } $path = JPATH_SITE . '/components/com_fabrik/views/FabrikView.php'; if (file_exists($path)) { require_once $path; } } private function appName($class) { $scope = Factory::getApplication()->scope; return 'com_' . strtolower(substr($class, 0, strlen($scope) - 4)); } /** * Load controller file * * @param string $class Class name */ private function controller($class) { if (!str_starts_with($class, 'Fabrik') || strpos($class, '\\') !== false) { return; } $parts = preg_split('/(?<=\\w)(?=[A-Z])/', $class); if ($parts[1] == 'Admin') { if ($parts[2] != 'Controller' || array_key_exists(3, $parts) === false) { return; } $jpath = JPATH_ADMINISTRATOR; $file = strtolower($parts[3]); } else { if ($parts[1] != 'Controller') { return; } $jpath = JPATH_SITE; $file = strtolower($parts[2]); } if (Factory::getApplication()->input->get('format') == 'raw') { $file .= '.raw'; } $path = $jpath . '/components/com_fabrik/controllers/' . $file . '.php'; if (file_exists($path)) { require_once $path; } } /** * Load library files, and possible helpers * * @param string $class Class Name */ private function library($class) { if (strstr($class, '\\')) { return; } if (strtolower(substr($class, 0, 3)) === 'fab') { $class = (substr($class, 3)); // Change from camel cased (e.g. ViewHtml) into a lowercase array (e.g. 'view','html') taken from FOF $class = preg_replace('/(\s)+/', '_', $class); $class = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class)); $class = explode('_', $class); $file = (count($class) === 1) ? $class[0] : array_pop($class); $path = JPATH_SITE . '/libraries/fabble/' . implode('/', $class); $classFile = $path . '/' . $file . '.php'; $helper = $path . '/helper.php'; if (file_exists($classFile)) { include_once $classFile; } if (file_exists($helper)) { include_once $helper; } } } /** * Load helper file **/ private function helper($class) { if (!strstr($class, 'Fabrik\Helpers')) { return; } $className = str_replace('\\', '/', $class); //$file = explode('/', $class); //$file = strtolower(array_pop($file)); $path = preg_replace('#Fabrik\/Helpers\/#', '/libraries/fabrik/fabrik/fabrik/Helpers/', $className); $path = JPATH_SITE . $path . '.php'; if (file_exists($path)) { require_once $path; if (is_callable(array($class, '__initStatic'))) { $class::__initStatic(); } } } /** * Load document file **/ private function document($class) { if (!strstr($class, 'Fabrik\Document')) { return; } $class = str_replace('\\', '/', $class); //$file = explode('/', $class); //$file = strtolower(array_pop($file)); $path = preg_replace('#Fabrik\/Document\/#', '/libraries/fabrik/fabrik/fabrik/Document/', $class); $path = JPATH_SITE . $path . '.php'; if (file_exists($path)) { require_once $path; } } } /* * If the Fabrik library package has been installed, or we have full github code, we can use Composer autoload */ if (file_exists(JPATH_LIBRARIES . '/fabrik/vendor/vendor/autoload.php')) { $loader = require JPATH_LIBRARIES . '/fabrik/vendor/vendor/autoload.php'; } $autoLoader = new FabrikAutoloader();
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка