Skip to content

Instantly share code, notes, and snippets.

@eddieajau
Created January 28, 2013 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eddieajau/4652141 to your computer and use it in GitHub Desktop.
Save eddieajau/4652141 to your computer and use it in GitHub Desktop.
Eclipse snippet category for packaging Joomla extensions. Includes: Basic installer class, SQL installation file header, XML installation supplement, XML administrator files, XML build file. Updated 2013-01-24
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1311161288555" initial_state="1" label="Packaging" largeicon="" smallicon="">
<description><![CDATA[Snippets to assist with creating extension packages for distribution.]]></description>
<item category="category_1311161288555" class="" editorclass="" id="item_1311161491543" label="Basic installer class" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[The basic installer class that can be created in a installer.php file in the main directory of the extension.]]></description>
<content><![CDATA[/**
* @package ${PACKAGE}
* @subpackage ${SUBPACKAGE}
* @since ${SINCE}
*/
class Com_${NAME}InstallerScript
{
/**
* Runs after files are installed and database scripts executed.
*
* @param JInstaller $parent The installer object.
*
* @return void
*
* @since ${SINCE}
*/
function install($parent)
{
// Add custom code.
}
/**
* Runs after files are removed and database scripts executed.
*
* @param JInstaller $parent The installer object.
*
* @return void
*
* @since ${SINCE}
*/
function uninstall($parent)
{
// Add custom code.
}
/**
* Runs after files are updated and database scripts executed.
*
* @param JInstaller $parent The installer object.
*
* @return void
*
* @since ${SINCE}
*/
function update($parent)
{
// Add custom code.
}
/**
* Runs before anything is run.
*
* @param string $type The type of installation: install|update.
* @param JInstaller $parent The installer object.
*
* @return void
*
* @since ${SINCE}
*/
function preflight($type, $parent)
{
// Add custom code.
}
/**
* Runs after an extension install or update.
*
* @param string $type The type of installation: install|update.
* @param JInstaller $parent The installer object.
*
* @return void
*
* @since ${SINCE}
*/
function postflight($type, $parent)
{
// Add custom code.
// Note: this file is executed in the tmp folder if using the upload method.
}
}
]]></content>
<variable default="" id="name_1" name="PACKAGE">
<description><![CDATA[The API package.]]></description>
</variable>
<variable default="" id="name_2" name="SUBPACKAGE">
<description><![CDATA[The API subpackage.]]></description>
</variable>
<variable default="" id="name_3" name="NAME">
<description><![CDATA[The proper case name of the component (without com_).]]></description>
</variable>
<variable default="1.0" id="name_4" name="SINCE">
<description><![CDATA[The version this feature was added.]]></description>
</variable>
</item>
<item category="category_1311161288555" class="" editorclass="" id="item_1311161993123" label="SQL installation file header" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[A basic header for the SQL install and uninstall file.]]></description>
<content><![CDATA[-- <?php defined('_JEXEC') or die ?>;
]]></content>
</item>
<item category="category_1311161288555" class="" editorclass="" id="item_1311162144845" label="XML installation supplement" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[XML tags for the installer and SQL files.]]></description>
<content><![CDATA[ <scriptfile>installer.php</scriptfile>
<install>
<sql>
<file charset="utf8" driver="mysql">sql/installsql.mysql.utf8.php</file>
</sql>
</install>
<uninstall>
<sql>
<file charset="utf8" driver="mysql">sql/uninstallsql.mysql.utf8.php</file>
</sql>
</uninstall>
<media destination="com_${NAME}" folder="media">
<folder>css</folder>
<folder>images</folder>
<filename>index.html</filename>
</media>
]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The lower case name of the component (without com_)]]></description>
</variable>
</item>
<item category="category_1311161288555" class="" editorclass="" id="item_1311162252754" label="XML administrator files" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[An additional snippet for the XML manifest file that defines the typical administrator files, menu and submenu.]]></description>
<content><![CDATA[ <administration>
<files folder="${FOLDER}">
<folder>controllers</folder>
<folder>helpers</folder>
<folder>language</folder>
<folder>models</folder>
<folder>sql</folder>
<folder>tables</folder>
<folder>views</folder>
<filename>access.xml</filename>
<filename>config.xml</filename>
<filename>controller.php</filename>
<filename>index.html</filename>
<filename>installer.php</filename>
<filename>${NAME}.php</filename>
</files>
<menu img="../media/com_hello/images/hello_16x16.png"
link="option=com_${NAME}">${TITLE}</menu>
<submenu>
<menu img="../media/com_hello/images/hello_16x16.png"
link="option=com_${NAME}">${TITLE}</menu>
<menu img="class:category"
link="option=com_categories&amp;extension=com_${NAME}">JCATEGORIES</menu>
</submenu>
</administration>
]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The lower case name of the component (without com_)]]></description>
</variable>
<variable default="" id="name_2" name="TITLE">
<description><![CDATA[The upper case title for the administrator menu (typically the upper case component folder).]]></description>
</variable>
<variable default="" id="name_3" name="FOLDER">
<description><![CDATA[The sub-folder for the administrator files in the installation package.]]></description>
</variable>
</item>
<item category="category_1311161288555" class="" editorclass="" id="item_1315900413309" label="XML build file" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[An XML Phing file (similar to an Ant script) that automatically builds the extension package.]]></description>
<content><![CDATA[<?xml version="1.0" ?>
<project
name="Builds the ${NAME} installable extension package."
basedir="."
default="main">
<property
name="package"
value="${NAME}"
override="true" />
<property
name="targetdir"
value="."
override="true" />
<!--
Usage:
1. Standard build
$ phing
2. Build and rename files with version
$ phing -Dpackage.version=1.0.1
-->
<!-- MAIN -->
<target name="main" description="Creates an extension build file">
<!-- Cleanup build area -->
<delete dir="${targetdir}/package" />
<mkdir dir="${targetdir}/package" />
<!-- Add the admin component -->
<phingcall target="build">
<property name="extpath" value="administrator/components/com_${NAME}" />
<property name="extname" value="com_${NAME}" />
<property name="extsub" value="admin" />
</phingcall>
</target>
<target name="build" description="Packages the extension for delivery">
<!-- Switch to tell this task to make the zip files. Default is on. -->
<if>
<not>
<isset property="build" />
</not>
<then>
<property name="build" value="1" />
</then>
</if>
<!-- Option to include the version number in the final file names. -->
<if>
<not>
<isset property="package.version" />
</not>
<then>
<property name="package.version" value="master" />
</then>
</if>
<!-- The following options are for picking up the right files/folders. -->
<if>
<not>
<isset property="extname" />
</not>
<then>
<property name="extname" value="" />
</then>
</if>
<if>
<not>
<isset property="extsub" />
</not>
<then>
<property name="extsub" value="" />
</then>
</if>
<if>
<not>
<isset property="extfile" />
</not>
<then>
<property name="extfile" value="" />
</then>
</if>
<!-- Check if the target folder exists. If not, create it -->
<if>
<not>
<available file="${targetdir}/package/${extname}/${extsub}" type="dir" />
</not>
<then>
<mkdir dir="${targetdir}/package/${extname}/${extsub}" />
</then>
</if>
<!-- Copy the source files to the target folder -->
<copy todir="${targetdir}/package/${extname}/${extsub}${extfile}">
<fileset dir="${extpath}">
<include name="**" />
<exclude name=".*" />
</fileset>
</copy>
<!-- Special case for components. Put the XML file in the correct place -->
<if>
<available file="${targetdir}/package/${extname}/${extsub}/${package}.xml" type="file" />
<then>
<copy
file="${targetdir}/package/${extname}/${extsub}/${package}.xml"
tofile="${targetdir}/package/${extname}/${package}.xml" overwrite="true" />
<delete
file="${targetdir}/package/${extname}/${extsub}/${package}.xml" />
</then>
</if>
<if>
<available file="${targetdir}/package/${extname}/${extsub}/installer.php" type="file" />
<then>
<copy
file="${targetdir}/package/${extname}/${extsub}/installer.php"
tofile="${targetdir}/package/${extname}/installer.php" overwrite="true" />
<delete
file="${targetdir}/package/${extname}/${extsub}/installer.php" />
</then>
</if>
<if>
<equals arg1="${build}" arg2="1" />
<then>
<delete file="${targetdir}/package/${extname}.${package.version}.tar.gz" />
<tar
destfile="${targetdir}/package/${extname}.${package.version}.tar.gz"
basedir="${targetdir}/package/${extname}"
includeEmptyDirs="0"
compression="gzip">
<fileset dir="${targetdir}/package/${extname}">
<include name="**" />
<exclude name=".*" />
</fileset>
</tar>
<delete file="${targetdir}/package/${extname}.${package.version}.zip" />
<zip
destfile="${targetdir}/package/${extname}.${package.version}.zip"
basedir="${targetdir}/package/${extname}">
<fileset dir="${targetdir}/package/${extname}">
<include name="**" />
<exclude name=".*" />
</fileset>
</zip>
</then>
</if>
</target>
</project>
]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The lower case name of the extension (without any prefix).]]></description>
</variable>
</item>
</category>
</snippets>
@bjtox
Copy link

bjtox commented Apr 1, 2014

hi can you explain mi how can import this file on my eclipse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment