From 60f4e8af32aaa837da92bd4276f2c9ea7cf024be Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 19 Jan 2021 00:10:59 +0200 Subject: [PATCH] Added new filters to admin, and custom admin, and site list view. gh-651 --- README.md | 2 +- admin/README.txt | 2 +- admin/helpers/componentbuilder.php | 118 ++++++++++++++++- .../en-GB/en-GB.com_componentbuilder.ini | 2 + admin/models/admin_views.php | 83 ++++++++++++ admin/models/custom_admin_views.php | 119 +++++++++++++++++- admin/models/fields.php | 10 +- admin/models/fieldtype.php | 4 +- .../forms/filter_custom_admin_views.xml | 3 +- admin/models/site_views.php | 83 ++++++++++++ .../views/custom_admin_views/tmpl/default.php | 1 + site/helpers/componentbuilder.php | 118 ++++++++++++++++- 12 files changed, 524 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f61976c9e..9e760a0f1 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ TODO + *Version*: 2.12.5 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **292985** ++ *Line count*: **293488** + *Field count*: **1611** + *File count*: **1934** + *Folder count*: **322** diff --git a/admin/README.txt b/admin/README.txt index f61976c9e..9e760a0f1 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -147,7 +147,7 @@ TODO + *Version*: 2.12.5 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **292985** ++ *Line count*: **293488** + *Field count*: **1611** + *File count*: **1934** + *Folder count*: **322** diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index dff0bcea2..4b2058b96 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -2110,7 +2110,7 @@ abstract class ComponentbuilderHelper // get the extension values foreach ($extensions as $extension => $label) { - ${$extension} = self::getExtensionTypeIdSystemName($extension); + ${$extension} = self::getByTypeTheIdsSystemNames($extension); } $xml = new DOMDocument(); @@ -2151,9 +2151,9 @@ abstract class ComponentbuilderHelper } /** - * get extentions ids and system names + * get by type the ids and system names **/ - public static function getExtensionTypeIdSystemName($type, $limiter = null) + public static function getByTypeTheIdsSystemNames($type, $limiter = null) { $db = JFactory::getDbo(); $query = $db->getQuery(true); @@ -2212,13 +2212,22 @@ abstract class ComponentbuilderHelper } /** - * get any extension field IDs + * get any area linked IDs */ - public static function getExtensionFieldIDs($extension, $type) + public static function getAreaLinkedIDs($extension, $type) { // yes we use switches switch ($type) { + case 'joomla_component_admin_views': + return self::getComponentAdminViewsIDs($extension); + break; + case 'joomla_component_custom_admin_views': + return self::getComponentCustomAdminViewsIDs($extension); + break; + case 'joomla_component_site_views': + return self::getComponentSiteViewsIDs($extension); + break; case 'joomla_component': return self::getComponentFieldsIDs($extension); break; @@ -2237,6 +2246,105 @@ abstract class ComponentbuilderHelper } } + /** + * get a component admin views IDs + */ + public static function getComponentAdminViewsIDs($id) + { + // get all this components views + $adminviewIds = array(); + // get the views of this component + if ($addViews = self::getVar('component_admin_views', (int) $id, 'joomla_component', 'addadmin_views')) + { + if (self::checkJson($addViews)) + { + $addViews = json_decode($addViews, true); + if (self::checkArray($addViews)) + { + foreach($addViews as $addView) + { + if (isset($addView['adminview'])) + { + $adminviewIds[(int) $addView['adminview']] = (int) $addView['adminview']; + } + } + } + } + } + // check that we have fields + if (self::checkArray($adminviewIds)) + { + return array_values($adminviewIds); + } + return false; + } + + /** + * get a component custom admin views IDs + */ + public static function getComponentCustomAdminViewsIDs($id) + { + // get all this components views + $adminviewIds = array(); + // get the views of this component + if ($addViews = self::getVar('component_custom_admin_views', (int) $id, 'joomla_component', 'addcustom_admin_views')) + { + if (self::checkJson($addViews)) + { + $addViews = json_decode($addViews, true); + if (self::checkArray($addViews)) + { + foreach($addViews as $addView) + { + if (isset($addView['customadminview'])) + { + $adminviewIds[(int) $addView['customadminview']] = (int) $addView['customadminview']; + } + } + } + } + } + // check that we have fields + if (self::checkArray($adminviewIds)) + { + return array_values($adminviewIds); + } + return false; + } + + /** + * get a component site views IDs + */ + public static function getComponentSiteViewsIDs($id) + { + // get all this components views + $adminviewIds = array(); + // get the views of this component + if ($addViews = self::getVar('component_site_views', (int) $id, 'joomla_component', 'addsite_views')) + { + if (self::checkJson($addViews)) + { + $addViews = json_decode($addViews, true); + if (self::checkArray($addViews)) + { + foreach($addViews as $addView) + { + if (isset($addView['siteview'])) + { + $adminviewIds[(int) $addView['siteview']] = (int) $addView['siteview']; + } + } + } + } + } + // check that we have fields + if (self::checkArray($adminviewIds)) + { + return array_values($adminviewIds); + } + return false; + } + /** * get a component fields IDs */ diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 31c60440b..628618656 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -8082,6 +8082,7 @@ COM_COMPONENTBUILDER_NOT_SET="not set" COM_COMPONENTBUILDER_NOT_TRANSLATED_IN="Not translated in" COM_COMPONENTBUILDER_NO_ACCESS_GRANTED="No Access Granted!" COM_COMPONENTBUILDER_NO_ADMIN_VIEWS_FOUND="No Admin Views Found" +COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND="No Components Found" COM_COMPONENTBUILDER_NO_COMPONENTS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN="No components were selected, please make a selection and try again!" COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE="No component details found, so it is not safe to continue!" COM_COMPONENTBUILDER_NO_COMPONENT_WAS_SELECTED_PLEASE_MAKE_A_SELECTION_OF_ONE_COMPONENT_AND_TRY_AGAIN="No component was selected, please make a selection of one component and try again!" @@ -8285,6 +8286,7 @@ COM_COMPONENTBUILDER_SELECT_ADMIN_VIEW="Select Admin View" COM_COMPONENTBUILDER_SELECT_AN_OPTION="Select an option" COM_COMPONENTBUILDER_SELECT_A_PROPERTY="Select a property" COM_COMPONENTBUILDER_SELECT_A_SNIPPET="select a snippet" +COM_COMPONENTBUILDER_SELECT_COMPONENT="Select Component" COM_COMPONENTBUILDER_SELECT_EXTENSION="Select Extension" COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_COMPILE="Select the component to compile" COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_YOUR_WOULD_LIKE_TO_IMPORT="Select the component your would like to import." diff --git a/admin/models/admin_views.php b/admin/models/admin_views.php index 4c1c2f74a..6ad633d89 100644 --- a/admin/models/admin_views.php +++ b/admin/models/admin_views.php @@ -42,6 +42,51 @@ class ComponentbuilderModelAdmin_views extends JModelList } parent::__construct($config); + } + + /** + * Get the filter form - Override the parent method + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|boolean The \JForm object or false on error + * + * @since JCB 2.12.5 + */ + public function getFilterForm($data = array(), $loadData = true) + { + // load form from the parent class + $form = parent::getFilterForm($data, $loadData); + + // Create the "joomla_component" filter + $attributes = array( + 'name' => 'joomla_component', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . JText::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -' + ); + // check if we have joomla components + if (($joomla_components = ComponentbuilderHelper::getByTypeTheIdsSystemNames('joomla_component')) !== false) + { + $options = array( + '' => '- ' . JText::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -' + ); + // make sure we do not lose the key values in normal merge + $options = $options + $joomla_components; + } + + $form->setField(ComponentbuilderHelper::getFieldXML($attributes, $options),'filter'); + $form->setValue( + 'joomla_component', + 'filter', + $this->state->get("filter.joomla_component") + ); + array_push($this->filter_fields, 'joomla_component'); + + return $form; } /** @@ -301,6 +346,25 @@ class ComponentbuilderModelAdmin_views extends JModelList // From the componentbuilder_item table $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_joomla_component, 'joomla_component_admin_views')) !== false) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + // Filter by published state $published = $this->getState('filter.published'); if (is_numeric($published)) @@ -516,6 +580,25 @@ class ComponentbuilderModelAdmin_views extends JModelList { $query->where('a.id IN (' . implode(',',$pks) . ')'); } + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_joomla_component, 'joomla_component_admin_views')) !== false) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } // Implement View Level Access if (!$user->authorise('core.options', 'com_componentbuilder')) { diff --git a/admin/models/custom_admin_views.php b/admin/models/custom_admin_views.php index 918a1aab4..d1431832c 100644 --- a/admin/models/custom_admin_views.php +++ b/admin/models/custom_admin_views.php @@ -40,6 +40,51 @@ class ComponentbuilderModelCustom_admin_views extends JModelList } parent::__construct($config); + } + + /** + * Get the filter form - Override the parent method + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|boolean The \JForm object or false on error + * + * @since JCB 2.12.5 + */ + public function getFilterForm($data = array(), $loadData = true) + { + // load form from the parent class + $form = parent::getFilterForm($data, $loadData); + + // Create the "joomla_component" filter + $attributes = array( + 'name' => 'joomla_component', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . JText::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -' + ); + // check if we have joomla components + if (($joomla_components = ComponentbuilderHelper::getByTypeTheIdsSystemNames('joomla_component')) !== false) + { + $options = array( + '' => '- ' . JText::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -' + ); + // make sure we do not lose the key values in normal merge + $options = $options + $joomla_components; + } + + $form->setField(ComponentbuilderHelper::getFieldXML($attributes, $options),'filter'); + $form->setValue( + 'joomla_component', + 'filter', + $this->state->get("filter.joomla_component") + ); + array_push($this->filter_fields, 'joomla_component'); + + return $form; } /** @@ -240,6 +285,25 @@ class ComponentbuilderModelCustom_admin_views extends JModelList // From the componentbuilder_item table $query->from($db->quoteName('#__componentbuilder_custom_admin_view', 'a')); + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_joomla_component, 'joomla_component_custom_admin_views')) !== false) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + // From the componentbuilder_dynamic_get table. $query->select($db->quoteName('g.name','main_get_name')); $query->join('LEFT', $db->quoteName('#__componentbuilder_dynamic_get', 'g') . ' ON (' . $db->quoteName('a.main_get') . ' = ' . $db->quoteName('g.id') . ')'); @@ -309,6 +373,29 @@ class ComponentbuilderModelCustom_admin_views extends JModelList { $query->where('a.main_get = ' . $db->quote($db->escape($_main_get))); } + elseif (ComponentbuilderHelper::checkArray($_main_get)) + { + // Secure the array for the query + $_main_get = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (ComponentbuilderHelper::checkString($val)) + { + return $db->quote($db->escape($val)); + } + }, $_main_get); + // Filter by the Main_get Array. + $query->where('a.main_get IN (' . implode(',', $_main_get) . ')'); + } // Filter by Add_php_ajax. $_add_php_ajax = $this->getState('filter.add_php_ajax'); if (is_numeric($_add_php_ajax)) @@ -402,6 +489,25 @@ class ComponentbuilderModelCustom_admin_views extends JModelList { $query->where('a.id IN (' . implode(',',$pks) . ')'); } + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_joomla_component, 'joomla_component_custom_admin_views')) !== false) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } // Implement View Level Access if (!$user->authorise('core.options', 'com_componentbuilder')) { @@ -528,7 +634,18 @@ class ComponentbuilderModelCustom_admin_views extends JModelList $id .= ':' . $this->getState('filter.ordering'); $id .= ':' . $this->getState('filter.created_by'); $id .= ':' . $this->getState('filter.modified_by'); - $id .= ':' . $this->getState('filter.main_get'); + // Check if the value is an array + $_main_get = $this->getState('filter.main_get'); + if (ComponentbuilderHelper::checkArray($_main_get)) + { + $id .= ':' . implode(':', $_main_get); + } + // Check if this is only an number or string + elseif (is_numeric($_main_get) + || ComponentbuilderHelper::checkString($_main_get)) + { + $id .= ':' . $_main_get; + } $id .= ':' . $this->getState('filter.add_php_ajax'); $id .= ':' . $this->getState('filter.add_custom_button'); $id .= ':' . $this->getState('filter.system_name'); diff --git a/admin/models/fields.php b/admin/models/fields.php index 63901ad6d..4a56de252 100644 --- a/admin/models/fields.php +++ b/admin/models/fields.php @@ -81,7 +81,7 @@ class ComponentbuilderModelFields extends JModelList '' => '- ' . JText::_('COM_COMPONENTBUILDER_NO_ADMIN_VIEWS_FOUND') . ' -' ); // check if we have admin views (and limit to an extension if it is set) - if (($admin_views = ComponentbuilderHelper::getExtensionTypeIdSystemName('admin_view', $this->state->get("filter.extension"))) !== false) + if (($admin_views = ComponentbuilderHelper::getByTypeTheIdsSystemNames('admin_view', $this->state->get("filter.extension"))) !== false) { $options = array( '' => '- ' . JText::_('COM_COMPONENTBUILDER_SELECT_ADMIN_VIEW') . ' -' @@ -378,7 +378,7 @@ class ComponentbuilderModelFields extends JModelList { // column name, and id $type_extension = explode('__', $filter_extension); - if (($ids = ComponentbuilderHelper::getExtensionFieldIDs($type_extension[1], $type_extension[0])) !== false) + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($type_extension[1], $type_extension[0])) !== false) { $field_ids = $ids; } @@ -394,7 +394,7 @@ class ComponentbuilderModelFields extends JModelList $filter_admin_view = $this->state->get("filter.admin_view"); if ($get_ids && $filter_admin_view !== null && !empty($filter_admin_view)) { - if (($ids = ComponentbuilderHelper::getExtensionFieldIDs($filter_admin_view, 'admin_view')) !== false) + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_admin_view, 'admin_view')) !== false) { // view will return less fields, so we ignore the component $field_ids = $ids; @@ -643,7 +643,7 @@ class ComponentbuilderModelFields extends JModelList { // column name, and id $type_extension = explode('__', $filter_extension); - if (($ids = ComponentbuilderHelper::getExtensionFieldIDs($type_extension[1], $type_extension[0])) !== false) + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($type_extension[1], $type_extension[0])) !== false) { $field_ids = $ids; } @@ -659,7 +659,7 @@ class ComponentbuilderModelFields extends JModelList $filter_admin_view = $this->state->get("filter.admin_view"); if ($get_ids && $filter_admin_view !== null && !empty($filter_admin_view)) { - if (($ids = ComponentbuilderHelper::getExtensionFieldIDs($filter_admin_view, 'admin_view')) !== false) + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_admin_view, 'admin_view')) !== false) { // view will return less fields, so we ignore the component $field_ids = $ids; diff --git a/admin/models/fieldtype.php b/admin/models/fieldtype.php index ca1a56a5d..71404c973 100644 --- a/admin/models/fieldtype.php +++ b/admin/models/fieldtype.php @@ -276,7 +276,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin { // column name, and id $type_extension = explode('__', $filter_extension); - if (($ids = ComponentbuilderHelper::getExtensionFieldIDs($type_extension[1], $type_extension[0])) !== false) + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($type_extension[1], $type_extension[0])) !== false) { $field_ids = $ids; } @@ -292,7 +292,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin $filter_admin_view = $this->state->get("filter.admin_view"); if ($get_ids && $filter_admin_view !== null && !empty($filter_admin_view)) { - if (($ids = ComponentbuilderHelper::getExtensionFieldIDs($filter_admin_view, 'admin_view')) !== false) + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_admin_view, 'admin_view')) !== false) { // view will return less fields, so we ignore the component $field_ids = $ids; diff --git a/admin/models/forms/filter_custom_admin_views.xml b/admin/models/forms/filter_custom_admin_views.xml index c71190273..53f95d4ab 100644 --- a/admin/models/forms/filter_custom_admin_views.xml +++ b/admin/models/forms/filter_custom_admin_views.xml @@ -34,7 +34,8 @@ type="maingets" name="main_get" label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_MAIN_GET_LABEL" - multiple="false" + class="multipleMaingets" + multiple="true" onchange="this.form.submit();" /> 'joomla_component', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . JText::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -' + ); + // check if we have joomla components + if (($joomla_components = ComponentbuilderHelper::getByTypeTheIdsSystemNames('joomla_component')) !== false) + { + $options = array( + '' => '- ' . JText::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -' + ); + // make sure we do not lose the key values in normal merge + $options = $options + $joomla_components; + } + + $form->setField(ComponentbuilderHelper::getFieldXML($attributes, $options),'filter'); + $form->setValue( + 'joomla_component', + 'filter', + $this->state->get("filter.joomla_component") + ); + array_push($this->filter_fields, 'joomla_component'); + + return $form; } /** @@ -248,6 +293,25 @@ class ComponentbuilderModelSite_views extends JModelList // From the componentbuilder_item table $query->from($db->quoteName('#__componentbuilder_site_view', 'a')); + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_joomla_component, 'joomla_component_site_views')) !== false) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + // From the componentbuilder_dynamic_get table. $query->select($db->quoteName('g.name','main_get_name')); $query->join('LEFT', $db->quoteName('#__componentbuilder_dynamic_get', 'g') . ' ON (' . $db->quoteName('a.main_get') . ' = ' . $db->quoteName('g.id') . ')'); @@ -433,6 +497,25 @@ class ComponentbuilderModelSite_views extends JModelList { $query->where('a.id IN (' . implode(',',$pks) . ')'); } + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_joomla_component, 'joomla_component_site_views')) !== false) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } // Implement View Level Access if (!$user->authorise('core.options', 'com_componentbuilder')) { diff --git a/admin/views/custom_admin_views/tmpl/default.php b/admin/views/custom_admin_views/tmpl/default.php index 662044e17..07086ab35 100644 --- a/admin/views/custom_admin_views/tmpl/default.php +++ b/admin/views/custom_admin_views/tmpl/default.php @@ -15,6 +15,7 @@ defined('_JEXEC') or die('Restricted access'); JHtml::_('behavior.tooltip'); JHtml::_('behavior.multiselect'); JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleMaingets', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_MAIN_GET') . ' -')); JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); JHtml::_('formbehavior.chosen', 'select'); if ($this->saveOrder) diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index b2a889b28..1a87d7a5d 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -2107,7 +2107,7 @@ abstract class ComponentbuilderHelper // get the extension values foreach ($extensions as $extension => $label) { - ${$extension} = self::getExtensionTypeIdSystemName($extension); + ${$extension} = self::getByTypeTheIdsSystemNames($extension); } $xml = new DOMDocument(); @@ -2148,9 +2148,9 @@ abstract class ComponentbuilderHelper } /** - * get extentions ids and system names + * get by type the ids and system names **/ - public static function getExtensionTypeIdSystemName($type, $limiter = null) + public static function getByTypeTheIdsSystemNames($type, $limiter = null) { $db = JFactory::getDbo(); $query = $db->getQuery(true); @@ -2209,13 +2209,22 @@ abstract class ComponentbuilderHelper } /** - * get any extension field IDs + * get any area linked IDs */ - public static function getExtensionFieldIDs($extension, $type) + public static function getAreaLinkedIDs($extension, $type) { // yes we use switches switch ($type) { + case 'joomla_component_admin_views': + return self::getComponentAdminViewsIDs($extension); + break; + case 'joomla_component_custom_admin_views': + return self::getComponentCustomAdminViewsIDs($extension); + break; + case 'joomla_component_site_views': + return self::getComponentSiteViewsIDs($extension); + break; case 'joomla_component': return self::getComponentFieldsIDs($extension); break; @@ -2234,6 +2243,105 @@ abstract class ComponentbuilderHelper } } + /** + * get a component admin views IDs + */ + public static function getComponentAdminViewsIDs($id) + { + // get all this components views + $adminviewIds = array(); + // get the views of this component + if ($addViews = self::getVar('component_admin_views', (int) $id, 'joomla_component', 'addadmin_views')) + { + if (self::checkJson($addViews)) + { + $addViews = json_decode($addViews, true); + if (self::checkArray($addViews)) + { + foreach($addViews as $addView) + { + if (isset($addView['adminview'])) + { + $adminviewIds[(int) $addView['adminview']] = (int) $addView['adminview']; + } + } + } + } + } + // check that we have fields + if (self::checkArray($adminviewIds)) + { + return array_values($adminviewIds); + } + return false; + } + + /** + * get a component custom admin views IDs + */ + public static function getComponentCustomAdminViewsIDs($id) + { + // get all this components views + $adminviewIds = array(); + // get the views of this component + if ($addViews = self::getVar('component_custom_admin_views', (int) $id, 'joomla_component', 'addcustom_admin_views')) + { + if (self::checkJson($addViews)) + { + $addViews = json_decode($addViews, true); + if (self::checkArray($addViews)) + { + foreach($addViews as $addView) + { + if (isset($addView['customadminview'])) + { + $adminviewIds[(int) $addView['customadminview']] = (int) $addView['customadminview']; + } + } + } + } + } + // check that we have fields + if (self::checkArray($adminviewIds)) + { + return array_values($adminviewIds); + } + return false; + } + + /** + * get a component site views IDs + */ + public static function getComponentSiteViewsIDs($id) + { + // get all this components views + $adminviewIds = array(); + // get the views of this component + if ($addViews = self::getVar('component_site_views', (int) $id, 'joomla_component', 'addsite_views')) + { + if (self::checkJson($addViews)) + { + $addViews = json_decode($addViews, true); + if (self::checkArray($addViews)) + { + foreach($addViews as $addView) + { + if (isset($addView['siteview'])) + { + $adminviewIds[(int) $addView['siteview']] = (int) $addView['siteview']; + } + } + } + } + } + // check that we have fields + if (self::checkArray($adminviewIds)) + { + return array_values($adminviewIds); + } + return false; + } + /** * get a component fields IDs */