Server IP : 195.201.23.43 / Your IP : 18.119.140.150 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/kdecoratie/public_html/libraries/src/Helper/ |
Upload File : |
<?php /** * Joomla! Content Management System * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Helper; defined('JPATH_PLATFORM') or die; use Joomla\Registry\Registry; /** * Library helper class * * @since 3.2 */ class LibraryHelper { /** * The component list cache * * @var array * @since 3.2 */ protected static $libraries = array(); /** * Get the library information. * * @param string $element Element of the library in the extensions table. * @param boolean $strict If set and the library does not exist, the enabled attribute will be set to false. * * @return \stdClass An object with the library's information. * * @since 3.2 */ public static function getLibrary($element, $strict = false) { // Is already cached? if (isset(static::$libraries[$element]) || static::loadLibrary($element)) { $result = static::$libraries[$element]; // Convert the params to an object. if (is_string($result->params)) { $result->params = new Registry($result->params); } } else { $result = new \stdClass; $result->enabled = $strict ? false : true; $result->params = new Registry; } return $result; } /** * Checks if a library is enabled * * @param string $element Element of the library in the extensions table. * * @return boolean * * @since 3.2 */ public static function isEnabled($element) { return static::getLibrary($element, true)->enabled; } /** * Gets the parameter object for the library * * @param string $element Element of the library in the extensions table. * @param boolean $strict If set and the library does not exist, false will be returned * * @return Registry A Registry object. * * @see Registry * @since 3.2 */ public static function getParams($element, $strict = false) { return static::getLibrary($element, $strict)->params; } /** * Save the parameters object for the library * * @param string $element Element of the library in the extensions table. * @param Registry $params Params to save * * @return Registry A Registry object. * * @see Registry * @since 3.2 */ public static function saveParams($element, $params) { if (static::isEnabled($element)) { // Save params in DB $db = \JFactory::getDbo(); $query = $db->getQuery(true) ->update($db->quoteName('#__extensions')) ->set($db->quoteName('params') . ' = ' . $db->quote($params->toString())) ->where($db->quoteName('type') . ' = ' . $db->quote('library')) ->where($db->quoteName('element') . ' = ' . $db->quote($element)); $db->setQuery($query); $result = $db->execute(); // Update params in libraries cache if ($result && isset(static::$libraries[$element])) { static::$libraries[$element]->params = $params; } return $result; } return false; } /** * Load the installed library into the libraries property. * * @param string $element The element value for the extension * * @return boolean True on success * * @since 3.2 * @deprecated 4.0 Use LibraryHelper::loadLibrary() instead */ protected static function _load($element) { return static::loadLibrary($element); } /** * Load the installed library into the libraries property. * * @param string $element The element value for the extension * * @return boolean True on success * * @since 3.7.0 */ protected static function loadLibrary($element) { $loader = function($element) { $db = \JFactory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName(array('extension_id', 'element', 'params', 'enabled'), array('id', 'option', null, null))) ->from($db->quoteName('#__extensions')) ->where($db->quoteName('type') . ' = ' . $db->quote('library')) ->where($db->quoteName('element') . ' = ' . $db->quote($element)); $db->setQuery($query); return $db->loadObject(); }; /** @var \JCacheControllerCallback $cache */ $cache = \JFactory::getCache('_system', 'callback'); try { static::$libraries[$element] = $cache->get($loader, array($element), __METHOD__ . $element); } catch (\JCacheException $e) { static::$libraries[$element] = $loader($element); } if (empty(static::$libraries[$element])) { // Fatal error. $error = \JText::_('JLIB_APPLICATION_ERROR_LIBRARY_NOT_FOUND'); \JLog::add(\JText::sprintf('JLIB_APPLICATION_ERROR_LIBRARY_NOT_LOADING', $element, $error), \JLog::WARNING, 'jerror'); return false; } return true; } }Private