[pLog-svn] r3099 - in plog/trunk: class/action/admin
class/controller class/plugin templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Mar 22 22:16:40 GMT 2006
Author: oscar
Date: 2006-03-22 22:16:39 +0000 (Wed, 22 Mar 2006)
New Revision: 3099
Added:
plog/trunk/class/action/admin/admineditblogcategoryaction.class.php
plog/trunk/class/action/admin/adminupdateblogcategoryaction.class.php
plog/trunk/templates/admin/editblogcategory.template
Modified:
plog/trunk/class/action/admin/adminupdateglobalarticlecategoryaction.class.php
plog/trunk/class/controller/admincontrollermap.properties.php
plog/trunk/class/plugin/eventlist.properties.php
Log:
added support for editing blog categories, that had somehow been left out.
Added: plog/trunk/class/action/admin/admineditblogcategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditblogcategoryaction.class.php 2006-03-22 22:09:56 UTC (rev 3098)
+++ plog/trunk/class/action/admin/admineditblogcategoryaction.class.php 2006-03-22 22:16:39 UTC (rev 3099)
@@ -0,0 +1,68 @@
+<?php
+
+ 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/adminblogcategorieslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/blogcategories.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 AdminEditBlogCategoryAction 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());
+ $errorView = new AdminBlogCategoriesListView( $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 BlogCategories();
+ $category = $categories->getBlogCategory( $this->_categoryId);
+ // show an error if we couldn't fetch the category
+ if( !$category ) {
+ $this->_view = new AdminBlogCategoriesListView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_category") );
+ $this->_view->setError( true );
+ $this->setCommonData();
+ return false;
+ }
+
+ $this->notifyEvent( EVENT_BLOG_CATEGORY_LOADED, Array( "category" => &$category ));
+ // otherwise show the form to edit its fields
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "editblogcategory" );
+ $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/adminupdateblogcategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateblogcategoryaction.class.php 2006-03-22 22:09:56 UTC (rev 3098)
+++ plog/trunk/class/action/admin/adminupdateblogcategoryaction.class.php 2006-03-22 22:16:39 UTC (rev 3099)
@@ -0,0 +1,97 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/blogcategories.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/adminblogcategorieslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Updates an article category.
+ */
+ class AdminUpdateBlogCategoryAction 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 AdminUpdateBlogCategoryAction( $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, "editblogcategory" );
+ $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 BlogCategories();
+ $category = $categories->getBlogCategory( $this->_categoryId );
+ if( !$category ) {
+ $this->_view = new AdminBlogCategoriesListView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_category"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ // fire the pre-event
+ $this->notifyEvent( EVENT_PRE_UPDATE_BLOG_CATEGORY, Array( "category" => &$category ));
+
+ // update the fields
+ $category->setName( $this->_categoryName );
+ $category->setProperties( $this->_properties );
+ $category->setDescription( $this->_categoryDescription );
+
+ // this is view we're going to use to show our messages
+ $this->_view = new AdminBlogCategoriesListView( $this->_blogInfo );
+
+ if( !$categories->updateBlogCategory( $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_UPDATE_BLOG_CATEGORY, Array( "category" => &$category ));
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+ }
+
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/adminupdateglobalarticlecategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateglobalarticlecategoryaction.class.php 2006-03-22 22:09:56 UTC (rev 3098)
+++ plog/trunk/class/action/admin/adminupdateglobalarticlecategoryaction.class.php 2006-03-22 22:16:39 UTC (rev 3099)
@@ -40,7 +40,7 @@
$this->registerFieldValidator( "categoryName", new StringValidator());
$this->registerFieldValidator( "categoryId", new IntegerValidator());
$this->registerFieldValidator( "categoryDescription", new StringValidator());
- $errorView = new AdminTemplatedView( $this->_blogInfo, "editarticlecategory" );
+ $errorView = new AdminTemplatedView( $this->_blogInfo, "editglobalarticlecategory" );
$errorView->setErrorMessage( $this->_locale->tr("error_updating_article_category" ));
$this->setValidationErrorView( $errorView );
}
Modified: plog/trunk/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/trunk/class/controller/admincontrollermap.properties.php 2006-03-22 22:09:56 UTC (rev 3098)
+++ plog/trunk/class/controller/admincontrollermap.properties.php 2006-03-22 22:16:39 UTC (rev 3099)
@@ -290,5 +290,8 @@
// generic user chooser
$actions["siteUsersChooser"] = "AdminUserChooserAction";
// generic blog chooser
- $actions["siteBlogsChooser"] = "AdminBlogChooserAction";
+ $actions["siteBlogsChooser"] = "AdminBlogChooserAction";
+ // edit and update blog categories
+ $actions["editBlogCategory"] = "AdminEditBlogCategoryAction";
+ $actions["updateBlogCategory"] = "AdminUpdateBlogCategoryAction";
?>
Modified: plog/trunk/class/plugin/eventlist.properties.php
===================================================================
--- plog/trunk/class/plugin/eventlist.properties.php 2006-03-22 22:09:56 UTC (rev 3098)
+++ plog/trunk/class/plugin/eventlist.properties.php 2006-03-22 22:16:39 UTC (rev 3099)
@@ -167,6 +167,7 @@
define( "EVENT_PRE_DELETE_BLOG_CATEGORY", ++$eventValue );
define( "EVENT_POST_DELETE_BLOG_CATEGORY", ++$eventValue );
define( "EVENT_BLOG_CATEGORIES_LOADED", ++$eventValue );
+ define( "EVENT_BLOG_CATEGORY_LOADED", ++$eventValue );
// global article categories
define( "EVENT_PRE_ADD_GLOBAL_CATEGORY", ++$eventValue );
define( "EVENT_POST_ADD_GLOBAL_CATEGORY", ++$eventValue );
Added: plog/trunk/templates/admin/editblogcategory.template
===================================================================
--- plog/trunk/templates/admin/editblogcategory.template 2006-03-22 22:09:56 UTC (rev 3098)
+++ plog/trunk/templates/admin/editblogcategory.template 2006-03-22 22:16:39 UTC (rev 3099)
@@ -0,0 +1,36 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=editBlogCategories title=$locale->tr("editBlogCategories")}
+
+ <form name="editBlogCategory" action="admin.php" method="post">
+
+ <fieldset class="inputField">
+ <legend>{$locale->tr("editBlogCategories")}</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">{$locale->tr("category_name_help")}</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">{$locale->tr("category_description_help")}</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="reset" name="reset" value="{$locale->tr("reset")}" />
+ <input type="submit" name="Update" value="{$locale->tr("update")}" />
+ <input type="hidden" name="op" value="updateBlogCategory" />
+ <input type="hidden" name="categoryId" value="{$categoryId}" />
+ </div>
+</form>
+
+{include file="$blogtemplate/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list