diff --git a/build.xml b/build.xml index 8e908ff..9b01416 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ - + diff --git a/mod_jlcontentfieldsfilter/assets/javascript/jlcontentfilter.js b/mod_jlcontentfieldsfilter/assets/javascript/jlcontentfilter.js index aca4df4..6291183 100644 --- a/mod_jlcontentfieldsfilter/assets/javascript/jlcontentfilter.js +++ b/mod_jlcontentfieldsfilter/assets/javascript/jlcontentfilter.js @@ -49,7 +49,7 @@ var JlContentFieldsFilter = { this.loadData(id); } else if (params.autho_send === 1) { - jQuery(id).submit(); + jQuery(form).submit(); } return false; }, diff --git a/mod_jlcontentfieldsfilter/helper.php b/mod_jlcontentfieldsfilter/helper.php index 9e79d88..245d479 100644 --- a/mod_jlcontentfieldsfilter/helper.php +++ b/mod_jlcontentfieldsfilter/helper.php @@ -92,12 +92,16 @@ function ($f) { $field = self::setHiddenOptions($field, $category_id, $option); } - $displayData = array('field' => $field, 'params' => $params, 'moduleId' => $moduleId, 'rangedata' => array()); + $displayData = array('field' => $field, 'params' => $params, 'moduleId' => $moduleId, 'rangedata' => array(), 'articleoptions' => array()); if (preg_match("/^range?.*?$/isu", $layout)) { $displayData = self::addRangeData($displayData, $category_id, $option); } + if ($layout == 'articles') { + $displayData = self::addArticlesFieldData($displayData); + } + $new[$key] = JLayoutHelper::render( 'mod_jlcontentfieldsfilter.'.$layout, $displayData, @@ -279,6 +283,21 @@ private static function addRangeData($displayData, $category_id, $option) return $displayData; } + private static function addArticlesFieldData($displayData) { + $field = $displayData['field']; + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select('DISTINCT A.`value`, B.`title`') + ->from('`#__fields_values` A') + ->leftJoin('`#__content` B ON A.`value` = B.`id`') + ->where('A.`field_id` ='.(int)$field->id) + ->where('B.`state` = 1') + ->order('B.`title` ASC'); + ; + $displayData['articleoptions'] = $db->setQuery($query)->loadObjectList(); + return $displayData; + } + public static function getOrderingSelect($selectedOrdering, $moduleId, $option) { $app = JFactory::getApplication(); diff --git a/mod_jlcontentfieldsfilter/layouts/mod_jlcontentfieldsfilter/articles.php b/mod_jlcontentfieldsfilter/layouts/mod_jlcontentfieldsfilter/articles.php new file mode 100644 index 0000000..517bc42 --- /dev/null +++ b/mod_jlcontentfieldsfilter/layouts/mod_jlcontentfieldsfilter/articles.php @@ -0,0 +1,53 @@ +label); +if(!empty($field->hidden)){ + return; +} +$value = $field->value; + +$listOptions = $displayData['articleoptions']; +$options = array(); +if(is_array($listOptions)){ + foreach ( $listOptions as $listOption ) { + if (!empty($listOption->title)) { + $options[] = JHtml::_('select.option', $listOption->value, $listOption->title); + } + } +} +if(!count($options)){ + return; +} +?> + + diff --git a/plg_system_jlcontentfieldsfilter/fields/jlcontentfieldsfilterfields.php b/plg_system_jlcontentfieldsfilter/fields/jlcontentfieldsfilterfields.php index 37fa0ed..7c909ad 100644 --- a/plg_system_jlcontentfieldsfilter/fields/jlcontentfieldsfilterfields.php +++ b/plg_system_jlcontentfieldsfilter/fields/jlcontentfieldsfilterfields.php @@ -81,6 +81,10 @@ protected function getOptions() $options[] = HTMLHelper::_('select.option', 'text', Text::_('PLG_JLCONTENTFIELDSFILTER_FILTER_TEXT')); $options[] = HTMLHelper::_('select.option', 'range', Text::_('PLG_JLCONTENTFIELDSFILTER_FILTER_RANGE')); break; + case 'articles': + case 'articleslinked': + $options[] = HTMLHelper::_('select.option', 'articles', Text::_('PLG_JLCONTENTFIELDSFILTER_FILTER_ARTICLES')); + break; default: break; } diff --git a/plg_system_jlcontentfieldsfilter/jlcontentfieldsfilter.php b/plg_system_jlcontentfieldsfilter/jlcontentfieldsfilter.php index 64a8ec4..48b4e29 100644 --- a/plg_system_jlcontentfieldsfilter/jlcontentfieldsfilter.php +++ b/plg_system_jlcontentfieldsfilter/jlcontentfieldsfilter.php @@ -188,6 +188,8 @@ public function onAfterRoute() case 'radio': case 'checkboxes': case 'list': + case 'articles': + case 'articleslinked': if(is_array($v) && count($v)){ $newVal = array(); foreach ( $v as $val ) { diff --git a/plg_system_jlcontentfieldsfilter/language/en-GB/en-GB.plg_system_jlcontentfieldsfilter.ini b/plg_system_jlcontentfieldsfilter/language/en-GB/en-GB.plg_system_jlcontentfieldsfilter.ini index 06a6a9e..821d82a 100644 --- a/plg_system_jlcontentfieldsfilter/language/en-GB/en-GB.plg_system_jlcontentfieldsfilter.ini +++ b/plg_system_jlcontentfieldsfilter/language/en-GB/en-GB.plg_system_jlcontentfieldsfilter.ini @@ -10,6 +10,8 @@ PLG_JLCONTENTFIELDSFILTER_FILTER_TEXT="Text" PLG_JLCONTENTFIELDSFILTER_FILTER_LAYOUT="Individual layout" PLG_JLCONTENTFIELDSFILTER_FILTER_LAYOUT_DESC="Individual layout" PLG_JLCONTENTFIELDSFILTER_FILTER_RANGE="Range" +PLG_JLCONTENTFIELDSFILTER_FILTER_ARTICLES="Articles" +PLG_JLCONTENTFIELDSFILTER_FILTER_ARTICLESLINKED="Linked Articles" PLG_JLCONTENTFIELDSFILTER_FILTER_DISABLEDCATS="Excluded categories" PLG_JLCONTENTFIELDSFILTER_FILTER_DISABLEDCATS_DESC="Categories from among the specified categories and their subcategories to be excluded to show the field in the filter module" PLG_JLCONTENTFIELDSFILTER_FILTER_FIELD_HIDDEN_EMPTY="Hidden empty field" diff --git a/plg_system_jlcontentfieldsfilter/language/fr-FR/fr-FR.plg_system_jlcontentfieldsfilter.ini b/plg_system_jlcontentfieldsfilter/language/fr-FR/fr-FR.plg_system_jlcontentfieldsfilter.ini index 2c3bb4e..70f8f0f 100644 --- a/plg_system_jlcontentfieldsfilter/language/fr-FR/fr-FR.plg_system_jlcontentfieldsfilter.ini +++ b/plg_system_jlcontentfieldsfilter/language/fr-FR/fr-FR.plg_system_jlcontentfieldsfilter.ini @@ -10,6 +10,8 @@ PLG_JLCONTENTFIELDSFILTER_FILTER_TEXT="Texte" PLG_JLCONTENTFIELDSFILTER_FILTER_LAYOUT="Mise en page individuelle" PLG_JLCONTENTFIELDSFILTER_FILTER_LAYOUT_DESC="Mise en page individuelle" PLG_JLCONTENTFIELDSFILTER_FILTER_RANGE="Range" +PLG_JLCONTENTFIELDSFILTER_FILTER_ARTICLES="Articles" +PLG_JLCONTENTFIELDSFILTER_FILTER_ARTICLESLINKED="Articles liés" PLG_JLCONTENTFIELDSFILTER_FILTER_DISABLEDCATS="Catégories exclues" PLG_JLCONTENTFIELDSFILTER_FILTER_DISABLEDCATS_DESC="Catégories parmi les catégories spécifiées et leurs sous-catégories à exclure pour afficher le champ dans le module filtre" PLG_JLCONTENTFIELDSFILTER_FILTER_FIELD_HIDDEN_EMPTY="Masquer champ vide" diff --git a/plg_system_jlcontentfieldsfilter/language/ru-RU/ru-RU.plg_system_jlcontentfieldsfilter.ini b/plg_system_jlcontentfieldsfilter/language/ru-RU/ru-RU.plg_system_jlcontentfieldsfilter.ini index 221dc02..ac97061 100644 --- a/plg_system_jlcontentfieldsfilter/language/ru-RU/ru-RU.plg_system_jlcontentfieldsfilter.ini +++ b/plg_system_jlcontentfieldsfilter/language/ru-RU/ru-RU.plg_system_jlcontentfieldsfilter.ini @@ -10,6 +10,8 @@ PLG_JLCONTENTFIELDSFILTER_FILTER_TEXT="Текст" PLG_JLCONTENTFIELDSFILTER_FILTER_LAYOUT="Индивидуальный макет" PLG_JLCONTENTFIELDSFILTER_FILTER_LAYOUT_DESC="Индивидуальный макет" PLG_JLCONTENTFIELDSFILTER_FILTER_RANGE="Диапазон" +PLG_JLCONTENTFIELDSFILTER_FILTER_ARTICLES="Статьи" +PLG_JLCONTENTFIELDSFILTER_FILTER_ARTICLESLINKED="Связанные статьи" PLG_JLCONTENTFIELDSFILTER_FILTER_DISABLEDCATS="Исключаемые категории" PLG_JLCONTENTFIELDSFILTER_FILTER_DISABLEDCATS_DESC="Категории из числа указанных категорий и их подкатегорий, которые следует исключить для показа поля в модуле фильтра" PLG_JLCONTENTFIELDSFILTER_FILTER_FIELD_HIDDEN_EMPTY="Скрывать пустое поле"