[pLog-svn] r2454 - in plog/trunk: class/action/admin class/controller class/dao class/net/http class/plugin class/view class/view/admin templates/admin

oscar at devel.plogworld.net oscar at devel.plogworld.net
Thu Sep 8 19:59:09 GMT 2005


Author: oscar
Date: 2005-09-08 19:59:08 +0000 (Thu, 08 Sep 2005)
New Revision: 2454

Added:
   plog/trunk/class/action/admin/adminaddglobalarticlecategoryaction.class.php
   plog/trunk/class/action/admin/admindeleteglobalarticlecategoryaction.class.php
   plog/trunk/class/action/admin/admineditglobalarticlecategoriesaction.class.php
   plog/trunk/class/action/admin/admineditglobalarticlecategoryaction.class.php
   plog/trunk/class/action/admin/adminglobalarticlecategorieslistview.class.php
   plog/trunk/class/action/admin/adminnewglobalarticlecategoryaction.class.php
   plog/trunk/class/action/admin/adminupdateglobalarticlecategoryaction.class.php
   plog/trunk/class/dao/globalarticlecategories.class.php
   plog/trunk/class/dao/globalarticlecategory.class.php
   plog/trunk/class/view/admin/adminglobalarticlecategorieslistview.class.php
   plog/trunk/class/view/admin/adminnewglobalarticlecategoryview.class.php
   plog/trunk/templates/admin/editglobalarticlecategory.template
   plog/trunk/templates/admin/globalarticlecategories.template
   plog/trunk/templates/admin/newglobalarticlecategory.template
Modified:
   plog/trunk/class/action/admin/adminaddpostaction.class.php
   plog/trunk/class/action/admin/adminpostmanagementcommonaction.class.php
   plog/trunk/class/controller/admincontrollermap.properties.php
   plog/trunk/class/dao/article.class.php
   plog/trunk/class/dao/articles.class.php
   plog/trunk/class/net/http/httpvars.class.php
   plog/trunk/class/plugin/eventlist.properties.php
   plog/trunk/class/view/admin/admineditpostview.class.php
   plog/trunk/class/view/admin/adminnewpostview.class.php
   plog/trunk/class/view/admin/admintemplatedview.class.php
   plog/trunk/class/view/view.class.php
   plog/trunk/templates/admin/editpost.template
   plog/trunk/templates/admin/menus.xml
   plog/trunk/templates/admin/newpost.template
Log:
finally merged nick's patch for global article categories. I've made a few changes to the original patch,
mostly because of the caching stuff in 1.1 and also because even though I thought we agreed that one 
global article category per blog was more than enough, nick still implemented this feature
with multiple global categories per post. In my opinion that wasn't necessary and the relation is now
1:1.
Global categories can be added and removed, but updating them won't probably work too well.


Added: plog/trunk/class/action/admin/adminaddglobalarticlecategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddglobalarticlecategoryaction.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/adminaddglobalarticlecategoryaction.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,87 @@
+<?php
+
+ 	  /**
+       * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
+       * version 1.0 
+       * Changed from original article category.
+       */
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminglobalarticlecategorieslistview.class.php" );
+
+    /**
+     * \ingroup Action
+     * @private
+     *
+     * Action that adds a new article category to the database.
+     */
+    class AdminAddGlobalArticleCategoryAction extends SiteAdminAction 
+	{
+
+    	var $_categoryName;
+		var $_categoryDescription;
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminAddGlobalArticleCategoryAction( $actionInfo, $request )
+        {
+        		$this->SiteAdminAction( $actionInfo, $request );
+			
+			    // register two validators
+				$this->registerFieldValidator( "categoryName", new StringValidator());
+				$this->registerFieldValidator( "categoryDescription", new StringValidator());
+				// and the view we should show in case there is a validation error
+				$errorView = new AdminTemplatedView( $this->_blogInfo, "newglobalarticlecategory" );
+				$errorView->setErrorMessage( $this->_locale->tr("error_adding_global_article_category" ));			
+				$this->setValidationErrorView( $errorView );
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+			// fetch the data, we already know it's valid and that we can trust it!
+        	$this->_categoryName     = $this->_request->getValue( "categoryName" );
+         	$this->_categoryDescription = $this->_request->getValue( "categoryDescription" );
+		
+			// create the object...
+            $categories = new GlobalArticleCategories();
+            $category   = new GlobalArticleCategory( $this->_categoryName,
+                                              	     $this->_categoryDescription );
+											   
+			// fire the pre event...
+			$this->notifyEvent( EVENT_PRE_GLOBAL_CATEGORY_ADD, Array( "category" => &$category ));
+
+            // once we have built the object, we can add it to the database!
+             if( $categories->addGlobalArticleCategory( $category )) {
+				// if everything went fine, transfer the execution flow to the action that
+				// lists all the article categories... without forgetting that we should let the
+				// next class know that we actually added a category alongside a message
+				// and the category that we just added!
+				$this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
+				$this->_view->setSuccess( true );
+				$this->_view->setSuccessMessage( $this->_locale->pr("global_category_added_ok", $category->getName()));
+				
+				// fire the post event
+				$this->notifyEvent( EVENT_POST_GLOBAL_CATEGORY_ADD, Array( "category" => &$category ));
+				
+				$this->setCommonData();				
+            }
+            else {
+				// if there was an error, we should say so... as well as not changing the view since
+				// we're going back to the original view where we can add the category
+				$this->_view->setError( true );
+				$this->_view->setErrorMessage( $this->_locale->tr("error_adding_global_article_category" ));
+				$this->setCommonData( true );
+            }
+
+            // better to return true if everything fine
+            return true;
+        }
+    }
+?>
\ No newline at end of file

Modified: plog/trunk/class/action/admin/adminaddpostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddpostaction.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/adminaddpostaction.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -28,6 +28,7 @@
         	$this->registerFieldValidator( "postText", new StringValidator());
         	$this->registerFieldValidator( "postTopic", new StringValidator());
         	$this->registerFieldValidator( "postCategories", new ArrayValidator());
+        	$this->registerFieldValidator( "globalArticleCategoryId", new IntegerValidator(), true );
         	$view = new AdminNewPostView( $this->_blogInfo );
         	$view->setErrorMessage( $this->_locale->tr("error_adding_post"));
         	$this->setValidationErrorView( $view );
@@ -58,7 +59,7 @@
 			
 			$articles = new Articles();
 			$article->setFields( $this->_getArticleCustomFields());			
