7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Markup
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
23 * @see Zend_Loader_PluginLoader
25 require_once 'Zend/Loader/PluginLoader.php';
29 * @package Zend_Markup
30 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
31 * @license http://framework.zend.com/license/new-bsd New BSD License
35 const CALLBACK
= 'callback';
36 const REPLACE
= 'replace';
42 * @var Zend_Loader_PluginLoader
44 protected static $_parserLoader;
49 * @var Zend_Loader_PluginLoader
51 protected static $_rendererLoader;
55 * Disable instantiation of Zend_Markup
57 private function __construct() { }
60 * Get the parser loader
62 * @return Zend_Loader_PluginLoader
64 public static function getParserLoader()
66 if (!(self
::$_parserLoader instanceof Zend_Loader_PluginLoader
)) {
67 self
::$_parserLoader = new Zend_Loader_PluginLoader(array(
68 'Zend_Markup_Parser' => 'Zend/Markup/Parser/',
72 return self
::$_parserLoader;
76 * Get the renderer loader
78 * @return Zend_Loader_PluginLoader
80 public static function getRendererLoader()
82 if (!(self
::$_rendererLoader instanceof Zend_Loader_PluginLoader
)) {
83 self
::$_rendererLoader = new Zend_Loader_PluginLoader(array(
84 'Zend_Markup_Renderer' => 'Zend/Markup/Renderer/',
88 return self
::$_rendererLoader;
94 * @param string $prefix
96 * @return Zend_Loader_PluginLoader
98 public static function addParserPath($prefix, $path)
100 return self
::getParserLoader()->addPrefixPath($prefix, $path);
104 * Add a renderer path
106 * @param string $prefix
107 * @param string $path
108 * @return Zend_Loader_PluginLoader
110 public static function addRendererPath($prefix, $path)
112 return self
::getRendererLoader()->addPrefixPath($prefix, $path);
118 * @param string $parser
119 * @param string $renderer
120 * @param array $options
121 * @return Zend_Markup_Renderer_RendererAbstract
123 public static function factory($parser, $renderer = 'Html', array $options = array())
125 $parserClass = self
::getParserLoader()->load($parser);
126 $rendererClass = self
::getRendererLoader()->load($renderer);
128 $parser = new $parserClass();
129 $options['parser'] = $parser;
130 $renderer = new $rendererClass($options);