[pLog-svn] r5537 - in plog/trunk: class/action class/dao class/view/admin templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Tue Jun 12 17:53:22 EDT 2007
Author: oscar
Date: 2007-06-12 17:53:22 -0400 (Tue, 12 Jun 2007)
New Revision: 5537
Modified:
plog/trunk/class/action/defaultaction.class.php
plog/trunk/class/dao/articles.class.php
plog/trunk/class/dao/blogsettings.class.php
plog/trunk/class/view/admin/adminpostslistview.class.php
plog/trunk/templates/admin/blogsettings.template
Log:
This is the proper way to fix issue http://bugs.lifetype.net/view.php?id=1334, but I couldn't do it in the 1.2 branch because I would have broken the signature of method Articles::getBlogArticles(), which is God knows used by how many plugins by now. Now the article order choice is left up to the calling code and not to getBlogArticles()
Modified: plog/trunk/class/action/defaultaction.class.php
===================================================================
--- plog/trunk/class/action/defaultaction.class.php 2007-06-12 20:54:21 UTC (rev 5536)
+++ plog/trunk/class/action/defaultaction.class.php 2007-06-12 21:53:22 UTC (rev 5537)
@@ -193,6 +193,8 @@
$this->_userId,
$todayTimestamp,
$this->_searchTerms,
+ $blogSettings->getValue( "articles_order", ARTICLES_NEWEST_FIRST ),
+ -1, // no location
$this->_page );
// and the total number based on the conditions given
$numArticles = $articles->getNumBlogArticles(
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2007-06-12 20:54:21 UTC (rev 5536)
+++ plog/trunk/class/dao/articles.class.php 2007-06-12 21:53:22 UTC (rev 5537)
@@ -4,6 +4,12 @@
lt_include( PLOG_CLASS_PATH.'class/dao/article.class.php' );
lt_include( PLOG_CLASS_PATH.'class/dao/articlestatus.class.php' );
lt_include( PLOG_CLASS_PATH.'class/dao/daocacheconstants.properties.php' );
+
+ /**
+ * Constants used as the $order parameter in method getBlogArticles
+ */
+ define( "ARTICLES_OLDEST_FIRST", 1 );
+ define( "ARTICLES_NEWEST_FIRST", 2 );
/**
* \ingroup DAO
@@ -425,6 +431,10 @@
* @param maxDate a date in MySQL TIMESTAMP(14)
* @param searchTerms in case we would like to further refine the filtering,
we can also use search features
+ * @param order Order in which items should be returned. It can take any of these
+ * two values: ARTICLES_NEWEST_FIRST and ARTICLES_OLDEST_FIRST. Bear in mind, however,
+ * that this parameter is not taken into account when $searchTerms is used, as searched
+ * articles are always returned sorted by relevance
* @param locationId A location identifier
* @return Returns an array with all the articles from the given blog
*/
@@ -437,6 +447,7 @@
$userId = 0,
$maxDate = 0,
$searchTerms = "",
+ $order = ARTICLES_NEWEST_FIRST,
$locationId = -1,
$page = -1 )
{
@@ -471,17 +482,10 @@
$query .= " ORDER BY relevance";
}
else {
- // check article order preference, default to newest first
- lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
- $blogs = new Blogs();
- $blogInfo = $blogs->getBlogInfo( $blogId );
- $blogSettings = $blogInfo->getSettings();
-
- if($blogSettings->getValue( "articles_order" ) == 1) {
- $query .= " ORDER BY a.date ASC";
- } else {
- $query .= " ORDER BY a.date DESC";
- }
+ if( $order == ARTICLES_NEWEST_FIRST )
+ $query .= " ORDER BY a.date DESC ";
+ else
+ $query .= " ORDER BY a.date ASC ";
}
// we don't need limits if we're getting the posts for a given day
Modified: plog/trunk/class/dao/blogsettings.class.php
===================================================================
--- plog/trunk/class/dao/blogsettings.class.php 2007-06-12 20:54:21 UTC (rev 5536)
+++ plog/trunk/class/dao/blogsettings.class.php 2007-06-12 21:53:22 UTC (rev 5537)
@@ -45,6 +45,7 @@
$this->setValue( "categories_order", 0 );
$this->setValue( "comments_order", $config->getValue( "comments_order" ));
$this->setValue( "time_offset", $config->getValue( "default_time_offset", DEFAULT_TIME_OFFSET ));
+ $this->setValue( "articles_order", 2 ); // :TODO: Use the constant here!
}
function getValue( $key, $defaultValue = null, $filterClass = null )
Modified: plog/trunk/class/view/admin/adminpostslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminpostslistview.class.php 2007-06-12 20:54:21 UTC (rev 5536)
+++ plog/trunk/class/view/admin/adminpostslistview.class.php 2007-06-12 21:53:22 UTC (rev 5537)
@@ -134,6 +134,7 @@
{
// fetch all the articles for edition, but we need to know whether we are trying to
// search for some of them or simply filter them based on certain criteria
+ $blogSettings = $this->_blogInfo->getSettings();
$articles = new Articles();
$posts = $articles->getBlogArticles( $this->_blogInfo->getId(), // the blog id
$this->_showMonth, // current month
@@ -143,6 +144,7 @@
$this->_showUser, // current user
0, // no maxdate
$this->_searchTerms, // current search terms
+ $blogSettings->getValue( "articles_order", ARTICLES_NEWEST_FIRST ), // articles order
$this->_locationId, // location id
$this->_page // current page
);
@@ -156,6 +158,7 @@
$this->_showUser, // current user
0, // no maxdate
$this->_searchTerms, // current search terms
+ $blogSettings->getValue( "articles_order", ARTICLES_NEWEST_FIRST ), // articles order
$this->_locationId // location id
);
Modified: plog/trunk/templates/admin/blogsettings.template
===================================================================
--- plog/trunk/templates/admin/blogsettings.template 2007-06-12 20:54:21 UTC (rev 5536)
+++ plog/trunk/templates/admin/blogsettings.template 2007-06-12 21:53:22 UTC (rev 5537)
@@ -192,8 +192,8 @@
<label for="blogArticlesOrder">{$locale->tr("articles_order")}</label>
<div class="formHelp">{$locale->tr("articles_order_help")}</div>
<select name="blogArticlesOrder" id="blogArticlesOrder">
+ <option value="2" {if $blogArticlesOrder == 2 } selected="selected" {/if}>{$locale->tr("newest_first")}</option>
<option value="1" {if $blogArticlesOrder == 1 } selected="selected" {/if}>{$locale->tr("oldest_first")}</option>
- <option value="2" {if $blogArticlesOrder == 2 } selected="selected" {/if}>{$locale->tr("newest_first")}</option>
</select>
</div>
More information about the pLog-svn
mailing list