From: garvinhicking Date: Tue, 11 Oct 2005 17:43:58 +0000 (+0000) Subject: Allow to show the category/entry count X-Git-Tag: 0.9~75 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9c5bebaec415ab901f8eb6396eb3778fcf5854c5;p=s9y.git Allow to show the category/entry count --- diff --git a/docs/NEWS b/docs/NEWS index afb7a05..5bdf7c9 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -8,7 +8,8 @@ Version 0.9-beta2 () Martin Eichenberg! (garvinhicking) * The output of the category plugin can now be styled via Smarty - templating (plugin_categories.tpl) + templating (plugin_categories.tpl). Also you can now enable showing + the number of entries per category. (garvinhicking) * Admin entry overview: Show pagination on bottom of the list and allow filtering for showing drafts/publishs (garvinhicking) diff --git a/include/plugin_internal.inc.php b/include/plugin_internal.inc.php index f7ca5f7..7abf7b8 100644 --- a/include/plugin_internal.inc.php +++ b/include/plugin_internal.inc.php @@ -1151,7 +1151,7 @@ class serendipity_categories_plugin extends serendipity_plugin { $propbag->add('stackable', true); $propbag->add('author', 'Serendipity Team'); $propbag->add('version', '2.0'); - $propbag->add('configuration', array('authorid', 'parent_base', 'image', 'sort_order', 'sort_method', 'allow_select', 'hide_parallel', 'smarty')); + $propbag->add('configuration', array('authorid', 'parent_base', 'image', 'sort_order', 'sort_method', 'allow_select', 'hide_parallel', 'show_count', 'smarty')); $propbag->add('groups', array('FRONTEND_VIEWS')); } @@ -1245,6 +1245,13 @@ class serendipity_categories_plugin extends serendipity_plugin { $propbag->add('default', false); break; + case 'show_count': + $propbag->add('type', 'boolean'); + $propbag->add('name', CATEGORY_PLUGIN_SHOWCOUNT); + $propbag->add('description', ''); + $propbag->add('default', false); + break; + default: return false; } @@ -1267,6 +1274,24 @@ class serendipity_categories_plugin extends serendipity_plugin { $categories = serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category, '', $sort); $title = $this->title; + $cat_count = array(); + if (serendipity_db_bool($this->get_config('show_count'))) { + $cat_sql = "SELECT c.categoryid, c.category_name, count(e.id) as postings + FROM {$serendipity['dbPrefix']}entrycat ec, + {$serendipity['dbPrefix']}category c, + {$serendipity['dbPrefix']}entries e + WHERE ec.categoryid = c.categoryid AND ec.entryid = e.id + GROUP BY ec.categoryid, c.category_name + ORDER BY postings DESC"; + $category_rows = serendipity_db_query($cat_sql); + if (is_array($category_rows)) { + foreach($category_rows AS $cat) { + $cat_count[$cat['categoryid']] = $cat['postings']; + } + } + + } + $html = ''; if (!$smarty && $is_form) { @@ -1320,6 +1345,11 @@ class serendipity_categories_plugin extends serendipity_plugin { $categories[$cid]['feedCategoryURL'] = serendipity_feedCategoryURL($cat, 'serendipityHTTPPath'); $categories[$cid]['categoryURL'] = serendipity_categoryURL($cat, 'serendipityHTTPPath'); $categories[$cid]['paddingPx'] = $cat['depth']*6; + + if (!empty($cat_count[$cid])) { + $categories[$cid]['true_category_name'] = $cat['category_name']; + $categories[$cid]['category_name'] .= ' (' . $cat_count[$cid] . ')'; + } if (!$smarty) { $html .= '
'; @@ -1331,7 +1361,7 @@ class serendipity_categories_plugin extends serendipity_plugin { if ( !empty($image) ) { $html .= 'XML '; } - $html .= ''. htmlspecialchars($cat['category_name']) .''; + $html .= ''. htmlspecialchars($categories[$cid]['category_name']) .''; $html .= '
' . "\n"; } } diff --git a/lang/UTF-8/serendipity_lang_bg.inc.php b/lang/UTF-8/serendipity_lang_bg.inc.php index a521658..198bb1c 100644 --- a/lang/UTF-8/serendipity_lang_bg.inc.php +++ b/lang/UTF-8/serendipity_lang_bg.inc.php @@ -1,4 +1,4 @@ - @@ -779,3 +779,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_cn.inc.php b/lang/UTF-8/serendipity_lang_cn.inc.php index f88e688..bc56586 100644 --- a/lang/UTF-8/serendipity_lang_cn.inc.php +++ b/lang/UTF-8/serendipity_lang_cn.inc.php @@ -1,4 +1,4 @@ - @@ -795,3 +795,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_cz.inc.php b/lang/UTF-8/serendipity_lang_cz.inc.php index f4d739c..2e5949f 100644 --- a/lang/UTF-8/serendipity_lang_cz.inc.php +++ b/lang/UTF-8/serendipity_lang_cz.inc.php @@ -1,4 +1,4 @@ - @@ -795,3 +795,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_da.inc.php b/lang/UTF-8/serendipity_lang_da.inc.php index e39111e..884e580 100644 --- a/lang/UTF-8/serendipity_lang_da.inc.php +++ b/lang/UTF-8/serendipity_lang_da.inc.php @@ -1,4 +1,4 @@ - @@ -794,3 +794,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_de.inc.php b/lang/UTF-8/serendipity_lang_de.inc.php index 18fb042..15bed7c 100644 --- a/lang/UTF-8/serendipity_lang_de.inc.php +++ b/lang/UTF-8/serendipity_lang_de.inc.php @@ -1,4 +1,4 @@ -, @@ -806,3 +806,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_fa.inc.php b/lang/UTF-8/serendipity_lang_fa.inc.php index 16e04c1..0b4c0a7 100644 --- a/lang/UTF-8/serendipity_lang_fa.inc.php +++ b/lang/UTF-8/serendipity_lang_fa.inc.php @@ -1,4 +1,4 @@ - @@ -794,3 +794,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_fi.inc.php b/lang/UTF-8/serendipity_lang_fi.inc.php index 802afee..c898b7f 100644 --- a/lang/UTF-8/serendipity_lang_fi.inc.php +++ b/lang/UTF-8/serendipity_lang_fi.inc.php @@ -1,4 +1,4 @@ - @@ -799,3 +799,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_hu.inc.php b/lang/UTF-8/serendipity_lang_hu.inc.php index 60599f8..08ca03f 100644 --- a/lang/UTF-8/serendipity_lang_hu.inc.php +++ b/lang/UTF-8/serendipity_lang_hu.inc.php @@ -793,3 +793,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_is.inc.php b/lang/UTF-8/serendipity_lang_is.inc.php index 402d36c..c7c8f86 100644 --- a/lang/UTF-8/serendipity_lang_is.inc.php +++ b/lang/UTF-8/serendipity_lang_is.inc.php @@ -1,4 +1,4 @@ - @@ -794,3 +794,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_ja.inc.php b/lang/UTF-8/serendipity_lang_ja.inc.php index e74df9f..6ee69df 100644 --- a/lang/UTF-8/serendipity_lang_ja.inc.php +++ b/lang/UTF-8/serendipity_lang_ja.inc.php @@ -1,4 +1,4 @@ -, 2004-2005. @@ -796,3 +796,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_ko.inc.php b/lang/UTF-8/serendipity_lang_ko.inc.php index e69363d..0458ba4 100644 --- a/lang/UTF-8/serendipity_lang_ko.inc.php +++ b/lang/UTF-8/serendipity_lang_ko.inc.php @@ -1,4 +1,4 @@ - @@ -795,3 +795,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_nl.inc.php b/lang/UTF-8/serendipity_lang_nl.inc.php index 105a10b..465aff4 100644 --- a/lang/UTF-8/serendipity_lang_nl.inc.php +++ b/lang/UTF-8/serendipity_lang_nl.inc.php @@ -1,4 +1,4 @@ - @@ -795,3 +795,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_no.inc.php b/lang/UTF-8/serendipity_lang_no.inc.php index bb4790c..aa08e58 100644 --- a/lang/UTF-8/serendipity_lang_no.inc.php +++ b/lang/UTF-8/serendipity_lang_no.inc.php @@ -1,4 +1,4 @@ - @@ -795,3 +795,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_pt.inc.php b/lang/UTF-8/serendipity_lang_pt.inc.php index 47e238f..a5342c9 100644 --- a/lang/UTF-8/serendipity_lang_pt.inc.php +++ b/lang/UTF-8/serendipity_lang_pt.inc.php @@ -1,4 +1,4 @@ - @@ -797,3 +797,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_pt_PT.inc.php b/lang/UTF-8/serendipity_lang_pt_PT.inc.php index ff58fec..4dc29a7 100644 --- a/lang/UTF-8/serendipity_lang_pt_PT.inc.php +++ b/lang/UTF-8/serendipity_lang_pt_PT.inc.php @@ -796,3 +796,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_ro.inc.php b/lang/UTF-8/serendipity_lang_ro.inc.php index 8fd65e2..843c408 100644 --- a/lang/UTF-8/serendipity_lang_ro.inc.php +++ b/lang/UTF-8/serendipity_lang_ro.inc.php @@ -792,3 +792,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_ru.inc.php b/lang/UTF-8/serendipity_lang_ru.inc.php index 7b46470..6fbe049 100644 --- a/lang/UTF-8/serendipity_lang_ru.inc.php +++ b/lang/UTF-8/serendipity_lang_ru.inc.php @@ -1,4 +1,4 @@ - @@ -795,3 +795,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_tw.inc.php b/lang/UTF-8/serendipity_lang_tw.inc.php index 712f0cc..ec4df91 100644 --- a/lang/UTF-8/serendipity_lang_tw.inc.php +++ b/lang/UTF-8/serendipity_lang_tw.inc.php @@ -1,4 +1,4 @@ - @@ -794,3 +794,4 @@ @define('AUTHOR_PLUGIN_DESC', 'Shows a list of authors'); @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?'); @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.'); +@define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?'); diff --git a/lang/UTF-8/serendipity_lang_zh.inc.php b/lang/UTF-8/serendipity_lang_zh.inc.php index 6869236..8abf4b0 100644 --- a/lang/UTF-8/serendipity_lang_zh.inc.php +++ b/lang/UTF-8/serendipity_lang_zh.inc.php @@ -1,4 +1,4 @@ -