[pLog-svn] r549 - in plog/trunk: class/action/admin
class/view/admin templates/admin
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sun Dec 19 17:10:17 GMT 2004
Author: oscar
Date: 2004-12-19 17:10:16 +0000 (Sun, 19 Dec 2004)
New Revision: 549
Added:
plog/trunk/class/view/admin/admineditresourcealbumview.class.php
Modified:
plog/trunk/class/action/admin/admineditresourcealbumaction.class.php
plog/trunk/class/action/admin/adminupdateresourcealbumaction.class.php
plog/trunk/templates/admin/editresourcealbum.template
Log:
the page that allows to edit a resource album has been ported to the new template
Modified: plog/trunk/class/action/admin/admineditresourcealbumaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditresourcealbumaction.class.php 2004-12-19 16:58:19 UTC (rev 548)
+++ plog/trunk/class/action/admin/admineditresourcealbumaction.class.php 2004-12-19 17:10:16 UTC (rev 549)
@@ -6,8 +6,9 @@
include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/admineditresourcealbumview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
/**
@@ -25,42 +26,35 @@
function AdminEditResourceAlbumAction( $actionInfo, $request )
{
$this->AdminAction( $actionInfo, $request );
+
+ $this->registerFieldValidator( "albumId", new IntegerValidator());
+ $view = new AdminResourcesListView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr("error_album_id_parameter_missing"));
+ $this->setValidationErrorView( $view );
}
- function validate()
- {
- $this->_albumId = $this->_request->getValue( "albumId" );
-
- if( $this->_albumId == "" || $this->_albumId == 0 ) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->tr("error_album_id_parameter_missing"));
- $this->setCommonData();
-
- return false;
- }
-
- return true;
- }
-
/**
* Carries out the specified action
*/
function perform()
{
// fetch the albums for this blog
+ $this->_albumId = $this->_request->getValue( "albumId" );
$albums = new GalleryAlbums();
$album = $albums->getAlbum( $this->_albumId, $this->_blogInfo->getId());
- $userAlbums = $albums->getUserAlbums( $this->_blogInfo->getId());
-
if( !$album ) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->tr("error_loading_resource_album"));
+ $this->_view = new AdminResourcesListView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_loading_resource_album"));
}
else {
- $this->_view = new AdminTemplatedView( $this->_blogInfo, "editresourcealbum" );
- $this->_view->setValue( "album", $album );
- $this->_view->setValue( "albums", $userAlbums );
+ // and put everything into the template
+ $this->_view = new AdminEditResourceAlbumView( $this->_blogInfo );
+ $this->_view->setValue( "albumName", $album->getName());
+ $this->_view->setValue( "albumDescription", $album->getDescription());
+ $this->_view->setValue( "showAlbum", $album->getShowAlbum());
+ $this->_view->setValue( "parentId", $album->getParentId());
+ $this->_view->setValue( "albumId", $album->getId());
}
$this->setCommonData();
Modified: plog/trunk/class/action/admin/adminupdateresourcealbumaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateresourcealbumaction.class.php 2004-12-19 16:58:19 UTC (rev 548)
+++ plog/trunk/class/action/admin/adminupdateresourcealbumaction.class.php 2004-12-19 17:10:16 UTC (rev 549)
@@ -6,8 +6,8 @@
include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/admineditresourcealbumview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.class.php" );
include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
@@ -31,61 +31,38 @@
function AdminUpdateResourceAlbumAction( $actionInfo, $request )
{
$this->AdminAction( $actionInfo, $request );
+
+ // data validation
+ $this->registerFieldValidator( "albumId", new IntegerValidator());
+ $this->registerFieldValidator( "albumName", new StringValidator());
+ $this->registerFieldValidator( "parentId", new IntegerValidator());
+ $this->registerField( "albumDescription" );
+ $this->registerField( "showAlbum" );
+ $view = new AdminEditResourceAlbumView( $this->_blogInfo, "editresourcealbum" );
+ $view->setErrorMessage( $this->_locale->tr("error_updating_resource_album" ));
+ $this->setValidationErrorView( $view );
}
- function validate()
- {
- $this->_albumId = $this->_request->getValue( "albumId" );
- $val1 = new IntegerValidator();
- if( !$val1->validate( $this->_albumId )) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->tr("error_album_id_parameter_missing"));
- $this->setCommonData();
-
- return false;
- }
-
- $this->_parentId = $this->_request->getValue( "parentAlbumId" );
- $val2 = new IntegerValidator();
- if( !$val2->validate( $this->_parentId )) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->tr("error_album_parent_id_parameter_missing"));
- $this->setCommonData();
-
- return false;
- }
-
- $this->_albumDescription = $this->_request->getValue( "albumDescription" );
-
- $this->_albumName = $this->_request->getValue( "albumName" );
- $val3 = new StringValidator();
- if( !$val3->validate( $this->_albumName )) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->tr("error_album_parent_id_parameter_missing"));
- $this->setCommonData();
-
- return false;
- }
-
- $this->_showAlbum = $this->_request->getValue( "showAlbum" );
- if( $this->_showAlbum == "" )
- $this->_showAlbum = 0;
-
- return true;
- }
-
/**
* Carries out the specified action
*/
function perform()
{
+ $this->_albumId = $this->_request->getValue( "albumId" );
+ $this->_parentId = $this->_request->getValue( "parentId" );
+ $this->_albumName = $this->_request->getValue( "albumName" );
+ $this->_albumDescription = $this->_request->getValue( "albumDescription" );
+ $this->_showAlbum = $this->_request->getValue( "showAlbum" );
+ if( $this->_showAlbum == "" )
+ $this->_showAlbum = 0;
+
// fetch the albums for this blog
$albums = new GalleryAlbums();
$album = $albums->getAlbum( $this->_albumId, $this->_blogInfo->getId());
if( !$album ) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( "error_loading_resource_album" );
+ $this->_view = new AdminResourcesListView( $this->_blogInfo );( $this->_blogInfo );
+ $this->_view->setErrorMessage( "error_updating_resource_album" );
$this->setCommonData();
return false;
@@ -96,18 +73,19 @@
$album->setDescription( $this->_albumDescription );
$album->setParentId( $this->_parentId );
$album->setShowAlbum( $this->_showAlbum );
+
$this->notifyEvent( EVENT_PRE_ALBUM_UPDATE, Array( "album" => &$album ));
// and update the data in the database
if( !$albums->updateAlbum( $album )) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->tr("error_updating_resource_album" ));
+ $this->_view = new AdminResourcesListView( $this->_blogInfo );( $this->_blogInfo );
+ $this->_view->setErrorMessage( "error_updating_resource_album" );
$this->setCommonData();
return false;
}
- $this->_view = new AdminMessageView( $this->_blogInfo );
- $this->_view->setMessage( $this->_locale->pr("resource_album_updated_ok", $album->getName()));
+ $this->_view = new AdminResourcesListView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->pr("resource_album_updated_ok", $album->getName()));
$this->notifyEvent( EVENT_POST_ALBUM_UPDATE, Array( "album" => &$album ));
$this->setCommonData();
Added: plog/trunk/class/view/admin/admineditresourcealbumview.class.php
===================================================================
--- plog/trunk/class/view/admin/admineditresourcealbumview.class.php 2004-12-19 16:58:19 UTC (rev 548)
+++ plog/trunk/class/view/admin/admineditresourcealbumview.class.php 2004-12-19 17:10:16 UTC (rev 549)
@@ -0,0 +1,28 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
+
+ /**
+ * shows the view that allows to edit an album
+ */
+ class AdminEditResourceAlbumView extends AdminTemplatedView
+ {
+
+ function AdminEditResourceAlbumView( $blogInfo )
+ {
+ $this->AdminTemplatedView( $blogInfo, "editresourcealbum" );
+ }
+
+ function render()
+ {
+ // load the nested list of albums
+ $albums = new GalleryAlbums();
+ $userAlbums = $albums->getNestedAlbumList( $this->_blogInfo->getId());
+ $this->setValue( "albums", $userAlbums );
+
+ // let the parent view do its work
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/templates/admin/editresourcealbum.template
===================================================================
--- plog/trunk/templates/admin/editresourcealbum.template 2004-12-19 16:58:19 UTC (rev 548)
+++ plog/trunk/templates/admin/editresourcealbum.template 2004-12-19 17:10:16 UTC (rev 549)
@@ -1,22 +1,48 @@
{include file="$admintemplatepath/header.template"}
-{include file="$admintemplatepath/navigation.template" showOpt=resourceAlbums title=$locale->tr("resourceAlbums")}
+{include file="$admintemplatepath/navigation.template" showOpt=resources title=$locale->tr("resourceAlbums")}
<form name="updateResourceAlbum" method="post">
- {$locale->tr("album_name")}: <input type="text" name="albumName" value="{$album->getName()|escape:"html"}" /><br/><br/>
- {$locale->tr("description")}:<br/>
- <textarea rows="6" cols="60" name="albumDescription">{$album->getDescription()}</textarea><br/><br/>
- {$locale->tr("parent_album")}:
- <select name="parentAlbumId">
- <option value="0" {if $album->getId() == 0} selected="selected" {/if}>({$locale->tr("no_parent_album")})</option>
- {foreach from=$albums item=useralbum}
- {if $useralbum->getId() != $album->getId()}
- <option value="{$useralbum->getId()}" {if $useralbum->getId() == $album->getParentId()} selected="selected" {/if}>{$useralbum->getName()}</option>
- {/if}
- {/foreach}
- </select><br/><br/>
- {$locale->tr("show_album_when_browsing")}: <input class="checkbox" type="checkbox" name="showAlbum" value="1" {if $album->getShowAlbum() == 1} checked="checked"{/if} /><br/><br/>
- <input type="hidden" name="op" value="updateResourceAlbum" />
- <input type="hidden" name="resourceId" value="{$album->getId()}" />
- <input type="submit" name="Update" value="{$locale->tr("update")}" />
+ <fieldset class="inputField">
+ <legend>{$locale->tr("editResourceAlbum")}</legend>
+ {include file="$admintemplatepath/formvalidate.template" message=$locale->tr("error_updating_album")}
+ <div class="field">
+ <label for="albumName">{$locale->tr("name")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("album_name_help")}</div>
+ <input type="text" name="albumName" value="{$albumName}" />
+ {include file="$admintemplatepath/validate.template" field=albumName message=$locale->tr("error_must_give_album_name")}
+ </div>
+ <div class="field">
+ <label for="parentId">{$locale->tr("parent_album")}</label>
+ <div class="formHelp">{$locale->tr("parent_album_help")}</div>
+ <select name="parentId">
+ <option value="0">({$locale->tr("no_parent_album")})</option>
+ {foreach from=$albums item=albumItem}
+ <option value="{$albumItem->getId()}" {if $albumItem->getId()==$parentId}selected="selected"{/if}>
+ {assign var=indentLevel value=$albumItem->getValue("level")}
+ {textformat indent=$indentLevel indent_char=" "}{$albumItem->getName()}{/textformat}
+ </option>
+ {/foreach}
+ </select>
+ </div>
+ <div class="field">
+ <label for="albumDescription">{$locale->tr("description")}</label>
+ <div class="formHelp">{$locale->tr("album_description_help")}</div>
+ <textarea name="albumDescription" rows="10" cols="60">{$albumDescription}</textarea>
+ </div>
+ <div class="field">
+ <label for="showAlbum">{$locale->tr("show_album")}</label>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="showAlbum" value="1" {if $showAlbum == 1} checked="checked"{/if} />
+ {$locale->tr("show_album_help")}
+ </div>
+ </div>
+ </fieldset>
+ <div class="buttons">
+ <input type="hidden" name="op" value="updateResourceAlbum" />
+ <input type="hidden" name="resourceId" value="{$albumId}" />
+ <input type="reset" name="reset" value="{$locale->tr("reset")}" />
+ <input type="submit" name="Update" value="{$locale->tr("update")}" />
+ </div>
</form>
{include file="$admintemplatepath/footernavigation.template"}
{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list