As we know that Joomla 1.6 is out and people started using it. But there are so many extensions which are not yet released for J!1.6. And one can't use the extensions meant for 1.5 in J!1.6

In this tutorial we will learn how to convert a content plug-in from 1.5 to 1.6.

The one I chosen is codecitation, a syntax highlighter plug-in helps write programming code in your content and highlight it /decorate it depending on the language chosen. The version we will be upgrading is 1.3.1 which is the latest version as I write this article.

Author of the plug-in is Konstantin Nizhegorodov and website http://www.smartsoftwarebits.com/codecitation
And extension mentioned in JED at  http://extensions.joomla.org/extensions/edition/code-display/8068.

Download the plug-in into your local system and here we start.


This tutorial divided into two parts, the first part we will convert the installation manifest changes and in the second part we will discuss about the plug-in code.


The XML manifest (installation descriptor) from Joomla 1.5 to 1.6 changed a lot and 1.6 is not backward compatible (no legacy mode; which is good).If you install the plug-in in J!1.6 as is, then you would not see basic options, in the right side. So we need to change certain items/elements from the CodeCitation.xml.

Here is how the code looks before modification:

<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="content">
  <name>Content - CodeCitation</name>
  <author>Konstantin Nizhegorodov (This email address is being protected from spambots. You need JavaScript enabled to view it.)</author>
  <creationDate>August 22, 2009</creationDate>
  <copyright>Copyright 2009 Konstantin Nizhegorodov. All rights reserved.</copyright>
  <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
  <authorUrl>http://www.smartsoftwarebits.com</authorUrl>
  <version>1.3.1</version>
  <description>The description is removed
  </description>
<files>
<filename plugin="CodeCitation">CodeCitation.php</filename>
<filename>CodeCitationREADME.txt</filename>
<filename>codecitation/scripts/clipboard.swf</filename>
<filename>codecitation/scripts/shBrushAS3.js</filename>
<filename>codecitation/scripts/shBrushBash.js</filename>
<filename>codecitation/scripts/shBrushCpp.js</filename>
<filename>codecitation/scripts/shBrushCSharp.js</filename>
<filename>codecitation/scripts/shBrushCss.js</filename>
<filename>codecitation/scripts/shBrushDelphi.js</filename>
<filename>codecitation/scripts/shBrushDiff.js</filename>
<filename>codecitation/scripts/shBrushGroovy.js</filename>
<filename>codecitation/scripts/shBrushJava.js</filename>
<filename>codecitation/scripts/shBrushJavaFX.js</filename>
<filename>codecitation/scripts/shBrushJScript.js</filename>
<filename>codecitation/scripts/shBrushPerl.js</filename>
<filename>codecitation/scripts/shBrushPhp.js</filename>
<filename>codecitation/scripts/shBrushPlain.js</filename>
<filename>codecitation/scripts/shBrushPowerShell.js</filename>
<filename>codecitation/scripts/shBrushPython.js</filename>
<filename>codecitation/scripts/shBrushRuby.js</filename>
<filename>codecitation/scripts/shBrushScala.js</filename>
<filename>codecitation/scripts/shBrushSql.js</filename>
<filename>codecitation/scripts/shBrushVb.js</filename>
<filename>codecitation/scripts/shBrushXml.js</filename>
<filename>codecitation/scripts/shCore.js</filename>
<filename>codecitation/scripts/shLegacy.js</filename>
<filename>codecitation/styles/help.png</filename>
<filename>codecitation/styles/magnifier.png</filename>
<filename>codecitation/styles/page_white_code.png</filename>
<filename>codecitation/styles/page_white_copy.png</filename>
<filename>codecitation/styles/printer.png</filename>
<filename>codecitation/styles/shCore.css</filename>
<filename>codecitation/styles/shThemeDefault.css</filename>
<filename>codecitation/styles/shThemeDjango.css</filename>
<filename>codecitation/styles/shThemeEmacs.css</filename>
<filename>codecitation/styles/shThemeFadeToGrey.css</filename>
<filename>codecitation/styles/shThemeMidnight.css</filename>
<filename>codecitation/styles/shThemeRDark.css</filename>
<filename>codecitation/styles/wrapping.png</filename>
</files>
<languages>
        <language tag="en-GB">en-GB.plg_content_CodeCitation.ini</language>
</languages>
    <params>
        <param name="theme" type="list" default="shThemeDefault.css" label="Color theme" description="Select color theme you preffer for the plugin">
            <option value="shThemeDefault.css">Default</option>
            <option value="shThemeDjango.css">Django</option>
            <option value="shThemeEmacs.css">Emacs</option>
            <option value="shThemeFadeToGrey.css">FadeToGrey</option>
            <option value="shThemeMidnight.css">Midnight</option>
            <option value="shThemeRDark.css">RDark</option>
        </param>
        <param name="alternativetag" type="text" default="" label="Alternative tag to trigger the plugin usage." description="If you think that {codecitation} is too long and preffer shorter syntax, feel free to specify your own tag. For example: code" />
        <param type="spacer" default="&lt;b&gt;Default engine parameters values:&lt;/b&gt;" />        
        <param name="defaultlang" type="list" default="text" label="Default language to cite" description="If you cite mostly code writen on particular language, you are able to specify it here and ommit brush name in codecitation tag usage (shorten syntax).">
            <option value="as3">actionscripts3</option>
            <option value="bash">bash</option>
            <option value="cpp">cpp</option>
            <option value="csharp">csharp</option>
            <option value="css">css</option>
            <option value="diff">diff</option>
            <option value="groovy">groovy</option>
            <option value="java">java</option>
            <option value="javafx">javafx</option>
            <option value="javascript">javascript</option>
            <option value="pascal">pascal</option>
            <option value="perl">perl</option>
            <option value="php">php</option>
            <option value="powershell">powershell</option>
            <option value="python">python</option>
            <option value="ruby">ruby</option>
            <option value="scala">scala</option>
            <option value="sql">sql</option>
            <option value="vb">vb</option>
            <option value="xml">xml</option>
            <option value="text">plain text</option>            
        </param>
        <param name="auto-links" type="list" default="1" label="Auto-links" description="Allows you to turn detection of links in the codecitation block on and off. If the option is turned off, URLs won't be clickable.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </param>
        <param name="collapse" type="list" default="0" label="Collapse" description="Allows you to force citation block on the page to be collapsed by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </param>
        <param name="gutter" type="list" default="1" label="Gutter" description="Allows you to turn gutter with line numbers on and off by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </param>
        <param name="smart-tabs" type="list" default="1" label="Smart tabs" description="Allows you to turn smart tabs feature on and off by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </param>
        <param name="tab-size" type="text" default="4" label="Tab size" decription="Allows you to adjust default tab size." />
        <param name="toolbar" type="list" default="1" label="Toolbar" description="Toggles toolbar on/off by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </param>
        <param name="wrap-lines" type="list" default="1" label="Wrap lines" description="Allows you to turn line wrapping feature on and off by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </param>
    </params>
</install>

There are few problems with this: the <install>, <params> and <param> tag.


Let’s talk about the install tag.
The back end / database of the Joomla is modified a little, all the extensions are now registered in the jos_extenstions table as opposed to jos_modules, jos_plugins and jos_componets tables in Joomla 1.5. So they decided to deprecate <install> tag and introduce <extension> tag in place.

Modifying the <install> to extension would look like this

<extension version="1.6" type="plugin" group="content">


Everything else ( attributes remains same ) in extension as earlier but the version attributes value, modified to 1.6

The <params> and <param> tags are also deprecated and <fields>, <fieldset> and <field> to be used instead. And should be wrapped inside <config> tag.

Here is how my codecitation.xml (after modification) looks.

<?xml version="1.0" encoding="utf-8"?>
<extension version="1.6" type="plugin" group="content">
  <name>Content - CodeCitation</name>
  <author>Konstantin Nizhegorodov (This email address is being protected from spambots. You need JavaScript enabled to view it.)</author>
  <creationDate>August 22, 2009</creationDate>
  <copyright>Copyright 2009 Konstantin Nizhegorodov. All rights reserved.</copyright>
  <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
  <authorUrl>http://www.smartsoftwarebits.com</authorUrl>
  <version>1.3.1</version>
  <description>The description is removed
  </description>
<files>
<filename plugin="CodeCitation">CodeCitation.php</filename>
<filename>CodeCitationREADME.txt</filename>
<filename>codecitation/scripts/clipboard.swf</filename>
<filename>codecitation/scripts/shBrushAS3.js</filename>
<filename>codecitation/scripts/shBrushBash.js</filename>
<filename>codecitation/scripts/shBrushCpp.js</filename>
<filename>codecitation/scripts/shBrushCSharp.js</filename>
<filename>codecitation/scripts/shBrushCss.js</filename>
<filename>codecitation/scripts/shBrushDelphi.js</filename>
<filename>codecitation/scripts/shBrushDiff.js</filename>
<filename>codecitation/scripts/shBrushGroovy.js</filename>
<filename>codecitation/scripts/shBrushJava.js</filename>
<filename>codecitation/scripts/shBrushJavaFX.js</filename>
<filename>codecitation/scripts/shBrushJScript.js</filename>
<filename>codecitation/scripts/shBrushPerl.js</filename>
<filename>codecitation/scripts/shBrushPhp.js</filename>
<filename>codecitation/scripts/shBrushPlain.js</filename>
<filename>codecitation/scripts/shBrushPowerShell.js</filename>
<filename>codecitation/scripts/shBrushPython.js</filename>
<filename>codecitation/scripts/shBrushRuby.js</filename>
<filename>codecitation/scripts/shBrushScala.js</filename>
<filename>codecitation/scripts/shBrushSql.js</filename>
<filename>codecitation/scripts/shBrushVb.js</filename>
<filename>codecitation/scripts/shBrushXml.js</filename>
<filename>codecitation/scripts/shCore.js</filename>
<filename>codecitation/scripts/shLegacy.js</filename>
<filename>codecitation/styles/help.png</filename>
<filename>codecitation/styles/magnifier.png</filename>
<filename>codecitation/styles/page_white_code.png</filename>
<filename>codecitation/styles/page_white_copy.png</filename>
<filename>codecitation/styles/printer.png</filename>
<filename>codecitation/styles/shCore.css</filename>
<filename>codecitation/styles/shThemeDefault.css</filename>
<filename>codecitation/styles/shThemeDjango.css</filename>
<filename>codecitation/styles/shThemeEmacs.css</filename>
<filename>codecitation/styles/shThemeFadeToGrey.css</filename>
<filename>codecitation/styles/shThemeMidnight.css</filename>
<filename>codecitation/styles/shThemeRDark.css</filename>
<filename>codecitation/styles/wrapping.png</filename>
</files>
<languages>
        <language tag="en-GB">en-GB.plg_content_CodeCitation.ini</language>
</languages>
    <config>
    <fields name="params">
        <fieldset name="basic">
        <field name="theme" type="list" default="shThemeDefault.css" label="Color theme" description="Select color theme you preffer for the plugin">
            <option value="shThemeDefault.css">Default</option>
            <option value="shThemeDjango.css">Django</option>
            <option value="shThemeEmacs.css">Emacs</option>
            <option value="shThemeFadeToGrey.css">FadeToGrey</option>
            <option value="shThemeMidnight.css">Midnight</option>
            <option value="shThemeRDark.css">RDark</option>
        </field>
        <field name="alternativetag" type="text" default="" label="Alternative tag to trigger the plugin usage." description="If you think that {codecitation} is too long and preffer shorter syntax, feel free to specify your own tag. For example: code" />
        <field type="spacer" default="&lt;b&gt;Default engine parameters values:&lt;/b&gt;" />        
        <field name="defaultlang" type="list" default="text" label="Default language to cite" description="If you cite mostly code writen on particular language, you are able to specify it here and ommit brush name in codecitation tag usage (shorten syntax).">
            <option value="as3">actionscripts3</option>
            <option value="bash">bash</option>
            <option value="cpp">cpp</option>
            <option value="csharp">csharp</option>
            <option value="css">css</option>
            <option value="diff">diff</option>
            <option value="groovy">groovy</option>
            <option value="java">java</option>
            <option value="javafx">javafx</option>
            <option value="javascript">javascript</option>
            <option value="pascal">pascal</option>
            <option value="perl">perl</option>
            <option value="php">php</option>
            <option value="powershell">powershell</option>
            <option value="python">python</option>
            <option value="ruby">ruby</option>
            <option value="scala">scala</option>
            <option value="sql">sql</option>
            <option value="vb">vb</option>
            <option value="xml">xml</option>
            <option value="text">plain text</option>            
        </field>
        <field name="auto-links" type="list" default="1" label="Auto-links" description="Allows you to turn detection of links in the codecitation block on and off. If the option is turned off, URLs won't be clickable.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </field>
        <field name="collapse" type="list" default="0" label="Collapse" description="Allows you to force citation block on the page to be collapsed by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </field>
        <field name="gutter" type="list" default="1" label="Gutter" description="Allows you to turn gutter with line numbers on and off by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </field>
        <field name="smart-tabs" type="list" default="1" label="Smart tabs" description="Allows you to turn smart tabs feature on and off by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </field>
        <field name="tab-size" type="text" default="4" label="Tab size" decription="Allows you to adjust default tab size." />
        <field name="toolbar" type="list" default="1" label="Toolbar" description="Toggles toolbar on/off by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </field>
        <field name="wrap-lines" type="list" default="1" label="Wrap lines" description="Allows you to turn line wrapping feature on and off by default.">
            <option value="0">"false"</option>
            <option value="1">"true"</option>
        </field>
    </fieldset>
    </fields>
    </config>
</extension>

Notice the <extension>,<config>,<fields>,<fieldset> and the <field> tags. See the Joomla 1.6 documentation for more here

In the next part of this tutorial we will modify the CodeCitation.php plugin file to adapt to Joomla1.6