-			print_r($article->_customFields);
+			//print_r($article->_customFields);
 			
 			// notifiy about this event
 			$this->notifyEvent( EVENT_PRE_POST_ADD, Array( "article" => &$article ));				
@@ -113,6 +114,7 @@
 			// set also the date before it's too late
 			$article->setDateObject( $this->_postTimestamp );
 			$article->setCommentsEnabled( $this->_commentsEnabled );
+			$article->setGlobalCategoryId( $this->_globalArticleCategoryId );
 		
 			// save the article to the db
 			$artId = $this->_savePostData( $article );

Added: plog/trunk/class/action/admin/admindeleteglobalarticlecategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeleteglobalarticlecategoryaction.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/admindeleteglobalarticlecategoryaction.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,114 @@
+<?php
+	  /**
+       * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
+       * version 1.0 
+       * Changed from original article category.
+       */
+	include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminglobalarticlecategorieslistview.class.php" );
+
+    /**
+     * \ingroup Action
+     * @private
+     *
+     * Deletes an article category from the database
+     */
+    class AdminDeleteGlobalArticleCategoryAction extends SiteAdminAction 
+	{
+
+    	var $_categoryId;
+        var $_categoryIds;
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminDeleteGlobalArticleCategoryAction( $actionInfo, $request )
+        {
+        	$this->SiteAdminAction( $actionInfo, $request );
+			$this->_mode = $actionInfo->getActionParamValue();
+        	
+        	// get the array that contains the categories we'd like to delete
+			if( $this->_mode == "deleteGlobalArticleCategory" ) 
+					$this->registerFieldValidator( "categoryId", new IntegerValidator());
+			else 
+					$this->registerFieldValidator( "categoryIds", new ArrayValidator());
+				
+			$view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
+			$view->setErrorMessage( $this->_locale->tr("error_incorrect_global_category_id"));
+			$this->setValidationErrorView( $view );		
+        }
+
+		/**
+		 * @private
+		 * removes categories from the database
+		 */
+		function _deleteGlobalArticleCategories()
+		{
+            $categories = new GlobalArticleCategories();
+			
+			$errorMessage = "";
+			$successMessage = "";
+			$totalOk = 0;
+			
+            foreach( $this->_categoryIds as $categoryId ) {
+            	// get the category
+            	$this->notifyEvent( EVENT_PRE_GLOBAL_CATEGORY_DELETE, Array( "category" => &$category ));
+                $category   = $categories->getGlobalArticleCategory( $categoryId );
+						if( $category ) {
+									// if everything correct, we can proceed and delete it
+						if( !$categories->deleteGlobalArticleCategory( $categoryId))
+							$errorMessage .= $this->_locale->pr("error_deleting_global_category")."<br/>";
+						else {
+							if( $totalOk < 2 )
+								$successMessage .= $this->_locale->pr("global_category_deleted_ok", $category->getName())."<br/>";
+							else
+								$successMessage = $this->_locale->pr( "global_categories_deleted_ok", $totalOk );
+								
+							// fire the pre-event
+							$this->notifyEvent( EVENT_POST_CATEGORY_DELETE, Array( "category" => &$category ));
+				
+					}
+				}
+				else {
+					$errorMessage .= $this->_locale->pr("error_deleting_global_category2", $categoryId)."<br/>";
+					}
+        }
+			
+			// prepare the view and all the information it needs to know
+			$this->_view = new AdminGlobalArticleCategoriesListView( $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 );
+			}
+				
+			$this->setCommonData();
+			
+			return true;
+		}
+
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+			// prepare the parameters.. If there's only one category id, then add it to
+			// an array.
+			if( $this->_mode == "deleteGlobalArticleCategory" ) {
+				$this->_categoryIds = Array();
+				$this->_categoryIds[] = $this->_request->getValue( "categoryId" );
+			}
+			else
+				$this->_categoryIds = $this->_request->getValue( "categoryIds" );
+			
+            return $this->_deleteGlobalArticleCategories();
+        }
+    }
+?>

Added: plog/trunk/class/action/admin/admineditglobalarticlecategoriesaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditglobalarticlecategoriesaction.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/admineditglobalarticlecategoriesaction.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,41 @@
+<?php
+	  /**
+       * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
+       * version 1.0 
+       * Changed from original article category.
+       */
+	  include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+      include_once( PLOG_CLASS_PATH."class/view/admin/adminglobalarticlecategorieslistview.class.php" );
+
+    /**
+     * \ingroup Action
+     * @private
+     *
+     * Action that shows a form to add a link for the blogroll feature
+     */
+    class AdminEditGlobalArticleCategoriesAction extends SiteAdminAction 
+	{
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminEditGlobalArticleCategoriesAction( $actionInfo, $request )
+        {
+        	$this->SiteAdminAction( $actionInfo, $request );
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+        	// create the view, which will take care of fetching the right data
+        	$this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
+            $this->setCommonData();
+
+            // better to return true if everything fine
+            return true;
+        }
+    }
+?>

