[pLog-svn] r5894 - in plog/trunk: class/action/admin js/ui/pages templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Mon Sep 3 16:04:34 EDT 2007


Author: oscar
Date: 2007-09-03 16:04:34 -0400 (Mon, 03 Sep 2007)
New Revision: 5894

Added:
   plog/trunk/class/action/admin/adminaddblogtemplatefolderaction.class.php
Modified:
   plog/trunk/js/ui/pages/templateeditor.js
   plog/trunk/templates/admin/editblogtemplate.template
   plog/trunk/templates/admin/edittemplate_table.template
Log:
Implemented creation of folders in blog templates


Added: plog/trunk/class/action/admin/adminaddblogtemplatefolderaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddblogtemplatefolderaction.class.php	                        (rev 0)
+++ plog/trunk/class/action/admin/adminaddblogtemplatefolderaction.class.php	2007-09-03 20:04:34 UTC (rev 5894)
@@ -0,0 +1,59 @@
+<?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/adminedittemplateview.class.php" );
+	
+	class AdminAddBlogTemplateFolderAction extends AdminBaseTemplateEditorAction
+	{
+		function __construct( $actionInfo, $request )
+		{
+			$this->AdminBaseTemplateEditorAction( $actionInfo, $request );
+			
+			$this->registerFieldValidator( "templateId", new TemplateNameValidator(), false);
+			$this->registerFieldValidator( "path", new StringValidator(), true );
+			$this->registerFieldValidator( "folderName", new StringValidator(), true );
+			$view = new AdminBlogTemplateSetsListView( $this->_blogInfo );
+			$view->setErrorMessage( $this->_locale->tr( "error_loading_template_set" ));
+			$this->setValidationErrorView( $view );
+			
+			$this->blogId = $this->_blogInfo->getId();
+
+			$this->requirePermission( "update_blog_template" );
+		}
+		
+		function validate()
+		{
+			return( parent::validate( Array( "templateId", "path" )));
+		}
+		
+		function createFolder()
+		{
+			$folderName = $this->_request->getFilteredValue( "folderName", TemplateTools::getTemplateNameFilter());
+			$folder = TemplateSetStorage::getTemplateFolder( $this->_templateId, $this->_blogInfo->getId()) . "/" . $this->_path . "/" . $folderName;
+			
+			return( File::createDir( $folder, File::FILE_DEFAULT_DIRECTORY_CREATION_MODE, false ));
+		}	
+		
+		function performAjax()
+		{
+			$result = $this->createFolder();
+			
+			lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
+			$this->_view = new AdminAjaxView( $this->_blogInfo );
+			
+			$this->_view->setSuccess( $result );
+			if( $result )
+				$this->_view->setSuccessMessage( $this->_locale->tr( "template_folder_created_ok" ));
+			else
+				$this->_view->setErrorMessage( $this->_locale->tr( "error_creating_template_folder" ));			
+			
+			return( true );
+		}
+	}
+?>
\ No newline at end of file

Modified: plog/trunk/js/ui/pages/templateeditor.js
===================================================================
--- plog/trunk/js/ui/pages/templateeditor.js	2007-09-03 20:03:41 UTC (rev 5893)
+++ plog/trunk/js/ui/pages/templateeditor.js	2007-09-03 20:04:34 UTC (rev 5894)
@@ -24,9 +24,15 @@
 	Lifetype.UI.Pages.TemplateEditor.currentUrl = url;
 }
 
-Lifetype.UI.Pages.TemplateEditor.newFolderButtonHandler = function( a )
+Lifetype.UI.Pages.TemplateEditor.newFolderButtonHandler = function( a, mode )
 {
-	var v = Lifetype.UI.Prompt.OkCancelPrompt.show( tr('enter_template_folder_name'), { handleOk:Lifetype.UI.Pages.TemplateEditor.handleNewFolderOk });
+	var okCallback;
+	if( mode == "blog" )
+		okCallback = Lifetype.UI.Pages.TemplateEditor.handleNewBlogFolderOk;
+	else
+		okCallback = Lifetype.UI.Pages.TemplateEditor.handleNewFolderOk;
+		
+	var v = Lifetype.UI.Prompt.OkCancelPrompt.show( tr('enter_template_folder_name'), { handleOk:okCallback });
 }
 
 Lifetype.UI.Pages.TemplateEditor.handleNewFolderOk = function( value )
@@ -37,6 +43,14 @@
 	}
 }
 
+Lifetype.UI.Pages.TemplateEditor.handleNewBlogFolderOk = function( value )
+{
+	if( value != "" ) {
+		var url = '?op=addBlogTemplateFolder&templateId=' + Lifetype.Dom.$( 'templateId' ).value + '&path=' + Lifetype.Dom.$( 'currentPath' ).value + '&folderName=' + value;
+		Lifetype.Forms.performUrl( url );
+	}
+}
+
 Lifetype.UI.Pages.TemplateEditor.handleCopyFileOk = function( value )
 {
 	if( value != "" ) {

Modified: plog/trunk/templates/admin/editblogtemplate.template
===================================================================
--- plog/trunk/templates/admin/editblogtemplate.template	2007-09-03 20:03:41 UTC (rev 5893)
+++ plog/trunk/templates/admin/editblogtemplate.template	2007-09-03 20:04:34 UTC (rev 5894)
@@ -7,7 +7,7 @@
 <div class="extraFunctions">
 	<div class="left">		
 		<a id="newFolderButton" href="#"
-		   onClick="Lifetype.UI.Pages.TemplateEditor.newFolderButtonHandler(this);return(false);">{$locale->tr("new_folder")}</a>&nbsp;|
+		   onClick="Lifetype.UI.Pages.TemplateEditor.newFolderButtonHandler(this,'blog');return(false);">{$locale->tr("new_folder")}</a>&nbsp;|
 		<a id="uploadFileButton" href="?op=newBlogTemplateFile" rel="overlay">{$locale->tr("upload_file")}</a>
 	</div>
 	<div class="right">
@@ -18,6 +18,7 @@
 {/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-03 20:03:41 UTC (rev 5893)
+++ plog/trunk/templates/admin/edittemplate_table.template	2007-09-03 20:04:34 UTC (rev 5894)
@@ -1,4 +1,3 @@
-{include file="$admintemplatepath/viewvalidateajax.template"}
 <table class="info" id="templateFiles">
   <thead>
    <tr>



More information about the pLog-svn mailing list