[pLog-svn] r3225 - in plog/trunk: class/summary/action
class/summary/dao class/summary/view templates/summary
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Apr 11 07:16:13 GMT 2006
Author: mark
Date: 2006-04-11 07:16:12 +0000 (Tue, 11 Apr 2006)
New Revision: 3225
Modified:
plog/trunk/class/summary/action/summarydefaultaction.class.php
plog/trunk/class/summary/action/summaryrssaction.class.php
plog/trunk/class/summary/dao/summarystats.class.php
plog/trunk/class/summary/view/summarybloglistview.class.php
plog/trunk/class/summary/view/summarypostlistview.class.php
plog/trunk/class/summary/view/summaryuserlistview.class.php
plog/trunk/templates/summary/index.template
plog/trunk/templates/summary/recent.template
Log:
I just re-organize the source code of summary. And also implement the idea that Oscar metioned in svn-list
-- move the calls to load the data to the template itself. Instead of loading the most read blogs, most commented articles, etc in summarydefaultaction.class.php
Modified: plog/trunk/class/summary/action/summarydefaultaction.class.php
===================================================================
--- plog/trunk/class/summary/action/summarydefaultaction.class.php 2006-04-11 04:49:23 UTC (rev 3224)
+++ plog/trunk/class/summary/action/summarydefaultaction.class.php 2006-04-11 07:16:12 UTC (rev 3225)
@@ -12,13 +12,9 @@
*/
class SummaryDefaultAction extends SummaryAction
{
-
- var $_numPosts;
-
function SummaryDefaultAction( $actionInfo, $request )
{
$this->SummaryAction( $actionInfo, $request );
- $this->_numPosts = $this->_config->getValue( "summary_page_show_max" );
}
/**
@@ -37,15 +33,6 @@
$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 );
- $recentBlogs = $stats->getRecentBlogs( $this->_numPosts );
- $activeBlogs = $stats->getMostActiveBlogs( $this->_numPosts);
- $commentedPosts = $stats->getMostCommentedArticles( $this->_numPosts, $registerTopic, $registerText );
- $readestBlogs = $stats->getMostReadArticles( $this->_numPosts, $registerTopic, $registerText );
-
// get all blog category
$categories = new GlobalArticleCategories();
$globalArticleCategories = $categories->getGlobalArticleCategories();
@@ -55,22 +42,13 @@
if($step == 0)
$step = $min + 1;
- // 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 );
-
// export the value for global article categories
+ $this->_view->setValue( "summaryStats", $stats );
$this->_view->setValue( "globalArticleCategories", $globalArticleCategories );
$this->_view->setValue( "min", $min );
$this->_view->setValue( "step", $step );
- //
- // :KLUDGE:
// we just need a random blog so... we'll get one :)
- //
$randomBlog = array_pop( $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, ALL_BLOG_CATEGORIES, "", 1, 1) );
$url = $randomBlog->getBlogRequestGenerator();
$this->_view->setValue( "url", $url );
Modified: plog/trunk/class/summary/action/summaryrssaction.class.php
===================================================================
--- plog/trunk/class/summary/action/summaryrssaction.class.php 2006-04-11 04:49:23 UTC (rev 3224)
+++ plog/trunk/class/summary/action/summaryrssaction.class.php 2006-04-11 07:16:12 UTC (rev 3225)
@@ -22,12 +22,9 @@
class SummaryRssAction extends SummaryAction
{
- var $_numPosts;
-
function SummaryRssAction( $actionInfo, $request )
{
$this->SummaryAction( $actionInfo, $request );
- $this->_numPosts = $this->_config->getValue( "summary_page_show_max" );
}
function validate()
@@ -70,16 +67,13 @@
$stats = new SummaryStats();
if( $this->_mode == SUMMARY_RSS_TYPE_MOST_COMMENTED ) {
- $posts = $stats->getMostCommentedArticles( $this->_numPosts);
+ $posts = $stats->getMostCommentedArticles();
}
elseif( $this->_mode == SUMMARY_RSS_TYPE_MOST_READ ) {
- $posts = $stats->getMostReadArticles( $this->_numPosts);
+ $posts = $stats->getMostReadArticles();
}
else {
- // load the most recent posts, filtering out all those registration messages...
- $registerTopic = $this->_locale->tr( "register_default_article_topic" );
- $registerText = $this->_locale->tr( "register_default_article_text" );
- $posts = $stats->getRecentArticles( $this->_numPosts, $registerTopic, $registerText );
+ $posts = $stats->getRecentArticles();
}
if( !$posts ) {
@@ -103,10 +97,10 @@
$stats = new SummaryStats();
if( $this->_mode == SUMMARY_RSS_TYPE_MOST_ACTIVE_BLOGS ) {
- $blogs = $stats->getMostActiveBlogs( $this->_numPosts );
+ $blogs = $stats->getMostActiveBlogs();
}
else {
- $blogs = $stats->getRecentBlogs( $this->_numPosts);
+ $blogs = $stats->getRecentBlogs();
}
// in case there is really no data to fetch...
Modified: plog/trunk/class/summary/dao/summarystats.class.php
===================================================================
--- plog/trunk/class/summary/dao/summarystats.class.php 2006-04-11 04:49:23 UTC (rev 3224)
+++ plog/trunk/class/summary/dao/summarystats.class.php 2006-04-11 07:16:12 UTC (rev 3225)
@@ -2,13 +2,15 @@
include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+ include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articlecommentstatus.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articlestatus.class.php" );
/**
* maximum number of items that will be shown per page in the summary
*/
- define( "SUMMARY_DEFAULT_ITEMS_PER_PAGE", 15 );
+ define( "SUMMARY_DEFAULT_ITEMS_PER_PAGE", 25 );
+ define( "SUMMARY_DEFAULT_PAGE_SHOW_MAX", 15 );
define( "ALL_GLOBAL_ARTICLE_CATEGORIES", 0 );
@@ -27,6 +29,7 @@
var $_now;
var $_sevenDaysAgo;
+ var $_summaryPageShowMax;
function SummaryStats()
{
@@ -40,17 +43,19 @@
// 7 days ago
$t->subtractSeconds( 7 * 24 * 60 * 60 );
$this->_sevenDaysAgo = $t->getTimestamp();
+
+ // get the summary_page_show_max from config
+ $config =& Config::getConfig();
+ $this->_summaryPageShowMax = $config->getValue( "summary_page_show_max", SUMMARY_DEFAULT_PAGE_SHOW_MAX );
}
/**
* Returns the most commented articles so far
*
* @param maxPosts The maximum number of posts to return
- * @param ignoreTopic ignore posts based on a certain topic
- * @param ignoreText ignore post based on a certain text
* @return An array of Article objects with the most commented articles
*/
- function getMostCommentedArticles( $maxPosts = 0, $ignoreTopic = "", $ignoreText = "" )
+ function getMostCommentedArticles( $maxPosts = 0 )
{
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/commentscommon.class.php" );
@@ -74,8 +79,9 @@
if( $maxPosts > 0 )
$query .= " LIMIT 0,".$maxPosts;
+ else
+ $query .= " LIMIT 0,".$this->_summaryPageShowMax;
-
$result = $this->Execute( $query );
if( !$result ){
@@ -96,12 +102,10 @@
* Returns an array with the most read articles
*
* @param maxPosts The maximum number of posts to return
- * @param ignoreTopic ignore posts based on a certain topic
- * @param ignoreText ignore post based on a certain text
* @return an array of Article objects with information about the posts
* TODO: perfalmence tuning
*/
- function getMostReadArticles( $maxPosts = 0, $ignoreTopic = "", $ignoreText = "" )
+ function getMostReadArticles( $maxPosts = 0 )
{
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
@@ -119,6 +123,8 @@
if( $maxPosts > 0 )
$query .= " LIMIT 0,".$maxPosts;
+ else
+ $query .= " LIMIT 0,".$this->_summaryPageShowMax;
$result = $this->Execute( $query );
@@ -143,7 +149,7 @@
* @return An array of BlogInfo objects
* @see BlogInfo
*/
- function getRecentBlogs($maxBlogs = 0)
+ function getRecentBlogs( $maxBlogs = 0 )
{
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
$query = "SELECT * FROM ".$this->getPrefix()."blogs WHERE status = ".BLOG_STATUS_ACTIVE."
@@ -151,6 +157,8 @@
if( $maxBlogs > 0 )
$query .= " LIMIT 0,".$maxBlogs;
+ else
+ $query .= " LIMIT 0,".$this->_summaryPageShowMax;
$result = $this->Execute( $query );
@@ -191,7 +199,9 @@
GROUP BY a.blog_id ORDER BY rank DESC ";
if( $maxBlogs > 0 )
- $query .= " LIMIT 0,".$maxBlogs;
+ $query .= " LIMIT 0,".$maxBlogs;
+ else
+ $query .= " LIMIT 0,".$this->_summaryPageShowMax;
$result = $this->Execute( $query );
@@ -217,11 +227,9 @@
* in categories not shown in the main page of each blog will not be shown!
*
* @param maxPosts The maximum number of posts to return
- * @param ignoreTopic ignore posts based on a certain topic
- * @param ignoreText ignore post based on a certain text
* @return An array of Article objects with the most recent articles.
*/
- function getRecentArticles( $maxPosts, $ignoreTopic = "", $ignoreText = "" )
+ function getRecentArticles( $maxPosts = 0 )
{
include_once( PLOG_CLASS_PATH . "class/data/timestamp.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
@@ -239,7 +247,13 @@
AND a.status = ".POST_STATUS_PUBLISHED."
AND a.in_summary_page = '1'";
- $query .= " GROUP BY a.id ORDER BY a.date DESC LIMIT 0, $maxPosts";
+ $query .= " GROUP BY a.id ORDER BY a.date DESC";
+
+ if( $maxPosts <= 0 )
+ $maxPosts = $this->_summaryPageShowMax;
+
+ $query .= " LIMIT 0,".$maxPosts;
+
$result = $this->Execute( $query );
if( !$result )
@@ -265,10 +279,8 @@
}
function getRecentPostsByGlobalCategory( $globaArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES,
- $ignoreTopic = "",
- $ignoreText = "",
$page = -1,
- $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+ $itemsPerPage = SUMMARY_DEFAULT_ITEMS_PER_PAGE )
{
include_once( PLOG_CLASS_PATH . "class/data/timestamp.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
@@ -290,6 +302,7 @@
$query .= " AND a.global_category_id = '".Db::qstr($globaArticleCategoryId)."'";
$query .= " GROUP BY a.blog_id ORDER BY a.date DESC";
+
$result = $this->Execute( $query, $page, $itemsPerPage );
if( !$result )
@@ -306,9 +319,7 @@
return $posts;
}
- function getNumRecentPostsByGlobalCategory( $globaArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES,
- $ignoreTopic = "",
- $ignoreText = "" )
+ function getNumRecentPostsByGlobalCategory( $globaArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES )
{
include_once( PLOG_CLASS_PATH . "class/data/timestamp.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
Modified: plog/trunk/class/summary/view/summarybloglistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarybloglistview.class.php 2006-04-11 04:49:23 UTC (rev 3224)
+++ plog/trunk/class/summary/view/summarybloglistview.class.php 2006-04-11 07:16:12 UTC (rev 3225)
@@ -12,7 +12,6 @@
*/
class SummaryBlogListView extends SummaryCachedView
{
- var $_numBlogs;
var $_numBlogsPerPage;
function SummaryBlogListView( $data = Array())
@@ -23,7 +22,6 @@
$this->SummaryCachedView( "blogslist", $data );
// items per page
- //$this->_numUsers = $this->_config->getValue( "summary_page_show_max" );
$config =& Config::getConfig();
$this->_numBlogsPerPage = $config->getValue( "summary_blogs_per_page", SUMMARY_DEFAULT_ITEMS_PER_PAGE );
}
Modified: plog/trunk/class/summary/view/summarypostlistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarypostlistview.class.php 2006-04-11 04:49:23 UTC (rev 3224)
+++ plog/trunk/class/summary/view/summarypostlistview.class.php 2006-04-11 07:16:12 UTC (rev 3225)
@@ -12,7 +12,6 @@
*/
class SummaryPostListView extends SummaryCachedView
{
- var $_numArticles;
var $_numArticlesPerPage;
function SummaryPostListView( $data = Array())
@@ -22,8 +21,9 @@
$this->SummaryCachedView( "postslist", $data );
+ // items per page
$config =& Config::getConfig();
- $this->_numArticlesPerPage = 25;
+ $this->_numArticlesPerPage = $config->getValue( "summary_blogs_per_page", SUMMARY_DEFAULT_ITEMS_PER_PAGE );
}
function render()
@@ -51,8 +51,8 @@
// get the data itself
$stats = new SummaryStats();
- $posts = $stats->getRecentPostsByGlobalCategory( $globalArticleCategoryId, "", "", $this->_page, $this->_numArticlesPerPage );
- $numPosts = $stats->getNumRecentPostsByGlobalCategory( $globalArticleCategoryId, "", "" );
+ $posts = $stats->getRecentPostsByGlobalCategory( $globalArticleCategoryId, $this->_page, $this->_numArticlesPerPage );
+ $numPosts = $stats->getNumRecentPostsByGlobalCategory( $globalArticleCategoryId );
if( !$posts ) {
// if there was an error, show the error view
Modified: plog/trunk/class/summary/view/summaryuserlistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summaryuserlistview.class.php 2006-04-11 04:49:23 UTC (rev 3224)
+++ plog/trunk/class/summary/view/summaryuserlistview.class.php 2006-04-11 07:16:12 UTC (rev 3225)
@@ -11,7 +11,6 @@
*/
class SummaryUserListView extends SummaryCachedView
{
- var $_numUsers;
var $_numUsersPerPage;
function SummaryUserListView( $data = Array())
@@ -25,7 +24,6 @@
// items per page
$config =& Config::getConfig();
$this->_numUsersPerPage = $config->getValue( "summary_blogs_per_page", SUMMARY_DEFAULT_ITEMS_PER_PAGE );
-
}
function render()
Modified: plog/trunk/templates/summary/index.template
===================================================================
--- plog/trunk/templates/summary/index.template 2006-04-11 04:49:23 UTC (rev 3224)
+++ plog/trunk/templates/summary/index.template 2006-04-11 07:16:12 UTC (rev 3225)
@@ -19,6 +19,7 @@
</fieldset>
</form>
<h4>{$locale->tr("summary_newest_blogs")}
+ {assign var=recentBlogs value=$summaryStats->getRecentBlogs()}
{if $recentBlogs}
<a href="{$url->getRssUrl()}?summary=1&type=newestblogs">
<img src="{$url->getUrl("/imgs/rss_logo_small.gif")}"
@@ -74,6 +75,7 @@
</fieldset>
</form>
<h4>{$locale->tr("summary_most_active_blogs")}
+ {assign var=activeBlogs value=$summaryStats->getMostActiveBlogs()}
{if $activeBlogs}
<a href="{$url->getRssUrl()}?summary=1&type=mostactiveblogs">
<img src="{$url->getUrl("/imgs/rss_logo_small.gif")}"
@@ -88,6 +90,7 @@
</ul>
<h4>{$locale->tr("summary_most_commented_articles")}
+ {assign var=commentedPosts value=$summaryStats->getMostCommentedArticles()}
{if $commentedPosts}
<a href="{$url->getRssUrl()}?summary=1&type=mostcommented">
<img src="{$url->getUrl("/imgs/rss_logo_small.gif")}"
@@ -110,6 +113,7 @@
{/foreach}
<h4>{$locale->tr("summary_most_read_articles")}
+ {assign var=readestBlogs value=$summaryStats->getMostReadArticles()}
{if $readestBlogs}
<a href="{$url->getRssUrl()}?summary=1&type=mostread">
<img src="{$url->getUrl("/imgs/rss_logo_small.gif")}"
Modified: plog/trunk/templates/summary/recent.template
===================================================================
--- plog/trunk/templates/summary/recent.template 2006-04-11 04:49:23 UTC (rev 3224)
+++ plog/trunk/templates/summary/recent.template 2006-04-11 07:16:12 UTC (rev 3225)
@@ -1,4 +1,5 @@
<h4>{$locale->tr("summary_latest_posts")}
+ {assign var=posts value=$summaryStats->getRecentArticles()}
{if $posts}
<a href="{$url->getRssUrl()}?summary=1">
<img src="{$url->getUrl("/imgs/rss_logo_small.gif")}"
More information about the pLog-svn
mailing list