Added: plog/trunk/class/action/admin/admineditglobalarticlecategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditglobalarticlecategoryaction.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/admineditglobalarticlecategoryaction.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,75 @@
+<?php
+	  /**
+       * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
+       * version 1.0 
+       * Changed from original article category.
+       */
+
+		include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+        include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+        include_once( PLOG_CLASS_PATH."class/view/admin/adminGlobalarticlecategorieslistview.class.php" );
+        include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+		include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+		include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+		include_once( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" );
+
+    /**
+     * \ingroup Action
+     * @private
+     *
+     * Action that shows a form to change the settings of the article category
+     */
+    class AdminEditGlobalArticleCategoryAction extends SiteAdminAction 
+	{
+
+    	var $_categoryId;
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminEditGlobalArticleCategoryAction( $actionInfo, $request )
+        {
+        	$this->SiteAdminAction( $actionInfo, $request );
+			
+			// stuff for the data validation
+			$this->registerFieldValidator( "categoryId", new IntegerValidator());
+			$this->_form->registerField( "categoryName" );
+			$this->_form->registerField( "categoryDescription" );
+			$errorView = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
+			$errorView->setErrorMessage( $this->_locale->tr("error_incorrect_category_id"));
+			$this->setValidationErrorView( $errorView );
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+        	// fetch the category
+			$this->_categoryId = $this->_request->getValue( "categoryId" );
+            $categories = new GlobalArticleCategories();
+            $category   = $categories->getCategory( $this->_categoryId);
+            // show an error if we couldn't fetch the category
+            if( !$category ) {
+            	$this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_category") );
+				$this->_view->setError( true );
+                $this->setCommonData();
+                return false;
+            }
+			
+			$this->notifyEvent( EVENT_CATEGORY_LOADED, Array( "category" => &$category ));			
+            // otherwise show the form to edit its fields
+        	$this->_view = new AdminTemplatedView( $this->_blogInfo, "globalsettings_editarticlecategory" );
+            $this->_view->setValue( "category", $category );
+			$this->_view->setValue( "categoryName", $category->getName());
+			$this->_view->setValue( "categoryDescription", $category->getDescription());
+			$this->_view->setValue( "categoryId", $category->getId());
+            $this->setCommonData();
+
+            // better to return true if everything fine
+           return true;
+        }
+    }
+?>

Added: plog/trunk/class/action/admin/adminglobalarticlecategorieslistview.class.php
===================================================================
--- plog/trunk/class/action/admin/adminglobalarticlecategorieslistview.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/adminglobalarticlecategorieslistview.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,65 @@
+<?php
+
+      /**
+       * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
+       * version 1.0 
+       * Changed from original article category.
+       */
+
+	include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+	
+    /**
+     * \ingroup View
+     * @private
+     *
+     * Action that shows a form to add a link for the blogroll feature
+     */
+    class AdminGlobalArticleCategoriesListView extends AdminTemplatedView 
+	{
+		var $_page;
+
+    	  /**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminGlobalArticleCategoriesListView( $blogInfo, $page = 1 )
+        {
+        	$this->AdminTemplatedView( $blogInfo, "globalsettings_articlecategories" );			
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function render()
+        {
+			// prepare a few parameters
+            $categories = new GlobalArticleCategories();
+			
+			// get the page too
+			$this->_page = $this->getCurrentPageFromRequest();			
+			
+			// retrieve the categories in an paged fashion
+			$totalCategories = 	$categories->getNumCategories();
+						
+            $globalCategories = $categories->getAllCategories();
+			
+			if( !$globalCategories ) {
+				$globalCategories = Array();
+			}
+			
+			// throw the even in case somebody's waiting for it!
+			$this->notifyEvent( EVENT_CATEGORIES_LOADED, Array( "categories" => &$globalCategories ));
+            $this->setValue( "categories", $globalCategories );
+			
+			// the pager that will be used
+			$pager = new Pager( "?op=editGlobalArticleCategories&amp;page=",
+			                    $this->_page,
+								$totalCategories,
+								DEFAULT_ITEMS_PER_PAGE );
+								$this->setValue( "pager", $pager );			
+			parent::render();
+        }
+    }
+?>

Added: plog/trunk/class/action/admin/adminnewglobalarticlecategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminnewglobalarticlecategoryaction.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/adminnewglobalarticlecategoryaction.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,40 @@
+<?php
+      /**
+       * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
+       * version 1.0 
+       * Changed from original article category.
+       */
+     
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+
+    /**
+     * \ingroup Action
+     * @private
+     *
+     * Action that adds a new category for the articles to the database
+     */
+    class AdminNewGlobalArticleCategoryAction extends SiteAdminAction 
+    {
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminNewGlobalArticleCategoryAction( $actionInfo, $request )
+        {
+        	$this->SiteAdminAction( $actionInfo, $request );
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+        	// initialize the view
+          $this->_view = new AdminTemplatedView( $this->_blogInfo, "newglobalarticlecategory" );
+          $this->setCommonData();
+        }
+    }
+?>
\ No newline at end of file

Modified: plog/trunk/class/action/admin/adminpostmanagementcommonaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminpostmanagementcommonaction.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/adminpostmanagementcommonaction.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -29,6 +29,7 @@
         var $_previewPost;
         var $_addPost;
         var $_commentsEnabled;
+        var $_globalCategoryId;
         // stuff about the date
         var $_postYear;
         var $_postMonth;
@@ -130,6 +131,7 @@
 			$this->_sendPings = $this->_request->getValue( "sendPings" );			
             $this->_postId       = $this->_request->getValue( "postId" );
             $this->_commentsEnabled = $this->_request->getValue( "commentsEnabled" );
+            $this->_globalArticleCategoryId = $this->_request->getValue( "globalArticleCategoryId" );
 				
 			// fetch the custom fields
 			$this->_customFields = $this->_request->getValue( "customField" );	

Added: plog/trunk/class/action/admin/adminupdateglobalarticlecategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateglobalarticlecategoryaction.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/action/admin/adminupdateglobalarticlecategoryaction.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,103 @@
+<?php
+	  /**
+       * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
+       * version 1.0 
+       * Changed from original article category.
+       */
+	include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminglobalarticlecategorieslistview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
+    /**
+     * \ingroup Action
+     * @private
+     *
+     * Updates an article category.
+     */
+    class AdminUpdateGlobalArticleCategoryAction extends SiteAdminAction 
+	{
+
+    	var $_categoryName;
+        var $_categoryUrl;
+        var $_categoryId;
+		var $_categoryDescription;     
+		var $_properties;
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminUpdateGlobalArticleCategoryAction( $actionInfo, $request )
+        {
+        	$this->SiteAdminAction( $actionInfo, $request );
+			
+			// data validation settings
+			$this->registerFieldValidator( "categoryName", new StringValidator());
+			$this->registerFieldValidator( "categoryId", new IntegerValidator());
+			$this->registerFieldValidator( "categoryDescription", new StringValidator());
+			$errorView = new AdminTemplatedView( $this->_blogInfo, "globalsettings_editarticlecategory" );
+			$errorView->setErrorMessage( $this->_locale->tr("error_updating_article_category" ));
+			$this->setValidationErrorView( $errorView );
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+			// get the data from the form
+        	$this->_categoryName = $this->_request->getValue( "categoryName" );
+            $this->_categoryId   = $this->_request->getValue( "categoryId" );
+			$this->_categoryDescription = $this->_request->getValue( "categoryDescription" );
+        	$this->_properties = Array();		
+		
+        	// fetch the category we're trying to update
+            $categories = new GlobalArticleCategories();
+            $category   = $categories->getCategory( $this->_categoryId );
+            if( !$category ) {
+            	$this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_category"));
+                $this->setCommonData();
+
+                return false;
+            }
+			
+			// fire the pre-event
+			$this->notifyEvent( EVENT_PRE_CATEGORY_UPDATE, Array( "category" => &$category ));			
+
+            // update the fields
+            $category->setName( $this->_categoryName );
+            $category->setUrl( "" );
+         
+			$category->setProperties( $this->_properties );
+			$category->setDescription( $this->_categoryDescription );
+			
+			// this is view we're going to use to show our messages
+			$this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );			
+			
+            if( !$categories->updateCategory( $category )) {
+                $this->_view->setErrorMessage( $this->_locale->tr("error_updating_article_category"));
+            }
+			else {
+				// if everything fine, load the list of categories
+				$this->_view->setSuccessMessage( $this->_locale->pr("article_category_updated_ok", $category->getName()));
+				
+				// fire the post-event
+				$this->notifyEvent( EVENT_POST_CATEGORY_UPDATE, Array( "category" => &$category ));			
+				
+				// clear the cache
+				CacheControl::resetBlogCache( $this->_blogInfo->getId());			
+			}
+			
+			$this->setCommonData();			
+			
+            // better to return true if everything fine
+            return true;
+        }
+    }
+?>

Modified: plog/trunk/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/trunk/class/controller/admincontrollermap.properties.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/controller/admincontrollermap.properties.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -261,4 +261,17 @@
 	$actions["editBlogCategories"] = "AdminBlogCategoriesAction";	
 	$actions["deleteBlogCategory"] = "AdminDeleteBlogCategoryAction";
 	$actions["deleteBlogCategories"] = "AdminDeleteBlogCategoryAction";
+	//nick add this to add global article categories.
+	$actions["newGlobalArticleCategory"] = "AdminNewGlobalArticleCategoryAction";
+  	// adds the category to the db
+  	$actions["addGlobalArticleCategory"] = "AdminAddGlobalArticleCategoryAction";	
+	//edit globalarticle categories.
+	$actions["editGlobalArticleCategories"] = "AdminEditGlobalArticleCategoriesAction";
+  	// deletes an article category from the database
+  	$actions["deleteGlobalArticleCategory"] = "AdminDeleteGlobalArticleCategoryAction";
+  	$actions["deleteGlobalArticleCategories"] = "AdminDeleteGlobalArticleCategoryAction";
+  	// edits an article category
+  	$actions["editGlobalArticleCategory"] = "AdminEditGlobalArticleCategoryAction";
+  	// updates the category
+  	$actions["updateGlobalArticleCategory"] = "AdminUpdateGlobalArticleCategoryAction";	
 ?>

Modified: plog/trunk/class/dao/article.class.php
===================================================================
--- plog/trunk/class/dao/article.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/dao/article.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -99,6 +99,7 @@
 			$this->_trackbacks = null;
 			$this->_userInfo = null;
 			$this->_blogInfo = null;
+			$this->_globalCategoryId = 0;
 
 			$this->_pk = "id";
 			$this->_fields = Array(
@@ -113,7 +114,8 @@
 			    "num_comments" => "getTotalComments",
 			    "num_trackbacks" => "getTotalTrackbacks",
 			    "num_nonspam_trackbacks" => "getNumTrackbacks",
-			    "num_nonspam_comments" => "getNumComments"
+			    "num_nonspam_comments" => "getNumComments",
+			    "global_category_id" => "getGlobalCategoryId"
 			);
 		}
 
