[pLog-svn] r1529 - in plugins/trunk/templateeditor: class/action class/view locale templates

mark at devel.plogworld.net mark at devel.plogworld.net
Wed Mar 16 15:36:31 GMT 2005


Author: mark
Date: 2005-03-16 15:36:31 +0000 (Wed, 16 Mar 2005)
New Revision: 1529

Modified:
   plugins/trunk/templateeditor/class/action/pluginblogcopytemplatesetaction.class.php
   plugins/trunk/templateeditor/class/view/pluginblogtemplatesetslistview.class.php
   plugins/trunk/templateeditor/locale/locale_en_UK.php
   plugins/trunk/templateeditor/locale/locale_zh_TW.php
   plugins/trunk/templateeditor/templates/blogtemplatesetslist.template
   plugins/trunk/templateeditor/templates/blogtemplateslist.template
   plugins/trunk/templateeditor/templates/sitetemplatesetslist.template
   plugins/trunk/templateeditor/templates/sitetemplateslist.template
Log:
Add the "copy globale template set" function to blog template editor. Now, blog user can copy the global template set to local template folder and modify by themself.

Modified: plugins/trunk/templateeditor/class/action/pluginblogcopytemplatesetaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/pluginblogcopytemplatesetaction.class.php	2005-03-16 15:22:24 UTC (rev 1528)
+++ plugins/trunk/templateeditor/class/action/pluginblogcopytemplatesetaction.class.php	2005-03-16 15:36:31 UTC (rev 1529)
@@ -13,6 +13,7 @@
 
     	var $_templateId;
     	var $_newTemplateId;
