[pLog-svn] r1243 - in plugins/trunk/templateeditor: . class/action class/view templates

mark at devel.plogworld.net mark at devel.plogworld.net
Mon Feb 28 17:12:11 GMT 2005


Author: mark
Date: 2005-02-28 17:12:11 +0000 (Mon, 28 Feb 2005)
New Revision: 1243

Added:
   plugins/trunk/templateeditor/class/action/pluginblogdeletetemplatefilesaction.class.php
   plugins/trunk/templateeditor/class/action/pluginblogdeletetemplatesetsaction.class.php
   plugins/trunk/templateeditor/class/action/pluginblogedittemplatefileaction.class.php
   plugins/trunk/templateeditor/class/action/pluginblogtemplatesetslistaction.class.php
   plugins/trunk/templateeditor/class/action/pluginblogtemplateslistaction.class.php
   plugins/trunk/templateeditor/class/action/pluginblogupdatetemplatefileaction.class.php
   plugins/trunk/templateeditor/class/view/pluginblogedittemplatefileview.class.php
   plugins/trunk/templateeditor/class/view/pluginblogtemplatesetslistview.class.php
   plugins/trunk/templateeditor/class/view/pluginblogtemplateslistview.class.php
   plugins/trunk/templateeditor/templates/blogedittemplatefile.template
   plugins/trunk/templateeditor/templates/blogtemplatesetslist.template
   plugins/trunk/templateeditor/templates/blogtemplateslist.template
Modified:
   plugins/trunk/templateeditor/class/view/pluginsitetemplatesetslistview.class.php
   plugins/trunk/templateeditor/plugintemplateeditor.class.php
Log:
blogTemplateEditor done!

Added: plugins/trunk/templateeditor/class/action/pluginblogdeletetemplatefilesaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/pluginblogdeletetemplatefilesaction.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/action/pluginblogdeletetemplatefilesaction.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,84 @@
+<?php
+    include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplateslistview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+
+    /**
+     * Removes global templates from disk.
+     */
+    class PluginBlogDeleteTemplateFilesAction extends BlogOwnerAdminAction
+    {
+        var $_templateId;
+    	var $_fileIds;
+    	var $_op;
+
+        function PluginBlogDeleteTemplateFilesAction( $actionInfo, $request )
+        {
+        	$this->BlogOwnerAdminAction( $actionInfo, $request );
+
+			$this->_templateId = $this->_request->getValue( "templateId" );
+			
+			// data validation stuff
+        	$this->_op = $actionInfo->getActionParamValue();
+        	if( $this->_op == "blogDeleteTemplateFile" )
+        		$this->registerFieldValidator( "fileId", new StringValidator());
+        	else
+        		$this->registerFieldValidator( "fileIds", new ArrayValidator());
+        	$view = new PluginBlogTemplatesListView( $this->_blogInfo , $this->_templateId);
+        	$view->setErrorMessage( $this->_locale->tr("error_no_files_selected"));
+        	$this->setValidationErrorView( $view );
+        }
+
+        function perform()
+        {
+        	if( $this->_op == "blogDeleteTemplateFile" ) {
+        		$fileId = $this->_request->getValue( "fileId" );
+        		$this->_fileIds = Array();
+        		$this->_fileIds[] = $fileId;
+        	}
+        	else
+        		$this->_fileIds = $this->_request->getValue( "fileIds" );
+
+        	// carry out the
+        	$this->_deleteFiles();
+        }
+
+        function _deleteFiles()
+        {
+        	$ts = new TemplateSetStorage();
+
+        	$errorMessage = "";
+        	$successMessage = "";
+        	$totalOk = 0;
+
+        	$ts = new TemplateSetStorage();
+            
+            $blogId = $this->_blogInfo->getId();
+            $templateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
+
+            foreach( $this->_fileIds as $fileId ) {
+                $filename = $templateFolder . $fileId;
+           		// if it's not the default, then try to really remove it from disk
+				if( !File::delete( $filename ))
+					$errorMessage .= $this->_locale->pr("error_removing_template_file", $fileId )."<br/>";
+				else {
+					$totalOk++;
+					if( $totalOk < 2 )
+						$successMessage = $this->_locale->pr("template_file_removed_ok", $fileId);
+					else
+						$successMessage = $this->_locale->pr( "template_files_removed_ok", $totalOk );
+				}
+            }
+
+            // create the view and show some feedback
+            $this->_view = new PluginBlogTemplatesListView( $this->_blogInfo, $this->_templateId );
+			if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
+			if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
+            $this->setCommonData();
+
+            return true;
+        }
+    }
+?>

