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

mark at devel.lifetype.net mark at devel.lifetype.net
Sat Nov 17 01:54:19 EST 2007


Author: mark
Date: 2007-11-17 01:54:19 -0500 (Sat, 17 Nov 2007)
New Revision: 6049

Modified:
   plog/trunk/class/action/admin/adminaddpostaction.class.php
   plog/trunk/class/action/admin/admineditpostaction.class.php
   plog/trunk/class/action/admin/adminupdatepostaction.class.php
   plog/trunk/class/view/admin/admineditpostview.class.php
   plog/trunk/js/ui/pages/posts.js
   plog/trunk/templates/admin/editpost.template
Log:
Now, updatePost and sendping, sendtrackback in updatePost works ..

I also refactor the code of addPost and updatePost, I believe the code looks better now.

Modified: plog/trunk/class/action/admin/adminaddpostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddpostaction.class.php	2007-11-16 07:42:45 UTC (rev 6048)
+++ plog/trunk/class/action/admin/adminaddpostaction.class.php	2007-11-17 06:54:19 UTC (rev 6049)
@@ -9,7 +9,7 @@
      */
     class AdminAddPostAction extends AdminPostManagementCommonAction
 	{
-		var $_article;
+        var $_message;
 
     	/**
          * Constructor. If nothing else, it also has to call the constructor of the parent
@@ -80,7 +80,7 @@
 			$article->setLocationId( $this->getLocationFromRequest());
 
 			// in case the post is already in the db
-			if( $this->_postId != "" ) {
+			if( !empty( $this->_postId) ) {
 				$article->setId( $this->_postId );
 				$artId = $this->_postId;
 				$postSavedOk = $articles->updateArticle( $article );
@@ -119,6 +119,7 @@
 									 0,
 									 Array(),
 									 $this->_postSlug );
+
 			// set also the date before it's too late
 			$article->setDateObject( $this->_postTimestamp );
 			$article->setCommentsEnabled( $this->_commentsEnabled );
@@ -127,30 +128,45 @@
 			// save the article to the db
 			$artId = $this->_savePostData( $article );
 
-			$message = "";
+            if( !$artId ) {
+                $this->_message = $this->_locale->tr("error_adding_post");
+                return false;
+            }
 
-			if( $artId ) {
-                // train the filter, but only if enabled
-				if( $this->_config->getValue( "bayesian_filter_enabled" ) == true ) {
-	                BayesianFilterCore::trainWithArticle( $article );
-				}
+            // train the filter, but only if enabled
+			if( $this->_config->getValue( "bayesian_filter_enabled" ) == true ) {
+	            BayesianFilterCore::trainWithArticle( $article );
+			}
 
-        		// add the article notification if requested to do so
-            	if( $this->_sendNotification ) {
-                	$artNotifications = new ArticleNotifications();
-	            	$artNotifications->addNotification( $artId, $this->_blogInfo->getId(), $this->_userInfo->getId());
-                    $message .= " ".$this->_locale->tr("send_notifications_ok");
-        	    }
+			$this->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));
 
-				$this->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));
+			// empty the cache used by this blog
+			CacheControl::resetBlogCache( $this->_blogInfo->getId());
 
-				// empty the cache used by this blog
-				CacheControl::resetBlogCache( $this->_blogInfo->getId());
-			}
+			$this->_message = $this->_locale->tr("post_added_ok");
 
+        	// add the article notification if requested to do so
+            if( $this->_sendNotification ) {
+            	$artNotifications = new ArticleNotifications();
+	        	$artNotifications->addNotification( $artId, $this->_blogInfo->getId(), $this->_userInfo->getId());
+                $this->_message .= "<br/>".$this->_locale->tr("send_notifications_ok");
+        	}
+
 			return( $article );
 		}
 
+        function clearAutoSaveCookie()
+        {
+        	$rg = $this->_blogInfo->getBlogRequestGenerator();
+        	$plogBaseUrl = $rg->getBaseUrl(false);
+        	$cookieBaseName = "LT" . preg_replace("/[^a-zA-Z0-9]/", "", $plogBaseUrl).$this->_blogInfo->getId();
+
+        	// set the auto save cookie as false
+	    	setcookie( $cookieBaseName.'postNotSaved', '0', -1, '/' );
+	    	setcookie( $cookieBaseName.'postTopic', '', -1, '/' );
+	    	setcookie( $cookieBaseName.'postText', '', -1, '/' );
+        }
+
         /**
          * Carries out the specified action
          */
@@ -164,108 +180,92 @@
 			else
 				$view = "AdminPostsListView";
 
-        	// once we have built the object, we can add it to the database
-			$message = "";
-        	if( $article ) {
-	            // clear autosave cookie
-	            $this->clearAutoSaveCookie();
+        	$this->_view = new $view( $this->_blogInfo );
 
-                $this->_view = new $view( $this->_blogInfo );
-            	//$article->setId( $artId );
-                $message = $this->_locale->tr("post_added_ok");
+            if( !$article )
+            {
+            	$this->_view->setErrorMessage( $this->_message );
+            	$this->setCommonData();
 
-                // we only have to send trackback pings if the article was published
-                // otherwise there is no need to...
-				//$article->setId( $artId );
-                if( $article->getStatus() == POST_STATUS_PUBLISHED) {
-                	// get the output from the xmlrpc pings but only if the user decided to do so!
+            	return true;
+            }
 
-					if( $this->_sendPings) {
-                        $t = new Timestamp();
-                        $today = $t->getTimestamp();
-                        if($today > $article->getDate()){
-                            $pingsOutput = $this->sendXmlRpcPings();
-                            $message .= "<br/><br/>".$pingsOutput;
-                        }
-					}
+	        // clear autosave cookie
+	        $this->clearAutoSaveCookie();
 
-                    // and now check what to do with the trackbacks
-                    if( $this->_sendTrackbacks ) {
-                    	// get the links from the text of the post
-        				$postLinks = StringUtils::getLinks( $article->getText());
+            // we only have to send trackback pings if the article was published
+            // otherwise there is no need to...
+            if( $article->getStatus() == POST_STATUS_PUBLISHED) {
+                // get the output from the xmlrpc pings but only if the user decided to do so!
 
-        				// if no links, there is nothing to do
-        				if( count($postLinks) == 0 ) {
-        					$this->_view = new $view( $this->_blogInfo );
-			                $this->_view->setErrorMessage( $this->_locale->tr("error_no_trackback_links_sent"));
-        				}
-        				else {
-                           	$this->_view = new AdminNewSendTrackbacksView( $this->_blogInfo );
-                            $this->_view->setValue( "post", $article);
-                            $this->_view->setValue( "postLinks", $postLinks );
-         				}
+				if( $this->_sendPings) {
+                    $t = new Timestamp();
+                    $today = $t->getTimestamp();
+                    if($today > $article->getDate()){
+                        $pingsOutput = $this->sendXmlRpcPings();
+                        $this->_message .= "<br/>".$pingsOutput;
                     }
-                    $this->_view->setSuccessMessage( $message );
                 }
-                else {
-                	$this->_view = new $view( $this->_blogInfo );
-                    $this->_view->setSuccessMessage( $this->_locale->tr("post_added_not_published") );
 
-					$this->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));
+                // and now check what to do with the trackbacks
+                if( $this->_sendTrackbacks ) {
+                	// get the links from the text of the post
+        		    $postLinks = StringUtils::getLinks( $article->getText());
+
+        			// if no links, there is nothing to do
+        			if( count($postLinks) == 0 ) {
+			            $this->_view->setErrorMessage( $this->_locale->tr("error_no_trackback_links_sent"));
+        			}
+        			else {
+                       	$this->_view = new AdminNewSendTrackbacksView( $this->_blogInfo );
+                        $this->_view->setValue( "post", $article);
+                        $this->_view->setValue( "postLinks", $postLinks );
+         			}
                 }
-        	}
-        	else {
-        		$this->_view = new $view( $this->_blogInfo );
-            	$this->_view->setErrorMessage( $this->_locale->tr("error_adding_post") );
-        	}
+            }
+            else {
+                $this->_message .= "<br/>".$this->_locale->tr("post_added_not_published");
+            }
 
+            $this->_view->setSuccessMessage( $this->_message );
             $this->setCommonData();
 
             // better to return true if everything fine
             return true;
         }
 
-        function clearAutoSaveCookie()
-        {
-        	$rg = $this->_blogInfo->getBlogRequestGenerator();
-        	$plogBaseUrl = $rg->getBaseUrl(false);
-        	$cookieBaseName = "LT" . preg_replace("/[^a-zA-Z0-9]/", "", $plogBaseUrl).$this->_blogInfo->getId();
-
-        	// set the auto save cookie as false
-	    	setcookie( $cookieBaseName.'postNotSaved', '0', -1, '/' );
-	    	setcookie( $cookieBaseName.'postTopic', '', -1, '/' );
-	    	setcookie( $cookieBaseName.'postText', '', -1, '/' );
-        }
-
 		function performAjax()
 		{
+            $article = $this->saveArticle();
+
 			$this->_view = new AdminAjaxView( $this->_blogInfo );
 
-			if(( $article = $this->saveArticle())) {
-				if( $article->getStatus() == POST_STATUS_PUBLISHED ) {
-					$message = $this->_locale->tr( "post_added_ok" );
-					if( $this->_sendPings) {
-                        $t = new Timestamp();
-                        $today = $t->getTimestamp();
-                        if($today > $article->getDate()){
-                            $pingsOutput = $this->sendXmlRpcPings();
-                            $message .= "<br/><br/>".$pingsOutput;
-                        }
-					}
+            if( !$article ) {
+				$this->_view->setErrorMessage( $this->_message );
+
+				return true;
+            }
+
+			if( $article->getStatus() == POST_STATUS_PUBLISHED ) {
+				if( $this->_sendPings) {
+                    $t = new Timestamp();
+                    $today = $t->getTimestamp();
+                    if($today > $article->getDate()){
+                        $pingsOutput = $this->sendXmlRpcPings();
+                        $this->_message .= "<br/>".$pingsOutput;
+                    }
 				}
-				else {
-					$message = $this->_locale->tr( "post_added_not_published" );
-				}
-				$this->_view->setSuccessMessage( $message );
-				$this->_view->setResult( $article );
 			}
 			else {
-				$this->_view->setErrorMessage( $this->_locale->tr("error_adding_post" ));
+				$this->_message .= "<br/>".$this->_locale->tr( "post_added_not_published" );
 			}
 
 			$this->clearAutoSaveCookie();
 
-			return( true );
+			$this->_view->setSuccessMessage( $this->_message );
+			$this->_view->setResult( $article );
+
+			return true;
 		}
     }
 ?>
\ No newline at end of file

Modified: plog/trunk/class/action/admin/admineditpostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditpostaction.class.php	2007-11-16 07:42:45 UTC (rev 6048)
+++ plog/trunk/class/action/admin/admineditpostaction.class.php	2007-11-17 06:54:19 UTC (rev 6049)
@@ -1,11 +1,4 @@
 <?php
-
-	
-    
-    
-    
-    
-
     /**
      * \ingroup Action
      * @private
@@ -24,7 +17,7 @@
         function AdminEditPostAction( $actionInfo, $request )
         {
         	$this->AdminAction( $actionInfo, $request );
-        	
+
         	// data validation
         	$this->registerFieldValidator( "postId", new IntegerValidator());
         	// if we don't register the fields below, the view will complain that they are
@@ -38,15 +31,15 @@
 
 			$this->requirePermission( "update_post" );
         }
-        
+
         /**
          * Carries out the specified action
          */
         function perform()
         {
 	        // fetch the post id that has already been validated
-	     	$this->_postId = $this->_request->getValue( "postId" );   
-	        
+	     	$this->_postId = $this->_request->getValue( "postId" );
+
         	// fetch the post from the database
             $posts = new Articles();
             $post  = $posts->getBlogArticle( $this->_postId, $this->_blogInfo->getId(), false );
@@ -69,17 +62,15 @@
 	                $this->_view->setErrorMessage( $this->_locale->tr("error_can_only_view_own_articles" ));
 	                $this->setCommonData();
 
-	                return false;		            
+	                return false;
 	            }
             }
 
-            
-    		
             // throw the event
-			$this->notifyEvent( EVENT_POST_LOADED, Array( "article" => &$post, "from" => "editPost" ));			
+			$this->notifyEvent( EVENT_POST_LOADED, Array( "article" => &$post, "from" => "editPost" ));
 
 			// and create the view where we will edit the post
-			$this->_view = new AdminEditPostView( $this->_blogInfo );			
+			$this->_view = new AdminEditPostView( $this->_blogInfo );
 			$this->_view->setArticle( $post );
 			$this->_view->setUserInfo( $this->_userInfo );
             $this->setCommonData();

Modified: plog/trunk/class/action/admin/adminupdatepostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdatepostaction.class.php	2007-11-16 07:42:45 UTC (rev 6048)
+++ plog/trunk/class/action/admin/adminupdatepostaction.class.php	2007-11-17 06:54:19 UTC (rev 6049)
@@ -1,5 +1,4 @@
 <?php
-
 	lt_include( PLOG_CLASS_PATH."class/dao/articlestatus.class.php" );
 
     /**
@@ -7,11 +6,10 @@
      * @private
      *
      * Updates the values of the post in the database
-	 *
-	 * Btw, this class could very well need some refactoring... :)
      */
     class AdminUpdatePostAction extends AdminPostManagementCommonAction
 	{
+        var $_message;
 
     	/**
          * Constructor. If nothing else, it also has to call the constructor of the parent
@@ -57,10 +55,7 @@
 			$this->requirePermission( "update_post" );
         }
 
-        /**
-         * Carries out the specified action
-         */
-        function perform()
+        function updateArticle()
         {
 	        // fetch the data
             $this->_fetchCommonData();
@@ -69,12 +64,10 @@
             // fetch the old post
             $articles =  new Articles();
             $post     = $articles->getBlogArticle( $this->_postId, $this->_blogInfo->getId());
+
             // there must be something wrong if we can't fetch the post that we are trying to update...
             if( !$post ) {
-				$this->_view = new AdminPostsListView( $this->_blogInfo );
-				$this->_view->setErrorMessage( $this->_locale->tr("error_fetching_article"));
-                $this->setCommonData();
-
+				$this->_message = $this->_locale->tr("error_fetching_article");
                 return false;
             }
 
@@ -83,10 +76,7 @@
             // user match
             if( !$this->userHasPermission( "update_all_user_articles" )) {
 	            if( $post->getUserId() != $this->_userInfo->getId()) {
-	            	$this->_view = new AdminPostsListView( $this->_blogInfo );
-	                $this->_view->setErrorMessage( $this->_locale->tr("error_can_only_update_own_articles" ));
-	                $this->setCommonData();
-
+	            	$this->_message = $this->_locale->tr("error_can_only_update_own_articles" );
 	                return false;
 	            }
             }
@@ -127,21 +117,17 @@
 
         	// and finally save the post to the database
         	if( !$articles->updateArticle( $post )) {
-				$this->_view = new AdminPostsListView( $this->_blogInfo );
-				$this->_view->setErrorMessage( $this->_locale->tr("error_updating_post"));
-            	$this->setCommonData();
-
+				$this->_message = $this->_locale->tr("error_updating_post");
             	return false;
-
         	}
 
+			// and fire the post event
+			$this->notifyEvent( EVENT_POST_POST_UPDATE, Array( "article" => &$post ));
+
 			// clean up the cache
 			CacheControl::resetBlogCache( $this->_blogInfo->getId());
 
-        	// create the definitive view
-        	$this->_view = new AdminPostsListView( $this->_blogInfo );
-        	// show a message saying that the post was updated
-        	$message = $this->_locale->pr("post_updated_ok", $post->getTopic());
+        	$this->_message = $this->_locale->pr("post_updated_ok", $post->getTopic());
 
         	// check if there was a previous notification
         	$notifications = new ArticleNotifications();
@@ -151,7 +137,7 @@
         		if( !$artNotification ) {
             		// if there wasn't one and now we want it, we have to add it
                 	$notifications->addNotification( $this->_postId, $this->_blogInfo->getId(), $this->_userInfo->getId());
-                	$message .= " ".$this->_locale->tr("notification_added");
+                	$this->_message .= "<br/>".$this->_locale->tr("notification_added");
             	}
         	}
         	else {
@@ -159,74 +145,108 @@
             	// should remove it
             	if( $artNotification ) {
             		$notifications->deleteNotification( $this->_postId, $this->_blogInfo->getId(), $this->_userInfo->getId());
-                	$message .= " ".$this->_locale->tr("notification_removed");
+                	$this->_message .= "<br/>".$this->_locale->tr("notification_removed");
             	}
         	}
 
-                // only send trackbacks and xmlrpc pings
-                // when a post is "published"
-			if( $post->getStatus() == POST_STATUS_PUBLISHED ) {
-				// get the links from the text of the post
-                $postLinks = StringUtils::getLinks($post->getText());
+        	return $post;
+        }
 
-                // get the real trackback links from trackbackUrls
-                $trackbackLinks = Array();
-                foreach(explode( "\r\n", $this->_trackbackUrls ) as $host ) {
-                	trim($host);
-                	if( $host != "" && $host != "\r\n" &&
-                        $host != "\r" && $host != "\n" )
-                    {
-                    	array_push( $trackbackLinks, $host );
-                    }
-                }
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+            $post = $this->updateArticle();
 
-                    // if the "send xmlrpc pings" checkbox was enabled,
-                    // do something about it...
+			// depending on the permission that the user has, we'll show one view or another
+			if( !$this->userHasPermission( "view_posts" ))
+				$view = "AdminEditPostView";
+			else
+				$view = "AdminPostsListView";
+
+            $this->_view = new $view( $this->_blogInfo );
+
+            if( !$post )
+            {
+                $this->_view->setErrorMessage( $this->_message );
+                $this->setCommonData();
+
+                return true;
+            }
+
+            // only send trackbacks and xmlrpc pings
+            // when a post is "published"
+			if( $post->getStatus() == POST_STATUS_PUBLISHED ) {
+                // if the "send xmlrpc pings" checkbox was enabled,
+                // do something about it...
                 if( $this->_sendPings ) {
                     $t = new Timestamp();
                     $today = $t->getTimestamp();
                     if($today > $post->getDate()){
-                        $message .= "<br/><br/>".$this->sendXmlRpcPings();
+                        $pingsOutput = $this->sendXmlRpcPings();
+                        $this->_message .= "<br/>".$pingsOutput;
                     }
 				}
-                    // and now check what to do with the trackbacks
+
+                // and now check what to do with the trackbacks
                 if( $this->_sendTrackbacks ) {
-                        // if no links, there is nothing to do
-                    if( count($postLinks) == 0 &&
-                        count($trackbackLinks) == 0 )
+    				// get the links from the text of the post
+                    $postLinks = StringUtils::getLinks($post->getText());
+
+                    // if no links, there is nothing to do
+                    if( count($postLinks) == 0 )
                     {
-                        $this->_view = new AdminPostsListView(
-                            $this->_blogInfo );
-                        $this->_view->setErrorMessage(
-                            $this->_locale->tr(
-                                "error_no_trackback_links_sent"));
+                        $this->_view->setErrorMessage( $this->_locale->tr("error_no_trackback_links_sent") );
                     }
                     else {
-                        $this->_view = new AdminTemplatedView(
-                            $this->_blogInfo, "sendtrackbacks" );
-                            // get the links from the text of the post
-                        $this->_view->setValue( "post", $post );
+                        $this->_view = new AdminNewSendTrackbacksView( $this->_blogInfo );
+                        $this->_view->setValue( "post", $post);
                         $this->_view->setValue( "postLinks", $postLinks );
-                        $this->_view->setValue( "trackbackLinks",
-                                                $trackbackLinks );
                     }
                 }
             }
+            else {
+                $this->_message .= "<br/>".$this->_locale->tr("post_added_not_published");
+            }
 
-        	// show the message
-        	$this->_view->setSuccessMessage( $message );
-
-			// and fire the post event
-			$this->notifyEvent( EVENT_POST_POST_UPDATE, Array( "article" => &$post ));
-
+            $this->_view->setSuccessMessage( $this->_message );
             $this->setCommonData();
 
+            // better to return true if everything fine
             return true;
         }
 
 		function performAjax()
 		{
+            $post = $this->updateArticle();
 
+			$this->_view = new AdminAjaxView( $this->_blogInfo );
+
+            if( !$post ) {
+				$this->_view->setErrorMessage( $this->_message );
+
+				return true;
+            }
+
+			if( $post->getStatus() == POST_STATUS_PUBLISHED ) {
+				if( $this->_sendPings) {
+                    $t = new Timestamp();
+                    $today = $t->getTimestamp();
+                    if($today > $post->getDate()){
+                        $pingsOutput = $this->sendXmlRpcPings();
+                        $this->_message .= "<br/>".$pingsOutput;
+                    }
+				}
+			}
+			else {
+				$this->_message .= "<br/>".$this->_locale->tr( "post_updated_not_published" );
+			}
+
+			$this->_view->setSuccessMessage( $this->_message );
+			$this->_view->setResult( $post );
+
+			return true;
 		}
     }
 ?>
\ No newline at end of file

Modified: plog/trunk/class/view/admin/admineditpostview.class.php
===================================================================
--- plog/trunk/class/view/admin/admineditpostview.class.php	2007-11-16 07:42:45 UTC (rev 6048)
+++ plog/trunk/class/view/admin/admineditpostview.class.php	2007-11-17 06:54:19 UTC (rev 6049)
@@ -1,30 +1,26 @@
 <?php
-
-	
-	
-	
     /**
      * \ingroup View
      * @private
-     *	
+     *
 	 * shows the view that will allow to edit an article
 	 */
 	class AdminEditPostView extends AdminNewPostView
 	{
-		
+
 		var $_article;
-	
+
 		function AdminEditPostView( $blogInfo )
 		{
 			$this->AdminTemplatedView( $blogInfo, "editpost" );
-			
+
 			// by default, we have no article
 			$this->_article = null;
 		}
-		
+
 		/**
 		 * passes an article to the view
-		 * 
+		 *
 		 * @param article
 		 * @return nothing
 		 */
@@ -33,21 +29,21 @@
 			$this->_article = $article;
 			$this->setValue( "post", $article );
 		}
-		
+
 		function render()
 		{
             // check if there is a notification for the article set up by this user
             if( $this->_article ) {
 	            $notifications = new ArticleNotifications();
 	            $userNotification = $notifications->getUserArticleNotification( $this->_article->getId(), $this->_blogInfo->getId(), $this->_userInfo->getId());
-	            
+
 	            // decide wether or not we should notify the user based on what we've just
 	            // fetched from the database
 	            if( $userNotification )
 	            	$this->setValue( "sendNotification", true );
 	            else
-	            	$this->setValue( "sendNotification", false );            
-	            
+	            	$this->setValue( "sendNotification", false );
+
 	            // set information about the post itself into the view
 	            $this->setValue( "postTopic", $this->_article->getTopic());
                 $this->setValue( "postText", str_replace('&', '&amp;', $this->_article->getText( false )));
@@ -61,7 +57,7 @@
 	            $this->setValue( "postCommentsEnabled", $commentsEnabled );
 	            $this->setValue( "postCategories", $this->_article->getCategoryIds());
 	            $this->setValue( "postStatus", $this->_article->getStatus());
-	            
+
 	            // we need to play a bit with the values of the fields, as the editpost.template page is
 	            // expecting them in a bit different way than if we just do an $article->getFields()
 	            $customFieldValues = $this->_article->getCustomFields();
@@ -69,7 +65,7 @@
 	            foreach( $customFieldValues as $fieldValue )
 	            	$customField[$fieldValue->getFieldId()] = $fieldValue->getValue();
 	            $this->setValue( "customField", $customField );
-	            
+
 	            // related to the date
 	            $postDate = $this->_article->getDateObject();
 	            $this->setValue( "postYear", $postDate->getYear());
@@ -78,7 +74,7 @@
 	            $this->setValue( "postHour", $postDate->getHour());
 	            $this->setValue( "postMinutes", $postDate->getMinutes());
 	            $this->setValue( "globalArticleCategoryId", $this->_article->getGlobalCategoryId());
-	
+
 				$config =& Config::getConfig();
 				if( $config->getValue( "location_data_enabled", false )) {
 					if( $this->_article->hasLocationData()) {
@@ -89,7 +85,7 @@
 					}
 				}
         	}
-                        
+
             // let our parent class do the rest...
             parent::render();
 		}

