[pLog-svn] r5892 - in plog/trunk: class/action/admin class/template/editor class/view/admin locale/admin templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Sep 2 17:24:00 EDT 2007
Author: oscar
Date: 2007-09-02 17:23:59 -0400 (Sun, 02 Sep 2007)
New Revision: 5892
Added:
plog/trunk/class/action/admin/admindeleteblogtemplatefileaction.class.php
plog/trunk/class/action/admin/admineditblogtemplateaction.class.php
plog/trunk/class/action/admin/admineditblogtemplatefileaction.class.php
plog/trunk/class/action/admin/adminupdateblogtemplatefileaction.class.php
plog/trunk/class/view/admin/adminbasetemplateeditorview.class.php
plog/trunk/class/view/admin/admineditblogtemplateview.class.php
plog/trunk/templates/admin/blogtemplates_table.template
plog/trunk/templates/admin/editblogtemplate.template
plog/trunk/templates/admin/newblogtemplate_form.template
Modified:
plog/trunk/class/action/admin/adminbasetemplateeditoraction.class.php
plog/trunk/class/action/admin/admindeletetemplatefileaction.class.php
plog/trunk/class/action/admin/adminnewblogtemplateaction.class.php
plog/trunk/class/template/editor/templatetools.class.php
plog/trunk/class/view/admin/adminedittemplateview.class.php
plog/trunk/locale/admin/locale_en_UK.php
plog/trunk/templates/admin/blogtemplates.template
plog/trunk/templates/admin/edittemplate.template
plog/trunk/templates/admin/edittemplate_table.template
plog/trunk/templates/admin/edittemplatefile_form.template
plog/trunk/templates/admin/newblogtemplate.template
Log:
Implemented edition and deletion of template files for blog templates.
Modified: plog/trunk/class/action/admin/adminbasetemplateeditoraction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminbasetemplateeditoraction.class.php 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/class/action/admin/adminbasetemplateeditoraction.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -1,6 +1,9 @@
<?php
lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/editor/templatetools.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/templatenamevalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
/**
* \ingroup Action
@@ -58,13 +61,32 @@
}
function validateTemplateFileName()
- {
+ {
$this->_file = $this->_request->getFilteredValue( "file", TemplateTools::getTemplateFileNameFilter());
- if( !TemplateTools::isValidTemplateFile( $this->_templateId, $this->_path, $this->_file, $this->blogId ) ||
- !TemplateTools::isEditable( $this->_file )) {
+
+ $valid = true;
+
+ // we have to check if we're dealing with a folder, because we don't need to check if the folder
+ // has one of the allowed extensions
+ lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
+ $filePath = TemplateSetStorage::getTemplateFolder( $this->_templateId, $this->blogId ) . $this->_path . "/" . $this->_file;
+ if( File::isDir( $filePath )) {
+ if( !TemplateTools::isValidTemplateFile( $this->_templateId, $this->_path, $this->_file, $this->blogId ) ||
+ !File::isReadable( $filePath )) {
+ $valid = false;
+ }
+ }
+ else {
+ if( !TemplateTools::isValidTemplateFile( $this->_templateId, $this->_path, $this->_file, $this->blogId ) ||
+ !TemplateTools::isEditable( $this->_file )) {
+ $valid = false;
+ }
+ }
+
+ if( !$valid ) {
$this->_form->setFieldValidationStatus( "file", false );
$this->validationErrorProcessing();
- return( false );
+ return( false );
}
return( true );
Added: plog/trunk/class/action/admin/admindeleteblogtemplatefileaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeleteblogtemplatefileaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/admindeleteblogtemplatefileaction.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,74 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminbasetemplateeditoraction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/templatenamevalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/filter/regexpfilter.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesets.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/editor/templatetools.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminsitetemplateslistview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminedittemplateview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminerrordialogview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
+
+ class AdminDeleteBlogTemplateFileAction extends AdminBaseTemplateEditorAction
+ {
+
+ function __construct( $actionInfo, $request )
+ {
+ $this->AdminBaseTemplateEditorAction( $actionInfo, $request );
+
+ $this->registerFieldValidator( "templateId", new TemplateNameValidator(), false);
+ $this->registerFieldValidator( "path", new StringValidator(), true );
+ $this->registerFieldValidator( "file", new StringValidator(), false );
+ $view = new AdminSiteTemplatesListView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( "error_deleting_template_file" ));
+ $this->setValidationErrorView( $view );
+
+ $this->requirePermission( "update_blog_template" );
+ }
+
+ function validate()
+ {
+ return( parent::validate( Array( "templateId", "path", "file" )));
+ }
+
+ function deleteFile()
+ {
+ $this->_path = TemplateTools::sanitizePath( $this->_path );
+
+ // load the file
+ $filePath = TemplateSetStorage::getTemplateFolder( $this->_templateId, $this->_blogInfo->getId()) . "/".
+ $this->_path . "/" .
+ $this->_file;
+
+ return( File::delete( $filePath ));
+ }
+
+ function perform()
+ {
+ $this->_view = new AdminEditTemplateView( $this->_blogInfo, $this->_templateId, $this->_path );
+ if( $this->deleteFile())
+ $this->_view->setSuccessMessage( $this->_locale->tr( "template_file_deleted_ok" ));
+ else
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_deleting_template_file" ));
+
+ $this->setCommonData();
+
+ return( true );
+ }
+
+ function performAjax()
+ {
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+
+ if( $this->deleteFile())
+ $this->_view->setSuccessMessage( $this->_locale->tr( "template_file_deleted_ok" ));
+ else
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_deleting_template_file" ));
+
+ return( true );
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/admindeletetemplatefileaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletetemplatefileaction.class.php 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/class/action/admin/admindeletetemplatefileaction.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -34,6 +34,7 @@
function deleteFile()
{
+
$this->_path = TemplateTools::sanitizePath( $this->_path );
// load the file
@@ -45,12 +46,12 @@
}
function perform()
- {
+ {
$this->_view = new AdminEditTemplateView( $this->_blogInfo, $this->_templateId, $this->_path );
if( $this->deleteFile())
$this->_view->setSuccessMessage( $this->_locale->tr( "template_file_deleted_ok" ));
else
- $this->_view->setSuccessMessage( $this->_locale->tr( "error_deleting_template_file" ));
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_deleting_template_file" ));
$this->setCommonData();
@@ -65,7 +66,7 @@
if( $this->deleteFile())
$this->_view->setSuccessMessage( $this->_locale->tr( "template_file_deleted_ok" ));
else
- $this->_view->setSuccessMessage( $this->_locale->tr( "error_deleting_template_file" ));
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_deleting_template_file" ));
return( true );
}
Added: plog/trunk/class/action/admin/admineditblogtemplateaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditblogtemplateaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/admineditblogtemplateaction.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,47 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminbasetemplateeditoraction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/templatenamevalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/filter/regexpfilter.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesets.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/editor/templatetools.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminblogtemplatesetslistview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/admineditblogtemplateview.class.php" );
+
+ class AdminEditBlogTemplateAction extends AdminBaseTemplateEditorAction
+ {
+ protected $_templateId;
+ protected $_path;
+
+ function __construct( $actionInfo, $request )
+ {
+ $this->AdminBaseTemplateEditorAction( $actionInfo, $request );
+
+ // the blog id is needed by the common validation code
+ $this->blogId = $this->_blogInfo->getId();
+
+ $this->registerFieldValidator( "templateId", new TemplateNameValidator());
+ $view = new AdminBlogTemplateSetsListView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( "error_loading_template_set" ));
+ $this->setValidationErrorView( $view );
+
+ $this->requirePermission( "update_blog_template" );
+ }
+
+ function validate()
+ {
+ return( parent::validate( Array( "templateId", "path" )));
+ }
+
+ function perform()
+ {
+ $this->_view = new AdminEditBlogTemplateView( $this->_blogInfo, $this->_templateId, TemplateTools::sanitizePath( $this->_path ));
+ $this->setCommonData();
+ }
+
+ function performAjax()
+ {
+ return( $this->perform());
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/action/admin/admineditblogtemplatefileaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditblogtemplatefileaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/admineditblogtemplatefileaction.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,69 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminbasetemplateeditoraction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/templatenamevalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/filter/regexpfilter.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesets.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/editor/templatetools.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminblogtemplatesetslistview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminedittemplatefileview.class.php" );
+
+ class AdminEditBlogTemplateFileAction extends AdminBaseTemplateEditorAction
+ {
+ protected $_templateId;
+ protected $_path;
+ protected $_file;
+
+ function __construct( $actionInfo, $request )
+ {
+ $this->AdminBaseTemplateEditorAction( $actionInfo, $request );
+
+ // the blog id is needed by the common validation code
+ $this->blogId = $this->_blogInfo->getId();
+
+ $this->registerFieldValidator( "templateId", new TemplateNameValidator(), false);
+ $this->registerFieldValidator( "path", new StringValidator(), true );
+ $this->registerFieldValidator( "file", new StringValidator(), false );
+ $view = new AdminBlogTemplateSetsListView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( "error_loading_template_set" ));
+ $this->setValidationErrorView( $view );
+
+ $this->requirePermission( "update_blog_template" );
+ }
+
+ function validate()
+ {
+ return( parent::validate( Array( "templateId", "path", "file" )));
+ }
+
+ function perform()
+ {
+ $this->_view = new AdminEditTemplateFileView( $this->_blogInfo );
+ $this->_view->setValue( "mode", "blog" );
+
+ $this->_path = TemplateTools::sanitizePath( $this->_path );
+
+ // load the file
+ $filePath = TemplateSetStorage::getTemplateFolder( $this->_templateId, $this->blogId ) . "/".
+ $this->_path . "/" .
+ $this->_file;
+
+ $f = new File( $filePath );
+ $this->_view->setValue( "fileContent", $f->readContents());
+ $this->_view->setValue( "path", $this->_path );
+ $this->_view->setValue( "file", $this->_file );
+ $this->_view->setValue( "template", $this->_templateId );
+
+ $this->setCommonData();
+
+ return( true );
+ }
+
+ function performAjax()
+ {
+ return( $this->perform());
+ }
+ }
+
+?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/adminnewblogtemplateaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminnewblogtemplateaction.class.php 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/class/action/admin/adminnewblogtemplateaction.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -2,6 +2,7 @@
lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminerrordialogview.class.php" );
lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
lt_include( PLOG_CLASS_PATH."class/view/admin/adminblogtemplatesetslistview.class.php" );
@@ -23,18 +24,31 @@
function perform()
{
- if( $this->_config->getValue( "users_can_add_templates" ) == true ) {
- $this->_view = new AdminTemplatedView( $this->_blogInfo, "newblogtemplate" );
+ if( $this->_config->getValue( "users_can_add_templates" ) == true ) {
+ if( Request::isXHR())
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "newblogtemplate_form" );
+ else
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "newblogtemplate" );
+
$this->_view->setValue( "templateFolder", TemplateSetStorage::getBlogBaseTemplateFolder( $this->_blogInfo->getId()));
$this->setCommonData();
}
else {
- $this->_view = new AdminBlogTemplateSetsListView( $this->_blogInfo );
+ if( Request::isXHR())
+ $this->_view = new AdminBlogTemplateSetsListView( $this->_blogInfo );
+ else
+ $this->_view = new AdminErrorDialogView( $this->_blogInfo );
+
$this->_view->setErrorMessage( $this->_locale->tr("error_add_template_disabled"));
$this->setCommonData();
}
return true;
}
+
+ function performAjax()
+ {
+ return( $this->perform());
+ }
}
?>
Added: plog/trunk/class/action/admin/adminupdateblogtemplatefileaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateblogtemplatefileaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/adminupdateblogtemplatefileaction.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,80 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminbasetemplateeditoraction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/templatenamevalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/filter/regexpfilter.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesets.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/editor/templatetools.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminsitetemplateslistview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminedittemplateview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminedittemplatefileview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
+
+ class AdminUpdateBlogTemplateFileAction extends AdminBaseTemplateEditorAction
+ {
+ function __construct( $actionInfo, $request )
+ {
+ $this->AdminBaseTemplateEditorAction( $actionInfo, $request );
+
+ $this->registerFieldValidator( "templateId", new TemplateNameValidator(), false);
+ $this->registerFieldValidator( "path", new StringValidator(), true );
+ $this->registerFieldValidator( "file", new StringValidator(), false );
+ $view = new AdminSiteTemplatesListView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( "error_loading_template_file" ));
+ $this->setValidationErrorView( $view );
+
+ $this->requirePermission( "update_blog_template" );
+ }
+
+ function validate()
+ {
+ return( parent::validate( Array( "templateId", "path", "file" )));
+ }
+
+ function writeFile()
+ {
+ $this->_path = TemplateTools::sanitizePath( $this->_path );
+
+ // load the file
+ $filePath = TemplateSetStorage::getTemplateFolder( $this->_templateId, $this->_blogInfo->getId()) . "/".
+ $this->_path . "/" .
+ $this->_file;
+
+ $f = new File( $filePath );
+ $f->open( "w+" );
+ return( $f->write( $this->_request->getValue( "fileContent" )));
+ }
+
+ function perform()
+ {
+ $result = $this->writeFile();
+
+ $this->_view = new AdminEditTemplateView( $this->_blogInfo, $this->_templateId, $this->_path );
+
+ if( $result )
+ $this->_view->setSuccessMessage( $this->_locale->tr( "template_file_updated_ok" ));
+ else
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_updating_template_file" ));
+
+ $this->setCommonData();
+
+ return( true );
+ }
+
+ function performAjax()
+ {
+ $result = $this->writeFile();
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+
+ if( $result )
+ $this->_view->setSuccessMessage( $this->_locale->tr( "template_file_updated_ok" ));
+ else
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_updating_template_file" ));
+
+ return( true );
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/class/template/editor/templatetools.class.php
===================================================================
--- plog/trunk/class/template/editor/templatetools.class.php 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/class/template/editor/templatetools.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -49,7 +49,7 @@
$tmp['name'] = basename($file);
$tmp['size'] = filesize($file);
$tmp['isEditable'] = TemplateTools::isValidExtension( $tmp['name'] ) && File::isWritable( $file ) && File::isReadable( $file );
- $tmp['isRemovable'] = File::isWritable( dirname( $file ));
+ $tmp['isRemovable'] = File::isWritable( dirname( $file )) && TemplateTools::isValidExtension( $tmp['name'] );
$tmp['isImage'] = TemplateTools::isImage( $tmp['name'] );
$tmp['isReadable'] = File::isReadable( $file );
$tmp['url'] = $file;
@@ -62,6 +62,8 @@
$tmp['name'] = basename($file);
$tmp['isFile'] = false;
$tmp['isFolder'] = true;
+ $tmp['isEditable'] = File::isReadable( $file );
+ $tmp['isImage'] = false;
if ( $tmp['name'] != "backups" ) {
array_push ($templateFiles, $tmp);
}
Added: plog/trunk/class/view/admin/adminbasetemplateeditorview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminbasetemplateeditorview.class.php (rev 0)
+++ plog/trunk/class/view/admin/adminbasetemplateeditorview.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,19 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+
+ abstract class AdminBaseTemplateEditorView extends AdminTemplatedView
+ {
+ protected $blogId;
+
+ function AdminBaseTemplateEditorView( $blogInfo )
+ {
+ $this->AdminTemplatedView( $blogInfo, $this->getTemplateFile());
+
+ $this->blogId = 0;
+ }
+
+ abstract function getTemplateFile();
+ }
+
+?>
\ No newline at end of file
Added: plog/trunk/class/view/admin/admineditblogtemplateview.class.php
===================================================================
--- plog/trunk/class/view/admin/admineditblogtemplateview.class.php (rev 0)
+++ plog/trunk/class/view/admin/admineditblogtemplateview.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,26 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminedittemplateview.class.php" );
+
+ class AdminEditBlogTemplateView extends AdminEditTemplateView
+ {
+ function __construct( $blogInfo, $templateId, $path = "" )
+ {
+ parent::__construct( $blogInfo, $templateId, $path );
+
+ $this->blogId = $blogInfo->getId();
+
+ $this->setValue( "mode", "blog" );
+ }
+
+ function getTemplateFile()
+ {
+ if( Request::isXHR())
+ $file = "edittemplate_table";
+ else
+ $file = "editblogtemplate";
+
+ return( $file );
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/class/view/admin/adminedittemplateview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminedittemplateview.class.php 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/class/view/admin/adminedittemplateview.class.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -1,28 +1,35 @@
<?php
- lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminbasetemplateeditorview.class.php" );
lt_include( PLOG_CLASS_PATH."class/template/editor/templatetools.class.php" );
- class AdminEditTemplateView extends AdminTemplatedView
+ class AdminEditTemplateView extends AdminBaseTemplateEditorView
{
private $_templateId;
private $_path;
function __construct( $blogInfo, $templateId, $path = "" )
{
- if( Request::isXHR())
- $this->AdminTemplatedView( $blogInfo, "edittemplate_table" );
- else
- $this->AdminTemplatedView( $blogInfo, "edittemplate" );
+ $this->AdminBaseTemplateEditorView( $blogInfo );
$this->_templateId = $templateId;
$this->_path = $path;
}
+ function getTemplateFile()
+ {
+ if( Request::isXHR())
+ $file = "edittemplate_table";
+ else
+ $file = "edittemplate";
+
+ return( $file );
+ }
+
function render()
{
- $files = TemplateTools::getTemplateFiles( $this->_templateId, $this->_path, 0 );
-
+ $files = TemplateTools::getTemplateFiles( $this->_templateId, $this->_path, $this->blogId );
+
$this->setValue( "files", $files );
$this->setValue( "template", $this->_templateId );
$this->setValue( "path", $this->_path );
Modified: plog/trunk/locale/admin/locale_en_UK.php
===================================================================
--- plog/trunk/locale/admin/locale_en_UK.php 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/locale/admin/locale_en_UK.php 2007-09-02 21:23:59 UTC (rev 5892)
@@ -1327,10 +1327,11 @@
$messages["copy"] = "Copy";
$messages['error_loading_template_set'] = 'Error loading the template set';
$messages['enter_template_folder_name'] = 'Enter a name for the new template folder';
-$messages['error_deleting_template_file'] = 'There was an error deleting the template file';
+$messages['error_deleting_template_file'] = 'There was an error deleting the file';
$messages['error_uploading_template_file'] = 'There was an error uploading the template file';
$messages['new_template_file_help'] = 'Please select a file to upload';
$messages['template_file_uploaded_ok'] = 'Template file successfully uploaded';
+$messages['error_updating_template_file'] = 'There was an error upading the template file';
$messages['ok'] = 'Ok';
$messages['cancel'] = 'Cancel';
Modified: plog/trunk/templates/admin/blogtemplates.template
===================================================================
--- plog/trunk/templates/admin/blogtemplates.template 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/templates/admin/blogtemplates.template 2007-09-02 21:23:59 UTC (rev 5892)
@@ -1,77 +1,24 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=blogTemplates title=$locale->tr("blogTemplates")}
{js src="js/ui/pages/templateeditor.js"}
-<script type="text/javascript">
-{literal}
-YAHOO.util.Event.addListener( window, "load", function() {
- var t = new Lifetype.Effects.Table( "list" );
- t.stripe();
- t.highlightRows();
- });
-{/literal}
-</script>
+{check_perms perm=add_blog_template}
<div class="extraFunctions">
<div class="left">
<a id="newBlogTemplate" href="?op=newBlogTemplate" rel="overlay">{$locale->tr("newBlogTemplate")}</a>
</div>
+{/check_perms}
<br style="clear:both" />
+{include file="$admintemplatepath/viewvalidateajax.template"}
<form id="editTemplates" method="post" action="admin.php">
<div id="list">
- {include file="$admintemplatepath/successmessage.template"}
- {include file="$admintemplatepath/errormessage.template"}
- <table id="list" class="info" summary="{$locale->tr("blogTemplates")}" id="list">
- <thead>
- <tr>
- <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('editTemplates');" /></th>
- <th style="width:90%;">{$locale->tr("template")}</th>
- <th style="width:10%;">{$locale->tr("actions")}</th>
- </tr>
- </thead>
- {if $templates}
- <tbody>
- {assign var=blogTemplate value=$blog->getTemplateSet()}
- {foreach from=$templates item=sitetemplate}
- <tr>
- <td>
- {if $blogTemplate->getName() != $sitetemplate->getName()}
- <input class="checkbox" type="checkbox" name="templateIds[{counter}]" value="{$sitetemplate->getName()}" />
- {/if}
- </td>
- <td class="col_highlighted">
- {if $sitetemplate->hasScreenshot()}
- <a href="javascript:Lifetype.UI.Pages.TemplateChooser.openScreenshotWindow('{$sitetemplate->getScreenshotUrl()}');">{$sitetemplate->getName()}</a>
- {else}
- {$sitetemplate->getName()}
- {/if}
- </td>
- <td>
- <div class="list_action_button">
- {check_perms perm=update_blog_template}
- <a href="?op=deleteBlogTemplate&templateId={$sitetemplate->getName()}" title="{$locale->tr("delete")}">
- {if $blogTemplate->getName() != $sitetemplate->getName()}
- <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
- {/if}
- </a>
- {/check_perms}
- {if $sitetemplate->hasScreenshot()}
- <a href="javascript:Lifetype.UI.Pages.TemplateChooser.openScreenshotWindow('{$sitetemplate->getScreenshotUrl()}');" title="{$locale->tr("preview")}">
- <img src="imgs/admin/icon_image-16.png" title="{$locale->tr("preview")}" />
- </a>
- {/if}
- </div>
- </td>
- </tr>
- {/foreach}
- </tbody>
- {/if}
- </table>
+ {include file="$admintemplatepath/blogtemplates_table.template"}
</div>
- <div id="list_action_bar">
+ <!--div id="list_action_bar">
{check_perms perm=update_blog_template}
<input type="hidden" name="op" value="deleteBlogTemplates" class="submit" />
<input type="submit" name="{$locale->tr("delete")}" value="{$locale->tr("delete")}"/>
{/check_perms}
- </div>
+ </div -->
</form>
{include file="$admintemplatepath/footernavigation.template"}
{include file="$admintemplatepath/footer.template"}
Added: plog/trunk/templates/admin/blogtemplates_table.template
===================================================================
--- plog/trunk/templates/admin/blogtemplates_table.template (rev 0)
+++ plog/trunk/templates/admin/blogtemplates_table.template 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,17 @@
+{foreach from=$templates item=sitetemplate}
+ <div class="template-screenshot">
+ <input style="display:none" type="checkbox" name="templateIds[{counter}]" value="{$sitetemplate->getName()}" />
+ <span style="font-weight:bold;font-size:1.1em">{$sitetemplate->getName()}</span>
+ {if $sitetemplate->hasScreenshot()}
+ <a href="{$sitetemplate->getScreenshotUrl()}" onClick="Lifetype.UI.Misc.openInNewWindow(this);">
+ <img src="{$sitetemplate->getScreenshotUrl()}" alt="{$sitetemplate->getName()}" />
+ </a>
+ {/if}
+ <br/>
+ {check_perms perm=update_blog_template}
+ <a href="?op=editBlogTemplate&templateId={$sitetemplate->getName()}">{$locale->tr("edit")}</a> |
+ <a href="#" onClick="Lifetype.UI.Pages.TemplateEditor.showCopyTemplatePrompt('{$sitetemplate->getName()}');return(false);">{$locale->tr("copy")}</a> |
+ <a href="?op=deleteBlogTemplate&templateId={$sitetemplate->getName()}" onClick="Lifetype.Forms.performRequest(this);return(false);">{$locale->tr("delete")}</a>
+ {/check_perms}
+ </div>
+{/foreach}
\ No newline at end of file
Added: plog/trunk/templates/admin/editblogtemplate.template
===================================================================
--- plog/trunk/templates/admin/editblogtemplate.template (rev 0)
+++ plog/trunk/templates/admin/editblogtemplate.template 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,33 @@
+{include file="$blogtemplate/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=blogTemplates title=$locale->tr("blogTemplates")}
+<link rel="stylesheet" href="js/editor/lifetypeeditor.css" type="text/css" />
+{js src="js/editor/lifetypeeditor.js"}
+{js src="js/ui/pages/templateeditor.js"}
+{check_perms perm=add_blog_template}
+<div class="extraFunctions">
+ <div class="left">
+ <a id="newFolderButton" href="#"
+ onClick="Lifetype.UI.Pages.TemplateEditor.newFolderButtonHandler(this);return(false);">{$locale->tr("new_folder")}</a> |
+ <a id="uploadFileButton" href="?op=newBlogTemplateFile" rel="overlay">{$locale->tr("upload_file")}</a>
+ </div>
+ <div class="right">
+ <a href="?op=editTemplate&templateId={$template}">{$template}</a> » {$path}
+ </div>
+</div>
+<br style="clear:both" />
+{/check_perms}
+
+<form id="siteTemplatesList" method="post" action="admin.php">
+ <div id="list">
+ {include file="$admintemplatepath/edittemplate_table.template"}
+ </div>
+ <div id="list_action_bar">
+ <input type="hidden" name="templateId" id="templateId" value="{$template}" />
+ <input type="hidden" name="path" value="{$path}" />
+ <input type="hidden" name="op" value="deleteBlogTemplateFile" class="submit" />
+ <input type="submit" name="{$locale->tr("delete")}" value="{$locale->tr("delete")}"/>
+ </div>
+</form>
+
+{include file="$blogtemplate/footernavigation.template"}
+{include file="$blogtemplate/footer.template"}
\ No newline at end of file
Modified: plog/trunk/templates/admin/edittemplate.template
===================================================================
--- plog/trunk/templates/admin/edittemplate.template 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/templates/admin/edittemplate.template 2007-09-02 21:23:59 UTC (rev 5892)
@@ -18,7 +18,6 @@
{/check_perms}
<form id="siteTemplatesList" method="post" action="admin.php">
- {include file="$admintemplatepath/viewvalidateajax.template"}
<div id="list">
{include file="$admintemplatepath/edittemplate_table.template"}
</div>
Modified: plog/trunk/templates/admin/edittemplate_table.template
===================================================================
--- plog/trunk/templates/admin/edittemplate_table.template 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/templates/admin/edittemplate_table.template 2007-09-02 21:23:59 UTC (rev 5892)
@@ -1,3 +1,4 @@
+{include file="$admintemplatepath/viewvalidateajax.template"}
<table class="info" id="templateFiles">
<thead>
<tr>
@@ -15,7 +16,7 @@
<div align="center"><span style="background-color: #CCCCCC"> </span></div>
</td>
<td class="col_highlighted">
- <a href="?op=editTemplate&templateId={$template}&path={$up}" onClick="Lifetype.UI.Pages.TemplateEditor.loadFolderLink(this.href);return(false);">
+ <a href="?op={if $mode=="blog"}editBlogTemplate{else}editTemplate{/if}&templateId={$template}&path={$up}" onClick="Lifetype.UI.Pages.TemplateEditor.loadFolderLink(this.href);return(false);">
<img src="imgs/admin/icon_folder-16.png" />
..
</a>
@@ -31,10 +32,10 @@
<td>
<input class="checkbox" type="checkbox" name="fileIds[{counter}]" value="{$file.name}" />
</td>
- <td class="col_highlighted">
+ <td class="col_highlighted">
{if $file.isFile}
{if $file.isEditable}
- <a href="?op=editTemplateFile&templateId={$template}&path={$path}&file={$file.name}" rel="overlay">
+ <a href="?op={if $mode=="blog"}editBlogTemplate{else}editTemplate{/if}File&templateId={$template}&path={$path}&file={$file.name}" rel="overlay">
<img src="imgs/admin/icon_template-16.png" />
{$file.name}
</a>
@@ -48,10 +49,15 @@
{$file.name}
{/if}
{elseif $file.isFolder}
- <a href="?op=editTemplate&templateId={$template}&path={$path}/{$file.name}" onClick="Lifetype.UI.Pages.TemplateEditor.loadFolderLink(this.href);return(false);">
+ {if $file.isEditable}
+ <a href="?op={if $mode=="blog"}editBlogTemplate{else}editTemplate{/if}&templateId={$template}&path={$path}/{$file.name}" onClick="Lifetype.UI.Pages.TemplateEditor.loadFolderLink(this.href);return(false);">
<img src="imgs/admin/icon_folder-16.png" />
{$file.name}
- </a>
+ </a>
+ {else}
+ <img src="imgs/admin/icon_folder-16.png" />
+ {$file.name}
+ {/if}
{/if}
</td>
<td>
@@ -59,21 +65,21 @@
</td>
<td>
<div class="list_action_button">
- {if $file.isEditable}
- <a href="?op=editTemplateFile&templateId={$template}&path={$path}&file={$file.name}" rel="overlay">
+ {if $file.isEditable && !$file.isFolder}
+ <a href="?op={if $mode=="blog"}editBlogTemplate{else}editTemplate{/if}File&templateId={$template}&path={$path}&file={$file.name}" rel="overlay">
<img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
</a>
{else}
<img src="imgs/admin/icon_empty-16.png" />
{/if}
{if $file.isRemovable}
- <a href="?op=deleteTemplateFile&templateId={$template}&path={$path}&file={$file.name}" onClick="Lifetype.Forms.performRequest(this);return(false);">
+ <a href="?op={if $mode=="blog"}deleteBlogTemplateFile{else}deleteTemplateFile{/if}&templateId={$template}&path={$path}&file={$file.name}" onClick="Lifetype.Forms.performRequest(this);return(false);">
<img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
</a>
{else}
<img src="imgs/admin/icon_empty-16.png" />
{/if}
- {if $file.isReadable}
+ {if $file.isReadable && !$file.isFolder}
<a href="#" id="{$file.name}" onClick="Lifetype.UI.Pages.TemplateEditor.copyTemplateFileTo('{$file.name}');return(false);" >
<img src="imgs/admin/icon_copy-16.png" alt="{$locale->tr("copy")}" />
</a>
Modified: plog/trunk/templates/admin/edittemplatefile_form.template
===================================================================
--- plog/trunk/templates/admin/edittemplatefile_form.template 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/templates/admin/edittemplatefile_form.template 2007-09-02 21:23:59 UTC (rev 5892)
@@ -1,6 +1,11 @@
<div class="extraFunctions">
<div class="right">
- <a href="?op=editTemplate&templateId={$template}">{$template}</a> » {$path}: {$file}
+ {if $mode=="blog"}
+ <a href="?op=editBlogTemplate&templateId={$template}">{$template}</a>
+ {else}
+ <a href="?op=editTemplate&templateId={$template}">{$template}</a>
+ {/if}
+ » {$path}: {$file}
</div>
</div>
<br style="clear:both" />
@@ -29,7 +34,11 @@
<input type="hidden" name="templateId" value="{$template}" />
<input type="hidden" name="path" value="{$path}" />
<input type="hidden" name="file" value="{$file}" />
- <input type="hidden" name="op" value="updateTemplateFile" />
+ {if $mode=="blog"}
+ <input type="hidden" name="op" value="updateBlogTemplateFile" />
+ {else}
+ <input type="hidden" name="op" value="updateTemplateFile" />
+ {/if}
<input type="reset" name="{$locale->tr("reset")}" />
<input type="submit" name="{$locale->tr("update")}" value="{$locale->tr("update")}" />
</div>
Modified: plog/trunk/templates/admin/newblogtemplate.template
===================================================================
--- plog/trunk/templates/admin/newblogtemplate.template 2007-09-02 18:59:28 UTC (rev 5891)
+++ plog/trunk/templates/admin/newblogtemplate.template 2007-09-02 21:23:59 UTC (rev 5892)
@@ -1,19 +1,5 @@
-<form name="newBlogTemplate" action="admin.php" method="post" enctype="multipart/form-data">
- <fieldset class="inputField">
- <legend>{$locale->tr("newBlogTemplate")}</legend>
- {include file="$admintemplatepath/successmessage.template"}
- {include file="$admintemplatepath/errormessage.template"}
- <div class="field">
- <label for="templateFile">{$locale->tr("template_package")}</label>
- <span class="required">*</span>
- <div class="formHelp">{$locale->pr("blog_template_package_help", $templateFolder)}</div>
- <input type="file" name="templateFile" value="" />
- </div>
- </fieldset>
- <div class="buttons">
- <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
- <input type="hidden" name="op" value="addBlogTemplate" />
- <input type="submit" name="scanBlogTemplates" value="{$locale->tr("scan_templates")}" />
- <input type="submit" name="addBlogTemplate" value="{$locale->tr("add")}" />
- </div>
-</form>
\ No newline at end of file
+{include file="$blogtemplate/header.template"}
+{include file="$blogtemplate/navigation.template" showOpt=newBlogTemplate title=$locale->tr("blogTemplates")}
+{include file="$blogtemplate/newblogtemplate_form.template"}
+{include file="$blogtemplate/footernavigation.template"}
+{include file="$blogtemplate/footer.template"}
\ No newline at end of file
Added: plog/trunk/templates/admin/newblogtemplate_form.template
===================================================================
--- plog/trunk/templates/admin/newblogtemplate_form.template (rev 0)
+++ plog/trunk/templates/admin/newblogtemplate_form.template 2007-09-02 21:23:59 UTC (rev 5892)
@@ -0,0 +1,19 @@
+<form name="newBlogTemplate" action="admin.php" method="post" enctype="multipart/form-data">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("newBlogTemplate")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="templateFile">{$locale->tr("template_package")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->pr("blog_template_package_help", $templateFolder)}</div>
+ <input type="file" name="templateFile" value="" />
+ </div>
+ </fieldset>
+ <div class="buttons">
+ <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
+ <input type="hidden" name="op" value="addBlogTemplate" />
+ <input type="submit" name="scanBlogTemplates" value="{$locale->tr("scan_templates")}" />
+ <input type="submit" name="addBlogTemplate" value="{$locale->tr("add")}" />
+ </div>
+</form>
\ No newline at end of file
More information about the pLog-svn
mailing list