Extension Creator app

Running Joomla component

All extensions are split up into tasks, which are each run separately. In the above execution of a sample Joomla component, first the language files are created via the language task, and then the main set of files are created via the main task. A task can be created for each MVC in the Joomla component, thereby signficantly reducing the amount of code that needs to be written. We finally note that after each Joomla extension is run, in addition to creating/updating files in the Output folder, a ZIP file is created in the Archives folder which could then be installed in Joomla.

Joomla component parameter file

Each extension has a corresponding XML file which tells the program how to generate the output. The program runs the tasks which are specified in the XML file. The following XML code creates a simple Joomla component.


<?xml version="1.0" encoding="utf-8"?>
<extension title="Joomla Component">
  <parameters>
	<loadTemplate from="joomla/component_j3.x.xml" select="component/parameters/*" />
	<component>
	  <!-- If name is not specified, it is auto-generated using the nameType parameter. -->
	  <label>Listing</label>
	  <!-- The description is optional and defaults to the name (not yet implemented)-->
	  <description>Lists articles from a category.</description>
	  <!-- Currently the default view for the back end. -->
	  <defaultView>listing</defaultView>
	  <joomlaVersion>3.2.0</joomlaVersion>
	</component>
  </parameters>
  <tasks>
	<!-- Order matters, the tasks are run in the order seen here. -->
	<!-- Language files need to go first, so the other files can add to them. -->
	<task name="Language" />
	<task name="Main" />
	<task name="MVC">
		<parameters>
			<nameObject>listing</nameObject>
		</parameters>
	</task>
   </tasks>
  <loadTemplate from="joomla/component_j3.x.xml" select="component/taskDefinitions" />
</extension>

The extension XML file also contains parameters which are used by the program. The first set of parameters, such as label, are extension wide, which means they can always be accessed. There are also task specific parmaeters, which can be accessed while a given task is running. In the example above, the MVC task uses the nameObject parameter.

The loadTemplate tags allow selecting XML from other files via XPath queries.

Custom tasks, such as the BasicBackend Task, could be created, which allows one to create a basic MVC for the administrator from a remote MySQL database.

Joomla component file structure

The program output is also specified in an XML file. Each task, such as language, has files associated with it. The output file names can use parameters from the extension's XML file using placeholders as shown below.

<?xml version="1.0" encoding="UTF-8"?>
<templateFiles>
	<!-- If this archive already exists in the archiveDirectory it will be overwritten. -->
	<ArchiveName>com_<%= StrConv(Value("Extension.name"), VbStrConv.Lowercase) %>-<%= Value("Extension.version") %>.zip</ArchiveName>
	<fileDefinitions>
		<file name="IndexHtmlFile" 
			  processFile="true" 
			  function="CreateIndexHtmlFile" >index.html</file>
	</fileDefinitions>
	<files for="Language">
		<folder name="language" 
				exportAs="language"
				archiveAs="site">			
			<folder archiveAs="site\language" name="<%= Value("Task.lang") %>">
				<file type="site" template="langFile.ini" ><%= Value("Task.lang") %>.com_<%= StrConv(Value("Extension.name"), VbStrConv.Lowercase) %>.ini</file>
			</folder>
		</folder>
		<folder name="administrator"
				exportAs="administrator">
			<folder archiveAs="admin" name="language">			
				<folder archiveAs="admin\language" name="<%= Value("Task.lang") %>">
					<file type="admin" template="langFile.ini" ><%= Value("Task.lang") %>.com_<%= StrConv(Value("Extension.name"), VbStrConv.Lowercase) %>.ini</file>
					<file type="admin.sys" template="langFile.ini" ><%= Value("Task.lang") %>.com_<%= StrConv(Value("Extension.name"), VbStrConv.Lowercase) %>.sys.ini</file>
				</folder>
			</folder>
		</folder>
	</files>
</templateFiles>

The following line combines the name and version parameters from the extension's XML file to create the name of the zip file which the generated code is compressed in to.


<ArchiveName>com_<%= StrConv(Value("Extension.name"), VbStrConv.Lowercase) %>-<%= Value("Extension.version") %>.zip</ArchiveName>

The files for each task could also use task specific parameters by replacing the prefix "Extension" with "Task" in the call to `Value`, as in the following line of code.


<file type="site" template="langFile.ini" ><%= Value("Task.lang") %>.com_<%= StrConv(Value("Extension.name"), VbStrConv.Lowercase) %>.ini</file>

As the above example demonstrates, the output file structure is highly customizable allowing the user to specify their own file structure by changing the XML file.