b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 2.4) [ 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-2008 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.     var $number_of_installs = 1;
  31.  
  32.  
  33.     /**
  34.      * GreyMatter formatting search array
  35.      *
  36.      * @access private
  37.      */
  38.     var $search array(
  39.             '# \*\* (.+?) \*\* #x',                // **bold**
  40.             '# \x5c\x5c (.+?) \x5c\x5c #x',        // \\italics\\
  41.             '# (?<!:) \x2f\x2f (.+?) \x2f\x2f #x'// //italics// (not preceded by : as in http://)
  42.             '# __ (.+?) __ #x',                    // __underline__
  43.             '/ \#\# (.+?) \#\# /x',                // ##tt##
  44.             '/ %%
  45.                 ( \s*? \n )?      # Eat optional blank line after %%%
  46.                 (.+?)
  47.                 ( \n \s*? )?      # Eat optional blank line before %%%
  48.                 %%
  49.             /sx'                                   // %%codeblock%%
  50.         );
  51.  
  52.     /**
  53.      * HTML replace array
  54.      *
  55.      * @access private
  56.      */
  57.     var $replace array(
  58.             '<strong>$1</strong>',
  59.             '<em>$1</em>',
  60.             '<em>$1</em>',
  61.             '<span style="text-decoration:underline">$1</span>',
  62.             '<tt>$1</tt>',
  63.             '<div class="codeblock"><pre><code>$2</code></pre></div>'
  64.         );
  65.  
  66.  
  67.     /**
  68.      * Init
  69.      */
  70.     function PluginInit$params )
  71.     {
  72.         $this->short_desc = T_('GreyMatter style formatting');
  73.         $this->long_desc = T_('**bold** \\italics\\ //italics// __underline__ ##tt## %%codeblock%%');
  74.     }
  75.  
  76.  
  77.     /**
  78.      * Perform rendering
  79.      *
  80.      * @see Plugin::RenderItemAsHtml()
  81.      */
  82.     function RenderItemAsHtml$params )
  83.     {
  84.         $content $params['data'];
  85.  
  86.         $content preg_replace$this->search$this->replace$content );
  87.  
  88.         return true;
  89.     }
  90. }
  91.  
  92.  
  93. /*
  94.  * $Log: _gmcode.plugin.php,v $
  95.  * Revision 1.17  2008/01/21 09:35:41  fplanque
  96.  * (c) 2008
  97.  *
  98.  * Revision 1.16  2007/04/26 00:11:04  fplanque
  99.  * (c) 2007
  100.  *
  101.  * Revision 1.15  2007/04/20 02:53:13  fplanque
  102.  * limited number of installs
  103.  *
  104.  * Revision 1.14  2006/12/26 03:19:12  fplanque
  105.  * assigned a few significant plugin groups
  106.  *
  107.  * Revision 1.13  2006/07/10 20:19:30  blueyed
  108.  * Fixed PluginInit behaviour. It now gets called on both installed and non-installed Plugins, but with the "is_installed" param appropriately set.
  109.  *
  110.  * Revision 1.12  2006/07/07 21:26:49  blueyed
  111.  * Bumped to 1.9-dev
  112.  *
  113.  * Revision 1.11  2006/07/06 19:56:29  fplanque
  114.  * no message
  115.  *
  116.  * Revision 1.10  2006/06/16 21:30:57  fplanque
  117.  * Started clean numbering of plugin versions (feel free do add dots...)
  118.  *
  119.  * Revision 1.9  2006/04/11 21:22:26  fplanque
  120.  * partial cleanup
  121.  *
  122.  */
  123. ?>

Documentation generated on Sat, 06 Mar 2010 03:34:13 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).