DiscuzX3x模板插件開發(fā)制作教程_第1頁
DiscuzX3x模板插件開發(fā)制作教程_第2頁
DiscuzX3x模板插件開發(fā)制作教程_第3頁
DiscuzX3x模板插件開發(fā)制作教程_第4頁
DiscuzX3x模板插件開發(fā)制作教程_第5頁
已閱讀5頁,還剩30頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

一、開發(fā)插件所需資料與工具1、DiscuzX3插件機制插件機制Discuz!擁有一套完整的插件機制。合理使用插件機制,你可以更好的將自己的個性功能需求整合到Discuz!產(chǎn)品中的同時,保持代碼獨立,并且不受后續(xù)Discuz!產(chǎn)品版本升級的影響。我們鼓勵并推薦,使用插件機制進行個性需求定制和研發(fā)。插件設計的準備工作插件實現(xiàn)流程開始編寫社區(qū)插件,您應當首先對插件實現(xiàn)的流程有一個大致的了解,以下是我們推薦的插件編寫流程:?熟練使用Discuz!社區(qū)系統(tǒng)后,對希望完善或補充的個性化功能進行評估,進而提出插件的功能需求。?對插件做一個概括性的設計,例如:需要使用什么菜單、什么參數(shù),配置哪些選項、數(shù)據(jù)結(jié)構(gòu)如何設計、前后臺實現(xiàn)哪些功能等等。?閱讀本文檔并在系統(tǒng)設置中實際體驗Discuz!插件接口所實現(xiàn)的功用,例如:您的插件應當如何設計才能良好的掛接到社區(qū)系統(tǒng)中來。插件接口能夠?qū)崿F(xiàn)哪些功能、不能實現(xiàn)哪些功能,插件為此而需要做的優(yōu)化、改造和取舍。?編寫相應程序代碼和模板語句,實現(xiàn)所需的功能并進行代碼測試、兼容性測試和代碼改進。?如果需要公開您的插件,可以用插件導出的方式,將插件配置信息導出到一個XML文件中,連同相應的程序和模板文件一同打包。同時,編寫一個適合新手的插件的說明書也是必不可少的,其中包括:插件適用的Discuz!版本、功能概述、兼容性聲明、安裝方法、使用方法、卸載方法等等。?將插件提供給他人,或自己使用,根據(jù)使用者反饋,對插件進行完善。插件實現(xiàn)流程至此結(jié)束。?文件命名規(guī)范Discuz!按照如下的規(guī)范對程序和模板進行命名,請在設計插件時盡量遵循此命名規(guī)范:?可以直接通過瀏覽器訪問的普通程序文件,以.php后綴命名。?被普通程序文件引用的程序文件,以.inc.php后綴命名。?被普通程序文件,或引用程序文件引用的函數(shù)庫或類庫,以.func.php(函數(shù)庫)或.class.php(類庫)后綴命名。?模板文件,以.htm后綴命名,插件模板文件存在于source/plugin/identifie/template/目錄中,手機版插件模板存在于source/plugin/identifiei/template/mobile/目錄中?模板語言包文件,以.lang.php后綴命名,插件語言包文件開發(fā)時存放于data/plugindata/目錄中,文件名為identifierlang.php。?動態(tài)緩存文件,存放于./data/cache目錄中,依據(jù)不同的功用進行獨立的命名。?使用后臺數(shù)據(jù)備份功能生成的備份文件,通常以.sql為后綴,存放于data/目錄中。?有些目錄中存在內(nèi)容為空白的index.htm文件,此類文件是為了避免Web服務器打開DirectoryIndex時可能產(chǎn)生的安全問題。?[X2.5新增內(nèi)容]從Discuz!X2.5開始,產(chǎn)品對數(shù)據(jù)表進行了封裝,封裝后的文件統(tǒng)一命名為Table類,通過“C::t(Table類文件名)”方式調(diào)用。插件如需封裝自己的數(shù)據(jù)表,可將Table類文件存放于source/plugin/identifier/table/目錄下,并以table—表名.php格式命名,詳見X2.5的新程序架構(gòu)。?class_core.php模塊功能白皮書source/class/class_core.php是Discuz!的通用初始化模塊程序,其幾乎被所有的外部代碼所引用,在您開始插件設計之前,可以先對該模塊的大致功能做一定的了解。class_core.php主要完成了以下任務:?對不同PHP及操作系統(tǒng)環(huán)境做了判斷和兼容性處理,使得Discuz!可以運行于各種不同配置的服務器環(huán)境下。?初始化常量IN_DISCUZ為TRUE,用于include或require后續(xù)程序的判斷,避免其他程序被非法引用。?讀取社區(qū)程序所在絕對路徑,存放于常量DISCUZ_ROOT中。?加載所需的基本函數(shù)庫source/function/function_core.php。?通過config/config_global.php中提供的數(shù)據(jù)庫賬號信息,建立數(shù)據(jù)庫連接。 Discuz!支持數(shù)據(jù)表的前綴,如需獲得表的全名,可使用“DB::table('tablename')”方式。?判斷用戶是否登錄,如登錄標記$_G['uid']為非0,同時將$_G['username'](加了addslashes的用戶名,可用于不加修改的插入數(shù)據(jù)庫)、$_G['member']['username'](原始的用戶名,可用于頁面顯示)、$_G['member']['password'](用戶密碼的MD5串)等相應用戶信息賦值,其他用戶信息存放于$_G['member'],更多信息可通過“getuserprofile()”獲取。?判斷用戶管理權(quán)限,將管理權(quán)限標記$_G['adminid']為1~3中間的值。0代表普通用戶;1代表論壇管理員;2代表超級版主;3代表論壇版主。將用戶權(quán)限按照其所在的主用戶組ID標記為$_G['groupid'],相關(guān)權(quán)限從該$_G['groupid']所對應的系統(tǒng)緩存中讀出,存放于$_G['group']。?預置讀入了每個模塊的各種設置變量。?[X2.5變更內(nèi)容]$_G['username']將不進行addslashes處理。插件接口概述使用管理員賬號登錄Discuz!管理中心,在頂部菜單將可以看到“插件”菜單?!安寮斜怼绷谐隽怂幸寻惭b的插件,是控制插件打開與否、設計插件模塊、菜單、參數(shù)和使用權(quán)限的地方,插件開發(fā)者可以依照設計意圖,在此進行插件的初步設置,這里同時也提供插件導入和插件開關(guān)的功能,用于導入他人設計的插件和對插件的可用狀態(tài)進行變更。開始編寫一個新插件,請首先打開config/config_global.php文件,在文件結(jié)尾添加以下代碼開啟插件設計者模式。?$_config['plugindeveloper']=1;在插件管理中選擇“設計新插件”,填寫插件名稱,名稱用于表明此插件的用途,例如設置為'虛擬銀行插件”。惟一標識符用于在后續(xù)的插件模塊中調(diào)用本插件,不可與現(xiàn)有插件重復,命名規(guī)則限制與PHP變量命名相同,雖然初次設置后仍可改動,但強烈建議一次性將此配置設置好,否則可能涉及到很多代碼方面的變更,增加編碼的麻煩。請注意:惟一標識符請不要設置的過短,或使用有可能與其他插件重復的命名,例如制作此插件的公司叫做ComsenzInc.,插件名稱是“虛擬銀行插件”,惟一標識符可設置為“comsenz_virtual_bank”。最后在source/plugin/目錄中創(chuàng)建與唯一標識符同名的目錄名,如source/plugin/comsenz_virtual_bank/。在插件管理中添加插件后,僅僅是增加了一條插件記錄,后面還需要很多相關(guān)的設計和設置。在列表中選擇插件的'詳情”進入插件的詳細設置。插件設置分為三個部分:?插件模塊插件模塊分為程序鏈接、擴展項目和程序腳本3類:程序鏈接主導航項目:可在主導航欄增加一個菜單項,可自主指派菜單鏈接的URL,也可以調(diào)用插件的一個模塊,模塊文件名指派為source/plugin/插件目錄/插件模塊名.inc.php”。注意:由于引用外部程序,因此即便設置了模塊的使用等級,您的程序仍需進行判斷使用等級是否合法。?程序鏈接主導航項目-插件菜單:可在主導航欄的插件子菜單中增加一個菜單項。?程序鏈接頂部導航項目、底部導航項目、快捷導航項目、家園導航項目:可在各個導航中增加一個菜單項。?擴展項目個人設置:可在個人設置中增加一個菜單項。?擴展項目個人設置-個人資料:可在個人設置的個人資料頁上部增加一個菜單項。?擴展項目個人設置-積分:可在個人設置的積分頁上部增加一個菜單項。?擴展項目站點幫助:可在站點幫助中增加一個菜單項。?擴展項目我的帖子:可在我的帖子中增加一個菜單項。?擴展項目門戶管理:可在門戶管理面板上部增加一個菜單項。?擴展項目論壇管理-基本:可在前臺論壇管理面板側(cè)邊上部增加一個菜單項。?擴展項目論壇管理-工具:可在前臺論壇管理面板側(cè)邊下部增加一個菜單項。?擴展項目管理中心:可在后臺插件欄目中為此插件增添一個管理模塊。?程序腳本頁面嵌入-普通版:設置一個包含頁面嵌入腳本的模塊,該模塊用于在普通電腦訪問的頁面顯示。模塊文件名指派為source/plugin/插件目錄/插件模塊名.class.php”。(頁面嵌入將在后面的《頁面嵌入模塊開發(fā)》中詳細說明)?程序腳本頁面嵌入-手機版:設置一個包含頁面嵌入腳本的模塊,該模塊用于在手機訪問的頁面顯示。?程序腳本特殊主題:設置一個特殊主題腳本的模塊,模塊文件名指派為source/plugin/插件目錄/插件模塊名.class.php”。(特殊主題將在后面的《特殊主題模塊開發(fā)》中詳細說明)?您可以為每個模塊設置不同的使用等級,例如設置為“超級版主”,則超級版主及更高的管理者可以使用此模塊。擴展項目模塊可以在社區(qū)的特定位置擴展出新的功能,通常用于擴展新的設置項目。項目的腳本文件以.inc.php結(jié)尾(如test.inc.php),模版為固定文件名,位于插件目錄的template/子目錄中,文件名與腳本名同名(如test.htm),擴展名為.htm。添加相應的擴展項目模塊時,需注明程序模塊、菜單名稱。例如我們添加個人面板項目,程序模塊為test,菜單名稱是“測試”,當插件啟用后,個人面板即家園的設置中會出現(xiàn)“測試”拓展項目。在新插件內(nèi)核中,通過plugin.php方式訪問的插件可直接通過plugin.php?id=xxx:yyy方式調(diào)用而無需再在后臺定義為普通腳本模塊,只要source/plugin/xxx/yyy.inc.php文件存在即可。如果xxx和yyy同名,可直接通過plugin.php?id=xxx方式訪問。插件變量配置插件接口中提供了一個通用的插件配置管理程序,在大多數(shù)情況下可實現(xiàn)插件的參數(shù)配置,省卻了插件開發(fā)者自行編寫后臺管理模塊(即上面提到的“擴展項目管理中心”模塊)的麻煩。通常情況下,應優(yōu)先使用通用插件配置管理程序來實現(xiàn)插件的參數(shù)配置,只有在通用程序確實無法實現(xiàn)時,才自行編寫后臺管理模塊。輸入配置名稱和配置變量名、選擇合適的配置類型后,即可為此插件增加一個配置變量,點'詳情”可以編輯此配置變量的更多信息。為了方便插件程序調(diào)用使用者配置好的參數(shù),配置變量同樣被存放在了緩存文件中,讀取方法將在后面的《插件的參數(shù)讀取與緩存控制》中詳細說明。注意:您只有在插件管理中將插件設置為“可用”,以上設置才能生效。插件的參數(shù)讀取與緩存控制?編寫插件程序時,可能需要讀取一些插件的信息,如果插件需要使用者進行配置,還需要讀取使用者設置的參數(shù)值。Discuz!允許插件程序使用數(shù)據(jù)庫讀取和緩存讀取這兩種方法獲取插件信息和參數(shù)。Discuz!的插件接口已經(jīng)對插件信息進行了合理的緩存,使用緩存讀取的方式,將比數(shù)據(jù)庫讀取速度更快,消耗的資源更是幾乎可以忽略不計。緩存讀取唯一的局限是需要插件使用插件接口提供的通用后臺管理程序。如果使用自定義后臺模塊的方式,需要后臺模塊將參數(shù)存放到pluginvars數(shù)據(jù)表中,才能被系統(tǒng)正常緩存。我們強烈推薦您通過緩存讀取插件信息和配置數(shù)據(jù)。?由于調(diào)用系統(tǒng)緩存統(tǒng)一通過Toadcache?!焙瘮?shù)調(diào)用,并存放于$_G['cache']中,因此Toadcache('plugin')”后插件的變量緩會存放于$_G['cache']['plugin']中。嵌入點插件和以plugin.php為主腳本調(diào)用的插件無需加載此緩存,系統(tǒng)已自動加載了緩存。變量配置類型為“版塊/*”的變量會保存在$_G['cache']['forums'][fid]['plugin']中。變量配置類型為“用戶組/*”的變量會保存在$_G['cache']['usergroup_groupid']['plugin']和$_G['group']['plugin']中。頁面嵌入模塊開發(fā)頁面嵌入類型腳本格式<?php//全局嵌入點類(必須存在)classplugin_identifier{functionHookId_1(){return...;}functionHookId_2(){return...;} }//腳本嵌入點類classplugin_identifier_CURSCRIPTextendsplugin_identifier{functionHookId_1(){return...;}functionHookId_2(){return...;}......}?>plugin_?普通版腳本中的類名以plugin_開頭。手機版腳本中的類名以mobileplugin_開頭。identifier?插件的唯一標識符,在插件設置中設置。CURSCRIPT?嵌入點位于的腳本名,如forum.php為forum。HookId函數(shù)名調(diào)用位置聲明位置參數(shù)含義HookId;)所有模塊執(zhí)行前被調(diào)用腳本嵌入點類HookId_output($value)模塊執(zhí)行完畢,模板輸出前被調(diào)用腳本嵌入點類$value:array('template'=>當前要輸出的模版,'message'=>showmessage的信息內(nèi)容,'values'=>showmessage的信息變量,)global_HookIc()模塊執(zhí)行完畢,模板輸出前被調(diào)用全局嵌入點類HookId_message($value)showmessage()執(zhí)行時調(diào)用腳本嵌入點類$value:array('param'=>showmessage()函數(shù)的參數(shù)數(shù)組,)ad_adId($value)相應的廣告位中調(diào)用函數(shù)名為廣告位腳本ID如:ad_headerbanner()全局嵌入點類腳本嵌入點類$value:array('params'=>廣告位參數(shù),'content'=>當前廣告位原本將要顯示的內(nèi)容,)

