CoreFiles by mySites.guru
PluginsHelper.php124 lines, 3,368 bytes, from Joomla_6.0.0-Stable-Full_Package.zip
Raw History Compare with 5.4.10
md5
c356a35216ea16fffda41fc70938dbba
sha1
cf27d7db2a3ded8a3a6e9d8bec12217c4dd7cfc2
sha256
3fdebf1b501ddb4ae3fba993484e532a111fc82289665655b15e8c6b57ce6192
<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_plugins
 *
 * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Plugins\Administrator\Helper;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Installer\Installer;
use Joomla\Filesystem\Path;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Plugins component helper.
 *
 * @since  1.6
 */
class PluginsHelper
{
    public static $extension = 'com_plugins';

    /**
     * Returns an array of standard published state filter options.
     *
     * @return  array    The HTML code for the select tag
     */
    public static function publishedOptions()
    {
        // Build the active state filter options.
        $options   = [];
        $options[] = HTMLHelper::_('select.option', '1', 'JENABLED');
        $options[] = HTMLHelper::_('select.option', '0', 'JDISABLED');

        return $options;
    }

    /**
     * Returns a list of folders filter options.
     *
     * @return  object[]   The HTML code for the select tag
     */
    public static function folderOptions()
    {
        $db    = Factory::getDbo();
        $query = $db->createQuery()
            ->select('DISTINCT(folder) AS value, folder AS text')
            ->from('#__extensions')
            ->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
            ->order('folder');

        $db->setQuery($query);

        try {
            $options = $db->loadObjectList();
        } catch (\RuntimeException $e) {
            Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
        }

        return $options;
    }

    /**
     * Returns a list of elements filter options.
     *
     * @return  object[]    The HTML code for the select tag
     */
    public static function elementOptions()
    {
        $db    = Factory::getDbo();
        $query = $db->createQuery()
            ->select('DISTINCT(element) AS value, element AS text')
            ->from('#__extensions')
            ->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
            ->order('element');
        $db->setQuery($query);

        try {
            $options = $db->loadObjectList();
        } catch (\RuntimeException $e) {
            Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
        }

        return $options;
    }

    /**
     * Parse the template file.
     *
     * @param   string  $templateBaseDir  Base path to the template directory.
     * @param   string  $templateDir      Template directory.
     *
     * @return  \stdClass|bool
     */
    public function parseXMLTemplateFile($templateBaseDir, $templateDir)
    {
        $data = new \stdClass();

        // Check of the xml file exists.
        $filePath = Path::clean($templateBaseDir . '/templates/' . $templateDir . '/templateDetails.xml');

        if (is_file($filePath)) {
            $xml = Installer::parseXMLInstallFile($filePath);

            if ($xml['type'] != 'template') {
                return false;
            }

            foreach ($xml as $key => $value) {
                $data->$key = $value;
            }
        }

        return $data;
    }
}

The same content is in 44 releases, Joomla 6.0.0-rc1 to 6.2.1-rc1. See them all, or every version of this file.