Modified: plog/trunk/js/ui/pages/posts.js
===================================================================
--- plog/trunk/js/ui/pages/posts.js	2007-11-16 07:42:45 UTC (rev 6048)
+++ plog/trunk/js/ui/pages/posts.js	2007-11-17 06:54:19 UTC (rev 6049)
@@ -74,7 +74,10 @@
 			}
 		}
 
-		Lifetype.Forms.AjaxFormProcessor(form.id,'?output=json', { resetAfterSuccess: true } );
+        if( mode == 'addPost' )
+		    Lifetype.Forms.AjaxFormProcessor( form.id, '?output=json', { resetAfterSuccess: true } );
+		else
+		    Lifetype.Forms.AjaxFormProcessor( form.id, '?output=json', { resetAfterSuccess: false } );
 
 		return false;
 	}
@@ -248,14 +251,14 @@
 	// we only show the send trackbacks dialog from addPost form handler
 	// if the form handler is from 'sendTrackbacks', we don't need to create
 	// the send trackbacks again.
-	if( success && sendTrackbacks && fromHandler == 'addPost' )
+	if( success && sendTrackbacks && fromHandler == 'postEdit' )
 	{
         var admin_base_url = Lifetype.Config.getValue( 'admin_base_url' );
         Lifetype.UI.ContentOverlay.createAndShow( admin_base_url + "?op=newSendTrackbacks&postId=" + result.id );
 	}
 }
 
