[pLog-svn] r3492 - plog/trunk/class/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Mon May 29 17:13:28 GMT 2006
Author: oscar
Date: 2006-05-29 17:13:27 +0000 (Mon, 29 May 2006)
New Revision: 3492
Removed:
plog/trunk/class/dao/blogarticles.class.php
Log:
not needed anymore
Deleted: plog/trunk/class/dao/blogarticles.class.php
===================================================================
--- plog/trunk/class/dao/blogarticles.class.php 2006-05-29 11:43:43 UTC (rev 3491)
+++ plog/trunk/class/dao/blogarticles.class.php 2006-05-29 17:13:27 UTC (rev 3492)
@@ -1,159 +0,0 @@
-<?php
-
- /**
- * \ingroup DAO
- *
- * Cache Object to cache all article ids of a blog, this information will not be stored
- * in the db but only in the disk-cache.
- */
- class BlogArticles {
-
- var $_blogId;
- var $_articles = array();
- var $_articlesByCategory = array();
- var $_articlesByDate = array();
- var $_articlesByStatus = array();
- var $_articlesByUser = array();
- var $_articleStatus = array();
- var $_articleDate = array();
- var $_articleDates = array();
- var $_articleCategories = array();
-
- /**
- * Constructor
- *
- * The constructor expects an array of sql rows instead of articles,
- * because to build a complete article we need to fetch to many information.
- * This class will only return ids, so we don't need full article objects,
- * please use Articles::getArticle() to fetch an article.
- *
- * @param blogId The blogId of the links to fetch
- * @blogArticlesSqlRows array containing sql row objects of articles
- */
- function BlogArticles( $blogId, $blogArticles )
- {
- $this->_blogId = $blogId;
-
- foreach( $blogArticles as $article ) {
- $articleId = $article->getId();
- $userId = $article->getUserId();
- $date = $article->getDate();
- $year = substr( $date, 0, 3 );
- $month = substr( $date, 4, 5 );
- $status = $article->getStatus();
-
- $this->_articles[] = $article;
- $this->_articlesByDate[$date][] = $article;
- $this->_articlesByStatus[$status][] = $article;
- $this->_articlesByUser[$userId][] = $article;
- $this->_articleStatus[$articleId] = $status;
- $this->_articleDate[$articleId] = $date;
- $this->_articleDates[$year][$month][] = $article;
- foreach( $article->getCategoryIds() as $categoryId )
- $this->_articleCategories[$articleId][] = $categoryId;
- $this->_articlesByCategory[$categoryId][] = $article;
- }
- }
-
- /**
- * Get the BlogId for the article ids stored in this object
- */
- function getBlogId()
- {
- return $this->_blogId;
- }
-
- /**
- * Get all article ids for current blog
- */
- function getArticleIds()
- {
- return $this->_articles;
- }
-
- function getArticleIdsByCategory( $categoryId, $articleIds = null )
- {
- if( !array_key_exists($categoryId, $this->_articlesByCategory) )
- return array();
-
- if( $articleIds == null )
- return $this->_articlesByCategory[$categoryId];
-
- $returnIds = array_intersect( $articleIds, $this->_articlesByCategory[$categoryId] );
-
- return $returnIds;
- }
-
- function getArticleIdsByStatus( $status, $articleIds = null )
- {
- require_once( PLOG_CLASS_PATH . 'class/dao/articlestatus.class.php' );
-
- if( $articleIds == null )
- $articleIds = $this->getArticleIds();
-
- if( $status == POST_STATUS_ALL )
- return $articleIds;
-
- if( !array_key_exists($status, $this->_articlesByStatus) )
- return array();
-
- $returnIds = array_intersect( $articleIds, $this->_articlesByStatus[$status] );
-
- return $returnIds;
- }
-
- function getArticleIdsByUserId( $userId, $articleIds = null )
- {
- if( !array_key_exists($userId, $this->_articlesByUser) )
- return array();
-
- if( $articleIds == null )
- $articleIds = $this->getArticleIds();
-
- $returnIds = array_intersect( $articleIds, $this->_articlesByUser[$userId] );
-
- return $returnIds;
- }
-
- function getArticleIdsByDate( $date, $articleIds = null )
- {
- if( $articleIds == null )
- $articleIds = $this->getArticleIds();
-
- $matchingArticleIds = array();
- foreach( array_keys($this->_articlesByDate) as $articleDate ) {
- if( preg_match('/^'.$date.'/', $articleDate) ) {
- $matchingArticleIds = array_merge( $matchingArticleIds,
- $this->_articlesByDate[$articleDate] );
- }
- }
-
- $returnIds = array_intersect( $articleIds, $matchingArticleIds );
-
- return $returnIds;
- }
-
- function getArticleIdsBefore( $date, $articleIds = null )
- {
- if( $articleIds == null )
- $articleIds = $this->getArticleIds();
-
- $matchingArticleIds = array();
-
- foreach( $articleIds as $articleId ) {
- if( $date > $this->_articleDate[$articleId] )
- $matchingArticleIds[] = $articleId;
- }
-
- return $matchingArticleIds;
- }
-
- function getCategoriesForArticle( $articleId )
- {
- if( !array_key_exists($articleId, $this->_articleCategories) )
- return array();
-
- return $this->_articleCategories[$articleId];
- }
- }
-?>
More information about the pLog-svn
mailing list