[pLog-svn] r4483 - in plog/trunk: class/summary/action
class/summary/dao templates/summary
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Thu Jan 4 13:04:39 GMT 2007
Author: oscar
Date: 2007-01-04 13:04:38 +0000 (Thu, 04 Jan 2007)
New Revision: 4483
Modified:
plog/trunk/class/summary/action/userprofileaction.class.php
plog/trunk/class/summary/dao/summarystats.class.php
plog/trunk/templates/summary/userprofile.template
Log:
now when browsing a user profile via the summary page, the 10 most recent posts of this user will be pulled and displayed.
Modified: plog/trunk/class/summary/action/userprofileaction.class.php
===================================================================
--- plog/trunk/class/summary/action/userprofileaction.class.php 2007-01-04 12:38:20 UTC (rev 4482)
+++ plog/trunk/class/summary/action/userprofileaction.class.php 2007-01-04 13:04:38 UTC (rev 4483)
@@ -37,6 +37,7 @@
// load the classes that we are going to need
lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
// load some information about the user
$users = new Users();
@@ -47,6 +48,10 @@
$this->setCommonData();
return false;
}
+
+ // load the user's recent posting activity
+ $stats = new SummaryStats();
+ $this->_view->setValue( "recentArticles", $stats->getUserRecentArticles( $userInfo->getId()));
$this->_view->setValue( "user", $userInfo );
Modified: plog/trunk/class/summary/dao/summarystats.class.php
===================================================================
--- plog/trunk/class/summary/dao/summarystats.class.php 2007-01-04 12:38:20 UTC (rev 4482)
+++ plog/trunk/class/summary/dao/summarystats.class.php 2007-01-04 13:04:38 UTC (rev 4483)
@@ -366,6 +366,32 @@
return $startTime;
}
-
+ /**
+ * Returns all the most recently posted articles by the given user id
+ *
+ * @param userId
+ * @param maxPosts
+ * @return An Array of Article objects
+ */
+ function getUserRecentArticles( $userId, $maxPosts = 10 )
+ {
+ lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+ // query to load the data
+ $query = "SELECT * FROM ".$this->getPrefix()."articles WHERE user_id = ".Db::qstr( $userId )." AND status = ".POST_STATUS_PUBLISHED."
+ ORDER BY date DESC";
+
+ // process it
+ $res = $this->Execute( $query, 1, $maxPosts );
+ if( !$res )
+ return( Array());
+
+ $posts = Array();
+ $articles = new Articles();
+ while( $row = $res->FetchRow()) {
+ $posts[] = $articles->mapRow( $row );
+ }
+
+ return( $posts );
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/templates/summary/userprofile.template
===================================================================
--- plog/trunk/templates/summary/userprofile.template 2007-01-04 12:38:20 UTC (rev 4482)
+++ plog/trunk/templates/summary/userprofile.template 2007-01-04 13:04:38 UTC (rev 4483)
@@ -6,8 +6,33 @@
{include file="summary/user.template"}
- <p>
- <a href="javascript:history.go(-1);">{$locale->tr("back")}</a>
- </p>
+ {foreach from=$recentArticles item=post}
+ <h3>
+ {assign var=blog value=$post->getBlogInfo()}
+ {assign var=request value=$blog->getBlogRequestGenerator()}
+ {assign var=postDate value=$post->getDateObject()}
+ <a href="{$request->postPermalink($post)}">{$post->getTopic()|strip_tags|truncate:60}</a>
+ </h3>
+
+ <div class="subtitle">
+ Publicat a <a href="{$request->postPermalink($post)}">{$blog->getBlog()}</a>{if $artGlobalCategory} | {$locale->tr("category")}: <a href="?op=PostList&globalArticleCategoryId={$artGlobalCategory->getId()}">{$artGlobalCategory->getName()}</a>{/if}
+ </div>
+
+ <p>
+ {$post->getText()|strip_tags|truncate:140:"..."}
+ </p>
+
+ <div class="postinfo">
+ <img src="imgs/post.png" width="10" height="11" alt="Autor" />
+ <strong>{$user->getUsername()}</strong>, {$locale->formatDate($postDate,"%e %B %Y")} |
+ <img src="imgs/comment.png" width="11" height="10" alt="{$locale->tr("comments")}" />
+ <a href="{$request->postPermalink($post)}#comments">{if $post->getTotalComments() eq 0}{$locale->tr("comment on this")}{else}{$post->getTotalComments()} {$locale->tr("comments")|capitalize}{/if}</a>
+ </div>
+ {/foreach}
+
+ <p>
+ <a href="javascript:history.go(-1);">{$locale->tr("back")}</a>
+ </p>
+
</div>
{include file="summary/footer.template"}
More information about the pLog-svn
mailing list