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
106
107
108
109
|
<?php
namespace Bitweaver\Liberty;
use Bitweaver\KernelTools;
/**
* @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 = [
'tag' => 'renderer',
'auto_activate' => false,
'requires_pair' => true,
'load_function' => '\data_renderer',
'help_function' => '\data_renderer_help',
'title' => 'Renderer',
'help_page' => 'DataPluginRenderer',
'description' => KernelTools::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>" . KernelTools::tra( "Key" ) . "</th>
<th>" . KernelTools::tra( "Type" ) . "</th>
<th>" . KernelTools::tra( "Comments" ) . "</th>
</tr>
<tr class=\"even\">
<td>id</td>
<td>" . KernelTools::tra( "div id") . '<br />' . KernelTools::tra("(optional)") . "</td>
<td>" . KernelTools::tra( "specify the id of the outputed div") . "</td>
</tr>
<tr class=\"odd\">
<td>class</td>
<td>" . KernelTools::tra( "div class") . '<br />' . KernelTools::tra("(optional)") . "</td>
<td>" . KernelTools::tra( "specify the class of the outputed div") . "</td>
</tr>
<tr class=\"even\">
<td>format_guid</td>
<td>" . KernelTools::tra( "string") . '<br />' . KernelTools::tra("(required)") . "</td>
<td>" . KernelTools::tra( "Specify what renderer should be used to render the contents") . "</td>
</tr>
</table>".
KernelTools::tra("Example: ") . "{renderer class=abc format_guid=tiki }.. content ..{/renderer}<br />";
return $help;
}
// Executable Routine
function data_renderer( $data, $params, $object = null ) { // 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 = [];
$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, $object );
}
$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;
}
|