Spade

Mini Shell

Directory:~$ /home/lmsyaran/www/khsh/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/www/khsh/fields.tar

consentbox.php000064400000015164151170256170007453 0ustar00<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Content.confirmconsent
 *
 * @copyright   (C) 2018 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

JFormHelper::loadFieldClass('Checkboxes');

/**
 * Consentbox Field class for the Confirm Consent Plugin.
 *
 * @since  3.9.1
 */
class JFormFieldConsentBox extends JFormFieldCheckboxes
{
	/**
	 * The form field type.
	 *
	 * @var    string
	 * @since  3.9.1
	 */
	protected $type = 'ConsentBox';

	/**
	 * Flag to tell the field to always be in multiple values mode.
	 *
	 * @var    boolean
	 * @since  3.9.1
	 */
	protected $forceMultiple = false;

	/**
	 * The article ID.
	 *
	 * @var    integer
	 * @since  3.9.1
	 */
	protected $articleid;

	/**
	 * Method to set certain otherwise inaccessible properties of the form
field object.
	 *
	 * @param   string  $name   The property name for which to set the value.
	 * @param   mixed   $value  The value of the property.
	 *
	 * @return  void
	 *
	 * @since   3.9.1
	 */
	public function __set($name, $value)
	{
		switch ($name)
		{
			case 'articleid':
				$this->articleid = (int) $value;
				break;

			default:
				parent::__set($name, $value);
		}
	}

	/**
	 * Method to get certain otherwise inaccessible properties from the form
field object.
	 *
	 * @param   string  $name  The property name for which to get the value.
	 *
	 * @return  mixed  The property value or null.
	 *
	 * @since   3.9.1
	 */
	public function __get($name)
	{
		switch ($name)
		{
			case 'articleid':
				return $this->$name;
		}

		return parent::__get($name);
	}

	/**
	 * Method to attach a JForm object to the field.
	 *
	 * @param   SimpleXMLElement  $element  The SimpleXMLElement object
representing the `<field>` tag for the form field object.
	 * @param   mixed             $value    The form field value to validate.
	 * @param   string            $group    The field name group control
value. This acts as an array container for the field.
	 *                                      For example if the field has
name="foo" and the group value is set to "bar" then the
	 *                                      full field name would end up being
"bar[foo]".
	 *
	 * @return  boolean  True on success.
	 *
	 * @see     JFormField::setup()
	 * @since   3.9.1
	 */
	public function setup(SimpleXMLElement $element, $value, $group = null)
	{
		$return = parent::setup($element, $value, $group);

		if ($return)
		{
			$this->articleid = (int) $this->element['articleid'];
		}

		return $return;
	}

	/**
	 * Method to get the field label markup.
	 *
	 * @return  string  The field label markup.
	 *
	 * @since   3.9.1
	 */
	protected function getLabel()
	{
		if ($this->hidden)
		{
			return '';
		}

		$data = $this->getLayoutData();

		// Forcing the Alias field to display the tip below
		$position = $this->element['name'] == 'alias' ?
' data-placement="bottom" ' : '';

		// When we have an article let's add the modal and make the title
clickable
		if ($data['articleid'])
		{
			$attribs['data-toggle'] = 'modal';

			$data['label'] = HTMLHelper::_(
				'link',
				'#modal-' . $this->id,
				$data['label'],
				$attribs
			);
		}

		// Here mainly for B/C with old layouts. This can be done in the layouts
directly
		$extraData = array(
			'text'     => $data['label'],
			'for'      => $this->id,
			'classes'  => explode(' ',
$data['labelclass']),
			'position' => $position,
		);

		return
$this->getRenderer($this->renderLabelLayout)->render(array_merge($data,
$extraData));
	}

	/**
	 * Method to get the field input markup.
	 *
	 * @return  string  The field input markup.
	 *
	 * @since   3.9.2
	 */
	protected function getInput()
	{
		$modalHtml  = '';
		$layoutData = $this->getLayoutData();

		if ($this->articleid)
		{
			$modalParams['title']  = $layoutData['label'];
			$modalParams['url']    = $this->getAssignedArticleUrl();
			$modalParams['height'] = 800;
			$modalParams['width']  = '100%';
			$modalHtml = HTMLHelper::_('bootstrap.renderModal',
'modal-' . $this->id, $modalParams);
		}

		return $modalHtml . parent::getInput();
	}