common()所有模塊執(zhí)行前被調(diào)用全局嵌入點類discuzcode($value)discuzcode()函數(shù)執(zhí)行時調(diào)用用于在帖子內(nèi)容解析時嵌入自己的功能,函數(shù)中$_G['discuzcodemessage']變量為待解析的字串全局嵌入點類$value:array('param'=>caller函數(shù)的參數(shù)數(shù)組,'caller'=>caller函數(shù),此嵌入點被哪個函數(shù)調(diào)用'discuzcode'被discuzcode()調(diào)用'messagecutstr'被messagecutstr()調(diào)用)deletethread($value)deletethread()函數(shù)執(zhí)行時調(diào)用用于在主題刪除前后嵌入自己的功能,此函數(shù)將在deletethread()中被調(diào)用2次,函數(shù)中$_G['deletethreadtids']變量為待處理的TID數(shù)組全局嵌入點類$value:array('param'=>deletethread()函數(shù)的參數(shù)數(shù)組,'step'=>刪除的步驟'check'檢測步驟'delete'刪除步驟)deletepost($value)deletepost()函數(shù)執(zhí)行時調(diào)用用于在帖子刪除前后嵌入自己的功能,此函數(shù)將在deletepost()中被調(diào)用2次,函數(shù)中$_G['deletepostids']變量為待處理的ID數(shù)組全局嵌入點類$value:array('param'=>deletepost()函數(shù)的參數(shù)數(shù)組,'step'=>刪除的步驟'check'檢測步驟'delete'刪除步驟)avatar($value)(X2.5新增)avatar()函數(shù)執(zhí)行時調(diào)用用于在頭像調(diào)用時嵌入自己的功能,函數(shù)中$_G['hookavatar']變量為新頭像返回值全局嵌入點類$value:array('param'=>avatar()函數(shù)的參數(shù)數(shù)組)profile_node($post,$start,$end)(X3.0新增)貼內(nèi)用戶信息標記,返回值為標記顯示內(nèi)容全局嵌入點類$post:當前帖子信息數(shù)組$start:用戶填寫的前置字符$end:用戶填寫的后置字符要查看所有的預定義嵌入點,請打開config/config_global.php文件,將文件結(jié)尾添加的設計者模式值改成“2”,然后更新緩存即可。在頁面源碼中查找"<hook>"可搜索到嵌入點。(詳細內(nèi)容可參閱的《插件嵌入點列表》)$_config['plugindeveloper']=2;預定義的嵌入點會在頁面預置好的位置輸出函數(shù)返回的內(nèi)容。函數(shù)返回值類型如果是array且是空值的,必須輸出一個空數(shù)組,如:returnarray();函數(shù)名并不限于以上列表,您可以自定義,只要符合以下規(guī)則,函數(shù)就會在適當?shù)牡胤奖徽{(diào)用。functionCURMODULE_USERDEFINE[_output]()CURMODULE指明了此函數(shù)在哪個模塊執(zhí)行,可通過常量CURMODULE得到當前頁面的CURMODULE值。USERDEFINE可自定義,如果函數(shù)名以“_output”結(jié)尾則會在模板輸出前調(diào)用,否則會在模塊執(zhí)行前調(diào)用。如:attachment_test()函數(shù)會在論壇的下載附件的時候執(zhí)行。"_output”結(jié)尾的函數(shù)的第一個參數(shù)為數(shù)組,含義為array('template'=>要輸出的模板名,'message'=>showmessage的文字)如:以下函數(shù)將在登錄的時候輸出調(diào)試文字functionlogging_test_output($a){print_r($a);print_r($_POST);}plugin_identifier類中的其它函數(shù)為了便于閱讀建議以“_”開頭,如:<?phpclassplugin_sample{function_updatecache(){return...;}}classplugin_sample_forumextendsplugin_sample{functionviewthread_posttop(){return...;}.....}?>插件嵌入點列表-全局(common/)extcredits.htmstringspacecp_credit_extrafaq.htmstringfaq_extrafooter.htmstringglobal_footerstringglobal_footerlinkheader.htmstringglobal_cpnav_top(X2.5)stringglobal_cpnav_extra1stringglobal_cpnav_extra2stringglobal_qmenu_top(X3)stringglobal_qmenu_bottom(X3)stringglobal_nav_extra(X2.5)stringglobal_headeruserabout.htmarrayglobal_userabout_topstringuserapp_menu_topstringuserapp_menu_middlearrayglobal_userabout_bottomuserstatus.htmstringglobal_usernav_extralstringglobal_usernav_extra2stringglobal_usernav_extra3stringglobal_usernav_extra4(X2.5)-論壇(forum/)collection_all.htm(X2.5)stringcollectionjndex_topstringcollection_index_bottomcollection_comment.htm(X2.5)stringcollection_nav_extracollection_index.htm(X2.5)stringcollectionjndex_topstringcollection_index_bottomcollection_mycollection.htm(X2.5)stringcollectionjndex_topstringcollection_index_bottomcollection_nav.htm(X2.5)stringcollection_nav_extracollection_view.htm(X2.5)stringcollection_viewoptionsstringcollection_view_topstringcollection_threadlistbottomstringcollection_relatedopstringco11ection_view_bottomstringcollection_side_bottomdiscuz.htmstringindex_status_extrastringindex_nav_extra(X2.5)stringindex_topstringindex_catlist_top(X2.5)arrayindex_followcollection_extra(X3)arrayindex_favforum_extra(X2.5)arrayindex_favforum_extra(X3)arrayindex_catlist(X2.5)arrayindex_forum_extra(X2.5)arrayindex_forum_extra(X2.5)arrayindex_datacollection_extra(X3)stringindex_middlestringindex_bottomstringindex_side_topstringindex_side_bottomdiscuzcode.htmarrayviewthread_attach_extra(X2.5)editor_menu_forum.htmstringpost_image_btn_extrastringpost_image_tab_extrastringpost_attach_btn_extrastringpost_attach_tab_extraforumdisplay.htmstringforumdisplay_leftside_topstringforumdisplay_leftside_bottomstringforumdisplay_forumactionstringforumdisplay_modlinkstringforumdisplay_topstringforumdisplay_middlestringforumdisplay_postbutton_topstringforumdisplay_threadtype_inner(X2.5)stringforumdisplay_filter_extra(X2.5)stringforumdisplay_threadtype_extra(X2.5)stringforumdisplay_bottomstringforumdisplay_side_topstringforumdisplay_side_bottomforumdisplay_fastpost.htmstringforumdisplay_fastpost_contentstringforumdisplay_fastpost_func_extrastringforumdisplay_fastpost_ctrl_extrastringglobal_login_textstringforumdisplay_fastpost_upload_extend(X3)stringforumdisplay_fastpost_btn_extrastringforumdisplay_fastpost_sync_methodforumdisplay_list.htmstringforumdisplay_filter_extraarrayforumdisplay_threadarrayforumdisplay_thread_subject(X2.5)arrayforumdisplay_authorarrayforumdisplay_thread(X2.5)arrayforumdisplay_author(X2.5)stringforumdisplay_threadlist_bottom(X2.5)stringforumdisplay_postbutton_bottomforumdisplay_sort.htm(X2.5)stringforumdisplay_postbutton_bottomforumdisplay_subforum.htm(X2.5)arrayforumdisplay_subforum_extraarrayforumdisplay_subforum_extraguide.htmstringguide_nav_extrastringguide_topstringguide_bottomindex_navbar.htmstringindex_navbarpost.htmstringpost_topstringpost_middlestringpost_btn_extrastringpost_sync_methodstringpost_bottomstringpost_upload_extend(X3)post_activity.htmstringpost_activity_extrapost_debate.htmstringpost_debate_extrapost_editor_attribute.htm(X3)stringpost_attribute_extrastringpost_attribute_extra_bodypost_editor_body.htmstringpost_editorctrl_rightstringpost_editorctrl_leftstringpost_editorctrl_topstringpost_editorctrl_bottompost_infloat.htmstringpost_infloat_topstringpost_infloat_middlestringpost_infloat_btn_extrapost_poll.htmstringpost_poll_extrastringpost_poll_upload_extend(X3)post_reward.htmstringpost_reward_extrapost_trade.htmstringpost_trade_extratopicadmin_modlayer.htmstringforumdisplay_modlayerstringmodcp_modlayertrade_info.htmstringviewthread_tradeinfo_extraviewthread.htmstringviewthread_topstringviewthread_postbutton_topstringviewthread_modoptionstringviewthread_beginline(X2.5)stringviewthread_title_extrastringviewthread_title_rowstringviewthread_middlestringviewthread_bottomviewthread_activity.htmstringviewthread_activity_extra1stringviewthread_activity_extra2viewthread_album.htm(X3)stringviewthread_beginlinestringviewthread_useraction_prefixstringviewthread_useractionstringviewthread_bottomviewthread_fastpost.htmstringviewthread_fastpost_sidestringviewthread_fastpost_contentstringviewthread_fastpost_func_extrastringviewthread_fastpost_ctrl_extrastringglobal_login_textstringviewthread_fastpost_upload_extend(X3)stringviewthread_fastpost_btn_extra(X2.5)viewthread_from_node.htmarrayviewthread_postheaderarrayviewthread_postheaderarrayviewthread_postheaderarrayviewthread_endlineviewthread_node.htmarrayviewthread_profiIesidearrayviewthreadjmiconsarrayviewthread_magic_userarrayviewthread_avatararrayviewthread_sidetoparrayviewthread_sidebottomarrayviewthread_postheaderstringviewthread_modaction(X2.5)stringviewthread_share_methodstringviewthread_useractionarrayviewthread_postsightmIafter(X2.5)arrayviewthread_postfooterarrayviewthread_postaction(X2.5)stringviewthread_magic_threadarrayviewthread_magic_postarrayviewthread_endlineviewthread_node_body.htmarrayviewthread_posttopstringglobal_login_textarrayviewthread_postbottomviewthread_poll.htmstringviewthread_poll_topstringviewthread_polLbottomviewthread_portal.htmstringviewthread_useraction_prefixstringviewthread_useractionstringviewthread_side_bottomviewthread_preview_node.htm(X3)arrayviewthread_postheaderarrayviewthread_endlineviewthread_trade.htmarrayviewthread_trade_extra-群組(group/)group.htmstringgroup_navlinkstringforumdisplay_navlinkstringgroup_navlinkstringforumdisplay_navlinkstringgroup_topstringforumdisplay_topstringgroup_nav_extrastringforumdisplay_nav_extrastringgroup_bottomstringforumdisplay_bottomstringgroup_side_bottomstringforumdisplay_side_bottomgroup_list.htmstringforumdisplay_postbutton_topstringforumdisplay_filter_extraarrayforumdisplay_threadstringforumdisplay_postbutton_bottomgroup_my.htmstringmy_headerstringmy_bottomstringmy_side_topstringmy_side_bottomgroup_right.htmstringgroup_index_sidestringgroup_side_topstringforumdisplay_side_topindex.htmstringindex_headerstringindex_topstringindex_bottomstringindex_side_topstringindex_side_bottomtype.htmstringindex_toparrayindex_groupliststringindex_bottomstringindex_side_topstringindex_side_bottom-家園(home/)editor_image_menu.htm(X3)stringspacecp_blog_upload_extendstringportalcp_top_upload_extendfollow_feed.htmstringfollow_nav_extrastringfollow_topstringfollow_upload_extend(X3)stringfollow_nav_extra(X3)spacecp_avatar.htmstringspacecp_avatar_topstringspacecp_avatar_bottomspacecp_blog.htmstringspacecp_blog_topstringspacecp_blog_middlestringspacecp_blog_bottomspacecp_credit_base.htmstringspacecp_credit_topstringspacecp_credit_extrastringspacecp_credit_bottomspacecp_creditjog.htmstringspacecp_credit_topstringspacecp_credit_bottomspacecp_privacy.htmstringspacecp_privacy_topstringspacecp_privacy_base_extrastringspacecp_privacy_feed_extrastringspacecp_privacy_bottomspacecp_profile.htmstringspacecp_profile_topstringspacecp_profile_extrastringspacecp_profile_bottomspacecp_promotion.htmstringspacecp_promotion_topstringspacecp_promotion_bottomspacecp_upload.htm(X3)stringspacecp_upload_extendspacecp_usergroup.htmstringspacecp_usergroup_topstringspacecp_usergroup_bottomstringspacecp_usergroup_topstringspacecp_usergroup_bottomstringspacecp_usergroup_topstringspacecp_usergroup_bottomspace_album_pic.htmstringspace_album_pic_topstringspace_album_pic_op_extrastringspace_album_pic_bottomstringspace_album_pic_face_extraspace_album_view.htmstringspace_album_op_extraspace_blog_list.htmarrayspace_blog_list_statusspace_blog_view.htmstringspace_blog_titlestringspace_blog_share_method(X2.5)stringspace_blog_op_extrastringspace_blog_face_extraspace_card.htmstringspace_card_topstringspace_card_baseinfo_middlestringspace_card_baseinfo_bottomstringspace_card_optionstringspace_card_magic_userstringspace_card_bottomspace_commentji.htmarrayglobal_space_comment_op(X3)stringglobal_comment_bottom(X3)space_doing.htmstringspace_doing_topstringspace_doing_bottomspace_favorite.htmstringspace_favorite_nav_extraspace_friend.htmstringspace_interaction_extraspace_header.htmstringglobal_usernav_extralstringglobal_usernav_extra2space_home.htmstringspace_home_navlink(X3)stringspace_home_side_top(X2.5)stringspace_home_side_bottomstringspace_home_topstringspace_home_navlinkstringspace_home_bottomspace_magic.htm(X2.5)stringmagic_nav_extraspace_medal.htm(X2.5)stringmedal_nav_extraspace_menu.htmstringspace_menu_extraspace_profile_body.htmstringspace_profile_baseinfo_topstringfollow_profile_baseinfo_top(X2.5)stringspace_profile_baseinfo_middlestringfollow_profile_baseinfo_middle(X2.5)stringspace_profile_baseinfo_bottomstringfollow_profile_baseinfo_bottom(X2.5)stringspace_profile_extrainfostringfollow_profile_extrainfo(X2.5)space_share_li.htmarrayspace_share_comment_opspace_status.htmstringspace_home_doing_sync_methodspace_wall.htmstringspace_wall_face_extra?注冊/登錄(member/)login.htmstringlogging_side_topstringlogging_topstringloggingjnputstringlogging_methodlogin_simple.htmstringglobal_login_extraregister.htmstringregister_side_topstringregister_topstringregisterjnputstringregister_logging_methodstringregister_bottom■門戶(portal/)portalcp_article.htmstringportalcp_topstringportalcp_extendstringportalcp_middlestringportalcp_bottomview.htmstringview_article_top(X2.5)stringview_article_subtitle(X2.5)stringview_article_summary(X2.5)stringview_article_content(X2.5)stringview_share_methodstringview_article_op_extra(X2.5)stringview_article_side_top(X2.5)stringview_article_side_bottom(X2.5)-排行榜(ranklist/)side_left.htmstringranklist_nav_extra-搜索(search/)album.htmstringalbum_topstringalbum_bottomblog.htmstringblog_topstringblog_bottomcollection.htm(X3)stringcollection_topstringcollection_bottomfooter.htmstringglobal_footerstringglobal_footerlinkforum.htmstringforum_topstringforum_bottomgroup.htmstringgroup_topstringgroup_bottomheader.htmstringglobal_usernav_extralstringglobal_usernav_extra2portal.htmstringportal_topstringportal_bottom-應用(userapp/)userapp_app.htmstringuserapp_app_topstringuserapp_app_bottomuserapp_index.htmstringuserapp_index_topstringuserapp_index_bottomuserapp_menu_list.htmstringuserapp_menu_topstringuserapp_menu_middlestringuserapp_menu_bottom-手機全局(mobile/common/)footer.htmstringglobal_footer_mobileheader.htmstringglobal_header_mobile-手機論壇(mobile/forum/)discuz.htmstringindex_top_mobilestringindex_middle_mobilestringindex_bottom_mobileforumdisplay.htmstringforumdisplay_top_mobilearrayforumdisplay_thread_mobilestringforumdisplay_bottom_mobileviewthread.htmstringviewthread_top_mobilearrayviewthread_posttop_mobilearrayviewthread_postbottom_mobilestringviewthread_bottom_mobiIe-手機論壇(wml/forum/)discuz.htmstringindex_top_mobilestringindex_middle_mobileforumdisplay.htmstringforumdisplay_top_mobilearrayforumdisplay_thread_mobilestringforumdisplay_bottom_mobileviewthread.htmstringviewthread_top_mobilearrayviewthread_posttop_mobilearrayviewthread_postbottom_mobilestringviewthread_bottom_mobiIe特殊主題模塊開發(fā)特殊主題模塊用于創(chuàng)建一個特殊主題,特殊主題類型腳本格式<?phpclassthreadpluginjdentifier{var$name='XX主題';〃主題類型名稱var$iconfile='icon.gif;〃發(fā)布主題鏈接中的前綴圖標var$buttontext='發(fā)布xx主題';〃發(fā)帖時按鈕文字functionnewthread($fid){return}functionnewthread_submit($fid){}functionnewthread_submit_end($fid,$tid){}functioneditpost($fid,$tid){return}functioneditpost_submit($fid,$tid){}functioneditpost_submit_end($fid,$tid){}functionnewreply_submit_end($fid,$tid){}functionviewthread($tid){return...;}}?>identifier插件的唯一標識符,在插件設置中設置。函數(shù)名以及含義函數(shù)名含義newthread()發(fā)主題時頁面新增的表單項目,通過return返回即可輸出到發(fā)帖頁面中newthread_submit()主題發(fā)布后的數(shù)據(jù)判斷newthread_submit_end()主題發(fā)布后的數(shù)據(jù)處理editpost()編輯主題時頁面新增的表單項目,通過return返回即可輸出到編輯主題頁面中editpost_submit()主題編輯后的數(shù)據(jù)判斷editpost_submit_end()主題編輯后的數(shù)據(jù)處理newreply_submit_end()回帖后的數(shù)據(jù)處理viewthread()查看主題時頁面新增的內(nèi)容,通過return返回即可輸出到主題首貼頁面中第三方拓展類的開發(fā)目錄[隱藏]?1廣告類2道具類3任務類4驗證問答類5驗證碼類(Discuz!X2.5新增)廣告類腳本位置:source/class/adv/adv_name.php語言包位置:source/language/adv/lang_name.php【Discuz!X3.0新增】腳本位置:source/plugin/插件目錄/adv/.php縮略圖:source/plugin/插件目錄/adv/adv_name.gif<?phpclassadv_name{var$version='1.0';//腳本版本號var$name='name';//廣告類型名稱(可填寫語言包項目)var$description='desc'y/廣告類型說明(可填寫語言包項目)var$copyright='ComsenzInc.';//版權(quán)(可填寫語言包項目)var$targets=array('portal','home','member','forum','group','userapp','plugin','custom');//廣告類型適用的投放范圍var$imagesizes=array('120x60','120x240');//圖片廣告推薦大小functiongetsetting(){//返回設置項目$settings=array('text'=>array('title'=>'text_title',//設置項目名稱(可填寫語言項目)'type'=>'mradio',//項目類型'value'=>array(),〃項目選項'default'=>0,//項目默認值));return$settings;}functionsetsetting(&$advnew,&$parameters){//保存設置項目}functionevalcode(){//廣告顯示時的運行代碼returnarray(〃檢測廣告是否投放時的代碼'check'=>'if(condition){$checked=false;}',〃廣告顯示時的代碼(隨機調(diào)用投放的廣告)'create'=>'$adcode=$codes[$adids[array_rand($adids)]];',);}}?>道具類腳本位置:source/class/magic/magic_name.php語言包位置:source/language/magic/lang_name.php【Discuz!X3.0新增】腳本位置:source/plugin/插件目錄/magic/.php圖標:source/plugin/插件目錄/magic/magic_name.small.gif、source/plugin/插件目錄/magic/magic_name.gif<?phpclassmagic_name{var$version='1.0';//腳本版本號var$name='name';//道具名稱(可填寫語言包項目)var$description='desc';//道具說明(可填寫語言包項目)var$price='10';//道具默認價格var$weight='10';//道具默認重量var$copyright='ComsenzInc.';//版權(quán)(可填寫語言包項目)functiongetsetting(){//返回設置項目$settings=array('text'=>array('title'=>'text_title',//設置項目名稱(可填寫語言項目)'type'=>'mradio',//項目類型'value'=>array(),〃項目選項'default'=>0,//項目默認值));return$settings;}functionsetsetting(&$advnew,&$parameters){//保存設置項目}functionusesubmit($magic,$parameters){//道具使用}functionshow($magic){//道具顯示}}?>任務類腳本位置:source/class/task/task_name.php語言包位置:source/language/task/lang_name.php【Discuz!X3.0新增】腳本位置:source/plugin/插件目錄/task/.php圖標:source/plugin/插件目錄/task/.gif<?phpclasstask_name{var$version='1.0';//腳本版本號var$name='name';//任務名稱(可填寫語言包項目)var$description='desc';//任務說明(可填寫語言包項目)var$copyright='ComsenzInc.';//版權(quán)(可填寫語言包項目)var$icon=〃〃默認圖標var$period='';//默認任務間隔周期var$periodtype=0;//默認任務間隔周期單位var$conditions=array(〃任務附加條件'text'=>array('title'=>'text_title',//設置項目名稱(可填寫語言項目)'type'=>'mradio',//項目類型'value'=>array(),〃項目選項'default'=>0,//項目默認值'sort'=>'complete',//條件類型(apply:申請任務條件complete:完成任務條件)),);functionpreprocess($task){//申請任務成功后的附加處理}functioncsc($task=array。){/判斷任務是否完成(返回TRUE:成功FALSE:失敗0:任務進行中進度未知或尚未開始大于0的正數(shù):任務進行中返回任務進度)}functionsufprocess($task){//完成任務后的附加處理}functionview($task,$taskvars){//任務顯示}functioninstall(){//任務安裝的附加處理}functionuninstall。{//任務卸載的附加處理}functionupgrade(){//任務升級的附加處理}}?>驗證問答類腳本位置:source/class/secqaa/secqaa_name.php語言包位置:source/language/secqaa/lang_name.php【Discuz!X3.0新增】腳本位置:source/plugin/插件目錄/secqaa/.php<?phpclasssecqaa_name{var$version='1.0';//腳本版本號var$name='name';//驗證問答名稱(可填寫語言包項目)var$description='desc';//驗證問答說明(可填寫語言包項目)var$copyright='ComsenzInc.';//版權(quán)(可填寫語言包項目)functionmake(&$question){//返回安全問答的答案和問題($question為問題,函數(shù)返回值為答案)}}?>驗證碼類(Discuz!X2.5新增)腳本位置:source/class/seccode/seccode_name.php語言包位置:source/language/seccode/lang_name.php【Discuz!X3.0新增】腳本位置:source/plugin/插件目錄/seccode/seccode_name.php<?phpclassseccode_name{var$version='1.0';//腳本版本號var$name='name';//驗證碼類型名稱(可填寫語言包項目)var$copyright='ComsenzInc.';//版權(quán)(可填寫語言包項目)var$setting=array();//后臺設置后的變量functioncheck($value,$idhash){〃檢查輸入的驗證碼,返回true表示通過}functionmake(){〃輸出驗證碼,echo輸出內(nèi)容將顯示在頁面中}}?>計劃任務模塊開發(fā)?本功能為Discuz!X3.0新增內(nèi)容?計劃任務模塊用于拓展一個計劃任務項目,本模塊會在插件安裝時自動添加到系統(tǒng)計劃任務中,并在插件卸載時自動從中刪除腳本位置:source/plugin/插件目錄/cron/cron_name.php<?php//cronname:mycron計劃任務名稱,可寫腳本語言包中的項目//week:1設置星期幾執(zhí)行本任務,留空為不限制//day:1設置哪一日執(zhí)行本任務,留空為不限制//hour:1設置哪一小時執(zhí)行本任務,留空為不限制//minute:0,30設置哪些分鐘執(zhí)行本任務,至多可以設置12個分鐘值,多個值之間用半角逗號","隔開,留空為不限制if(!defined('IN_DISCUZ')){exit('AccessDenied');}//您的計劃任務腳本內(nèi)容?〉緩存更新模塊開發(fā)?本功能為Discuz!X3.0新增內(nèi)容?緩存更新模塊用于在系統(tǒng)更新緩存時拓展一個緩存更新項目腳本位置:source/plugin/插件目錄/cache/.php<?phpif(!defined('IN_DISCUZ')){exit('AccessDenied');}functionbuild_cache_plugin_name(){〃您的緩存更新腳本內(nèi)容}?>插件安裝、卸載、升級腳本的設計目錄[隱藏]?1安裝、卸載2升級3檢測4授權(quán)協(xié)議、插件介紹5Discuz!版本兼容性設置6其他論壇數(shù)據(jù)導入7小提示安裝、卸載插件作者可以設計2個腳本文件用于插件的安裝和卸載,文件名任意。腳本中可用runquery()函數(shù)執(zhí)行SQL語句,表名可以直接寫“cdb_”。插件作者只需在導出的XML文件結(jié)尾加上安裝、卸載腳本的文件名即可<itemid="installfile"><![CDATA[install.php]]></item><itemid="uninstallfile"><![CDATA[uninstall.php]]></item></item></root>安裝、卸載程序中可隨意設計頁面的跳轉(zhuǎn),只要在插件安裝、卸載結(jié)束時候輸出添加以下代碼即可。$finish=TRUE;升級插件作者可以設計一個腳本文件用于插件的升級,文件名任意。腳本中可用runquery()函數(shù)執(zhí)行SQL語句,表名可以直接寫“cdb_”。插件作者只需在導出的XML文件結(jié)尾加上升級腳本的文件名即可<itemid="upgradefile"><![CDATA[upgrade.php]]></item></item></root>升級程序中可通過$fromversion和$toversion變量判斷升級的具體版本號,并隨意設計頁面的跳轉(zhuǎn),只要在插件升級結(jié)束時候輸出添加以下代碼即可。$finish=TRUE;插件的當前版本號位于XML文件的以下分支中,可自行更改。<itemid="plugin"><itemid="version"><![CDATA[當前版本]]></item></item>檢測插件作者可以設計一個腳本文件用于插件在安裝、卸載、升級操作前的檢測,文件名任意。插件作者只需在導出的XML文件結(jié)尾加上檢測腳本的文件名即可<itemid="checkfile"><![CDATA[check.php]]></item></item> </root>授權(quán)協(xié)議、插件介紹插件在安裝的時候您可以自定義授權(quán)信息文本,文本支持Discuz!代碼,站長同意后才能安裝插件。如果插件存在后臺管理界面或者變量配置,那么插件介紹文本會顯示在插件后臺頁面中。插件作者只需在導出的XML文件結(jié)尾加上以下內(nèi)容即可<itemid="license"><![CDATA[授權(quán)協(xié)議文本]]></item><itemid="intro"><![CDATA[插件介紹文本]]></item></item> </root>Discuz!版本兼容性設置請仔細檢查您的插件是否可以在相應的Discuz!版本中運行。然后在XML文件的以下分支中自行更改。如您的插件兼容多個版本,請用逗號■(,)分隔,如“X2,X2.5”(此寫法從Discuz!X2R20120329后開始支持)<itemid="Data"><itemid="plugin"></item><itemid="version"><![CDATA[兼容性設置]]></item></item>其他論壇數(shù)據(jù)導入插件安裝時可以直接導入一個或多個論壇數(shù)據(jù),這些論壇數(shù)據(jù)包括表情(smilies)、風格(styles)的數(shù)據(jù)。在導出的XML文件結(jié)尾加上需要導入數(shù)據(jù)的類型和數(shù)據(jù)文件名即可,多個文件名用逗號(",”)分隔。<itemid="importfile"><itemid="smilies"><![CDATA[discuz_smilies_test.xml]]></item><itemid="styles"><![CDATA[discuz_styles_test.xml]]></item></item></item> </root>小提示如果導出的XML文件名以SC_GBK、SC_UTF8、TC_BIG5、TC_UTF8結(jié)尾,顯示的時候?qū)⒅苯语@示為“簡體”、“繁體”、“UTF8”等字樣。插件模板和語言包的設計插件語言包創(chuàng)建語言包給插件創(chuàng)建語言包首先需要創(chuàng)建一個data/plugindata/identifier.lang.php文件,文件內(nèi)容中包含4個數(shù)組,如下:<?php$scriptlang['identifier']=array('english'=>'chinese',...);$templatelang['identifier']=array('english'=>'chinese',...);$installlang['identifier']=array('english'=>'Chinese',...);$systemlang['identifier']=array('file'=>array('english'=>'Chinese',...),...);?>$scriptlang為程序腳本文件的語言包。$templatelang為模版文件的語言包。$installlang為安裝、升級、卸載腳本用的語言包。$systemlang為系統(tǒng)語言包(Discuz!X3新增)。如果插件不涉及某些類型的語言文字,變量可忽略。然后在插件基本設置中開啟語言包選項后即可。調(diào)用語言包模版中調(diào)用模板文件語言包,通過{langidentifierenglish}方式調(diào)用。程序腳本中調(diào)用腳本文件語言包,通過lang('plugin/identifier;'english')方式調(diào)用。安裝腳本中調(diào)用安裝腳本文件語言包,通過$installlang變量直接獲取。如$installlang['english']。系統(tǒng)語言包用于替換系統(tǒng)語言包中的某些語言條目。語言包導出創(chuàng)建好的語言包在插件導出后會自動導出到XML文件中,供插件作者轉(zhuǎn)碼后發(fā)放多編碼版本的插件。如上例中導出的XML中會包含以下內(nèi)容:<itemid="language"><itemid="scriptlang"><itemid="english"><![CDATA[chinese]]></item></item><itemid="templatelang"><itemid="english"><![CDATA[chinese]]></item></item><itemid="installlang"><itemid="english"><![CDATA[chinese]]></item></item><itemid="systemlang"><itemid="file"><itemid="english"><![CDATA[chinese]]></item></item></item></item>data/plugindata/identifierlang.php文件不必在插件發(fā)布的時候?qū)С?,此文件僅供插件設計者模式時使用。插件模板插件的模板統(tǒng)一放置到source/plugin/identifie/template目錄下,程序腳本通過以下語句調(diào)用插件模板文件,如下例,調(diào)用source/plugin/identifie/template/test.htmincludetemplate('identifier:test');模版中調(diào)用插件模版通過以下方法

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論