[pLog-svn] r3227 - 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 08:53:41 GMT 2006
Author: mark
Date: 2006-04-11 08:53:41 +0000 (Tue, 11 Apr 2006)
New Revision: 3227
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/summarypostlistview.class.php
plog/trunk/templates/summary/index.template
plog/trunk/templates/summary/recent.template
Log:
Now, when we click on the globalarticlecategory, we will stay in summary front page, instead of jumping to postlist page.
Modified: plog/trunk/class/summary/action/summarydefaultaction.class.php
===================================================================
--- plog/trunk/class/summary/action/summarydefaultaction.class.php 2006-04-11 07:42:56 UTC (rev 3226)
+++ plog/trunk/class/summary/action/summarydefaultaction.class.php 2006-04-11 08:53:41 UTC (rev 3227)
@@ -2,7 +2,8 @@
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/dao/globalarticlecategories.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
/**
* This is the one and only default action. It simply fetches all the most recent
@@ -24,27 +25,52 @@
{
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
- $this->_view = new SummaryCachedView( "index", Array( "summary" => "default" ));
+ // get the blogCategoryId from request
+ $globalArticleCategoryId = $this->_request->getValue( "globalArticleCategoryId" );
+ $val = new IntegerValidator();
+ if( !$val->validate( $globalArticleCategoryId ))
+ $globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
+
+ $this->_view = new SummaryCachedView( "index",
+ Array( "summary" => "default",
+ "globalArticleCategoryId" => $globalArticleCategoryId ));
if( $this->_view->isCached()) {
// if the view is already cached... move along! nothing to see here
return true;
}
-
+
$blogs = new Blogs();
$stats = new SummaryStats();
// get all blog category
$categories = new GlobalArticleCategories();
$globalArticleCategories = $categories->getGlobalArticleCategories();
- $min = $categories->getMinNumActiveArticles();
- $max = $categories->getMaxNumActiveArticles();
+
+ $min = 0;
+ $max = 0;
+
+ foreach( $globalArticleCategories as $globalArticleCategory ){
+ $numActiveArticles = $globalArticleCategory->getNumActiveArticles();
+ if( $numActiveArticles < $min ) {
+ $min = $numActiveArticles;
+ continue;
+ }
+ if( $numActiveArticles > $max ) {
+ $max = $numActiveArticles;
+ continue;
+ }
+ }
+
$step = ( $max - $min )/6;
if($step == 0)
- $step = $min + 1;
+ $step = $min + 1;
+ $currentGlobalArticleCategory = $categories->getGlobalArticleCategory( $globalArticleCategoryId );
+
// export the value for global article categories
$this->_view->setValue( "summaryStats", $stats );
$this->_view->setValue( "globalArticleCategories", $globalArticleCategories );
+ $this->_view->setValue( "currentGlobalArticleCategory", $currentGlobalArticleCategory);
$this->_view->setValue( "min", $min );
$this->_view->setValue( "step", $step );
Modified: plog/trunk/class/summary/action/summaryrssaction.class.php
===================================================================
--- plog/trunk/class/summary/action/summaryrssaction.class.php 2006-04-11 07:42:56 UTC (rev 3226)
+++ plog/trunk/class/summary/action/summaryrssaction.class.php 2006-04-11 08:53:41 UTC (rev 3227)
@@ -6,6 +6,8 @@
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
include_once( PLOG_CLASS_PATH."class/summary/view/summaryrssview.class.php" );
include_once( PLOG_CLASS_PATH."class/net/rawrequestgenerator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
define( "SUMMARY_RSS_TYPE_DEFAULT", "default" );
define( "SUMMARY_RSS_TYPE_MOST_COMMENTED", "mostcommented" );
@@ -41,7 +43,7 @@
$this->_mode = SUMMARY_RSS_TYPE_DEFAULT;
}
- $this->_profile = $this->_request->getValue( "profile" );
+ $this->_profile = $this->_request->getValue( "profile" );
return true;
}
@@ -55,8 +57,15 @@
$this->_mode == SUMMARY_RSS_TYPE_MOST_READ ||
$this->_mode == SUMMARY_RSS_TYPE_DEFAULT ) {
+ // get the blogCategoryId from request
+ $globalArticleCategoryId = $this->_request->getValue( "globalArticleCategoryId" );
+ $val = new IntegerValidator();
+ if( !$val->validate( $globalArticleCategoryId ))
+ $globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
+
// RSS feeds for posts stuff
$this->_view = new SummaryRssView( $this->_profile, Array( "summary" => "rss",
+ "globalArticleCategoryId" => $globalArticleCategoryId,
"mode" => $this->_mode,
"profile" => $this->_profile ));
if( $this->_view->isCached()) {
@@ -73,7 +82,13 @@
$posts = $stats->getMostReadArticles();
}
else {
- $posts = $stats->getRecentArticles();
+ $categories = new GlobalArticleCategories();
+ $currentGlobalArticleCategory = $categories->getGlobalArticleCategory( $globalArticleCategoryId );
+
+ if( empty($currentGlobalArticleCategory) )
+ $globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
+
+ $posts = $stats->getRecentArticles( $globalArticleCategoryId );
}
if( !$posts ) {
Modified: plog/trunk/class/summary/dao/summarystats.class.php
===================================================================
--- plog/trunk/class/summary/dao/summarystats.class.php 2006-04-11 07:42:56 UTC (rev 3226)
+++ plog/trunk/class/summary/dao/summarystats.class.php 2006-04-11 08:53:41 UTC (rev 3227)
@@ -229,7 +229,7 @@
* @param maxPosts The maximum number of posts to return
* @return An array of Article objects with the most recent articles.
*/
- function getRecentArticles( $maxPosts = 0 )
+ function getRecentArticles( $globaArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES, $maxPosts = 0 )
{
include_once( PLOG_CLASS_PATH . "class/data/timestamp.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
@@ -247,6 +247,9 @@
AND a.status = ".POST_STATUS_PUBLISHED."
AND a.in_summary_page = '1'";
+ if($globaArticleCategoryId != ALL_GLOBAL_ARTICLE_CATEGORIES)
+ $query .= " AND a.global_category_id = '".Db::qstr($globaArticleCategoryId)."'";
+
$query .= " GROUP BY a.id ORDER BY a.date DESC";
if( $maxPosts <= 0 )
Modified: plog/trunk/class/summary/view/summarypostlistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarypostlistview.class.php 2006-04-11 07:42:56 UTC (rev 3226)
+++ plog/trunk/class/summary/view/summarypostlistview.class.php 2006-04-11 08:53:41 UTC (rev 3227)
@@ -61,7 +61,7 @@
$currentGlobalArticleCategory = $categories->getGlobalArticleCategory( $globalArticleCategoryId );
if( empty($currentGlobalArticleCategory) )
- $globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
+ $globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
// get the data itself
$stats = new SummaryStats();
Modified: plog/trunk/templates/summary/index.template
===================================================================
--- plog/trunk/templates/summary/index.template 2006-04-11 07:42:56 UTC (rev 3226)
+++ plog/trunk/templates/summary/index.template 2006-04-11 08:53:41 UTC (rev 3227)
@@ -48,7 +48,7 @@
<h4>{$locale->tr("global_article_categories")}</h4>
{foreach from=$globalArticleCategories item=globalArticleCategory}
{math assign=fontSize equation="(int)((x-y)/step)+12" x=$globalArticleCategory->getNumActiveArticles() y=$min step=$step}
- <span class="tag"><a style="font-size: {$fontSize}px" href="?op=PostList&globalArticleCategoryId={$globalArticleCategory->getId()}">{$globalArticleCategory->getName()}</a></span>
+ <span class="tag"><a style="font-size: {$fontSize}px" href="?op=Summary&globalArticleCategoryId={$globalArticleCategory->getId()}">{$globalArticleCategory->getName()}</a></span>
{/foreach}
</div>
{include file="summary/recent.template"}
Modified: plog/trunk/templates/summary/recent.template
===================================================================
--- plog/trunk/templates/summary/recent.template 2006-04-11 07:42:56 UTC (rev 3226)
+++ plog/trunk/templates/summary/recent.template 2006-04-11 08:53:41 UTC (rev 3227)
@@ -1,9 +1,25 @@
-<h4>{$locale->tr("summary_latest_posts")}
- {assign var=posts value=$summaryStats->getRecentArticles()}
+<h4>{$locale->tr("summary_latest_posts")} (
+ {if empty($currentGlobalArticleCategory)}
+ {$locale->tr("all")}
+ {else}
+ {$currentGlobalArticleCategory->getName()}
+ {/if})
+ {if $currentGlobalArticleCategory}
+ {assign var=globalArticleCategoryId value=$currentGlobalArticleCategory->getId()}
+ {assign var=posts value=$summaryStats->getRecentArticles($globalArticleCategoryId)}
+ {else}
+ {assign var=posts value=$summaryStats->getRecentArticles()}
+ {/if}
{if $posts}
- <a href="{$url->getRssUrl()}?summary=1">
- <img src="{$url->getUrl("/imgs/rss_logo_small.gif")}"
- alt="RSS" /></a>
+ {if $currentGlobalArticleCategory}
+ <a href="{$url->getRssUrl()}?summary=1&globalArticleCategoryId={$globalArticleCategoryId}">
+ <img src="{$url->getUrl("/imgs/rss_logo_small.gif")}" alt="RSS" />
+ </a>
+ {else}
+ <a href="{$url->getRssUrl()}?summary=1">
+ <img src="{$url->getUrl("/imgs/rss_logo_small.gif")}" alt="RSS" />
+ </a>
+ {/if}
{/if}
</h4>
{foreach from=$posts item=post}
More information about the pLog-svn
mailing list