Skip to content

Commit

Permalink
Fixed 'require ALL' parameter of tags scope of universal content modu…
Browse files Browse the repository at this point in the history
…le. Added 'require ALL' parameter to the categories scope of universal content module
  • Loading branch information
ggppdk committed Mar 17, 2016
1 parent 0837ccc commit 8e18142
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
2 changes: 1 addition & 1 deletion admin/language/en-GB/en-GB.com_flexicontent.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3346,7 +3346,7 @@ FLEXI_ITEM_RELATION_FIELDS="Item relations fields"

; Experimental params
FLEXI_EXPERIMENTAL="Experimental"
FLEXI_EXPERIMENTAL_DESC="Experimental features are only for testing, and getting reportis by end users or testers if they work. <br/><br/>NOTE: we do support these directly, and if they cause problems then they WILL BE DISABLED in future versions"
FLEXI_EXPERIMENTAL_DESC="Experimental features are only for testing, and getting reports by end users or testers if they work. <br/><br/>NOTE: we do support these directly, and if they cause problems then they WILL BE DISABLED in future versions"

; Allow Joomla article view
FLEXI_REDIRECT_ARTICLE_VIEW="Joomla article view"
Expand Down
26 changes: 23 additions & 3 deletions modules/mod_flexicontent/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ public static function getItems(&$params, $ordering)
$catids = $params->get('catids', array());
$behaviour_cat = $params->get('behaviour_cat', 0);
$treeinclude = $params->get('treeinclude');
$cat_combine = $params->get('cat_combine', 0);

// types scope parameters
$method_types = (int)$params->get('method_types', 1);
Expand Down Expand Up @@ -984,15 +985,31 @@ public static function getItems(&$params, $ordering)
return;
}
$where .= ' AND c.id NOT IN (' . implode(',', $catids_arr) . ')';
} else if ($method_cat == 3) { // include method
}

else if ($method_cat == 3) { // include method

if (!$apply_config_per_category) {
$where .= ' AND c.id IN (' . implode(',', $catids_arr) . ')';
} else {
if ($cat_combine)
{
$where .= ' AND i.id IN ('
.' SELECT DISTINCT itemid'
.' FROM #__flexicontent_cats_item_relations'
.' WHERE catid IN ('.implode(',', $catids_arr).')'
.' GROUP by itemid HAVING COUNT(*) >= '.count($catids_arr) .')'
;
}
else
$where .= ' AND c.id IN (' . implode(',', $catids_arr) . ')';
}

else {
// *** Applying configuration per category ***
foreach($catids_arr as $catid) // The items retrieval query will be executed ... once per EVERY category
$multiquery_cats[$catid] = ' AND c.id = '.$catid;
$params->set('dynamic_catids', serialize($catids_arr)); // Set dynamic catids to be used by the getCategoryData
}

}
}

Expand Down Expand Up @@ -1258,6 +1275,9 @@ public static function getItems(&$params, $ordering)
// Make sure tag_ids is an array
$tag_ids = !is_array($tag_ids) ? array($tag_ids) : $tag_ids ;

// Require ALL is meant only for "include" method
if ($method_tags == 2) $tag_combine = 0;

// Create query to match item ids using the selected tags
$query2 = 'SELECT '.($tag_combine ? 'itemid' : 'DISTINCT itemid')
. ' FROM #__flexicontent_tags_item_relations'
Expand Down
11 changes: 9 additions & 2 deletions modules/mod_flexicontent/languages/en-GB.mod_flexicontent.ini
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ FLEXI_SELECT_RELATION_FIELDS="Relation Field(s)"
FLEXI_SELECT_RELATION_FIELDS_DESC="Select the relation field(s) (used by behavior: Reverse Related Items / Related items via relation field)"

FLEXI_TAGS_REQUIRE_ALL="Require ALL tags"
FLEXI_TAGS_REQUIRE_ALL_DESC="Select whether to require ALL selected tags to be assigned to listed items"
FLEXI_TAGS_REQUIRE_ALL_DESC="Select whether listed items must be haved ALL selected tags"

FLEXI_CATS_REQUIRE_ALL="Require ALL categories"
FLEXI_CATS_REQUIRE_ALL_DESC="Select whether listed items must be assigned to ALL selected categories"

