Version 0.9 ()
------------------------------------------------------------------------
+ * Categories plugin now offers to sort by category name, description
+ or creation date. (garvinhicking)
+
* Deactivated gzip compression by default, as in certain server
setups it creates problem with double-encoding or missing
ob_gzhandlers. (garvinhicking)
/**
* Fetches a users categories
**/
-function serendipity_fetchCategories($authorid = null, $name = '') {
+function serendipity_fetchCategories($authorid = null, $name = '', $order = 'category_name ASC') {
global $serendipity;
if (!isset($authorid) || $authorid === null) {
a.realname
FROM {$serendipity['dbPrefix']}category AS c
LEFT OUTER JOIN {$serendipity['dbPrefix']}authors AS a
- ON c.authorid = a.authorid $where
- ORDER BY category_name";
+ ON c.authorid = a.authorid $where";
+
+ if (!empty($order)) {
+ $querystring .= "\n ORDER BY $order";
+ }
+
return serendipity_db_query($querystring);
}
$propbag->add('stackable', true);
$propbag->add('author', 'Serendipity Team');
$propbag->add('version', '1.0');
- $propbag->add('configuration', array('authorid', 'image'));
+ $propbag->add('configuration', array('authorid', 'image', 'sort_order', 'sort_method'));
}
function introspect_config_item($name, &$propbag)
$propbag->add('default', 'all');
break;
+ case 'sort_order':
+ $select = array();
+ $select['category_name'] = CATEGORY;
+ $select['category_description'] = DESCRIPTION;
+ $select['none'] = NONE;
+ $propbag->add('type', 'select');
+ $propbag->add('name', SORT_ORDER);
+ $propbag->add('description', '');
+ $propbag->add('select_values', $select);
+ $propbag->add('default', 'category_name');
+ break;
+
+ case 'sort_method':
+ $select = array();
+ $select['ASC'] = SORT_ORDER_ASC;
+ $select['DESC'] = SORT_ORDER_DESC;
+ $propbag->add('type', 'select');
+ $propbag->add('name', SORT_ORDER);
+ $propbag->add('description', '');
+ $propbag->add('select_values', $select);
+ $propbag->add('default', 'ASC');
+ break;
+
case 'image':
$propbag->add('type', 'string');
$propbag->add('name', XML_IMAGE_TO_DISPLAY);
global $serendipity;
$which_category = $this->get_config('authorid');
- $categories = serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category);
+ $sort = $this->get_config('sort_order');
+ if ($sort == 'none') {
+ $sort = '';
+ } else {
+ $sort .= ' ' . $this->get_config('sort_method');
+ }
+ $categories = serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category, '', $sort);
$title = $this->title;
$html = '';
$image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif'));