home/wuectly/www/libraries/regularlabs/src/Plugin.php000060400000024051152455562070017042 0ustar00 * @link http://www.regularlabs.com * @copyright Copyright © 2021 Regular Labs All Rights Reserved * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ namespace RegularLabs\Library; defined('_JEXEC') or die; use Joomla\CMS\Application\CMSApplication as JCMSApplication; use Joomla\CMS\Factory as JFactory; use Joomla\CMS\Form\Form as JForm; use Joomla\CMS\Language\Text as JText; use Joomla\CMS\Plugin\CMSPlugin as JPlugin; use Joomla\CMS\Plugin\PluginHelper as JPluginHelper; class Plugin extends JPlugin { public $_alias = ''; public $_title = ''; public $_lang_prefix = ''; public $_is_admin = false; public $_has_tags = false; public $_enable_in_frontend = true; public $_enable_in_admin = false; public $_can_disable_by_url = true; public $_disable_on_components = false; public $_protected_formats = []; public $_page_types = []; public $_jversion = 3; private $_pass = null; /** * @var JCMSApplication */ protected $app; /** * @var \JDatabaseDriver */ protected $db; /** * @param object &$subject The object to observe * @param array $config An optional associative array of configuration settings. * Recognized key values include 'name', 'group', 'params', 'language' * (this list is not meant to be comprehensive). */ public function __construct(&$subject, $config = []) { if (isset($config['id'])) { $this->_id = $config['id']; } parent::__construct($subject, $config); $this->app = JFactory::getApplication(); $this->db = JFactory::getDbo(); $this->_is_admin = Document::isAdmin(); if (empty($this->_alias)) { $this->_alias = $this->_name; } if (empty($this->_title)) { $this->_title = strtoupper($this->_alias); } Language::load('plg_' . $this->_type . '_' . $this->_name); } /** * @return void */ public function onAfterRoute() { if ( ! $this->passChecks()) { return; } $this->handleOnAfterRoute(); } /** * @return void */ public function onAfterDispatch() { if ( ! $this->passChecks()) { return; } $this->handleOnAfterDispatch(); $buffer = Document::getBuffer(); $this->loadStylesAndScripts($buffer); if ( ! $buffer) { return; } if ( ! $this->changeDocumentBuffer($buffer)) { return; } Document::setBuffer($buffer); } /** * @return void */ public function onAfterInitialise() { if ( ! $this->passChecks()) { return; } $this->handleOnAfterInitialise(); } /** * @param string $context The context of the content being passed to the plugin. * @param mixed &$row An object with a "text" property * @param mixed &$params Additional parameters. See {@see PlgContentContent()}. * @param integer $page Optional page number. Unused. Defaults to zero. * * @return bool */ public function onContentPrepare($context, &$article, &$params, $page = 0) { if ( ! $this->passChecks()) { return true; } $area = isset($article->created_by) ? 'article' : 'other'; $context = (($params instanceof \JRegistry) && $params->get('rl_search')) ? 'com_search.' . $params->get('readmore_limit') : $context; if ( ! $this->handleOnContentPrepare($area, $context, $article, $params, $page)) { return false; } Article::process($article, $context, $this, 'processArticle', [$area, $context, $article, $page]); return true; } /** * @param JForm $form The form to be altered. * @param mixed $data The associated data for the form. * * @return bool */ public function onContentPrepareForm(JForm $form, $data) { if ( ! $this->passChecks()) { return true; } return $this->handleOnContentPrepareForm($form, $data); } /** * @return void */ public function onAfterRender() { if ( ! $this->passChecks()) { return; } $this->handleOnAfterRender(); $html = $this->app->getBody(); if ($html == '') { return; } if ( ! $this->changeFinalHtmlOutput($html)) { return; } $this->cleanFinalHtmlOutput($html); $this->app->setBody($html); } /** * @return void */ protected function handleOnAfterRoute() { } /** * @return void */ protected function handleOnAfterDispatch() { } /** * @return void */ protected function handleOnAfterInitialise() { } /** * @param string $area * @param string $context The context of the content being passed to the plugin. * @param mixed $article An object with a "text" property * @param mixed &$params Additional parameters. See {@see PlgContentContent()}. * @param int $page Optional page number. Unused. Defaults to zero. * * @return bool */ protected function handleOnContentPrepare($area, $context, &$article, &$params, $page = 0) { return true; } /** * @param JForm $form The form to be altered. * @param mixed $data The associated data for the form. * * @return bool */ protected function handleOnContentPrepareForm(JForm $form, $data) { return true; } /** * @param string $buffer * * @return void */ protected function loadStylesAndScripts(&$buffer) { } /** * @return void * * Consider using changeFinalHtmlOutput instead */ protected function handleOnAfterRender() { } /** * @param string &$string * @param string $area * @param string $context The context of the content being passed to the plugin. * @param mixed $article An object with a "text" property * @param int $page Optional page number. Unused. Defaults to zero. * * @return void */ public function processArticle(&$string, $area = 'article', $context = '', $article = null, $page = 0) { } /** * @param string $buffer * * @return bool */ protected function changeDocumentBuffer(&$buffer) { return false; } /** * @param string $html * * @return bool */ protected function changeFinalHtmlOutput(&$html) { return false; } /** * @param string $html * * @return void */ protected function cleanFinalHtmlOutput(&$html) { } /** * @return bool */ protected function passChecks() { if ( ! is_null($this->_pass)) { return $this->_pass; } $this->_pass = false; if ( ! $this->isFrameworkEnabled()) { return false; } if ( ! $this->passPageTypes()) { return false; } // allow in frontend? if ( ! $this->_enable_in_frontend && ! $this->_is_admin) { return false; } $params = Parameters::getInstance()->getPluginParams($this->_name); // allow in admin? if ( ! $this->_enable_in_admin && $this->_is_admin && ( ! isset($params->enable_admin) || ! $params->enable_admin)) { return false; } // disabled by url? if ($this->_can_disable_by_url && Protect::isDisabledByUrl($this->_alias)) { return false; } // disabled by component? if ($this->_disable_on_components && Protect::isRestrictedComponent(isset($params->disabled_components) ? $params->disabled_components : [], 'component')) { return false; } // restricted page? if (Protect::isRestrictedPage($this->_has_tags, $this->_protected_formats)) { return false; } if ( ! $this->extraChecks()) { return false; } $this->_pass = true; return true; } protected function passPageTypes() { if (empty($this->_page_types)) { return true; } if (in_array('*', $this->_page_types)) { return true; } if (empty(JFactory::$document)) { return true; } if (Document::isFeed()) { return in_array('feed', $this->_page_types); } if (Document::isPDF()) { return in_array('pdf', $this->_page_types); } $page_type = JFactory::getDocument()->getType(); if (in_array($page_type, $this->_page_types)) { return true; } return false; } protected function extraChecks() { $input = JFactory::getApplication()->input; // Disable on Gridbox edit form: option=com_gridbox&view=gridbox if ($input->get('option') == 'com_gridbox' && $input->get('view') == 'gridbox') { return false; } // Disable on SP PageBuilder edit form: option=com_sppagebuilder&view=form if ($input->get('option') == 'com_sppagebuilder' && $input->get('view') == 'form') { return false; } return true; } protected function init() { return; } /** * Check if the Regular Labs Library is enabled * * @return bool */ private function isFrameworkEnabled() { if ( ! defined('REGULAR_LABS_LIBRARY_ENABLED')) { $this->setIsFrameworkEnabled(); } if ( ! REGULAR_LABS_LIBRARY_ENABLED) { $this->throwError('REGULAR_LABS_LIBRARY_NOT_ENABLED'); } return REGULAR_LABS_LIBRARY_ENABLED; } /** * Set the define with whether the Regular Labs Library is enabled */ private function setIsFrameworkEnabled() { if ( ! JPluginHelper::isEnabled('system', 'regularlabs')) { $this->throwError('REGULAR_LABS_LIBRARY_NOT_ENABLED'); define('REGULAR_LABS_LIBRARY_ENABLED', false); return; } define('REGULAR_LABS_LIBRARY_ENABLED', true); } /** * Place an error in the message queue */ protected function throwError($error) { // Return if page is not an admin page or the admin login page if ( ! JFactory::getApplication()->isClient('administrator') || JFactory::getUser()->get('guest') ) { return; } // load the admin language file JFactory::getLanguage()->load('plg_' . $this->_type . '_' . $this->_name, JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name); $text = JText::sprintf($this->_lang_prefix . '_' . $error, JText::_($this->_title)); $text = JText::_($text) . ' ' . JText::sprintf($this->_lang_prefix . '_EXTENSION_CAN_NOT_FUNCTION', JText::_($this->_title)); // Check if message is not already in queue $messagequeue = JFactory::getApplication()->getMessageQueue(); foreach ($messagequeue as $message) { if ($message['message'] == $text) { return; } } JFactory::getApplication()->enqueueMessage($text, 'error'); } } home/wuectly/www/libraries/fof30/Utils/InstallScript/Plugin.php000060400000017263152456041210020554 0ustar00InstallerScript per Joomla's conventions. * * This namespace contains more classes for creating installation scripts for other kinds of Joomla! extensions as well. * Do keep in mind that only components, modules and plugins could have post-installation scripts before Joomla! 3.3. */ class Plugin extends BaseInstaller { /** * The plugins's name, e.g. foobar (for plg_system_foobar). Auto-filled from the class name. * * @var string */ protected $pluginName = ''; /** * The plugins's folder, e.g. system (for plg_system_foobar). Auto-filled from the class name. * * @var string */ protected $pluginFolder = ''; /** * The path where the schema XML files are stored. The path is relative to the folder which contains the extension's * files. * * @var string */ protected $schemaXmlPath = 'sql/xml'; /** * Plugin installer script constructor. */ public function __construct() { // Get the plugin name and folder from the class name (it's always plgFolderPluginInstallerScript) if necessary. if (empty($this->pluginFolder) || empty($this->pluginName)) { $class = get_class($this); $words = preg_replace('/(\s)+/', '_', $class); $words = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $words)); $classParts = explode('_', $words); if (empty($this->pluginFolder)) { $this->pluginFolder = $classParts[1]; } if (empty($this->pluginName)) { $this->pluginName = $classParts[2]; } } } /** * Joomla! pre-flight event. This runs before Joomla! installs or updates the component. This is our last chance to * tell Joomla! if it should abort the installation. * * @param string $type Installation type (install, update, * discover_install) * @param ComponentAdapter $parent Parent object * * @return boolean True to let the installation proceed, false to halt the installation */ public function preflight($type, $parent) { // Check the minimum PHP version if (!$this->checkPHPVersion()) { return false; } // Check the minimum Joomla! version if (!$this->checkJoomlaVersion()) { return false; } // Clear op-code caches to prevent any cached code issues $this->clearOpcodeCaches(); return true; } /** * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing * or updating your component. This is the last chance you've got to perform any additional installations, clean-up, * database updates and similar housekeeping functions. * * @param string $type install, update or discover_update * @param ComponentAdapter $parent Parent object * * @return void * @throws Exception * */ public function postflight($type, $parent) { /** * We are not doing dependency tracking for modules and plugins because of the way Joomla package uninstallation * works. FOF's uninstall() method would get called before the extensions are uninstalled, therefore its * uninstallation would fail and make the entire package uninstallation to fail (the package is impossible to * uninstall). */ // Add ourselves to the list of extensions depending on FOF30 // $this->addDependency('fof30', $this->getDependencyName()); // Install or update database $schemaPath = $parent->getParent()->getPath('source') . '/' . $this->schemaXmlPath; if (@is_dir($schemaPath)) { $dbInstaller = new Installer(Factory::getDbo(), $schemaPath); $dbInstaller->updateSchema(); } // Make sure everything is copied properly $this->bugfixFilesNotCopiedOnUpdate($parent); // Add post-installation messages on Joomla! 3.2 and later $this->_applyPostInstallationMessages(); // Clear the opcode caches again - in case someone accessed the extension while the files were being upgraded. $this->clearOpcodeCaches(); } /** * Runs on uninstallation * * @param ComponentAdapter $parent The parent object */ public function uninstall($parent) { // Uninstall database $schemaPath = $parent->getParent()->getPath('source') . '/' . $this->schemaXmlPath; // Uninstall database if (@is_dir($schemaPath)) { $dbInstaller = new Installer(Factory::getDbo(), $schemaPath); $dbInstaller->removeSchema(); } // Uninstall post-installation messages on Joomla! 3.2 and later $this->uninstallPostInstallationMessages(); /** * We are not doing dependency tracking for modules and plugins because of the way Joomla package uninstallation * works. FOF's uninstall() method would get called before the extensions are uninstalled, therefore its * uninstallation would fail and make the entire package uninstallation to fail (the package is impossible to * uninstall). */ // Remove ourselves from the list of extensions depending on FOF30 // $this->removeDependency('fof30', $this->getDependencyName()); } /** * Fix for Joomla bug: sometimes files are not copied on update. * * We have observed that ever since Joomla! 1.5.5, when Joomla! is performing an extension update some files / * folders are not copied properly. This seems to be a bit random and seems to be more likely to happen the more * added / modified files and folders you have. We are trying to work around it by retrying the copy operation * ourselves WITHOUT going through the manifest, based entirely on the conventions we follow for Akeeba Ltd's * extensions. * * @param ComponentAdapter $parent */ protected function bugfixFilesNotCopiedOnUpdate($parent) { Log::add("Joomla! extension update workaround for $this->pluginFolder plugin $this->pluginName", Log::INFO, 'fof3_extension_installation'); $temporarySource = $parent->getParent()->getPath('source'); $copyMap = [ // Plugin files $temporarySource => JPATH_ROOT . '/plugins/' . $this->pluginFolder . '/' . $this->pluginName, // Language (always stored in administrator for plugins) $temporarySource . '/language' => JPATH_ADMINISTRATOR . '/language', // Media files, e.g. /media/plg_system_foobar $temporarySource . '/media' => JPATH_ROOT . '/media/' . $this->getDependencyName(), ]; foreach ($copyMap as $source => $target) { Log::add(__CLASS__ . ":: Conditional copy $source to $target", Log::DEBUG, 'fof3_extension_installation'); $ignored = []; if ($source == $temporarySource) { $ignored = [ 'index.html', 'index.htm', 'LICENSE.txt', 'license.txt', 'readme.htm', 'readme.html', 'README.md', 'script.php', 'language', 'media', ]; } $this->recursiveConditionalCopy($source, $target, $ignored); } } /** * Get the extension name for FOF dependency tracking, e.g. plg_system_foobar * * @return string */ protected function getDependencyName() { return 'plg_' . strtolower($this->pluginFolder) . '_' . $this->pluginName; } } home/wuectly/www/libraries/fof40/InstallScript/Plugin.php000060400000016775152456047630017500 0ustar00InstallerScript per Joomla's conventions. * * This namespace contains more classes for creating installation scripts for other kinds of Joomla! extensions as well. * Do keep in mind that only components, modules and plugins could have post-installation scripts before Joomla! 3.3. */ class Plugin extends BaseInstaller { /** * The plugins's name, e.g. foobar (for plg_system_foobar). Auto-filled from the class name. * * @var string */ protected $pluginName = ''; /** * The plugins's folder, e.g. system (for plg_system_foobar). Auto-filled from the class name. * * @var string */ protected $pluginFolder = ''; /** * The path where the schema XML files are stored. The path is relative to the folder which contains the extension's * files. * * @var string */ protected $schemaXmlPath = 'sql/xml'; /** * Plugin installer script constructor. */ public function __construct() { // Get the plugin name and folder from the class name (it's always plgFolderPluginInstallerScript) if necessary. if (empty($this->pluginFolder) || empty($this->pluginName)) { $class = get_class($this); $words = preg_replace('/(\s)+/', '_', $class); $words = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $words)); $classParts = explode('_', $words); if (empty($this->pluginFolder)) { $this->pluginFolder = $classParts[1]; } if (empty($this->pluginName)) { $this->pluginName = $classParts[2]; } } } /** * Joomla! pre-flight event. This runs before Joomla! installs or updates the component. This is our last chance to * tell Joomla! if it should abort the installation. * * @param string $type Installation type (install, update, discover_install) * @param PluginAdapter $parent Parent object * * @return boolean True to let the installation proceed, false to halt the installation * @noinspection PhpUnusedParameterInspection */ public function preflight(string $type, PluginAdapter $parent): bool { // Do not run on uninstall. if ($type === 'uninstall') { return true; } // Check the minimum PHP version if (!$this->checkPHPVersion()) { return false; } // Check the minimum Joomla! version if (!$this->checkJoomlaVersion()) { return false; } // Clear op-code caches to prevent any cached code issues $this->clearOpcodeCaches(); return true; } /** * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing * or updating your component. This is the last chance you've got to perform any additional installations, clean-up, * database updates and similar housekeeping functions. * * @param string $type install, update or discover_update * @param PluginAdapter $parent Parent object * * @return void * @throws Exception * */ public function postflight(string $type, PluginAdapter $parent): void { // Do not run on uninstall. if ($type === 'uninstall') { return; } // Add ourselves to the list of extensions depending on FOF40 $dependencyName = $this->getDependencyName(); $this->addDependency('fof40', $dependencyName); $this->removeDependency('fof30', $dependencyName); // Install or update database $schemaPath = $parent->getParent()->getPath('source') . '/' . $this->schemaXmlPath; if (@is_dir($schemaPath)) { $dbInstaller = new Installer(JoomlaFactory::getDbo(), $schemaPath); $dbInstaller->updateSchema(); } // Make sure everything is copied properly $this->bugfixFilesNotCopiedOnUpdate($parent); // Add post-installation messages on Joomla! 3.2 and later $this->_applyPostInstallationMessages(); // Clear the opcode caches again - in case someone accessed the extension while the files were being upgraded. $this->clearOpcodeCaches(); // Finally, see if FOF 3.x is obsolete and remove it. // $this->uninstallFOF3IfNecessary(); } /** * Runs on uninstallation * * @param PluginAdapter $parent The parent object */ public function uninstall(PluginAdapter $parent): void { // Uninstall database $schemaPath = $parent->getParent()->getPath('source') . '/' . $this->schemaXmlPath; // Uninstall database if (@is_dir($schemaPath)) { $dbInstaller = new Installer(JoomlaFactory::getDbo(), $schemaPath); $dbInstaller->removeSchema(); } // Uninstall post-installation messages on Joomla! 3.2 and later $this->uninstallPostInstallationMessages(); // Remove ourselves from the list of extensions depending on FOF40 $dependencyName = $this->getDependencyName(); // Remove ourselves from the list of extensions depending of FOF 4 $this->removeDependency('fof40', $dependencyName); // Uninstall FOF 4 if nothing else depends on it $this->uninstallFOF4IfNecessary(); } /** * Fix for Joomla bug: sometimes files are not copied on update. * * We have observed that ever since Joomla! 1.5.5, when Joomla! is performing an extension update some files / * folders are not copied properly. This seems to be a bit random and seems to be more likely to happen the more * added / modified files and folders you have. We are trying to work around it by retrying the copy operation * ourselves WITHOUT going through the manifest, based entirely on the conventions we follow for Akeeba Ltd's * extensions. * * @param PluginAdapter $parent */ protected function bugfixFilesNotCopiedOnUpdate(PluginAdapter $parent): void { Log::add("Joomla! extension update workaround for $this->pluginFolder plugin $this->pluginName", Log::INFO, 'fof4_extension_installation'); $temporarySource = $parent->getParent()->getPath('source'); $copyMap = [ // Plugin files $temporarySource => JPATH_ROOT . '/plugins/' . $this->pluginFolder . '/' . $this->pluginName, // Language (always stored in administrator for plugins) $temporarySource . '/language' => JPATH_ADMINISTRATOR . '/language', // Media files, e.g. /media/plg_system_foobar $temporarySource . '/media' => JPATH_ROOT . '/media/' . $this->getDependencyName(), ]; foreach ($copyMap as $source => $target) { Log::add(__CLASS__ . ":: Conditional copy $source to $target", Log::DEBUG, 'fof4_extension_installation'); $ignored = []; if ($source === $temporarySource) { $ignored = [ 'index.html', 'index.htm', 'LICENSE.txt', 'license.txt', 'readme.htm', 'readme.html', 'README.md', 'script.php', 'language', 'media', ]; } $this->recursiveConditionalCopy($source, $target, $ignored); } } /** * Get the extension name for FOF dependency tracking, e.g. plg_system_foobar * * @return string */ protected function getDependencyName(): string { return 'plg_' . strtolower($this->pluginFolder) . '_' . $this->pluginName; } } home/wuectly/www/plugins/system/tabs/src/Plugin.php000060400000020370152457410210016507 0ustar00 * @link http://www.regularlabs.com * @copyright Copyright © 2020 Regular Labs All Rights Reserved * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ /* * This class is used as template (extend) for most Regular Labs plugins * This class is not placed in the Regular Labs Library as a re-usable class because * it also needs to be working when the Regular Labs Library is not installed */ namespace RegularLabs\Plugin\System\Tabs; defined('_JEXEC') or die; if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php')) { require_once JPATH_LIBRARIES . '/regularlabs/autoload.php'; } use Joomla\CMS\Factory as JFactory; use Joomla\CMS\Installer\Installer as JInstaller; use Joomla\CMS\Language\Text as JText; use Joomla\CMS\Plugin\CMSPlugin as JPlugin; use Joomla\CMS\Plugin\PluginHelper as JPluginHelper; use ReflectionMethod; use RegularLabs\Library\Document as RL_Document; use RegularLabs\Library\Language as RL_Language; use RegularLabs\Library\Protect as RL_Protect; class Plugin extends JPlugin { public $_alias = ''; public $_title = ''; public $_lang_prefix = ''; public $_has_tags = false; public $_enable_in_frontend = true; public $_enable_in_admin = false; public $_can_disable_by_url = true; public $_disable_on_components = false; public $_protected_formats = []; public $_page_types = []; private $_init = false; private $_pass = null; private $_helper = null; protected function run() { if ( ! $this->passChecks()) { return false; } if ( ! $this->getHelper()) { return false; } $caller = debug_backtrace()[1]; if (empty($caller)) { return false; } $event = $caller['function']; if ( ! method_exists($this->_helper, $event)) { return false; } $reflect = new ReflectionMethod($this->_helper, $event); $parameters = $reflect->getParameters(); $arguments = []; // Check if arguments should be passed as reference or not foreach ($parameters as $count => $parameter) { if ($parameter->isPassedByReference()) { $arguments[] = &$caller['args'][$count]; continue; } $arguments[] = $caller['args'][$count]; } // Work-around for K2 stuff :( if ($event == 'onContentPrepare' && empty($arguments[1]->id) && strpos($arguments[0], 'com_k2') === 0 ) { return false; } return call_user_func_array([$this->_helper, $event], $arguments); } /** * Create the helper object * * @return object|null The plugins helper object */ private function getHelper() { // Already initialized, so return if ($this->_init) { return $this->_helper; } $this->_init = true; RL_Language::load('plg_' . $this->_type . '_' . $this->_name); $this->init(); $this->_helper = new Helper; return $this->_helper; } private function passChecks() { if ( ! is_null($this->_pass)) { return $this->_pass; } $this->_pass = false; if ( ! $this->isFrameworkEnabled()) { return false; } if ( ! self::passPageTypes()) { return false; } // allow in frontend? if ( ! $this->_enable_in_frontend && ! RL_Document::isAdmin()) { return false; } // allow in admin? if ( ! $this->_enable_in_admin && RL_Document::isAdmin() && ( ! isset(Params::get()->enable_admin) || ! Params::get()->enable_admin)) { return false; } // disabled by url? if ($this->_can_disable_by_url && RL_Protect::isDisabledByUrl($this->_alias)) { return false; } // disabled by component? if ($this->_disable_on_components && RL_Protect::isRestrictedComponent(isset(Params::get()->disabled_components) ? Params::get()->disabled_components : [], 'component')) { return false; } // restricted page? if (RL_Protect::isRestrictedPage($this->_has_tags, $this->_protected_formats)) { return false; } if ( ! $this->extraChecks()) { return false; } $this->_pass = true; return true; } public function passPageTypes() { if (empty($this->_page_types)) { return true; } if (in_array('*', $this->_page_types)) { return true; } if (empty(JFactory::$document)) { return true; } if (RL_Document::isFeed()) { return in_array('feed', $this->_page_types); } if (RL_Document::isPDF()) { return in_array('pdf', $this->_page_types); } $page_type = JFactory::getDocument()->getType(); if (in_array($page_type, $this->_page_types)) { return true; } return false; } public function extraChecks() { $input = JFactory::getApplication()->input; // Disable on Gridbox edit form: option=com_gridbox&view=gridbox if ($input->get('option') == 'com_gridbox' && $input->get('view') == 'gridbox') { return false; } // Disable on SP PageBuilder edit form: option=com_sppagebuilder&view=form if ($input->get('option') == 'com_sppagebuilder' && $input->get('view') == 'form') { return false; } return true; } public function init() { return; } /** * Check if the Regular Labs Library is enabled * * @return bool */ private function isFrameworkEnabled() { if ( ! defined('REGULAR_LABS_LIBRARY_ENABLED')) { $this->setIsFrameworkEnabled(); } if ( ! REGULAR_LABS_LIBRARY_ENABLED) { $this->throwError('REGULAR_LABS_LIBRARY_NOT_ENABLED'); } return REGULAR_LABS_LIBRARY_ENABLED; } /** * Set the define with whether the Regular Labs Library is enabled */ private function setIsFrameworkEnabled() { // Return false if Regular Labs Library is not installed if ( ! $this->isFrameworkInstalled()) { define('REGULAR_LABS_LIBRARY_ENABLED', false); return; } if ( ! JPluginHelper::isEnabled('system', 'regularlabs')) { $this->throwError('REGULAR_LABS_LIBRARY_NOT_ENABLED'); define('REGULAR_LABS_LIBRARY_ENABLED', false); return; } define('REGULAR_LABS_LIBRARY_ENABLED', true); } /** * Check if the Regular Labs Library is installed * * @return bool */ private function isFrameworkInstalled() { if ( ! defined('REGULAR_LABS_LIBRARY_INSTALLED')) { $this->setIsFrameworkInstalled(); } switch (REGULAR_LABS_LIBRARY_INSTALLED) { case 'outdated': $this->throwError('REGULAR_LABS_LIBRARY_OUTDATED'); return false; case 'no': $this->throwError('REGULAR_LABS_LIBRARY_NOT_INSTALLED'); return false; case 'yes': default: return true; } } /** * set the define with whether the Regular Labs Library is installed */ private function setIsFrameworkInstalled() { if ( ! is_file(JPATH_PLUGINS . '/system/regularlabs/regularlabs.xml') || ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php') ) { define('REGULAR_LABS_LIBRARY_INSTALLED', 'no'); return; } $plugin = JInstaller::parseXMLInstallFile(JPATH_PLUGINS . '/system/regularlabs/regularlabs.xml'); $library = JInstaller::parseXMLInstallFile(JPATH_LIBRARIES . '/regularlabs/regularlabs.xml'); if (empty($plugin) || empty($library)) { define('REGULAR_LABS_LIBRARY_INSTALLED', 'no'); return; } if (version_compare($plugin['version'], '20.6.16076', '<') || version_compare($library['version'], '20.6.16076', '<')) { define('REGULAR_LABS_LIBRARY_INSTALLED', 'outdated'); return; } define('REGULAR_LABS_LIBRARY_INSTALLED', 'yes'); } /** * Place an error in the message queue */ private function throwError($error) { // Return if page is not an admin page or the admin login page if ( ! JFactory::getApplication()->isClient('administrator') || JFactory::getUser()->get('guest') ) { return; } // load the admin language file JFactory::getLanguage()->load('plg_' . $this->_type . '_' . $this->_name, JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name); $text = JText::sprintf($this->_lang_prefix . '_' . $error, JText::_($this->_title)); $text = JText::_($text) . ' ' . JText::sprintf($this->_lang_prefix . '_EXTENSION_CAN_NOT_FUNCTION', JText::_($this->_title)); // Check if message is not already in queue $messagequeue = JFactory::getApplication()->getMessageQueue(); foreach ($messagequeue as $message) { if ($message['message'] == $text) { return; } } JFactory::getApplication()->enqueueMessage($text, 'error'); } }