@@ -972,5 +974,55 @@
 
 			return( $resources );
 		}
+		
+		/**
+		 * returns the article global category id
+		 *
+		 * @return the global category id
+		 */
+		function getGlobalCategoryId()
+		{
+			return( $this->_globalCategoryId );
+		}
+		
+		/**
+		 * sets the global category id
+		 *
+		 * @param id the new category id
+		 */
+		function setGlobalCategoryId( $id )
+		{
+			if( $id != $this->_globalCategoryId )
+				$this->_globalCategory = null;
+				
+			$this->_globalCategoryId = $id;
+		}
+		
+		/**
+		 * @return Returns a GlobalArticleCategory object, or null if this article
+		 * has not been assigned a global category
+		 */
+		function getGlobalCategory()
+		{
+			if( $this->_globalCategory == null ) {
+				include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+				$globalCategories = new GlobalArticleCategories();
+				$this->_globalCategory = $globalCategories->getCategory( $this->_globalCategoryId );
+			}
+			
+			return( $this->_globalCategory );
+		}
+		
+		/**
+		 * sets a new global category
+		 *
+		 * @param category A valid GlobalArticleCategory object
+		 */
+		function setGlobalCategory( $category ) 
+		{
+			$this->_globalCategory = $category;
+			$this->_globalCategoryId = $category->getId();
+			return( true );
+		}		 
 	}
-?>
+?>
\ No newline at end of file

Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/dao/articles.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -1060,6 +1060,9 @@
 			$article->setNumComments( $query_result['num_nonspam_comments'] );
 			$article->setNumTrackbacks( $query_result['num_nonspam_trackbacks'] );
 			$article->setTotalTrackbacks( $query_result['num_trackbacks'] );
+			
+			// global article category
+			$article->setGlobalCategoryId( $query_result['global_category_id'] );
 
             return $article;
 

