Joomla 3.x_component如何打包安装和卸载
2013-04-04 22:50
281 查看
本文是component的打包,与component安装和卸载相关的内容。component包内与安装卸载相关的文件就只有两个,script.php和componentname.xml。script.php是安装或卸载时运行的脚本,componentname.xml是指导安装如何进行的和包含哪些安装文件。下面就一步步建一个基本component包,例子的component名为com_example:
(1)example.xml文件,注意的是,每个文件夹下一定要有个index.html,防止目录浏览。
(2)script.php文件,类名一定要为com_componentnameInstallerScript,这里是com_exampleInstallerScript
(3)下图为目录及文件的组织,文件下载地址:
http://download.csdn.net/detail/fightingbull/5221439
辉辉
(FightingBull Studio)
欢迎转载,但请注明出处:http://blog.csdn.net/fightingbull
(1)example.xml文件,注意的是,每个文件夹下一定要有个index.html,防止目录浏览。
<?xml version="1.0" encoding="utf-8"?> <extension type="component" version="3.0" method="upgrade"> <!-- component的基本信息 --> <name>COM_EXAMPLE</name> <!-- 大写表明该项为多语言翻译项,在language的ini文件中 --> <author>Laixiang Wen</author> <version>1.0</version> <creationDate>Apirl 4, 2013</creationDate> <copyright>Copyright (C) 2013 Fighting Bull Studio. All rights reserved.</copyright> <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license> <authorEmail>fightingbull.wen@gmail.com</authorEmail> <description>COM_EXAMPLE_XML_DESCRIPTION</description> <!-- 与安装卸载有关的文件 --> <scriptfile>script.php</scriptfile><!-- 安装过程中的高级定制 --> <install> <sql> <file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file> <!-- 数据库中表的创建 --> </sql> </install> <uninstall> <sql> <file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file> <!-- 数据库中表的删除 --> </sql> </uninstall> <!--安装中拷贝的文件 --> <!-- frontend安装的文件,放到WebRoot/components/com_example下 --> <files folder="site"> <filename>index.html</filename> <filename>example.php</filename> <filename>controller.php</filename> <folder>models</folder> <folder>views</folder> <folder>controllers</folder> <folder>helpers</folder> </files> <languages folder="site"> <language tag="en-GB">language/en-GB/en-GB.com_example.ini</language> </languages> <!-- 媒体文件放置的目录 ,创建并放置到media/com_example目录--> <media destination="com_example" folder="media"> <filename>index.html</filename> <folder>images</folder> </media> <!-- backend相关的文件及设置 --> <administration> <!-- 在后台的component菜单中创建该component的菜单项 --> <menu img="class:example">COM_EXAMPLE_MENU</menu> <submenu> <!-- Note that all & must be escaped to & for the file to be valid XML and be parsed by the installer --> <menu link="option=com_example" view="links" img="class:example" alt="example/Submenu1">COM_EXAMPLE_SUBMENU_1</menu> <menu link="option=com_categories&extension=com_example" view="categories" img="class:example-cat" alt="Example/submenu2">COM_EXAMPLE_SUBMENU_2</menu> </submenu> <!-- backend安装的文件,放到WebRoot/administrator/components/com_example下 --> <files folder="admin"> <filename>index.html</filename> <filename>example.php</filename><!-- 该组件的入口文件 --> <filename>access.xml</filename><!-- 控制角色权限的文件 --> <filename>config.xml</filename><!-- 该组件的options项设置 --> <filename>controller.php</filename> <folder>controllers</folder> <folder>models</folder> <folder>views</folder> <folder>tables</folder> <folder>helpers</folder> <folder>sql</folder> </files> <languages folder="admin"> <language tag="en-GB">language/en-GB/en-GB.com_example.ini</language> <language tag="en-GB">language/en-GB/en-GB.com_example.sys.ini</language> </languages> </administration> </extension>
(2)script.php文件,类名一定要为com_componentnameInstallerScript,这里是com_exampleInstallerScript
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); /** * Script file of EXAMPLE component */ class com_exampleInstallerScript { /** * method to install the component * * @return void */ function install($parent) { // $parent is the class calling this method //$parent->getParent()->setRedirectURL('index.php?option=com_example'); } /** * method to uninstall the component * * @return void */ function uninstall($parent) { // $parent is the class calling this method echo '<p>' . JText::_('COM_EXAMPLE_UNINSTALL_TEXT') . '</p>'; } /** * method to update the component * * @return void */ function update($parent) { // $parent is the class calling this method echo '<p>' . JText::sprintf('COM_EXAMPLE_UPDATE_TEXT', $parent->get('manifest')->version) . '</p>'; } /** * method to run before an install/update/uninstall method * * @return void */ function preflight($type, $parent) { // $parent is the class calling this method // $type is the type of change (install, update or discover_install) echo '<p>' . JText::_('COM_EXAMPLE_PREFLIGHT_' . $type . '_TEXT') . '</p>'; } /** * method to run after an install/update/uninstall method * * @return void */ function postflight($type, $parent) { // $parent is the class calling this method // $type is the type of change (install, update or discover_install) echo '<p>' . JText::_('COM_EXAMPLE_POSTFLIGHT_' . $type . '_TEXT') . '</p>'; } }
(3)下图为目录及文件的组织,文件下载地址:
http://download.csdn.net/detail/fightingbull/5221439
辉辉
(FightingBull Studio)
欢迎转载,但请注明出处:http://blog.csdn.net/fightingbull
相关文章推荐
- VS2005(C#)下如何打包安装卸载程序[转]
- VS2005(C#)下如何打包安装卸载程序[转]
- vb.net如何打包exe安装文件
- C#如何打包EXE程序生成setup安装文件
- [图文]手把手教你用C#打包应用程序(安装程序)【卸载模块已添加】
- 如何安装和卸载grub(补充Ubuntu 11.04恢复grub的方法)
- VS如何打包成一个安装文件
- 如何安装或卸载DirectShow filter
- SQL Server2005、2008如何彻底删除卸载并重新安装?
- 手把手教你用C#打包应用程序(安装程序)【卸载模块已添加】
- 关于【cocos2d-X】 3.X 安卓如何打包 (我用的3.7.1) 针对第一次打包新手
- linux如何卸载自带的openJdk,并且安装jdk1.8
- Mac OS X下应该如何卸载软件和安装应用软件
- myeclipse 10 安装Fat jar打包插件以及如何使用fat打包工具
- 如何打包安装pm2
- 如何安装/卸载APK
- 手把手教你用C#打包应用程序(安装程序)【卸载模块已添加】
- linux 下如何安装卸载 .tar.gz 格式的文件
- .Net程序打包安装与卸载制作 ——怎样将.Net程序部署到没有安装.Net Framwork的机器上?(二)
- 如何卸载.vsix文件安装的Vs插件?