[geeklog-hg] geeklog: Older Stories Block uses the cache now and is multi-lan...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Aug 19 21:35:40 EDT 2013
changeset 9261:2aef7e84ecc5
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/2aef7e84ecc5
user: Tom <websitemaster at cogeco.net>
date: Mon Aug 19 21:35:14 2013 -0400
description:
Older Stories Block uses the cache now and is multi-language aware. Removed COM_olderstuff function and created COM_olderStoriesBlock. Divides date story entries by a div that uses the class divider-older-stories instead of a break tag. (bug #0001667)
diffstat:
public_html/admin/block.php | 8 +-
public_html/admin/install/migrate.php | 9 +-
public_html/admin/moderation.php | 1 -
public_html/admin/topic.php | 6 +-
public_html/lib-common.php | 175 ++++++++++++++++++---------------
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/classes/story.class.php | 1 -
system/lib-story.php | 20 ++-
system/lib-template.php | 6 +
11 files changed, 129 insertions(+), 106 deletions(-)
diffs (truncated from 449 to 300 lines):
diff -r a0f396565b08 -r 2aef7e84ecc5 public_html/admin/block.php
--- a/public_html/admin/block.php Mon Aug 19 19:40:50 2013 -0400
+++ b/public_html/admin/block.php Mon Aug 19 21:35:14 2013 -0400
@@ -614,9 +614,7 @@
$rdfurl = COM_sanitizeUrl ($rdfurl, array ('http', 'https'));
}
if ($type == 'gldefault') {
- if ($name != 'older_stories') {
- $content = '';
- }
+ $content = '';
$rdfurl = '';
$rdfupdated = '';
$rdflimit = 0;
@@ -676,10 +674,6 @@
$bid = DB_insertId();
}
- if (($type == 'gldefault') && ($name == 'older_stories')) {
- COM_olderStuff ();
- }
-
TOPIC_saveTopicSelectionControl('block', $bid);
$cacheInstance = 'block__' . $bid . '__'; // remove any of this blocks instances if exists
diff -r a0f396565b08 -r 2aef7e84ecc5 public_html/admin/install/migrate.php
--- a/public_html/admin/install/migrate.php Mon Aug 19 19:40:50 2013 -0400
+++ b/public_html/admin/install/migrate.php Mon Aug 19 21:35:14 2013 -0400
@@ -1004,13 +1004,10 @@
&& ($_OLD_CONF['site_url'] != $_CONF['site_url'])) {
INST_updateSiteUrl($_OLD_CONF['site_url'], $_CONF['site_url']);
-
- } else {
-
- // refresh "Older Stories" block
- COM_olderStuff();
-
}
+
+ // Clear the Geeklog Cache incase paths etc. in cache files
+ INST_clearCache();
/**
* Import complete.
diff -r a0f396565b08 -r 2aef7e84ecc5 public_html/admin/moderation.php
--- a/public_html/admin/moderation.php Mon Aug 19 19:40:50 2013 -0400
+++ b/public_html/admin/moderation.php Mon Aug 19 21:35:14 2013 -0400
@@ -413,7 +413,6 @@
PLG_itemSaved($A['sid'], 'article');
COM_rdfUpToDateCheck ();
- COM_olderStuff ();
} elseif ($type == 'comment') {
$sid = CMT_approveModeration($mid[$i]);
if (! in_array($sid, $sidArray)) {
diff -r a0f396565b08 -r 2aef7e84ecc5 public_html/admin/topic.php
--- a/public_html/admin/topic.php Mon Aug 19 19:40:50 2013 -0400
+++ b/public_html/admin/topic.php Mon Aug 19 21:35:14 2013 -0400
@@ -525,9 +525,8 @@
PLG_itemSaved($tid, 'topic');
}
- // update feed(s) and Older Stories block
+ // update feed(s)
COM_rdfUpToDateCheck('article', $tid);
- COM_olderStuff();
$retval = COM_refresh ($_CONF['site_admin_url'] . '/topic.php?msg=13');
} elseif ($restricted_tid) {
@@ -793,9 +792,8 @@
// Update Topics Array to reflect any changes since not sure what is called after
$_TOPICS = TOPIC_buildTree(TOPIC_ROOT, true);
- // update feed(s) and Older Stories block
+ // update feed(s)
COM_rdfUpToDateCheck('article');
- COM_olderStuff();
return COM_refresh ($_CONF['site_admin_url'] . '/topic.php?msg=14');
}
diff -r a0f396565b08 -r 2aef7e84ecc5 public_html/lib-common.php
--- a/public_html/lib-common.php Mon Aug 19 19:40:50 2013 -0400
+++ b/public_html/lib-common.php Mon Aug 19 21:35:14 2013 -0400
@@ -4173,87 +4173,97 @@
return($retval === true ? true : false);
}
-
-/**
-* Creates older stuff block
-*
-* Creates the olderstuff block for display.
-* Actually updates the olderstuff record in the gl_blocks database.
-* @return void
-*/
-
-function COM_olderStuff()
+/**
+* Shows older story information in a block
+*
+* Return the HTML that shows any older stories
+*
+* @param string $help Help file for block
+* @param string $title Title used in block header
+* @param string $position Position in which block is being rendered 'left', 'right' or blank (for centre)
+* @return string Return the HTML that shows any new stories, comments, etc
+*
+*/
+function COM_olderStoriesBlock( $help = '', $title = '', $position = '' )
{
global $_TABLES, $_CONF;
- $sql['mysql'] = "SELECT sid,ta.tid,title,comments,UNIX_TIMESTAMP(date) AS day
- FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
- WHERE ta.type = 'article' AND ta.id = sid
- AND (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1, 'ta') . "
- GROUP BY sid
- ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
+ $cacheInstance = 'olderstories__' . CACHE_security_hash() . '__' . $_CONF['theme'];
+ $retval = CACHE_check_instance($cacheInstance, 0);
+ if (empty($retval)) {
+ $retval = COM_startBlock( $title, $help,
+ COM_getBlockTemplate( 'older_stories_block', 'header', $position ));
+
+ $sql['mysql'] = "SELECT sid,ta.tid,title,comments,UNIX_TIMESTAMP(date) AS day
+ FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
+ WHERE ta.type = 'article' AND ta.id = sid " . COM_getLangSQL('sid', 'AND') . "
+ AND (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1, 'ta') . "
+ GROUP BY sid
+ ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
+
+ $sql['mssql'] = $sql['mysql'];
+
+ $sql['pgsql'] = "SELECT sid,ta.tid,title,comments,date_part('epoch',date) AS day
+ FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
+ WHERE ta.type = 'article' AND ta.id = sid " . COM_getLangSQL('sid', 'AND') . "
+ AND (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1, 'ta') . "
+ GROUP BY sid, ta.tid, title, comments, day
+ ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
- $sql['mssql'] = $sql['mysql'];
+ $result = DB_query($sql);
+ $nrows = DB_numRows($result);
- $sql['pgsql'] = "SELECT sid,ta.tid,title,comments,date_part('epoch',date) AS day
- FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
- WHERE ta.type = 'article' AND ta.id = sid AND
- (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1, 'ta') . "
- GROUP BY sid, ta.tid, title, comments, day
- ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
-
- $result = DB_query( $sql );
- $nrows = DB_numRows( $result );
-
- if( $nrows > 0 )
- {
- $dateonly = $_CONF['dateonly'];
- if( empty( $dateonly ))
- {
- $dateonly = '%d-%b'; // fallback: day - abbrev. month name
- }
-
- $day = 'noday';
- $string = '';
-
- for( $i = 0; $i < $nrows; $i++ )
- {
- $A = DB_fetchArray( $result );
-
- $daycheck = strftime( '%A', $A['day'] );
- if( $day != $daycheck )
+ if ($nrows > 0) {
+ $dateonly = $_CONF['dateonly'];
+ if (empty($dateonly)) {
+ $dateonly = '%d-%b'; // fallback: day - abbrev. month name
+ }
+
+ $day = 'noday';
+ $string = '';
+
+ for ($i = 0; $i < $nrows; $i++) {
+ $A = DB_fetchArray( $result );
+
+ $daycheck = strftime( '%A', $A['day'] );
+ if( $day != $daycheck )
+ {
+ if( $day != 'noday' )
+ {
+ $daylist = COM_makeList( $oldnews, 'list-older-stories' );
+ $daylist = preg_replace( "/(\015\012)|(\015)|(\012)/",
+ '', $daylist );
+ $string .= $daylist . '<div class="divider-older-stories"></div>';
+ }
+
+ $day2 = strftime( $dateonly, $A['day'] );
+ $string .= '<h3>' . $daycheck . ' <small>' . $day2
+ . '</small></h3>' . LB;
+ $oldnews = array();
+ $day = $daycheck;
+ }
+
+ $oldnews_url = COM_buildUrl( $_CONF['site_url'] . '/article.php?story='
+ . $A['sid'] );
+ $oldnews[] = COM_createLink($A['title'], $oldnews_url)
+ .' (' . COM_numberFormat( $A['comments'] ) . ')';
+ }
+
+ if( !empty( $oldnews ))
{
- if( $day != 'noday' )
- {
- $daylist = COM_makeList( $oldnews, 'list-older-stories' );
- $daylist = preg_replace( "/(\015\012)|(\015)|(\012)/",
- '', $daylist );
- $string .= $daylist . '<br' . XHTML . '>';
- }
-
- $day2 = strftime( $dateonly, $A['day'] );
- $string .= '<h3>' . $daycheck . ' <small>' . $day2
- . '</small></h3>' . LB;
- $oldnews = array();
- $day = $daycheck;
- }
-
- $oldnews_url = COM_buildUrl( $_CONF['site_url'] . '/article.php?story='
- . $A['sid'] );
- $oldnews[] = COM_createLink($A['title'], $oldnews_url)
- .' (' . COM_numberFormat( $A['comments'] ) . ')';
- }
-
- if( !empty( $oldnews ))
- {
- $daylist = COM_makeList( $oldnews, 'list-older-stories' );
- $daylist = preg_replace( "/(\015\012)|(\015)|(\012)/", '', $daylist );
- $string .= $daylist;
- $string = DB_escapeString( $string );
-
- DB_query( "UPDATE {$_TABLES['blocks']} SET content = '$string' WHERE name = 'older_stories'" );
- }
- }
+ $daylist = COM_makeList( $oldnews, 'list-older-stories' );
+ $daylist = preg_replace( "/(\015\012)|(\015)|(\012)/", '', $daylist );
+ $string .= $daylist;
+
+ $retval .= $string;
+ }
+ }
+
+ $retval .= COM_endBlock( COM_getBlockTemplate( 'older_stories_block', 'footer', $position ));
+ CACHE_create_instance($cacheInstance, $retval, 0);
+ }
+
+ return $retval;
}
/**
@@ -4313,6 +4323,13 @@
$retval .= COM_whatsNewBlock( $help, $title, $position );
}
break;
+
+ case 'older_stories':
+ if( !$_USER['noboxes'] )
+ {
+ $retval .= COM_olderStoriesBlock( $help, $title, $position );
+ }
+ break;
}
return $retval;
@@ -5201,7 +5218,7 @@
|| ( $_CONF['trackback_enabled']
&& ( $_CONF['hidenewtrackbacks'] == 0 )))
{
- $retval .= '<div class="whatsnew-divider"></div>';
+ $retval .= '<div class="divider-whats-new"></div>';
}
}
@@ -5273,7 +5290,7 @@
|| ( $_CONF['trackback_enabled']
&& ( $_CONF['hidenewtrackbacks'] == 0 )))
{
- $retval .= '<div class="whatsnew-divider"></div>';
+ $retval .= '<div class="divider-whats-new"></div>';
}
}
@@ -5343,7 +5360,7 @@
}
if( $_CONF['hidenewplugins'] == 0 )
{
- $retval .= '<div class="whatsnew-divider"></div>';
+ $retval .= '<div class="divider-whats-new"></div>';
}
}
@@ -5368,7 +5385,7 @@
More information about the geeklog-cvs
mailing list