[pLog-svn] r5937 - in plog/trunk: class/action/admin js/ui/pages templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sat Sep 15 10:42:39 EDT 2007
Author: oscar
Date: 2007-09-15 10:42:39 -0400 (Sat, 15 Sep 2007)
New Revision: 5937
Modified:
plog/trunk/class/action/admin/admincopyblogtemplatesetaction.class.php
plog/trunk/js/ui/pages/templateeditor.js
plog/trunk/templates/admin/blogtemplates_table.template
Log:
Now it is finally possible to copy a global template into a blog template, so that users can customize any of the global templates to suit their needs.
Modified: plog/trunk/class/action/admin/admincopyblogtemplatesetaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admincopyblogtemplatesetaction.class.php 2007-09-15 14:13:13 UTC (rev 5936)
+++ plog/trunk/class/action/admin/admincopyblogtemplatesetaction.class.php 2007-09-15 14:42:39 UTC (rev 5937)
@@ -2,7 +2,8 @@
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/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.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" );
@@ -40,10 +41,22 @@
function validate()
{
- if( !parent::validate( Array( "templateId" ))) {
- $this->validationErrorProcessing();
+ // the source is a global template or a blog template?
+ $this->_sourceTemplateType = $this->_request->getValue( "templateType", AdminCopyBlogtemplateSetAction::BLOG_TEMPLATE );
+
+ // check that the template really exists
+ $this->_templateId = $this->_request->getFilteredValue( "templateId", TemplateTools::getTemplateNameFilter());
+
+ if( $this->blogId == AdminCopyBlogTemplateSetAction::GLOBAL_TEMPLATE )
+ $result = TemplateSets::isTemplate( $this->_templateId );
+ else
+ $result = TemplateSets::isBlogTemplate( $this->_templateId, $this->_blogInfo->getId());
+
+ if( !$result ) {
+ $this->_form->setFieldValidationStatus( "templateId", false );
+ $this->validationErrorProcessing();
return( false );
- }
+ }
// check that the destination template does not exist
$this->_destTemplate = $this->_request->getFilteredValue( "destTemplate", TemplateTools::getTemplateNameFilter());
Modified: plog/trunk/js/ui/pages/templateeditor.js
===================================================================
--- plog/trunk/js/ui/pages/templateeditor.js 2007-09-15 14:13:13 UTC (rev 5936)
+++ plog/trunk/js/ui/pages/templateeditor.js 2007-09-15 14:42:39 UTC (rev 5937)
@@ -124,10 +124,35 @@
Lifetype.UI.Pages.TemplateEditor.copySourceTemplate = null;
}
-Lifetype.UI.Pages.TemplateEditor.showCopyBlogTemplatePrompt = function( sourceTemplate )
+/**
+ * Callback used for the 'copy template set' prompt, but on the blog side (which is slightly different from the one above)
+ */
+Lifetype.UI.Pages.TemplateEditor.handleCopyGlobalToBlogTemplateOk = function( value )
{
+ if( value != "" ) {
+ var url = '?op=copyBlogTemplateSet&templateId=' + Lifetype.UI.Pages.TemplateEditor.copySourceTemplate +
+ '&destTemplate=' + value + '&templateType=1';
+ Lifetype.Forms.performUrl( url );
+ }
+
+ Lifetype.UI.Pages.TemplateEditor.copySourceTemplate = null;
+}
+
+/**
+ * @param sourceTemplate
+ * @param templateType 'global' for global template and 'blog' for blog templates
+ */
+Lifetype.UI.Pages.TemplateEditor.showCopyBlogTemplatePrompt = function( sourceTemplate, templateType )
+{
Lifetype.UI.Pages.TemplateEditor.copySourceTemplate = sourceTemplate;
- var v = Lifetype.UI.Prompt.OkCancelPrompt.show( tr('enter_new_template_name'), { handleOk:Lifetype.UI.Pages.TemplateEditor.handleCopyBlogTemplateOk });
+ var callback = null;
+
+ if( templateType == 'global' )
+ callback = Lifetype.UI.Pages.TemplateEditor.handleCopyGlobalToBlogTemplateOk;
+ else
+ callback = Lifetype.UI.Pages.TemplateEditor.handleCopyBlogTemplateOk;
+
+ var v = Lifetype.UI.Prompt.OkCancelPrompt.show( tr('enter_new_template_name'), { handleOk: callback });
}
Lifetype.UI.Pages.TemplateEditor.templateFileUploadHandler = function( form )
Modified: plog/trunk/templates/admin/blogtemplates_table.template
===================================================================
--- plog/trunk/templates/admin/blogtemplates_table.template 2007-09-15 14:13:13 UTC (rev 5936)
+++ plog/trunk/templates/admin/blogtemplates_table.template 2007-09-15 14:42:39 UTC (rev 5937)
@@ -10,7 +10,7 @@
<br/>
{check_perms perm=update_blog_template}
{if $blogtemplate->isBlogSpecific()}<a href="?op=editBlogTemplate&templateId={$blogtemplate->getName()}">{$locale->tr("edit")}</a> |{/if}
- <a href="#" onClick="Lifetype.UI.Pages.TemplateEditor.showCopyBlogTemplatePrompt('{$blogtemplate->getName()}');return(false);">{$locale->tr("copy")}</a>
+ <a href="#" onClick="Lifetype.UI.Pages.TemplateEditor.showCopyBlogTemplatePrompt('{$blogtemplate->getName()}',{if $blogtemplate->isGlobal()}'global'{else}'blog'{/if});return(false);">{$locale->tr("copy")}</a>
{if $blogtemplate->isBlogSpecific()}| <a href="?op=deleteBlogTemplate&templateId={$blogtemplate->getName()}" onClick="Lifetype.Forms.performRequest(this);return(false);">{$locale->tr("delete")}</a>{/if}
{/check_perms}
</div>
More information about the pLog-svn
mailing list