-Lifetype.Config.setValue( 'form_handler', 'addPost' );
+Lifetype.Config.setValue( 'form_handler', 'postEdit' );
 
 Lifetype.UI.Pages.Posts.sendTrackbackSubmitHook = function( form )
 {

Modified: plog/trunk/templates/admin/editpost.template
===================================================================
--- plog/trunk/templates/admin/editpost.template	2007-11-16 07:42:45 UTC (rev 6048)
+++ plog/trunk/templates/admin/editpost.template	2007-11-17 06:54:19 UTC (rev 6049)
@@ -17,29 +17,29 @@
   <script type="text/javascript" src="js/tinymce/tiny_mce-plog.js"></script>
  {else}
   <script type="text/javascript" src="js/editor/lifetypeeditor.js"></script>
- {/if} 
- <script type="text/javascript">  
+ {/if}
+ <script type="text/javascript">
   // this needs to be pre-initialized
   Lifetype.UI.Pages.Posts.preview = false;
  </script>
-  <form name="postEdit" id="postEdit" action="admin.php" method="post" onSubmit="this.target='admin';return Lifetype.UI.Pages.Posts.selectOperation(this,'updatePost');">   
+  <form name="postEdit" id="postEdit" action="admin.php" method="post" onSubmit="this.target='admin';Lifetype.Config.setValue( 'send_trackbacks', Lifetype.Dom.$('sendTrackbacks').checked );return Lifetype.UI.Pages.Posts.selectOperation(this,'updatePost');">
    <fieldset class="inputField">
    <legend>{$locale->tr("editPost")}</legend>
-   <div id="mainPanel" style="float:left; width: 73%; border-right: 1px solid #DEDEDE;">  
-     {include file="$admintemplatepath/formvalidate.template"}    
-	 
+   <div id="mainPanel" style="float:left; width: 73%; border-right: 1px solid #DEDEDE;">
+     {include file="$admintemplatepath/formvalidateajax.template"}
+
 	   <div class="field">
 	     <label for="postTopic">{$locale->tr("topic")}</label>
 		 <span class="required">*</span>
 		 <div class="formHelp">{$locale->tr("topic_help")}</div>
 	     <input type="text" id="postTopic" name="postTopic" style="width:100%" value="{$postTopic|escape:"html"}" />
-	     {include file="$admintemplatepath/validate.template" field=postTopic message=$locale->tr("error_missing_post_topic")}
+	     {include file="$admintemplatepath/validateajax.template" field=postTopic}
 	   </div>
-	   
+
 	   <!-- text field custom fields -->
-	   {include file="$admintemplatepath/newpost_customfields.template" type=1 fields=$customfields}	   
-	   
-	   
+	   {include file="$admintemplatepath/newpost_customfields.template" type=1 fields=$customfields}
+
+
 	   <div class="field">
 	     <label for="postText">{$locale->tr("text")}</label>
 		 <span class="required">*</span>
@@ -48,21 +48,21 @@
 	     <textarea {if $htmlarea==1}rows="20"{else}rows="15"{/if} id="postText" name="postText" style="width:100%">{$postText}</textarea>
 	     <a href="{if $htmlarea}javascript:tinyMCE.execInstanceCommand('mce_editor_0','mceinsertresource',true);{else}javascript:ed1.execute('postText','7_but_res',''){/if}">{$locale->tr("insert_media")}</a> |
              <a href="{if $htmlarea}javascript:tinyMCE.execInstanceCommand('mce_editor_0','mcemoremore');{else}javascript:ed1.execute('postText','8_but_more',''){/if}">{$locale->tr("insert_more")}</a>
-	     {include file="$admintemplatepath/validate.template" field=postText message=$locale->tr("error_missing_post_text")}   
+	     {include file="$admintemplatepath/validateajax.template" field=postText}
 	   </div>
-	   
+
 	   <!-- text area custom fields -->
       {include file="$admintemplatepath/newpost_customfields.template" type=2 fields=$customfields}
-   </div>	   
-   
-   <div id="optionPanel" style="float:left; width: 23%; margin-left: 8px;">   
-	 
+   </div>
+
+   <div id="optionPanel" style="float:left; width: 23%; margin-left: 8px;">
+
 	   <div class="field">
 	     <label for="postSlug">{$locale->tr("post_slug")}</label>
 		 <div class="formHelp">{$locale->tr("post_slug_help")}</div>
 	     <input type="text" name="postSlug" id="postSlug" style="width:100%" value="{$postSlug|escape:"html"}" />
 	   </div>
-	   
+
        <div class="field">
    	     <label for="postDateTime">{$locale->tr("date")}</label>
 		 <span class="required">*</span>
@@ -87,21 +87,21 @@
 	       });
 	   {/literal}
 	   </script>
