[pLog-svn] r3281 - plugins/trunk/blogtimes
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Thu Apr 27 07:39:29 GMT 2006
Author: pwestbro
Date: 2006-04-27 07:39:28 +0000 (Thu, 27 Apr 2006)
New Revision: 3281
Modified:
plugins/trunk/blogtimes/pluginblogtimes.class.php
Log:
Fixed bug where the time offset was not being taken into account when
rendering the graphic.
Also fixed problems with spacing
Modified: plugins/trunk/blogtimes/pluginblogtimes.class.php
===================================================================
--- plugins/trunk/blogtimes/pluginblogtimes.class.php 2006-04-27 02:56:24 UTC (rev 3280)
+++ plugins/trunk/blogtimes/pluginblogtimes.class.php 2006-04-27 07:39:28 UTC (rev 3281)
@@ -3,6 +3,7 @@
include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
+ include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
include_once( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
/**
@@ -46,9 +47,9 @@
}
function init()
- {
- // register the events we want
- $this->registerNotification( EVENT_POST_POST_ADD );
+ {
+ // register the events we want
+ $this->registerNotification( EVENT_POST_POST_ADD );
$this->registerAdminAction( "blogtimes", "PluginBlogTimesConfigAction" );
$this->registerAdminAction( "updateBlogTimesConfig", "PluginBlogTimesUpdateConfigAction" );
@@ -87,35 +88,35 @@
return $this->pluginEnabled;
}
- /**
- * process the events that we have registered
- *
- * @see PluginBase::process
- * @see PluginManager
- */
- function process( $eventType, $params )
- {
- // make sure we're processing the right event!
- if( $eventType != EVENT_POST_POST_ADD )
- {
- return true;
- }
-
- // Load all of the settings for this blog
- $this->register();
-
- // make sure that the plugin is enabled
- if( !$this->isEnabled())
- {
- return true;
- }
-
- // Update the Blogtime png
+ /**
+ * process the events that we have registered
+ *
+ * @see PluginBase::process
+ * @see PluginManager
+ */
+ function process( $eventType, $params )
+ {
+ // make sure we're processing the right event!
+ if( $eventType != EVENT_POST_POST_ADD )
+ {
+ return true;
+ }
+
+ // Load all of the settings for this blog
+ $this->register();
+
+ // make sure that the plugin is enabled
+ if( !$this->isEnabled())
+ {
+ return true;
+ }
+
+ // Update the Blogtime png
$this->updateBlogTimePNG();
-
- return true;
- }
-
+
+ return true;
+ }
+
function show() {
$saveFile = $this->cacheFolder."/blogtimes.png";
$rg =& RequestGenerator::getRequestGenerator( $this->blogInfo );
@@ -229,7 +230,7 @@
# save the file to disk in PNG format
ImageColorTransparent($im, $backColor);
ImagePNG ($im,$saveFile);
- File::chMod($saveFile, 0644);
+ File::chMod($saveFile, 0644);
}
# This function will query the db for all the posts in last x days
@@ -237,8 +238,16 @@
function getPostTimes($lastDays = 30)
{
$blogId = $this->blogInfo->getId();
+
+ //
+ // if there's a time difference applied to all dates, then we'd better
+ // calculate it here!!
+ //
+ $blogSettings = $this->blogInfo->getSettings();
+ $timeDiff = $blogSettings->getValue( 'time_offset' );
- $query = "SELECT HOUR(date)*60+MINUTE(date) AS totmins FROM ".$this->prefix."articles";
+
+ $query = "SELECT date FROM ".$this->prefix."articles";
$query .= " WHERE blog_id = ".$blogId." AND status = 1";
$query .= " AND (TO_DAYS(CURRENT_DATE) - TO_DAYS(date)) <= '$lastDays'";
$query .= " ORDER BY date ASC";
@@ -250,7 +259,12 @@
$postTimes = Array();
while( $row = $result->FetchRow()) {
- array_push( $postTimes, $row["totmins"]);
+ // we can use this auxiliary function to help us...
+ $date = new Timestamp( Timestamp::getDateWithOffset(
+ $row['date'],
+ $timeDiff ));
+
+ array_push( $postTimes, ($date->getHour()*60)+$date->getMinute());
}
return $postTimes;
More information about the pLog-svn
mailing list