summaryrefslogtreecommitdiff
path: root/plugins/format.pearwiki_tiki.php
blob: 92695672cbecb44b252b054fcd7793d33efef2f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
 * @version  $Revision: 1.3 $
 * @package  Liberty
 * @subpackage plugins_format
 */


/**
 * definitions
 */
global $gLibertySystem;

define( 'PLUGIN_GUID_PEARWIKI_TIKI', 'pearwiki_tiki' );

$auto_activate = ( @include_once( 'Text/Wiki.php' ) ? TRUE : FALSE );

$pluginParams = array ( 'store_function' => 'pearwiki_tiki_save_data',
						'load_function' => 'pearwiki_tiki_parse_data',
						'verify_function' => 'pearwiki_tiki_verify_data',
						'auto_activate' => $auto_activate,
						'description' => 'Pear Wiki Parser for TikiWiki Syntax. Requires Text_Wiki Pear extension. More info <a href="http://wiki.ciaweb.net/yawiki/index.php?area=Text_Wiki&page=SamplePage">here</a>',
						'edit_label' => 'Tiki Wiki Syntax, parsed by Pear::Text_Wiki',
						'edit_field' => '<input type="radio" name="format_guid" value="'.PLUGIN_GUID_PEARWIKI_TIKI.'"',
						'help_page' => 'TikiWikiSyntax',
						'plugin_type' => FORMAT_PLUGIN
					  );

$gLibertySystem->registerPlugin( PLUGIN_GUID_PEARWIKI_TIKI, $pluginParams );

function pearwiki_tiki_save_data( &$pParamHash ) {
}

function pearwiki_tiki_verify_data( &$pParamHash ) {
	$errorMsg = NULL;
	$pParamHash['content_store']['data'] = $pParamHash['edit'];
	return( $errorMsg );
}

function pearwiki_tiki_parse_data( &$pData, &$pCommonObject ) {
	static $parser;
	if( empty( $parser ) ) {
		define('PAGE_SEP', 'PAGE MARKER HERE*&^%$#^$%*PAGEMARKERHERE');

		require_once(dirname(__FILE__).'/../../util/pear/Text/Wiki/Tiki.php');
		$parser =& new Text_Wiki_Tiki();
		$parser->setRenderConf('xhtml', 'wikilink', 'exists_callback', array(&$pCommonObject, 'pageExists'));
		$parser->setRenderConf('xhtml', 'wikilink', 'view_url', 'index.php?page=');
		$parser->setRenderConf('xhtml', 'wikilink', 'new_url', 'edit.php?page=');
		$parser->setRenderConf('xhtml', 'table', 'css_table', 'wikitable');
		$parser->setRenderConf('xhtml', 'table', 'css_td', 'wikicell');
		//$parser->setFormatConf('Xhtml', 'translate', false);
		/*$extwiki = array();
		$extwikiSth = $this->query('SELECT `extwiki`, `name` FROM `tiki_extwiki`');
		while ($rec = $extwikiSth->fetchRow()) {
			$extwiki[$rec['name']] = str_replace('$page', '%s', $rec['extwiki']);
		}
		$parser->setRenderConf('xhtml', 'interwiki', 'sites', $extwiki);*/
	}
	$xhtml = $parser->transform($pData, 'Xhtml');

	global $gLibertySystem;
	// create a table of contents for this page
	// this function is called manually, since it processes the HTML code
	/*if( preg_match( "/\{maketoc.*?\}/", $xhtml ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) {
		$xhtml= data_maketoc($xhtml);
	}*/
	return $xhtml;
}
?>