-	   
+
 	   <!-- date custom fields -->
-	   {include file="$admintemplatepath/newpost_customfields.template" type=4 fields=$customfields}	   
+	   {include file="$admintemplatepath/newpost_customfields.template" type=4 fields=$customfields}
 
 	   <div class="field">
          <label for="postStatus">{$locale->tr("status")}</label>
-		 <span class="required">*</span>		 
+		 <span class="required">*</span>
 		 <div class="formHelp">{$locale->tr("post_status_help")}</div>
 		 <select name="postStatus" id="postStatus">
-		   {foreach from=$poststatus key=name item=status}
+		   {foreach from=$articlestatus key=name item=status}
 		   <option value="{$status}" {if $postStatus == $status} selected="selected"{/if}>{$locale->tr($name)}</option>
 		   {/foreach}
-         </select>	   
+         </select>
 	   </div>
-	
+
       {if $location_data_enabled}
       <!-- location selector, this should only appear if location data is enabled -->
       <div class="field">
@@ -110,22 +110,22 @@
 	    <div class="formHelp">{$locale->tr("article_location_help")}</div>
 	    {location_chooser blogId=$blog->getId() showAddNewLink=1 showDisplayLink=1 default=$location}
       </div>
-      {/if}	
-	
+      {/if}
+
 	  <!-- user field -->
 	  {check_perms perm=update_all_user_articles}
 	   <div class="field">
         <label for="postUser">{$locale->tr("posted_by")}</label>
