歡迎光臨, 訪客. 請先 登入註冊一個帳號.
三月 29, 2024, 04:25:47 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  外掛程式  |  template editor 的怪現象 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: template editor 的怪現象  (閱讀 13393 次)
lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 於: 十月 16, 2005, 09:17:30 下午 »

自從學校的 plog 實驗站被我玩死之後 吐舌頭,一直沒有時間,也提不起興趣重灌。今天在同事的催促下終於動起來了。待我調校完畢,這回一定整理一個完整的安裝文件出來。

說到安裝 template editor ,其實應該很簡單。但是這次做了一點改變,就讓 template editor 不工作了。

為了讓 templates 目錄與 pLog 程式分離,我把 templates 目錄搬到 /home/plogdata/templates ,而 pLog 裝在 /var/www/blog 。結果 template editor 給我下面的錯誤訊息:
引用
Exception message: Smarty error: (secure mode) accessing "/home/plogdata/templates/admin/header.template" is not allowed
Error code: 512
........
不得已,只好把目錄改回 ./templates 。

第二個怪地方,其實以前就發生過,即使是網站管理員要修改模版,一定要在 「模版編輯器」設定裡面先「啟動允許網誌使用者使用模版編輯器」才能使用。我不想讓 blogger 自行上傳、修改模版,得先做「啟動」再「取消啟動」才能讓網站管理員正常使用模版編輯器的編輯功能。

mark,有空看看嗎?我應該能自行搞定第二個部份,但是第一個我就完全沒概念了。
已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #1 於: 十月 17, 2005, 11:11:12 上午 »

第二個部分,應該很好改。你改好後我可以把他 commit 進 SVN。

有關第一個部分,mmm.... 那可能是 bug,你可以把 /pLog/class/template/templateservice.class.php

引用
      function _configureTemplateSettings( $t, $blogInfo, $layout = "" )
      {
         // change a few things...
            $config =& Config::getConfig();
         $tmpFolder = $config->getValue( 'temp_folder' );
         if( $blogInfo == null )
            $blogTmpFolder = $tmpFolder;
         else {
            $blogTmpFolder = $tmpFolder.'/'.$blogInfo->getId();
            if( !File::exists( $blogTmpFolder )) {
               File::createDir( $blogTmpFolder, DEFAULT_TEMPLATE_TEMP_FOLDER_PERMISSIONS );
            }
            $t->secure_dir[] = "./templates/blog_".$blogInfo->getId()."/$layout";
         }
         
            $t->cache_dir    = $blogTmpFolder;
            $t->compile_dir  = $blogTmpFolder;
         
         $t->compile_check = $config->getValue( 'template_compile_check' );

         return $t;
      }

改成

引用
      function _configureTemplateSettings( $t, $blogInfo, $layout = "" )
      {
         // change a few things...
            $config =& Config::getConfig();
         $tmpFolder = $config->getValue( 'temp_folder' );
         if( $blogInfo == null )
            $blogTmpFolder = $tmpFolder;
         else {
            $blogTmpFolder = $tmpFolder.'/'.$blogInfo->getId();
            if( !File::exists( $blogTmpFolder )) {
               File::createDir( $blogTmpFolder, DEFAULT_TEMPLATE_TEMP_FOLDER_PERMISSIONS );
            }
            $baseTemplateFolder = TemplateSetStorage::getBaseTemplateFolder();
            $localTemplateFolder  = $baseTemplateFolder.'/'.BLOG_BASE_TEMPLATE_FOLDER.$blogInfo->getId().'/'.$layout;
            $t->secure_dir[] = $localTemplateFolder;


         }
         
            $t->cache_dir    = $blogTmpFolder;
            $t->compile_dir  = $blogTmpFolder;
         
         $t->compile_check = $config->getValue( 'template_compile_check' );

         return $t;
      }

這是我在腦海中模擬的,還沒試過。請你試試看。

Mark
已記錄

lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #2 於: 十月 17, 2005, 12:58:37 下午 »

第二個部分,應該很好改。你改好後我可以把他 commit 進 SVN。

有關第一個部分,mmm.... 那可能是 bug,你可以把 /pLog/class/template/templateservice.class.php

引用
略..........

改成

引用
      function _configureTemplateSettings( $t, $blogInfo, $layout = "" )
      {
         // change a few things...
            $config =& Config::getConfig();
         $tmpFolder = $config->getValue( 'temp_folder' );
         if( $blogInfo == null )
            $blogTmpFolder = $tmpFolder;
         else {
            $blogTmpFolder = $tmpFolder.'/'.$blogInfo->getId();
            if( !File::exists( $blogTmpFolder )) {
               File::createDir( $blogTmpFolder, DEFAULT_TEMPLATE_TEMP_FOLDER_PERMISSIONS );
            }
            $baseTemplateFolder = TemplateSetStorage::getBaseTemplateFolder();
            $localTemplateFolder  = $baseTemplateFolder.'/'.BLOG_BASE_TEMPLATE_FOLDER.$blogInfo->getId().'/'.$layout;
            $t->secure_dir[] = $localTemplateFolder;


         }
         
            $t->cache_dir    = $blogTmpFolder;
            $t->compile_dir  = $blogTmpFolder;
         
         $t->compile_check = $config->getValue( 'template_compile_check' );

         return $t;
      }

