Author: dordille
Date: 2010-01-20 20:43:44 +0100 (Wed, 20 Jan 2010)
New Revision: 26953
Modified:
plugins/pkBlogPlugin/trunk/lib/model/doctrine/PluginpkBlogEventTable.class.php
plugins/pkBlogPlugin/trunk/lib/model/doctrine/PluginpkBlogPostTable.class.php
Log:
Proper sorting.
Modified:
plugins/pkBlogPlugin/trunk/lib/model/doctrine/PluginpkBlogEventTable.class.php
===================================================================
---
plugins/pkBlogPlugin/trunk/lib/model/doctrine/PluginpkBlogEventTable.class.php
2010-01-20 17:38:24 UTC (rev 26952)
+++
plugins/pkBlogPlugin/trunk/lib/model/doctrine/PluginpkBlogEventTable.class.php
2010-01-20 19:43:44 UTC (rev 26953)
@@ -4,9 +4,43 @@
*/
class PluginpkBlogEventTable extends pkBlogItemTable
{
+ /**
+ * Builds the query for blog posts and events based on the request
parameters.
+ *
+ * @param Doctrine_Query $q
+ * @param string $tableName This is going to be either pkBlogPost or
pkBlogEvent
+ * @return Doctrrin_Query $q
+ */
public function buildQuery(sfWebRequest $request, $tableName = 'pkBlogEvent')
- {
- return Doctrine::getTable('pkBlogItem')->buildQuery($request, $tableName);
+ {
+ if ($request->getParameter('tag'))
+ {
+ $q = PluginTagTable::getObjectTaggedWithQuery($tableName,
$request->getParameter('tag'), null, array('nb_common_tag' => 1));
+ }
+ else
+ {
+ $q = Doctrine_Query::create()->from($tableName.' a');
+ }
+
+ if ($request->getParameter('search'))
+ {
+ $q = Doctrine::getTable($tableName)->addSearchQuery($q,
$request->getParameter('search'));
+ }
+
+ $q = Doctrine::getTable($tableName)->addDateRangeQuery($request, $q);
+
+ $rootAlias = $q->getRootAlias();
+
+ if ($request->getParameter('cat'))
+ {
+ $q->innerJoin($rootAlias.'.Category c WITH c.slug = ? ',
$request->getParameter('cat'));
+ }
+
+ $q->addWhere($q->getRootAlias().'.published = ?', true);
+
+ $q->orderBy($rootAlias.'.start_date asc');
+
+ return $q;
}
public function addDateRangeQuery(sfWebRequest $request, Doctrine_Query $q =
null)
@@ -79,4 +113,4 @@
{
return pkZendSearch::addSearchQueryWithScores($this, $q, $luceneQuery,
null, $scores);
}
-}
\ No newline at end of file
+}
Modified:
plugins/pkBlogPlugin/trunk/lib/model/doctrine/PluginpkBlogPostTable.class.php
===================================================================
---
plugins/pkBlogPlugin/trunk/lib/model/doctrine/PluginpkBlogPostTable.class.php
2010-01-20 17:38:24 UTC (rev 26952)
+++
plugins/pkBlogPlugin/trunk/lib/model/doctrine/PluginpkBlogPostTable.class.php
2010-01-20 19:43:44 UTC (rev 26953)
@@ -21,10 +21,11 @@
// if it's an RSS feed, we don't want to be concerned with a time frame,
just give us the latest stuff
if ($request->getParameter('format') != 'rss')
{
- $q->addWhere($rootAlias.'.published_at > ?',
$request->getParameter('year', date('Y')).'-'.$request->getParameter('month',
1).'-'.$request->getParameter('day', 1).' 0:00:00')
- ->addWhere($rootAlias.'.published_at < ?',
$request->getParameter('year', date('Y')).'-'.$request->getParameter('month',
12).'-'.$request->getParameter('day', 31).' 23:59:59');
+ $q->addWhere($rootAlias.'.published_at > ? and
'.$rootAlias.'.published_at < ?', array(
+ $request->getParameter('year', 0).'-'.$request->getParameter('month',
1).'-'.$request->getParameter('day', 1).' 0:00:00',
+ $request->getParameter('year',
date('Y')).'-'.$request->getParameter('month',
12).'-'.$request->getParameter('day', 31).' 23:59:59'
+ ));
}
-
return $q;
}
@@ -67,4 +68,4 @@
{
return pkZendSearch::addSearchQueryWithScores($this, $q, $luceneQuery,
null, $scores);
}
-}
\ No newline at end of file
+}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.