Archived
1
0

The archive sidebar plugin shiped with s9y now displays numbers of articles correctly for month, catergories and so on, even if multicategory articles are used. (brockhaus)

This commit is contained in:
Grischa Brockhaus
2007-07-13 12:05:22 +00:00
parent 5930736d70
commit c668918c81
3 changed files with 32 additions and 9 deletions
+4
View File
@@ -3,6 +3,10 @@
Version 1.3 () Version 1.3 ()
------------------------------------------------------------------------ ------------------------------------------------------------------------
* The archive sidebar plugin shiped with s9y now displays numbers
of articles correctly for month, catergories and so on, even
if multicategory articles are used. (brockhaus)
* Trackbacks to links without a description now get properly * Trackbacks to links without a description now get properly
evaluated. (brockhaus) evaluated. (brockhaus)
+9 -4
View File
@@ -206,7 +206,7 @@ function &serendipity_fetchEntryCategories($entryid) {
* @param string If set to "array", the array of entries will be returned. "flat-array" will only return the articles without their entryproperties. "single" will only return a 1-dimensional array. "query" will only return the used SQL. * @param string If set to "array", the array of entries will be returned. "flat-array" will only return the articles without their entryproperties. "single" will only return a 1-dimensional array. "query" will only return the used SQL.
* @return array Holds the super-array of all entries with all additional information * @return array Holds the super-array of all entries with all additional information
*/ */
function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp DESC', $filter_sql = '', $noCache = false, $noSticky = false, $select_key = null, $group_by = null, $returncode = 'array') { function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp DESC', $filter_sql = '', $noCache = false, $noSticky = false, $select_key = null, $group_by = null, $returncode = 'array',$joinauthors = true, $joincategories =true) {
global $serendipity; global $serendipity;
$cond = array(); $cond = array();
@@ -376,13 +376,18 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe
// Store the unique query condition for entries for later reference, like getting the total article count. // Store the unique query condition for entries for later reference, like getting the total article count.
$serendipity['fullCountQuery'] = " $serendipity['fullCountQuery'] = "
FROM FROM
{$serendipity['dbPrefix']}entries AS e {$serendipity['dbPrefix']}entries AS e";
if ($joinauthors)
$serendipity['fullCountQuery'] .="
LEFT JOIN {$serendipity['dbPrefix']}authors a LEFT JOIN {$serendipity['dbPrefix']}authors a
ON e.authorid = a.authorid ON e.authorid = a.authorid";
if ($joincategories)
$serendipity['fullCountQuery'] .="
LEFT JOIN {$serendipity['dbPrefix']}entrycat ec LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
ON e.id = ec.entryid ON e.id = ec.entryid
LEFT JOIN {$serendipity['dbPrefix']}category c LEFT JOIN {$serendipity['dbPrefix']}category c
ON ec.categoryid = c.categoryid ON ec.categoryid = c.categoryid";
$serendipity['fullCountQuery'] .="
{$cond['joins']} {$cond['joins']}
{$cond['and']}"; {$cond['and']}";
+18 -4
View File
@@ -400,7 +400,7 @@ class serendipity_archives_plugin extends serendipity_plugin {
$propbag->add('stackable', true); $propbag->add('stackable', true);
$propbag->add('author', 'Serendipity Team'); $propbag->add('author', 'Serendipity Team');
$propbag->add('version', '1.0'); $propbag->add('version', '1.0');
$propbag->add('configuration', array('title', 'frequency', 'count', 'show_count')); $propbag->add('configuration', array('title', 'frequency', 'count', 'show_count','hide_zero_count'));
$propbag->add('groups', array('FRONTEND_VIEWS')); $propbag->add('groups', array('FRONTEND_VIEWS'));
} }
@@ -436,6 +436,13 @@ class serendipity_archives_plugin extends serendipity_plugin {
$propbag->add('default', false); $propbag->add('default', false);
break; break;
case 'hide_zero_count':
$propbag->add('type', 'boolean');
$propbag->add('name', CATEGORY_PLUGIN_HIDEZEROCOUNT);
$propbag->add('description', '');
$propbag->add('default', false);
break;
default: default:
return false; return false;
} }
@@ -451,13 +458,16 @@ class serendipity_archives_plugin extends serendipity_plugin {
$ts = mktime(0, 0, 0, date('m'), 1); $ts = mktime(0, 0, 0, date('m'), 1);
$add_query = ''; $add_query = '';
if (isset($serendipity['GET']['category'])) {
$category_set = isset($serendipity['GET']['category']);
if ($category_set) {
$base_query = 'C' . (int)$serendipity['GET']['category']; $base_query = 'C' . (int)$serendipity['GET']['category'];
$add_query = '/' . $base_query; $add_query = '/' . $base_query;
} }
$max_x = $this->get_config('count', 3); $max_x = $this->get_config('count', 3);
$show_count = serendipity_db_bool($this->get_config('show_count', false)); $show_count = serendipity_db_bool($this->get_config('show_count', false));
$hide_zero_count = serendipity_db_bool($this->get_config('hide_zero_count', false));
$freq = $this->get_config('frequency', 'months'); $freq = $this->get_config('frequency', 'months');
for($x = 0; $x < $max_x; $x++) { for($x = 0; $x < $max_x; $x++) {
@@ -515,6 +525,7 @@ class serendipity_archives_plugin extends serendipity_plugin {
$link = serendipity_rewriteURL(PATH_ARCHIVES . '/' . $linkStamp . $add_query . '.html', 'serendipityHTTPPath'); $link = serendipity_rewriteURL(PATH_ARCHIVES . '/' . $linkStamp . $add_query . '.html', 'serendipityHTTPPath');
$html_count = ''; $html_count = '';
$hidden_by_zero_count = false;
if ($show_count) { if ($show_count) {
switch($freq) { switch($freq) {
case 'months': case 'months':
@@ -540,18 +551,21 @@ class serendipity_archives_plugin extends serendipity_plugin {
true, true,
'count(e.id) AS orderkey', 'count(e.id) AS orderkey',
'', '',
'single' 'single',
false, $category_set // the joins used
); );
if (is_array($ec)) { if (is_array($ec)) {
if (empty($ec['orderkey'])) { if (empty($ec['orderkey'])) {
$ec['orderkey'] = '0'; $ec['orderkey'] = '0';
} }
$hidden_by_zero_count = $hide_zero_count && ( $ec['orderkey'] == '0');
$html_count .= ' (' . $ec['orderkey'] . ')'; $html_count .= ' (' . $ec['orderkey'] . ')';
} }
} }
echo '<a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . $html_count . '</a><br />' . "\n"; if (!$hidden_by_zero_count)
echo '<a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . $html_count . '</a><br />' . "\n";
} }