[geeklog-hg] geeklog: Made the Article list in the What's New Block the same ...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Thu Jun 27 12:44:39 EDT 2013
changeset 9137:bf88f40c7a0b
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/bf88f40c7a0b
user: Tom <websitemaster at cogeco.net>
date: Thu Jun 27 12:30:21 2013 -0400
description:
Made the Article list in the What's New Block the same as plugins. What's New block can now be cached and new config option whatsnew_cache_time. (feature request #0001634)
diffstat:
language/english.php | 1 +
language/english_utf-8.php | 1 +
public_html/admin/configuration_validation.php | 1 +
public_html/admin/install/config-install.php | 1 +
public_html/docs/english/config.html | 4 +
public_html/docs/japanese/config.html | 4 +
public_html/index.php | 26 +----
public_html/lib-common.php | 127 ++++++++++++++----------
sql/updates/mssql_2.0.0_to_2.0.1.php | 3 +
sql/updates/mysql_2.0.0_to_2.0.1.php | 3 +
sql/updates/pgsql_2.0.0_to_2.0.1.php | 3 +
system/lib-plugins.php | 36 ++++--
system/lib-template.php | 71 +++++++++++++-
system/lib-topic.php | 2 +-
14 files changed, 191 insertions(+), 92 deletions(-)
diffs (truncated from 505 to 300 lines):
diff -r ba0818b28094 -r bf88f40c7a0b language/english.php
--- a/language/english.php Tue Jun 25 20:36:11 2013 -0400
+++ b/language/english.php Thu Jun 27 12:30:21 2013 -0400
@@ -1940,6 +1940,7 @@
'hidenewtrackbacks' => "Hide New Trackbacks",
'hidenewplugins' => "Hide New Plugin Entries",
'title_trim_length' => "Title Trim Length",
+ 'whatsnew_cache_time' => "Max Cache Time",
'trackback_enabled' => "Trackback Enabled?",
'pingback_enabled' => "Pingback Enabled?",
'ping_enabled' => "Ping Enabled?",
diff -r ba0818b28094 -r bf88f40c7a0b language/english_utf-8.php
--- a/language/english_utf-8.php Tue Jun 25 20:36:11 2013 -0400
+++ b/language/english_utf-8.php Thu Jun 27 12:30:21 2013 -0400
@@ -1940,6 +1940,7 @@
'hidenewtrackbacks' => "Hide New Trackbacks",
'hidenewplugins' => "Hide New Plugin Entries",
'title_trim_length' => "Title Trim Length",
+ 'whatsnew_cache_time' => "Max Cache Time",
'trackback_enabled' => "Trackback Enabled?",
'pingback_enabled' => "Pingback Enabled?",
'ping_enabled' => "Ping Enabled?",
diff -r ba0818b28094 -r bf88f40c7a0b public_html/admin/configuration_validation.php
--- a/public_html/admin/configuration_validation.php Tue Jun 25 20:36:11 2013 -0400
+++ b/public_html/admin/configuration_validation.php Thu Jun 27 12:30:21 2013 -0400
@@ -278,6 +278,7 @@
$_CONF_VALIDATE['Core']['hidenewtrackbacks'] = array('rule' => 'boolean');
$_CONF_VALIDATE['Core']['hidenewplugins'] = array('rule' => 'boolean');
$_CONF_VALIDATE['Core']['title_trim_length'] = array('rule' => 'numeric');
+$_CONF_VALIDATE['Core']['whatsnew_cache_time'] = array('rule' => 'numeric');
/* Subgroup Users and Submissions, Tab Users */
$_CONF_VALIDATE['Core']['disable_new_user_registration'] = array('rule' => 'boolean');
diff -r ba0818b28094 -r bf88f40c7a0b public_html/admin/install/config-install.php
--- a/public_html/admin/install/config-install.php Tue Jun 25 20:36:11 2013 -0400
+++ b/public_html/admin/install/config-install.php Thu Jun 27 12:30:21 2013 -0400
@@ -213,6 +213,7 @@
$c->add('hidenewtrackbacks',0,'select',3,15,0,1030,TRUE, $me, 15);
$c->add('hidenewplugins',0,'select',3,15,0,1040,TRUE, $me, 15);
$c->add('title_trim_length',20,'text',3,15,NULL,1050,TRUE, $me, 15);
+ $c->add('whatsnew_cache_time',3600,'text',3,15,NULL,1060,TRUE, $me, 15);
// Subgroup: Users and Submissions
$c->add('sg_users', NULL, 'subgroup', 4, 0, NULL, 0, TRUE, $me, 0);
diff -r ba0818b28094 -r bf88f40c7a0b public_html/docs/english/config.html
--- a/public_html/docs/english/config.html Tue Jun 25 20:36:11 2013 -0400
+++ b/public_html/docs/english/config.html Thu Jun 27 12:30:21 2013 -0400
@@ -747,6 +747,10 @@
<td valign="top">20</td>
<td valign="top">Max. length of the title of items listed in the What's New
block.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_whatsnew_cache_time">whatsnew_cache_time</a></td>
+ <td valign="top">3600</td>
+ <td valign="top">If Caching is enabled the What's New Block will be Cached for no longer than this many seconds.</td></tr>
</table>
diff -r ba0818b28094 -r bf88f40c7a0b public_html/docs/japanese/config.html
--- a/public_html/docs/japanese/config.html Tue Jun 25 20:36:11 2013 -0400
+++ b/public_html/docs/japanese/config.html Thu Jun 27 12:30:21 2013 -0400
@@ -666,6 +666,10 @@
<td valign="top"><a name="desc_title_trim_length">ã¿ã¤ãã«æ大é·(title_trim_length)</a></td>
<td valign="top">20</td>
<td valign="top">æ°çãããã¯ã«è¡¨ç¤ºããã¿ã¤ãã«ã®ããªãã³ã°ã®æåæ°ãæå®ãã¾ãã</td></tr>
+<tr>
+ <td valign="top"><a name="desc_whatsnew_cache_time">whatsnew_cache_time</a></td>
+ <td valign="top">3600</td>
+ <td valign="top">If Caching is enabled the What's New Block will be Cached for no longer than this many seconds.</td></tr>
</table>
diff -r ba0818b28094 -r bf88f40c7a0b public_html/index.php
--- a/public_html/index.php Tue Jun 25 20:36:11 2013 -0400
+++ b/public_html/index.php Thu Jun 27 12:30:21 2013 -0400
@@ -99,12 +99,9 @@
}
-$newstories = false;
$displayall = false;
if (isset ($_GET['display'])) {
- if (($_GET['display'] == 'new') && (empty ($topic))) {
- $newstories = true;
- } else if (($_GET['display'] == 'all') && (empty ($topic))) {
+ if (($_GET['display'] == 'all') && (empty ($topic))) {
$displayall = true;
}
}
@@ -122,7 +119,7 @@
$display = '';
-if (!$newstories && !$displayall) {
+if (!$displayall) {
// give plugins a chance to replace this page entirely
$newcontent = PLG_showCenterblock (0, $page, $topic);
if (!empty ($newcontent)) {
@@ -260,7 +257,7 @@
$tid_list = "'" . $topic . "'";
}
$sql .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$topic}')))";
-} elseif (!$newstories) {
+} else {
$sql .= " AND frontpage = 1 AND ta.tdefault = 1";
}
@@ -280,20 +277,6 @@
$sql .= COM_getTopicSQL ('AND', 0, 'ta') . ' ';
-if ($newstories) {
- switch ($_DB_dbms) {
- case 'mysql':
- $sql .= "AND (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) ";
- break;
- case 'pgsql':
- $sql .= "AND (date >= (NOW() - INTERVAL '{$_CONF['newstoriesinterval']} SECOND')) ";
- break;
- case 'mssql':
- $sql .= "AND (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) ";
- break;
- }
-}
-
$offset = ($page - 1) * $limit;
$userfields = 'u.uid, u.username, u.fullname';
if ($_CONF['allow_user_photo'] == 1) {
@@ -383,9 +366,6 @@
($_CONF['hide_main_page_navigation'] == 0)) {
if (empty ($topic)) {
$base_url = $_CONF['site_url'] . '/index.php';
- if ($newstories) {
- $base_url .= '?display=new';
- }
} else {
$base_url = $_CONF['site_url'] . '/index.php?topic=' . $topic;
}
diff -r ba0818b28094 -r bf88f40c7a0b public_html/lib-common.php
--- a/public_html/lib-common.php Tue Jun 25 20:36:11 2013 -0400
+++ b/public_html/lib-common.php Thu Jun 27 12:30:21 2013 -0400
@@ -506,12 +506,7 @@
$last_topic_update = DB_getItem($_TABLES['vars'], 'value', "name='last_topic_update'");
// Figure out how old stored topic tree is
if ($_CONF['cache_templates']) {
- if (COM_isAnonUser()) {
- $uid = 1;
- } else {
- $uid = $_USER['uid'];
- }
- $cacheInstance = 'topic_tree__' . CACHE_security_hash() . '__' . $uid;
+ $cacheInstance = 'topic_tree__' . CACHE_security_hash();
$topic_tree_date = date("Y-m-d H:i:s", CACHE_get_instance_update($cacheInstance, true));
} else {
if (COM_isAnonUser()) {
@@ -5177,8 +5172,26 @@
function COM_whatsNewBlock( $help = '', $title = '', $position = '' )
{
- global $_CONF, $_TABLES, $LANG01, $LANG_WHATSNEW, $page, $newstories;
-
+ global $_CONF, $_TABLES, $LANG01, $LANG_WHATSNEW, $page, $_USER;
+
+ if ($_CONF['cache_templates']) {
+ if (COM_isAnonUser()) {
+ $uid = 1;
+ } else {
+ $uid = $_USER['uid'];
+ }
+
+ $cacheInstance = 'whatsnew__' . CACHE_security_hash() . '__' . $_CONF['theme'];
+ $retval = CACHE_check_instance($cacheInstance, 0);
+ if ( $retval ) {
+ $lu = CACHE_get_instance_update($cacheInstance, 0);
+ $now = time();
+ if (( $now - $lu ) < $_CONF['whatsnew_cache_time'] ) {
+ return $retval;
+ }
+ }
+ }
+
$retval = COM_startBlock( $title, $help,
COM_getBlockTemplate( 'whats_new_block', 'header', $position ));
@@ -5201,53 +5214,58 @@
}
// Find the newest stories
- $sql['mssql'] = "SELECT COUNT(DISTINCT sid) AS count FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
- WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL( 'AND' ) . $topicsql . COM_getLangSQL( 'sid', 'AND' );
+ $sql['mssql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
+ WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL( 'AND' ) . $topicsql . COM_getLangSQL( 'sid', 'AND' ) . "
+ GROUP BY sid, title ORDER BY date DESC";
- $sql['mysql'] = "SELECT COUNT(DISTINCT sid) AS count FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
- WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL( 'AND' ) . $topicsql . COM_getLangSQL( 'sid', 'AND' );
+ $sql['mysql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
+ WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL( 'AND' ) . $topicsql . COM_getLangSQL( 'sid', 'AND' ) . "
+ GROUP BY sid, title ORDER BY date DESC";
- $sql['pgsql'] = "SELECT COUNT(DISTINCT sid) AS count FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
- WHERE (date >= (NOW() - INTERVAL '{$_CONF['newstoriesinterval']} SECOND')) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL( 'AND' ) . $topicsql . COM_getLangSQL( 'sid', 'AND' );
+ $sql['pgsql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
+ WHERE (date >= (NOW() - INTERVAL '{$_CONF['newstoriesinterval']} SECOND')) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL( 'AND' ) . $topicsql . COM_getLangSQL( 'sid', 'AND' ) . "
+ GROUP BY sid, title ORDER BY date DESC";
+
+ $result = DB_query( $sql );
+ $nrows = DB_numRows( $result );
+
+ if( empty( $title ))
+ {
+ $title = DB_getItem( $_TABLES['blocks'], 'title', "name='whats_new_block'" );
+ }
+
+ // Any late breaking news stories?
+ $retval .= '<h3>' . $LANG01[99] . ' <small>'
+ . COM_formatTimeString( $LANG_WHATSNEW['new_last'],
+ $_CONF['newstoriesinterval'] )
+ . '</small></h3>';
- $result = DB_query( $sql );
- $A = DB_fetchArray( $result );
- $nrows = $A['count'];
-
- if( empty( $title ))
- {
- $title = DB_getItem( $_TABLES['blocks'], 'title', "name='whats_new_block'" );
- }
-
- // Any late breaking news stories?
- $retval .= '<h3>' . $LANG01[99] . '</h3>';
-
- if( $nrows > 0 )
- {
- $newmsg = COM_formatTimeString( $LANG_WHATSNEW['new_string'],
- $_CONF['newstoriesinterval'], $LANG01[11], $nrows);
-
- if( $newstories && ( $page < 2 ))
- {
- $retval .= $newmsg . '<br' . XHTML . '>';
- }
- else
- {
- $retval .= COM_createLink($newmsg, $_CONF['site_url']
- . '/index.php?display=new') . '<br' . XHTML . '>';
- }
- }
- else
- {
- $retval .= $LANG01[100] . '<br' . XHTML . '>';
- }
-
- if(( $_CONF['hidenewcomments'] == 0 ) || ( $_CONF['trackback_enabled']
- && ( $_CONF['hidenewtrackbacks'] == 0 ))
- || ( $_CONF['hidenewplugins'] == 0 ))
- {
- $retval .= '<br' . XHTML . '>';
- }
+ if ($nrows > 0) {
+ $newarticles = array();
+
+ for ($x = 0; $x < $nrows; $x++) {
+ $A = DB_fetchArray($result);
+
+ $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
+
+ $title = COM_undoSpecialChars(stripslashes( $A['title']));
+ $titletouse = COM_truncate($title, $_CONF['title_trim_length'],
+ '...');
+ if ($title != $titletouse) {
+ $attr = array('title' => htmlspecialchars($title));
+ } else {
+ $attr = array();
+ }
+ $aarticle = str_replace('$', '$', $titletouse);
+ $aarticle = str_replace(' ', ' ', $aarticle);
+
+ $newarticles[] = COM_createLink($aarticle, $url, $attr);
+ }
+
+ $retval .= COM_makeList($newarticles, 'list-new-plugins');
+ } else {
+ $retval .= $LANG01[100] . '<br' . XHTML . '>' . LB; // No new stories
+ }
}
if( $_CONF['hidenewcomments'] == 0 )
@@ -5420,6 +5438,7 @@
}
$retval .= COM_endBlock( COM_getBlockTemplate( 'whats_new_block', 'footer', $position ));
+ if ($_CONF['cache_templates']) { CACHE_create_instance($cacheInstance, $retval, 0); }
return $retval;
}
@@ -7174,7 +7193,7 @@
*/
function COM_onFrontpage()
{
- global $_CONF, $topic, $page, $newstories;
More information about the geeklog-cvs
mailing list