Added: plugins/trunk/templateeditor/class/action/pluginblogdeletetemplatesetsaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/pluginblogdeletetemplatesetsaction.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/action/pluginblogdeletetemplatesetsaction.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,85 @@
+<?php
+    include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
+    include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplatesetslistview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+
+    /**
+     * Removes global templates from disk.
+     */
+    class PluginBlogDeleteTemplateSetsAction extends BlogOwnerAdminAction
+    {
+
+        var $_templateIds;
+        var $_op;
+
+        function PluginBlogDeleteTemplateSetsAction( $actionInfo, $request )
+        {
+            $this->BlogOwnerAdminAction( $actionInfo, $request );
+
+            // data validation stuff
+            $this->_op = $actionInfo->getActionParamValue();
+            if( $this->_op == "blogDeleteTemplateSet" )
+                $this->registerFieldValidator( "templateId", new StringValidator());
+            else
+                $this->registerFieldValidator( "templateIds", new ArrayValidator());
+            $view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
+            $view->setErrorMessage( $this->_locale->tr("error_no_templates_selected"));
+            $this->setValidationErrorView( $view );
+        }
+
+        function perform()
+        {
+            if( $this->_op == "blogDeleteTemplateSet" ) {
+                $templateId = $this->_request->getValue( "templateId" );
+                $this->_templateIds = Array();
+                $this->_templateIds[] = $templateId;
+            }
+            else
+                $this->_templateIds = $this->_request->getValue( "templateIds" );
+
+            // carry out the
+            $this->_deleteTemplates();
+        }
+
+        function _deleteTemplates()
+        {
+            $ts = new TemplateSetStorage();
+
+            $errorMessage = "";
+            $successMessage = "";
+            $totalOk = 0;
+
+            // get the id of the default template
+            $blogTemplate = $this->_blogInfo->getTemplateSet();
+
+            foreach( $this->_templateIds as $templateId ) {
+                // we can't remove the default template
+                if( $blogTemplate->getName() == $templateId ) {
+                    $errorMessage .=$this->_locale->pr( "error_template_is_current", $templateId)."<br/>";
+                }
+                else {
+                    // if it's not the default, then try to really remove it from disk
+                    if( !$ts->removeTemplate( $templateId, $this->_blogInfo->getId() ))
+                        $errorMessage .= $this->_locale->pr("error_removing_template", $templateId )."<br/>";
+                    else {
+                        $totalOk++;
+                        if( $totalOk < 2 )
+                            $successMessage = $this->_locale->pr("template_removed_ok", $templateId);
+                        else
+                            $successMessage = $this->_locale->pr( "templates_removed_ok", $totalOk );
+                    }
+                }
+            }
+
+            // create the view and show some feedback
+            $this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
+            if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
+            if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
+            $this->setCommonData();
+
+            return true;
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/templateeditor/class/action/pluginblogedittemplatefileaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/pluginblogedittemplatefileaction.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/action/pluginblogedittemplatefileaction.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,33 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogedittemplatefileview.class.php" );
+
+	/**
+	 * shows a form with the current configuration
+	 */
+	class PluginBlogEditTemplateFileAction extends BlogOwnerAdminAction
+	{
+        var $_templateId;        
+        var $_fileId;
+        var $_backupId;
+        		
+		function PluginBlogEditTemplateFileAction( $actionInfo, $request )
+		{
+			$this->BlogOwnerAdminAction( $actionInfo, $request );
+		}
+		
+		function perform()
+		{
+            $this->_templateId = $this->_request->getValue( "templateId" );
+            $this->_fileId = $this->_request->getValue( "fileId" );
+            $this->_backupId = $this->_request->getValue( "backupId" );
+            
+            $this->_view = new PluginBlogEditTemplateFileView( $this->_blogInfo, $this->_templateId, $this->_fileId, $this->_backupId );
+            
+			$this->setCommonData();
+			
+			return true;
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/templateeditor/class/action/pluginblogtemplatesetslistaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/pluginblogtemplatesetslistaction.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/action/pluginblogtemplatesetslistaction.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,26 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplatesetslistview.class.php" );
+
+	/**
+	 * shows a form with the current configuration
+	 */
+	class PluginBlogTemplateSetsListAction extends BlogOwnerAdminAction
+	{
+		
+		function PluginBlogTemplateSetsListAction( $actionInfo, $request )
+		{
+			$this->BlogOwnerAdminAction( $actionInfo, $request );
+		}
+		
+		function perform()
+		{
+            $this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
+			
+			$this->setCommonData();
+			
+			return true;
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/templateeditor/class/action/pluginblogtemplateslistaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/pluginblogtemplateslistaction.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/action/pluginblogtemplateslistaction.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,29 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplateslistview.class.php" );
+
+	/**
+	 * shows a form with the current configuration
+	 */
+	class PluginBlogTemplatesListAction extends BlogOwnerAdminAction
+	{
+        var $_templateId;
+        		
+		function PluginBlogTemplatesListAction( $actionInfo, $request )
+		{
+			$this->BlogOwnerAdminAction( $actionInfo, $request );
+		}
+		
+		function perform()
+		{
+            $this->_templateId = $this->_request->getValue( "templateId" );
+            
+            $this->_view = new PluginBlogTemplatesListView( $this->_blogInfo, $this->_templateId );
+            
+			$this->setCommonData();
+			
+			return true;
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/templateeditor/class/action/pluginblogupdatetemplatefileaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/pluginblogupdatetemplatefileaction.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/action/pluginblogupdatetemplatefileaction.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,83 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogedittemplatefileview.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplateslistview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );		
+    include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/file/myfile.class.php" );	
+    include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );	
+
+	/**
+	 * shows a form with the current configuration
+	 */
+	class PluginBlogUpdateTemplateFileAction extends BlogOwnerAdminAction
+	{
+        var $_fileContent;
+        var $_templateId;        
+        var $_fileId;
+        		
+		function PluginBlogUpdateTemplateFileAction( $actionInfo, $request )
+		{
+			$this->BlogOwnerAdminAction( $actionInfo, $request );
+			
+            $this->_templateId = $this->_request->getValue( "templateId" );
+            $this->_fileId = $this->_request->getValue( "fileId" );
+            $this->_backupId = $this->_request->getValue( "backupId" );
+
+			$this->registerFieldValidator( "fileContent", new StringValidator());
+			$this->registerFieldValidator( "templateId", new StringValidator());
+			$this->registerFieldValidator( "fileId", new StringValidator());
+			$this->registerField( "backupId" );
+
+        	$view = new PluginBlogEditTemplateFileView( $this->_blogInfo, $this->_templateId, $this->_fileId, $this->_backupId );
+        	$view->setErrorMessage( $this->_locale->tr("error_updating_template_file"));
+        	$this->setValidationErrorView( $view );
+		}
+		
+		function perform()
+		{
+			$this->_fileContent = $this->_request->getValue( "fileContent" );
+			
+			// get a list with all the specific template files 
+        	$ts = new TemplateSetStorage();
+            
+            $blogId = $this->_blogInfo->getId();
+            $templateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
+            $backupFolder = $templateFolder . "backups/";
+			if( !File::exists( $backupFolder )) {
+				File::createDir( $backupFolder );
+			}
+            
+            $fileName = $templateFolder . $this->_fileId;
+            $backupFileName = $backupFolder . $this->_fileId . "_" . time();
+            if( !File::copy($fileName,$backupFileName) ) {
+            	$this->_view = new PluginBlogEditTemplateFileView( $this->_blogInfo, $this->_templateId, $this->_fileId, $this->_backupId );
+            	$this->_view->setErrorMessage( $this->_locale->tr("error_backup_template_file"));
+                $this->setCommonData();
+                return false;            	
+            }
+            
+        	$file = new MyFile($fileName);
+        	if( !$file->isWritable() ) {
+            	$this->_view = new PluginBlogEditTemplateFileView( $this->_blogInfo, $this->_templateId, $this->_fileId, $this->_backupId );
+            	$this->_view->setErrorMessage( $this->_locale->tr("error_updating_template_file"));
+                $this->setCommonData();
+                return false;              
+            }
+            $fileContent = $file->writeFileContent( stripslashes($this->_fileContent) );
+
+			// if everything went ok...
+            $this->_session->setValue( "blogInfo", $this->_blogInfo );
+            $this->saveSession();
+            
+			$this->_view = new PluginBlogTemplatesListView( $this->_blogInfo, $this->_templateId );
+			$this->_view->setSuccessMessage( $this->_locale->tr("templateeditor_file_saved_ok"));
+			$this->setCommonData();
+			
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId());			
+            
+            return true;
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/templateeditor/class/view/pluginblogedittemplatefileview.class.php
===================================================================
--- plugins/trunk/templateeditor/class/view/pluginblogedittemplatefileview.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/view/pluginblogedittemplatefileview.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,77 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );		
+    include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/file/myfile.class.php" );
+    
+    define( "MAX_BACKUP_FILES", 5 );
+
+	/**
+	 * implements the main view of the feed reader plugin
+	 */
+	class PluginBlogEditTemplateFileView extends AdminPluginTemplatedView
+	{
+        var $_templateId;
+        var $_fileId;
+        var $_backupId;
+
+		function PluginBlogEditTemplateFileView( $blogInfo, $templateId, $fileId, $backupId )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "templateeditor", "blogedittemplatefile" );
+			
+			$this->_templateId = $templateId;
+			$this->_fileId = $fileId;
+			$this->_backupId = $backupId;
+		}
+		
+		function render()
+		{
+			// get a list with all the specific template files 
+        	$ts = new TemplateSetStorage();
+            
+            $blogId = $this->_blogInfo->getId();
+            $templateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
+            $backupFolder = $templateFolder . "backups/";
+			if( !File::exists( $backupFolder )) {
+				File::createDir( $backupFolder );
+			}
+           
+            if ( !$this->_backupId ) {
+                $filename = $templateFolder . $this->_fileId;
+            } else {
+                $filename = $backupFolder . $this->_fileId . "_" . $this->_backupId;
+            }
+            $backupFilePattern = $this->_fileId . "_*";
+
+            $bakFiles = Glob::myGlob( $backupFolder, $backupFilePattern );
+            sort($bakFiles);
+            $backupFiles = Array();
+            $backupFileCount = 0;
+            for ($i = count($bakFiles) - 1; $i >= 0; $i--) {
+                $bakFile = $bakFiles[$i];
+                if ( $backupFileCount < MAX_BACKUP_FILES ) {
+                    $bakElements = explode ( "_" ,$bakFile);
+                    $bakId = $bakElements[count($bakElements)-1];
+                    $bakTime = strftime ( "%Y/%m/%d - %H:%M:%S", $bakId );
+                    $file['time'] = $bakTime;
+                    $file['backupId'] = basename($bakId);
+                    array_push ($backupFiles, $file);
+                    $backupFileCount++;
+                } else {
+                    File::delete($bakFile);
+                }
+            }
+
+        	$file = new MyFile($filename);
+            $fileContent = $file->readFileContent();
+            
+            $this->setValue( "backupId", $this->_backupId );
+            $this->setValue( "backupFiles", $backupFiles );
+            $this->setValue( "currentTemplate", $this->_templateId );
+            $this->setValue( "currentFile", $this->_fileId );
+            $this->setValue( "fileContent", $fileContent );
+            		
+			parent::render();
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/templateeditor/class/view/pluginblogtemplatesetslistview.class.php
===================================================================
--- plugins/trunk/templateeditor/class/view/pluginblogtemplatesetslistview.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/view/pluginblogtemplatesetslistview.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,28 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/template/templatesets/templatesets.class.php" );	
+
+	/**
+	 * implements the main view of the feed reader plugin
+	 */
+	class PluginBlogTemplateSetsListView extends AdminPluginTemplatedView
+	{
+
+		function PluginBlogTemplateSetsListView( $blogInfo )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "templateeditor", "blogtemplatesetslist" );
+		}
+		
+		function render()
+		{
+			// get a list with all the global template sets
+        	$ts = new TemplateSets();
+            $blogTemplateSets = $ts->getBlogTemplateSets( $this->_blogInfo->getId(), false );
+            
+            $this->setValue( "templates", $blogTemplateSets );
+		
+			parent::render();
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/templateeditor/class/view/pluginblogtemplateslistview.class.php
===================================================================
--- plugins/trunk/templateeditor/class/view/pluginblogtemplateslistview.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/view/pluginblogtemplateslistview.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,57 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );		
+    include_once( PLOG_CLASS_PATH."class/misc/glob.class.php" );
+
+	/**
+	 * implements the main view of the feed reader plugin
+	 */
+	class PluginBlogTemplatesListView extends AdminPluginTemplatedView
+	{
+        var $_templateId;
+
+		function PluginBlogTemplatesListView( $blogInfo, $templateId )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "templateeditor", "blogtemplateslist" );
+			
+			$this->_templateId = $templateId;
+		}
+		
+		function render()
+		{
+			// get a list with all the global template sets
+        	$ts = new TemplateSets();
+            $blogTemplateSets = $ts->getBlogTemplateSets( $this->_blogInfo->getId(), false );
+
+			// get a list with all the specific template files 
+        	$ts = new TemplateSetStorage();
+            
+            $blogId = $this->_blogInfo->getId();
+            $templateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
+
+            $cssFiles = Glob::myGlob( $templateFolder, "*.css" );
+            $tplFiles = Glob::myGlob( $templateFolder, "*.template" );
+           
+            $templateFiles = Array();
+
+            foreach ($cssFiles as $cssFile) {
+                $file['name'] = basename($cssFile);
+                $file['size'] = filesize($cssFile);
+                array_push ($templateFiles, $file);
+            }
+            
+            foreach ($tplFiles as $tplFile) {
+                $file['name'] = basename($tplFile);
+                $file['size'] = filesize($tplFile);
+                array_push ($templateFiles, $file);
+            }
+
+            $this->setValue( "currentTemplate", $this->_templateId );
+            $this->setValue( "templateSets", $blogTemplateSets );
+            $this->setValue( "templateFiles", $templateFiles );
+            		
+			parent::render();
+		}
+	}
+?>
\ No newline at end of file

Modified: plugins/trunk/templateeditor/class/view/pluginsitetemplatesetslistview.class.php
===================================================================
--- plugins/trunk/templateeditor/class/view/pluginsitetemplatesetslistview.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/class/view/pluginsitetemplatesetslistview.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -21,7 +21,6 @@
             $globalTemplates = $ts->getGlobalTemplateSets();
             
             $this->setValue( "templates", $globalTemplates );
-            $this->setValue( "defaultTemplate", $ts->getDefaultTemplateSet());
 		
 			parent::render();
 		}

Modified: plugins/trunk/templateeditor/plugintemplateeditor.class.php
===================================================================
--- plugins/trunk/templateeditor/plugintemplateeditor.class.php	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/plugintemplateeditor.class.php	2005-02-28 17:12:11 UTC (rev 1243)
@@ -29,8 +29,18 @@
             $this->registerAdminAction( "siteDeleteTemplateFiles", "PluginSiteDeleteTemplateFilesAction" );
             $this->registerAdminAction( "siteEditTemplateFile", "PluginSiteEditTemplateFileAction" );
             $this->registerAdminAction( "siteUpdateTemplateFile", "PluginSiteUpdateTemplateFileAction" );
+
+            $this->registerAdminAction( "blogTemplateSetsList", "PluginBlogTemplateSetsListAction" );
+            $this->registerAdminAction( "blogDeleteTemplateSet", "PluginBlogDeleteTemplateSetsAction" );
+            $this->registerAdminAction( "blogDeleteTemplateSets", "PluginBlogDeleteTemplateSetsAction" );
+            $this->registerAdminAction( "blogTemplatesList", "PluginBlogTemplatesListAction" );
+            $this->registerAdminAction( "blogDeleteTemplateFile", "PluginBlogDeleteTemplateFilesAction" );
+            $this->registerAdminAction( "blogDeleteTemplateFiles", "PluginBlogDeleteTemplateFilesAction" );
+            $this->registerAdminAction( "blogEditTemplateFile", "PluginBlogEditTemplateFileAction" );
+            $this->registerAdminAction( "blogUpdateTemplateFile", "PluginBlogUpdateTemplateFileAction" );            
 			
 			$this->addMenuEntry( "/menu/adminSettings/Templates", "SiteTemplateEditor", "admin.php?op=siteTemplateSetsList", "SiteTemplateEditor", false, true );
+			$this->addMenuEntry( "/menu/controlCenter/manageBlogTemplates", "BlogTemplateEditor", "admin.php?op=blogTemplateSetsList", "BlogTemplateEditor", false, true );
 		}
 	}
 ?>
