歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 20, 2024, 02:15:36 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  手冊文件  |  LifeType英文wiki文件翻譯--plugin篇 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: LifeType英文wiki文件翻譯--plugin篇  (閱讀 15228 次)
CrazyLion
初級會員
**
文章: 53



檢視個人資料 個人網站
« 於: 十二月 05, 2005, 03:15:30 下午 »

Hello 大家好,因為自己想學習plugin的撰寫方式,所以想藉著翻譯文件的方式來順便學習。
底下是我試翻的章節,請大家幫我看看哪邊不妥,OK的話我會繼續翻下去:> 感謝

http://wiki.lifetype.net/index.php/PLog_1.0/Plugins#Plugin_structure

Plugin structure

Plugins are still stored in the plugins/ folder and there is no need to install/uninstall them before being used.

外掛程式目前仍然存放在 plugins/的資料夾中,並且你並不需要在使用前安裝或是反安裝它們。

The first change compared to the 0.3 branch is that now plugins are self contained. Prior to 1.0, the contents of the plugins/ folder was just a bunch of plugin*.class.php files but now every plugin lives inside its own folder under the main plugins folder, as in:


跟0.3版第一個相異之處就在於目前每個外掛都包含在自己的子目錄底下。1.0版之前的 plugins/目錄底下是一大堆plugin*.php的程式集合,目前則是放在它們各自的目錄底下,像是這樣:

引用
plugins/
  helloworld/
  smileys/
    icons/
    locale/
    templates/
    class/
      action/
      dao/
       view/
  ...

The locale/ and templates/ folders for a plugin *must* live under the plugin's own folder. Everything else is not strictly necessary, but advisable, as it will make it much easier to remove the plugin if (and when) needed, rather than leaving the user to hunt down files all over the plog source tree.

loale/ 和 templates/ 這兩個目錄*必須*包含在 plugin自己的目錄中。其他的目錄則是可有可無,但還是建議保留。這可以讓使用者在移除plugin時簡單許多,而不用讓使用者在lifetype 的程式結構中找尋這些檔案。

Regardin the class subfolder in the plugin main folder, it is advisable to mimic the same structure as in the main class folder. Not only because the structure looks cleaner, but also because by putting our custom action*.class.php classes in there will allow the core plugin loader to load them dynamically at run time, there will be no need to include_once(...) them at the top of our plugin*.class.php file.

plugin 主目錄底下的class子目錄方面,則是建議依照主 class的目錄結構來建立。並不只是因為這種結構看起來比較清爽,另一個原因是我們可以將主要的action*.class.php 放置在此處,這將允許核心的 plugin 載入器在執行階段動態地載入,這樣一來,我們就不需要在最高層的 plugin*.class.php 加入 include_once(...)的程式碼。

Another very important rule is that if our plugin is called "smileys", the class that extends from PluginBase and that implements the plugin's main class *must* be called *pluginsmileys.class.php* and must reside in the plugins' first level folder, and the same level than the locale/ and templates/ folder. Example:

另一個非常重要的規則則是如果我們的plugin 叫做 "smileyes",這個class 繼承 PluginBase 並且這個實做plugin的主class*必須*被命名為*pluginsmileys.class.php*,此外還必須放置在plugins 的第一層目錄底下,與locle/ 和 template/目錄相同層級。像是:

引用
plugins/
  smileys/
    pluginsmileys.class.php
    locale/
      locale_en_UK.php
    templates/
      ...
    icons/
      ...
    class/
       action/
         pluginsmileysconfigaction.class.php
         pluginsmileysupdateconfigaction.class.php
Otherwise, the plugin manager class will not be able to autoload your plugin! Developer note: there is no need to call the static method PluginManager::registerPlugin(...) at the end of our plugin class file, outside the class, to let the plugin manager know about it!

否則plugin管理程式將無法自動地載入你的plugin! 開發者注意:你並不需要呼叫靜態方法 PluginManager::registerPlugin(...)在你的pluginclass程式末尾以便讓plugin 管理程式知道。
已記錄
czly
新手見習
*
文章: 31


檢視個人資料
« 回覆文章 #1 於: 九月 19, 2007, 10:33:12 上午 »

这样的文章好,再接再厉
已記錄
頁: [1]
LifeType 中文開發論壇  |  開發  |  手冊文件  |  LifeType英文wiki文件翻譯--plugin篇 « 上篇主題 下篇主題 »
    前往: