summaryrefslogtreecommitdiff
path: root/plugins/data.renderer.php
blob: 993bb1e85bcc533c25fd1875bf8412b72df2c0b0 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
 * @version  $Revision$
 * @package  liberty
 * @subpackage plugins_data
 */
// +----------------------------------------------------------------------+
// | Copyright (c) 2005, bitweaver.org
// +----------------------------------------------------------------------+
// | All Rights Reserved. See below for details and a complete list of authors.
// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
// |
// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
// | -> see http://phpdocu.sourceforge.net/
// +----------------------------------------------------------------------+
// | Author (TikiWiki): Gustavo Muslera <gmuslera@users.sourceforge.net>
// | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
// | by: wjames5
// | Reworked from: data.articles.php from wikiplugin_articles.php
// +----------------------------------------------------------------------+
// $Id$

/**
 * definitions
 */
global $gBitSystem, $gBitSmarty;
define( 'PLUGIN_GUID_DATARENDERER', 'datarenderer' );
global $gLibertySystem;
$pluginParams = array (
	'tag' => 'renderer',
	'auto_activate' => FALSE,
	'requires_pair' => TRUE,
	'load_function' => 'data_renderer',
	'help_function' => 'data_renderer_help',
	'title' => 'Renderer',
	'help_page' => 'DataPluginRenderer',
	'description' => tra( "This plugin will render the given content as described by the content_type given." ),
	'syntax' => "{renderer class= format_guid= }.. content ..{/renderer}",
	'plugin_type' => DATA_PLUGIN
);
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATARENDERER, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATARENDERER );

	// Help Routine
	function data_renderer_help() {
		$help ="<table class=\"data help\">
			<tr>
				<th>" . tra( "Key" ) . "</th>
				<th>" . tra( "Type" ) . "</th>
				<th>" . tra( "Comments" ) . "</th>
			</tr>
			<tr class=\"even\">
				<td>id</td>
				<td>" . tra( "div id") . '<br />' . tra("(optional)") . "</td>
				<td>" . tra( "specify the id of the outputed div") . "</td>
			</tr>
			<tr class=\"odd\">
				<td>class</td>
				<td>" . tra( "div class") . '<br />' . tra("(optional)") . "</td>
				<td>" . tra( "specify the class of the outputed div") . "</td>
			</tr>
			<tr class=\"even\">
				<td>format_guid</td>
				<td>" . tra( "string") . '<br />' . tra("(required)") . "</td>
				<td>" . tra( "Specify what renderer should be used to render the contents") . "</td>
			</tr>
		</table>".
		tra("Example: ") . "{renderer class=abc format_guid=tiki }.. content ..{/renderer}<br />";
		return $help;
	}

	// Executable Routine
	function data_renderer($data, $params) { // No change in the parameters with Clyde
		// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
		global $gLibertySystem, $gBitSmarty, $gBitSystem;

		$data = trim($data);

		if (empty($data)) { // If there is NO data to display - why do anything - get out of here
			return " ";
		}

		$rendererHash=array();
		$rendererHash['content_id']=0;
		$rendererHash['format_guid'] = empty($params['format_guid']) ? $gBitSystem->getConfig('default_format') : $params['format_guid'];
		$rendererHash['data'] =$data;

		$formatGuid=$rendererHash['format_guid'];
		$ret = "";
		if( $func = $gLibertySystem->getPluginFunction( $formatGuid, 'load_function' ) ) {
			$ret = $func( $rendererHash, $this );
		}

		$display_result = "<div";
		if (!empty($params['id'])) {
			$display_result .= " id=\"".$params['id']."\"";
		}
		if (!empty($params['class'])) {
			$display_result .= " class=\"".$params['class']."\"";
		}
		$display_result .= ">$ret</div>";

		return $display_result;
	}
?>