\ No newline at end of file

Added: plugins/trunk/templateeditor/templates/blogedittemplatefile.template
===================================================================
--- plugins/trunk/templateeditor/templates/blogedittemplatefile.template	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/templates/blogedittemplatefile.template	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,52 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=BlogTemplateEditor title=$locale->tr("BlogTemplateEditor")}
+<link rel="stylesheet" href="plugins/templateeditor/js/editor/smartyeditor.css" type="text/css" />
+{literal}
+<script type="text/javascript" src="plugins/templateeditor/js/editor/smartyeditor.js"></script>
+<script type="text/javascript">
+function MM_jumpMenu(targ,selObj,restore){ //v3.0 
+    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); 
+    if (restore) selObj.selectedIndex=0; 
+}
+</script>
+{/literal}
+<form name="blogEditTemplateFile" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_edit")}</legend>  
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"}   
+
+  <div class="field">
+   <label for="backupFile">{$locale->tr("label_backupfile")}</label>
+   <span class="required"></span>
+   <div class="formHelp">{$locale->tr("templateeditor_backupfile")}</div>
+   <select name="backupFile" id="backupFile" onChange="MM_jumpMenu('parent',this,0)">
+    <option value="">{$locale->tr("templateeditor_choose_backupfile")}</option>
+    <option value="admin.php?op=blogEditTemplateFile&amp;templateId={$currentTemplate}&amp;fileId={$currentFile}">{$locale->tr("templateeditor_currentfile")}</option>
+    {foreach from=$backupFiles item=backupFile}
+     <option value="admin.php?op=blogEditTemplateFile&amp;templateId={$currentTemplate}&amp;fileId={$currentFile}&amp;backupId={$backupFile.backupId}">{$backupFile.time}</option>
+    {/foreach}
+   </select>
+  </div>
+
+  <div class="field">
+   <label for="fileContent"><a href="?op=blogTemplatesList&amp;templateId={$currentTemplate}">{$currentTemplate}</a> &raquo; {$currentFile} {if !empty($backupId)}&raquo; {$locale->tr("templateeditor_recover_from")}: {$backupId|date_format:"%Y/%m/%d - %H:%M:%S"}{/if}</label>
+   <span class="required">*</span>
+   <div class="formHelp">{$locale->tr("templateeditor_filecontent")}</div>
+   <script type="text/javascript">var ed1 = new SmartyEditor('fileContent','ed1');</script>
+   <textarea rows="25" id="fileContent" name="fileContent" style="width:100%">{$fileContent|escape:"html"}</textarea>
+  </div>
+  
+ </fieldset>  
+
+ <div class="buttons">
+  <input type="hidden" name="templateId" value="{$currentTemplate}" />
+  <input type="hidden" name="fileId" value="{$currentFile}" />
+  <input type="hidden" name="op" value="blogUpdateTemplateFile" />
+  <input type="reset" name="{$locale->tr("reset")}" />    
+  <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+ 
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file

Added: plugins/trunk/templateeditor/templates/blogtemplatesetslist.template
===================================================================
--- plugins/trunk/templateeditor/templates/blogtemplatesetslist.template	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/templates/blogtemplatesetslist.template	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,51 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=BlogTemplateEditor title=$locale->tr("BlogTemplateEditor")}
+ <form id="blogTemplateSetsList" method="post" action="admin.php">
+ <div id="list">
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"}
+  <table class="info">
+   <thead>
+    <tr>
+      <th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('blogTemplates');" /></th>
+      <th style="width:670px;">{$locale->tr("template")}</th>
+      <th style="width:95px;">{$locale->tr("actions")}</th>
+    </tr>
+  </thead>
+  <tbody>
+  {foreach from=$templates item=blogtemplate}
+   <tr class="{cycle values="odd,even"}">
+    <td>
+       <input class="checkbox" type="checkbox" name="templateIds[{counter}]" value="{$blogtemplate->getName()}" />
+    </td>
+    <td  class="col_highlighted">
+     <a href="?op=blogTemplatesList&amp;templateId={$blogtemplate->getName()}">{$blogtemplate->getName()}</a>
+    </td>
+    <td>
+     <div class="list_action_button">
+      <a href="?op=blogTemplatesList&amp;templateId={$blogtemplate->getName()}">
+        <img src="imgs/icon_edit-16.png" alt="{$locale->tr("edit")}" />
+      </a>
+      <a href="?op=blogDeleteTemplateSet&amp;templateId={$blogtemplate->getName()}">
+        <img src="imgs/icon_delete-16.png" alt="{$locale->tr("delete")}" />
+      </a>
+	  {if $blogtemplate->hasScreenshot()}
+	    <a href="javascript:openScreenshotWindow('{$blogtemplate->getScreenshotUrl()}');">
+		  <img src="imgs/icon_image-16.png" alt="Screenshot" />
+		</a>
+	  {/if}	  
+     </div>
+    </td>
+   </tr>
+  {/foreach}
+  </tbody>
+ </table>
+ </div>
+ <div id="list_action_bar">
+   <input type="hidden" name="op" value="blogDeleteTemplateSets" class="submit" />
+   <input type="submit" name="{$locale->tr("delete")}" value="{$locale->tr("delete")}"/>
+ </div>
+ </form>
+ 
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file

