primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,139 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
use Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection as JfiltersCollection;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Extension as RL_Extension;
use RegularLabs\Library\FieldsPlugin;
use RegularLabs\Plugin\Fields\Articles\Helper;
defined('_JEXEC') or die;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/regularlabs.xml')
|| ! class_exists('RegularLabs\Library\Parameters')
|| ! class_exists('RegularLabs\Library\DownloadKey')
|| ! class_exists('RegularLabs\Library\FieldsPlugin')
)
{
return;
}
if ( ! RL_Document::isJoomlaVersion(4))
{
RL_Extension::disable('articles', 'plugin', 'fields');
RL_Document::adminError(
JText::sprintf('RL_PLUGIN_HAS_BEEN_DISABLED', JText::_('ARTICLESFIELD'))
);
return;
}
if (true)
{
class PlgFieldsArticles extends FieldsPlugin
{
/**
* Prepares the field value.
*
* @param string $context The context.
* @param stdclass $item The item.
* @param stdclass $field The field.
*
* @return string
*
* @since 3.7.0
*/
public function onCustomFieldsPrepareField($context, $item, $field)
{
// Check if the field should be processed by us
if (!$this->isTypeSupported($field->type)) {
return;
}
// The field's rawvalue should be an array
if (!is_array($field->rawvalue)) {
$field->rawvalue = (array) $field->rawvalue;
}
return parent::onCustomFieldsPrepareField($context, $item, $field);
}
public function onJFiltersOptionsAfterCreation(JfiltersCollection $options)
{
$attributes = $options->getFilterItem()->getAttributes();
if ($attributes->get('type') !== $this->_name)
{
return $options;
}
$sort_by = $attributes->get('options_sort_by', 'title');
$sort_direction = strtoupper($attributes->get('options_sort_direction', 'ASC'));
$options_by_id = [];
foreach ($options as $option)
{
$label = $option->getLabel();
$options_by_id[$label] = $option;
}
$ids = array_keys($options_by_id);
$articles = Helper::getArticlesByIds($ids);
$this->orderArticles($articles, $sort_by, $sort_direction, $options_by_id);
$options->clearItems(false);
foreach ($articles as $article)
{
$option = $options_by_id[$article->id];
if ( ! empty($article->title))
{
$option->setLabel($article->title);
}
$options->addItem($option);
}
return $options;
}
private function orderArticles(&$articles, $sort_by, $sort_direction, $options)
{
if ($sort_by === 'label')
{
Helper::orderArticles($articles, 'title', $sort_direction);
return;
}
$ordered = [];
foreach ($articles as $article)
{
$order = ($sort_direction === 'DESC')
? (10000000 - $options[$article->id]->getData()->count)
: str_pad($options[$article->id]->getData()->count, 8, '0', STR_PAD_LEFT);
$ordered[$order . '.' . $article->title . '.' . $article->id] = $article;
}
ksort($ordered);
$articles = array_values($ordered);
}
}
}

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="4" type="plugin" group="fields" method="upgrade">
<name>PLG_FIELDS_ARTICLES</name>
<description>PLG_FIELDS_ARTICLES_DESC</description>
<version>4.3.2</version>
<creationDate>October 2024</creationDate>
<author>Regular Labs (Peter van Westen)</author>
<authorEmail>info@regularlabs.com</authorEmail>
<authorUrl>https://regularlabs.com</authorUrl>
<copyright>Copyright © 2024 Regular Labs - All Rights Reserved</copyright>
<license>GNU General Public License version 2 or later</license>
<namespace path="src">RegularLabs\Plugin\Fields\Articles</namespace>
<scriptfile>script.install.php</scriptfile>
<files>
<file plugin="articles">articles.php</file>
<folder>language</folder>
<folder>layouts</folder>
<folder>params</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<config>
<fields name="params" addfieldprefix="RegularLabs\Library\Form\Field">
<fieldset name="basic">
<field name="@load_script_descriptions" type="LoadMedia" filetype="script" file="regularlabs.admin-form-descriptions"/>
<field name="@load_language_regularlabs" type="LoadLanguage" extension="plg_system_regularlabs"/>
<field name="@license" type="License" extension="ARTICLESFIELD"/>
<field name="@version" type="Version" extension="ARTICLESFIELD"/>
<field name="@header" type="Header" label="ARTICLESFIELD" description="ARTICLESFIELD_DESC" url="https://regularlabs.com/articlesfield"/>
<field name="multiple" type="Radio" class="btn-group rl-btn-group btn-group-md btn-group-yesno" default="0" label="RL_FIELD_PARAM_MULTIPLE" description="RL_FIELD_PARAM_MULTIPLE_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="@note__select_style" type="OnlyPro" label="RL_FIELD_SELECT_STYLE" description="RL_FIELD_SELECT_STYLE_DESC"/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,72 @@
;; @package Articles Field
;; @version 4.3.2
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link https://regularlabs.com
;; @copyright Copyright © 2024 Regular Labs All Rights Reserved
;; @license GNU General Public License version 2 or later
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
PLG_FIELDS_ARTICLES="Fields - Regular Labs - Articles"
PLG_FIELDS_ARTICLES_DESC="Articles Field - connect other articles to your content item"
ARTICLESFIELD="Articles Field"
ARTICLESFIELD_DESC="<p>The Articles field enables you to link to other articles from the current item.</p>"
PLG_FIELDS_ARTICLES_LABEL="Articles (%s)"
FLDA_ADD_LINKED_FIELDS_FIELDS="Linked Fields"
FLDA_ADD_LINKED_FIELDS_FIELDS_DESC="Select the Articles Fields through which other articles are linking to the current article."
FLDA_ARTICLE_GROUPING="Grouping"
FLDA_ARTICLE_GROUPING_DESC="Select how you would like the articles to be grouped in the article select field."
FLDA_CATEGORIES_DESC="Select the categories to limit the articles by. Only articles under these categories will be available to select in the select list."
FLDA_CUSTOM_FIELD_DESC="Select the custom field value to use. Only articles having the given value for the given custom field will be available to select in the select list."
FLDA_CUSTOM_HTML="Custom HTML"
FLDA_CUSTOM_HTML_DESC="Set a custom HTML as the layout for each element. You can use [data] tags to output available article data."
FLDA_FIELD_TYPE="Field Type"
FLDA_FIELD_TYPE_DESC="Select the type of field to use."
FLDA_FILTER_BY_AUTHORS="Filter by Authors"
FLDA_FILTER_BY_AUTHORS_DESC="Select to filter by Authors"
FLDA_FILTER_BY_CATEGORIES="Filter by Categories"
FLDA_FILTER_BY_CATEGORIES_DESC="Select to filter by Categories"
FLDA_FILTER_BY_CUSTOM_FIELDS="Filter by Custom Fields"
FLDA_FILTER_BY_CUSTOM_FIELDS_DESC="Select to filter by Custom Fields"
FLDA_FILTER_BY_LANGUAGE="Filter by Language"
FLDA_FILTER_BY_LANGUAGE_DESC="Select to filter by Language"
FLDA_FILTER_BY_TAGS="Filter by Tags"
FLDA_FILTER_BY_TAGS_DESC="Select to filter by Tags"
FLDA_FILTER_SHOW_CATEGORY="Show Category Title"
FLDA_FILTER_SHOW_CATEGORY_DESC="Select to show the name of the Category near the title of the article in the article select field. This only applies when the select includes articles from multiple categories."
FLDA_FILTER_SHOW_UNPUBLISHED="Show Unpublished Articles"
FLDA_FILTER_SHOW_UNPUBLISHED_DESC="Select to show unpublished articles in the article select field. Selected unpublished articles will only show on the frontend output when they get published."
FLDA_IGNORE_FILTER_FOR_ADMINISTRATORS="Ignore for Administrators"
FLDA_IGNORE_FILTER_FOR_ADMINISTRATORS_DESC="Select to ignore the filter field for administrators (users with core admin rights)."
FLDA_INPUT_OPTIONS="Input Select Options"
FLDA_INPUT_OPTIONS_DESC="These options only affect the article select field. They do not affect the frontend display."
FLDA_LANGUAGE_CURRENT="Current Language"
FLDA_LANGUAGE_CURRENT_DESC="Select to use the current articles language to limit the articles by. Only articles assigned to this language will be available to select in the select list."
FLDA_LANGUAGE_DESC="Select the language to limit the articles by. Only articles assigned t this language will be available to select in the select list."
FLDA_LAST_SEPARATOR="Separator"
FLDA_LAST_SEPARATOR_DESC="Choose a different separator to place in between the last 2 elements."
FLDA_LAYOUT_CUSTOM_HTML="Custom HTML"
FLDA_LAYOUT_TITLE="Title"
FLDA_LAYOUT_TITLE_CUSTOM_FIELD="Title + Custom Field"
FLDA_LIMIT="Limit"
FLDA_LINK_ARTICLES="Articles"
FLDA_LINK_ARTICLES_DESC="This field enables you to select other articles to link to."
FLDA_LINK_TITLE="Link Title"
FLDA_LINK_TITLE_DESC="Select to add a link to the article titles."
FLDA_LINKED_ARTICLES="Articles - Linked"
FLDA_LINKED_ARTICLES_DESC="This field will show articles linking to the current article (via other Articles Fields)."
FLDA_ORDER_OF_SELECTION="Order of Selection"
FLDA_OUTPUT_LIMIT="Output Limit"
FLDA_OUTPUT_LIMIT_DESC="Set the maximum number of articles to show on the frontend. Set to 0 to show all."
FLDA_OUTPUT_TITLE_CUSTOM_FIELD="[[%1:title%]] ([[%2:custom field%]])"
FLDA_SEPARATOR="Separator"
FLDA_SEPARATOR_DESC="Choose a separator for multiple elements."
FLDA_TAGS_DESC="Select the tags to limit the articles by. Only articles that have any of these tags will be available to select in the select list."
FLDA_USE_LAST_SEPARATOR="Use Last Separator"
FLDA_USE_LAST_SEPARATOR_DESC="Select to use a different separator to place in between the last 2 elements."
FLDA_USE_SEPARATOR="Use Separator"
FLDA_USE_SEPARATOR_DESC="Select to use a separator for multiple elements."
FLDA_USERS_DESC="Select the users to limit the articles by. Only articles created by these users will be available to select in the select list."

View File

@ -0,0 +1,12 @@
;; @package Articles Field
;; @version 4.3.2
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link https://regularlabs.com
;; @copyright Copyright © 2024 Regular Labs All Rights Reserved
;; @license GNU General Public License version 2 or later
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
PLG_FIELDS_ARTICLES="Fields - Regular Labs - Articles"
PLG_FIELDS_ARTICLES_DESC="Articles Field - connect other articles to your content item"

View File

@ -0,0 +1,16 @@
;; @package Articles Field
;; @version 4.3.2
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link https://regularlabs.com
;; @copyright Copyright © 2024 Regular Labs All Rights Reserved
;; @license GNU General Public License version 2 or later
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Articles Field - connect other articles to your content item"
PLG_FIELDS_ARTICLESLINKED_LABEL="Articles - Linked (%s)"
FLDA_THE_MAIN_FIELD_PLUGIN="the main Articles Field plugin"

View File

@ -0,0 +1,12 @@
;; @package Articles Field
;; @version 4.3.2
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link https://regularlabs.com
;; @copyright Copyright © 2024 Regular Labs All Rights Reserved
;; @license GNU General Public License version 2 or later
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Articles Field - connect other articles to your content item"

View File