	/**
	 * Method to get the data to be passed to the layout for rendering.
	 *
	 * @return  array
	 *
	 * @since   3.9.1
	 */
	protected function getLayoutData()
	{
		$data = parent::getLayoutData();

		$extraData = array(
			'articleid' => (integer) $this->articleid,
		);

		return array_merge($data, $extraData);
	}

	/**
	 * Return the url of the assigned article based on the current user
language
	 *
	 * @return  string  Returns the link to the article
	 *
	 * @since   3.9.1
	 */
	private function getAssignedArticleUrl()
	{
		$db = Factory::getDbo();

		// Get the info from the article
		$query = $db->getQuery(true)
			->select($db->quoteName(array('id', 'catid',
'language')))
			->from($db->quoteName('#__content'))
			->where($db->quoteName('id') . ' = ' . (int)
$this->articleid);
		$db->setQuery($query);

		try
		{
			$article = $db->loadObject();
		}
		catch (JDatabaseExceptionExecuting $e)
		{
			// Something at the database layer went wrong
			return Route::_(
				'index.php?option=com_content&view=article&id='
				. $this->articleid . '&tmpl=component'
			);
		}

		if (!is_object($article))
		{
			// We have not found the article object lets show a 404 to the user
			return Route::_(
				'index.php?option=com_content&view=article&id='
				. $this->articleid . '&tmpl=component'
			);
		}

		// Register ContentHelperRoute
		JLoader::register('ContentHelperRoute', JPATH_BASE .
'/components/com_content/helpers/route.php');

		if (!Associations::isEnabled())
		{
			return Route::_(
				ContentHelperRoute::getArticleRoute(
					$article->id,
					$article->catid,
					$article->language
				) . '&tmpl=component'
			);
		}

		$associatedArticles =
Associations::getAssociations('com_content',
'#__content', 'com_content.item', $article->id);
		$currentLang        = Factory::getLanguage()->getTag();

		if (isset($associatedArticles) && $currentLang !==
$article->language && array_key_exists($currentLang,
$associatedArticles))
		{
			return Route::_(
				ContentHelperRoute::getArticleRoute(
					$associatedArticles[$currentLang]->id,
					$associatedArticles[$currentLang]->catid,
					$associatedArticles[$currentLang]->language
				) . '&tmpl=component'
			);
		}

		// Association is enabled but this article is not associated
		return Route::_(
			'index.php?option=com_content&view=article&id='
				. $article->id . '&catid=' . $article->catid
				. '&tmpl=component&lang=' . $article->language
		);
	}
}
fields.xml000064400000001676151170300120006534 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="content"
method="upgrade">
	<name>plg_content_fields</name>
	<author>Joomla! Project</author>
	<creationDate>2017-02</creationDate>
	<copyright>(C) 2017 Open Source Matters, Inc.</copyright>
	<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
	<authorEmail>admin@joomla.org</authorEmail>
	<authorUrl>www.joomla.org</authorUrl>
	<version>3.7.0</version>
	<description>PLG_CONTENT_FIELDS_XML_DESCRIPTION</description>
	<namespace
path="src">Joomla\Plugin\Content\Fields</namespace>
	<files>
		<folder plugin="fields">services</folder>
		<folder>src</folder>
	</files>
	<languages>
		<language
tag="en-GB">language/en-GB/plg_content_fields.ini</language>
		<language
tag="en-GB">language/en-GB/plg_content_fields.sys.ini</language>
	</languages>
	<config>
		<fields name="params">
			<fieldset name="basic">
			</fieldset>
		</fields>
	</config>
</extension>
services/provider.php000064400000002234151170300120010721 0ustar00<?php

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

\defined('_JEXEC') or die;

use Joomla\CMS\Extension\PluginInterface;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Content\Fields\Extension\Fields;

return new class () implements ServiceProviderInterface {
    /**
     * Registers the service provider with a DI container.
     *
     * @param   Container  $container  The DI container.
     *
     * @return  void
     *
     * @since   4.3.0
     */
    public function register(Container $container)
    {
        $container->set(
            PluginInterface::class,
            function (Container $container) {
                $plugin     = new Fields(
                    $container->get(DispatcherInterface::class),
                    (array) PluginHelper::getPlugin('content',
'fields')
                );

                return $plugin;
            }
        );
    }
};
src/Extension/Fields.php000064400000012576151170300120011227
0ustar00<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  Content.fields
 *
 * @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\Plugin\Content\Fields\Extension;

