b2evolution

Multilingual multiuser multiblog engine

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

Source for file _texturize.renderer.php

Documentation is available at _texturize.renderer.php

  1. <?php
  2. /**
  3.  * This file implements the Texturize plugin for b2evolution
  4.  *
  5.  * @author WordPress team - http://sourceforge.net/project/memberlist.php?group_id=51422
  6.  *  b2evo: 1 notice fix.
  7.  *
  8.  * @package plugins
  9.  */
  10. if!defined('DB_USER') ) die'Please, do not access this page directly.' );
  11.  
  12. /**
  13.  * Includes:
  14.  */
  15. require_once dirname(__FILE__).'/../renderer.class.php';
  16.  
  17. /**
  18.  * @package plugins
  19.  */
  20. {
  21.     var $code = 'b2WPTxrz';
  22.     var $name = 'Texturize';
  23.     var $priority = 90;
  24.     var $apply_when = 'opt-in';
  25.     var $apply_to_html = true
  26.     var $apply_to_xml = true
  27.     var $short_desc;
  28.     var $long_desc;
  29.     
  30.  
  31.     /**
  32.      * Constructor
  33.      *
  34.      * {@internal texturize_Rendererplugin::texturize_Rendererplugin(-)}}
  35.      */
  36.     function texturize_Rendererplugin()
  37.     {
  38.         $this->short_desc = 'Smart quotes and more';
  39.         $this->long_desc = 'No description available';
  40.     }
  41.  
  42.  
  43.     /**
  44.      * Perform rendering
  45.      *
  46.      * {@internal texturize_Rendererplugin::render(-)}}
  47.      *
  48.      * @param string content to render (by reference) / rendered content
  49.      * @param string Output format, see {@link format_to_output()}
  50.      * @return boolean true if we can render something for the required output format
  51.      */
  52.     function render$content$format )
  53.     {
  54.         ifparent::render$content$format ) )
  55.         {    // We cannot render the required format
  56.             return false;
  57.         }
  58.     
  59.         $output '';
  60.         $textarr preg_split("/(<.*>)/Us"$content-1PREG_SPLIT_DELIM_CAPTURE)// capture the tags as well as in between
  61.         $stop count($textarr)$next true// loop stuff
  62.         for ($i 0$i $stop$i++{
  63.             $curl $textarr[$i];
  64.     
  65.             if (strlen($curl&& '<' != $curl{0&& $next// If it's not a tag
  66.                 $curl str_replace('---''&#8212;'$curl);
  67.                 $curl str_replace('--''&#8211;'$curl);
  68.                 $curl str_replace("..."'&#8230;'$curl);
  69.                 $curl str_replace('``''&#8220;'$curl);
  70.     
  71.                 // This is a hack, look at this more later. It works pretty well though.
  72.                 $cockney array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round");
  73.                 $cockneyreplace array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round");
  74.                 $curl str_replace($cockney$cockneyreplace$curl);
  75.     
  76.                 $curl preg_replace("/'s/"'&#8217;s'$curl);
  77.                 $curl preg_replace("/'(\d\d(?:&#8217;|')?s)/""&#8217;$1"$curl);
  78.                 $curl preg_replace('/(\s|\A|")\'/''$1&#8216;'$curl);
  79.                 $curl preg_replace('/(\d+)"/''$1&Prime;'$curl);
  80.                 $curl preg_replace("/(\d+)'/"'$1&prime;'$curl);
  81.                 $curl preg_replace("/(\S)'([^'\s])/""$1&#8217;$2"$curl);
  82.                 $curl preg_replace('/(\s|\A)"(?!\s)/''$1&#8220;$2'$curl);
  83.                 $curl preg_replace('/"(\s|\Z)/''&#8221;$1'$curl);
  84.                 $curl preg_replace("/'([\s.]|\Z)/"'&#8217;$1'$curl);
  85.                 $curl preg_replace("/\(tm\)/i"'&#8482;'$curl);
  86.                 $curl preg_replace("/\(c\)/i"'&#169;'$curl);
  87.                 $curl preg_replace("/\(r\)/i"'&#174;'$curl);
  88.                 $curl preg_replace('/&([^#])(?![a-z]{1,8};)/''&#038;$1'$curl);
  89.                 $curl str_replace("''"'&#8221;'$curl);
  90.                 
  91.                 $curl preg_replace('/(d+)x(\d+)/'"$1&#215;$2"$curl);
  92.     
  93.             elseif (strstr($curl'<code'|| strstr($curl'<pre'|| strstr($curl'<kbd' || strstr($curl'<style'|| strstr($curl'<script'))) {
  94.                 // strstr is fast
  95.                 $next false;
  96.             else {
  97.                 $next true;
  98.             }
  99.             $output .= $curl;
  100.         }
  101.         $content $output;
  102.         
  103.         return true;
  104.     }
  105. }
  106.  
  107. // Register the plugin:
  108. $this->registernew texturize_Rendererplugin() );
  109.  
  110. ?>

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