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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
<?php
/**
* @version $Revision: 1.8 $
* @package liberty
* @subpackage plugins_data
*/
// +----------------------------------------------------------------------+
// | Copyright (c) 2004, bitweaver.org
// +----------------------------------------------------------------------+
// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
// |
// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
// | -> see http://phpdocu.sourceforge.net/
// +----------------------------------------------------------------------+
// | Author (TikiWiki): Oliver Hertel <ohertel@users.sourceforge.net>
// | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
// | by: StarRider <starrrider@users.sourceforge.net>
// | Reworked from: wikiplugin_category.php - see deprecated code below
// +----------------------------------------------------------------------+
// $Id: data.category.php,v 1.8 2006/04/06 05:06:11 starrrider Exp $
/**
* definitions
*/
global $gBitSystem;
if( $gBitSystem->isPackageActive( 'categories' ) ) { // Do not include this Plugin if the Package is not active
define( 'PLUGIN_GUID_DATACATEGORY', 'datacategory' );
global $gLibertySystem;
$pluginParams = array (
'tag' => 'CATEGORY',
'auto_activate' => FALSE,
'requires_pair' => FALSE,
'load_function' => 'data_category',
'title' => 'Category<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
// 'title' => 'Category', // and Remove the comment from the start of this line
'help_page' => 'DataPluginCategory',
'description' => tra("This plugin insert a list of items for the current category or a given category."),
'help_function' => 'data_category_help',
'syntax' => "{CATEGORY id= types= sort= sub= split= }",
'path' => LIBERTY_PKG_PATH.'plugins/data.category.php',
'security' => 'registered',
'plugin_type' => DATA_PLUGIN
);
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATACATEGORY, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACATEGORY );
// Help Function
function data_category_help() {
$help =
'<table class="data help">'
.'<tr>'
.'<th>' . tra( "Key" ) . '</th>'
.'<th>' . tra( "Type" ) . '</th>'
.'<th>' . tra( "Comments" ) . '</th>'
.'</tr>'
.'<tr class="odd">'
.'<td>id</td>'
.'<td>' . tra( "number(s)") . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "A Category Id number or list of Id numbers. The easiest way to see a Category Id number is to open 'View Categories' and placing the mouse over the Category in question. The URL will be displayed by most browsers. The end of the URL contains an Id number like this: <strong>parent_id=9</strong>. Multiple Id numbers can be entered by joining them with the + character like this: <strong>1+2+3</strong>. Default = <strong>the Current Category Id Number </strong> if not defined.") . '</td>'
.'</tr>'
.'<tr class="even">'
.'<td>type</td>'
.'<td>' . tra( "key-word") . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "A filter to limit which <strong>bitweaver</strong> Object will be displayed on the page. The key-words are:") . ' <strong>blog faq fgal igal newsletter poll quiz survey tracker & wiki</strong>. ' . tra("Multiple key-words can be entered by joining them with the + character like this:") . ' <strong>blog+wiki</strong>. ' . tra("The Default = ") . '<strong>ALL OBJECTS</strong></td>'
.'</tr>'
.'<tr class="odd">'
.'<td>sort</td>'
.'<td>' . tra( "key-word") . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "Specifies a Sort Order. The Sort Order may be by:") . '<strong> type, created, name, or hits. </strong>' . tra("A direction can be defined by adding either") . '<strong> _asc</strong> or <strong>_dec. </strong>' . tra("(The Default = ") . '<strong>name_asc</strong>)</td>'
.'</tr>'
.'<tr class="even">'
.'<td>sub</td>'
.'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "Determins if any subcategory items are to be displayed. Passing any value in this parameter will make it <strong>FALSE</strong>. The Default = <strong>TRUE</strong> so subcategories are displayed.") . '</td>'
.'</tr>'
.'<tr class="odd">'
.'<td>split</td>'
.'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "Primarilly used when displaying multiple categories. Determins if the display will be split into more than one column. Passing any value in this parameter will make it <strong>FALSE</strong>. The Default = <strong>TRUE</strong> so multiple columns are displayed.") . '</td>'
.'</tr>'
.'</table>'
. tra("Example: ") . "{CATEGORY id='1+2+3' types='blog+faq' sort='type_asc'}<br />"
. tra("Example: ") . "{CATEGORY id='1+2+3' types='blog+faq+wiki' sort='name_asc' sub='No' split='No'}";
return $help;
}
// Load Function
function data_category($data, $params) { // Pre-Clyde Changes
// requires_pair was TRUE / No other changes were made to the Help
// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
global $gLibertySystem;
$pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATACATEGORY];
$ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
return $ret;
}
}
/******************************************************************************
The code below is from the deprecated CATEGORY plugin. All comments and the help routines have been removed. - StarRider
function in_multi_array($needle, $haystack) {
$in_multi_array = false;
if (in_array($needle, $haystack)) {
$in_multi_array = true;
} else {
while (list($tmpkey, $tmpval) = each($haystack)) {
if (is_array($haystack[$tmpkey])) {
if (in_multi_array($needle, $haystack[$tmpkey])) {
$in_multi_array = true;
break;
}
}
}
}
return $in_multi_array;
}
function wikiplugin_category($data, $params) {
global $gBitSmarty;
global $package_categories;
global $categlib;
if (!is_object($categlib)) {
require_once (CATEGORIES_PKG_PATH."categlib.php");
}
if ($package_categories != 'y') {
return "<span class='warn'>" . tra("Categories are disabled"). "</span>";
}
extract ($params, EXTR_SKIP);
// array for converting long type names (as in database) to short names (as used in plugin)
$typetokens = array(
"article" => "article",
"blog" => "blog",
"faq" => "faq",
"file gallery" => "fgal",
"image gallery" => "igal",
"newsletter" => "newsletter",
"poll" => "poll",
"quiz" => "quiz",
"survey" => "survey",
"tracker" => "tracker",
"wiki page" => "wiki"
);
// TODO: move this array to a lib
// array for converting long type names to translatable headers (same strings as in application menu)
$typetitles = array(
"article" => "Articles",
"blog" => "Blogs",
"directory" => "Directory",
"faq" => "FAQs",
"file gallery" => "File Galleries",
"forum" => "Forums",
"image gallery" => "Image Gals",
"newsletter" => "Newsletters",
"poll" => "Polls",
"quiz" => "Quizzes",
"survey" => "Surveys",
"tracker" => "Trackers",
"wiki page" => "Wiki"
);
// string given back to caller
$out = "";
// TODO: use categ name instead of id (alternative)
$id = (isset($id)) ? $id : 'current'; // use current category if none is given
if ($id == 'current') {
$obj_id = urldecode($_REQUEST['page']);
$catids = $categlib->get_object_categories('wiki page', $obj_id);
} else {
$catids = explode("+", $id); // create array of category ids to be displayed
}
// default setting for $split is 'yes'
if (!(isset($split))) {
$split = 'yes';
} elseif ($split != 'y' and $split != 'yes' and $split != 'n' and $split != 'no' and $split != 'true' and $split != 'false') {
$split = 'yes';
}
// array with items to be displayed
$listcat = array();
// title of categories
$title = '';
// TODO: allow 'find' and 'max_records'
$find = "";
$offset = 0;
$max_records = 500;
$count = 0;
$sort = (isset($sort)) ? $sort : "name_asc";
$types = (isset($types)) ? "+" . strtolower($types) : "*";
$typesallowed = split("\+", $types); // create array of types the user allowed to be displayed
foreach ($catids as $id) {
// get data of category
$cat = $categlib->get_category($id);
// store name of category
if ($count != 0) {
$title .= "| <a href=\"".CATEGORIES_PKG_URL."index.php?parent_id=" . $id . "\">" . $cat['name'] . "</a> ";
} else {
$title .= "<a href=\"".CATEGORIES_PKG_URL."index.php?parent_id=" . $id . "\">" . $cat['name'] . "</a> ";
}
// keep track of how many categories there are for split mode off
$count++;
// check if sub=>true and get sub category data
if (!(isset($sub))) {
$sub = true;
} elseif ($sub == 'no' or $sub == 'n' or $sub == 'false') {
$sub = false;
} else {
$sub = true;
}
$subcategs = array();
if ($sub) {
$subcategs = $categlib->get_category_descendants($id);
}
// array with objects in category
$objectcat = array();
if ($sub) {
// get all items for category and sub category
$objectcat = $categlib->list_category_objects_deep($id, $offset, $max_records, $sort, $find);
} else {
// get all items for category
$objectcat = $categlib->list_category_objects($id, $offset, $max_records, $sort, $find);
}
foreach ($objectcat["data"] as $obj) {
$type = $obj["type"];
// check if current type is in allowed type list: * = everything allowed
if (($types == '*') || array_search($typetokens[strtolower($type)], $typesallowed)) {
// remove duplicates in non-split mode
if ($split == 'n' or $split == 'no' or $split == 'false') {
if (!(in_multi_array($obj['name'], $listcat))) // TODO: check for name+type
{
$listcat[$typetitles["$type"]][] = $obj;
}
} else {
$listcat[$typetitles["$type"]][] = $obj;
}
}
}
// split mode: appending onto $out each time
if ($split == 'y' or $split == 'yes' or $split == 'true') {
$gBitSmarty->assign("title", $title);
$gBitSmarty->assign("listcat", $listcat);
$out .= $gBitSmarty->fetch("bitpackage:wiki/simple_plugin.tpl");
// reset array for next loop
$listcat = array();
// reset title
$title = '';
$count = 0;
}
}
// non-split mode
if ($split == 'n' or $split == 'no' or $split == 'false') {
$gBitSmarty->assign("title", $title);
$gBitSmarty->assign("listcat", $listcat);
$out = $gBitSmarty->fetch("bitpackage:wiki/simple_plugin.tpl");
}
return '~np~'.$out.'~/np~';
}
*/
?>
|