*************************************************
** 本教程基于版本:Discuz! X 3.4 **
*************************************************
在之前的插件體系中,設(shè)計(jì)一個(gè)插件的最后一個(gè)步驟就是將插件導(dǎo)出為xml 文件以便安裝,如果對(duì)于沒有單獨(dú)數(shù)據(jù)表的插件來說,這樣就算是最后一步了,但是如果對(duì)于有自己的插件表,甚至還有自己的一個(gè)安裝流程的插件來說,還需要自行編輯 xml 文件,添加安裝腳本的信息,或者是添加卸載等腳本的信息。
在 Discuz!x3.4中只要插件目錄中存在 install.php 或者 uninstall.php、 upgrade.php 這些文件,那么在導(dǎo)出的時(shí)候都會(huì)自動(dòng)的在 xml 文件中生成對(duì)應(yīng)的數(shù)據(jù)。極大的方便了插件開發(fā)者。
以官方的“我的馬甲”插件為例,在 source\plugin\myrepeats 目錄下存在install.php 和 uninstall.php 兩個(gè)文件,在Discuz!X 3.4中,如果在后臺(tái)-插件-設(shè)計(jì) 我的馬甲,中點(diǎn)擊導(dǎo)出的話是不會(huì)有這兩個(gè)文件的相關(guān)信息導(dǎo)出的,在 Discuz!X 3.4 中,將會(huì)自動(dòng)在xml 文件中增加:
- <item id="installfile"><![CDATA[install.php]]></item>
- <item id="uninstallfile"><![CDATA[uninstall.php]]></item>
復(fù)制代碼
此代碼,即可完全免去手動(dòng)修改 xml 的操作了~~
分析代碼:
打開 source\admincp\admincp_plugins.php 這個(gè)文件可以看到:
- if(file_exists($plugindir.'/install.php')) {
- $pluginarray['installfile'] = 'install.php';
- }
- if(file_exists($plugindir.'/uninstall.php')) {
- $pluginarray['uninstallfile'] = 'uninstall.php';
- }
- if(file_exists($plugindir.'/upgrade.php')) {
- $pluginarray['upgradefile'] = 'upgrade.php';
- }
- if(file_exists($plugindir.'/check.php')) {
- $pluginarray['checkfile'] = 'check.php';
- }
復(fù)制代碼游客,如果您要查看本帖隱藏內(nèi)容請(qǐng) 回復(fù)
|