diff options
| author | Hash9 <hash9@users.sourceforge.net> | 2006-08-20 23:04:58 +0000 |
|---|---|---|
| committer | Hash9 <hash9@users.sourceforge.net> | 2006-08-20 23:04:58 +0000 |
| commit | 6e52d611ff996a304b505a2273e85a9bed4672f4 (patch) | |
| tree | cfaec86e624bbfa0e5856d95bab0ce4004269972 /plugins/format.pearwiki_general.php | |
| parent | 63de8cae6a1b19f5c56c67b4ad80506e3340c99a (diff) | |
| download | liberty-6e52d611ff996a304b505a2273e85a9bed4672f4.tar.gz liberty-6e52d611ff996a304b505a2273e85a9bed4672f4.tar.bz2 liberty-6e52d611ff996a304b505a2273e85a9bed4672f4.zip | |
create a new data format plugin to generalise all the pear Text_Wiki parsers (requires the parsers to be installed using the pear installer)
Diffstat (limited to 'plugins/format.pearwiki_general.php')
| -rw-r--r-- | plugins/format.pearwiki_general.php | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/plugins/format.pearwiki_general.php b/plugins/format.pearwiki_general.php new file mode 100644 index 0000000..aad08b3 --- /dev/null +++ b/plugins/format.pearwiki_general.php @@ -0,0 +1,84 @@ +<?php +/** + * @version $Revision: 1.9 $ + * @package liberty + * @subpackage plugins_format + */ + +/** + * definitions + */ +global $gLibertySystem; + +$genPluginParams = array ( +'store_function' => 'pearwiki_general_save_data', +'verify_function' => 'pearwiki_general_verify_data', +'plugin_type' => FORMAT_PLUGIN +); + +require_once('PEAR/Registry.php'); +$reg = new PEAR_Registry; +foreach ($reg->listPackages() as $package) { + if (substr($package,0,strlen("text_wiki"))=="text_wiki") { + $inf = $reg->packageInfo($package); + $package = $inf['package']; + $p = substr($package,strlen("text_wiki")); + if (empty($p)) { + $parser = "Text_Wiki"; + $parser_class = "Default"; + } else { + $parser = substr($p,1); + $parser_class = $parser; + } + $f = create_function('&$pParseHash, &$pCommonObject','return pearwiki_general_parse_data("'.$parser_class.'",$pParseHash, $pCommonObject);'); + $guid = "pearwiki_$parser"; + if (strlen($guid)>16) { + $guid = "pw_$parser"; + } + if (strlen($guid)>16) { + $guid = substr($guid,0,16); + } + $insPluginParams = array( + 'load_function' => $f, + 'edit_field' => "<input type=\"radio\" name=\"format_guid\" value=\"$guid\"", + 'description' => "Pear Wiki Parser for $parser Syntax.", + 'edit_label' => "$parser Syntax, parsed by Pear::Text_Wiki$p", + 'help_page' => "{$parser}Syntax", + 'auto_activate' => true, + ); + $gLibertySystem->registerPlugin( $guid, array_merge($genPluginParams,$insPluginParams) ); + + } +} + +function pearwiki_general_save_data( &$pParamHash ) { +} + +function pearwiki_general_verify_data( &$pParamHash ) { + $pParamHash['content_store']['data'] = $pParamHash['edit']; + return( NULL ); +} + +function pearwiki_general_parse_data( $parser_fmt, &$pParseHash, &$pCommonObject ) { + if (!defined('PAGE_SEP')) { + define('PAGE_SEP', 'PAGE MARKER HERE*&^%$#^$%*PAGEMARKERHERE'); + } + + require_once 'Text/Wiki.php'; + $parser = Text_Wiki::singleton($parser_fmt); + if (PEAR::isError($parser)) { + vd($parser); + die(); + } + global $gBitSystem; + if ($gBitSystem->isPackageActive('wiki')) { + $parser->setRenderConf('xhtml', 'wikilink', 'exists_callback', array( &$pCommonObject, 'pageExists' ) ); + $parser->setRenderConf('xhtml', 'wikilink', 'view_url', WIKI_PKG_URL.'index.php?page='); + $parser->setRenderConf('xhtml', 'wikilink', 'new_url', WIKI_PKG_URL.'edit.php?page='); + } + $parser->setRenderConf('xhtml', 'table', 'css_table', 'wikitable'); + $xhtml = $parser->transform( $pParseHash['data'], 'Xhtml' ); + + return $xhtml; +} +?> |
