[pLog-svn] r576 - plog/trunk/class/action/admin
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Thu Dec 23 23:38:23 GMT 2004
Author: oscar
Date: 2004-12-23 23:38:23 +0000 (Thu, 23 Dec 2004)
New Revision: 576
Modified:
plog/trunk/class/action/admin/adminresourceinfoaction.class.php
plog/trunk/class/action/admin/adminupdateresourceaction.class.php
Log:
forgot to commit this from a few days ago...
Modified: plog/trunk/class/action/admin/adminresourceinfoaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminresourceinfoaction.class.php 2004-12-23 23:35:14 UTC (rev 575)
+++ plog/trunk/class/action/admin/adminresourceinfoaction.class.php 2004-12-23 23:38:23 UTC (rev 576)
@@ -57,6 +57,9 @@
$this->_view->setValue( "resourceDescription", $resource->getDescription());
$this->_view->setValue( "albumId", $resource->getAlbumId());
}
+
+ $this->_view->setValue( "resourceDescription", $resource->getDescription());
+ $this->_view->setValue( "albumId", $resource->getAlbumId());
$this->setCommonData();
Modified: plog/trunk/class/action/admin/adminupdateresourceaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateresourceaction.class.php 2004-12-23 23:35:14 UTC (rev 575)
+++ plog/trunk/class/action/admin/adminupdateresourceaction.class.php 2004-12-23 23:38:23 UTC (rev 576)
@@ -6,10 +6,11 @@
include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
- include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresource.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/admineditresourceview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
/**
* Updates a resource in the database
@@ -28,23 +29,44 @@
function AdminUpdateResourceAction( $actionInfo, $request )
{
$this->AdminAction( $actionInfo, $request );
+
+ // data validation
+ $this->registerFieldValidator( "albumId", new IntegerValidator());
+ $this->registerFieldValidator( "resourceId", new IntegerValidator());
+ $this->registerField( "resourceDescription" );
+ $view = new AdminEditResourceView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr("error_updating_resource" ));
+ $this->setValidationErrorView( $view );
}
+
+ function validate()
+ {
+ if( !parent::validate()) {
+ print("here!!");
+ $resources = new GalleryResources();
+ $resource = $resources->getResource( $this->_request->getValue("resourceId"), $this->_blogInfo->getId());
+ if( !$resource ) {
+ $this->setValidationErrorView( new AdminResourcesListView( $this->_blogInfo ));
+ $this->setCommonData();
+ return false;
+ }
+ $this->_view->setValue( "resource", $resource );
+
+ return false;
+ }
+
+ return true;
+ }
- function validate()
- {
- $this->_resourceId = $this->_request->getValue( "resourceId" );
- $this->_albumId = $this->_request->getValue( "albumId" );
- $this->_resourceDescription = $this->_request->getValue( "resourceDescription" );
-
- return true;
- }
-
/**
* Carries out the specified action
*/
function perform()
{
// load the resource
+ $this->_resourceDescription = $this->_request->getValue( "resourceDescription" );
+ $this->_albumId = $this->_request->getValue( "albumId" );
+ $this->_resourceId = $this->_request->getValue( "resourceId" );
$resources = new GalleryResources();
$resource = $resources->getResource( $this->_resourceId, $this->_blogInfo->getId());
// update the fields we'd like to update
@@ -56,12 +78,12 @@
$result = $resources->updateResource( $resource );
if( !$result ) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->tr("error_updating_resource"));
+ $this->_view = new AdminResourcesListView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_resource"));
}
else {
- $this->_view = new AdminMessageView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->pr("resource_updated_ok", $resource->getFileName()));
+ $this->_view = new AdminResourcesListView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->pr("resource_updated_ok", $resource->getFileName()));
$this->notifyEvent( EVENT_POST_RESOURCE_UPDATE, Array( "resource" => &$resource ));
// clear the cache
More information about the pLog-svn
mailing list