[pLog-svn] r6304 - in plog/trunk: class/action/admin js/ui/pages templates/admin

mark at devel.lifetype.net mark at devel.lifetype.net
Wed Apr 9 05:37:18 EDT 2008


Author: mark
Date: 2008-04-09 05:37:17 -0400 (Wed, 09 Apr 2008)
New Revision: 6304

Modified:
   plog/trunk/class/action/admin/adminchangegalleryitemsalbumaction.class.php
   plog/trunk/class/action/admin/adminchangegalleryitemslocationaction.class.php
   plog/trunk/js/ui/pages/resources.js
   plog/trunk/templates/admin/resources.template
Log:
Fixed bulk edit in resources.

Modified: plog/trunk/class/action/admin/adminchangegalleryitemsalbumaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangegalleryitemsalbumaction.class.php	2008-04-09 08:43:21 UTC (rev 6303)
+++ plog/trunk/class/action/admin/adminchangegalleryitemsalbumaction.class.php	2008-04-09 09:37:17 UTC (rev 6304)
@@ -48,32 +48,31 @@
 		
 		function perform()
 		{
-			// create the view
-			$this->_view = new AdminResourcesListView( $this->_blogInfo );
+			// update the items, if any
+			$this->_updateAlbums();	
+			$this->_updateResources();
+			
+            $this->_view = new AdminResourcesListView( $this->_blogInfo );
+            if( $this->_errorMessage != "" ) $this->_view->setErrorMessage( $this->_errorMessage );
+			if( $this->_successMessage != "" ) $this->_view->setSuccessMessage( $this->_successMessage );
+            $this->setCommonData();
 
-			// fetch the parameters
-			$this->_resourceIds = $this->_request->getValue( "resourceIds" );
-			$this->_albumIds = $this->_request->getValue( "albumIds" );
-			$this->_galleryAlbumId = $this->_request->getValue( "galleryAlbumId" );
+			return( true );
+		}
 
-			// make sure that we're dealing with arrays!
-			if( !is_array( $this->_resourceIds)) $this->_resourceIds = Array();
-			if( !is_array( $this->_albumIds)) $this->_albumIds = Array();
-
+		function performAjax()
+		{
 			// update the items, if any
 			$this->_updateAlbums();	
 			$this->_updateResources();
-
-			// 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 );
+			$results = Array( "errorMessage" => $this->_errorMessage, "successMessage" => $this->_successMessage );
+            $this->_view = new AdminAjaxView( $this->_blogInfo );
+			$this->_view->setMessage( $results );
+			$this->_view->setSuccess( true );
 
             // better to return true if everything fine
-            return true;		
+            return true;						
 		}
 
         /**
@@ -81,6 +80,12 @@
          */
         function _updateResources()
         {
+			// fetch the parameters
+			$this->_resourceIds = $this->_request->getValue( "resourceIds" );
+			$this->_galleryAlbumId = $this->_request->getValue( "galleryAlbumId" );
+			// make sure that we're dealing with arrays!
+			if( !is_array( $this->_resourceIds)) $this->_resourceIds = Array();
+
         	// Chanages the resource album field by selection
             $resources = new GalleryResources();
 
@@ -113,6 +118,9 @@
 					$this->_errorMessage .= $this->_locale->pr("error_updating_resource2", $resourceId )."<br/>";
 				}
 			}
+
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
         }
 
         /**
@@ -120,6 +128,12 @@
          */
         function _updateAlbums()
         {
+			// fetch the parameters
+			$this->_albumIds = $this->_request->getValue( "albumIds" );
+			$this->_galleryAlbumId = $this->_request->getValue( "galleryAlbumId" );
+			// make sure that we're dealing with arrays!
+			if( !is_array( $this->_albumIds)) $this->_albumIds = Array();
+
         	// Chanages the album's parent album field by selection
         	$albums = new GalleryAlbums();
 
@@ -152,6 +166,9 @@
 					$this->_errorMessage .= $this->_locale->pr( "error_updating_album2", $albumId )."<br/>";
             	}
 			}
