b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.9) [ class tree: plugins ] [ index: plugins ] [ all elements ]

Source for file _gmcode.plugin.php

Documentation is available at _gmcode.plugin.php

  1. <?php
  2. /**
  3.  * This file implements the GMcode plugin for b2evolution
  4.  *
  5.  * GreyMatter style formatting
  6.  *
  7.  * b2evolution - {@link http://b2evolution.net/}
  8.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  9.  * @copyright (c)2003-2006 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *
  11.  * @package plugins
  12.  */
  13. if!defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
  14.  
  15. /**
  16.  * Replaces GreyMatter markup in HTML (not XML).
  17.  *
  18.  * @package plugins
  19.  */
  20. class gmcode_plugin extends Plugin
  21. {
  22.     var $code = 'b2evGMco';
  23.     var $name = 'GM code';
  24.     var $priority = 45;
  25.     var $apply_rendering = 'opt-out';
  26.     var $group = 'rendering';
  27.     var $short_desc;
  28.     var $long_desc;
  29.     var $version = '1.9-dev';
  30.  
  31.  
  32.     /**
  33.      * GreyMatter formatting search array
  34.      *
  35.      * @access private
  36.      */
  37.     var $search array(
  38.             '# \*\* (.+?) \*\* #x',                // **bold**
  39.             '# \x5c\x5c (.+?) \x5c\x5c #x',        // \\italics\\
  40.             '# (?<!:) \x2f\x2f (.+?) \x2f\x2f #x'// //italics// (not preceded by : as in http://)
  41.             '# __ (.+?) __ #x',                    // __underline__
  42.             '/ \#\# (.+?) \#\# /x',                // ##tt##
  43.             '/ %%
  44.                 ( \s*? \n )?      # Eat optional blank line after %%%
  45.                 (.+?)
  46.                 ( \n \s*? )?      # Eat optional blank line before %%%
  47.                 %%
  48.             /sx'                                   // %%codeblock%%
  49.         );
  50.  
  51.     /**
  52.      * HTML replace array
  53.      *
  54.      * @access private
  55.      */
  56.     var $replace array(
  57.             '<strong>$1</strong>',
  58.             '<em>$1</em>',
  59.             '<em>$1</em>',
  60.             '<span style="text-decoration:underline">$1</span>',
  61.             '<tt>$1</tt>',
  62.             '<div class="codeblock"><pre><code>$2</code></pre></div>'
  63.         );
  64.  
  65.  
  66.     /**
  67.      * Init
  68.      */
  69.     function PluginInit$params )
  70.     {
  71.         $this->short_desc = T_('GreyMatter style formatting');
  72.         $this->long_desc = T_('**bold** \\italics\\ //italics// __underline__ ##tt## %%codeblock%%');
  73.     }
  74.  
  75.  
  76.     /**
  77.      * Perform rendering
  78.      *
  79.      * @see Plugin::RenderItemAsHtml()
  80.      */
  81.     function RenderItemAsHtml$params )
  82.     {
  83.         $content $params['data'];
  84.  
  85.         $content preg_replace$this->search$this->replace$content );
  86.  
  87.         return true;
  88.     }
  89. }
  90.  
  91.  
  92. /*
  93.  * $Log: _gmcode.plugin.php,v $
  94.  * Revision 1.13.2.3  2006/12/26 03:18:51  fplanque
  95.  * assigned a few significant plugin groups
  96.  *
  97.  * Revision 1.13.2.2  2006/11/04 19:55:12  fplanque
  98.  * Reinjected old Log blocks. Removing them from CVS was a bad idea -- especially since Daniel has decided branch 1.9 was his HEAD...
  99.  *
  100.  * Revision 1.13  2006/07/10 20:19:30  blueyed
  101.  * Fixed PluginInit behaviour. It now gets called on both installed and non-installed Plugins, but with the "is_installed" param appropriately set.
  102.  *
  103.  * Revision 1.12  2006/07/07 21:26:49  blueyed
  104.  * Bumped to 1.9-dev
  105.  *
  106.  * Revision 1.11  2006/07/06 19:56:29  fplanque
  107.  * no message
  108.  *
  109.  * Revision 1.10  2006/06/16 21:30:57  fplanque
  110.  * Started clean numbering of plugin versions (feel free do add dots...)
  111.  *
  112.  * Revision 1.9  2006/04/11 21:22:26  fplanque
  113.  * partial cleanup
  114.  *
  115.  */
  116. ?>

Documentation generated on Tue, 18 Dec 2007 19:17:42 +0100 by phpDocumentor 1.4.0