[pLog-svn] r3216 - in plog/trunk: . class/dao class/summary/action
class/summary/view class/view/admin templates/summary
mark at devel.lifetype.net
mark at devel.lifetype.net
Mon Apr 10 08:44:23 GMT 2006
Author: mark
Date: 2006-04-10 08:44:22 +0000 (Mon, 10 Apr 2006)
New Revision: 3216
Modified:
plog/trunk/class/dao/blogs.class.php
plog/trunk/class/dao/searchengine.class.php
plog/trunk/class/summary/action/bloglistaction.class.php
plog/trunk/class/summary/action/summarydefaultaction.class.php
plog/trunk/class/summary/view/summarybloglistview.class.php
plog/trunk/class/view/admin/adminsiteblogslistview.class.php
plog/trunk/summary.php
plog/trunk/templates/summary/blogslist.template
plog/trunk/templates/summary/header.template
Log:
Now the Summary Blog List can display differnt blogs list according to blogCategoryId.
And, I also change 2 method in blogs.class.php for make the summary design work.
1. getAllBlogs() : Now we need to pass the blogCategoryId as a parameter to this method. The default value is ALL_BLOG_CATEGORIES (0)
2. getNumBlogs() : As the same I modified in getAllBlogs()
I also modidy all related scripts for adapt this change.
Modified: plog/trunk/class/dao/blogs.class.php
===================================================================
--- plog/trunk/class/dao/blogs.class.php 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/class/dao/blogs.class.php 2006-04-10 08:44:22 UTC (rev 3216)
@@ -5,7 +5,9 @@
define( "CACHE_BLOGINFOS", "bloginfo" );
define( "CACHE_BLOGIDBYNAME", "bloginfo_idbyname" );
- define( "CACHE_BLOGIDBYDOMAIN","bloginfo_idbydomain" );
+ define( "CACHE_BLOGIDBYDOMAIN","bloginfo_idbydomain" );
+
+ define( "ALL_BLOG_CATEGORIES", 0 );
/**
* \ingroup DAO
@@ -169,6 +171,7 @@
* of the blog with $blogId as its identifier.
*/
function getAllBlogs( $status = BLOG_STATUS_ALL,
+ $blogCategoryId = ALL_BLOG_CATEGORIES,
$searchTerms = "",
$page = -1,
$itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
@@ -177,6 +180,9 @@
if( $status != BLOG_STATUS_ALL )
$statusCond = "status = '".Db::qstr($status)."'";
$where = $statusCond;
+
+ if( $blogCategoryId != ALL_BLOG_CATEGORIES )
+ $where .= " AND blog_category_id = '".Db::qstr($blogCategoryId)."'";
$searchCond = "";
if( $searchTerms != "" ){
@@ -189,7 +195,7 @@
$where = " WHERE $where";
$query = "SELECT * FROM ".$this->getPrefix()."blogs $where ORDER BY blog";
-
+
$result = $this->Execute( $query, $page, $itemsPerPage );
if( !$result )
@@ -238,20 +244,22 @@
*
* @return The number of blogs
*/
- function getNumBlogs( $status = BLOG_STATUS_ALL, $searchTerms = "" )
+ function getNumBlogs( $status = BLOG_STATUS_ALL, $blogCategoryId = ALL_BLOG_CATEGORIES, $searchTerms = "" )
{
$statusCond = "";
if( $status != BLOG_STATUS_ALL )
$statusCond = "status = '".Db::qstr($status)."'";
- $searchCond = "";
- if( $searchTerms != "" )
- $searchCond = $this->getSearchConditions( $searchTerms );
-
$where = $statusCond;
- if( $where != "" )
- $where .= " AND";
- $where .= $searchCond;
+ if( $blogCategoryId != ALL_BLOG_CATEGORIES )
+ $where .= " AND blog_category_id = '".Db::qstr($blogCategoryId)."'";
+
+ if( $searchTerms != "" ){
+ $searchCond = $this->getSearchConditions( $searchTerms );
+ if( $where != "" )
+ $where .= " AND " . $searchCond;
+ }
+
return( $this->getNumItems( $this->getPrefix()."blogs", $where ));
}
Modified: plog/trunk/class/dao/searchengine.class.php
===================================================================
--- plog/trunk/class/dao/searchengine.class.php 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/class/dao/searchengine.class.php 2006-04-10 08:44:22 UTC (rev 3216)
@@ -256,6 +256,7 @@
$blogs = new Blogs();
$blogsResult = $blogs->getAllBlogs( $blogStatus,
+ ALL_BLOG_CATEGORIES,
$searchTerms,
-1,
DEFAULT_ITEMS_PER_PAGE );
Modified: plog/trunk/class/summary/action/bloglistaction.class.php
===================================================================
--- plog/trunk/class/summary/action/bloglistaction.class.php 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/class/summary/action/bloglistaction.class.php 2006-04-10 08:44:22 UTC (rev 3216)
@@ -2,6 +2,7 @@
include_once( PLOG_CLASS_PATH."class/summary/action/summaryaction.class.php" );
include_once( PLOG_CLASS_PATH."class/summary/view/summarybloglistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
/**
* shows a list with all the blogs, pager included
@@ -18,18 +19,27 @@
*/
function perform()
{
+ // get the blogCategoryId from request
+ $blogCategoryId = $this->_request->getValue( "blogCategoryId" );
+ $val = new IntegerValidator();
+ if( !$val->validate( $blogCategoryId ))
+ $blogCategoryId = ALL_BLOG_CATEGORIES;
+
// this is a bit hackish but it works...
$page = View::getCurrentPageFromRequest();
// create the view
$this->_view = new SummaryBlogListView( Array( "summary" => "BlogList",
+ "blogCategoryId" => $blogCategoryId,
"page" => $page,
- "locale" => $this->_locale->getLocaleCode()));
+ "locale" => $this->_locale->getLocaleCode() ));
if( $this->_view->isCached()) {
// nothing to do, the view is cached
return true;
}
+
+ $this->_view->setValue( "blogCategoryId", $blogCategoryId );
$this->setCommonData();
Modified: plog/trunk/class/summary/action/summarydefaultaction.class.php
===================================================================
--- plog/trunk/class/summary/action/summarydefaultaction.class.php 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/class/summary/action/summarydefaultaction.class.php 2006-04-10 08:44:22 UTC (rev 3216)
@@ -57,7 +57,7 @@
// :KLUDGE:
// we just need a random blog so... we'll get one :)
//
- $randomBlog = array_pop( $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, "", 1, 1) );
+ $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/view/summarybloglistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarybloglistview.class.php 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/class/summary/view/summarybloglistview.class.php 2006-04-10 08:44:22 UTC (rev 3216)
@@ -5,6 +5,7 @@
include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
include_once( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
/**
* shows a paged list of blogs
@@ -34,11 +35,20 @@
parent::render();
return true;
}
+ // get all blog category
+ $categories = new BlogCategories();
+ $blogCategories = $categories->getBlogCategories();
+
+ // get current blogCategory
+ $blogCategoryId = $this->_params->getValue( "blogCategoryId" );
+ $currentBlogCategory = $categories->getBlogCategory( $blogCategoryId );
+ if( !$currentBlogCategory )
+ $blogCategoryId = ALL_BLOG_CATEGORIES;
// get the data itself
$blogs = new Blogs();
- $siteBlogs = $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, "", $this->_page, $this->_numBlogsPerPage );
- $numBlogs = $blogs->getNumBlogs( BLOG_STATUS_ACTIVE );
+ $siteBlogs = $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, $blogCategoryId, "", $this->_page, $this->_numBlogsPerPage );
+ $numBlogs = $blogs->getNumBlogs( BLOG_STATUS_ACTIVE, $blogCategoryId );
if( !$siteBlogs ) {
// if there was an error, show the error view
@@ -53,6 +63,8 @@
$this->setValue( "blogs", $siteBlogs );
$this->setValue( "pager", $pager );
+ $this->setValue( "blogCategories", $blogCategories );
+ $this->setValue( "currentBlogCategory", $currentBlogCategory);
// let the parent view do its job
parent::render();
Modified: plog/trunk/class/view/admin/adminsiteblogslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminsiteblogslistview.class.php 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/class/view/admin/adminsiteblogslistview.class.php 2006-04-10 08:44:22 UTC (rev 3216)
@@ -56,8 +56,8 @@
$this->_status = $this->getStatusFromRequest();
$this->_searchTerms = HttpVars::getRequestValue( "searchTerms" );
$blogs = new Blogs();
- $siteBlogs = $blogs->getAllBlogs( $this->_status, $this->_searchTerms, $this->_page, DEFAULT_ITEMS_PER_PAGE );
- $numBlogs = $blogs->getNumBlogs( $this->_status, $this->_searchTerms );
+ $siteBlogs = $blogs->getAllBlogs( $this->_status, ALL_BLOG_CATEGORIES, $this->_searchTerms, $this->_page, DEFAULT_ITEMS_PER_PAGE );
+ $numBlogs = $blogs->getNumBlogs( $this->_status, ALL_BLOG_CATEGORIES, $this->_searchTerms );
if( !$siteBlogs ) {
$siteBlogs = Array();
}
Modified: plog/trunk/summary.php
===================================================================
--- plog/trunk/summary.php 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/summary.php 2006-04-10 08:44:22 UTC (rev 3216)
@@ -54,9 +54,11 @@
//// map to associate actions with classes ////
$_actionMap["Default"] = "SummaryDefaultAction";
$_actionMap["BlogList"] = "BlogListAction";
- $_actionMap["UserList"] = "UserListAction";
- $_actionMap["UserProfile"] = "UserProfileAction";
- $_actionMap["BlogProfile"] = "BlogProfileAction";
+ $_actionMap["PostList"] = "PostListAction";
+ $_actionMap["RankList"] = "RankListAction";
+ $_actionMap["UserList"] = "UserListAction";
+ $_actionMap["UserProfile"] = "UserProfileAction";
+ $_actionMap["BlogProfile"] = "BlogProfileAction";
// conditional action registration... you've got to love this :)))
if( !$config->getValue( 'summary_disable_registration' )) {
$_actionMap["RegisterStep0"] = "doReadAgreement";
Modified: plog/trunk/templates/summary/blogslist.template
===================================================================
--- plog/trunk/templates/summary/blogslist.template 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/templates/summary/blogslist.template 2006-04-10 08:44:22 UTC (rev 3216)
@@ -1,5 +1,19 @@
{include file="summary/header.template" section=$locale->tr("blogs")}
<div id="onecolumn">
+ <div id="intro">
+ {foreach from=$blogCategories item=blogCategory}
+ {if $blogCategory->getNumBlogs() > 0}
+ <a href="?op=BlogList&blogCategoryId={$blogCategory->getId()}">{$blogCategory->getName()}</a>
+ {else}
+ {$blogCategory->getName()}
+ {/if}
+ {/foreach}
+ </div>
+ {if empty($currentBlogCategory)}
+ <h4>{$locale->tr("all")} ({$blogCategory->getNumBlogs()})</h4>
+ {else}
+ <h4>{$currentBlogCategory->getName()}</h4>
+ {/if}
{foreach from=$blogs item=blog}
{assign var="updateDate" value=$blog->getUpdateDateObject()}
{assign var="owner" value=$blog->getOwnerInfo()}
Modified: plog/trunk/templates/summary/header.template
===================================================================
--- plog/trunk/templates/summary/header.template 2006-04-10 07:50:28 UTC (rev 3215)
+++ plog/trunk/templates/summary/header.template 2006-04-10 08:44:22 UTC (rev 3216)
@@ -36,6 +36,8 @@
<ul class="menuTop">
<li class="menuOption"><a href="?op=Summary">{$locale->tr("summary")}</a></li>
<li class="menuOption"><a href="?op=RegisterStep0">{$locale->tr("register")}</a></li>
+ <li class="menuOption"><a href="?op=PostList">{$locale->tr("post")}</a></li>
+ <li class="menuOption"><a href="?op=RankList">{$locale->tr("rank")}</a></li>
<li class="menuOption"><a href="?op=BlogList">{$locale->tr("blogs")}</a></li>
<li class="menuOption"><a href="?op=UserList">{$locale->tr("users")}</a></li>
</ul>
More information about the pLog-svn
mailing list