b2evolution

Multilingual multiuser multiblog engine

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

Source for file renderer.class.php

Documentation is available at renderer.class.php

  1. <?php
  2. /**
  3.  * This file implements the RendererPlugin class (EXPERIMENTAL)
  4.  *
  5.  * This is the base class from which you should derive all rendering plugins.
  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.  * RendererPlugin Class
  22.  *
  23.  * @package plugins
  24.  * @abstract
  25.  */
  26. class RendererPlugin extends Plugin
  27. {
  28.     /**
  29.      * When should this plugin apply?
  30.      * Possible values:
  31.      * - 'stealth'
  32.      * - 'always'
  33.      * - 'opt-out'
  34.      * - 'opt-in'
  35.      * - 'lazy'
  36.      * - 'never'
  37.      */
  38.     var $apply_when = 'opt-out';
  39.     /**
  40.      * Should this plugin apply to HTML?
  41.      */
  42.     var $apply_to_html = true
  43.     /**
  44.      * Should this plugin apply to XML?
  45.      * It should actually only apply when:
  46.      * - it generates some content that is visible without HTML tags
  47.      * - it removes some dirty markup when generating the tags (which will get stripped afterwards)
  48.      * Note: htmlentityencoded is not considered as XML here.
  49.      */
  50.     var $apply_to_xml = false
  51.     
  52.     /**
  53.      * Perform rendering
  54.      *
  55.      * Well, this one does nothing but checking if Rendering applies to the output format.
  56.      * You need to derive this function.
  57.      *
  58.      * {@internal Rendererplugin::render(-)}}
  59.      *
  60.      * @param string content to render (by reference) / rendered content
  61.      * @param string Output format, see {@link format_to_output()}
  62.      * @return boolean true if we can render something for the required output format
  63.      */
  64.     function render$content$format )
  65.     {
  66.         switch$format )
  67.         {
  68.             case 'raw':
  69.                 // do nothing!
  70.                 return false;
  71.     
  72.             case 'htmlbody':
  73.                 // display in HTML page body: allow full HTML
  74.                 return $this->apply_to_html;
  75.     
  76.             case 'entityencoded':
  77.                 // Special mode for RSS 0.92: apply renders and allow full HTML but escape it
  78.                 return $this->apply_to_html;
  79.     
  80.             case 'htmlhead':
  81.                 // strips out HTML (mainly for use in Title)
  82.             case 'htmlattr':
  83.                 // use as an attribute: strips tags and escapes quotes
  84.             case 'formvalue':
  85.                 // use as a form value: escapes quotes and < > but leaves code alone
  86.                 return false;
  87.     
  88.             case 'xml':
  89.                 // use in an XML file: strip HTML tags
  90.                 return $this->apply_to_xml;
  91.  
  92.             case 'xmlattr':
  93.                 // use as an attribute: strips tags and escapes quotes
  94.                 return false;
  95.  
  96.             default:
  97.                 die'Output format ['.$format.'] not supported by RendererPlugin.' );
  98.         }
  99.     }
  100. }
  101. ?>

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