-		 <span class="required">*</span>		 
+		 <span class="required">*</span>
 		 <div class="formHelp">{$locale->tr("posted_by_help")}</div>
 		 <select name="postUser" id="postUser">
 		   {foreach from=$blog->getUsersInfo() item=bloguser}
 			<option value="{$bloguser->getId()}" {if $postUser==$bloguser->getId()}selected="selected"{/if}>{$bloguser->getUserName()}</option>
 		   {/foreach}
-        </select>	   
+        </select>
 	   </div>
-	   {/check_perms}	
-	   
+	   {/check_perms}
+
 	   <div class="field">
          <label for="postCategories[]">{$locale->tr("categories")}</label>
 		 <span class="required">*</span>
@@ -137,9 +137,9 @@
          </select>
          <input type="text" name="newArticleCategory" id="newArticleCategory" style="width:100px; margin-top:3px;" size="16" value="" />
          <input type="button" name="addArticleCategory" id="addArticleCategory" style="width:35px; margin-top:3px;" value="{$locale->tr("add")}" onclick="Lifetype.UI.Pages.Posts.addArticleCategoryAjax()" />
-        {include file="$admintemplatepath/validate.template" field=postCategories message=$locale->tr("error_no_categories")}	   
+        {include file="$admintemplatepath/validateajax.template" field=postCategories}
 	   </div>