@ -0,0 +1,56 @@
;; @package Articles Field
;; @version 1.2.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://www.regularlabs.com
;; @copyright Copyright © 2018 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://www.regularlabs.com/translate
;;
;; @translation Tradotto da: Roberto Nervi <r.nervi@tiscali.it>, $Red <redwebsite@altervista.org> RedWebSite (redwebsite.altervista.org)
; PLG_FIELDS_ARTICLES="Fields - Regular Labs - Articles"
; PLG_FIELDS_ARTICLES_DESC="Articles Field - connect other articles to your content item"
; ARTICLES_FIELD="Articles Field"
; ARTICLES_FIELD_DESC="<p>The Articles field enables you to link to other articles from the current item.</p>"
PLG_FIELDS_ARTICLES_LABEL="Articoli (%s)"
; FLDA_ADD_LINKED_FIELDS_FIELDS="Linked Fields"
; FLDA_ADD_LINKED_FIELDS_FIELDS_DESC="Select the Articles fields through which other articles are linking to the current article."
; FLDA_CATEGORIES_DESC="Select the categories to limit the articles by. Only articles under these categories will be available to select in the select list."
; FLDA_CUSTOM_FIELD_DESC="Select the custom field value to use. Only articles having the given value for the given custom field will be available to select in the select list."
FLDA_CUSTOM_HTML="HTML Personalizzato"
; FLDA_CUSTOM_HTML_DESC="Set a custom HTML as the layout for each element. You can use [data] tags to output available article data."
FLDA_FIELD_TYPE="Tipo di campo"
; FLDA_FIELD_TYPE_DESC="Select the type of field to use."
; FLDA_FILTER_BY_AUTHORS="Filter by Authors"
; FLDA_FILTER_BY_AUTHORS_DESC="Select to filter by Authors"
FLDA_FILTER_BY_CATEGORIES="Filtra per Categorie"
; FLDA_FILTER_BY_CATEGORIES_DESC="Select to filter by Categories"
; FLDA_FILTER_BY_CUSTOM_FIELDS="Filter by Custom Fields"
; FLDA_FILTER_BY_CUSTOM_FIELDS_DESC="Select to filter by Custom Fields"
; FLDA_FILTER_BY_LANGUAGE="Filter by Language"
; FLDA_FILTER_BY_LANGUAGE_DESC="Select to filter by Language"
; FLDA_FILTER_BY_TAGS="Filter by Tags"
; FLDA_FILTER_BY_TAGS_DESC="Select to filter by Tags"
; FLDA_LANGUAGE_CURRENT="Current Language"
; FLDA_LANGUAGE_CURRENT_DESC="Select the use the current articles language to limit the articles by. Only articles assigned t this language will be available to select in the select list."
; FLDA_LANGUAGE_DESC="Select the language to limit the articles by. Only articles assigned t this language will be available to select in the select list."
FLDA_LAYOUT_CUSTOM_HTML="HTML Personalizzato"
FLDA_LAYOUT_TITLE="Titolo"
; FLDA_LAYOUT_TITLE_CUSTOM_FIELD="Title + Custom Field"
; FLDA_LINK_ARTICLES="Link Articles"
; FLDA_LINK_ARTICLES_DESC="This field enables you to select other articles to link to."
; FLDA_LINK_TITLE="Link Title"
; FLDA_LINK_TITLE_DESC="Select to add a link to the article titles."
; FLDA_LINKED_ARTICLES="Show Linked Articles"
; FLDA_LINKED_ARTICLES_DESC="This field will show articles linking to the current article (via other Articles fields)."
; FLDA_OUTPUT_TITLE_CUSTOM_FIELD="[[%1:title%]] ([[%2:custom field%]])"
FLDA_SEPARATOR="Separatore"
; FLDA_SEPARATOR_DESC="Choose a separator for repeated elements."
; FLDA_TAGS_DESC="Select the tags to limit the articles by. Only articles that have any of these tags will be available to select in the select list."
; FLDA_USE_SEPARATOR="Use Separator"
; FLDA_USE_SEPARATOR_DESC="Select to use a separator for repeated elements."
; FLDA_USERS_DESC="Select the users to limit the articles by. Only articles created by these users will be available to select in the select list."

View File

@ -0,0 +1,14 @@
;; @package Articles Field
;; @version 1.2.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://www.regularlabs.com
;; @copyright Copyright © 2018 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://www.regularlabs.com/translate
;;
;; @translation Tradotto da: Roberto Nervi <r.nervi@tiscali.it>, $Red <redwebsite@altervista.org> RedWebSite (redwebsite.altervista.org)
; PLG_FIELDS_ARTICLES="Fields - Regular Labs - Articles"
; PLG_FIELDS_ARTICLES_DESC="Articles Field - connect other articles to your content item"

View File

@ -0,0 +1,26 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use RegularLabs\Plugin\Fields\Articles\Helper;
/*
* @var array $displayData
* @var object $layout
* @var object $field
* @var string $layout_type
*/
extract($displayData);
$ids = (array) $field->value;
echo Helper::renderLayout($ids, $layout, $field, $layout_type);

View File

@ -0,0 +1,15 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die();
// Only used in Pro version

View File

@ -0,0 +1,15 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
// Only used in Pro version

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die();
use Joomla\CMS\Router\Route as JRoute;
use Joomla\Component\Content\Site\Helper\RouteHelper as JContentHelperRoute;
/*
* @var array $displayData
* @var object $article
* @var object $settings
*/
extract($displayData);
$title = htmlentities($article->title);
if ($settings->link_title)
{
$slug = $article->alias ? ($article->id . ':' . $article->alias) : $article->id;
$link = JRoute::link('site', JContentHelperRoute::getArticleRoute($slug, $article->catid, $article->language));
$title = '<a href="' . $link . '">' . $title . '</a>';
}
echo $title;

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die();
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Router\Route as JRoute;
use Joomla\Component\Content\Site\Helper\RouteHelper as JContentHelperRoute;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper as JFieldsHelper;
use RegularLabs\Plugin\Fields\Articles\Helper;
/*
* @var array $displayData
* @var object $article
* @var object $settings
*/
extract($displayData);
$title = htmlentities($article->title);
if ($settings->link_title)
{
$slug = $article->alias ? ($article->id . ':' . $article->alias) : $article->id;
$link = JRoute::link('site', JContentHelperRoute::getArticleRoute($slug, $article->catid, $article->language));
$title = '<a href="' . $link . '">' . $title . '</a>';
}
// No custom field found. Just return title
if (empty($settings->custom_field))
{
echo $title;
return;
}
$fields = JFieldsHelper::getFields('com_content.article', $article);
// No custom fields found. Just return title
if (empty($fields))
{
return $title;
}
foreach ($fields as $field)
{
if ($field->id != $settings->custom_field)
{
continue;
}
// field has no value
if (empty($field->value))
{
break;
}
Helper::prepareCustomField('com_content.article', $article, $field);
echo JText::sprintf('FLDA_OUTPUT_TITLE_CUSTOM_FIELD', $title, $field->value);
return;
}
// No custom field found. Just return title
echo $title;

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="fieldparams" addfieldprefix="RegularLabs\Library\Form\Field">
<fieldset name="fieldparams" addfieldprefix="RegularLabs\Plugin\Fields\Articles\Form\Field">
<field name="@load_script_descriptions" type="LoadMedia" filetype="script" file="regularlabs.admin-form-descriptions"/>
<field name="field_type" type="List" label="FLDA_FIELD_TYPE" description="FLDA_FIELD_TYPE_DESC" default="articles">
<option value="articles">FLDA_LINK_ARTICLES</option>
<option value="" disabled="true">FLDA_LINKED_ARTICLES</option>
<option value="" disabled="true">RL_ONLY_AVAILABLE_IN_PRO_LIST_OPTION</option>
</field>
<field name="multiple" type="List" label="RL_FIELD_PARAM_MULTIPLE" description="RL_FIELD_PARAM_MULTIPLE_DESC" default="">
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="@description_link_articles" type="Note" description="FLDA_LINK_ARTICLES_DESC"/>
<field name="@block__filters__a" type="Block" start="1" label="RL_FILTERS"/>
<field name="@block__filters_categories__a" type="Block" start="1" label="RL_CATEGORIES"/>
<field name="filter_categories" type="Radio" default="0" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="FLDA_FILTER_BY_CATEGORIES">
<option value="0">JNO</option>
<option value="1">JYES</option>
<option value="current" class="btn btn-outline-info">RL_CURRENT</option>
</field>
<field name="categories" type="ContentCategories" label="RL_CATEGORIES" description="FLDA_CATEGORIES_DESC" multiple="1" simple="1" showon="filter_categories:1"/>
<field name="categories_inc_children" type="Radio" default="0" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="RL_INCLUDE_CHILD_CATEGORIES" description="RL_INCLUDE_CHILD_ITEMS_DESC" showon="filter_categories:1,current">
<option value="0">JNO</option>
<option value="1">JYES</option>
<option value="2" class="btn btn-outline-info">RL_ONLY</option>
</field>
<field name="@block__filters_categories__b" type="Block" end="1"/>
<field name="@block__filters_tags__a" type="Block" start="1" label="RL_TAGS"/>
<field name="@free__filters_tags" type="OnlyPro" label="FLDA_FILTER_BY_TAGS"/>
<field name="@block__filters_tags__b" type="Block" end="1"/>
<field name="@block__filters_language__a" type="Block" start="1" label="RL_LANGUAGE"/>
<field name="@free__filters_language" type="OnlyPro" label="FLDA_FILTER_BY_LANGUAGE"/>
<field name="@block__filters_languages__b" type="Block" end="1"/>
<field name="@block__filters_users__a" type="Block" start="1" label="JAUTHOR"/>
<field name="@free__filters_users" type="OnlyPro" label="FLDA_FILTER_BY_AUTHORS"/>
<field name="@block__filters_users__b" type="Block" end="1"/>
<field name="@block__filters_custom_fields__a" type="Block" start="1" label="RL_CUSTOM_FIELDS"/>
<field name="@free__filter_customfields" type="OnlyPro" label="FLDA_FILTER_BY_CUSTOM_FIELDS"/>
<field name="@block__filters_custom_fields__b" type="Block" end="1"/>
<field name="@block__filters__b" type="Block" end="1"/>
<field name="@block__articles_ordering__a" type="Block" start="1" label="RL_ORDERING"/>
<field name="articles_ordering" type="List" class="w-auto" label="RL_ORDERING_PRIMARY" description="JGLOBAL_FIELD_FIELD_ORDERING_DESC" default="title">
<option value="none">FLDA_ORDER_OF_SELECTION</option>
<option value="ordering">JFIELD_ORDERING_LABEL</option>
<option value="id">JGRID_HEADING_ID</option>
<option value="title">JGLOBAL_TITLE</option>
<option value="alias">JFIELD_ALIAS_LABEL</option>
<option value="hits">JGLOBAL_HITS</option>
<option value="created">JGLOBAL_CREATED_DATE</option>
<option value="modified">JGLOBAL_MODIFIED_DATE</option>
<option value="publish_up">JGLOBAL_PUBLISHED_DATE</option>
<option value="featured">JFEATURED</option>
<option value="category_lft">JGLOBAL_CATEGORY_ORDER_LABEL</option>
<option value="category_title">JGLOBAL_LIST_TITLE_LABEL</option>
</field>
<field name="articles_ordering_direction" type="Radio" default="ASC" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="RL_ORDER_DIRECTION_PRIMARY" description="JGLOBAL_ORDER_DIRECTION_DESC" showon="articles_ordering!:none">
<option value="ASC" class="btn btn-outline-info">JGLOBAL_ORDER_ASCENDING</option>
<option value="DESC" class="btn btn-outline-info">JGLOBAL_ORDER_DESCENDING</option>
</field>
<field name="articles_ordering_2" type="List" class="w-auto" label="RL_ORDERING_SECONDARY" description="JGLOBAL_FIELD_FIELD_ORDERING_DESC" default="created" showon="articles_ordering!:none[AND]articles_ordering!:id">
<option value="ordering">JFIELD_ORDERING_LABEL</option>
<option value="id">JGRID_HEADING_ID</option>
<option value="title">JGLOBAL_TITLE</option>
<option value="alias">JFIELD_ALIAS_LABEL</option>
<option value="hits">JGLOBAL_HITS</option>
<option value="created">JGLOBAL_CREATED_DATE</option>
<option value="modified">JGLOBAL_MODIFIED_DATE</option>
<option value="publish_up">JGLOBAL_PUBLISHED_DATE</option>
<option value="featured">JFEATURED</option>
<option value="category_lft">JGLOBAL_CATEGORY_ORDER_LABEL</option>
<option value="category_title">JGLOBAL_LIST_TITLE_LABEL</option>
</field>
<field name="articles_ordering_direction_2" type="Radio" default="DESC" class="btn-group rl-btn-group btn-group-md" label="RL_ORDER_DIRECTION_SECONDARY" description="JGLOBAL_ORDER_DIRECTION_DESC" showon="articles_ordering!:none[AND]articles_ordering!:id">
<option value="ASC" class="btn btn-outline-info">JGLOBAL_ORDER_ASCENDING</option>
<option value="DESC" class="btn btn-outline-info">JGLOBAL_ORDER_DESCENDING</option>
</field>
<field name="@block__articles_ordering__b" type="Block" end="1"/>
<field name="@block__output_limit__a" type="Block" start="1" label="FLDA_OUTPUT_LIMIT"/>
<field name="@free__output_limit" type="OnlyPro" label="FLDA_LIMIT" description="FLDA_OUTPUT_LIMIT_DESC"/>
<field name="@block__output_limit__b" type="Block" end="1"/>
<field name="@block__layout__a" type="Block" start="1" label="RL_LAYOUT"/>
<field name="layout" type="List" class="w-auto" label="RL_LAYOUT" description="RL_LAYOUT_DESC" default="title">
<option value="title">FLDA_LAYOUT_TITLE</option>
<option value="title_custom">FLDA_LAYOUT_TITLE_CUSTOM_FIELD</option>
<option value="" disabled="true">FLDA_LAYOUT_CUSTOM_HTML</option>
<option value="" disabled="true">RL_ONLY_AVAILABLE_IN_PRO_LIST_OPTION</option>
</field>
<field name="custom_field" type="CustomField" label="RL_CUSTOM_FIELD" description="FLDA_CUSTOM_FIELD_DESC" class="w-auto" default="" exclude="articles" showon="layout:title_custom"/>
<field name="link_title" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="FLDA_LINK_TITLE" description="FLDA_LINK_TITLE_DESC" showon="layout:title,title_custom">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="custom_html" type="TextArea" texttype="html" filter="raw" label="FLDA_CUSTOM_HTML" description="FLDA_CUSTOM_HTML_DESC" default="&lt;a href=&quot;[url]&quot;&gt;[title]&lt;/a&gt; ([hits])" showon="layout:custom_html"/>
<field name="use_separator" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="FLDA_USE_SEPARATOR" description="FLDA_USE_SEPARATOR_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="@showon__use_separator__a" type="ShowOn" value="use_separator:1"/>
<field name="separator" type="Text" class="w-12" label="FLDA_SEPARATOR" description="FLDA_SEPARATOR_DESC" default=", " filter="raw"/>
<field name="use_last_separator" type="Radio" default="0" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="FLDA_USE_LAST_SEPARATOR" description="FLDA_USE_LAST_SEPARATOR_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="last_separator" type="Text" class="w-12" label="FLDA_LAST_SEPARATOR" description="FLDA_LAST_SEPARATOR_DESC" default=" &amp; " filter="raw" showon="use_last_separator:1"/>
<field name="@showon__use_separator__b" type="ShowOn"/>
<field name="@block__layout__b" type="Block" end="1"/>
<field name="@block__input_options__a" type="Block" start="1" label="FLDA_INPUT_OPTIONS"/>
<field name="@description_field_option" type="Note" description="FLDA_INPUT_OPTIONS_DESC" class="alert alert-info"/>
<field name="show_unpublished" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="FLDA_FILTER_SHOW_UNPUBLISHED" description="FLDA_FILTER_SHOW_UNPUBLISHED_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="show_category" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="FLDA_FILTER_SHOW_CATEGORY" description="FLDA_FILTER_SHOW_CATEGORY_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="@free__articles_grouping" type="OnlyPro" label="FLDA_ARTICLE_GROUPING" description="FLDA_ARTICLE_GROUPING_DESC"/>
<!-- >>> [PRO] >>> -->
<field name="articles_grouping" type="List" class="w-auto" label="FLDA_ARTICLE_GROUPING" description="FLDA_ARTICLE_GROUPING_DESC" default="title">
<option value="">JNONE</option>
<option value="category">RL_CATEGORY</option>
</field>
<field name="@block__input_options__b" type="Block" end="1"/>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,57 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Filesystem\File as JFile;
use Joomla\CMS\Filesystem\Folder as JFolder;
class PlgFieldsArticlesInstallerScript
{
public function postflight($install_type, $adapter)
{
if ( ! in_array($install_type, ['install', 'update']))
{
return true;
}
self::deleteJoomla3Files();
return true;
}
private static function delete($files = [])
{
foreach ($files as $file)
{
if (is_dir($file))
{
JFolder::delete($file);
}
if (is_file($file))
{
JFile::delete($file);
}
}
}
private static function deleteJoomla3Files()
{
self::delete(
[
JPATH_SITE . '/plugins/fields/articles/fields',
JPATH_SITE . '/plugins/fields/articles/helper.php',
JPATH_SITE . '/plugins/fields/articles/filters.php',
]
);
}
}

