File manager - Edit - /home/opticamezl/www/newok/platform-joomla.zip
Back
PK ҙ�\ˍ��� � src/Media.phpnu �[��� <?php namespace YOOtheme\Joomla; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Extension\MVCComponent; use Joomla\CMS\Factory; use Joomla\Component\Media\Administrator\Model\ApiModel; use Joomla\Component\Media\Administrator\Provider\ProviderInterface; use YOOtheme\Path; class Media { public static function getRoot($root = null): string { $provider = static::getLocalProvider(); $path = null; if ($provider) { $adapters = $provider->getAdapters(); $adapter = $root ? $adapters[$root] ?? null : current($adapters); if ($adapter) { $path = $adapter->getAdapterName(); } } return Path::join( JPATH_ROOT, $path ?: ComponentHelper::getParams('com_media')->get('file_path', 'images'), ); } public static function getRootPaths(): array { $provider = static::getLocalProvider(); if (!$provider) { return []; } return array_values( array_map(fn($adapter) => $adapter->getAdapterName(), $provider->getAdapters()), ); } protected static function getLocalProvider(): ?ProviderInterface { $joomla = Factory::getApplication(); if (!method_exists($joomla, 'bootComponent')) { return null; } try { /** @var MVCComponent $component */ $component = $joomla->bootComponent('com_media'); /** @var ApiModel $model */ $model = $component->getMVCFactory()->createModel('Api', 'Administrator'); return $model->getProvider('local'); } catch (\Exception $e) { return null; } } } PK ҙ�\��m� � src/Router.phpnu �[��� <?php namespace YOOtheme\Joomla; use Joomla\CMS\Router\Route; use YOOtheme\Url; class Router { public static function generate($pattern = '', array $parameters = [], $secure = null) { if ($pattern) { $parameters = ['p' => $pattern] + $parameters; } return Url::to( Route::_('index.php?' . http_build_query(['option' => 'com_ajax']), false), $parameters, $secure, ); } } PK ҙ�\\�[7\ \ src/Storage.phpnu �[��� <?php namespace YOOtheme\Joomla; use Joomla\CMS\Factory; use Joomla\Database\DatabaseDriver; use YOOtheme\Storage as AbstractStorage; use function YOOtheme\app; class Storage extends AbstractStorage { /** * Constructor. * * @param string $element * @param string $folder * * @throws \Exception */ public function __construct($element = 'yootheme', $folder = 'system') { /** @var DatabaseDriver $db */ $db = app(DatabaseDriver::class); $query = sprintf( 'SELECT custom_data FROM #__extensions WHERE element = %s AND folder = %s LIMIT 1', $db->quote($element), $db->quote($folder), ); if ($result = $db->setQuery($query)->loadResult()) { $this->addJson($result); } $joomla = Factory::getApplication(); $joomla->registerEvent('onAfterRespond', function () use ($db, $element, $folder) { if ($this->isModified()) { $data = json_encode($this, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); if ($data === false) { return; } $this->alterCustomDataColumn($db); $extension = (object) [ 'element' => $element, 'folder' => $folder, 'custom_data' => $data, ]; $db->updateObject('#__extensions', $extension, ['element', 'folder']); } }); } /** * Alter custom_data type to MEDIUMTEXT only in MySQL database */ protected function alterCustomDataColumn($db) { if (!str_contains($db->getName(), 'mysql')) { return; } if ( $db ->setQuery( "SHOW FIELDS FROM #__extensions WHERE Field = 'custom_data' AND Type = 'text'", ) ->loadRow() ) { $db->setQuery( 'ALTER TABLE #__extensions CHANGE `custom_data` `custom_data` MEDIUMTEXT NOT NULL', )->execute(); } } } PK ҙ�\OPH�� � src/ActionLoader.phpnu �[��� <?php namespace YOOtheme\Joomla; use Joomla\CMS\Factory; use Joomla\Event\DispatcherInterface; use YOOtheme\Application\EventLoader; use YOOtheme\Container; use YOOtheme\EventDispatcher; /** * @property EventDispatcher|DispatcherInterface $dispatcher */ class ActionLoader extends EventLoader { /** * Constructor. */ public function __construct() { $joomla = Factory::getApplication(); if (version_compare(JVERSION, '5.0', '<')) { $this->dispatcher = new Dispatcher($joomla); } else { $this->dispatcher = $joomla->getDispatcher(); } } /** * Load action listeners. * * @param Container $container * @param array $configs */ public function __invoke(Container $container, array $configs) { if (!$container->has('dispatcher')) { $container->set('dispatcher', $this->dispatcher); } parent::__invoke($container, $configs); } } PK ҙ�\�z�g src/HttpClient.phpnu �[��� <?php namespace YOOtheme\Joomla; use Joomla\CMS\Http\HttpFactory; use Joomla\Registry\Registry; use YOOtheme\Http\Response; use YOOtheme\HttpClientInterface; class HttpClient implements HttpClientInterface { /** * Execute a GET HTTP request. * * @param string $url * @param array $options * * @return Response */ public function get($url, $options = []) { $response = HttpFactory::getHttp(new Registry($options))->get($url); return (new Response($response->code, $response->headers))->write($response->body); } /** * Execute a POST HTTP request. * * @param string $url * @param string $data * @param array $options * * @return Response */ public function post($url, $data = null, $options = []) { $response = HttpFactory::getHttp(new Registry($options))->post($url, $data); return (new Response($response->code, $response->headers))->write($response->body); } /** * Execute a PUT HTTP request. * * @param string $url * @param string $data * @param array $options * * @return Response */ public function put($url, $data = null, $options = []) { $response = HttpFactory::getHttp(new Registry($options))->put($url, $data); return (new Response($response->code, $response->headers))->write($response->body); } /** * Execute a DELETE HTTP request. * * @param string $url * @param array $options * * @return Response */ public function delete($url, $options = []) { $response = HttpFactory::getHttp(new Registry($options))->delete($url); return (new Response($response->code, $response->headers))->write($response->body); } } PK ҙ�\b���D D src/Dispatcher.phpnu �[��� <?php namespace YOOtheme\Joomla; use Joomla\CMS\Application\CMSApplication; use Joomla\Event\Event; use YOOtheme\EventDispatcher; class Dispatcher extends EventDispatcher { /** * @var CMSApplication */ protected $joomla; public static $actions = [ 'onAfterCleanModuleList' => ['modules', 'subject'], 'onBeforeCompileHead' => ['subject', 'document'], 'onContentBeforeSave' => ['context', 'subject'], 'onContentPrepare' => ['context', 'subject', 'params', 'page'], 'onContentPrepareData' => ['context', 'data', 'subject'], 'onContentPrepareForm' => ['subject', 'data'], ]; /** * Constructor. * * @param CMSApplication $joomla */ public function __construct($joomla) { parent::__construct(); $this->joomla = $joomla; } /** * Adds an event listener. * * @param string $event * @param callable $listener * @param int $priority */ public function addListener($event, $listener, $priority = 0) { if (version_compare(JVERSION, '4.0', '>=')) { return $this->joomla ->getDispatcher() ->addListener( $event, fn($event) => $listener($this->prepareArguments($event)), $priority, ); } if (empty($this->listeners[$event])) { if ($event === 'onAfterCleanModuleList') { $handler = fn(&$modules) => $this->dispatch( $event, new Event($event, ['modules' => &$modules]), ); } else { $handler = function (...$arguments) use ($event) { return $this->dispatch( $event, $this->prepareArguments(new Event($event, $arguments)), ); }; } $this->joomla->registerEvent($event, $handler); } parent::addListener($event, $listener, $priority); } protected function prepareArguments($event) { foreach (static::$actions[$event->getName()] ?? [] as $i => $key) { if (!isset($event[$key])) { $event[$key] = $event[$i]; } } return $event; } } PK ҙ�\r�w w src/Platform.phpnu �[��� <?php namespace YOOtheme\Joomla; use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Document\Document; use Joomla\CMS\Document\HtmlDocument; use Joomla\Input\Input; use YOOtheme\Application; use YOOtheme\Arr; use YOOtheme\Http\Exception; use YOOtheme\Http\Request; use YOOtheme\Http\Response; use YOOtheme\Metadata; use YOOtheme\Path; use YOOtheme\Url; class Platform { /** * Handle application routes. */ public static function handleRoute(Application $app, CMSApplication $joomla, Input $input) { if ($input->getCmd('option') !== 'com_ajax' || !$input->get('p')) { return; } $response = null; // disable cache $joomla->set('caching', 0); // default format $input->def('format', 'raw'); // get response $joomla->registerEvent('onAfterDispatch', function () use ($app, &$response, $input) { // On administrator routes com_login is rendered for guest users if ($input->getCmd('option') !== 'com_ajax') { return; } $response = $app->run(false); }); // send response $joomla->registerEvent('onAfterRender', function () use ($joomla, &$response) { if (!$response) { return; } $isHtml = strpos($response->getContentType(), 'html'); if (!$isHtml) { // disable gzip for none html responses like binary images $joomla->set('gzip', false); } if (version_compare(JVERSION, '4.0', '>')) { $joomla->allowCache(true); $joomla->setResponse($isHtml ? $response->write($joomla->getBody()) : $response); return; } // send headers if (!headers_sent()) { $response->sendHeaders(); } // set body for none html responses if (!$isHtml) { $joomla->setBody($response->getBody()); } // set cms headers (fix issue when headers_sent() is still false) if (!headers_sent()) { $joomla->allowCache(true); $joomla->setHeader('Cache-Control', $response->getHeaderLine('Cache-Control')); $joomla->setHeader('Content-Type', $response->getContentType()); } }); } /** * Handle application errors. * * @param Request $request * @param Response $response * @param \Exception $exception * * @throws \Exception * * @return Response */ public static function handleError(Request $request, $response, $exception) { if ($exception instanceof Exception) { if (str_starts_with($request->getHeaderLine('Content-Type'), 'application/json')) { return $response->withJson($exception->getMessage()); } return $response ->write($exception->getMessage()) ->withHeader('Content-Type', 'text/plain'); } throw $exception; } /** * Callback to register assets. * * @param Metadata $metadata * @param Document $document */ public static function registerAssets(Metadata $metadata, Document $document) { if (version_compare(JVERSION, '4.0', '<')) { static::registerAssetsLegacy($metadata, $document); return; } $wa = $document->getWebAssetManager(); // Ensure WebAssetManager is not locked // This might happen if a view is rendered after the documents head has been rendered (e.g. HikaShop renders multiple Views) if (\Closure::bind(fn() => $this->locked, $wa, $wa)()) { return; } foreach ($metadata->all('style:*') as $style) { if ($style->href) { $attrs = Arr::omit($style->getAttributes(), ['version', 'href', 'rel', 'defer']); if ($style->defer && $document instanceof HtmlDocument) { $attrs = array_merge($attrs, [ 'rel' => 'preload', 'as' => 'style', 'onload' => "this.onload=null;this.rel='stylesheet'", ]); } $wa->registerAndUseStyle( $style->getName(), static::toRelativeUrl($style->href), ['version' => $style->version], $attrs, ); } elseif ($value = $style->getValue()) { $wa->addInlineStyle($value, [], Arr::omit($style->getAttributes(), ['version'])); } } foreach ($metadata->all('script:*') as $script) { if ($script->src) { $wa->registerAndUseScript( $script->getName(), static::toRelativeUrl($script->src), ['version' => $script->version], Arr::omit($script->getAttributes(), ['version', 'src']), ); } elseif ($value = $script->getValue()) { $wa->addInlineScript($value, [], Arr::omit($script->getAttributes(), ['version'])); } } } protected static function toRelativeUrl($url) { $url = Path::resolveAlias($url); if (Path::isBasePath(JPATH_ROOT, $url)) { return Path::relative(JPATH_ROOT, $url); } return $url; } /** * Callback to register assets (Joomla 3.x). * * @param Metadata $metadata * @param Document $document */ protected static function registerAssetsLegacy(Metadata $metadata, Document $document) { foreach ($metadata->all('style:*') as $style) { if ($style->href) { $attrs = Arr::omit($style->getAttributes(), ['version', 'href', 'rel', 'defer']); if ($style->defer && $document instanceof HtmlDocument) { $document->addHeadLink( htmlentities(Url::to($style->href, ['ver' => $style->version])), 'preload', 'rel', [ 'as' => 'style', 'onload' => "this.onload=null;this.rel='stylesheet'", ] + $attrs, ); } else { $document->addStyleSheet( htmlentities(Url::to($style->href)), ['version' => $style->version], $attrs, ); } } elseif ($value = $style->getValue()) { $document->addStyleDeclaration($value); } } foreach ($metadata->all('script:*') as $script) { if ($script->src) { $document->addScript( htmlentities(Url::to($script->src)), ['version' => $script->version], Arr::omit($script->getAttributes(), ['version', 'src']), ); } elseif ($value = $script->getValue()) { if ($document instanceof HtmlDocument) { $document->addCustomTag((string) $script->withAttribute('version', '')); } else { $document->addScriptDeclaration($value); } } } } } PK ҙ�\n�|% % bootstrap.phpnu �[��� <?php namespace YOOtheme; use Joomla\CMS\Application\CMSApplication as CMSApp; use Joomla\CMS\Application\SiteApplication as SiteApp; use Joomla\CMS\Document\Document; use Joomla\CMS\Document\HtmlDocument; use Joomla\CMS\Factory; use Joomla\CMS\Language\Language; use Joomla\CMS\Router\Router as JoomlaRouter; use Joomla\CMS\Router\SiteRouter; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; use Joomla\CMS\User\User; use Joomla\DI\Container; use Joomla\Database\DatabaseDriver; use Joomla\Input\Input; use YOOtheme\Joomla\ActionLoader; use YOOtheme\Joomla\Media; use YOOtheme\Joomla\Platform; use YOOtheme\Joomla\Router; Url::setBase(Uri::root(true)); Path::setAlias('~', strtr(JPATH_ROOT, '\\', '/')); return [ 'config' => function () { $joomla = Factory::getApplication(); $normalize = fn($path) => strtr($path, '\\', '/'); return [ 'app' => [ 'platform' => 'joomla', 'version' => JVERSION, 'secret' => (string) $joomla->get('secret'), 'debug' => (bool) $joomla->get('debug'), 'rootDir' => $normalize(JPATH_ROOT), 'tempDir' => $normalize($joomla->get('tmp_path', JPATH_ROOT . '/tmp')), 'adminDir' => $normalize(JPATH_ADMINISTRATOR), 'cacheDir' => $normalize($joomla->get('cache_path', JPATH_ROOT . '/cache')), 'uploadDir' => fn() => Media::getRoot(), 'isSite' => $joomla->isClient('site'), 'isAdmin' => $joomla->isClient('administrator'), ], 'req' => [ 'baseUrl' => Uri::base(true), 'rootUrl' => Uri::root(true), 'siteUrl' => rtrim(Uri::root(), '/'), ], 'locale' => [ 'rtl' => fn() => $joomla->getLanguage()->isRtl(), 'code' => fn() => strtr($joomla->getLanguage()->getTag(), '-', '_'), ], 'session' => [ 'token' => fn() => Session::getFormToken(), ], ]; }, 'events' => [ 'url.route' => [Router::class => 'generate'], 'app.error' => [Platform::class => ['handleError', -50]], ], 'actions' => [ 'onAfterRoute' => [Platform::class => ['handleRoute', -50]], 'onBeforeCompileHead' => [Platform::class => ['registerAssets', -50]], ], 'loaders' => [ 'actions' => ActionLoader::class, ], 'aliases' => [ Document::class => HtmlDocument::class, ], 'services' => array_merge( [ ActionLoader::class => '', CsrfMiddleware::class => fn(Config $config) => new CsrfMiddleware( $config('session.token'), ), HttpClientInterface::class => Joomla\HttpClient::class, Storage::class => Joomla\Storage::class, DatabaseDriver::class => [ 'factory' => fn(Container $container) => $container->get(DatabaseDriver::class), ], SiteApp::class => [ 'factory' => fn(CMSApp $joomla) => $joomla->isClient('site') ? $joomla : null, ], CMSApp::class => ['factory' => fn() => Factory::getApplication()], Container::class => ['factory' => fn() => Factory::getContainer()], Document::class => [ 'shared' => false, 'factory' => fn(CMSApp $joomla) => $joomla->getDocument(), ], Input::class => ['factory' => fn(CMSApp $joomla) => $joomla->input], Language::class => ['factory' => fn(CMSApp $joomla) => $joomla->getLanguage()], Session::class => ['factory' => fn(CMSApp $joomla) => $joomla->getSession()], SiteRouter::class => fn(Container $container) => $container->get(SiteRouter::class), User::class => [ 'shared' => false, 'factory' => fn(CMSApp $joomla) => $joomla->getIdentity(), ], ], version_compare(JVERSION, '4.0', '<') ? [ DatabaseDriver::class => [ 'factory' => function () { // Force autoloading (Type hints do not trigger autoloading) class_exists(DatabaseDriver::class); return Factory::getDbo(); }, ], SiteRouter::class => fn() => JoomlaRouter::getInstance('site'), User::class => ['shared' => false, 'factory' => fn() => Factory::getUser()], ] : [], ), ]; PK ҙ�\ˍ��� � src/Media.phpnu �[��� PK ҙ�\��m� � src/Router.phpnu �[��� PK ҙ�\\�[7\ \ ! src/Storage.phpnu �[��� PK ҙ�\OPH�� � � src/ActionLoader.phpnu �[��� PK ҙ�\�z�g � src/HttpClient.phpnu �[��� PK ҙ�\b���D D 7 src/Dispatcher.phpnu �[��� PK ҙ�\r�w w �&