這是我在腦海中模擬的,還沒試過。請你試試看。

Mark
Mark:

第二個部份我空我會處理,第一個部份確定是bug,你提供的程式碼可以修正這個錯誤,但是還有一個地方也要加:
引用
      function _configureTemplateSettings( $t, $blogInfo, $layout = "" )
      {
         // change a few things...
            $config =& Config::getConfig();
         $tmpFolder = $config->getValue( 'temp_folder' );
         if( $blogInfo == null ){
            $blogTmpFolder = $tmpFolder;
            $baseTemplateFolder = TemplateSetStorage::getBaseTemplateFolder();
            $localTemplateFolder  = $baseTemplateFolder.'/'.BLOG_BASE_TEMPLATE_FOLDER.$blogInfo->getId().'/'.$layout;
            $t->secure_dir[] = $localTemplateFolder;

         }
         else {
            $blogTmpFolder = $tmpFolder.'/'.$blogInfo->getId();
            if( !File::exists( $blogTmpFolder )) {
               File::createDir( $blogTmpFolder, DEFAULT_TEMPLATE_TEMP_FOLDER_PERMISSIONS );
            }
            $baseTemplateFolder = TemplateSetStorage::getBaseTemplateFolder();
            $localTemplateFolder  = $baseTemplateFolder.'/'.BLOG_BASE_TEMPLATE_FOLDER.$blogInfo->getId().'/'.$layout;
            $t->secure_dir[] = $localTemplateFolder;


         }
         
            $t->cache_dir    = $blogTmpFolder;
            $t->compile_dir  = $blogTmpFolder;
         
         $t->compile_check = $config->getValue( 'template_compile_check' );

         return $t;
      }
你加的紅色部份是用戶自訂樣版的目錄,全站樣版目錄也要有相對的程式碼(藍色部份)才行。
mmm....藍色部份我試過沒問題,紅色部份我還沒試,不過應該也可以運作才是。

謝謝啦!
« 最後編輯時間: 十月 17, 2005, 01:09:22 下午 由 lss » 已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #3 於: 十月 17, 2005, 01:29:22 下午 »

mmm ... 藍色那部分應該不要加,因為那要在 /pLog/class/template/template.class.php 的 Template() 裡面來設定才對。呵呵!你真的每次都能找到 Bug 耶!

程式碼:
Line 82: $this->secure_dir = Array( "./templates/admin", "./templates/" );

Oscar 把他寫死在程式裡面了。

Mark
已記錄

lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #4 於: 十月 17, 2005, 03:55:34 下午 »

那來的及在加入 1.0.2 正式版嗎?  微笑 微笑
已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #5 於: 十月 18, 2005, 10:17:25 上午 »

那來的及在加入 1.0.2 正式版嗎?  微笑 微笑

呵呵,等一下就改。

Mark
已記錄

lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #6 於: 十一月 01, 2005, 07:52:34 下午 »

今天找到了時間,回頭關心一下找到的 template editor 問題。

關於前面提到的第二部份:剛安裝好的 template editor ,即使是 admin 也無法編輯,必需先 啟動 允許使用者編輯模版後再 取消啟用 才能讓 admin 使用的這個部份已經抓到問題了。因為剛安裝好的 plugin 沒有把 plugin_templateeditor_allowedextension 設定值加到 blog config 裡面,所以任何副檔名的檔案都是 不可編輯的

我在 plugintemplateeditor.class.php 裡面的 第19行後 加了下面幾行:
程式碼:
            $pluginAllowedExtensions = $config->getValue( "plugin_templateeditor_allowedextension" );
            if( empty( $pluginAllowedExtensions )){
                        $config->saveValue( "plugin_templateeditor_allowedextension", "css,inc,template,txt" );
                }
在 pllugin 執行時先檢查 plugin_templateeditor_allowedextension 是否已設定,若沒有,就加上預設值。

在我的 LifeType 站已經試過可行。

Mark,這純粹是頭痛醫頭,腳痛醫腳的方式,你看看能不能用。
已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #7 於: 十一月 27, 2005, 05:38:34 下午 »

Hi lss:

我已經找到這個問題了。這是因為裝好後 ValidExtension 還未存在 Settings 中,所以才會造成全域模版篇及器無法編輯。已經修正了,晚一些為 commit 上去。

Mark

已記錄

markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #8 於: 十一月 27, 2005, 06:37:39 下午 »

已經在 SVN rev. 2645 修復了。

Mark
已記錄

lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #9 於: 十一月 27, 2005, 09:23:13 下午 »

mark:

我最後還是把樣版目錄放回 ./templates 了。因為還有很多問題無法克服:
1.樣版的預覽和模版編輯器裡的圖片預覽都會失效,因為核心程式裡傳回的路徑都是用 $baseUrl/{template_path} 的方式。
2.連 getTemplateFile 傳回的路徑也是,結果會連 css 檔都找不到。

第 1 點還好,可以比照 resserver.php 的方式處理,但是目前我想不到什麼方法來克服第2點,所以放棄了。
已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
頁: [1]
LifeType 中文開發論壇  |  開發  |  外掛程式  |  template editor 的怪現象 « 上篇主題 下篇主題 »
    前往: