b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: plugins ] [ index: plugins ] [ all elements ]

Source for file _gmcode.renderer.php

Documentation is available at _gmcode.renderer.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-2005 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *
  11.  * @package plugins
  12.  */
  13. if!defined('DB_USER') ) die'Please, do not access this page directly.' );
  14.  
  15. /**
  16.  * Includes:
  17.  */
  18. require_once dirname(__FILE__).'/../renderer.class.php';
  19.  
  20. /**
  21.  * @package plugins
  22.  */
  23. {
  24.     var $code = 'b2evGMco';
  25.     var $name = 'GM code';
  26.     var $priority = 45;
  27.     var $apply_when = 'opt-out';
  28.     var $apply_to_html = true
  29.     var $apply_to_xml = false// Leave the GMcode markup
  30.     var $short_desc;
  31.     var $long_desc;
  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.      * Constructor
  69.      *
  70.      * {@internal gmcode_Rendererplugin::gmcode_Rendererplugin(-)}}
  71.      */
  72.     function gmcode_Rendererplugin()
  73.     {
  74.         $this->short_desc = T_('GreyMatter style formatting');
  75.         $this->long_desc = T_('**bold** \\italics\\ //italics// __underline__ ##tt## %%codeblock%%');
  76.     }
  77.  
  78.  
  79.     /**
  80.      * Perform rendering
  81.      *
  82.      * {@internal gmcode_Rendererplugin::render(-)}}
  83.      *
  84.      * @param string content to render (by reference) / rendered content
  85.      * @param string Output format, see {@link format_to_output()}
  86.      * @return boolean true if we can render something for the required output format
  87.      */
  88.     function render$content$format )
  89.     {
  90.         ifparent::render$content$format ) )
  91.         {    // We cannot render the required format
  92.             return false;
  93.         }
  94.     
  95.         $content preg_replace$this->search$this->replace$content );
  96.         
  97.         return true;
  98.     }
  99. }
  100.  
  101. // Register the plugin:
  102. $this->registernew gmcode_Rendererplugin() );
  103.  
  104. ?>

Documentation generated on Tue, 20 May 2008 01:55:20 +0200 by phpDocumentor 1.4.2