+
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
         }
     }
 ?>

Modified: plog/trunk/class/action/admin/adminchangegalleryitemslocationaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangegalleryitemslocationaction.class.php	2008-04-09 08:43:21 UTC (rev 6303)
+++ plog/trunk/class/action/admin/adminchangegalleryitemslocationaction.class.php	2008-04-09 09:37:17 UTC (rev 6304)
@@ -33,10 +33,6 @@
         {
         	$this->AdminAction( $actionInfo, $request );
 
-			$this->_totalOk = 0;
-			$this->_successMessage = "";
-			$this->_errorMessage = "";
-			
 			// data validation
 			$this->registerFieldValidator( "resourceIds", new ArrayValidator(), true );
 			$this->registerFieldValidator( "locationId", new IntegerValidator(), true );
@@ -47,28 +43,27 @@
 		
 		function perform()
 		{
-			// create the view
-			$this->_view = new AdminResourcesListView( $this->_blogInfo );
+			$results = $this->_updateResources();
+			
+            $this->_view = new AdminResourcesListView( $this->_blogInfo );
+            if( $results["errorMessage"] != "" ) $this->_view->setErrorMessage( $results["errorMessage"] );
+			if( $results["successMessage"] != "" ) $this->_view->setSuccessMessage( $results["successMessage"] );
+            $this->setCommonData();
 
-			// fetch the parameters
-			$this->_resourceIds = $this->_request->getValue( "resourceIds" );
-			$this->_locationId = $this->_request->getValue( "locationId" );
+			return( true );
+		}
 
-			// make sure that we're dealing with arrays!
-			if( !is_array( $this->_resourceIds)) $this->_resourceIds = Array();
-
-			$this->_updateResources();
-
-			// 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();
+		function performAjax()
+		{
+			$results = $this->_updateResources();
 			
-			// clear the cache
-			CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
+			
+            $this->_view = new AdminAjaxView( $this->_blogInfo );
+			$this->_view->setMessage( $results );
+			$this->_view->setSuccess( true );
 
             // better to return true if everything fine
-            return true;		
+            return true;						
 		}
 
         /**
@@ -76,6 +71,17 @@
          */
         function _updateResources()
         {
+			// fetch the parameters
+			$this->_resourceIds = $this->_request->getValue( "resourceIds" );
+			$this->_locationId = $this->_request->getValue( "locationId" );
+
+			// make sure that we're dealing with arrays!
+			if( !is_array( $this->_resourceIds)) $this->_resourceIds = Array();
+
+            $errorMessage = "";
+			$successMessage = "";
+			$numOk = 0;
+
         	// Chanages the resource album field by selection
             $resources = new GalleryResources();
 
@@ -92,22 +98,27 @@
 					$result = $resources->updateResource( $resource );
 					
 					if( !$result ) {
-						$this->_errorMessage .= $this->_locale->pr("error_updating_resource", $resource->getFileName())."<br/>";
+						$errorMessage .= $this->_locale->pr("error_updating_resource", $resource->getFileName())."<br/>";
 					}
 					else {
-						$this->_totalOk++;
-						if( $this->_totalOk < 2 ) 
-							$this->_successMessage .= $this->_locale->pr("resource_updated_ok", $resource->getFileName());
+						$numOk++;
+						if( $numOk < 2 ) 
+							$successMessage .= $this->_locale->pr("resource_updated_ok", $resource->getFileName());
 						else
-							$this->_successMessage = $this->_locale->pr("resources_updated_ok", $this->_totalOk );
+							$successMessage = $this->_locale->pr("resources_updated_ok", $numOk );
 						// fire the post event
 						$this->notifyEvent( EVENT_POST_RESOURCE_UPDATE, Array( "article" => &$post ));					
 					}
 				} 
 				else {
-					$this->_errorMessage .= $this->_locale->pr("error_updating_resource2", $resourceId )."<br/>";
+					$errorMessage .= $this->_locale->pr("error_updating_resource2", $resourceId )."<br/>";
 				}
 			}