Added: plog/trunk/class/dao/globalarticlecategories.class.php
===================================================================
--- plog/trunk/class/dao/globalarticlecategories.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/dao/globalarticlecategories.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,141 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
+	include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategory.class.php" );
+	
+	define( "CACHE_GLOBALCATEGORIES", "cache_global_categories" );
+	define( "CACHE_GLOBALCATEGORIES_ALL", "cache_global_categories_all" );	
+	
+	class GlobalArticleCategories extends Model
+	{
+	
+		function GlobalArticleCategories()
+		{
+			$this->Model();			
+			$this->table = $this->getPrefix()."global_articles_categories";
+		}
+		
+		/**
+		 * loads the given blog category
+		 *
+		 * @param id
+		 * @return false if there was an error loading or a BlogCategory object if it was found
+		 */
+		function getGlobalArticleCategory( $id )
+		{
+			return( $this->get( "id", $id, CACHE_GLOBALCATEGORIES ));
+		}
+		
+		/**
+		 * adds a new global article category
+		 *
+		 * @param category A GlobalArticleCategory object
+		 * @return true if successful or false otherwise. Upon success, $category->getId() will
+		 * return the new id assigned to the object in the db.
+		 */
+		function addGlobalArticleCategory( &$category )
+		{
+			if( ($result = $this->add( $category, Array( CACHE_GLOBALCATEGORIES => "getId" )))) {
+				$this->_cache->removeData( "all", CACHE_GLOBALCATEGORIES_ALL );
+			}
+				
+			return( $result );
+		}
+		
+		/**
+		 * deletes a blog category. Warning: the upper layers must have already made sure that there
+		 * are no blogs that point to this blog categories *before* removing it, or else we could have
+		 * problems with data integrity.		 
+		 *
+		 * @param id
+		 * @return True if successful, false otherwise
+		 */
+		function deleteGlobalArticleCategory( $id )
+		{
+			if( ($result = $this->delete( "id", $id ))) {
+				$this->_cache->removeData( $id, CACHE_GLOBALCATEGORIES );
+				$this->_cache->removeData( "all", CACHE_GLOBALCATEGORIES_ALL );
+			}
+			
+			return( $result );
+		}
+		
+		/**
+		 * update a given global article category
+		 *
+		 * @param category A GlobalArticleCategory object
+		 * @return True if successful or false otherwise
+		 */
+		function updateGlobalArticleCategory( $category )
+		{
+			if(( $result = $this->update( $category ))) {
+				$this->_cache->removeData( $category->getId(), CACHE_GLOBALCATEGORIES );
+				$this->_cache->removeData( "all", CACHE_GLOBALCATEGORIES_ALL );
+			}
+			
+			return( $result );
+		}
+		
+		/**
+		 * returns the total amount of global article categories in the database
+		 *
+		 * @return an integer
+		 */
+		function getNumGlobalArticleCategories()
+		{
+			return( $this->getNumItems( $this->table ));
+		}
+		
+		/**
+		 * returns all blog categories
+		 *
+		 * @param page
+		 * @param itemsPerPage
+		 * @return An array of BlogCategory objects or false in case of error
+		 */
+		function getGlobalArticleCategories( $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+		{
+			$categories = $this->getAll( "all", CACHE_GLOBALCATEGORIES_ALL, 
+			                             Array( CACHE_GLOBALCATEGORIES => "getId" ),
+			                             $page,
+			                             $itemsPerPage );
+	                             
+			if( !$categories )
+				return( Array());
+			                             			                             
+			return( $categories );
+		}
+		
+		/**
+		 * returns how many blogs have been categorized under this category
+		 *
+		 * @param categoryId
+		 * @param status
+		 * @return an integer
+		 */
+		function getNumArticlesGlobalCategory( $categoryId, $status = ARTICLE_STATUS_ALL )
+		{
+			$cond = "a.global_category_id = '".Db::qstr( $categoryId )."'";			
+			if( $status != BLOG_STATUS_ALL )
+				$cond .= " AND status = '".Db::qstr( $status )."'";
+			
+			return( $this->getNumItems( $this->getPrefix()."articles", $cond ));
+			          
+		}
+		
+		/**
+		 * @private
+		 */
+		function mapRow( $row )
+		{
+			$category = new GlobalArticleCategory( $row["name"],
+			                              $row["description"],
+							    		  unserialize($row["properties"]),
+								    	  $row["id"] );
+			$category->setNumArticles( $row["num_articles"] );
+			$category->setNumActiveArticles( $row["num_active_articles"] );
+				
+			return( $category );
+		}
+	}
+?>
\ No newline at end of file

Added: plog/trunk/class/dao/globalarticlecategory.class.php
===================================================================
--- plog/trunk/class/dao/globalarticlecategory.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/dao/globalarticlecategory.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,150 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
+	include_once( PLOG_CLASS_PATH."class/dao/articlestatus.class.php" );
+
+    /**
+	 * \ingroup DAO
+	 *
+     * Represents a global blog category
+     */
+	class GlobalArticleCategory extends DbObject 
+	{
+	
+		var $_id;
+		var $_name;
+		var $_description;
+		var $_properties;
+
+		function GlobalArticleCategory( $name, $description = "", $properties = Array(), $id = -1 )
+		{
+			$this->DbObject();
+		
+			$this->_id = $id;
+			$this->_name = $name;
+			$this->_description = $description;
+			$this->_properties = $properties;
+			$this->_numArticles = 0;
+			$this->_numActiveArticles = 0;
+			$this->_mangledName;
+			
+			$this->_pk = "id";
+			$this->_fields = Array( "id" => "getId",
+			                        "name" => "getName",
+			                        "description" => "getDescription",
+			                        "properties" => "getProperties",
+			                        "num_articles" => "getNumArticles",
+			                        "num_active_articles" => "getNumActiveArticles",
+			                        "mangled_name" => "getMangledName" );
+		}
+
+        /**
+         * @private
+         */
+		function setId( $newId )
+		{
+			$this->_id = $newId;
+		}
+
+        /**
+         * @private
+         */
+		function setName( $newName )
+		{
+			$this->_name = $newName;
+		}
+				
+		/**
+		 * sets the description
+		 *
+		 * @param description
+		 */
+		function setDescription( $desc )
+		{
+			$this->_description = $desc;
+		}
+
+        /**
+         * Returns the identifier assigned to this category.
+         *
+         * @return An integer value with the category number.
+         */
+		function getId()
+		{
+			return $this->_id;
+		}
+
+        /**
+         * Returns the name assigned to the category.
+         *
+         * @return A string value with the name assigned to the category.
+         */
+		function getName()
+		{
+			return $this->_name;
+		}
+
+        /**
+         * Returns how many articles have been categorized under this category.
+         *
+		 * @param status A valid post status
+         * @return An integer value
+         */
+        function getNumArticles( $status = ARTICLE_STATUS_ACTIVE )        
+        {
+        	if( $status == ARTICLE_STATUS_ALL )
+        		return( $this->_numArticles );
+        	elseif( $status == ARTICLE_STATUS_ACTIVE )
+        		return( $this->_numActiveArticles );
+        	else {
+	        	include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );        	
+    	    	$categories = new GlobalArticleCategories();
+        		return( $categories->getNumArticlesCategory( $this->getId(), $status ));
+        	}
+        }
+        
+        function setNumArticles( $numArticles )
+        {
+        	$this->_numArticles = $numArticles;
+        }
+        
+        function getNumActiveArticles()
+        {
+        	return( $this->_numActiveArticles );
+        }
+        
+        function setNumActiveArticles( $numActiveArticles )
+        {
+        	$this->_numActiveArticles = $numActiveArticles;
+        }
+		
+		/**
+		 * returns the description
+		 *
+		 * @return The description
+		 */
+		function getDescription()
+		{
+			return $this->_description;
+		}
+		
+		/**
+		 * @private
+		 * For future use
+		 */
+		function getProperties()
+		{
+			return( $this->_properties );
+		}	
+		
+		function getMangledName()
+		{
+			if( $this->_mangledName == "" ) {
+				include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+				$this->_mangledName = Textfilter::urlize( $this->_mangledName );
+			}
+			
+			return( $this->_mangledName );
+		}
+	}
+?>
\ No newline at end of file