View File

@ -0,0 +1,212 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\Fields\Articles;
defined('_JEXEC') or die();
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\ArrayHelper as RL_Array;
use RegularLabs\Library\DB as RL_DB;
use RegularLabs\Library\Input as RL_Input;
class Filters
{
private $db;
private $form;
private $params;
public function __construct($params, $form = null)
{
$this->params = $params;
$this->form = $form;
$this->db = JFactory::getDbo();
}
public function addToQuery(&$query)
{
$this->addCategoriesToQuery($query);
}
public function get()
{
$filters = [];
if ($this->params->get('filter_categories'))
{
$categories = RL_Array::toArray($this->params->get('categories'));
if ($this->params->get('filter_categories') === 'current')
{
$categories = [$this->getCurrentCategoryId()];
}
$filters['filter_categories'] = true;
$filters['categories'] = $categories;
$filters['categories_inc_children'] = $this->params->get('categories_inc_children');
}
return $filters;
}
public function getCategories()
{
if ( ! $this->params->get('filter_categories'))
{
return [];
}
if ($this->params->get('filter_categories') === 'current')
{
return [$this->getCurrentCategoryId()];
}
$categories = (array) $this->params->get('categories', []);
if (empty($categories))
{
return [];
}
$inc_children = $this->params->get('categories_inc_children');
if ( ! $inc_children)
{
return $categories;
}
$children = $this->getCategoriesChildIds($categories);
if ($inc_children == 2)
{
return $children;
}
return [...$categories, ...$children];
}
public function getCurrentArticleId(): int
{
if (
RL_Input::getCmd('option') != 'com_content'
|| ! in_array(RL_Input::getCmd('view'), ['form', 'article'])
|| ! in_array(RL_Input::getCmd('layout'), ['edit', 'modal'])
)
{
return 0;
}
if ($this->form && $this->form->getValue('id'))
{
return (int) $this->form->getValue('id');
}
return RL_Input::getInt('id');
}
private function addCategoriesToQuery(&$query)
{
$categories = $this->getCategories();
if (empty($categories))
{
return $categories;
}
$query->where(RL_DB::is('a.catid', $categories));
return $categories;
}
private function addCustomFieldsToQuery(&$query)
{
}
private function addTagsToQuery(&$query)
{
}
private function addUsersToQuery(&$query)
{
}
private function filterDownArticlesByCustomFields(&$ids, $id, $value)
{
}
private function getArticlesByCustomFields()
{
}
private function getCategoriesChildIds($categories = [])
{
$children = [];
$query = RL_DB::getQuery()
->select('category.id')
->from(RL_DB::quoteName('#__categories', 'category'))
->where('category.extension = ' . RL_DB::quote('com_content'))
->where('category.published = 1');
while ( ! empty($categories))
{
$query->clear('where')
->where(RL_DB::is('category.parent_id', $categories));
$this->db->setQuery($query);
$categories = $this->db->loadColumn();
$children = [...$children, ...$categories];
}
return $children;
}
private function getCurrentArticleLanguage()
{
}
private function getCurrentCategoryId(): int
{
if ($this->form && $this->form->getValue('catid'))
{
return (int) $this->form->getValue('catid');
}
$id = $this->getCurrentArticleId();
if ( ! $id)
{
return 0;
}
$query = RL_DB::getQuery()
->select('content.catid')
->from(RL_DB::quoteName('#__content', 'content'))
->where('content.id = ' . $id);
$this->db->setQuery($query);
return (int) $this->db->loadResult();
}
private function getTags()
{
}
private function getTagsChildIds($tags = [])
{
}
private function getUsers()
{
}
}

View File

@ -0,0 +1,240 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\Fields\Articles\Form\Field;
defined('_JEXEC') or die();
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\Registry\Registry;
use RegularLabs\Library\ArrayHelper as RL_Array;
use RegularLabs\Library\DB as RL_DB;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Form\Form as RL_Form;
use RegularLabs\Library\Form\FormField as RL_Field;
use RegularLabs\Library\Parameters as RL_Parameters;
use RegularLabs\Plugin\Fields\Articles\Filters;
use RegularLabs\Plugin\Fields\Articles\Helper;
class ArticlesField extends RL_Field
{
protected function getInput()
{
$this->params = $this->element->attributes();
$plugin_params = RL_Parameters::getPlugin('articles', 'fields');
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
$attributes = [
'fieldtype' => 'articles',
'multiple' => $this->get('multiple', $plugin_params->multiple),
'currentid' => $this->getCurrentArticleId(),
'ordering' => $this->get('articles_ordering', 'title'),
'ordering_direction' => $this->get('articles_ordering_direction', 'ASC'),
'ordering_2' => $this->get('articles_ordering_2', 'created'),
'ordering_direction_2' => $this->get('articles_ordering_direction_2', 'DESC'),
'grouping' => $this->get('articles_grouping', ''),
'show_category' => $this->get('show_category', '1'),
'show_unpublished' => $this->get('show_unpublished', '1'),
];
$filters = $this->getFilters();
$attributes = [...$attributes, ...$filters];
$this->attributes = new Registry($attributes);
// Fix for subform fields which doesn't show the dropdown select list properly
RL_Document::styleDeclaration(
'.table-responsive {overflow-x: visible;}'
);
return RL_Form::selectListAjax(
$this::class,
$this->name,
$this->value,
$this->id,
$attributes
);
//
// return RL_Form::selectlist(
// $options,
// $this->name,
// $this->value,
// $this->id,
// [
// 'size' => $this->attributes->get('size'),
// 'multiple' => $this->attributes->get('multiple'),
// ]);
}
protected function getListOptions(array $attributes): int|array
{
$this->attributes = new Registry($attributes);
return $this->getOptions();
}
protected function getOptions()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from($this->db->quoteName('#__content', 'a'))
->where('a.access > -1');
$filters = new Filters($this->attributes, $this->form);
$filters->addToQuery($query);
if ($this->max_list_count)
{
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
}
$categories = $filters->getCategories();
$primary_ordering = $this->attributes->get('ordering', 'title');
$primary_direction = $this->attributes->get('ordering_direction', 'ASC');
$secondary_ordering = $this->attributes->get('ordering_2', 'created');
$secondary_direction = $this->attributes->get('ordering_direction_2', 'DESC');
$ordering = Helper::getFullOrdering($primary_ordering, $primary_direction, $secondary_ordering, $secondary_direction);
$place_selected_at_top = false;
if ($ordering == 'none')
{
$ordering = 'a.title ASC';
$place_selected_at_top = true;
}
$grouping = $this->attributes->get('grouping', '');
$show_category = $this->attributes->get('show_category', 1) && count($categories) != 1;
$extras = ['unpublished', 'language'];
$query->clear('select')
->select('a.id, a.title as name, a.language, a.state as published')
->join('LEFT', $this->db->quoteName('#__categories', 'c') . ' ON c.id = a.catid');
if (
$show_category
)
{
$query->select(['a.catid', 'c.title as cat']);
}
if ($show_category && $grouping != 'category')
{
$extras[] = 'cat';
}
if (RL_Document::isAdmin())
{
$extras[] = 'id';
}
$query->where(RL_DB::is('a.state', [0, 1]));
if ( ! $this->attributes->get('show_unpublished', 1))
{
RL_DB::addArticleIsPublishedFilters($query);
}
$ordering = trim($ordering, ', ');
if ($ordering)
{
$query->order($ordering);
}
$this->db->setQuery($query);
$list = $this->db->loadObjectList('id');
if ($place_selected_at_top && ! empty($this->value))
{
$selected = [];
foreach ($this->value as $value)
{
if (isset($list[$value]))
{
$selected[$value] = $list[$value];
unset($list[$value]);
}
}
$list = $selected + $list;
}
switch ($grouping)
{
default:
$options = $this->getOptionsByList($list, $extras);
break;
}
$currentid = $this->attributes->get('currentid');
if (isset($options[$currentid]) && isset($options[$currentid]->text))
{
$options[$currentid]->disable = true;
$options[$currentid]->text .= ' (' . JText::_('RL_CURRENT') . ')';
}
if ($this->attributes->get('multiple'))
{
return $options;
}
array_unshift($options, JHtml::_('select.option', '-', '&nbsp;', 'value', 'text', true));
array_unshift($options, JHtml::_('select.option', '', '- ' . JText::_('Select Item') . ' -'));
return $options;
}
private function flattenGroups($groups, $level = 0)
{
}
private function flattenOptions($options)
{
}
private function getCurrentArticleId()
{
$filters = new Filters($this, $this->form);
return $filters->getCurrentArticleId();
}
private function getFilters()
{
$filters = new Filters($this, $this->form);
return $filters->get();
}
private function getOptionsByListGroupedByCategory($list, $extras = [])
{
}
}