use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

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

/**
 * Plug-in to show a custom field in eg an article
 * This uses the {fields ID} syntax
 *
 * @since  3.7.0
 */
final class Fields extends CMSPlugin
{
    /**
     * Plugin that shows a custom field
     *
     * @param   string  $context  The context of the content being passed
to the plugin.
     * @param   object  &$item    The item object.  Note
$article->text is also available
     * @param   object  &$params  The article params
     * @param   int     $page     The 'page' number
     *
     * @return void
     *
     * @since  3.7.0
     */
    public function onContentPrepare($context, &$item, &$params,
$page = 0)
    {
        // If the item has a context, overwrite the existing one
        if ($context === 'com_finder.indexer' &&
!empty($item->context)) {
            $context = $item->context;
        } elseif ($context === 'com_finder.indexer') {
            // Don't run this plugin when the content is being indexed
and we have no real context
            return;
        }

        // This plugin only works if $item is an object
        if (!\is_object($item)) {
            return;
        }

        // Don't run if there is no text property (in case of bad
calls) or it is empty
        if (!property_exists($item, 'text') ||
empty($item->text)) {
            return;
        }

        // Prepare the text
        if (property_exists($item, 'text') &&
strpos($item->text, 'field') !== false) {
            $item->text = $this->prepare($item->text, $context,
$item);
        }

        // Prepare the intro text
        if (property_exists($item, 'introtext') &&
\is_string($item->introtext) && strpos($item->introtext,
'field') !== false) {
            $item->introtext = $this->prepare($item->introtext,
$context, $item);
        }

        // Prepare the full text
        if (!empty($item->fulltext) &&
strpos($item->fulltext, 'field') !== false) {
            $item->fulltext = $this->prepare($item->fulltext,
$context, $item);
        }
    }

    /**
     * Prepares the given string by parsing {field} and {fieldgroup} groups
and replacing them.
     *
     * @param   string  $string   The text to prepare
     * @param   string  $context  The context of the content
     * @param   object  $item     The item object
     *
     * @return string
     *
     * @since  3.8.1
     */
    private function prepare($string, $context, $item)
    {
        // Search for {field ID} or {fieldgroup ID} tags and put the
results into $matches.
        $regex = '/{(field|fieldgroup)\s+(.*?)}/i';
        preg_match_all($regex, $string, $matches, PREG_SET_ORDER);

        if (!$matches) {
            return $string;
        }

        $parts = FieldsHelper::extract($context);

        if (!$parts || \count($parts) < 2) {
            return $string;
        }

        $context    = $parts[0] . '.' . $parts[1];
        $fields     = FieldsHelper::getFields($context, $item, true);
        $fieldsById = [];
        $groups     = [];

        // Rearranging fields in arrays for easier lookup later.
        foreach ($fields as $field) {
            $fieldsById[$field->id]     = $field;
            $groups[$field->group_id][] = $field;
        }

        foreach ($matches as $i => $match) {
            // $match[0] is the full pattern match, $match[1] is the type
(field or fieldgroup) and $match[2] the ID and optional the layout
            $explode = explode(',', $match[2]);
            $id      = (int) $explode[0];
            $output  = '';

            if ($match[1] === 'field' && $id) {
                if (isset($fieldsById[$id])) {
                    $layout = !empty($explode[1]) ? trim($explode[1]) :
$fieldsById[$id]->params->get('layout',
'render');
                    $output = FieldsHelper::render(
                        $context,
                        'field.' . $layout,
                        [
                            'item'    => $item,
                            'context' => $context,
                            'field'   => $fieldsById[$id],
                        ]
                    );
                }
            } else {
                if ($match[2] === '*') {
                    $match[0]     = str_replace('*',
'\*', $match[0]);
                    $renderFields = $fields;
                } else {
                    $renderFields = $groups[$id] ?? '';
                }

                if ($renderFields) {
                    $layout = !empty($explode[1]) ? trim($explode[1]) :
'render';
                    $output = FieldsHelper::render(
                        $context,
                        'fields.' . $layout,
                        [
                            'item'    => $item,
                            'context' => $context,
                            'fields'  => $renderFields,
                        ]
                    );
                }
            }

            $string = preg_replace("|$match[0]|",
addcslashes($output, '\\$'), $string, 1);
        }

        return $string;
    }
}