Modified: plog/trunk/class/net/http/httpvars.class.php
===================================================================
--- plog/trunk/class/net/http/httpvars.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/net/http/httpvars.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -272,16 +272,10 @@
             } else {
                 $protocol = 'https://';
             }
-            //$host      = $serverVars["HTTP_HOST"];
-            $host = $serverVars["SERVER_NAME"];
+            $host      = $serverVars["HTTP_HOST"];
             $scriptUrl = $serverVars["PHP_SELF"];
-            $port = $serverVars["SERVER_PORT"];
-            if( $port == 80 || $post == 443 )
-				$baseUrl = $protocol . $host . $scriptUrl;
-			else
-				$baseUrl = $protocol . $host . ":" . $port . $scriptUrl;
-				
-            return( $baseUrl );
+
+            return $protocol . $host . $scriptUrl;
         }
     }
 ?>

Modified: plog/trunk/class/plugin/eventlist.properties.php
===================================================================
--- plog/trunk/class/plugin/eventlist.properties.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/plugin/eventlist.properties.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -164,4 +164,12 @@
 	define( "EVENT_PRE_DELETE_BLOG_CATEGORY", 116 );
 	define( "EVENT_POST_UPDATE_BLOG_CATEGORY", 117 );
 	define( "EVENT_BLOG_CATEGORIES_LOADED", 118 );
+	// global article categories
+	define( "EVENT_PRE_ADD_GLOBAL_CATEGORY", 119 );
+	define( "EVENT_POST_ADD_GLOBAL_CATEGORY", 120 );
+	define( "EVENT_PRE_UPDATE_GLOBAL_CATEGORY", 121 );
+	define( "EVENT_POST_UPDATE_GLOBAL_CATEGORY", 122 );
+	define( "EVENT_PRE_DELETE_GLOBAL_CATEGORY", 123 );
+	define( "EVENT_POST_UPDATE_GLOBAL_CATEGORY", 124 );
+	define( "EVENT_GLOBAL_CATEGORIES_LOADED", 125 );	
 ?>
\ No newline at end of file

Modified: plog/trunk/class/view/admin/admineditpostview.class.php
===================================================================
--- plog/trunk/class/view/admin/admineditpostview.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/view/admin/admineditpostview.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -65,7 +65,6 @@
 	            // 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();
-	            print_r($customFieldValues);
 	            $customField = Array();
 	            foreach( $customFieldValues as $fieldValue )
 	            	$customField[$fieldValue->getFieldId()] = $fieldValue->getValue();
@@ -78,10 +77,11 @@
 	            $this->setValue( "postDay", $postDate->getDay());
 	            $this->setValue( "postHour", $postDate->getHour());
 	            $this->setValue( "postMinutes", $postDate->getMinutes());
+	            $this->setValue( "globalArticleCategoryId", $this->_article->getGlobalCategoryId());
         	}
                         
             // let our parent class do the rest...
             parent::render();
 		}
 	}
-?>
+?>
\ No newline at end of file

Added: plog/trunk/class/view/admin/adminglobalarticlecategorieslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminglobalarticlecategorieslistview.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/view/admin/adminglobalarticlecategorieslistview.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,64 @@
+<?php
+
+      /**
+       * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
+       * version 1.0 
+       * Changed from original article category.
+       */
+
+	include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+	
+    /**
+     * \ingroup View
+     * @private
+     *
+     * Action that shows a form to add a link for the blogroll feature
+     */
+    class AdminGlobalArticleCategoriesListView extends AdminTemplatedView 
+	{
+		var $_page;
+
+    	  /**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminGlobalArticleCategoriesListView( $blogInfo, $page = 1 )
+        {
+        	$this->AdminTemplatedView( $blogInfo, "globalarticlecategories" );			
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function render()
+        {        
+			// prepare a few parameters
+            $categories = new GlobalArticleCategories();
+			
+			// get the page too
+			$this->_page = $this->getCurrentPageFromRequest();			
+			
+			// retrieve the categories in an paged fashion
+			$totalCategories = 	$categories->getNumGlobalArticleCategories();						
+            $globalCategories = $categories->getGlobalArticleCategories( $this->_page, DEFAULT_ITEMS_PER_PAGE );
+			
+			if( !$globalCategories ) {
+				$globalCategories = Array();
+			}					
+			
+			// throw the even in case somebody's waiting for it!
+			$this->notifyEvent( EVENT_GLOBAL_CATEGORIES_LOADED, Array( "categories" => &$globalCategories ));
+            $this->setValue( "categories", $globalCategories );			
+			
+			// the pager that will be used
+			$pager = new Pager( "?op=editGlobalArticleCategories&amp;page=",
+			                    $this->_page,
+								$totalCategories,
+								DEFAULT_ITEMS_PER_PAGE );
+								$this->setValue( "pager", $pager );								
+			parent::render();			
+        }
+    }
+?>

Added: plog/trunk/class/view/admin/adminnewglobalarticlecategoryview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminnewglobalarticlecategoryview.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/view/admin/adminnewglobalarticlecategoryview.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,22 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+
+    /**
+     * \ingroup View
+     * @private
+     *	
+	 * shows the view that will allow to edit an article
+	 */
+	class AdminNewGlobalArticleCategoryView extends AdminTemplatedView
+	{
+		
+		var $_article;
+	
+		function AdminNewGlobalArticleCategoryView( $blogInfo )
+		{
+			$this->AdminTemplatedView( $blogInfo, "newglobalarticlecategory" );
+		}
+	}
+?>
\ No newline at end of file

Modified: plog/trunk/class/view/admin/adminnewpostview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminnewpostview.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/view/admin/adminnewpostview.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -3,6 +3,7 @@
     include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );    
     include_once( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
     include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
@@ -28,21 +29,15 @@
             $blogSettings = $this->_blogInfo->getSettings();
             $categoriesOrder = $blogSettings->getValue( "categories_order" );
             $blogCategories = $categories->getBlogCategories( $this->_blogInfo->getId(), false, $categoriesOrder );
+            
+            // global article categories
+            $globalArticleCategories = new GlobalArticleCategories();
+            $globalCategories = $globalArticleCategories->getGlobalArticleCategories();
 
             // get some stuff for the time stamp of the post, which is changeable now
             //$t = new Timestamp();
             $t = Timestamp::getBlogDate( $this->_blogInfo );
-            //$t->toUTC();
-            //
-            // changes to make plog store its dates with the time difference already
-            // applied, instead of applying it dynamically
-            //
             $config =& Config::getConfig();
-            /*if( $config->getValue( "time_difference_calculation" == TIME_DIFFERENCE_CALCULATION_STATIC ) {
-                $blogSettings = $this->_blogInfo->getSettings();
-                $difference = $blogSettings->getValue( "time_offset" );
-                $t->setDate( Timestamp::getDateWithOffset( $t->getDate(), $difference ), DATE_FORMAT_TIMESTAMP );
-            }*/
 
             // fetch the custom fields, if any, but not including the ones that have been set to "hidden"...
             $customFields = new CustomFields();
@@ -52,6 +47,7 @@
             $locale = $this->_blogInfo->getLocale();
             $this->setValue( "commentsEnabled", $blogSettings->getValue( "comments_enabled" ));
             $this->setValue( "categories", $blogCategories );
+            $this->setValue( "globalcategories", $globalCategories );
             $this->setValue( "today", $t );
             $this->setValue( "months", $locale->getMonthNames());
             $this->setValue( "days", $locale->getDayNamesShort());

Modified: plog/trunk/class/view/admin/admintemplatedview.class.php
===================================================================
--- plog/trunk/class/view/admin/admintemplatedview.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/view/admin/admintemplatedview.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -37,7 +37,7 @@
 		
         	$template = $this->_templateService->AdminTemplate( $this->_templateName, $this->_blogInfo );
             // assign all the values
-            $template->assign( $this->_params->getAsArray());
+            $template->assign( $this->_params->getAsArray());           
 
             // and send the results
             print $template->fetch();

Modified: plog/trunk/class/view/view.class.php
===================================================================
--- plog/trunk/class/view/view.class.php	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/class/view/view.class.php	2005-09-08 19:59:08 UTC (rev 2454)
@@ -300,7 +300,7 @@
          * By default does nothing and it has no parameters
          */
         function render()
-        {
+        {        
 	        include_once( PLOG_CLASS_PATH."class/net/http/phpsniff/phpSniff.class.php" );
 
             // send the headers we've been assigned if any, alognside the conten-type header
@@ -315,7 +315,7 @@
                 // as long as we're part of a session, the client won't change :)
                 $this->setSessionValue( "phpSniff", serialize(new phpSniff()) );
             }
-            $this->setValue( "browser", unserialize($this->getSessionValue("phpSniff")) );
+            $this->setValue( "browser", unserialize($this->getSessionValue("phpSniff")) );            
         }
     }
 ?>

