[pLog-svn] r6589 - in plog/branches/lifetype-1.2/class: action/admin view/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Thu Jun 19 04:28:34 EDT 2008
Author: mark
Date: 2008-06-19 04:28:34 -0400 (Thu, 19 Jun 2008)
New Revision: 6589
Modified:
plog/branches/lifetype-1.2/class/action/admin/admineditarticlecategoriesaction.class.php
plog/branches/lifetype-1.2/class/view/admin/adminarticlecategorieslistview.class.php
Log:
Move all validation parts to action, instead of view.
It can avoid the in-valid data to touch the view.
Modified: plog/branches/lifetype-1.2/class/action/admin/admineditarticlecategoriesaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/admineditarticlecategoriesaction.class.php 2008-06-19 08:23:39 UTC (rev 6588)
+++ plog/branches/lifetype-1.2/class/action/admin/admineditarticlecategoriesaction.class.php 2008-06-19 08:28:34 UTC (rev 6589)
@@ -1,8 +1,10 @@
<?php
lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
- lt_include( PLOG_CLASS_PATH."class/view/admin/adminarticlecategorieslistview.class.php" );
-
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminarticlecategorieslistview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/filter/htmlfilter.class.php" );
+
/**
* \ingroup Action
* @private
@@ -19,8 +21,12 @@
function AdminEditArticleCategoriesAction( $actionInfo, $request )
{
$this->AdminAction( $actionInfo, $request );
-
- $this->requirePermission( "view_categories" );
+
+ $this->registerFieldValidator( "searchTerms", new StringValidator(), true);
+ $this->setValidationErrorView( new AdminArticleCategoriesListView( $this->_blogInfo,
+ Array( "searchTerms" => "" )
+ ) );
+ $this->requirePermission( "view_categories" );
}
/**
@@ -28,8 +34,9 @@
*/
function perform()
{
+ $searchTerms = $this->_request->getFilteredValue( "searchTerms", new HtmlFilter());
// create the view, which will take care of fetching the right data
- $this->_view = new AdminArticleCategoriesListView( $this->_blogInfo );
+ $this->_view = new AdminArticleCategoriesListView( $this->_blogInfo, Array( "searchTerms" => $searchTerms ) );
$this->setCommonData();
// better to return true if everything fine
Modified: plog/branches/lifetype-1.2/class/view/admin/adminarticlecategorieslistview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/adminarticlecategorieslistview.class.php 2008-06-19 08:23:39 UTC (rev 6588)
+++ plog/branches/lifetype-1.2/class/view/admin/adminarticlecategorieslistview.class.php 2008-06-19 08:28:34 UTC (rev 6589)
@@ -3,7 +3,6 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/filter/htmlfilter.class.php" );
/**
* \ingroup View
@@ -20,9 +19,16 @@
* Constructor. If nothing else, it also has to call the constructor of the parent
* class, BlogAction with the same parameters
*/
- function AdminArticleCategoriesListView( $blogInfo, $page = 1 )
+ function AdminArticleCategoriesListView( $blogInfo, $params = Array() )
{
- $this->AdminTemplatedView( $blogInfo, "editarticlecategories" );
+ $this->AdminTemplatedView( $blogInfo, "editarticlecategories" );
+
+ // save the parameters and put them in a nicer place after checking them
+ if( !isset( $params["searchTerms"] ) )
+ $params["searchTerms"] = "";
+
+ $this->_searchTerms = $params["searchTerms"];
+ $this->_page = $this->getCurrentPageFromRequest();
}
/**
@@ -35,10 +41,6 @@
$blogSettings = $this->_blogInfo->getSettings();
$categoriesOrder = $blogSettings->getValue( "categories_order" );
- // get the page too
- $this->_page = $this->getCurrentPageFromRequest();
- $this->_searchTerms = $this->_request->getFilteredValue( "searchTerms", new HtmlFilter());
-
// retrieve the categories in an paged fashion
$totalCategories = $categories->getBlogNumCategories( $this->_blogInfo->getId(), true, $this->_searchTerms );
$blogCategories = $categories->getBlogCategories( $this->_blogInfo->getId(),
@@ -47,9 +49,8 @@
$this->_searchTerms,
$this->_page,
DEFAULT_ITEMS_PER_PAGE );
- if( !$blogCategories ) {
+ if( !$blogCategories )
$blogCategories = Array();
- }
// throw the even in case somebody's waiting for it!
$this->notifyEvent( EVENT_CATEGORIES_LOADED, Array( "categories" => &$blogCategories ));
More information about the pLog-svn
mailing list