[pLog-svn] r6067 - in plog/trunk: class/action/admin templates/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Thu Nov 22 01:20:12 EST 2007
Author: mark
Date: 2007-11-22 01:20:12 -0500 (Thu, 22 Nov 2007)
New Revision: 6067
Modified:
plog/trunk/class/action/admin/admindeletegalleryitemsaction.class.php
plog/trunk/templates/admin/resources.template
plog/trunk/templates/admin/resources_table.template
Log:
Fixed the delete gallery items ajax action.
Modified: plog/trunk/class/action/admin/admindeletegalleryitemsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletegalleryitemsaction.class.php 2007-11-21 17:17:17 UTC (rev 6066)
+++ plog/trunk/class/action/admin/admindeletegalleryitemsaction.class.php 2007-11-22 06:20:12 UTC (rev 6067)
@@ -1,13 +1,13 @@
<?php
-
-
-
-
-
-
-
+
+
+
+
+
+
+
/**
* \ingroup Action
* @private
@@ -19,7 +19,7 @@
var $_resourceIds;
var $_albumIds;
-
+
var $_successMessage;
var $_errorMessage;
var $_totalOk;
@@ -35,7 +35,7 @@
$this->_totalOk = 0;
$this->_successMessage = "";
$this->_errorMessage = "";
-
+
// data validation
$this->registerFieldValidator( "resourceIds", new ArrayValidator( new IntegerValidator()), true );
$this->registerFieldValidator( "albumIds", new ArrayValidator( new IntegerValidator()), true );
@@ -43,41 +43,18 @@
$view->setErrorMessage( $this->_locale->tr("error_no_resources_selected"));
$this->setValidationErrorView( $view );
}
-
- function perform()
- {
- // create the view
- $this->_view = new AdminResourcesListView( $this->_blogInfo );
+ /**
+ * deletes resources from the list
+ */
+ function _deleteResources()
+ {
// fetch the parameters
$this->_resourceIds = $this->_request->getValue( "resourceIds" );
- $this->_albumIds = $this->_request->getValue( "albumIds" );
// make sure that we're dealing with arrays!
if( !is_array( $this->_resourceIds)) $this->_resourceIds = Array();
- if( !is_array( $this->_albumIds)) $this->_albumIds = Array();
- // remove the items, if any
- $this->_deleteAlbums();
- $this->_deleteResources();
-
- // put error and success messages (if any) into the view
- if( $this->_successMessage != "" ) $this->_view->setSuccessMessage( $this->_successMessage );
- if( $this->_errorMessage != "" ) $this->_view->setErrorMessage( $this->_errorMessage );
- $this->setCommonData();
-
- // clear the cache
- CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
-
- // better to return true if everything fine
- return true;
- }
-
- /**
- * deletes resources from the list
- */
- function _deleteResources()
- {
// load the resource
$resources = new GalleryResources();
@@ -86,13 +63,13 @@
foreach( $this->_resourceIds as $resourceId => $value ) {
// fetch the resource first, to get some info about it
$resource = $resources->getResource( $resourceId, $this->_blogInfo->getId());
-
+
if( !$resource ) {
$this->_errorMessage .= $this->_locale->pr("error_deleting_resource2", $resourceId )."<br/>";
}
else {
$this->notifyEvent( EVENT_PRE_RESOURCE_DELETE, Array( "resource" => &$resource ));
-
+
// and now remove it
$res = $resources->deleteResource( $resourceId, $this->_blogInfo->getId());
if( $res ) {
@@ -103,7 +80,7 @@
$this->_successMessage .= $this->_locale->pr("item_deleted_ok", $resource->getFileName());
$this->notifyEvent( EVENT_PRE_RESOURCE_DELETE, Array( "resource" => &$resource ));
}
- else
+ else
$this->_errorMessage .= $this->_locale->pr("error_deleting_resource", $resource->getFileName())."<br/>";
}
}
@@ -116,6 +93,12 @@
*/
function _deleteAlbums()
{
+ // fetch the parameters
+ $this->_albumIds = $this->_request->getValue( "albumIds" );
+
+ // make sure that we're dealing with arrays!
+ if( !is_array( $this->_albumIds)) $this->_albumIds = Array();
+
$albums = new GalleryAlbums();
// loop through the array of resource ids and
@@ -123,7 +106,7 @@
foreach( $this->_albumIds as $albumId => $value ) {
// fetch the resource first, to get some info about it
$album = $albums->getAlbum( $albumId, $this->_blogInfo->getId());
-
+
if( !$album ) {
$this->_errorMessage .= $this->_locale->pr( "error_deleting_album2", $albumId )."<br/>";
}
@@ -133,7 +116,7 @@
}
else {
$this->notifyEvent( EVENT_PRE_ALBUM_DELETE, Array( "album" => &$album ));
-
+
// and now remove it
$res = $albums->deleteAlbum( $albumId, $this->_blogInfo->getId());
if( $res ) {
@@ -142,10 +125,10 @@
$this->_successMessage = $this->_locale->pr("items_deleted_ok", $this->_totalOk );
else
$this->_successMessage = $this->_locale->pr("item_deleted_ok", $album->getName());
-
+
$this->notifyEvent( EVENT_POST_ALBUM_DELETE, Array( "album" => &$album ));
}
- else
+ else
$this->_errorMessage .= $this->_locale->pr("error_deleting_album", $album->getName())."<br/>";
}
}
@@ -153,5 +136,47 @@
return true;
}
+
+ function perform()
+ {
+ // create the view
+ $this->_view = new AdminResourcesListView( $this->_blogInfo );
+
+ // remove the items, if any
+ $this->_deleteAlbums();
+ $this->_deleteResources();
+
+ // put error and success messages (if any) into the view
+ if( $this->_successMessage != "" ) $this->_view->setSuccessMessage( $this->_successMessage );
+ if( $this->_errorMessage != "" ) $this->_view->setErrorMessage( $this->_errorMessage );
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
+
+ // better to return true if everything fine
+ return true;
+ }
+
+ /**
+ * Ajax-specific behaviour
+ */
+ function performAjax()
+ {
+ // remove the items, if any
+ $this->_deleteAlbums();
+ $this->_deleteResources();
+
+ // put error and success messages (if any) into the view
+ $results["successMessage"] = $this->_successMessage;
+ $results["errorMessage"] = $this->_errorMessage;
+
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+ $this->_view->setMessage( $results );
+ $this->_view->setResult( true );
+
+ // better to return true if everything fine
+ return true;
+ }
}
?>
Modified: plog/trunk/templates/admin/resources.template
===================================================================
--- plog/trunk/templates/admin/resources.template 2007-11-21 17:17:17 UTC (rev 6066)
+++ plog/trunk/templates/admin/resources.template 2007-11-22 06:20:12 UTC (rev 6067)
@@ -65,7 +65,7 @@
</div>
</div>
-<form id="Resources" method="post" action="admin.php">
+<form id="Resources" method="post" action="admin.php" onSubmit="Lifetype.Forms.performRequest(this);return(false);">
{include file="$admintemplatepath/viewvalidateajax.template"}
<div id="list">
{include file="$admintemplatepath/resources_table.template"}
Modified: plog/trunk/templates/admin/resources_table.template
===================================================================
--- plog/trunk/templates/admin/resources_table.template 2007-11-21 17:17:17 UTC (rev 6066)
+++ plog/trunk/templates/admin/resources_table.template 2007-11-22 06:20:12 UTC (rev 6067)
@@ -68,14 +68,6 @@
{elseif $resource->isZip()}
{$metadata->getTotalFiles()} {$locale->tr("files")}<br/>
{/if}
- <span class="list_action_button">
- <a rel="overlay" href="?op=resourceInfo&resourceId={$resource->getId()}" title="{$locale->tr("edit")}">
- <img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
- </a>
- {*<a href="?op=deleteResource&resourceId={$resource->getId()}" title="{$locale->tr("delete")}" onClick="Lifetype.Forms.performRequest(this);return(false)">
- <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
- </a>*}
- </span>
</div>
{/foreach}
<div class="clearer"> </div>
More information about the pLog-svn
mailing list