Commit d6f24fbb authored by Jyhem's avatar Jyhem

[ENH] Select default sorting order in freetags search page

parent acfca1eb
......@@ -7,6 +7,28 @@
function prefs_freetags_list()
{
$freetags_sort_orders = array(
'name_asc' => tra('Name') . ' ' . tra('ascending'),
'name_desc' => tra('Name') . ' ' . tra('descending'),
'created_asc' => tra('Created') . ' ' . tra('ascending'),
'created_desc' => tra('Created') . ' ' . tra('descending'),
'description_asc' => tra('Description') . ' ' . tra('ascending'),
'description_desc' => tra('Description') . ' ' . tra('descending'),
'hits_asc' => tra('Hits') . ' ' . tra('ascending'),
'hits_desc' => tra('Hits') . ' ' . tra('descending'),
'href_asc' => tra('Href') . ' ' . tra('ascending'),
'href_desc' => tra('Href') . ' ' . tra('descending'),
'itemid_asc' => tra('Item ID') . ' ' . tra('ascending'),
'itemid_desc' => tra('Item ID') . ' ' . tra('descending'),
'objectid_asc' => tra('Object ID') . ' ' . tra('ascending'),
'objectid_desc' => tra('Object ID') . ' ' . tra('descending'),
'type_asc' => tra('Type') . ' ' . tra('ascending'),
'type_desc' => tra('Type') . ' ' . tra('descending'),
'comments_locked_asc' => tra('Comments Locked') . ' ' . tra('ascending'),
'comments_locked_desc' => tra('Comments Locked') . ' ' . tra('descending'),
);
return array (
'freetags_multilingual' => array(
'name' => tra('Multilingual tags'),
......@@ -19,6 +41,13 @@ function prefs_freetags_list()
),
'default' => 'n',
),
'freetags_sort_mode' => array(
'name' => tra('Tagged objects ordering'),
'description' => tra('Default sort mode for the tagged objects listing'),
'type' => 'list',
'options' => $freetags_sort_orders,
'default' => 'name_asc',
),
'freetags_browse_show_cloud' => array(
'name' => tra('Show tag cloud'),
'description' => tra(''),
......
......@@ -33,8 +33,6 @@
{preference name=freetags_3d_autoload}
{preference name=freetags_show_middle}
{preference name=freetags_preload_random_search}
<em>{tr}When arriving on <a href="tiki-browse_freetags.php">freetag search page</a>{/tr}.</em>
<div class="adminoptionbox">
<div class="adminoptionlabel">
......@@ -58,6 +56,13 @@
{preference name=morelikethis_algorithm}
{preference name=morelikethis_basic_mincommon}
</fieldset>
<fieldset class="admin">
<legend>{tr}Freetag search page{/tr}</legend>
{preference name=freetags_sort_mode}
{preference name=freetags_preload_random_search}
<em>{tr}When arriving on <a href="tiki-browse_freetags.php">freetag search page</a>{/tr}.</em>
</fieldset>
<fieldset>
<legend>{tr}Tag Management{/tr}</legend>
......
......@@ -130,7 +130,7 @@
{assign var=thistype value=$objectType|escape:'url'}
{capture name="fl"}{tr}{$feature_label}{/tr}{/capture}
{button _text=$smarty.capture.fl _class=$thisclass href="tiki-browse_freetags.php?tag=$tagString$thisbroaden&amp;type=$thistype"}
{button _text=$smarty.capture.fl _class=$thisclass href="tiki-browse_freetags.php?tag=$tagString$thisbroaden&amp;type=$thistype&amp;sort_mode=$sort_mode"}
{assign var=cpt value=$cpt+1}
{/if}
......@@ -156,7 +156,7 @@
{assign var=thistype value=$objectType|escape:'url'}
{capture name="fl"}{tr}{$feature_label}{/tr}{/capture}
{button _text=$smarty.capture.fl _class=$thisclass href="tiki-browse_freetags.php?tag=$tagString$thisbroaden&amp;type=$thistype"}
{button _text=$smarty.capture.fl _class=$thisclass href="tiki-browse_freetags.php?tag=$tagString$thisbroaden&amp;type=$thistype&amp;sort_mode=$sort_mode"}
{assign var=cpt value=$cpt+1}
{/if}
{/foreach}
......@@ -172,6 +172,7 @@
</div>
{/if}
<input type="hidden" name="sort_mode" value="{$sort_mode|escape}">
<input type="hidden" name="old_type" value="{$type|escape}">
<input type="text" name="find" value="{$find|escape}">
<input type="submit" class="btn btn-default btn-sm" value="{tr}Filter{/tr}">
......
......@@ -39,11 +39,11 @@ if (!isset($_REQUEST['tag']) && $prefs['freetags_preload_random_search'] == 'y')
}
}
if (!isset($_REQUEST["sort_mode"])) {
$sort_mode = 'name_asc';
$sort_mode = $prefs['freetags_sort_mode'];
} else {
$sort_mode = $_REQUEST["sort_mode"];
$sort_mode = str_replace('created', 'o.`created`', $sort_mode);
}
$query_sort_mode = str_replace('created', 'o.`created`', $sort_mode);
if (isset($_REQUEST["find"])) {
$find = $_REQUEST["find"];
} else {
......@@ -133,7 +133,7 @@ if ($broaden == 'last') {
$tagArray[count($tagArray) - 1]
);
}
$objects = $freetaglib->get_objects_with_tag_combo($tagArray, $type, $view_user, $offset, $maxRecords, $sort_mode, $find, $broaden, $objectId);
$objects = $freetaglib->get_objects_with_tag_combo($tagArray, $type, $view_user, $offset, $maxRecords, $query_sort_mode, $find, $broaden, $objectId);
$smarty->assign_by_ref('objects', $objects["data"]);
$smarty->assign_by_ref('cantobjects', $objects["cant"]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment