Now comes the important part of the plugin, the CodeCitation.php. You might be wondering whether there is any API changes in J!1.6. If not then our code is ready ( anyway we already modified the installation descriptor file).Unfortunately, the answer is YES! Especially the plug-ins. There are few events are introduced and few got renamed, including the one that code citation plug-in uses;
onPrepareContent. The onPrepareContent is renamed to onContentPrepare and the signature also got changed.

So change; 

function onPrepareContent( &$row, &$params, $page=0 ) 


function onContentPrepare($context,&$row, &$params, $page=0 )

Once you have the change , your code inside the onContentPrepare will execute, but there are One more big problem left out.

At line number 113 of CodeCitation.php we have

$args = SAXY_Parser_Base::parseAttributes( $matches[2] ); 

which calls a parser  and  Joomla 1.6 does not. have this parser in its' library. So this line of code will not work. I came up with a workaround as follows for the above line

$xat = '<a><some '.$matches[2].' /></a>';
    foreach($xml->some[0]->attributes() as $a => $b){

In Joomla 1.6 the way the extensions are created in the respective plugin type folder is  little different from Joomla 1.5.

Joomla 1.6 creates a folder for each plugin and extracts all content of the plugin's zip file but in Joomla 1.5 plugins are extracted in the root  folder( plugin type folder). So the way the plugin assets referred is deferent from Joomla1.5 because of the folder structure.

In CodeCitation.php modify the function

public static function getPluginRoot(){
      return JURI::root().'plugins/content/codecitation/';

Here is how the modified CodeCitation.php looks


public static function getPluginRoot()
      return JURI::root().'plugins/content/CodeCitation/codecitation/';

And we are done. Zip back the plug-in and install it on your Joomla 1.6.

Here is my finised CodeCitation.php

* CodeCitation 1.3.1
* Joomla plugin
* allow usage of SyntaxHighlighter in WYSIWYG editor
* Usage: { codecitation class="(class params for SyntaxHighlighter)" width="(optional width param for div tag)"} CODE TO HIGHTLIGHT { /  codecitation}
* Usage example: { codecitation class="brush: VisualBasic; gutter:true"} VB CODE { / codecitation }
* Copyright 2009 This email address is being protected from spambots. You need JavaScript enabled to view it.. All rights reserved.
* This is a derivative work. Portions are copyright:
*     Open Source Matters
* This work is licensed under the GNU/GPL license.
* This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.event.plugin' );

class plgContentCodeCitation extends JPlugin {
    const _tag="codecitation";
    private static $langAliases = array("as3" => "as3", "actionscript3" => "as3",
                                        "bash" => "bash", "shell" => "bash",
                                        "cpp" => "cpp", "c" => "cpp",
                                        "csharp" => "csharp", "c#" => "csharp", "c-sharp" => "csharp",
                                        "css" => "css",
                                        "pascal" => "pascal", "delphi" => "pascal",
                                        "diff" => "diff", "patch" => "diff",
                                        "groovy" => "groovy",
                                        "java" => "java",
                                        "javafx" => "javafx", "jfx" => "javafx",
                                        "js" => "javascript", "javascript" => "javascript", "jscript" => "javascript",
                                        "perl" => "perl", "pl" => "perl", "Perl" => "perl",
                                        "php" => "php",
                                        "text" => "text", "plain" => "text",
                                        "powershell" => "powershell", "ps" => "powershell",
                                        "python" => "python", "py" => "python",
                                        "ruby" => "ruby", "rails" => "ruby", "ror" => "ruby",
                                        "scala" => "scala",
                                        "sql" => "sql",
                                        "vb" => "vb", "vbnet" => "vb", "VisualBasic" => "vb",
                                        "xml" => "xml", "xhtml" => "xml", "xslt" => "xml", "html" => "xml"    );
    private static $langFiles = array(  "as3"            => "shBrushAS3.js",
                                        "bash"            => "shBrushBash.js",
                                        "cpp"            => "shBrushCpp.js",
                                        "csharp"        => "shBrushCSharp.js",
                                        "css"            => "shBrushCss.js",
                                        "pascal"        => "shBrushDelphi.js",
                                        "diff"            => "shBrushDiff.js",
                                        "groovy"        => "shBrushGroovy.js",
                                        "java"            => "shBrushJava.js",
                                        "javafx"        => "shBrushJavaFX.js",
                                        "javascript"    => "shBrushJScript.js",
                                        "perl"            => "shBrushPerl.js",
                                        "php"            => "shBrushPhp.js",
                                        "text"            => "shBrushPlain.js",
                                        "powershell"    => "shBrushPowerShell.js",
                                        "python"        => "shBrushPython.js",
                                        "ruby"            => "shBrushRuby.js",
                                        "scala"            => "shBrushScala.js",
                                        "sql"            => "shBrushSql.js",
                                        "vb"            => "shBrushVb.js",
                                        "xml"            => "shBrushXml.js"
    private $_includeCSSOnce = False;
    private $_includedScripts = array();
    private $_runHighlighterOnce=False;

  function plgContentCodeCitation( &$subject, $params ){
     parent::__construct( $subject, $params );
  //onPrepareContent event handler. Replace all entries of { codecitation } tag and load necessary scripts
  function onContentPrepare($context,&$row, &$params, $page=0 ) {
      $alternativetag=$this->params->def( 'alternativetag', '');
      if ($alternativetag!='')
    $regex = "#{".$tag."[\s|&nbsp;]*(.*?)}([\s\S]*?){/\\1}#s";
    // register the regular expresstion to invoke our replacer in case Joomla finds the matches
    $row->text = preg_replace_callback( $regex, array($this,'replacer'), $row->text );
    return true;

  //Do the replacement work to replace { codecitation }{ / codecitation} into <div><pre></pre></div>
  //and include scripts as necessary
  private function replacer( &$matches ) {
   //commenting this as well since we don't need this ; refer 113 jimport('domit.xml_saxy_shared');

    //adjust document header to include SyntaxHighlighter styles and core
    $html_entities_match = array( "'\n'", "'\<\s*span\s*[\s\S]*?/*\s*\>'i", "'\<pre\s*[\s\S]*?/*\s*\>'i","'\<\s*/\s*pre\s*\>'i", "'\<div\s*[\s\S]*?/*\s*\>'i","'\<\s*/\s*div\s*\>'i","'\<\s*/\s*span\s*\>'i", "'\<\s*/\s*p\s*\>'i", "'\<p\s*[\s\S]*?/*\s*\>'i","'\<br\s*\/*\s*\>'i", "'<'i", "'>'i", "'&#39;'", "'&quot;'i", "'&nbsp;'i" );
    $html_entities_replace = array("",      "",                              "",                           "",                     "",                           "",                     "",                       "",                  "\n",                      "\n",               '&lt;',  '&gt;', "'",        '"',        ' ' );

    $matches[2]=preg_replace($html_entities_match, $html_entities_replace, $matches[2] );
    $matches[3]=preg_replace($html_entities_match, $html_entities_replace, $matches[3] );
    $text = $matches[3];

    //commentng this $args = SAXY_Parser_Base::parseAttributes( $matches[2] );

    $xat = '<a><some '.$matches[2].' /></a>';
    foreach($xml->some[0]->attributes() as $a => $b){
    $shclass = JArrayHelper::getValue( $args, 'class', '' );
    $width = JArrayHelper::getValue( $args, 'width', 'inherit' );
    //determine language to show

    if (preg_match($regexLangAlias,$shclass,$langAliasMatches)>0)
        $langAlias=$this->params->def( 'defaultlang', 'text');
    //determine if we need to include xml markup parser for html scripts
     if (preg_match($regexHtmlScriptMode,$shclass,$htmlScriptModeMatches)>0)
    }    else
    //include Java script that is necessary to show the code (if we have not already did it for this language)
    $prolog='<div style="overflow: hidden; display: block; height: auto; width: '.$width.';"><pre class="'.$shclass.'">';
    $text = $codes.$prolog.$text.$epilog;
    return $text;
  private function includeScript($langAlias, $htmlScriptMode) {
      //get then lanuage name for the alias

      if (isset(self::$langAliases[$langAlias]))
      //get the filename for the language
      if (isset(self::$langFiles[$langName]))
      //check if we have already embeeded file into the page
      if (!isset($this->_includedScripts[$fileName]))
          //embeed xml lang file if necessary for html-script mode
          if (!isset($this->_includedScripts[self::$langFiles[self::$langAliases["xml"]]]))

      //since we are here, we need to embeed styles and scripts into document
      if ($this->_runHighlighterOnce) return "";
      //TODO: Handle plugin parameters and set default SyntaxHighlighter values according to the plugin params vaules
      $codes='<script type="text/javascript">
    SyntaxHighlighter.config.clipboardSwf = "'.$pluginRoot.'scripts/clipboard.swf";
    SyntaxHighlighter.defaults["auto-links"] = '.($this->params->def( 'auto-links', 0) ? 'true' : 'false').';
    SyntaxHighlighter.defaults["collapse"] = '.($this->params->def( 'collapse', 0) ? 'true' : 'false').';
    SyntaxHighlighter.defaults["gutter"] = '.($this->params->def( 'gutter', 0) ? 'true' : 'false').';
    SyntaxHighlighter.defaults["smart-tabs"] = '.($this->params->def( 'smart-tabs', 0) ? 'true' : 'false').';
    SyntaxHighlighter.defaults["tab-size"] = '.$this->params->def( 'tab-size', '4').';
    SyntaxHighlighter.defaults["toolbar"] = '.($this->params->def( 'toolbar', 0) ? 'true' : 'false').';
    SyntaxHighlighter.defaults["wrap-lines"] = '.($this->params->def( 'wrap-lines', 0) ? 'true' : 'false').';    
      return $codes;
  private function updatePageIncludes($fileName)
      $tag='<script type="text/javascript" src="'.$pluginRoot.'scripts/'.$fileName.'"></script>';
     $document= & JFactory::getDocument();
      if ($document)
  //include necessary styles into page only once
  private function includeCSSOnce() {
      //since we are here, we need to embeed styles and scripts into document
      if ($this->_includeCSSOnce) return;
      // we want only one link to the CSS
      $this->_includeCSSOnce = True;
      $tag= '<link type="text/css" rel="stylesheet" href="'.$pluginRoot.'styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="'.$pluginRoot.'styles/'.$this->params->def( 'theme', 'shThemeDefault.css').'"/>
<script type="text/javascript" src="'.$pluginRoot.'scripts/shCore.js"></script>';
      $document= & JFactory::getDocument();
      if ($document){
  public static function getPluginRoot(){
      return JURI::root().'plugins/content/CodeCitation/codecitation/';


Thanks to Konstantin Nizhegorodov for such a beautiful plugin.