[pLog-svn] r6610 - plog/branches/lifetype-1.2/class/action

mark at devel.lifetype.net mark at devel.lifetype.net
Fri Jun 20 16:15:21 EDT 2008


Author: mark
Date: 2008-06-20 16:15:21 -0400 (Fri, 20 Jun 2008)
New Revision: 6610

Modified:
   plog/branches/lifetype-1.2/class/action/viewresourceaction.class.php
Log:
1. Refactoring the validators.

2. resId can not be empty if resource is empty.

Modified: plog/branches/lifetype-1.2/class/action/viewresourceaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/viewresourceaction.class.php	2008-06-20 19:24:30 UTC (rev 6609)
+++ plog/branches/lifetype-1.2/class/action/viewresourceaction.class.php	2008-06-20 20:15:21 UTC (rev 6610)
@@ -4,7 +4,7 @@
     lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" );
     lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
     lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
 
 	define( "VIEW_RESOURCE_TEMPLATE", "resource" );
 
@@ -26,32 +26,28 @@
         {
 			$this->BlogAction( $actionInfo, $request );
 			$this->registerFieldValidator( "resId", new IntegerValidator(), true );
-			$this->registerFieldValidator( "resource", new StringValidator( false ), true );
+			$this->registerFieldValidator( "resource", new StringValidator(), true );
 			$this->registerFieldValidator( "albumId", new IntegerValidator(), true );
-			$this->registerFieldValidator( "albumName", new StringValidator( false ), true );
+			$this->registerFieldValidator( "albumName", new StringValidator(), true );
+
+			if( $this->_request->getValue( "resource" ) == "" )
+				$this->registerFieldValidator( "resId", new IntegerValidator() );
 			
 			$this->setValidationErrorView( new ErrorView( $this->_blogInfo, "error_fetching_resource" ));
         }
 
-        function validate()
-        {
-			if( !parent::validate())
-				return false;
-
-        	$this->_resourceId = $this->_request->getValue( "resId" );
-            $this->_resourceName = $this->_request->getValue( "resource" );
-			$this->_albumId = $this->_request->getValue( "albumId" );
-			$this->_albumName = $this->_request->getValue( "albumName" );
-			
-			// if no album parameter in the url, forget about the whole thing
-			if( $this->_albumId == "" && $this->_albumName == "")
-				$this->_albumId = -1;
-
-            return true;
-        }
-
         function perform()
         {
+    		lt_include( PLOG_CLASS_PATH."class/data/filter/htmlfilter.class.php" );
+        	$this->_resourceId = $this->_request->getValue( "resId" );
+            $this->_resourceName = $this->_request->getFilteredValue( "resource", new HtmlFilter() );
+			$this->_albumId = $this->_request->getValue( "albumId" );
+			$this->_albumName = $this->_request->getFilteredValue( "albumName", new HtmlFilter() );
+
+			// if no album id parameter in the url, forget about the whole thing
+			if( $this->_albumId == "" && $this->_albumName == "")
+				$this->_albumId = -1;
+
         	$galleryResources = new GalleryResources();
 			
 			// initialize the view



More information about the pLog-svn mailing list