[pLog-svn] r6217 - in plog/trunk: class/action/admin templates/admin

mark at devel.lifetype.net mark at devel.lifetype.net
Thu Mar 13 07:49:49 EDT 2008


Author: mark
Date: 2008-03-13 07:49:49 -0400 (Thu, 13 Mar 2008)
New Revision: 6217

Modified:
   plog/trunk/class/action/admin/admindeleteblogcategoryaction.class.php
   plog/trunk/templates/admin/blogcategories_table.template
Log:
deleteBlogCategory ajax-lize, too

Modified: plog/trunk/class/action/admin/admindeleteblogcategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeleteblogcategoryaction.class.php	2008-03-13 11:35:57 UTC (rev 6216)
+++ plog/trunk/class/action/admin/admindeleteblogcategoryaction.class.php	2008-03-13 11:49:49 UTC (rev 6217)
@@ -42,6 +42,15 @@
 		 */
 		function _deleteBlogCategories()
 		{
+			// prepare the parameters.. If there's only one category id, then add it to
+			// an array.
+			if( $this->_mode == "deleteBlogCategory" ) {
+				$this->_categoryIds = Array();
+				$this->_categoryIds[] = $this->_request->getValue( "categoryId" );
+			}
+			else
+				$this->_categoryIds = $this->_request->getValue( "categoryIds" );
+
             $categories = new BlogCategories();
 			
 			$errorMessage = "";
@@ -89,19 +98,11 @@
 				}
         	}
 			
-			// prepare the view and all the information it needs to know
-			$this->_view = new AdminBlogCategoriesListView( $this->_blogInfo );
-			if( $errorMessage != "" ) 
-				$this->_view->setErrorMessage( $errorMessage );
-			if( $successMessage != "" ) {
-				// and clear the cache to avoid outdated information
-				CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );			
-				$this->_view->setSuccessMessage( $successMessage );
-			}
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
 				
-			$this->setCommonData();
-			
-			return true;
+            // better to return true if everything fine
+            return( Array( "errorMessage" => $errorMessage, "successMessage" => $successMessage ));
 		}
 
         /**
@@ -109,16 +110,29 @@
          */
         function perform()
         {
-			// prepare the parameters.. If there's only one category id, then add it to
-			// an array.
-			if( $this->_mode == "deleteBlogCategory" ) {
-				$this->_categoryIds = Array();
-				$this->_categoryIds[] = $this->_request->getValue( "categoryId" );
-			}
-			else
-				$this->_categoryIds = $this->_request->getValue( "categoryIds" );
+			$results = $this->_deleteBlogCategories();
+
+            $this->_view = new AdminBlogCategoriesListView( $this->_blogInfo );
+            if( $results["errorMessage"] != "" ) $this->_view->setErrorMessage( $results["errorMessage"] );
+			if( $results["successMessage"] != "" ) $this->_view->setSuccessMessage( $results["successMessage"] );
+            $this->setCommonData();
 			
-            return $this->_deleteBlogCategories();
+            return true;
         }
+
+		/**
+		 * Ajax-specific behaviour
+		 */
+		function performAjax()
+		{
+			$results = $this->_deleteBlogCategories();
+
+            $this->_view = new AdminAjaxView( $this->_blogInfo );
+			$this->_view->setMessage( $results );
+			$this->_view->setSuccess( true );
+
+            // better to return true if everything fine
+            return true;			
+		}         
     }
 ?>

Modified: plog/trunk/templates/admin/blogcategories_table.template
===================================================================
--- plog/trunk/templates/admin/blogcategories_table.template	2008-03-13 11:35:57 UTC (rev 6216)
+++ plog/trunk/templates/admin/blogcategories_table.template	2008-03-13 11:49:49 UTC (rev 6217)
@@ -1,7 +1,7 @@
  <table id="categories" class="info" summary="{$locale->tr("editBlogCategories")}">
   <thead>
    <tr>
-    <th style="width:10px;"><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('editCategories');" /></th>
+    <th style="width:10px;"><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('editBlogCategories');" /></th>
     <th style="width:75%;">{$locale->tr("category")}</th>
     <th style="width:15%;">{$locale->tr("blogs")}</th>
     <th style="width:10%;">{$locale->tr("actions")}</th>



More information about the pLog-svn mailing list