NexusLeads Webshell
NexusLeads


Server : LiteSpeed
System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64
User : alsaif ( 1057)
PHP Version : 7.4.33
Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/alsaif/domains/alsaif.group/public_html/libraries/regularlabs/fields/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/alsaif/domains/alsaif.group/public_html/libraries/regularlabs/fields/components.php
<?php
/**
 * @package         Regular Labs Library
 * @version         23.9.3039
 * 
 * @author          Peter van Westen <info@regularlabs.com>
 * @link            https://regularlabs.com
 * @copyright       Copyright © 2023 Regular Labs All Rights Reserved
 * @license         GNU General Public License version 2 or later
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\Registry\Registry;
use RegularLabs\Library\Field;
use RegularLabs\Library\RegEx as RL_RegEx;

if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
    return;
}

require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';

class JFormFieldRL_Components extends Field
{
    public $type = 'Components';

    public function getAjaxRaw(Registry $attributes)
    {
        $name  = $attributes->get('name', $this->type);
        $id    = $attributes->get('id', strtolower($name));
        $value = $attributes->get('value', []);
        $size  = $attributes->get('size');

        $options = $this->getComponents();

        return $this->selectListSimple($options, $name, $value, $id, $size, true, true);
    }

    public function getComponents()
    {
        $frontend = $this->get('frontend', 1);
        $admin    = $this->get('admin', 1);

        if ( ! $frontend && ! $admin)
        {
            return [];
        }

        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');

        $query = $this->db->getQuery(true)
            ->select('e.name, e.element')
            ->from('#__extensions AS e')
            ->where('e.type = ' . $this->db->quote('component'))
            ->where('e.name != ""')
            ->where('e.element != ""')
            ->group('e.element')
            ->order('e.element, e.name');
        $this->db->setQuery($query);
        $components = $this->db->loadObjectList();

        $comps = [];
        $lang  = JFactory::getLanguage();

        foreach ($components as $i => $component)
        {
            if (empty($component->element))
            {
                continue;
            }

            $component_folder = ($frontend ? JPATH_SITE : JPATH_ADMINISTRATOR) . '/components/' . $component->element;

            if ( ! JFolder::exists($component_folder) && $admin)
            {
                $component_folder = JPATH_ADMINISTRATOR . '/components/' . $component->element;
            }

            // return if there is no main component folder
            if ( ! JFolder::exists($component_folder))
            {
                continue;
            }

            // return if there is no view(s) folder
            if ( ! JFolder::exists($component_folder . '/views') && ! JFolder::exists($component_folder . '/view'))
            {
                continue;
            }

            if (strpos($component->name, ' ') === false)
            {
                // Load the core file then
                // Load extension-local file.
                $lang->load($component->element . '.sys', JPATH_BASE, null, false, false)
                || $lang->load($component->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $component->element, null, false, false)
                || $lang->load($component->element . '.sys', JPATH_BASE, $lang->getDefault(), false, false)
                || $lang->load($component->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $component->element, $lang->getDefault(), false, false);

                $component->name = JText::_(strtoupper($component->name));
            }

            $comps[RL_RegEx::replace('[^a-z0-9_]', '', $component->name . '_' . $component->element)] = $component;
        }

        ksort($comps);

        $options = [];

        foreach ($comps as $component)
        {
            $options[] = JHtml::_('select.option', $component->element, $component->name);
        }

        return $options;
    }

    protected function getInput()
    {
        $size = (int) $this->get('size');

        return $this->selectListSimpleAjax(
            $this->type, $this->name, $this->value, $this->id,
            compact('size')
        );
    }
}

NexusLeads