Added: plugins/trunk/templateeditor/templates/blogtemplateslist.template
===================================================================
--- plugins/trunk/templateeditor/templates/blogtemplateslist.template	2005-02-28 16:09:24 UTC (rev 1242)
+++ plugins/trunk/templateeditor/templates/blogtemplateslist.template	2005-02-28 17:12:11 UTC (rev 1243)
@@ -0,0 +1,77 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=BlogTemplateEditor title=$locale->tr("BlogTemplateEditor")}
+
+<div id="list_nav_bar">
+ <div id="list_nav_select">
+  <form id="viewTemplateSets" action="admin.php" method="post">
+   <fieldset>
+    <legend>{$locale->tr("show_by")}</legend>
+    <div class="list_nav_option">
+     <label for="templateId">{$locale->tr("template")}</label>
+	 <br />
+	 <select name="templateId" id="templateId">
+      {foreach from=$templateSets item=templateSet}
+       <option value="{$templateSet->getName()}" {if $currentTemplate == $templateSet->getName()} selected="selected" {/if}>{$templateSet->getName()}</option>
+      {/foreach}
+     </select>
+    </div>
+    <div class="list_nav_option">
+     <br />
+     <input type="hidden" name="op" value="blogTemplatesList">
+     <input type="submit" name="Show" value="{$locale->tr("show")}">
+    </div>
+   </fieldset> 
+  </form> 
+ </div>
+ <br style="clear:both">
+</div>
+
+<form id="blogTemplatesList" method="post" action="admin.php">
+ <div id="list">
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"}
+  <table class="info">
+   <thead>
+    <tr>
+      <th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('templateFiles');" /></th>
+      <th style="width:520px;">{$locale->tr("file")}</th>
+      <th style="width:150px;">{$locale->tr("size")} ({$locale->tr("bytes")})</th>
+      <th style="width:95px;">{$locale->tr("actions")}</th>
+    </tr>
+  </thead>
+  <tbody>
+  {foreach from=$templateFiles item=file}
+   <tr class="{cycle values="odd,even"}">
+    <td>
+       <input class="checkbox" type="checkbox" name="fileIds[{counter}]" value="{$file.name}" />
+    </td>
+    <td  class="col_highlighted">
+     <a href="?op=blogEditTemplateFile&amp;templateId={$currentTemplate}&amp;fileId={$file.name}">{$file.name}</a>
+    </td>
+    <td>
+     {$file.size}
+    </td>    
+    <td>
+     <div class="list_action_button">
+      <a href="?op=blogEditTemplateFile&amp;templateId={$currentTemplate}&amp;fileId={$file.name}">
+        <img src="imgs/icon_edit-16.png" alt="{$locale->tr("edit")}" />
+      </a>
+      <a href="?op=blogDeleteTemplateFile&amp;templateId={$currentTemplate}&amp;fileId={$file.name}">
+        <img src="imgs/icon_delete-16.png" alt="{$locale->tr("delete")}" />
+      </a>
+     </div>
+    </td>
+   </tr>
+  {/foreach}
+  </tbody>
+ </table>
+ </div>
+ <div id="list_action_bar">
+   <input type="hidden" name="templateId" value="{$currentTemplate}" />
+   <input type="hidden" name="op" value="blogDeleteTemplateFiles" class="submit" />
+   <input type="submit" name="{$locale->tr("delete")}" value="{$locale->tr("delete")}"/>
+ </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