diff --git a/administrator/language/en-GB/en-GB.plg_fields_displaylist.ini b/administrator/language/en-GB/en-GB.plg_fields_displaylist.ini new file mode 100644 index 0000000000000..e6ad5d3aa4098 --- /dev/null +++ b/administrator/language/en-GB/en-GB.plg_fields_displaylist.ini @@ -0,0 +1,15 @@ +; +; Displaylist language file +; + +PLG_FIELDS_DISPLAYLIST="Fields - Display List" +PLG_FIELDS_DISPLAYLIST_LABEL="Display List (%s)" +PLG_FIELDS_DISPLAYLIST_XML_DESCRIPTION="Plugin to create display list for Joomla custom fields" +PLG_FIELDS_DISPLAYLIST_OUTPUTMODE_LABEL="Output mode" +PLG_DISPLAYLIST_SAMPLE_DESCRIPTION="Set the output mode for the display list" +PLG_FIELDS_DISPLAYLIST_UNORDERED_LIST="Unordered list" +PLG_FIELDS_DISPLAYLIST_ORDERED_LIST="Ordered list" +PLG_FIELDS_DISPLAYLIST_PARAMS_LIST_NAME_LABEL="List Name" +PLG_FIELDS_DISPLAYLIST_PARAMS_LIST_NAME_DESC="" +PLG_FIELDS_DISPLAYLISTS_PARAMS_OPTIONS_LABEL="List Items" +PLG_FIELDS_DISPLAYLISTS_LIST_ITEM_LABEL="List item" diff --git a/administrator/language/en-GB/en-GB.plg_fields_displaylist.sys.ini b/administrator/language/en-GB/en-GB.plg_fields_displaylist.sys.ini new file mode 100644 index 0000000000000..954752eebe3e5 --- /dev/null +++ b/administrator/language/en-GB/en-GB.plg_fields_displaylist.sys.ini @@ -0,0 +1,13 @@ +; +; Displaylist language file +; + +PLG_FIELDS_DISPLAYLIST="Fields - Display List" +PLG_FIELDS_DISPLAYLIST_LABEL="Display List (%s)" +PLG_FIELDS_DISPLAYLIST_XML_DESCRIPTION="Plugin to create display list for Joomla custom fields" +PLG_FIELDS_DISPLAYLIST_OUTPUTMODE_LABEL="Output mode" +PLG_DISPLAYLIST_SAMPLE_DESCRIPTION="Set the output mode for the display list" +PLG_FIELDS_DISPLAYLIST_UNORDERED_LIST="Unordered list" +PLG_FIELDS_DISPLAYLIST_ORDERED_LIST="Ordered list" +PLG_FIELDS_DISPLAYLIST_PARAMS_LIST_NAME_LABEL="List Name" +PLG_FIELDS_DISPLAYLISTS_PARAMS_OPTIONS_LABEL="Display List Values" diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 72dddaa5bb888..a4affc90860ce 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -643,6 +643,7 @@ INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `elem (478, 0, 'plg_editors-xtd_fields', 'plugin', 'fields', 'editors-xtd', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (479, 0, 'plg_sampledata_blog', 'plugin', 'blog', 'sampledata', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (480, 0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), +(481, 0, 'plg_fields_displaylist', 'plugin', 'displaylist', 'fields', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (503, 0, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (504, 0, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (506, 0, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index d5686a2e6f61c..97e81054bdca8 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -657,6 +657,7 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem (478, 0, 'plg_editors-xtd_fields', 'plugin', 'fields', 'editors-xtd', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (479, 0, 'plg_sampledata_blog', 'plugin', 'blog', 'sampledata', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (480, 0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), +(481, 0, 'plg_fields_displaylist', 'plugin', 'displaylist', 'fields', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (503, 0, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '1970-01-01 00:00:00', 0, 0), (504, 0, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '1970-01-01 00:00:00', 0, 0), (506, 0, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '1970-01-01 00:00:00', 0, 0), diff --git a/installation/sql/sqlazure/joomla.sql b/installation/sql/sqlazure/joomla.sql index 49e643241b005..1033523639bb5 100644 --- a/installation/sql/sqlazure/joomla.sql +++ b/installation/sql/sqlazure/joomla.sql @@ -872,6 +872,7 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem (478, 0, 'plg_editors-xtd_fields', 'plugin', 'fields', 'editors-xtd', 0, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), (479, 0, 'plg_sampledata_blog', 'plugin', 'blog', 'sampledata', 0, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), (480, 0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), +(481, 0, 'plg_fields_displaylist', 'plugin', 'displaylist', 'fields', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (503, 0, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '1900-01-01 00:00:00', 0, 0), (504, 0, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '1900-01-01 00:00:00', 0, 0), (506, 0, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '1900-01-01 00:00:00', 0, 0), diff --git a/plugins/fields/displaylist/displaylist.php b/plugins/fields/displaylist/displaylist.php new file mode 100644 index 0000000000000..ff3375bece61b --- /dev/null +++ b/plugins/fields/displaylist/displaylist.php @@ -0,0 +1,121 @@ +setAttribute('type', 'subform'); + $fieldNode->setAttribute('multiple', 'true'); + $fieldNode->setAttribute('formsource', '/plugins/fields/displaylist/params/displaylist.xml'); + $fieldNode->setAttribute('layout', 'joomla.form.field.subform.repeatable-table'); + + // Return the node + return $fieldNode; + } + + /** + * The save event. + * + * @param string $context The context + * @param JTable $item The article data + * @param boolean $isNew Is new item + * @param array $data The validated data + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + public function onContentAfterSave($context, $item, $isNew, $data = array()) + { + // Create correct context for category + if ($context == 'com_categories.category') + { + $context = $item->get('extension') . '.categories'; + + // Set the catid on the category to get only the fields which belong to this category + $item->set('catid', $item->get('id')); + } + + // Check the context + $parts = FieldsHelper::extract($context, $item); + + if (!$parts) + { + return true; + } + + // Compile the right context for the fields + $context = $parts[0] . '.' . $parts[1]; + + // Loading the fields + $fields = FieldsHelper::getFields($context, $item); + + if (!$fields) + { + return true; + } + + // Get the fields data + $fieldsData = !empty($data['com_fields']) ? $data['com_fields'] : array(); + + // Loading the model + /** @var FieldsModelField $model */ + $model = BaseDatabaseModel::getInstance('Field', 'FieldsModel', array('ignore_request' => true)); + + // Loop over the fields + foreach ($fields as $field) + { + // Find the field of this type displaylist + if ($field->type === $this->_name) + { + // Determine the value if it is available from the data + $value = key_exists($field->name, $fieldsData) ? $fieldsData[$field->name] : null; + + // Setting the value for the field and the item + $value = json_encode($value); + + // Setting the value for the field and the item + $model->setFieldValue($field->id, $item->get('id'), $value); + } + } + + return true; + } +} diff --git a/plugins/fields/displaylist/displaylist.xml b/plugins/fields/displaylist/displaylist.xml new file mode 100644 index 0000000000000..7013af178c520 --- /dev/null +++ b/plugins/fields/displaylist/displaylist.xml @@ -0,0 +1,21 @@ + + + plg_fields_displaylist + Joomla! Project + April 2018 + Copyright (C) 2005 - 2018 Open Source Matters. All rights reserved. + GNU General Public License version 2 or later; see LICENSE.txt + admin@joomla.org + www.joomla.org + __DEPLOY_VERSION__ + PLG_FIELDS_DISPLAYLIST_XML_DESCRIPTION + + displaylist.php + params + tmpl + + + en-GB/en-GB.plg_fields_displaylist.ini + en-GB/en-GB.plg_fields_displaylist.sys.ini + + diff --git a/plugins/fields/displaylist/params/displaylist.xml b/plugins/fields/displaylist/params/displaylist.xml new file mode 100644 index 0000000000000..43678520a4013 --- /dev/null +++ b/plugins/fields/displaylist/params/displaylist.xml @@ -0,0 +1,16 @@ + +
+ +
+ + +
+
+
diff --git a/plugins/fields/displaylist/tmpl/displaylist.php b/plugins/fields/displaylist/tmpl/displaylist.php new file mode 100644 index 0000000000000..71e2d99a302aa --- /dev/null +++ b/plugins/fields/displaylist/tmpl/displaylist.php @@ -0,0 +1,36 @@ +value; + +if ($fieldValue === '') +{ + return; +} + +// Get the values +$fieldValues = json_decode($fieldValue, true); + +if (empty($fieldValues)) +{ + return; +} + +$html = ''; + +echo $html;