目前的做法很粗糙,是直接在 class/summary/summarydefaultaction.class.php 裡面動手腳,而且也只能列出「所有」站務公告文章裡的連結。應該要能控制輸出數目及直接連到「站務公告」分類頁面的連結。還有,目前是把 blogId 和 CategoryId 寫死在 summarydefaultaction.class.php 裡面的,應該要能在管理介面設定比較好。
<?php
include_once( PLOG_CLASS_PATH."class/summary/action/summaryaction.class.php" );
include_once( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
include_once( PLOG_CLASS_PATH."class/logger/LogUtil.php" );
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" ); /**
* This is the one and only default action. It simply fetches all the most recent
* posts from the database and shows them. The default locale is the one specified
* in the configuration file and the amount of posts shown in this page is also
* configurable through the config file.
*/
class SummaryDefaultAction extends SummaryAction
{
var $_numPosts;
function SummaryDefaultAction( $actionInfo, $request )
{
$this->SummaryAction( $actionInfo, $request );
$this->_numPosts = $this->_config->getValue( "summary_page_show_max" );
}
/**
* Loads the posts and shows them.
*/
function perform()
{
$this->_view = new SummaryCachedView( "index", Array( "summary" => "default", "locale" => $this->_locale->getLocaleCode()));
if( $this->_view->isCached()) {
// if the view is already cached... move along! nothing to see here
return true;
}
$blogs = new Blogs();
$stats = new SummaryStats();
// load the posts, filtering out all those registration messages...
$registerTopic = $this->_locale->tr( "register_default_article_topic" );
$registerText = $this->_locale->tr( "register_default_article_text" );
$recentPosts = $stats->getRecentArticles( $this->_numPosts, $registerTopic, $registerText );
// get all the blogs
$siteBlogs = $blogs->getAllBlogs( true );
$recentBlogs = $stats->getRecentBlogs( $this->_numPosts );
$activeBlogs = $stats->getMostActiveBlogs( $this->_numPosts);
$commentedPosts = $stats->getMostCommentedArticles( $this->_numPosts, $registerTopic, $registerText );
$readestBlogs = $stats->getMostReadArticles( $this->_numPosts, $registerTopic, $registerText );
$articles = new Articles();
$announcePosts = $articles->getBlogArticles( 1, -1, -1, 13); // export all these things to the view
$this->_view->setValue( "posts", $recentPosts );
$this->_view->setValue( "recentBlogs", $recentBlogs );
$this->_view->setValue( "activeBlogs", $activeBlogs );
$this->_view->setValue( "commentedPosts", $commentedPosts );
$this->_view->setValue( "readestBlogs", $readestBlogs );
$this->_view->setValue( "blogs", $siteBlogs );
$this->_view->setValue( "announces", $announcePosts ); //
// :KLUDGE:
// we just need a random blog so... we'll get one
//
$randomBlog = array_pop($siteBlogs);
$url = $randomBlog->getBlogRequestGenerator();
$this->_view->setValue( "url", $url );
$this->setCommonData();
return true;
}
}
?>
.....
column-left部份省略
.....
<div id="maincolumn">
<div id="intro">
<h4>{$locale->tr("summary_welcome")}</h4>
歡迎來到內壢高中 blog 站!<br />
本站目前正在測試中,暫不開放註冊!本校同仁若有興趣參與測試,請洽資訊媒體組。
</div>
{include file="summary/announces.template"}
{include file="summary/recent.template"}
</div>
.....
column-right部份省略
.....