+    	var $_type;
 
         function PluginBlogCopyTemplateSetAction( $actionInfo, $request )
         {
@@ -29,38 +30,77 @@
                 $this->setCommonData();
 
                 return false;
-            }        	                
-			return true;
+            }
+            
+            $this->_type = $this->_request->getValue( "type" );
+            if( $this->_type != 1 && $this->_type != 2) {
+                $this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("templateeditor_error_templateset_type"));
+                $this->setCommonData();
+
+                return false;
+            }
+            
+            return true;
 		}        
 
         function perform()
         {
 			// get a list with all the global template sets
-        	$ts = new TemplateSets();
-            $blogTemplateSets = $ts->getBlogTemplateSets( $this->_blogInfo->getId(), false );
-            
-            foreach ($blogTemplateSets as $template) {
-                if ( $template->getName() == $this->_newTemplateId ) {
-                	$this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
-                	$this->_view->setErrorMessage( $this->_locale->tr("error_duplicate_templateset_name"));
+			if ( $this->_type == 1 ) {
+            	$ts = new TemplateSets();
+                $blogTemplateSets = $ts->getBlogTemplateSets( $this->_blogInfo->getId(), false );
+                
+                foreach ($blogTemplateSets as $template) {
+                    if ( $template->getName() == $this->_newTemplateId ) {
+                    	$this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
+                    	$this->_view->setErrorMessage( $this->_locale->tr("error_duplicate_templateset_name"));
+                        $this->setCommonData();
+                        return false;
+                    }
+                }
+    
+            	$ts = new TemplateSetStorage();
+                $blogId = $this->_blogInfo->getId();
+                $sourceTemplateFolder = $ts->getTemplateFolder($this->_templateId);
+                $newTemplateFolder = $ts->getBlogBaseTemplateFolder($blogId) . $this->_newTemplateId;
+                
+                if ( MyFile::copyDir($sourceTemplateFolder, $newTemplateFolder) ) {
+                    $ts->addTemplate($this->_newTemplateId, $blogId);
+                } else {
+                    File::deleteDir($newTemplateFolder);
+                    $this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
+                    $this->_view->setErrorMessage( $this->_locale->tr("error_copying_templateset"));
                     $this->setCommonData();
-                    return false;
+                    return false;            
                 }
-            }
-
-        	$ts = new TemplateSetStorage();
-            $blogId = $this->_blogInfo->getId();
-            $sourceTemplateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
-            $newTemplateFolder = $ts->getBlogBaseTemplateFolder($blogId) . $this->_newTemplateId;
-            
-            if ( MyFile::copyDir($sourceTemplateFolder, $newTemplateFolder) ) {
-                $ts->addTemplate($this->_newTemplateId, $blogId);
             } else {
-                File::deleteDir($newTemplateFolder);
-                $this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
-                $this->_view->setErrorMessage( $this->_locale->tr("error_copying_templateset"));
-                $this->setCommonData();
-                return false;                
+            	$ts = new TemplateSets();
+                $blogTemplateSets = $ts->getBlogTemplateSets( $this->_blogInfo->getId(), false );
+                
+                foreach ($blogTemplateSets as $template) {
+                    if ( $template->getName() == $this->_newTemplateId ) {
+                    	$this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
+                    	$this->_view->setErrorMessage( $this->_locale->tr("error_duplicate_templateset_name"));
+                        $this->setCommonData();
+                        return false;
+                    }
+                }
+    
+            	$ts = new TemplateSetStorage();
+                $blogId = $this->_blogInfo->getId();
+                $sourceTemplateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
+                $newTemplateFolder = $ts->getBlogBaseTemplateFolder($blogId) . $this->_newTemplateId;
+                
+                if ( MyFile::copyDir($sourceTemplateFolder, $newTemplateFolder) ) {
+                    $ts->addTemplate($this->_newTemplateId, $blogId);
+                } else {
+                    File::deleteDir($newTemplateFolder);
+                    $this->_view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
+                    $this->_view->setErrorMessage( $this->_locale->tr("error_copying_templateset"));
+                    $this->setCommonData();
+                    return false;                
+                }                
             }
 
 			// if everything went ok...

Modified: plugins/trunk/templateeditor/class/view/pluginblogtemplatesetslistview.class.php
===================================================================
--- plugins/trunk/templateeditor/class/view/pluginblogtemplatesetslistview.class.php	2005-03-16 15:22:24 UTC (rev 1528)
+++ plugins/trunk/templateeditor/class/view/pluginblogtemplatesetslistview.class.php	2005-03-16 15:36:31 UTC (rev 1529)
@@ -16,11 +16,14 @@
 		
 		function render()
 		{
-			// get a list with all the global template sets
         	$ts = new TemplateSets();
+            // get a list with all the site template sets
+            $globalTemplateSets = $ts->getGlobalTemplateSets();
+			// get a list with all the blog template sets
             $blogTemplateSets = $ts->getBlogTemplateSets( $this->_blogInfo->getId(), false );
             
-            $this->setValue( "templates", $blogTemplateSets );
+            $this->setValue( "globalTemplateSets", $globalTemplateSets );
+            $this->setValue( "blogTemplateSets", $blogTemplateSets );
 		
 			parent::render();
 		}

Modified: plugins/trunk/templateeditor/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/templateeditor/locale/locale_en_UK.php	2005-03-16 15:22:24 UTC (rev 1528)
+++ plugins/trunk/templateeditor/locale/locale_en_UK.php	2005-03-16 15:36:31 UTC (rev 1529)
@@ -21,6 +21,7 @@
 $messages["templateeditor_error_maxbackupfiles"] = "Maximum Backup Files Should > 0!";
 $messages["templateeditor_error_allowedextension"] = "Allowed extension can not be empty.";
 $messages["templateeditor_error_templatefile_name"] = 'Wrong template file name. The file name is limited to a-z, A-Z, "_", "-" and ".", space in file name is not allowed.';
+$messages["templateeditor_error_templateset_type"] = 'Wrong template set type.';
 $messages["templateeditor_error_templatefile_extension"] = "Wrong template extension.";
 $messages["error_duplicate_templatefile_name"] = "Duplicate template file name.";
 $messages["error_copying_templatefile"] = "There was an error copying template file.";

Modified: plugins/trunk/templateeditor/locale/locale_zh_TW.php
===================================================================
--- plugins/trunk/templateeditor/locale/locale_zh_TW.php	2005-03-16 15:22:24 UTC (rev 1528)
+++ plugins/trunk/templateeditor/locale/locale_zh_TW.php	2005-03-16 15:36:31 UTC (rev 1529)
@@ -21,6 +21,7 @@
 $messages["templateeditor_error_maxbackupfiles"] = "模版備份檔案儲存限制個數必須要 > 0!";
 $messages["templateeditor_error_allowedextension"] = "允許編輯的模版檔案附加檔名不可為空白。";
 $messages["templateeditor_error_templatefile_name"] = '模版檔案名稱錯誤。必須為英文字、數字、"-"、"_" 與 ".",檔案名稱中也不能有空白。';
+$messages["templateeditor_error_templateset_type"] = '模版類別錯誤';
 $messages["templateeditor_error_templatefile_extension"] = "模版檔案附加檔名錯誤。";
 $messages["error_duplicate_templatefile_name"] = "重複的模版檔案名稱。";
 $messages["error_copying_templatefile"] = "在複製模版檔案時發生錯誤。";

Modified: plugins/trunk/templateeditor/templates/blogtemplatesetslist.template
===================================================================
--- plugins/trunk/templateeditor/templates/blogtemplatesetslist.template	2005-03-16 15:22:24 UTC (rev 1528)
+++ plugins/trunk/templateeditor/templates/blogtemplatesetslist.template	2005-03-16 15:36:31 UTC (rev 1529)
@@ -23,21 +23,52 @@
   <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:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('blogTemplateSetsList');" /></th>
+      <th style="width:600px;">{$locale->tr("template")}</th>
+      <th style="width:70px;">{$locale->tr("type")}</th>
       <th style="width:95px;">{$locale->tr("actions")}</th>
     </tr>
   </thead>
   <tbody>
-  {foreach from=$templates item=blogtemplate}
+
+  {foreach from=$globalTemplateSets item=sitetemplate}
    <tr class="{cycle values="odd,even"}">
     <td>
+     <div align="center"><span style="background-color: #CCCCCC">&nbsp;&nbsp;&nbsp;</span></div>
+    </td>
+    <td  class="col_highlighted">
+     {$sitetemplate->getName()}
+    </td>
+    <td>
+     {$locale->tr("global")}
+    </td>
+    <td>
+     <div class="list_action_button">
+      <a href="?op=blogCopyTemplateSet&amp;type=1&amp;templateId={$sitetemplate->getName()}" id="{$sitetemplate->getName()}" onClick="copyTemplateSetTo(this.id)" >
+        <img src="imgs/admin/icon_copy-16.png" alt="{$locale->tr("copy")}" />
+      </a>      
+	  {if $sitetemplate->hasScreenshot()}
+	    <a href="javascript:openScreenshotWindow('{$sitetemplate->getScreenshotUrl()}');">
+		  <img src="imgs/admin/icon_image-16.png" alt="Screenshot" />
+		</a>
+	  {/if}	  
+     </div>
+    </td>
+   </tr>
+  {/foreach}  
+
+  {foreach from=$blogTemplateSets 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>
+     {$locale->tr("blog")}
+    </td>    
+    <td>
      <div class="list_action_button">
       <a href="?op=blogTemplatesList&amp;templateId={$blogtemplate->getName()}">
         <img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
@@ -45,7 +76,7 @@
       <a href="?op=blogDeleteTemplateSet&amp;templateId={$blogtemplate->getName()}">
         <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
       </a>
-      <a href="?op=blogCopyTemplateSet&amp;templateId={$blogtemplate->getName()}" id="{$blogtemplate->getName()}" onClick="copyTemplateSetTo(this.id)" >
+      <a href="?op=blogCopyTemplateSet&amp;type=2&amp;templateId={$blogtemplate->getName()}" id="{$blogtemplate->getName()}" onClick="copyTemplateSetTo(this.id)" >
         <img src="imgs/admin/icon_copy-16.png" alt="{$locale->tr("copy")}" />
       </a>       
 	  {if $blogtemplate->hasScreenshot()}
@@ -57,6 +88,7 @@
     </td>
    </tr>
   {/foreach}
+
   </tbody>
  </table>
  </div>

Modified: plugins/trunk/templateeditor/templates/blogtemplateslist.template
===================================================================
--- plugins/trunk/templateeditor/templates/blogtemplateslist.template	2005-03-16 15:22:24 UTC (rev 1528)
+++ plugins/trunk/templateeditor/templates/blogtemplateslist.template	2005-03-16 15:36:31 UTC (rev 1529)
@@ -48,7 +48,7 @@
   <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:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('blogTemplatesList');" /></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>

Modified: plugins/trunk/templateeditor/templates/sitetemplatesetslist.template
===================================================================
--- plugins/trunk/templateeditor/templates/sitetemplatesetslist.template	2005-03-16 15:22:24 UTC (rev 1528)
+++ plugins/trunk/templateeditor/templates/sitetemplatesetslist.template	2005-03-16 15:36:31 UTC (rev 1529)
@@ -23,7 +23,7 @@
   <table class="info">
    <thead>
     <tr>
-      <th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('siteTemplates');" /></th>
+      <th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('siteTemplateSetsList');" /></th>
       <th style="width:670px;">{$locale->tr("template")}</th>
       <th style="width:95px;">{$locale->tr("actions")}</th>
     </tr>

Modified: plugins/trunk/templateeditor/templates/sitetemplateslist.template
===================================================================
--- plugins/trunk/templateeditor/templates/sitetemplateslist.template	2005-03-16 15:22:24 UTC (rev 1528)
+++ plugins/trunk/templateeditor/templates/sitetemplateslist.template	2005-03-16 15:36:31 UTC (rev 1529)
@@ -48,7 +48,7 @@
   <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:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('siteTemplatesList');" /></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>




More information about the pLog-svn mailing list