This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
388 lines (345 loc) · 11.3 KB
/
index.php
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?php
/**
* moziloCMS Plugin: ContentOverview
*
* Returns a different styled list of content pages of current category
*
* PHP version 5
*
* @category PHP
* @package PHP_MoziloPlugins
* @author DEVMOUNT <[email protected]>
* @license GPL v3+
* @version GIT: v0.1.2014-04-14
* @link https://github.com/devmount-mozilo/ContentOverview/wiki/Dokumentation
*
* Plugin created by DEVMOUNT
* www.devmount.de
*
*/
// only allow moziloCMS environment
if (!defined('IS_CMS')) {
die();
}
/**
* ContentOverview Class
*
* @category PHP
* @package PHP_MoziloPlugins
* @author DEVMOUNT <[email protected]>
* @license GPL v3+
* @link https://github.com/devmount-mozilo/ContentOverview
*/
class ContentOverview extends Plugin
{
// language
private $_admin_lang;
private $_cms_lang;
// plugin information
const PLUGIN_AUTHOR = 'DEVMOUNT';
const PLUGIN_TITLE = 'ContentOverview';
const PLUGIN_VERSION = 'v0.1.2014-04-14';
const MOZILO_VERSION = '2.0';
const PLUGIN_DOCU
= 'https://github.com/devmount-mozilo/ContentOverview/wiki/Dokumentation';
private $_plugin_tags = array(
'tag1' => '{ContentOverview|tiles}',
'tag2' => '{ContentOverview|list}',
'tag3' => '{ContentOverview|links}',
);
const LOGO_URL = 'http://media.devmount.de/logo_pluginconf.png';
/**
* creates plugin content
*
* @param string $value Parameter divided by '|'
*
* @return string HTML output
*/
function getContent($value)
{
// call given mode
switch ($value) {
case 'tiles':
return $this->catTiles();
break;
case 'list':
return $this->catList();
break;
case 'links':
return $this->catLinks();
break;
default:
return $this->noMode();
break;
}
return $this->noMode();
}
/**
* returns list formatted as tiles
*
* @return string html output
*/
function catTiles()
{
global $CatPage;
// get conf
$tilenumber = $this->settings->get("tilenumber");
$col = 15/$tilenumber;
// get pages of current cat
$pagearray = $CatPage->get_PageArray(
CAT_REQUEST,
array(EXT_PAGE, EXT_HIDDEN)
);
// real cat name without '/'
$cat = substr(CAT_REQUEST, strpos(CAT_REQUEST, '%2F')+3);
// remove page = category
for ($i=0; $i < count($pagearray); $i++) {
if ($cat == $pagearray[$i]) {
unset($pagearray[$i]);
}
}
$pagearray = array_values($pagearray);
$content = '';
// build tile for each content page
for ($i=0; $i < count($pagearray); $i++) {
$pagename = $pagearray[$i];
$catname = CAT_REQUEST;
// if pagename contains category, extract the name, rebuild the category
if (strpos($pagearray[$i], '%2F') !== false) {
// real page name without '/'
$pagename = substr($pagearray[$i], strpos($pagearray[$i], '%2F')+3);
$catname = $pagearray[$i];
}
// build rows
if ($i % $tilenumber == 0) {
$content .= '<div class="row">';
}
$content .=
'<div
class="large-' . $col . ' large-uncentered columns box"
>';
// build page link with mozilo syntax [seite|...]
$content .=
'[seite=<span>'. urldecode($pagename) . '</span>
|@='. $catname . ':'. $pagename . '=@]';
$content .= '</div>';
if ($i % $tilenumber == $tilenumber-1) {
$content .= '</div>';
}
}
if (count($pagearray) % $tilenumber != 0) {
$content .= '</div>';
}
// clear floats
$content .= '<br style="clear:both;" />';
return $content;
}
/**
* returns list formatted as list
*
* @return string html output
*/
function catList()
{
global $CatPage;
// get conf
$catdescriptions = explode('\r\n', $this->settings->get("catdescriptions"));
// get pages of current cat
$pagearray = $CatPage->get_PageArray(CAT_REQUEST, array(EXT_PAGE));
$cat = substr(CAT_REQUEST, strripos(CAT_REQUEST, '%2F')+3);
$content = '';
// build listbox for each page
foreach ($pagearray as $page) {
$pagename = $page;
$catname = CAT_REQUEST;
// if pagename contains category, extract the name, rebuild the category
if (strpos($page, '%2F') !== false) {
// real page name without '/'
$pagename = substr($page, strpos($page, '%2F')+3);
$catname = $page;
}
// only take pages unlike category
if ($cat != $page) {
$content .= '<div class="row collapse listboxrow">';
$content .= '<div class="large-5 columns listbox">';
$content .= '[seite=<span>'. urldecode($pagename) . '</span>
|@='. $catname . ':'. $pagename . '=@]';
$content .= '</div>';
$content .= '<div class="large-10 columns listboxdescription">';
$description = $this->settings->get('conf_' . $page);
if (isset($description)) {
$content .= $description;
}
$content .= '</div>';
$content .= '</div>';
}
}
return $content;
}
/**
* returns list formatted as tiles
*
* @return string html output
*/
function catLinks()
{
global $CatPage;
// get conf
$catdescriptions = explode('\r\n', $this->settings->get("catdescriptions"));
// get pages of current cat
$pagearray = $CatPage->get_PageArray(CAT_REQUEST, array(EXT_PAGE));
$cat = substr(CAT_REQUEST, strripos(CAT_REQUEST, '%2F')+3);
$content = '';
// build list item for each page
foreach ($pagearray as $page) {
$pagename = $page;
$catname = CAT_REQUEST;
// if pagename contains category, extract the name, rebuild the category
if (strpos($page, '%2F') !== false) {
// real page name without '/'
$pagename = substr($page, strpos($page, '%2F')+3);
$catname = $page;
}
// only take pages unlike category
if ($cat != $page) {
if (PAGE_REQUEST != $page) {
$content .=
'[liste|[seite=<span>'. urldecode($pagename) . '</span>
|@='. $catname . ':'. $pagename . '=@]]';
} else {
$content .= '[liste|' . urldecode($pagename) . ']';
}
}
}
return $content;
}
/**
* returns warning of wrong or no mode
*
* @return string html output
*/
function noMode()
{
$content = 'Bitte einen gültigen Modus angeben.';
return $content;
}
/**
* sets backend configuration elements and template
*
* @return Array configuration
*/
function getConfig()
{
global $CatPage;
$pages = array();
$catarr = $CatPage->get_CatArray();
foreach ($catarr as $cat) {
$pagearr = $CatPage->get_PageArray($cat);
foreach ($pagearr as $page) {
$pages[$page] = $cat;
}
}
$config = array();
// Number of tiles in one line
$config['tilenumber'] = array(
'type' => 'text',
'description' => 'Anzahl an Kacheln in einer Reihe',
'maxlength' => '100',
'size' => '4',
'regex' => "/^[1-9]{1,2}$/",
'regex_error' => 'Bitte eine Zahl zwischen 1 und 9 eingeben'
);
// Categories / Page Description
foreach ($pages as $page => $cat) {
$config['conf_' . $page] = array(
'type' => 'textarea',
'description' => '<b>' . urldecode($page) . '</b>',
'cols' => '',
'rows' => '1'
);
}
// read admin.css
$admin_css = '';
$lines = file('../plugins/' . self::PLUGIN_TITLE. '/admin.css');
foreach ($lines as $line_num => $line) {
$admin_css .= trim($line);
}
// add template CSS
$template = '<style>' . $admin_css . '</style>';
// Template
$template .= '
<div class="contentoverview-admin-header">
<span>'
. $this->_admin_lang->getLanguageValue(
'admin_header',
self::PLUGIN_TITLE
)
. '</span>
<a href="' . self::PLUGIN_DOCU . '" target="_blank">
<img style="float:right;" src="' . self::LOGO_URL . '" />
</a>
</div>
</li>
<li class="mo-in-ul-li ui-widget-content contentoverview-admin-li">
<div class="contentoverview-admin-subheader">'
. $this->_admin_lang->getLanguageValue('admin_tiles')
. '</div>
<div style="margin-bottom:5px;">
{tilenumber_text}
{tilenumber_description}
</div>
</li>
<li class="mo-in-ul-li ui-widget-content contentoverview-admin-li">
<div class="contentoverview-admin-subheader">'
. $this->_admin_lang->getLanguageValue('admin_description')
. '</div>
<div style="margin-bottom:5px;">
';
foreach ($pages as $page => $cat) {
$template .=
'{conf_' . $page . '_description}
{conf_' . $page . '_textarea}';
}
$config['--template~~'] = $template;
return $config;
}
/**
* sets backend plugin information
*
* @return Array information
*/
function getInfo()
{
global $ADMIN_CONF;
$this->_admin_lang = new Language(
$this->PLUGIN_SELF_DIR
. 'lang/admin_language_'
. $ADMIN_CONF->get('language')
. '.txt'
);
// build plugin tags
$tags = array();
foreach ($this->_plugin_tags as $key => $tag) {
$tags[$tag] = $this->_admin_lang->getLanguageValue('tag_' . $key);
}
$info = array(
'<b>' . self::PLUGIN_TITLE . '</b> ' . self::PLUGIN_VERSION,
self::MOZILO_VERSION,
$this->_admin_lang->getLanguageValue(
'description',
htmlspecialchars($this->_plugin_tags['tag1'], ENT_COMPAT, 'UTF-8'),
htmlspecialchars($this->_plugin_tags['tag2'], ENT_COMPAT, 'UTF-8'),
htmlspecialchars($this->_plugin_tags['tag3'], ENT_COMPAT, 'UTF-8')
),
self::PLUGIN_AUTHOR,
array(
self::PLUGIN_DOCU,
self::PLUGIN_TITLE . ' '
. $this->_admin_lang->getLanguageValue('on_devmount')
),
$tags
);
return $info;
}
}
?>