-	   
+
       <div class="field">
          <label for="globalArticleCategoryId">{$locale->tr("global_category")}</label>
 		 <span class="required">*</span>
@@ -150,45 +150,45 @@
            <option value="{$globalcategory->getId()}" {if $globalcategory->getId() == $globalArticleCategoryId} selected="selected" {/if}>{$globalcategory->getName()}</option>
            {/foreach}
          </select>
-        {include file="$admintemplatepath/validate.template" field=globalArticleCategoryId message=$locale->tr("error_no_global_article_category_selected")}	   
-       </div>   
+        {include file="$admintemplatepath/validateajax.template" field=globalArticleCategoryId}
+       </div>
 
 	   <!-- list custom fields -->
 	   {include file="$admintemplatepath/newpost_customfields.template" type=5 fields=$customfields}
-	      
+
        <div class="field_checkbox">
          <input class="checkbox" type="checkbox" id="commentsEnabled" name="commentsEnabled" value="1" {if $postCommentsEnabled} checked="checked" {/if}/>
 		 <label for="commentsEnabled">{$locale->tr("post_comments_enabled_help")}</label>
 	   </div>
-	   
+
        <div class="field_checkbox">
 	     <input class="checkbox" type="checkbox" id="sendNotification" name="sendNotification" value="1" {if $sendNotification} checked="checked" {/if}/>
 		 <label for="sendNotification">{$locale->tr("send_notification_help")}</label>
 	   </div>