FLEXI_TAGS_SCOPE="Tags scope"
FLEXI_SELECT_TAGS="Select tags"
Expand Down Expand Up @@ -386,7 +389,7 @@ FLEXI_UMOD_STATIC_USE_SPECIFIC_DATES="Static: Specific FROM/TO dates or date exp
FLEXI_BEHAVIOUR_STATIC_DYNAMIC="Behaviour (**)"
FLEXI_BEHAVIOUR_STATIC_DYNAMIC_DESC="<br><u>Static behaviour</u>: <b>ignores currently viewed item</b> and uses above parameters to <b>displays data in all views</b>. <br><br><u>Dynamic behaviour</u>: compares items to <b>currently viewed item</b> and thus it <b>displays data in item views only</b>, it may or may not use above data, e.g. date SCOPE uses them</small>"
FLEXI_BEHAVIOUR_STATIC_DYNAMIC_DATE="Behaviour (***) <br><small>Please read</small>"
FLEXI_BEHAVIOUR_STATIC_DYNAMIC_DATE_DESC="<br><u>Static behaviour</u>: compares dates of items to the FROM/TO date parameters and <b>displays data in all views</b>. <br><br><u>Dynamic behaviour</u>: compares dates of items to <b>dates of currently viewed item</b> or to <b>current server time</b> (e.g. to current item created date -2 weeks, e.g. to previous week of current server time)<br>- if comparing to current item dates, it <b>displays data in item views only</b><br>- if comparing to current server time it <b>displays data in all views</b><br><br>NOTE: Both (a) static scope and (b) Custom Offset (dynamic scope), USE the above data</small>"
FLEXI_BEHAVIOUR_STATIC_DYNAMIC_DATE_DESC="<br><u>Static behaviour</u>: compares dates of items to the FROM/TO date parameters and <b>displays data in all views</b>. <br><br><u>Dynamic behaviour</u>: compares dates of items to <b>dates of currently viewed item</b> or to <b>current server time</b> (e.g. to current item created date -2 weeks, e.g. to previous week of current server time)<br>- if comparing to current item dates, it <b>displays data in item views only</b><br>- if comparing to current server time it <b>displays data in all views</b>"

FLEXI_STATIC_DATE_BEHAVIOUR="Static behaviour: Specific dates ... or custom offset for dynamic behaviours"
FLEXI_DYNAMIC_DATE_BEHAVIOUR="Dynamic behaviours: Compare to server time or to currently viewed item"
Expand Down Expand Up @@ -584,3 +587,7 @@ FLEXI_UMOD_IGNORE_SCHEDULED_EXPIRED_DATES_DESC="You can select to ignore publish

FLEXI_UMOD_USE_LIST_ITEMS_IN_ANY_STATE_ACL="Use 'List items in any state' ACL"
FLEXI_UMOD_USE_LIST_ITEMS_IN_ANY_STATE_ACL_DESC="Enable this to allow privileged users (ACL privelege: 'list items in any state') and super admins to see ANY state items and items that are scheduled and/or expired. NOTE that you would want to give this module a specific / special view access level"

; Experimental params
FLEXI_UMOD_EXPERIMENTAL="Experimental"
FLEXI_UMOD_EXPERIMENTAL_DESC="Experimental features are only for testing, and getting reports by end users or testers if they work. <br/><br/>NOTE: we do support these directly, and if they cause problems then they WILL BE DISABLED in future versions"
24 changes: 14 additions & 10 deletions modules/mod_flexicontent/mod_flexicontent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@

<field name="" type="separator" default="FLEXI_TAGS_SCOPE" level="level2" />
<field name="method_tags" type="multilist" subtype="radio" default="1" label="FLEXI_METHOD_STATIC" description="FLEXI_METHOD_DESC" toggle_related="1" class="btn-group group-fcmethod">
<option value="1" show_list="" hide_list="method_tags_ops">FLEXI_ALL</option>
<option value="2" show_list="method_tags_ops" hide_list="">FLEXI_EXCLUDE</option>
<option value="3" show_list="method_tags_ops" hide_list="">FLEXI_INCLUDE</option>
<option value="1" show_list="" hide_list="method_tags_ops,method_tags_inc">FLEXI_ALL</option>
<option value="2" show_list="method_tags_ops" hide_list="method_tags_inc">FLEXI_EXCLUDE</option>
<option value="3" show_list="method_tags_ops,method_tags_inc" hide_list="">FLEXI_INCLUDE</option>
</field>
<field name="tag_ids" type="tags" default="" multiple="true" size="6" label="FLEXI_SELECT_TAGS" description="FLEXI_SELECT_TAGS_DESC" class="method_tags_ops" />
<field name="combine_tags" type="radio" default="1" label="FLEXI_TAGS_REQUIRE_ALL" description="FLEXI_TAGS_REQUIRE_ALL_DESC" class="method_tags_ops btn-group btn-group-yesno">
<field name="tag_combine" type="radio" default="0" label="FLEXI_TAGS_REQUIRE_ALL" description="FLEXI_TAGS_REQUIRE_ALL_DESC" class="method_tags_ops method_tags_inc btn-group group-fcmethod">
<option value="0">FLEXI_NO</option>
<option value="1">FLEXI_YES_SLOW</option>
<option value="1">FLEXI_YES</option>
</field>


