* @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
*/
-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;
$cond = array();
// Store the unique query condition for entries for later reference, like getting the total article count.
$serendipity['fullCountQuery'] = "
FROM
- {$serendipity['dbPrefix']}entries AS e
+ {$serendipity['dbPrefix']}entries AS e";
+ if ($joinauthors)
+ $serendipity['fullCountQuery'] .="
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
ON e.id = ec.entryid
LEFT JOIN {$serendipity['dbPrefix']}category c
- ON ec.categoryid = c.categoryid
+ ON ec.categoryid = c.categoryid";
+ $serendipity['fullCountQuery'] .="
{$cond['joins']}
{$cond['and']}";
$propbag->add('stackable', true);
$propbag->add('author', 'Serendipity Team');
$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('default', false);
break;
+ case 'hide_zero_count':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', CATEGORY_PLUGIN_HIDEZEROCOUNT);
+ $propbag->add('description', '');
+ $propbag->add('default', false);
+ break;
+
default:
return false;
}
$ts = mktime(0, 0, 0, date('m'), 1);
$add_query = '';
- if (isset($serendipity['GET']['category'])) {
+
+ $category_set = isset($serendipity['GET']['category']);
+ if ($category_set) {
$base_query = 'C' . (int)$serendipity['GET']['category'];
$add_query = '/' . $base_query;
}
$max_x = $this->get_config('count', 3);
$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');
-
+
for($x = 0; $x < $max_x; $x++) {
$current_ts = $ts;
switch($freq) {
$link = serendipity_rewriteURL(PATH_ARCHIVES . '/' . $linkStamp . $add_query . '.html', 'serendipityHTTPPath');
$html_count = '';
+ $hidden_by_zero_count = false;
if ($show_count) {
switch($freq) {
case 'months':
true,
'count(e.id) AS orderkey',
'',
- 'single'
+ 'single',
+ false, $category_set // the joins used
);
if (is_array($ec)) {
if (empty($ec['orderkey'])) {
$ec['orderkey'] = '0';
}
+ $hidden_by_zero_count = $hide_zero_count && ( $ec['orderkey'] == '0');
$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";
}