[pLog-svn] r6300 - plog/trunk/class/dao
mark at devel.lifetype.net
mark at devel.lifetype.net
Mon Apr 7 04:46:40 EDT 2008
Author: mark
Date: 2008-04-07 04:46:39 -0400 (Mon, 07 Apr 2008)
New Revision: 6300
Modified:
plog/trunk/class/dao/articles.class.php
Log:
Add a new method to get the article object from article topic instead of post slug.
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2008-04-06 20:11:52 UTC (rev 6299)
+++ plog/trunk/class/dao/articles.class.php 2008-04-07 08:46:39 UTC (rev 6300)
@@ -72,7 +72,7 @@
return $article;
}
- /**
+ /**
* Gets an article from the database, given its slug, this is used
* with the fancy permalinks
*
@@ -118,6 +118,63 @@
}
/**
+ * Gets an article from the database, given its topic, this is used
+ * with the fancy permalinks
+ *
+ * @param artTitle Identifier of the article we want to fetch
+ * @param blogId If set, the article must belong to the given blog
+ * @return Returns an Article object or 'false' otherwise.
+ */
+ function getBlogArticleByTopic( $articleTitle,
+ $blogId,
+ $includeHiddenFields = true,
+ $date = -1,
+ $categoryId = -1,
+ $userId = -1,
+ $status = POST_STATUS_PUBLISHED,
+ $maxDate = -1 )
+ {
+
+ if(!$articleTitle)
+ return false;
+
+ // load all the articles with the same title
+ $query = "SELECT t.article_id FROM "
+ .$this->getPrefix()."articles_text as t, "
+ .$this->getPrefix()."articles as a
+ WHERE a.blog_id='".$blogId."' AND a.id=t.article_id AND t.topic='"
+ .LtDb::qstr($articleTitle)."'";
+
+ // execute the query and process the result if any
+ $result = $this->Execute( $query );
+ if( !$result )
+ return( false );
+
+ $articles = Array();
+ while( $row = $result->FetchRow()) {
+ $articles[] = $this->getBlogArticle( $row['article_id'] );
+ }
+
+ $found = false;
+ if($articles){
+ foreach( $articles as $article ) {
+ if( $article->getBlogId() == $blogId && $this->check( $article, $date, $categoryId,
+ $status, $userId, $maxDate )) {
+ $found = true;
+ break;
+ }
+ // if not, continue with the next...
+ }
+ }
+
+ if( !$found ) {
+ return false;
+ }
+
+ return( $article );
+ }
+
+ /**
* @private
*/
function _getBlogArticleFromQuery($query)
More information about the pLog-svn
mailing list