+
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
+			
+			return( Array( "errorMessage" => $errorMessage, "successMessage" => $successMessage ));
         }
     }
 ?>

Modified: plog/trunk/js/ui/pages/resources.js
===================================================================
--- plog/trunk/js/ui/pages/resources.js	2008-04-09 08:43:21 UTC (rev 6303)
+++ plog/trunk/js/ui/pages/resources.js	2008-04-09 09:37:17 UTC (rev 6304)
@@ -94,7 +94,7 @@
 	}
 
 	document.getElementById("Resources").op.value = op;
-	document.getElementById("Resources").submit();
+	Lifetype.Forms.performRequest(Lifetype.Dom.$( 'Resources' ));
 }
 
 Lifetype.UI.Pages.Resources.updateSubmitHook = function( form )

Modified: plog/trunk/templates/admin/resources.template
===================================================================
--- plog/trunk/templates/admin/resources.template	2008-04-09 08:43:21 UTC (rev 6303)
+++ plog/trunk/templates/admin/resources.template	2008-04-09 09:37:17 UTC (rev 6304)
@@ -65,8 +65,8 @@
   <a {if $album}href="?op=newResource&albumId={$album->getId()}"{else}href="?op=newResource"{/if} id="addResourceButton" rel="overlay">{$locale->tr("newResource")}</a>
  </div>
  <div class="right">
-  <a href="#" id="selectAll" onClick="Lifetype.UI.Pages.Resources.selectAll('Resources')">{$locale->tr("select_all")}</a> |
   <a id="optionIconLink" href="#bulkEdit" title="{$locale->tr("show_massive_change_option")}" onclick="Lifetype.UI.Pages.Global.switchMassiveOption()">{$locale->tr("show_massive_change_option")}</a>
+  <a href="#" id="selectAll" onClick="Lifetype.UI.Pages.Resources.selectAll('Resources')">{$locale->tr("select_all")}</a>
  </div>
  <br style="clear:both" />
 </div>
@@ -97,7 +97,7 @@
           </option>
         {/foreach}
       </select>
-	  <input type="button" name="changeGalleryItemsAlbum" value="{$locale->tr("change_album")}" class="submit" onClick="Lifetype.UI.Pages.Resources.submitGalleryItemsList('changeGalleryItemsAlbum');" />
+	  <input type="button" name="changeGalleryItemsAlbum" value="{$locale->tr("change_album")}" class="submit" onClick="Lifetype.UI.Pages.EditResources.submitGalleryItemsList('changeGalleryItemsAlbum');" />
 		{if $location_data_enabled}
 		<!-- location mass-edit -->
       <label for="location">{$locale->tr("location")}</label>
@@ -111,7 +111,7 @@
 		<a href="#" onClick="Lifetype.UI.Location.displaySelectedLocationFromId('resourceLocation', [ 0, -1 ] );">
 		  <img src="imgs/admin/icon_map-16.png" alt="View" style="border:0px" />
 		</a>
-      <input type="button" name="changeResourcesLocation" value="{$locale->tr("change_location")}" class="submit" onClick="Lifetype.UI.Pages.Resources.submitGalleryItemsList('changeGalleryItemsLocation');" />
+      <input type="button" name="changeResourcesLocation" value="{$locale->tr("change_location")}" class="submit" onClick="Lifetype.UI.Pages.EditResources.submitGalleryItemsList('changeGalleryItemsLocation');" />
 		{/if}
     </fieldset>
   </div>
@@ -119,4 +119,4 @@
 </form>
 
 {include file="$admintemplatepath/footernavigation.template"}
-{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
+{include file="$admintemplatepath/footer.template"}



More information about the pLog-svn mailing list