[pLog-svn] r1142 - in plog/trunk: class/dao class/view/admin
templates/admin
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sat Feb 19 16:06:06 GMT 2005
Author: oscar
Date: 2005-02-19 16:06:06 +0000 (Sat, 19 Feb 2005)
New Revision: 1142
Modified:
plog/trunk/class/dao/trackback.class.php
plog/trunk/class/dao/trackbacks.class.php
plog/trunk/class/view/admin/admindashboardview.class.php
plog/trunk/templates/admin/dashboard.template
Log:
added support for showing the most recent trackbacks in the 'dashboard' view, which is something that we're going to need.
Also one stupid bug in Trackbacks::_fillTrackbackInformation() was fixed as well as the addition of Trackbacks::getBlogTrackbacks() which is used to get the 'x' most recent trackbacks received in a blog.
Modified: plog/trunk/class/dao/trackback.class.php
===================================================================
--- plog/trunk/class/dao/trackback.class.php 2005-02-19 15:18:32 UTC (rev 1141)
+++ plog/trunk/class/dao/trackback.class.php 2005-02-19 16:06:06 UTC (rev 1142)
@@ -21,6 +21,7 @@
var $_date;
var $_dateObject;
var $_id;
+ var $_article;
/**
* Constructor. Creates a new trackback object.
@@ -44,10 +45,11 @@
$this->_date = $date;
$this->_dateObject = new Timestamp( $this->_date );
$this->_id = $id;
+
+ // this will be initialized later
+ $this->_article = null;
}
- /***** getters ******/
-
/**
* Returns the permalink of the post that sent the trackback link.
*
@@ -141,5 +143,24 @@
{
return $this->_dateObject;
}
+
+ /**
+ * returns the Article object to which this one trackback points
+ *
+ * @return An Article object
+ */
+ function getArticle()
+ {
+ // if we haven't loaded the article yet
+ if( $this->_article == null ) {
+ include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+
+ // load the article and return it
+ $articles = new Articles();
+ $this->_article = $articles->getBlogArticle( $this->_articleId );
+ }
+
+ return( $this->_article );
+ }
}
?>
Modified: plog/trunk/class/dao/trackbacks.class.php
===================================================================
--- plog/trunk/class/dao/trackbacks.class.php 2005-02-19 15:18:32 UTC (rev 1141)
+++ plog/trunk/class/dao/trackbacks.class.php 2005-02-19 16:06:06 UTC (rev 1142)
@@ -124,6 +124,42 @@
return $trackbacks;
}
+
+ /**
+ * returns the 'x' most recent trackbacks from a blog
+ *
+ * @param blogId the blog id
+ * @param amount the maximum numer of trackbacks to return. By default, it will return all trackbacks.
+ * @return an array of Trackback objects
+ */
+ function getBlogTrackbacks( $blogId, $amount = -1 )
+ {
+ $prefix = $this->getPrefix();
+
+ $query = "SELECT t.id AS id, t.url AS url, t.title AS title, t.article_id AS article_id,
+ t.excerpt AS excerpt, t.blog_name AS blog_name, t.date AS date
+ FROM {$prefix}trackbacks t, {$prefix}articles a
+ WHERE a.blog_id = '".Db::qstr( $blogId )."' AND a.id = t.article_id
+ ORDER BY t.date DESC";
+ if( $amount > 0 )
+ $query .= " LIMIT 0, $amount";
+
+ $trackbacks = Array();
+
+ $result = $this->Execute( $query );
+
+ // if there was an error, return an empty array
+ if( !$result )
+ return( $trackbacks );
+
+ // otherwise proceed and loop through the rows
+ while( $row = $result->FetchRow()) {
+ $trackback = $this->_fillTrackbackInformation( $row );
+ array_push( $trackbacks, $trackback );
+ }
+
+ return( $trackbacks );
+ }
/**
* returns a list of trackbacks given an array with article ids
@@ -224,13 +260,15 @@
// calculate what would the "real" date...
$date = Timestamp::getDateWithOffset( $date, $timeDiff );
- return new TrackBack( $row["url"],
+ $trackback = new TrackBack( $row["url"],
$row["title"],
$row["article_id"],
$row["excerpt"],
$row["blog_name"],
$date,
$row["id"] );
+
+ return( $trackback );
}
/**
Modified: plog/trunk/class/view/admin/admindashboardview.class.php
===================================================================
--- plog/trunk/class/view/admin/admindashboardview.class.php 2005-02-19 15:18:32 UTC (rev 1141)
+++ plog/trunk/class/view/admin/admindashboardview.class.php 2005-02-19 16:06:06 UTC (rev 1142)
@@ -9,6 +9,7 @@
include_once( PLOG_CLASS_PATH."class/template/menu/menurenderer.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
/**
@@ -54,6 +55,7 @@
// for each blog, load some statistics
$articles = new Articles();
$comments = new ArticleComments();
+ $trackbacks = new Trackbacks();
$resources = new GalleryResources();
$recentPosts = Array();
$recentComments = Array();
@@ -67,12 +69,14 @@
0,
POST_STATUS_PUBLISHED );
$recentComments[$userBlog->getId()] = $comments->getBlogComments ( $userBlog->getId(), DASHBOARD_MAX_RECENT_ITEMS );
+ $recentTrackbacks[$userBlog->getId()] = $trackbacks->getBlogTrackbacks( $userBlog->getId(), DASHBOARD_MAX_RECENT_ITEMS );
$recentResources[$userBlog->getId()] = $resources->getUserResources( $userBlog->getId(), GALLERY_NO_ALBUM, GALLERY_TYPE_RESOURCE_ANY, 1, DASHBOARD_MAX_RECENT_ITEMS );
}
$this->_params->setValue( "userblogs", $this->_userBlogs );
$this->_params->setValue( "recentposts", $recentPosts );
$this->_params->setValue( "recentcomments", $recentComments );
+ $this->_params->setValue( "recenttrackbacks", $recentTrackbacks );
$this->_params->setValue( "recentresources", $recentResources );
}
Modified: plog/trunk/templates/admin/dashboard.template
===================================================================
--- plog/trunk/templates/admin/dashboard.template 2005-02-19 15:18:32 UTC (rev 1141)
+++ plog/trunk/templates/admin/dashboard.template 2005-02-19 16:06:06 UTC (rev 1142)
@@ -37,6 +37,26 @@
{/foreach}
<br/>
+ {** loop to print out the list of recent trackbacks **}
+ <b>{$locale->tr("recent_trackbacks")}</b><br/>
+ {foreach from=$recenttrackbacks[$blogId] item=trackback}
+ {assign var=article value=$trackback->getArticle()}
+ <a target="_blank" href="{$url->postTrackbackStatsLink($article)}#{$trackback->getId()}">
+ {if $trackback->getTitle() == ""}
+ <i>{$locale->tr("no_subject")}</i>
+ {else}
+ {$trackback->getExcerpt()}
+ {/if}
+ </a>
+ {if $trackback->getBlogName() != ""}
+ , {$locale->tr("in")} <a href="{$trackback->getUrl()}">{$trackback->getBlogName()}</a>
+ {/if}
+ {$locale->tr("in")} <a href="{$url->postPermalink($article)}">{$article->getTopic()}</a>
+ {assign var=trackbackDate value=$trackback->getDateObject()}
+ {$locale->formatDate($trackbackDate)}<br/>
+ {/foreach}
+ <br/>
+
{** loop to print out the list of recent resources **}
<b>{$locale->tr("recent_resources")}</b><br/>
{foreach from=$recentresources[$blogId] item=resource}
More information about the pLog-svn
mailing list