[pLog-svn] r3226 - in plog/trunk/class: dao summary/view
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Apr 11 07:42:56 GMT 2006
Author: mark
Date: 2006-04-11 07:42:56 +0000 (Tue, 11 Apr 2006)
New Revision: 3226
Modified:
plog/trunk/class/dao/blogcategories.class.php
plog/trunk/class/dao/globalarticlecategories.class.php
plog/trunk/class/summary/view/summarybloglistview.class.php
plog/trunk/class/summary/view/summarypostlistview.class.php
Log:
Remove the min/max method in DAO.
And also use foreach to go through the BlogCategories/GlobalArticleCategories objects to get the min/max.
Modified: plog/trunk/class/dao/blogcategories.class.php
===================================================================
--- plog/trunk/class/dao/blogcategories.class.php 2006-04-11 07:16:12 UTC (rev 3225)
+++ plog/trunk/class/dao/blogcategories.class.php 2006-04-11 07:42:56 UTC (rev 3226)
@@ -128,42 +128,6 @@
}
/**
- * returns the minimal number of blogs in BlogCategory
- * @return an integer
- */
- function getMinNumActiveBlogs()
- {
- $query = "SELECT MIN(num_active_blogs) as min FROM ".$this->table;
-
- $result = $this->Execute( $query );
-
- if( !$result )
- return 0;
-
- $row = $result->FetchRow($result);
-
- return $row["min"];
- }
-
- /**
- * returns the minimal number of blogs in BlogCategory
- * @return an integer
- */
- function getMaxNumActiveBlogs()
- {
- $query = "SELECT MAX(num_active_blogs) as max FROM ".$this->table;
-
- $result = $this->Execute( $query );
-
- if( !$result )
- return 0;
-
- $row = $result->FetchRow($result);
-
- return $row["max"];
- }
-
- /**
* @see Model::getSearchConditions()
*/
function getSearchConditions( $searchTerms )
Modified: plog/trunk/class/dao/globalarticlecategories.class.php
===================================================================
--- plog/trunk/class/dao/globalarticlecategories.class.php 2006-04-11 07:16:12 UTC (rev 3225)
+++ plog/trunk/class/dao/globalarticlecategories.class.php 2006-04-11 07:42:56 UTC (rev 3226)
@@ -129,42 +129,6 @@
}
/**
- * returns the minimal number of articles in GlobalArticleCategory
- * @return an integer
- */
- function getMinNumActiveArticles()
- {
- $query = "SELECT MIN(num_active_articles) as min FROM ".$this->table;
-
- $result = $this->Execute( $query );
-
- if( !$result )
- return 0;
-
- $row = $result->FetchRow($result);
-
- return $row["min"];
- }
-
- /**
- * returns the maximal number of articles in GlobalArticleCategory
- * @return an integer
- */
- function getMaxNumActiveArticles()
- {
- $query = "SELECT MAX(num_active_articles) as max FROM ".$this->table;
-
- $result = $this->Execute( $query );
-
- if( !$result )
- return 0;
-
- $row = $result->FetchRow($result);
-
- return $row["max"];
- }
-
- /**
* @see Model::getSearchConditions()
*/
function getSearchConditions( $searchTerms )
Modified: plog/trunk/class/summary/view/summarybloglistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarybloglistview.class.php 2006-04-11 07:16:12 UTC (rev 3225)
+++ plog/trunk/class/summary/view/summarybloglistview.class.php 2006-04-11 07:42:56 UTC (rev 3226)
@@ -36,8 +36,22 @@
// get all blog category
$categories = new BlogCategories();
$blogCategories = $categories->getBlogCategories();
- $min = $categories->getMinNumActiveBlogs();
- $max = $categories->getMaxNumActiveBlogs();
+
+ $min = 0;
+ $max = 0;
+
+ foreach( $blogCategories as $blogCategory ){
+ $numActiveBlogs = $blogCategory->getNumActiveBlogs();
+ if( $numActiveBlogs < $min ) {
+ $min = $numActiveBlogs;
+ continue;
+ }
+ if( $numActiveBlogs > $max ) {
+ $max = $numActiveBlogs;
+ continue;
+ }
+ }
+
$step = ( $max - $min )/6;
if($step == 0)
$step = $min + 1;
Modified: plog/trunk/class/summary/view/summarypostlistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarypostlistview.class.php 2006-04-11 07:16:12 UTC (rev 3225)
+++ plog/trunk/class/summary/view/summarypostlistview.class.php 2006-04-11 07:42:56 UTC (rev 3226)
@@ -36,11 +36,25 @@
// 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;
// get current globalArticleCategoryId
$globalArticleCategoryId = $this->_params->getValue( "globalArticleCategoryId" );
More information about the pLog-svn
mailing list