Added: plog/trunk/templates/admin/editglobalarticlecategory.template
===================================================================
--- plog/trunk/templates/admin/editglobalarticlecategory.template	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/templates/admin/editglobalarticlecategory.template	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,36 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=editGlobalArticleCategories title=$locale->tr("editGlobalArticleCategories")}
+
+ <form name="editGlobalArticleCategory" action="admin.php" method="post">
+
+  <fieldset class="inputField">
+   <legend>{$locale->tr("editGlobalArticleCategories")}</legend>
+   {include file="$admintemplatepath/formvalidate.template" message=$locale->tr("error_updating_article_category")}
+
+   <div class="field">
+    <label for="categoryName">{$locale->tr("name")}</label>
+    <span class="required">*</span>
+    <div class="formHelp"></div>
+    <input type="text" id="categoryName" name="categoryName" value="{$categoryName|escape:"html"}"/>
+    {include file="$admintemplatepath/validate.template" field=categoryName message=$locale->tr("error_empty_name")}
+   </div>
+
+   <div class="field">
+    <label for="categoryDescription">{$locale->tr("description")}</label>
+    <span class="required">*</span>
+    <div class="formHelp"></div>
+    <textarea name="categoryDescription" id="categoryDescription" cols="60" rows="5">{$categoryDescription}</textarea>
+    {include file="$admintemplatepath/validate.template" field=categoryDescription message=$locale->tr("error_empty_description")}
+  </div>
+   
+  </fieldset>
+  <div class="buttons">   
+    <input type="hidden" name="categoryUrl" value="" />
+    <input type="reset" name="reset" value="{$locale->tr("reset")}" />
+    <input type="submit" name="Update" value="{$locale->tr("update")}" />
+    <input type="hidden" name="op" value="updateGlobalArticleCategory" />
+    <input type="hidden" name="categoryId" value="{$categoryId}" />
+  </div>
+</form>
+
+{include file="$admintemplatepath/footer.template"}

Modified: plog/trunk/templates/admin/editpost.template
===================================================================
--- plog/trunk/templates/admin/editpost.template	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/templates/admin/editpost.template	2005-09-08 19:59:08 UTC (rev 2454)
@@ -1,3 +1,4 @@
+{$globalArticleCategoryId}
 {include file="$admintemplatepath/header.template"}
 {include file="$admintemplatepath/navigation.template" showOpt=editPosts title=$locale->tr("editPost")}
 <script type="text/javascript" src="js/calendar/datetimepicker.js"></script>
@@ -105,7 +106,20 @@
            {/foreach}
          </select>
         {include file="$admintemplatepath/validate.template" field=postCategories message=$locale->tr("error_no_categories")}	   
-	   </div>	   
+	   </div>
+	   
+      <div class="field">
+         <label for="globalArticleCategoryId">{$locale->tr("global_category")}</label>
+		 <span class="required">*</span>
+		 <div class="formHelp">{$locale->tr("global_article_category_help")}</div>
+	    <select name="globalArticleCategoryId" id="globalArticleCategoryId" size="1" style="width:100%">
+	       <option value="0">{$locale->tr("none")}</option>
+           {foreach from=$globalcategories item=globalcategory}
+           <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>   
 	      
        <div class="field_checkbox">
          <input class="checkbox" type="checkbox" id="commentsEnabled" name="commentsEnabled" value="1" {if $postCommentsEnabled} checked="checked" {/if}/>