View File

@ -0,0 +1,67 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\Fields\Articles\Form\Field;
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper as JFieldsHelper;
use RegularLabs\Library\Form\Form as RL_Form;
use RegularLabs\Library\Form\FormField as RL_Field;
class ArticlesFieldsField extends RL_Field
{
protected function getInput()
{
$this->params = $this->element->attributes();
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
$options = $this->getOptions();
return RL_Form::selectlist(
$options,
$this->name,
$this->value,
$this->id,
['multiple' => true]
);
}
protected function getOptions()
{
$options = parent::getOptions();
$fields = JFieldsHelper::getFields('com_content.article', null, false, null, true);
foreach ($fields as $field)
{
if ($field->type != 'articles')
{
continue;
}
$options[] = JHtml::_('select.option', $field->id, $field->title);
}
// Sorting the fields based on the text which is displayed
usort(
$options,
fn($a, $b) => strcmp($a->text, $b->text)
);
return $options;
}
}

View File

@ -0,0 +1,70 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\Fields\Articles\Form\Field;
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper as JFieldsHelper;
use RegularLabs\Library\ArrayHelper as RL_Array;
use RegularLabs\Library\Form\Form as RL_Form;
use RegularLabs\Library\Form\FormField as RL_Field;
class CustomFieldField extends RL_Field
{
protected function getInput()
{
$this->params = $this->element->attributes();
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
$options = $this->getOptions();
return RL_Form::selectlist(
$options,
$this->name,
$this->value,
$this->id
);
}
protected function getOptions()
{
$excludes = RL_Array::toArray($this->get('exclude'));
$options = parent::getOptions();
$fields = JFieldsHelper::getFields('com_content.article');
foreach ($fields as $field)
{
if (in_array($field->type, $excludes))
{
continue;
}
$options[] = JHtml::_('select.option', $field->id, $field->title);
}
if ( ! empty($options))
{
array_unshift($options, JHtml::_('select.option', '-', '&nbsp;', 'value', 'text', true));
array_unshift($options, JHtml::_('select.option', '', '- ' . JText::_('JSELECT') . ' -', 'value', 'text', false));
}
return $options;
}
}

View File

