Spade

Mini Shell

Directory:~$ /home/lmsyaran/public_html/joomla4/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/public_html/joomla4/repeatable.zip

PK�H�[�w�R�	�	params/repeatable.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<form>
	<fields name="fieldparams">
		<fieldset name="fieldparams">
			<field
				name="fields"
				type="subform"
				label="PLG_FIELDS_REPEATABLE_PARAMS_FIELDS_LABEL"
				description="PLG_FIELDS_REPEATABLE_PARAMS_FIELDS_DESC"
				multiple="true">
				<form>
					<fields>
						<fieldset>
							<field
								name="fieldname"
								type="text"
								label="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_NAME_LABEL"
								description="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_NAME_DESC"
								required="true"
							/>
							<field
								name="fieldtype"
								type="list"
								label="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_LABEL"
								description="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_DESC"
								>
								<option
value="editor">PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_EDITOR</option>
								<option
value="media">PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_MEDIA</option>
								<option
value="number">PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_NUMBER</option>
								<option
value="text">PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_TEXT</option>
								<option
value="textarea">PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_TEXTAREA</option>
							</field>
							<field
								name="fieldfilter"
								type="list"
								label="PLG_FIELDS_TEXT_PARAMS_FILTER_LABEL"
								description="PLG_FIELDS_TEXT_PARAMS_FILTER_DESC"
								class="btn-group"
								validate="options"
								showon="fieldtype!:media,number"
								>
								<option value="0">JNO</option>
								<option
									showon="fieldtype:editor,text,textarea"
									value="raw">JLIB_FILTER_PARAMS_RAW</option>
								<option
									showon="fieldtype:editor,text,textarea"
									value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
								<option
									showon="fieldtype:editor,text,textarea"
									value="JComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
								<option
									showon="fieldtype:text,textarea"
									value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
								<option
									showon="fieldtype:text,textarea"
									value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
								<option
									showon="fieldtype:text,textarea"
									value="float">JLIB_FILTER_PARAMS_FLOAT</option>
								<option
									showon="fieldtype:text,textarea"
									value="tel">JLIB_FILTER_PARAMS_TEL</option>
							</field>
						</fieldset>
					</fields>
				</form>
			</field>
		</fieldset>
	</fields>
</form>
PK�H�[n��&��repeatable.phpnu�[���<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Repeatable
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

use Joomla\CMS\MVC\Model\BaseDatabaseModel;

defined('_JEXEC') or die;

JLoader::import('components.com_fields.libraries.fieldsplugin',
JPATH_ADMINISTRATOR);

/**
 * Repeatable plugin.
 *
 * @since  3.9.0
 */
class PlgFieldsRepeatable extends FieldsPlugin
{
	/**
	 * Transforms the field into a DOM XML element and appends it as a child
on the given parent.
	 *
	 * @param   stdClass    $field   The field.
	 * @param   DOMElement  $parent  The field node parent.
	 * @param   JForm       $form    The form.
	 *
	 * @return  DOMElement
	 *
	 * @since   3.9.0
	 */
	public function onCustomFieldsPrepareDom($field, DOMElement $parent, JForm
$form)
	{
		$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);

		if (!$fieldNode)
		{
			return $fieldNode;
		}

		$readonly = false;

		if (!FieldsHelper::canEditFieldValue($field))
		{
			$readonly = true;
		}

		$fieldNode->setAttribute('type', 'subform');
		$fieldNode->setAttribute('multiple', 'true');
		$fieldNode->setAttribute('layout',
'joomla.form.field.subform.repeatable-table');

		// Build the form source
		$fieldsXml = new SimpleXMLElement('<form/>');
		$fields    = $fieldsXml->addChild('fields');

		// Get the form settings
		$formFields = $field->fieldparams->get('fields');

		// Add the fields to the form
		foreach ($formFields as $index => $formField)
		{
			$child = $fields->addChild('field');
			$child->addAttribute('name', $formField->fieldname);
			$child->addAttribute('type', $formField->fieldtype);
			$child->addAttribute('readonly', $readonly);

			if (isset($formField->fieldfilter))
			{
				$child->addAttribute('filter',
$formField->fieldfilter);
			}
		}

		$fieldNode->setAttribute('formsource',
$fieldsXml->asXML());

		// Return the node
		return $fieldNode;
	}

	/**
	 * The save event.
	 *
	 * @param   string   $context  The context
	 * @param   JTable   $item     The article data
	 * @param   boolean  $isNew    Is new item
	 * @param   array    $data     The validated data
	 *
	 * @return  boolean
	 *
	 * @since   3.9.0
	 */
	public function onContentAfterSave($context, $item, $isNew, $data =
array())
	{
		// Create correct context for category
		if ($context == 'com_categories.category')
		{
			$context = $item->get('extension') .
'.categories';

			// Set the catid on the category to get only the fields which belong to
this category
			$item->set('catid', $item->get('id'));
		}

		// Check the context
		$parts = FieldsHelper::extract($context, $item);

		if (!$parts)
		{
			return true;
		}

		// Compile the right context for the fields
		$context = $parts[0] . '.' . $parts[1];

		// Loading the fields
		$fields = FieldsHelper::getFields($context, $item);

		if (!$fields)
		{
			return true;
		}

		// Get the fields data
		$fieldsData = !empty($data['com_fields']) ?
$data['com_fields'] : array();

		// Loading the model
		/** @var FieldsModelField $model */
		$model = BaseDatabaseModel::getInstance('Field',
'FieldsModel', array('ignore_request' => true));

		// Loop over the fields
		foreach ($fields as $field)
		{
			// Find the field of this type repeatable
			if ($field->type !== $this->_name)
			{
				continue;
			}

			// Determine the value if it is available from the data
			$value = key_exists($field->name, $fieldsData) ?
$fieldsData[$field->name] : null;

			// Handle json encoded values
			if (!is_array($value))
			{
				$value = json_decode($value, true);
			}

			// Setting the value for the field and the item
			$model->setFieldValue($field->id, $item->get('id'),
json_encode($value));
		}

		return true;
	}
}
PK�H�[�?����repeatable.xmlnu�[���<?xml
version="1.0" encoding="utf-8" ?>
<extension type="plugin" version="3.8.0"
group="fields" method="upgrade">
	<name>plg_fields_repeatable</name>
	<author>Joomla! Project</author>
	<creationDate>April 2018</creationDate>
	<copyright>Copyright (C) 2005 - 2020 Open Source Matters. All rights
reserved.</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.9.0</version>
	<description>PLG_FIELDS_REPEATABLE_XML_DESCRIPTION</description>
	<files>
		<filename
plugin="repeatable">repeatable.php</filename>
		<folder>params</folder>
		<folder>tmpl</folder>
	</files>
	<languages folder="language">
		<language
tag="en-GB">en-GB/en-GB.plg_fields_repeatable.ini</language>
		<language
tag="en-GB">en-GB/en-GB.plg_fields_repeatable.sys.ini</language>
	</languages>
</extension>
PK�H�[�%�LLtmpl/repeatable.phpnu�[���<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Repeatable
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

$fieldValue = $field->value;

if ($fieldValue === '')
{
	return;
}

// Get the values
$fieldValues = json_decode($fieldValue, true);

if (empty($fieldValues))
{
	return;
}

$html = '<ul>';

foreach ($fieldValues as $value)
{
	$html .= '<li>' . implode(', ', $value) .
'</li>';
}

$html .= '</ul>';

echo $html;
PK�H�[�w�R�	�	params/repeatable.xmlnu�[���PK�H�[n��&��
repeatable.phpnu�[���PK�H�[�?����3repeatable.xmlnu�[���PK�H�[�%�LLtmpl/repeatable.phpnu�[���PKD