Expand All @@ -227,9 +227,9 @@
<field name="" type="separator" default="FLEXI_CAT_SCOPE" level="level2" />
<field name="" type="separator" default="FLEXI_UMOD_STATIC_SET_TO_ALL_TO_DISABLE" level="level3" />
<field name="method_cat" type="multilist" subtype="radio" default="1" label="FLEXI_METHOD_STATIC" description="FLEXI_METHOD_STATIC_DESC" toggle_related="1" class="btn-group group-fcmethod">
<option value="1" show_list="" hide_list="method_cat_ops">FLEXI_ALL</option>
<option value="2" show_list="method_cat_ops" hide_list="">FLEXI_EXCLUDE</option>
<option value="3" show_list="method_cat_ops" hide_list="">FLEXI_INCLUDE</option>
<option value="1" show_list="" hide_list="method_cat_ops,method_cat_inc">FLEXI_ALL</option>
<option value="2" show_list="method_cat_ops" hide_list="method_cat_inc">FLEXI_EXCLUDE</option>
<option value="3" show_list="method_cat_ops,method_cat_inc" hide_list="">FLEXI_INCLUDE</option>
</field>
<field name="catids" type="flexicategories" multiple="true" label="FLEXI_CATEGORIES" description="FLEXI_CATEGORIES_DESC" class="method_cat_ops" />
<field name="" type="separator" default="FLEXI_UMOD_DYNAMIC_SET_TO_STATIC_TO_DISABLE" level="level3" class="method_cat_ops" />
Expand All @@ -251,6 +251,10 @@
<option value="3">FLEXI_CHILDREN_PARENTS</option>
<option value="4">FLEXI_OTHER_CATS_OF_ITEM</option>
</field>
<field name="cat_combine" type="radio" default="0" label="FLEXI_CATS_REQUIRE_ALL" description="FLEXI_CATS_REQUIRE_ALL_DESC" class="method_cat_ops method_cat_inc no_confpercat btn-group group-fcmethod" >
<option value="0">FLEXI_NO</option>
<option value="1">FLEXI_YES</option>
</field>

<field name="" type="separator" default="FLEXI_TYPES_SCOPE" level="level2" />
<field name="" type="separator" default="FLEXI_UMOD_STATIC_SET_TO_ALL_TO_DISABLE" level="level3" />
Expand Down Expand Up @@ -739,8 +743,8 @@
<field name="" type="separator" default="FLEXI_CATS" level="level1" />

<field name="apply_config_per_category" type="multilist" subtype="radio" toggle_related="1" default="0" label="FLEXI_MOD_APPLY_CON_PER_CAT" description="FLEXI_MOD_APPLY_CON_PER_CAT_DESC" class="btn-group group-fcmethod fcoffactive">
<option value="0" show_list="" hide_list="confpercat">FLEXI_NO</option>
<option value="1" show_list="confpercat" hide_list="">FLEXI_YES</option>
<option value="0" show_list="no_confpercat" hide_list="confpercat">FLEXI_NO</option>
<option value="1" show_list="confpercat" hide_list="no_confpercat">FLEXI_YES</option>
</field>
<field name="skip_category_if_noitems" type="radio" default="0" label="FLEXI_MOD_SKIP_CATEGORY_IF_NOITEMS" description="FLEXI_MOD_SKIP_CATEGORY_IF_NOITEMS_DESC" class="confpercat btn-group btn-group-yesno">
<option value="0">FLEXI_NO</option>
Expand Down

0 comments on commit 8e18142

Please sign in to comment.