@ -0,0 +1,371 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\Fields\Articles;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
use Joomla\CMS\Router\Route as JRoute;
use Joomla\Component\Content\Site\Helper\RouteHelper as JContentHelperRoute;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper as JFieldsHelper;
use Joomla\Registry\Registry as JRegistry;
use RegularLabs\Library\ArrayHelper as RL_Array;
use RegularLabs\Library\Article as RL_Article;
use RegularLabs\Library\Cache as RL_Cache;
use RegularLabs\Library\DB as RL_DB;
use RegularLabs\Library\Parameters as RL_Parameters;
use RegularLabs\Library\Protect as RL_Protect;
use RegularLabs\Library\RegEx as RL_RegEx;
use RegularLabs\Library\StringHelper as RL_String;
use RegularLabs\Plugin\System\ArticlesAnywhere\Helpers\Params as AA_Params;
use RegularLabs\Plugin\System\ArticlesAnywhere\Replace as AA_Replace;
class Helper
{
public static function getArticlesByIds($ids)
{
$articles = [];
foreach ($ids as $id)
{
if ( ! $id)
{
continue;
}
$article = RL_Article::get($id);
if (empty($article->id))
{
continue;
}
if ( ! in_array($article->access, JFactory::getUser()->getAuthorisedViewLevels()))
{
continue;
}
$articles[] = $article;
}
return $articles;
}
public static function getFullOrdering(
$primary_ordering,
$primary_direction,
$secondary_ordering,
$secondary_direction,
$prefix_articles = 'a',
$prefix_categories = 'c'
)
{
$db = JFactory::getDbo();
if ($primary_ordering == 'none')
{
return 'none';
}
self::prepareOrdering($primary_ordering, $primary_direction);
self::prepareOrdering($secondary_ordering, $secondary_direction);
self::prefixOrdering($primary_ordering, $prefix_articles, $prefix_categories);
self::prefixOrdering($secondary_ordering, $prefix_articles, $prefix_categories);
return $db->quoteName($primary_ordering) . ' ' . $primary_direction . ','
. $db->quoteName($secondary_ordering) . ' ' . $secondary_direction;
}
public static function getLinkedArticleIds($field_ids, $article_id, $field)
{
}
public static function orderArticles(
&$articles,
$primary_ordering,
$primary_direction = 'ASC',
$secondary_ordering = '',
$secondary_direction = 'ASC'
)
{
$ordered = self::orderArticlesSet($articles, $primary_ordering, $primary_direction);
if ($primary_ordering == 'none' || $primary_ordering == 'id' || ! $secondary_ordering)
{
$articles = RL_Array::flatten($ordered);
return;
}
foreach ($ordered as &$ordered_set)
{
$ordered_set = self::orderArticlesSet($ordered_set, $secondary_ordering, $secondary_direction);
}
$articles = RL_Array::flatten($ordered);
}
public static function prepareCustomField($context, $item, &$field)
{
JPluginHelper::importPlugin('fields');
// Event allow plugins to modify the output of the field before it is prepared
JFactory::getApplication()->triggerEvent('onCustomFieldsBeforePrepareField', [
$context, $item, &$field
]);
// Gathering the value for the field
$value = JFactory::getApplication()->triggerEvent('onCustomFieldsPrepareField', [
$context, $item, &$field
]);
$value = RL_Array::implode($value, ' ');
// Event allow plugins to modify the output of the prepared field
JFactory::getApplication()->triggerEvent('onCustomFieldsAfterPrepareField', [
$context, $item, $field, &$value
]);
// Assign the value
$field->value = $value;
}
public static function protectArticlesAnywhere(&$string)
{
}
public static function renderLayout(
$ids,
$layout,
$field,
$layout_type = 'title',
$apply_ordering = true
)
{
if (count($ids) === 1)
{
$ids = RL_Array::toArray($ids[0]);
}
$settings = (object) [];
switch ($layout_type)
{
case 'title_custom':
$settings->custom_field = $field->fieldparams->get('custom_field', '');
$settings->link_title = $field->fieldparams->get('link_title', 1);
break;
case 'title':
default:
$settings->link_title = $field->fieldparams->get('link_title', 1);
break;
}
$outputs = self::getOutputs($ids, $layout, $field, $settings, $apply_ordering);
$separator = $field->fieldparams->get('use_separator') ? $field->fieldparams->get('separator', ', ') : '';
$last_separator = $field->fieldparams->get('use_last_separator') ? $field->fieldparams->get('last_separator', ', ') : $separator;
return RL_Array::implode(
$outputs,
$separator,
$last_separator
);
}
public static function replaceDataTags($string, &$article)
{
}
public static function runThroughArticlesAnywhere($string)
{
}
private static function addFilters(&$query, $field)
{
}
private static function getArticleFieldIds()
{
}
private static function getArticleOrderId($article, $ordering)
{
if ( ! isset($article->{$ordering}))
{
return 0;
}
switch ($ordering)
{
case 'ordering':
case 'hits':
return ($article->{$ordering} + 100000000);
case 'created_time':
case 'modified_time':
case 'publish_up':
case 'alias':
case 'title':
default:
return strtolower($article->{$ordering});
}
}
private static function getCategoriesByFieldId($field_id)
{
}
private static function getChildCategories($categories)
{
}
private static function getDataTagValue(&$article, $key)
{
}
private static function getDataTagValueCustomField(&$article, $key)
{
}
private static function getDataTags($html)
{
}
private static function getFieldIdsByType($type = 'articles')
{
$cache = new RL_Cache;
if ($cache->exists())
{
return $cache->get();
}
}
private static function getLinkedArticleIdsByFieldId($field_id, $article_id, $field)
{
}
private static function getOutputs($ids, $layout, $field, $settings, $apply_ordering = true)
{
$ids = array_unique($ids);
$articles = self::getArticlesByIds($ids);
if ($apply_ordering)
{
$primary_ordering = $field->fieldparams->get('articles_ordering', 'title');
$primary_direction = $field->fieldparams->get('articles_ordering_direction', 'ASC');
$secondary_ordering = $field->fieldparams->get('articles_ordering_2', 'created');
$secondary_direction = $field->fieldparams->get('articles_ordering_direction_2', 'DESC');
self::orderArticles($articles, $primary_ordering, $primary_direction, $secondary_ordering, $secondary_direction);
}
return self::getOutputsByArticles($articles, $layout, $settings);
}
private static function getOutputsByArticles($articles, $layout, $settings)
{
$outputs = [];
$total_count = count($articles);
foreach ($articles as $i => $article)
{
$output = $layout->render(compact('article', 'settings'));
if (empty($output))
{
continue;
}
$outputs[] = $output;
}
return $outputs;
}
private static function getSubformFieldIds()
{
}
private static function orderArticlesSet($articles, $ordering, $direction = 'ASC')
{
if ( ! is_array($articles) || count($articles) < 2)
{
return $articles;
}
if ($ordering == 'none')
{
return $articles;
}
self::prepareOrdering($ordering, $direction);
$ordered = [];
// Handle 1st ordering
foreach ($articles as $article)
{
$order_id = self::getArticleOrderId($article, $ordering);
if ( ! isset($ordered[$order_id]))
{
$ordered[$order_id] = [];
}
$ordered[$order_id][] = $article;
}
switch ($direction)
{
case 'DESC':
krsort($ordered);
break;
case 'ASC':
default:
ksort($ordered);
break;
}
return array_values($ordered);
}
private static function prefixOrdering(
&$ordering,
$prefix_articles = 'a',
$prefix_categories = 'c'
)
{
if (str_starts_with($ordering, 'category_'))
{
$ordering = $prefix_categories . '.' . substr($ordering, strlen('category_'));
return;
}
$ordering = $prefix_articles . '.' . $ordering;
}
private static function prepareOrdering(&$ordering, &$direction)
{
if ($ordering == 'featured')
{
$direction = $direction == 'DESC' ? 'ASC' : 'DESC';
}
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Layout\FileLayout as JLayoutFile;
if (empty($field->value))
{
return;
}
$layout = new JLayoutFile('plg_fields_articles.articles');
$include_paths = $layout->getIncludePaths();
$include_paths[] = JPATH_SITE . '/plugins/fields/articles/layouts';
$layout->setIncludePaths($include_paths);
$layout_type = $field->fieldparams->get('layout', 'title');
$value_layout = new JLayoutFile('plg_fields_articles.' . $layout_type);
$value_layout->setIncludePaths($include_paths);
echo $layout->render([
'context' => $context,
'item' => $item,
'field' => $field,
'layout_type' => $layout_type,
'layout' => $value_layout,
]);

View File

@ -0,0 +1,19 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
use Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection as JfiltersCollection;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Extension as RL_Extension;
use RegularLabs\Library\FieldsPlugin;
defined('_JEXEC') or die;
// Only used in Pro version

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="4" type="plugin" group="fields" method="upgrade">
<name>PLG_FIELDS_ARTICLESLINKED</name>
<description>PLG_FIELDS_ARTICLESLINKED_DESC</description>
<version>4.3.2</version>
<creationDate>October 2024</creationDate>
<author>Regular Labs (Peter van Westen)</author>
<authorEmail>info@regularlabs.com</authorEmail>
<authorUrl>https://regularlabs.com</authorUrl>
<copyright>Copyright © 2024 Regular Labs - All Rights Reserved</copyright>
<license>GNU General Public License version 2 or later</license>
<namespace path="src">RegularLabs\Plugin\Fields\ArticlesLinked</namespace>
<scriptfile>script.install.php</scriptfile>
<files>
<file plugin="articleslinked">articleslinked.php</file>
<folder>language</folder>
</files>
<config>
<fields name="params" addfieldprefix="RegularLabs\Library\Form\Field">
<fieldset name="basic">
<field name="@load_language_regularlabs" type="LoadLanguage" extension="plg_system_regularlabs"/>
<field name="@load_language" type="LoadLanguage" extension="plg_fields_articles"/>
<field name="@license" type="License" extension="ARTICLESFIELD"/>
<field name="@version" type="Version" extension="ARTICLESFIELD"/>
<field name="@header" type="Header" label="ARTICLESFIELD" description="ARTICLESFIELD_DESC" url="https://regularlabs.com/articlesfield"/>
<field name="@notice" type="OnlyPro" label=""/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,14 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Artikler felt - forbind andre artikler til dit indholds element"
; PLG_FIELDS_ARTICLESLINKED_LABEL="Articles - Linked (%s)"

View File

@ -0,0 +1,12 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Artikler felt - forbind andre artikler til dit indholds element"

View File

@ -0,0 +1,16 @@
;; @package Articles Field
;; @version 4.3.2
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link https://regularlabs.com
;; @copyright Copyright © 2024 Regular Labs All Rights Reserved
;; @license GNU General Public License version 2 or later
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Articles Field - connect other articles to your content item"
PLG_FIELDS_ARTICLESLINKED_LABEL="Articles - Linked (%s)"
FLDA_THE_MAIN_FIELD_PLUGIN="the main Articles Field plugin"

View File

@ -0,0 +1,12 @@
;; @package Articles Field
;; @version 4.3.2
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link https://regularlabs.com
;; @copyright Copyright © 2024 Regular Labs All Rights Reserved
;; @license GNU General Public License version 2 or later
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Articles Field - connect other articles to your content item"

View File

@ -0,0 +1,14 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Artiklite väli - ühenda teised artiklid oma sisuga"
; PLG_FIELDS_ARTICLESLINKED_LABEL="Articles - Linked (%s)"

View File

@ -0,0 +1,12 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Artiklite väli - ühenda teised artiklid oma sisuga"

View File

@ -0,0 +1,14 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Artikelveld - verbind andere artikelen met je inhoud"
; PLG_FIELDS_ARTICLESLINKED_LABEL="Articles - Linked (%s)"

View File

@ -0,0 +1,12 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Artikelveld - verbind andere artikelen met je inhoud"

View File

@ -0,0 +1,14 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Campo Artigos - conecta outros artigos para o seu item de conteúdo"
; PLG_FIELDS_ARTICLESLINKED_LABEL="Articles - Linked (%s)"

View File

@ -0,0 +1,12 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="Campo Artigos - conecta outros artigos para o seu item de conteúdo"

View File

@ -0,0 +1,14 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="文章字段 - 将其他文章与您的内容项目相关联"
; PLG_FIELDS_ARTICLESLINKED_LABEL="Articles - Linked (%s)"

View File

@ -0,0 +1,12 @@
;; @package Articles Field
;; @version 3.6.1
;;
;; @author Peter van Westen <info@regularlabs.com>
;; @link http://regularlabs.com
;; @copyright Copyright © 2021 Regular Labs All Rights Reserved
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;;
;; @translate Want to help with translations? See: https://regularlabs.com/translate
; PLG_FIELDS_ARTICLESLINKED="Fields - Regular Labs - Articles (Linked)"
PLG_FIELDS_ARTICLESLINKED_DESC="文章字段 - 将其他文章与您的内容项目相关联"

View File

@ -0,0 +1,55 @@
<?php
/**
* @package Articles Field
* @version 4.3.2
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Filesystem\File as JFile;
use Joomla\CMS\Filesystem\Folder as JFolder;
class PlgFieldsArticlesLinkedInstallerScript
{
public function postflight($install_type, $adapter)
{
if ( ! in_array($install_type, ['install', 'update']))
{
return true;
}
self::deleteJoomla3Files();
return true;
}
private static function delete($files = [])
{
foreach ($files as $file)
{
if (is_dir($file))
{
JFolder::delete($file);
}
if (is_file($file))
{
JFile::delete($file);
}
}
}
private static function deleteJoomla3Files()
{
self::delete(
[
JPATH_SITE . '/plugins/fields/articleslinked/fields',
]
);
}
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_calendar</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_CALENDAR_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Calendar</namespace>
<files>
<folder>params</folder>
<folder plugin="calendar">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_calendar.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_calendar.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="showtime"
type="radio"
label="PLG_FIELDS_CALENDAR_PARAMS_SHOWTIME_LABEL"
description="PLG_FIELDS_CALENDAR_PARAMS_SHOWTIME_DESC"
layout="joomla.form.field.radio.switcher"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.calendar
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Calendar\Extension\Calendar;
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 Calendar(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'calendar')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,56 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.calendar
*
* @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\Fields\Calendar\Extension;
use Joomla\CMS\Form\Form;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Calendar Plugin
*
* @since 3.7.0
*/
final class Calendar extends FieldsPlugin implements SubscriberInterface
{
/**
* 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 Form $form The form.
*
* @return ?\DOMElement
*
* @since 3.7.0
*/
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
{
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
if (!$fieldNode) {
return $fieldNode;
}
// Set filter to user UTC
$fieldNode->setAttribute('filter', 'USER_UTC');
// Set field to use translated formats
$fieldNode->setAttribute('translateformat', '1');
$fieldNode->setAttribute('showtime', $field->fieldparams->get('showtime', 0) ? 'true' : 'false');
return $fieldNode;
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Calendar
*
* @copyright (C) 2016 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\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
$value = $field->value;
if ($value == '') {
return;
}
if (is_array($value)) {
$value = implode(', ', $value);
}
$formatString = $field->fieldparams->get('showtime', 0) ? 'DATE_FORMAT_LC5' : 'DATE_FORMAT_LC4';
echo htmlentities(HTMLHelper::_('date', $value, Text::_($formatString)));

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_checkboxes</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_CHECKBOXES_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Checkboxes</namespace>
<files>
<folder>params</folder>
<folder plugin="checkboxes">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_checkboxes.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_checkboxes.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="options"
type="subform"
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
icon="list"
multiple="true"
>
<form hidden="true" name="list_templates_modal" repeat="true">
<field
name="name"
type="text"
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_NAME_LABEL"
/>
<field
name="value"
type="text"
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_VALUE_LABEL"
/>
</form>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="options"
type="subform"
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
icon="list"
multiple="true"
>
<form hidden="true" name="list_templates_modal" repeat="true">
<field
name="name"
type="text"
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_NAME_LABEL"
required="true"
/>
<field
name="value"
type="text"
label="PLG_FIELDS_CHECKBOXES_PARAMS_OPTIONS_VALUE_LABEL"
/>
</form>
</field>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.checkboxes
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Checkboxes\Extension\Checkboxes;
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 Checkboxes(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'checkboxes')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,63 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.checkboxes
*
* @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\Fields\Checkboxes\Extension;
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Checkboxes Plugin
*
* @since 3.7.0
*/
final class Checkboxes extends FieldsListPlugin
{
/**
* Before prepares the field value.
*
* @param string $context The context.
* @param \stdclass $item The item.
* @param \stdclass $field The field.
*
* @return void
*
* @since 3.7.0
*/
public function onCustomFieldsBeforePrepareField($context, $item, $field)
{
if (!$this->getApplication()->isClient('api')) {
return;
}
if (!$this->isTypeSupported($field->type)) {
return;
}
$field->apivalue = [];
$options = $this->getOptionsFromField($field);
if (empty($field->value)) {
return;
}
if (\is_array($field->value)) {
foreach ($field->value as $key => $value) {
$field->apivalue[$value] = $options[$value];
}
} else {
$field->apivalue[$field->value] = $options[$field->value];
}
}
}

View File

@ -0,0 +1,32 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Checkboxes
*
* @copyright (C) 2017 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\Language\Text;
/** @var \Joomla\CMS\Layout\FileLayout $this */
$fieldValue = $field->value;
if ($fieldValue === '' || $fieldValue === null) {
return;
}
$fieldValue = (array) $fieldValue;
$texts = [];
$options = $this->getOptionsFromField($field);
foreach ($options as $value => $name) {
if (in_array((string) $value, $fieldValue)) {
$texts[] = Text::_($name);
}
}
echo htmlentities(implode(', ', $texts));

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_color</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_COLOR_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Color</namespace>
<files>
<folder plugin="color">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_color.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_color.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.color
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Color\Extension\Color;
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 Color(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'color')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,51 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.color
*
* @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\Fields\Color\Extension;
use Joomla\CMS\Form\Form;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Color Plugin
*
* @since 3.7.0
*/
final class Color extends FieldsPlugin implements SubscriberInterface
{
/**
* 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 Form $form The form.
*
* @return ?\DOMElement
*
* @since 3.7.0
*/
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
{
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
if (!$fieldNode) {
return $fieldNode;
}
$fieldNode->setAttribute('validate', 'color');
return $fieldNode;
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Color
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$value = $field->value;
if ($value == '') {
return;
}
if (is_array($value)) {
$value = implode(', ', $value);
}
echo htmlentities($value);

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_editor</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_EDITOR_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Editor</namespace>
<files>
<folder>params</folder>
<folder plugin="editor">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_editor.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_editor.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="buttons"
type="radio"
label="PLG_FIELDS_EDITOR_PARAMS_SHOW_BUTTONS_LABEL"
layout="joomla.form.field.radio.switcher"
default="0"
filter="integer"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="hide"
type="plugins"
label="PLG_FIELDS_EDITOR_PARAMS_BUTTONS_HIDE_LABEL"
folder="editors-xtd"
multiple="true"
layout="joomla.form.field.list-fancy-select"
/>
<field
name="width"
type="text"
label="PLG_FIELDS_EDITOR_PARAMS_WIDTH_LABEL"
default="100%"
/>
<field
name="height"
type="text"
label="PLG_FIELDS_EDITOR_PARAMS_HEIGHT_LABEL"
default="250px"
/>
<field
name="filter"
type="list"
label="PLG_FIELDS_EDITOR_PARAMS_FILTER_LABEL"
class="list"
default="\Joomla\CMS\Component\ComponentHelper::filterText"
validate="options"
>
<option value="0">JNO</option>
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="buttons"
type="list"
label="PLG_FIELDS_EDITOR_PARAMS_SHOW_BUTTONS_LABEL"
filter="integer"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="hide"
type="plugins"
label="PLG_FIELDS_EDITOR_PARAMS_BUTTONS_HIDE_LABEL"
folder="editors-xtd"
multiple="true"
layout="joomla.form.field.list-fancy-select"
/>
<field
name="width"
type="text"
label="PLG_FIELDS_EDITOR_PARAMS_WIDTH_LABEL"
/>
<field
name="height"
type="text"
label="PLG_FIELDS_EDITOR_PARAMS_HEIGHT_LABEL"
/>
<field
name="filter"
type="list"
label="PLG_FIELDS_TEXT_PARAMS_FILTER_LABEL"
class="list"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
</field>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.editor
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Editor\Extension\Editor;
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 Editor(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'editor')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.editor
*
* @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\Fields\Editor\Extension;
use Joomla\CMS\Form\Form;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Editor Plugin
*
* @since 3.7.0
*/
final class Editor extends FieldsPlugin implements SubscriberInterface
{
/**
* 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 Form $form The form.
*
* @return ?\DOMElement
*
* @since 3.7.0
*/
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
{
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
if (!$fieldNode) {
return $fieldNode;
}
$fieldNode->setAttribute('buttons', $field->fieldparams->get('buttons', $this->params->get('buttons', 0)) ? 'true' : 'false');
$fieldNode->setAttribute('hide', implode(',', $field->fieldparams->get('hide', [])));
return $fieldNode;
}
}

View File

@ -0,0 +1,21 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Editor
*
* @copyright (C) 2017 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\HTML\HTMLHelper;
$value = $field->value;
if ($value == '') {
return;
}
echo HTMLHelper::_('content.prepare', $value);

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_imagelist</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_IMAGELIST_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Imagelist</namespace>
<files>
<folder>params</folder>
<folder plugin="imagelist">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_imagelist.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_imagelist.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="directory"
type="folderlist"
label="PLG_FIELDS_IMAGELIST_PARAMS_DIRECTORY_LABEL"
description="PLG_FIELDS_IMAGELIST_PARAMS_DIRECTORY_DESC"
directory="images"
hide_none="true"
hide_default="true"
recursive="true"
default="/"
validate="options"
>
<option value="/">/</option>
</field>
<field
name="multiple"
type="radio"
label="PLG_FIELDS_IMAGELIST_PARAMS_MULTIPLE_LABEL"
layout="joomla.form.field.radio.switcher"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="image_class"
type="textarea"
label="PLG_FIELDS_IMAGELIST_PARAMS_IMAGE_CLASS_LABEL"
validate="CssIdentifier"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="directory"
type="folderlist"
label="PLG_FIELDS_IMAGELIST_PARAMS_DIRECTORY_LABEL"
description="PLG_FIELDS_IMAGELIST_PARAMS_DIRECTORY_DESC"
directory="images"
hide_none="true"
hide_default="true"
recursive="true"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="/">/</option>
</field>
<field
name="multiple"
type="list"
label="PLG_FIELDS_IMAGELIST_PARAMS_MULTIPLE_LABEL"
filter="integer"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="image_class"
type="textarea"
label="PLG_FIELDS_IMAGELIST_PARAMS_IMAGE_CLASS_LABEL"
validate="CssIdentifier"
/>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.imagelist
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Imagelist\Extension\Imagelist;
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 Imagelist(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'imagelist')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.imagelist
*
* @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\Fields\Imagelist\Extension;
use Joomla\CMS\Form\Form;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Imagelist Plugin
*
* @since 3.7.0
*/
final class Imagelist extends FieldsPlugin implements SubscriberInterface
{
/**
* 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 Form $form The form.
*
* @return ?\DOMElement
*
* @since 3.7.0
*/
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
{
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
if (!$fieldNode) {
return $fieldNode;
}
$fieldNode->setAttribute('hide_default', 'true');
$fieldNode->setAttribute('directory', '/images/' . $fieldNode->getAttribute('directory'));
return $fieldNode;
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Imagelist
*
* @copyright (C) 2017 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\Image\Image;
if ($field->value == '') {
return;
}
$class = $fieldParams->get('image_class');
if ($class) {
// space before, so if no class sprintf below works
$class = ' class="' . htmlentities($class, ENT_COMPAT, 'UTF-8', true) . '"';
}
$value = (array) $field->value;
$buffer = '';
foreach ($value as $path) {
if (!$path || $path == '-1') {
continue;
}
$imageFilePath = htmlentities($path, ENT_COMPAT, 'UTF-8', true);
if ($fieldParams->get('directory', '/') !== '/') {
$imageInfo = Image::getImageFileProperties(JPATH_ROOT . '/images/' . $fieldParams->get('directory') . '/' . $imageFilePath);
$buffer .= sprintf(
'<img loading="lazy" width="%s" height="%s" src="images/%s/%s"%s alt="">',
$imageInfo->width,
$imageInfo->height,
$fieldParams->get('directory'),
$imageFilePath,
$class
);
} else {
$imageInfo = Image::getImageFileProperties(JPATH_ROOT . '/images/' . $imageFilePath);
$buffer .= sprintf(
'<img loading="lazy" width="%s" height="%s" src="images/%s"%s>',
$imageInfo->width,
$imageInfo->height,
$imageFilePath,
$class
);
}
}
echo $buffer;

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_integer</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_INTEGER_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Integer</namespace>
<files>
<folder>params</folder>
<folder plugin="integer">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_integer.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_integer.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="multiple"
type="radio"
label="PLG_FIELDS_INTEGER_PARAMS_MULTIPLE_LABEL"
layout="joomla.form.field.radio.switcher"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
class="form-select"
default="joomla.form.field.list"
>
<option value="joomla.form.field.list">JLIB_FORM_FIELD_PARAM_LAYOUT_BASIC_SELECT</option>
<option value="joomla.form.field.list-fancy-select">JLIB_FORM_FIELD_PARAM_LAYOUT_FANCY_SELECT</option>
</field>
<field
name="first"
type="number"
label="PLG_FIELDS_INTEGER_PARAMS_FIRST_LABEL"
default="1"
filter="integer"
/>
<field
name="last"
type="number"
label="PLG_FIELDS_INTEGER_PARAMS_LAST_LABEL"
default="100"
filter="integer"
/>
<field
name="step"
type="number"
label="PLG_FIELDS_INTEGER_PARAMS_STEP_LABEL"
default="1"
filter="integer"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="multiple"
type="list"
label="PLG_FIELDS_INTEGER_PARAMS_MULTIPLE_LABEL"
filter="integer"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="first"
type="number"
label="PLG_FIELDS_INTEGER_PARAMS_FIRST_LABEL"
filter="integer"
/>
<field
name="last"
type="number"
label="PLG_FIELDS_INTEGER_PARAMS_LAST_LABEL"
filter="integer"
/>
<field
name="step"
type="number"
label="PLG_FIELDS_INTEGER_PARAMS_STEP_LABEL"
filter="integer"
/>
</fieldset>
</fields>
<fields name="params">
<fieldset name="basic">
<fieldset name="formoptions">
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
class="form-select"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="joomla.form.field.list">JLIB_FORM_FIELD_PARAM_LAYOUT_BASIC_SELECT</option>
<option value="joomla.form.field.list-fancy-select">JLIB_FORM_FIELD_PARAM_LAYOUT_FANCY_SELECT</option>
</field>
</fieldset>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.integer
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Integer\Extension\Integer;
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 Integer(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'integer')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,27 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.integer
*
* @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\Fields\Integer\Extension;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Integer Plugin
*
* @since 3.7.0
*/
final class Integer extends FieldsPlugin implements SubscriberInterface
{
}

View File

@ -0,0 +1,25 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Integer
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$value = $field->value;
if ($value == '') {
return;
}
if (is_array($value)) {
$value = implode(', ', array_map('intval', $value));
} else {
$value = (int) $value;
}
echo $value;

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_list</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_LIST_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\ListField</namespace>
<files>
<folder>params</folder>
<folder plugin="list">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_list.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_list.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="header"
type="text"
label="PLG_FIELDS_LIST_PARAMS_HEADER_LABEL"
description="PLG_FIELDS_LIST_PARAMS_HEADER_DESC"
filter="string"
/>
<field
name="multiple"
type="radio"
label="PLG_FIELDS_LIST_PARAMS_MULTIPLE_LABEL"
layout="joomla.form.field.radio.switcher"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
class="form-select"
default="joomla.form.field.list"
>
<option value="joomla.form.field.list">JLIB_FORM_FIELD_PARAM_LAYOUT_BASIC_SELECT</option>
<option value="joomla.form.field.list-fancy-select">JLIB_FORM_FIELD_PARAM_LAYOUT_FANCY_SELECT</option>
</field>
<field
name="options"
type="subform"
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
icon="list"
multiple="true"
>
<form hidden="true" name="list_templates_modal" repeat="true">
<field
name="name"
type="text"
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_NAME_LABEL"
/>
<field
name="value"
type="text"
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_VALUE_LABEL"
/>
</form>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="header"
type="text"
label="PLG_FIELDS_LIST_PARAMS_HEADER_LABEL"
description="PLG_FIELDS_LIST_PARAMS_HEADER_DESC"
filter="string"
/>
<field
name="multiple"
type="list"
label="PLG_FIELDS_LIST_PARAMS_MULTIPLE_LABEL"
filter="integer"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="options"
type="subform"
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
icon="list"
multiple="true"
>
<form hidden="true" name="list_templates_modal" repeat="true">
<field
name="name"
type="text"
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_NAME_LABEL"
required="true"
/>
<field
name="value"
type="text"
label="PLG_FIELDS_LIST_PARAMS_OPTIONS_VALUE_LABEL"
/>
</form>
</field>
</fieldset>
</fields>
<fields name="params">
<fieldset name="basic">
<fieldset name="formoptions">
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
class="form-select"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="joomla.form.field.list">JLIB_FORM_FIELD_PARAM_LAYOUT_BASIC_SELECT</option>
<option value="joomla.form.field.list-fancy-select">JLIB_FORM_FIELD_PARAM_LAYOUT_FANCY_SELECT</option>
</field>
</fieldset>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.list
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\ListField\Extension\ListPlugin;
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 ListPlugin(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'list')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,84 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.list
*
* @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\Fields\ListField\Extension;
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields List Plugin
*
* @since 3.7.0
*/
final class ListPlugin extends FieldsListPlugin
{
/**
* Before prepares the field value.
*
* @param string $context The context.
* @param \stdclass $item The item.
* @param \stdclass $field The field.
*
* @return void
*
* @since 3.7.0
*/
public function onCustomFieldsBeforePrepareField($context, $item, $field)
{
if (!$this->getApplication()->isClient('api')) {
return;
}
if (!$this->isTypeSupported($field->type)) {
return;
}
$options = $this->getOptionsFromField($field);
$field->apivalue = [];
if (\is_array($field->value)) {
foreach ($field->value as $value) {
$field->apivalue[$value] = $options[$value];
}
} elseif (!empty($field->value)) {
$field->apivalue[$field->value] = $options[$field->value];
}
}
/**
* Prepares the field
*
* @param string $context The context.
* @param \stdclass $item The item.
* @param \stdclass $field The field.
*
* @return ?string
*
* @since 3.9.2
*/
public function onCustomFieldsPrepareField($context, $item, $field)
{
// Check if the field should be processed
if (!$this->isTypeSupported($field->type)) {
return;
}
// The field's rawvalue should be an array
if (!\is_array($field->rawvalue)) {
$field->rawvalue = (array) $field->rawvalue;
}
return parent::onCustomFieldsPrepareField($context, $item, $field);
}
}

View File

@ -0,0 +1,32 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.List
*
* @copyright (C) 2017 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\Language\Text;
/** @var \Joomla\CMS\Layout\FileLayout $this */
$fieldValue = $field->value;
if ($fieldValue == '') {
return;
}
$fieldValue = (array) $fieldValue;
$texts = [];
$options = $this->getOptionsFromField($field);
foreach ($options as $value => $name) {
if (in_array((string) $value, $fieldValue)) {
$texts[] = Text::_($name);
}
}
echo htmlentities(implode(', ', $texts));

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_media</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_MEDIA_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Media</namespace>
<files>
<folder>params</folder>
<folder plugin="media">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_media.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_media.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="directory"
type="media"
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
preview="false"
types="directories"
/>
<field
name="preview"
type="list"
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
class="list"
default="true"
validate="options"
>
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
<option value="false">JNO</option>
</field>
<field
name="image_class"
type="textarea"
label="PLG_FIELDS_MEDIA_PARAMS_IMAGE_CLASS_LABEL"
validate="CssIdentifier"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="directory"
type="media"
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
preview="false"
types="directories"
/>
<field
name="preview"
type="list"
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
<option value="false">JNO</option>
</field>
<field
name="image_class"
type="textarea"
label="PLG_FIELDS_MEDIA_PARAMS_IMAGE_CLASS_LABEL"
validate="CssIdentifier"
/>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.media
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Media\Extension\Media;
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 Media(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'media')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,96 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.media
*
* @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\Fields\Media\Extension;
use Joomla\CMS\Form\Form;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Media Plugin
*
* @since 3.7.0
*/
final class Media 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 Form $form The form.
*
* @return ?\DOMElement
*
* @since 4.0.0
*/
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
{
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
if (!$fieldNode) {
return $fieldNode;
}
$fieldNode->setAttribute('type', 'accessiblemedia');
if ($this->getApplication()->getIdentity()->authorise('core.create', 'com_media')) {
$fieldNode->setAttribute('disabled', 'false');
}
return $fieldNode;
}
/**
* Before prepares the field value.
*
* @param string $context The context.
* @param \stdclass $item The item.
* @param \stdclass $field The field.
*
* @return void
*
* @since 4.0.0
*/
public function onCustomFieldsBeforePrepareField($context, $item, $field)
{
// Check if the field should be processed by us
if (!$this->isTypeSupported($field->type)) {
return;
}
// Check if the field value is an old (string) value
$field->value = $this->checkValue($field->value);
}
/**
* Before prepares the field value.
*
* @param string $value The value to check.
*
* @return array The checked value
*
* @since 4.0.0
*/
private function checkValue($value)
{
json_decode($value);
if (json_last_error() === JSON_ERROR_NONE) {
return (array) json_decode($value, true);
}
return ['imagefile' => $value, 'alt_text' => ''];
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Media
*
* @copyright (C) 2016 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\Layout\LayoutHelper;
if (empty($field->value) || empty($field->value['imagefile'])) {
return;
}
$class = $fieldParams->get('image_class');
$options = [
'src' => $field->value['imagefile'],
'alt' => empty($field->value['alt_text']) && empty($field->value['alt_empty']) ? false : $field->value['alt_text'],
];
if ($class) {
$options['class'] = $class;
}
echo LayoutHelper::render('joomla.html.image', $options);

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="options"
type="subform"
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
icon="list"
multiple="true"
>
<form hidden="true" name="list_templates_modal" repeat="true">
<field
name="name"
type="text"
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_NAME_LABEL"
required="true"
/>
<field
name="value"
type="text"
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_VALUE_LABEL"
/>
</form>
</field>
</fieldset>
</fields>
<fields name="params">
<fieldset name="basic">
<fieldset name="formoptions">
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
class="form-select"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="joomla.form.field.radio.buttons">PLG_FIELDS_RADIO_PARAMS_FORM_LAYOUT_BUTTONS</option>
<option value="joomla.form.field.radio.switcher">PLG_FIELDS_RADIO_PARAMS_FORM_LAYOUT_SWITCHER</option>
</field>
</fieldset>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_radio</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_RADIO_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Radio</namespace>
<files>
<folder>params</folder>
<folder plugin="radio">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_radio.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_radio.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
class="form-select"
default="joomla.form.field.radio.buttons"
>
<option value="joomla.form.field.radio.buttons">PLG_FIELDS_RADIO_PARAMS_FORM_LAYOUT_BUTTONS</option>
<option value="joomla.form.field.radio.switcher">PLG_FIELDS_RADIO_PARAMS_FORM_LAYOUT_SWITCHER</option>
</field>
<field
name="options"
type="subform"
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
icon="list"
multiple="true"
>
<form hidden="true" name="list_templates_modal" repeat="true">
<field
name="name"
type="text"
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_NAME_LABEL"
/>
<field
name="value"
type="text"
label="PLG_FIELDS_RADIO_PARAMS_OPTIONS_VALUE_LABEL"
/>
</form>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.radio
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Radio\Extension\Radio;
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 Radio(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'radio')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.radio
*
* @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\Fields\Radio\Extension;
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Radio Plugin
*
* @since 3.7.0
*/
final class Radio extends FieldsListPlugin
{
/**
* Before prepares the field value.
*
* @param string $context The context.
* @param \stdclass $item The item.
* @param \stdclass $field The field.
*
* @return void
*
* @since 3.7.0
*/
public function onCustomFieldsBeforePrepareField($context, $item, $field)
{
if (!$this->getApplication()->isClient('api')) {
return;
}
if (!$this->isTypeSupported($field->type)) {
return;
}
$options = $this->getOptionsFromField($field);
$field->apivalue = [];
if (!empty($field->value)) {
$field->apivalue = [$field->value => $options[$field->value]];
}
}
}

View File

@ -0,0 +1,32 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Radio
*
* @copyright (C) 2017 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\Language\Text;
/** @var \Joomla\CMS\Layout\FileLayout $this */
$value = $field->value;
if ($value == '') {
return;
}
$value = (array) $value;
$texts = [];
$options = $this->getOptionsFromField($field);
foreach ($options as $optionValue => $optionText) {
if (in_array((string) $optionValue, $value)) {
$texts[] = Text::_($optionText);
}
}
echo htmlentities(implode(', ', $texts));

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="query"
type="textarea"
label="PLG_FIELDS_SQL_PARAMS_QUERY_LABEL"
description="PLG_FIELDS_SQL_PARAMS_QUERY_DESC"
filter="raw"
rows="10"
required="true"
/>
<field
name="header"
type="text"
label="PLG_FIELDS_SQL_PARAMS_HEADER_LABEL"
description="PLG_FIELDS_SQL_PARAMS_HEADER_DESC"
filter="string"
/>
<field
name="multiple"
type="list"
label="PLG_FIELDS_SQL_PARAMS_MULTIPLE_LABEL"
filter="integer"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<fields name="params">
<fieldset name="basic">
<fieldset name="formoptions">
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
class="form-select"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="joomla.form.field.list">JLIB_FORM_FIELD_PARAM_LAYOUT_BASIC_SELECT</option>
<option value="joomla.form.field.list-fancy-select">JLIB_FORM_FIELD_PARAM_LAYOUT_FANCY_SELECT</option>
</field>
</fieldset>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.sql
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\SQL\Extension\SQL;
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 SQL(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'sql')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_sql</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_SQL_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\SQL</namespace>
<files>
<folder>params</folder>
<folder plugin="sql">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_sql.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_sql.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="query"
type="textarea"
label="PLG_FIELDS_SQL_PARAMS_QUERY_LABEL"
description="PLG_FIELDS_SQL_PARAMS_QUERY_DESC"
rows="10"
filter="raw"
required="true"
/>
<field
name="header"
type="text"
label="PLG_FIELDS_SQL_PARAMS_HEADER_LABEL"
description="PLG_FIELDS_SQL_PARAMS_HEADER_DESC"
filter="string"
/>
<field
name="multiple"
type="radio"
layout="joomla.form.field.radio.switcher"
default="0"
label="PLG_FIELDS_SQL_PARAMS_MULTIPLE_LABEL"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
class="form-select"
default="joomla.form.field.list"
>
<option value="joomla.form.field.list">JLIB_FORM_FIELD_PARAM_LAYOUT_BASIC_SELECT</option>
<option value="joomla.form.field.list-fancy-select">JLIB_FORM_FIELD_PARAM_LAYOUT_FANCY_SELECT</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,81 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.sql
*
* @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\Fields\SQL\Extension;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Form\Form;
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields SQL Plugin
*
* @since 3.7.0
*/
final class SQL extends FieldsListPlugin
{
/**
* 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 Form $form The form.
*
* @return ?\DOMElement
*
* @since 3.7.0
*/
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
{
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
if (!$fieldNode) {
return $fieldNode;
}
$fieldNode->setAttribute('value_field', 'text');
$fieldNode->setAttribute('key_field', 'value');
return $fieldNode;
}
/**
* The save event.
*
* @param string $context The context
* @param \Joomla\CMS\Table\Table $item The table
* @param boolean $isNew Is new item
* @param array $data The validated data
*
* @return boolean
*
* @since 3.7.0
*/
public function onContentBeforeSave($context, $item, $isNew, $data = [])
{
// Only work on new SQL fields
if ($context != 'com_fields.field' || !isset($item->type) || $item->type != 'sql') {
return true;
}
// If we are not a super admin, don't let the user create or update a SQL field
if (!Access::getAssetRules(1)->allow('core.admin', $this->getApplication()->getIdentity()->getAuthorisedGroups())) {
$item->setError($this->getApplication()->getLanguage()->_('PLG_FIELDS_SQL_CREATE_NOT_POSSIBLE'));
return false;
}
return true;
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Sql
*
* @copyright (C) 2017 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\Factory;
use Joomla\Database\ParameterType;
$value = $field->value;
if ($value == '') {
return;
}
$db = Factory::getDbo();
$value = (array) $value;
$query = $db->getQuery(true);
$sql = $fieldParams->get('query', '');
$bindNames = $query->bindArray($value, ParameterType::STRING);
// Run the query with a having condition because it supports aliases
$query->setQuery($sql . ' HAVING ' . $db->quoteName('value') . ' IN (' . implode(',', $bindNames) . ')');
try {
$db->setQuery($query);
$items = $db->loadObjectList();
} catch (Exception $e) {
// If the query failed, we fetch all elements
$db->setQuery($sql);
$items = $db->loadObjectList();
}
$texts = [];
foreach ($items as $item) {
if (in_array($item->value, $value)) {
$texts[] = $item->text;
}
}
echo htmlentities(implode(', ', $texts));

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<field
name="default_value"
type="hidden"
default=""
/>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="repeat"
type="radio"
label="PLG_FIELDS_SUBFORM_PARAMS_REPEAT_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="max_rows"
type="number"
label="PLG_FIELDS_SUBFORM_PARAMS_MAX_ROWS_LABEL"
default=""
filter="integer"
showon="repeat:1"
/>
<field
name="options"
type="subform"
label="PLG_FIELDS_SUBFORM_PARAMS_OPTIONS_LABEL"
icon="list"
layout="joomla.form.field.subform.repeatable-table"
min="1"
multiple="true"
>
<form hidden="true" name="options_modal" repeat="true">
<field
context=""
name="customfield"
type="subfields"
label="PLG_FIELDS_SUBFORM_PARAMS_CUSTOMFIELD_LABEL"
default=""
required="true"
/>
<field
name="render_values"
type="radio"
label="PLG_FIELDS_SUBFORM_PARAMS_RENDER_VALUES_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</form>
</field>
</fieldset>
</fields>
<fields name="params">
<fieldset name="basic">
<fieldset name="formoptions">
<field
name="form_layout"
type="list"
label="JLIB_FORM_FIELD_PARAM_LAYOUT_LABEL"
default=""
class="form-select"
showon="repeat:1"
>
<option value="">JDEFAULT</option>
<option value="joomla.form.field.subform.repeatable-table">PLG_FIELDS_SUBFORM_PARAMS_EDIT_LAYOUT_OPTION_REPEATABLE_TABLE_LABEL</option>
<option value="joomla.form.field.subform.repeatable">PLG_FIELDS_SUBFORM_PARAMS_EDIT_LAYOUT_OPTION_REPEATABLE_FORM_LABEL</option>
</field>
</fieldset>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.subform
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Subform\Extension\Subform;
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 Subform(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'subform')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,415 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.subform
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Fields\Subform\Extension;
use Joomla\CMS\Form\Form;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Subform Plugin
*
* @since 3.7.0
*/
final class Subform extends FieldsPlugin
{
/**
* Two-dimensional array to hold to do a fast in-memory caching of rendered
* subfield values.
*
* @var array
*
* @since 4.0.0
*/
protected $renderCache = [];
/**
* Array to do a fast in-memory caching of all custom field items.
*
* @var array
*
* @since 4.0.0
*/
protected static $customFieldsCache = null;
/**
* Handles the onContentPrepareForm event. Adds form definitions to relevant forms.
*
* @param Form $form The form to manipulate
* @param array|object $data The data of the form
*
* @return void
*
* @since 4.0.0
*/
public function onContentPrepareForm(Form $form, $data)
{
// Get the path to our own form definition (basically ./params/subform.xml)
$path = $this->getFormPath($form, $data);
if ($path === null) {
return;
}
// Ensure it is an object
$formData = (object) $data;
// Now load our own form definition into a DOMDocument, because we want to manipulate it
$xml = new \DOMDocument();
$xml->load($path);
// Prepare a DOMXPath object
$xmlxpath = new \DOMXPath($xml);
/**
* Get all fields of type "subfields" in our own XML
*
* @var $valuefields \DOMNodeList
*/
$valuefields = $xmlxpath->evaluate('//field[@type="subfields"]');
// If we haven't found it, something is wrong
if (!$valuefields || $valuefields->length != 1) {
return;
}
// Now iterate over those fields and manipulate them, set its parameter `context` to our context
foreach ($valuefields as $valuefield) {
$valuefield->setAttribute('context', $formData->context);
}
// When this is not a new instance (editing an existing instance)
if (isset($formData->id) && $formData->id > 0) {
// Don't allow the 'repeat' attribute to be edited
foreach ($xmlxpath->evaluate('//field[@name="repeat"]') as $field) {
$field->setAttribute('readonly', '1');
}
}
// And now load our manipulated form definition into the JForm
$form->load($xml->saveXML(), true, '/form/*');
}
/**
* Manipulates the $field->value before the field is being passed to
* onCustomFieldsPrepareField.
*
* @param string $context The context
* @param object $item The item
* @param \stdClass $field The field
*
* @return void
*
* @since 4.0.0
*/
public function onCustomFieldsBeforePrepareField($context, $item, $field)
{
if (!$this->isTypeSupported($field->type)) {
return;
}
if (\is_array($field->value)) {
return;
}
$decoded_value = json_decode($field->value, true);
if (!$decoded_value || !\is_array($decoded_value)) {
return;
}
$field->value = $decoded_value;
}
/**
* Renders this fields value by rendering all sub fields and joining all those rendered sub fields together.
*
* @param string $context The context
* @param object $item The item
* @param \stdClass $field The field
*
* @return ?string
*
* @since 4.0.0
*/
public function onCustomFieldsPrepareField($context, $item, $field)
{
// Check if the field should be processed by us
if (!$this->isTypeSupported($field->type)) {
return;
}
// If we don't have any subfields (or values for them), nothing to do.
if (!\is_array($field->value) || \count($field->value) < 1) {
return;
}
// Get the field params
$field_params = $this->getParamsFromField($field);
/**
* Placeholder to hold all rows (if this field is repeatable).
* Each array entry is another array representing a row, containing all of the sub fields that
* are valid for this row and their raw and rendered values.
*/
$subform_rows = [];
// Create an array with entries being subfields forms, and if not repeatable, containing only one element.
$rows = $field->value;
if ($field_params->get('repeat', '1') == '0') {
$rows = [$field->value];
}
// Iterate over each row of the data
foreach ($rows as $row) {
// Holds all sub fields of this row, incl. their raw and rendered value
$row_subfields = [];
// For each row, iterate over all the subfields
foreach ($this->getSubfieldsFromField($field) as $subfield) {
// Fill value (and rawvalue) if we have data for this subfield in the current row, otherwise set them to empty
$subfield->rawvalue = $subfield->value = $row[$subfield->name] ?? '';
// Do we want to render the value of this field, and is the value non-empty?
if ($subfield->value !== '' && $subfield->render_values == '1') {
/**
* Construct the cache-key for our renderCache. It is important that the cache key
* is as unique as possible to avoid false duplicates (e.g. type and rawvalue is not
* enough for the cache key, because type 'list' and value '1' can have different
* rendered values, depending on the list items), but it also must be as general as possible
* to not cause too many unneeded rendering processes (e.g. the type 'text' will always be
* rendered the same when it has the same rawvalue).
*/
$renderCache_key = serialize(
[
$subfield->type,
$subfield->id,
$subfield->rawvalue,
]
);
// Let's see if we have a fast in-memory result for this
if (isset($this->renderCache[$renderCache_key])) {
$subfield->value = $this->renderCache[$renderCache_key];
} else {
// Render this virtual subfield
$subfield->value = $this->getApplication()->triggerEvent(
'onCustomFieldsPrepareField',
[$context, $item, $subfield]
);
$this->renderCache[$renderCache_key] = $subfield->value;
}
}
// Flatten the value if it is an array (list, checkboxes, etc.) [independent of render_values]
if (\is_array($subfield->value)) {
$subfield->value = implode(' ', $subfield->value);
}
// Store the subfield (incl. its raw and rendered value) into this rows sub fields
$row_subfields[$subfield->fieldname] = $subfield;
}
// Store all the sub fields of this row
$subform_rows[] = $row_subfields;
}
// Store all the rows and their corresponding sub fields in $field->subform_rows
$field->subform_rows = $subform_rows;
// Call our parent to combine all those together for the final $field->value
return parent::onCustomFieldsPrepareField($context, $item, $field);
}
/**
* Returns a DOMElement which is the child of $parent and represents
* the form XML definition for this field.
*
* @param \stdClass $field The field
* @param \DOMElement $parent The original parent element
* @param Form $form The form
*
* @return ?\DOMElement
*
* @since 4.0.0
*/
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
{
// Call the onCustomFieldsPrepareDom method on FieldsPlugin
$parent_field = parent::onCustomFieldsPrepareDom($field, $parent, $form);
if (!$parent_field) {
return $parent_field;
}
// Override the fieldname attribute of the subform - this is being used to index the rows
$parent_field->setAttribute('fieldname', 'row');
// If the user configured this subform instance as required
if ($field->required) {
// Then we need to have at least one row
$parent_field->setAttribute('min', '1');
}
// Get the configured parameters for this field
$field_params = $this->getParamsFromField($field);
// If this fields should be repeatable, set some attributes on the subform element
if ($field_params->get('repeat', '1') == '1') {
$parent_field->setAttribute('multiple', 'true');
$parent_field->setAttribute('layout', 'joomla.form.field.subform.repeatable-table');
}
// Create a child 'form' DOMElement under the field[type=subform] element.
$parent_fieldset = $parent_field->appendChild(new \DOMElement('form'));
$parent_fieldset->setAttribute('hidden', 'true');
$parent_fieldset->setAttribute('name', ($field->name . '_modal'));
if ($field_params->get('max_rows')) {
$parent_field->setAttribute('max', $field_params->get('max_rows'));
}
// If this field should be repeatable, set some attributes on the modal
if ($field_params->get('repeat', '1') == '1') {
$parent_fieldset->setAttribute('repeat', 'true');
}
// Get the configured sub fields for this field
$subfields = $this->getSubfieldsFromField($field);
// If we have 5 or more of them, use the `repeatable` layout instead of the `repeatable-table`
if (\count($subfields) >= 5) {
$parent_field->setAttribute('layout', 'joomla.form.field.subform.repeatable');
}
// Iterate over the sub fields to call prepareDom on each of those sub-fields
foreach ($subfields as $subfield) {
// Let the relevant plugins do their work and insert the correct
// DOMElement's into our $parent_fieldset.
$this->getApplication()->triggerEvent(
'onCustomFieldsPrepareDom',
[$subfield, $parent_fieldset, $form]
);
}
// If the edit layout is set we override any automation
$editLayout = $field->params->get('form_layout');
if ($editLayout) {
$parent_field->setAttribute('layout', $editLayout);
}
return $parent_field;
}
/**
* Returns an array of all options configured for this field.
*
* @param \stdClass $field The field
*
* @return \stdClass[]
*
* @since 4.0.0
*/
protected function getOptionsFromField(\stdClass $field)
{
$result = [];
// Fetch the options from the plugin
$params = $this->getParamsFromField($field);
foreach ($params->get('options', []) as $option) {
$result[] = (object) $option;
}
return $result;
}
/**
* Returns the configured params for a given field.
*
* @param \stdClass $field The field
*
* @return \Joomla\Registry\Registry
*
* @since 4.0.0
*/
protected function getParamsFromField(\stdClass $field)
{
$params = (clone $this->params);
if (isset($field->fieldparams) && \is_object($field->fieldparams)) {
$params->merge($field->fieldparams);
}
return $params;
}
/**
* Returns an array of all subfields for a given field. This will always return a bare clone
* of a sub field, so manipulating it is safe.
*
* @param \stdClass $field The field
*
* @return \stdClass[]
*
* @since 4.0.0
*/
protected function getSubfieldsFromField(\stdClass $field)
{
if (static::$customFieldsCache === null) {
// Prepare our cache
static::$customFieldsCache = [];
// Get all custom field instances
$customFields = FieldsHelper::getFields('', null, false, null, true);
foreach ($customFields as $customField) {
// Store each custom field instance in our cache with its id as key
static::$customFieldsCache[$customField->id] = $customField;
}
}
$result = [];
// Iterate over all configured options for this field
foreach ($this->getOptionsFromField($field) as $option) {
// Check whether the wanted sub field really is an existing custom field
if (!isset(static::$customFieldsCache[$option->customfield])) {
continue;
}
// Get a clone of the sub field, so we and the caller can do some manipulation with it.
$cur_field = (clone static::$customFieldsCache[$option->customfield]);
// Manipulate it and add our custom configuration to it
$cur_field->render_values = $option->render_values;
/**
* Set the name of the sub field to its id so that the values in the database are being saved
* based on the id of the sub fields, not on their name. Actually we do not need the name of
* the sub fields to render them, but just to make sure we have the name when we need it, we
* store it as `fieldname`.
*/
$cur_field->fieldname = $cur_field->name;
$cur_field->name = 'field' . $cur_field->id;
// And add it to our result
$result[] = $cur_field;
}
return $result;
}
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_subform</name>
<author>Joomla! Project</author>
<creationDate>2017-06</creationDate>
<copyright>(C) 2019 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>4.0.0</version>
<description>PLG_FIELDS_SUBFORM_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Subform</namespace>
<files>
<folder>params</folder>
<folder plugin="subform">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_subform.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_subform.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Subform
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
defined('_JEXEC') or die;
if (!$context || empty($field->subform_rows)) {
return;
}
$result = '';
// Iterate over each row that we have
foreach ($field->subform_rows as $subform_row) {
// Placeholder array to generate this rows output
$row_output = [];
// Iterate over each sub field inside of that row
foreach ($subform_row as $subfield) {
$class = trim($subfield->params->get('render_class', ''));
$layout = trim($subfield->params->get('layout', 'render'));
$content = trim(
FieldsHelper::render(
$context,
'field.' . $layout, // normally just 'field.render'
['field' => $subfield]
)
);
// Skip empty output
if ($content === '') {
continue;
}
// Generate the output for this sub field and row
$row_output[] = '<span class="field-entry' . ($class ? (' ' . $class) : '') . '">' . $content . '</span>';
}
// Skip empty rows
if (count($row_output) == 0) {
continue;
}
$result .= '<li>' . implode(', ', $row_output) . '</li>';
}
?>
<?php if (trim($result) != '') : ?>
<ul class="fields-container">
<?php echo $result; ?>
</ul>
<?php endif; ?>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="filter"
type="list"
label="PLG_FIELDS_TEXT_PARAMS_FILTER_LABEL"
class="list"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
<option value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
<option value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
<option value="float">JLIB_FILTER_PARAMS_FLOAT</option>
<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
</field>
<field
name="maxlength"
type="number"
label="PLG_FIELDS_TEXT_PARAMS_MAXLENGTH_LABEL"
filter="integer"
/>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.text
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Text\Extension\Text;
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 Text(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'text')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,27 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.text
*
* @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\Fields\Text\Extension;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Text Plugin
*
* @since 3.7.0
*/
final class Text extends FieldsPlugin implements SubscriberInterface
{
}

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_text</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_TEXT_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Text</namespace>
<files>
<folder>params</folder>
<folder plugin="text">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_text.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_text.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="filter"
type="list"
label="PLG_FIELDS_TEXT_PARAMS_FILTER_LABEL"
class="list"
default="\Joomla\CMS\Component\ComponentHelper::filterText"
validate="options"
>
<option value="0">JNO</option>
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
<option value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
<option value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
<option value="float">JLIB_FILTER_PARAMS_FLOAT</option>
<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
</field>
<field
name="maxlength"
type="number"
label="PLG_FIELDS_TEXT_PARAMS_MAXLENGTH_LABEL"
filter="integer"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,23 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Text
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$value = $field->value;
if ($value == '') {
return;
}
if (is_array($value)) {
$value = implode(', ', $value);
}
echo htmlentities($value);

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="rows"
type="number"
label="PLG_FIELDS_TEXTAREA_PARAMS_ROWS_LABEL"
filter="integer"
/>
<field
name="cols"
type="number"
label="PLG_FIELDS_TEXTAREA_PARAMS_COLS_LABEL"
filter="integer"
/>
<field
name="maxlength"
type="number"
label="PLG_FIELDS_TEXTAREA_PARAMS_MAXLENGTH_LABEL"
filter="integer"
/>
<field
name="filter"
type="list"
label="PLG_FIELDS_TEXTAREA_PARAMS_FILTER_LABEL"
class="list"
validate="options"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
<option value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
<option value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
<option value="float">JLIB_FILTER_PARAMS_FLOAT</option>
<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
</field>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.textarea
*
* @copyright (C) 2023 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\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Textarea\Extension\Textarea;
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 Textarea(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'textarea')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,27 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.textarea
*
* @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\Fields\Textarea\Extension;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields Textarea Plugin
*
* @since 3.7.0
*/
final class Textarea extends FieldsPlugin implements SubscriberInterface
{
}

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_textarea</name>
<author>Joomla! Project</author>
<creationDate>2016-03</creationDate>
<copyright>(C) 2016 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_FIELDS_TEXTAREA_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Textarea</namespace>
<files>
<folder>params</folder>
<folder plugin="textarea">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_textarea.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_textarea.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="rows"
type="number"
label="PLG_FIELDS_TEXTAREA_PARAMS_ROWS_LABEL"
default="10"
filter="integer"
/>
<field
name="cols"
type="number"
label="PLG_FIELDS_TEXTAREA_PARAMS_COLS_LABEL"
default="10"
filter="integer"
/>
<field
name="maxlength"
type="number"
label="PLG_FIELDS_TEXTAREA_PARAMS_MAXLENGTH_LABEL"
filter="integer"
/>
<field
name="filter"
type="list"
label="PLG_FIELDS_TEXTAREA_PARAMS_FILTER_LABEL"
class="list"
default="\Joomla\CMS\Component\ComponentHelper::filterText"
validate="options"
>
<option value="0">JNO</option>
<option value="raw">JLIB_FILTER_PARAMS_RAW</option>
<option value="safehtml">JLIB_FILTER_PARAMS_SAFEHTML</option>
<option value="\Joomla\CMS\Component\ComponentHelper::filterText">JLIB_FILTER_PARAMS_TEXT</option>
<option value="alnum">JLIB_FILTER_PARAMS_ALNUM</option>
<option value="integer">JLIB_FILTER_PARAMS_INTEGER</option>
<option value="float">JLIB_FILTER_PARAMS_FLOAT</option>
<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,21 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.Textarea
*
* @copyright (C) 2017 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\HTML\HTMLHelper;
$value = $field->value;
if ($value == '') {
return;
}
echo HTMLHelper::_('content.prepare', $value);

Some files were not shown because too many files have changed in this diff Show More