[pLog-svn] r6515 - plog/branches/lifetype-1.2/class/action/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Sun Jun 8 16:05:19 EDT 2008
Author: mark
Date: 2008-06-08 16:05:19 -0400 (Sun, 08 Jun 2008)
New Revision: 6515
Modified:
plog/branches/lifetype-1.2/class/action/admin/adminaddpostaction.class.php
plog/branches/lifetype-1.2/class/action/admin/adminpostmanagementcommonaction.class.php
plog/branches/lifetype-1.2/class/action/admin/adminupdatepostaction.class.php
Log:
1. Move the validation stuffs to adminpostmanagementcommonaction.class.php. It is easier for us to maintain.
2. We don't need to use the postDateTime in adminupdatepostaction.class.php, just use the original article date time in the admineditpostview.class.php when something invalid in this action.
Modified: plog/branches/lifetype-1.2/class/action/admin/adminaddpostaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/adminaddpostaction.class.php 2008-06-08 19:14:06 UTC (rev 6514)
+++ plog/branches/lifetype-1.2/class/action/admin/adminaddpostaction.class.php 2008-06-08 20:05:19 UTC (rev 6515)
@@ -23,28 +23,10 @@
function AdminAddPostAction( $actionInfo, $request )
{
$this->AdminPostManagementCommonAction( $actionInfo, $request );
-
- // for data validation purposes, posts must have at least a topic, an intro text, and a category
- $this->registerFieldValidator( "postText", new StringValidator( true ));
- $this->registerFieldValidator( "postTopic", new StringValidator());
- $this->registerFieldValidator( "postCategories", new ArrayValidator( new IntegerValidator()));
- $this->registerFieldValidator( "globalArticleCategoryId", new IntegerValidator(), true );
+
$view = new AdminNewPostView( $this->_blogInfo );
$view->setErrorMessage( $this->_locale->tr("error_adding_post"));
$this->setValidationErrorView( $view );
-
- // these fields do not need to be validated but should be there when we show the view once again
- $this->registerField( "postSlug" );
- $this->registerField( "postStatus" );
- $this->registerField( "sendNotification" );
- $this->registerField( "sendTrackbacks" );
- $this->registerField( "sendPings" );
- $this->registerField( "postId" );
- $this->registerField( "commentsEnabled" );
- $this->registerField( "customField" );
- $this->registerField( "postDateTime" );
- $this->registerField( "trackbackUrls" );
- $this->registerField( "postUser" );
// security checks
$this->requirePermission( "add_post" );
Modified: plog/branches/lifetype-1.2/class/action/admin/adminpostmanagementcommonaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/adminpostmanagementcommonaction.class.php 2008-06-08 19:14:06 UTC (rev 6514)
+++ plog/branches/lifetype-1.2/class/action/admin/adminpostmanagementcommonaction.class.php 2008-06-08 20:05:19 UTC (rev 6515)
@@ -2,7 +2,10 @@
lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfieldvaluefactory.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/datetimevalidator.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
@@ -48,19 +51,32 @@
{
$this->AdminAction( $actionInfo, $request );
- // TODO: there should be validators here, rather than depending
- // on the child classes to validate everything each time?
- // Child classes call _fetchCommonData, which then gets
- // unvalidated data
- // Before removing this comment, check for all occurrences of
- // _request in this file and make sure they are either validated
- // here or in all child classes
+ // for data validation purposes, posts must have at least a topic, an intro text, and a category
+ $this->registerFieldValidator( "postText", new StringValidator( true ) );
+ $this->registerFieldValidator( "postTopic", new StringValidator() );
+ $this->registerFieldValidator( "postCategories", new ArrayValidator( new IntegerValidator() ) );
+ $this->registerFieldValidator( "postId", new IntegerValidator() );
+ $this->registerFieldValidator( "globalArticleCategoryId", new IntegerValidator(), true );
+ $this->registerFieldValidator( "postDateTime", new DateTimeValidator( '%j/%m/%Y %G:%i' ) );
+
+ // these fields do not need to be validated but should be there when we show the view once again
+ $this->registerField( "postSlug" );
+ $this->registerField( "postStatus" );
+ $this->registerField( "sendNotification" );
+ $this->registerField( "sendTrackbacks" );
+ $this->registerField( "sendPings" );
+ $this->registerField( "postId" );
+ $this->registerField( "commentsEnabled" );
+ $this->registerField( "customField" );
+
+ $this->registerField( "trackbackUrls" );
+ $this->registerField( "postUser" );
}
function _fetchPostDateInformation()
{
- // TODO: this needs to be validated
+ // TODO: this needs to be validated
// fetch the timestamp that the post will have
$postDateTime = $this->_request->getValue( "postDateTime" );
$dateTimeParts = explode(" ", $postDateTime);
Modified: plog/branches/lifetype-1.2/class/action/admin/adminupdatepostaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/adminupdatepostaction.class.php 2008-06-08 19:14:06 UTC (rev 6514)
+++ plog/branches/lifetype-1.2/class/action/admin/adminupdatepostaction.class.php 2008-06-08 20:05:19 UTC (rev 6515)
@@ -2,13 +2,11 @@
lt_include( PLOG_CLASS_PATH."class/action/admin/adminpostmanagementcommonaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/view/admin/adminpostslistview.class.php" );
- lt_include( PLOG_CLASS_PATH."class/view/admin/admineditpostview.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/admineditpostview.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfieldsvalues.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
@@ -32,42 +30,12 @@
function AdminUpdatePostAction( $actionInfo, $request )
{
$this->AdminPostManagementCommonAction( $actionInfo, $request );
-
- // for data validation purposes, posts must have at least a topic, an intro text, and a category
- $this->registerFieldValidator( "postText", new StringValidator( true ));
- $this->registerFieldValidator( "postTopic", new StringValidator());
- $this->registerFieldValidator( "postCategories", new ArrayValidator( new IntegerValidator()));
+
$this->registerFieldValidator( "postId", new IntegerValidator());
- $this->registerFieldValidator( "globalArticleCategoryId", new IntegerValidator(), true );
$view = new AdminEditPostView( $this->_blogInfo );
-
- // TODO: this needs to be validated, maybe validate each part after it is split?
- $dateTimeParts = explode(" ", $this->_request->getValue("postDateTime"));
- $dateParts = explode("/", $dateTimeParts[0] );
- $timeParts = explode(":",$dateTimeParts[1] );
- $view->setValue( "postDay", $dateParts[0]);
- $view->setValue( "postMonth", $dateParts[1]);
- $view->setValue( "postYear", $dateParts[2]);
- $view->setValue( "postHour", $timeParts[0]);
- $view->setValue( "postMinutes", $timeParts[1]);
-
$view->setErrorMessage( $this->_locale->tr("error_updating_post"));
$this->setValidationErrorView( $view );
-
- // these fields do not need to be validated but should be there when we show the view once again
- $this->registerField( "postExtendedText" );
- $this->registerField( "postSlug" );
- $this->registerField( "postStatus" );
- $this->registerField( "sendNotification" );
- $this->registerField( "sendTrackbacks" );
- $this->registerField( "sendPings" );
- $this->registerField( "postId" );
- $this->registerField( "commentsEnabled" );
- $this->registerField( "customField" );
- $this->registerField( "postDateTime" );
- $this->registerField( "trackbackUrls" );
- $this->registerField( "postUser" );
$this->requirePermission( "update_post" );
}
More information about the pLog-svn
mailing list