Added: plog/trunk/templates/admin/globalarticlecategories.template
===================================================================
--- plog/trunk/templates/admin/globalarticlecategories.template	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/templates/admin/globalarticlecategories.template	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,68 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=editGlobalArticleCategories title=$locale->tr("editArticleCategories")}
+
+<div id="list_nav_bar">
+<div id="list_nav_select">
+            
+<form id="viewArticleCategories" action="admin.php" method="post">
+ <fieldset>
+  <legend>{$locale->tr("show_by")}</legend>
+   <div class="list_nav_option">
+   <label for="search">{$locale->tr("search_terms")}</label>
+   <br />
+   <input type="text" name="searchTerms" value="{$searchTerms}" size="15" id="search" />
+   </div>   
+   
+   <div class="list_nav_option">
+    <br />
+    <input type="hidden" name="op" value="editGlobalArticleCategories">
+    <input type="submit" name="Show" value="{$locale->tr("show")}">
+   </div>
+  </fieldset> 
+ </form> 
+ </div>
+ <br style="clear:both">
+ </div> 
+
+ <form id="deleteCategories" action="admin.php" method="post"
+ <div id="list">
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"}
+ <table class="info">
+  <thead>
+   <tr>
+    <th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('deleteCategories');" /></th>
+    <th style="width:375px;">{$locale->tr("category")}</th>  
+    <th style="width:95px;">{$locale->tr("actions")}</th>
+   </tr>
+  </thead>
+  <tbody> 
+  {foreach from=$categories item=category}
+  <tr class="{cycle values="odd, even"}">
+   <td>
+      <input class="checkbox" type="checkbox" name="categoryIds[{counter}]" id="checks_{$category->getId()}" value="{$category->getId()}" />
+   </td>  
+   <td class="col_highlighted">
+    <a href="admin.php?op=editGlobalArticleCategory&amp;categoryId={$category->getId()}">{$category->getName()}</a>
+   </td>   
+  
+   <td>
+     <div class="list_action_button">
+       <a href="?op=editGlobalArticleCategory&amp;categoryId={$category->getId()}"><img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" /></a>
+       <a href="?op=deleteGlobalArticleCategory&amp;categoryId={$category->getId()}"><img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" /></a>
+     </div>
+   </td>
+  </tr>
+  {/foreach}
+ </tbody> 
+ </table>
+ </div>
+ <div id="list_action_bar">
+  {include file="$admintemplatepath/adminpager.template" style=list}
+  <input type="hidden" name="op" value="deleteGlobalArticleCategories"/>
+  <input type="submit" name="Delete selected" value="{$locale->tr("delete")}"/>
+ </div>
+ </form>
+
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}

Modified: plog/trunk/templates/admin/menus.xml
===================================================================
--- plog/trunk/templates/admin/menus.xml	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/templates/admin/menus.xml	2005-09-08 19:59:08 UTC (rev 2454)
@@ -61,6 +61,10 @@
 			<newTemplate url="?op=newTemplate" siteAdmin="1" />
 			<siteTemplates url="?op=siteTemplates" siteAdmin="1" />		
 		</Templates>
+	    <manageGlobalArticleCategory ignoreBreadCrumbs="1">
+	    	<newGlobalArticleCategory url="?op=newGlobalArticleCategory" /> 	    
+ 		    <editGlobalArticleCategories url="?op=editGlobalArticleCategories" />
+		</manageGlobalArticleCategory>		
 		<GlobalSettings ignoreBreadCrumbs="1">
 			<editSiteSettings url="?op=editSiteSettings&amp;show=general" siteAdmin="1" />
 			<summarySettings url="?op=editSiteSettings&amp;show=summary" siteAdmin="1" />

Added: plog/trunk/templates/admin/newglobalarticlecategory.template
===================================================================
--- plog/trunk/templates/admin/newglobalarticlecategory.template	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/templates/admin/newglobalarticlecategory.template	2005-09-08 19:59:08 UTC (rev 2454)
@@ -0,0 +1,33 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=newGlobalArticleCategory title=$locale->tr("newGlobalArticleCategory")}
+
+ <form name="addGlobalCategory" method="post" action="admin.php">
+  <fieldset class="inputField">
+   <legend>{$locale->tr("newGlobalArticleCategory")}</legend>
+   {include file="$admintemplatepath/formvalidate.template" message=$locale->tr("error_adding_article_category")}   
+   
+   <div class="field">
+    <label for="categoryName">{$locale->tr("name")}</label>
+    <span class="required">*</span><br/>
+    <div class="formHelp">{$locale->tr("global_category_name_help")}</div>     
+     <input type="text" value="{$categoryName}" id="categoryName" name="categoryName" />
+    {include file="$admintemplatepath/validate.template" field=categoryName message=$locale->tr("error_empty_name")}
+   </div>
+   
+   <div class="field">
+    <label for="categoryDescription">{$locale->tr("description")}</label>
+    <span class="required">*</span>
+    <div class="formHelp">{$locale->tr("global_category_description_help")}</div> 
+    <textarea name="categoryDescription" cols="60" id="categoryDescription" rows="5">{$categoryDescription}</textarea>
+    {include file="$admintemplatepath/validate.template" field=categoryDescription message=$locale->tr("error_empty_description")}  
+   </div>  
+   
+  </fieldset>
+  <div class="buttons">
+   <input type="hidden" value="" name="categoryUrl" />
+   <input type="hidden" name="op" value="addGlobalArticleCategory" />
+   <input type="reset" name="Reset" value="{$locale->tr("reset")}" />
+   <input type="submit" name="Add" value="{$locale->tr("add")}" />
+  </div> 
+ </form>
+{include file="$admintemplatepath/footer.template"}

Modified: plog/trunk/templates/admin/newpost.template
===================================================================
--- plog/trunk/templates/admin/newpost.template	2005-09-08 19:11:07 UTC (rev 2453)
+++ plog/trunk/templates/admin/newpost.template	2005-09-08 19:59:08 UTC (rev 2454)
@@ -130,6 +130,19 @@
          </select>
         {include file="$admintemplatepath/validate.template" field=postCategories message=$locale->tr("error_no_category_selected")}	   
 	   </div>
+	   
+      <div class="field">
+         <label for="globalArticleCategoryId">{$locale->tr("global_category")}</label>
+		 <span class="required">*</span>
+		 <div class="formHelp">{$locale->tr("global_article_category_help")}</div>
+	    <select name="globalArticleCategoryId" id="globalArticleCategoryId" size="1" style="width:100%">
+	       <option value="0">{$locale->tr("none")}</option>
+           {foreach from=$globalcategories item=globalcategory}
+           <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>	   
    
        <div class="field_checkbox">
          <input class="checkbox" type="checkbox" id="commentsEnabled" name="commentsEnabled" value="1" {if $commentsEnabled} checked="checked" {/if}/>




More information about the pLog-svn mailing list