Skip to content

Commit

Permalink
Add new descending sort option for 'order by tag count' sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
ophian committed Mar 13, 2016
1 parent 2227e9c commit fb865bd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
3.11 (sidebar):
---------------

* Add new descending sort option for 'order by tag count' sorting.


3.77:
-----

Expand Down
2 changes: 2 additions & 0 deletions UTF-8/lang_de.inc.php
Expand Up @@ -127,3 +127,5 @@

@define('PLUGIN_EVENT_FREETAG_LOWERCASE_TAGS_DESC', 'Datenbank und Backend-Tags werden wie eingegeben gespeichert und angezeigt. Diese Option ist nur für Frontend-Tags.');

@define('PLUGIN_EVENT_FREETAG_SORT_DESC_FOR_TOTAL', 'Mit "order by count", absteigender Sortierung');

2 changes: 2 additions & 0 deletions lang_de.inc.php
Expand Up @@ -129,3 +129,5 @@

@define('PLUGIN_EVENT_FREETAG_LOWERCASE_TAGS_DESC', 'Datenbank und Backend-Tags werden wie eingegeben gespeichert und angezeigt. Diese Option ist nur für Frontend-Tags.');

@define('PLUGIN_EVENT_FREETAG_SORT_DESC_FOR_TOTAL', 'Mit "order by count", absteigender Sortierung');

2 changes: 2 additions & 0 deletions lang_en.inc.php
Expand Up @@ -157,3 +157,5 @@

@define('PLUGIN_EVENT_FREETAG_ADMIN_DELIMITER', 'Allow alphabetical index Backend-Tags List delimiter?');

@define('PLUGIN_EVENT_FREETAG_SORT_DESC_FOR_TOTAL', 'With "order by count", sort descending');

4 changes: 2 additions & 2 deletions serendipity_event_freetag.php
Expand Up @@ -2884,7 +2884,7 @@ function backend_fetch_tags_for_saving($eventData)
$tags = array(); // avoid having "[] operator not supported for strings" errors
}
$tags[] = $tag;
printf("\n<br /> - ".PLUGIN_EVENT_FREETAG_KEYWORDS_ADD, self::specialchars_mapper($keyword), self::specialchars_mapper($tag));
printf("\n - ".PLUGIN_EVENT_FREETAG_KEYWORDS_ADD."\n<br>", self::specialchars_mapper($keyword), self::specialchars_mapper($tag));
if (!empty($tags)) {
$key2tagIDs[] = $eventData['id']; // gather ids to updertEntries
}
Expand Down Expand Up @@ -3108,7 +3108,7 @@ function trim(str)

} else {
?>
<fieldset id="edit_entry_freetags" class="entryproperties_freetag">
<fieldset id="edit_entry_freetags" class="entryproperties_freetag" style="margin: 1em 0;">
<span class="wrap_legend"><legend><?php echo PLUGIN_EVENT_FREETAG_TITLE; ?></legend></span>
<div class="form_field">
<label for="properties_freetag_tagList" class="block_level"><?php echo PLUGIN_EVENT_FREETAG_ENTERDESC; ?>:</label>
Expand Down
13 changes: 10 additions & 3 deletions serendipity_plugin_freetag.php
Expand Up @@ -25,7 +25,7 @@ function introspect(&$propbag)
'smarty' => '2.6.7',
'php' => '5.3.0'
));
$propbag->add('version', '3.10');
$propbag->add('version', '3.11');
$propbag->add('groups', array('FRONTEND_ENTRY_RELATED'));
$propbag->add('configuration', array(
'config_pagegrouper',
Expand All @@ -36,7 +36,7 @@ function introspect(&$propbag)
'lowercase_tags',
'scale_tag', 'min_percent', 'max_percent', 'show_newline',
'treshold_tag_count', 'max_tags',
'order_by',
'order_by', 'sort_desc',
'template',

'separator2', 'config_cloudgrouper',
Expand Down Expand Up @@ -147,6 +147,13 @@ function introspect_config_item($name, &$propbag)
$propbag->add('default', 'tag');
break;

case 'sort_desc':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_FREETAG_SORT_DESC_FOR_TOTAL);
$propbag->add('description', '');
$propbag->add('default', 'false');
break;

case 'xml_image':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_FREETAG_XMLIMAGE);
Expand Down Expand Up @@ -304,7 +311,7 @@ function generate_content(&$title)
uksort($tags, 'strnatcasecmp');
serendipity_plugin_api::hook_event('sort', $tags);
} else if ($this->get_config('order_by') == 'total'){
asort($tags);
serendipity_db_bool($this->get_config('sort_desc', 'false')) ? arsort($tags) : asort($tags);
}

$xml = serendipity_db_bool($this->get_config('show_xml', 'true'));
Expand Down

0 comments on commit fb865bd

Please sign in to comment.