-	   
+
        <div class="field_checkbox">
-	     <input class="checkbox" type="checkbox" id="sendTrackbacks" name="sendTrackbacks" value="1" {if $sendTrackbacks} checked="checked" {/if}/>  
+	     <input class="checkbox" type="checkbox" id="sendTrackbacks" name="sendTrackbacks" value="1" {if $sendTrackbacks} checked="checked" {/if}/>
 		 <label for="sendTrackbacks">{$locale->tr("send_trackback_pings_help")}</label>
 	   </div>
-	   
+
        {if $xmlRpcPingEnabled}
-  	    <div class="field_checkbox">	
+  	    <div class="field_checkbox">
 		 <input class="checkbox" type="checkbox" name="sendPings" id="sendPings" value="1" {if $sendPings} checked="checked" {/if}/>
 		 <label for="sendPings">{$locale->tr("send_xmlrpc_pings_help")}</label>
         </div>
        {/if}
-	  
+
   	  <!-- checkbox custom fields -->
-      {include file="$admintemplatepath/newpost_customfields.template" type=3 fields=$customfields}	  
+      {include file="$admintemplatepath/newpost_customfields.template" type=3 fields=$customfields}
 
 	</div>
 	</fieldset>
-	<div class="buttons">  
-      <input type="submit" name="previewPost" value="{$locale->tr("preview")}" onClick="Lifetype.UI.Pages.Posts.preview=true" />	
+	<div class="buttons">
+      <input type="submit" name="previewPost" value="{$locale->tr("preview")}" onClick="Lifetype.UI.Pages.Posts.preview=true" />
       <input type="submit" name="updatePost" value="{$locale->tr("update")}" onClick="Lifetype.UI.Pages.Posts.preview=false"/>
       <input type="hidden" name="op" value="updatePost"/>
       <input type="hidden" name="postId" id="postId" value="{$postId}"/>
-	</div>  	
+	</div>
   </form>
 {include file="$admintemplatepath/footernavigation.template"}
 {include file="$admintemplatepath/footer.template"}



More information about the pLog-svn mailing list