OSDN Git Service

コピーライト表示部分の年度変更
[nucleus-jp/nucleus-next.git] / nucleus / libs / showlist.php
1 <?php\r
2 /*\r
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
4  * Copyright (C) 2002-2012 The Nucleus Group\r
5  *\r
6  * This program is free software; you can redistribute it and/or\r
7  * modify it under the terms of the GNU General Public License\r
8  * as published by the Free Software Foundation; either version 2\r
9  * of the License, or (at your option) any later version.\r
10  * (see nucleus/documentation/index.html#license for more info)\r
11  */\r
12 /**\r
13  * Functions to create lists of things inside the admin are\r
14  *\r
15  * @license http://nucleuscms.org/license.txt GNU General Public License\r
16  * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
17  * @version $Id: showlist.php 1662 2012-02-12 12:18:37Z sakamocchi $\r
18  */\r
19 \r
20 \r
21 // can take either an array of objects, or an SQL query\r
22 function showlist($query, $type, $template)\r
23 {\r
24         if ( is_array($query) )\r
25         {\r
26                 if ( sizeof($query) == 0 )\r
27                 {\r
28                         return 0;\r
29                 }\r
30                 \r
31                 call_user_func("listplug_{$type}", $template, 'HEAD');\r
32                 \r
33                 foreach ( $query as $currentObj )\r
34                 {\r
35                         $template['current'] = $currentObj;\r
36                         call_user_func("listplug_{$type}", $template, 'BODY');\r
37                 }\r
38                 \r
39                 call_user_func("listplug_{$type}", $template, 'FOOT');\r
40                 \r
41                 return sizeof($query);\r
42         }\r
43         else\r
44         {\r
45                 $res = sql_query($query);\r
46                 \r
47                 // don't do anything if there are no results\r
48                 $numrows = sql_num_rows($res);\r
49                 if ( $numrows == 0 )\r
50                 {\r
51                         return 0;\r
52                 }\r
53                 call_user_func("listplug_{$type}", $template, 'HEAD');\r
54                 \r
55                 while( $template['current'] = sql_fetch_object($res) )\r
56                 {\r
57                         call_user_func("listplug_{$type}", $template, 'BODY');\r
58                 }\r
59                 \r
60                 call_user_func("listplug_{$type}", $template, 'FOOT');\r
61                 \r
62                 sql_free_result($res);\r
63                 \r
64                 // return amount of results\r
65                 return $numrows;\r
66         }\r
67 }\r
68 \r
69 function listplug_select($template, $type)\r
70 {\r
71         switch( $type )\r
72         {\r
73                 case 'HEAD':\r
74                         echo '<select name="' . ifset($template['name']) . '" tabindex="' . ifset($template['tabindex']) . '" ' . ifset($template['javascript']) . ">\n";\r
75                         \r
76                         // add extra row if needed\r
77                         if ( ifset($template['extra']) )\r
78                         {\r
79                                 echo '<option value="', ifset($template['extraval']), '">', $template['extra'], "</option>\n";\r
80                         }\r
81                         \r
82                         break;\r
83                 case 'BODY':\r
84                         $current = $template['current'];\r
85 \r
86                         echo '<option value="' . Entity::hsc($current->value) . '"';\r
87                         if ( $template['selected'] == $current->value )\r
88                         {\r
89                                 echo ' selected="selected" ';\r
90                         }\r
91                         if ( isset($template['shorten']) && $template['shorten'] > 0 )\r
92                         {\r
93                                 echo ' title="'. Entity::hsc($current->text).'"';\r
94                                 $current->text = Entity::hsc(Entity::shorten($current->text, $template['shorten'], $template['shortenel']));\r
95                         }\r
96                         echo '>' . Entity::hsc($current->text) . "</option>\n";\r
97                         break;\r
98                 case 'FOOT':\r
99                         echo '</select>';\r
100                         break;\r
101         }\r
102         return;\r
103 }\r
104 \r
105 function listplug_table($template, $type)\r
106 {\r
107         switch( $type )\r
108         {\r
109                 case 'HEAD':\r
110                         echo "\n\n";\r
111                         echo "<table frame=\"box\" rules=\"all\" summary=\"{$template['content']}\">\n";\r
112                         echo "<thead>\n";\r
113                         echo "<tr>\n";\r
114                         // print head\r
115                         call_user_func("listplug_table_{$template['content']}" , $template, 'HEAD');\r
116                         echo "</tr>\n";\r
117                         echo "</thead>\n";\r
118                         echo "<tbody>\n";\r
119                         break;\r
120                 case 'BODY':\r
121                         // print tabletype specific thingies\r
122                         echo "<tr>\n";\r
123                         call_user_func("listplug_table_{$template['content']}" , $template,  'BODY');\r
124                         echo "</tr>\n";\r
125                         break;\r
126                 case 'FOOT':\r
127                         call_user_func("listplug_table_{$template['content']}" , $template,  'FOOT');\r
128                         echo "</tbody>\n";\r
129                         echo "</table>\n";\r
130                         echo "\n";\r
131                         break;\r
132         }\r
133         return;\r
134 }\r
135 \r
136 function listplug_table_memberlist($template, $type)\r
137 {\r
138         switch( $type )\r
139         {\r
140                 case 'HEAD':\r
141                         echo '<th>' . _LIST_MEMBER_NAME . "</th>\n";\r
142                         echo '<th>' . _LIST_MEMBER_RNAME . "</th>\n";\r
143                         echo '<th>' . _LIST_MEMBER_URL . "</th>\n";\r
144                         echo '<th>' . _LIST_MEMBER_ADMIN . "</th>\n";\r
145                         help('superadmin');\r
146                         echo "</th>\n";\r
147                         echo '<th>' . _LIST_MEMBER_LOGIN;\r
148                         help('canlogin');\r
149                         echo "</th>\n";\r
150                         echo '<th colspan="2">' . _LISTS_ACTIONS. "</th>\n";\r
151                         break;\r
152                 case 'BODY':\r
153                         $current = $template['current'];\r
154                         echo '<td>';\r
155                         $id = listplug_nextBatchId();\r
156                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->mnumber}\" />\n";\r
157                         echo "<label for=\"batch{$id}\">\n";\r
158                         echo '<a href="mailto:' . Entity::hsc($current->memail) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->mname), "</a>\n";\r
159                         echo "</label>\n";\r
160                         echo "</td>";\r
161                         echo "<td>" . Entity::hsc($current->mrealname) . "</td>\n";\r
162                         echo '<td><a href="' . Entity::hsc($current->murl) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->murl) . "</a></td>\n";\r
163                         echo '<td>' . ($current->madmin ? _YES : _NO) . "</td>\n";\r
164                         echo '<td>' . ($current->mcanlogin ? _YES : _NO) . "</td>\n";\r
165                         echo '<td><a href="index.php?action=memberedit&amp;memberid=$current->mnumber" tabindex="' . $template['tabindex'] . '">' . _LISTS_EDIT . "</a></td>\n";\r
166                         echo '<td><a href="index.php?action=memberdelete&amp;memberid=$current->mnumber" tabindex="' . $template['tabindex'].'">' . _LISTS_DELETE . "</a></td>\n";\r
167                         break;\r
168         }\r
169         return;\r
170 }\r
171 \r
172 function listplug_table_teamlist($template, $type)\r
173 {\r
174         global $manager;\r
175         switch( $type )\r
176         {\r
177                 case 'HEAD':\r
178                         echo "<th>" . _LIST_MEMBER_NAME . "</th>\n";\r
179                         echo "<th>" . _LIST_MEMBER_RNAME . "</th>\n";\r
180                         echo "<th>" . _LIST_TEAM_ADMIN . "</th>\n";\r
181                         help('teamadmin');\r
182                         echo "</th>\n";\r
183                         echo "<th colspan=\"2\">"._LISTS_ACTIONS."</th>\n";\r
184                         break;\r
185                 case 'BODY':\r
186                         $current = $template['current'];\r
187                         \r
188                         echo '<td>';\r
189                         $id = listplug_nextBatchId();\r
190                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->tmember}\" />\n";\r
191                         echo '<label for="batch',$id,'">';\r
192                         echo '<a href="mailto:' . Entity::hsc($current->memail) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->mname), "</a>\n";\r
193                         echo "</label>\n";\r
194                         echo "</td>";\r
195                         echo '<td>', Entity::hsc($current->mrealname), "</td>\n";\r
196                         echo '<td>', ($current->tadmin ? _YES : _NO) , "</td>\n";\r
197                         echo "<td><a href=\"index.php?action=teamdelete&amp;memberid=$current->tmember&amp;blogid={$current->tblog}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";\r
198                         \r
199                         $url = "index.php?action=teamchangeadmin&memberid={$current->tmember}&blogid={$current->tblog}";\r
200                         $url = $manager->addTicketToUrl($url);\r
201                         echo '<td><a href="' . Entity::hsc($url) . '" tabindex="' . $template['tabindex'] . '">' . _LIST_TEAM_CHADMIN . "</a></td>\n";\r
202                         break;\r
203         }\r
204         return;\r
205 }\r
206 \r
207 function listplug_table_pluginlist($template, $type)\r
208 {\r
209         global $manager;\r
210         switch( $type )\r
211         {\r
212                 case 'HEAD':\r
213                         echo '<th>' . _LISTS_INFO . "</th>\n";\r
214                         echo '<th>' . _LISTS_DESC . "</th>\n";\r
215                         echo '<th>' . _LISTS_ACTIONS . "</th>\n";\r
216                         break;\r
217                 case 'BODY':\r
218                         $current = $template['current'];\r
219                         \r
220                         $plug =& $manager->getPlugin($current->pfile);\r
221                         if ( $plug )\r
222                         {\r
223                                 echo "<td>\n";\r
224                                 echo '<h3>' . Entity::hsc($plug->getName()) . "</h3>\n";\r
225                                 \r
226                                 echo "<dl>\n";\r
227                                 if ( $plug->getAuthor() )\r
228                                 {\r
229                                         echo '<dt>' . _LIST_PLUGS_AUTHOR . "</dt>\n";\r
230                                         echo '<dd>' . Entity::hsc($plug->getAuthor()) , "</dd>\n";\r
231                                 }\r
232                                 \r
233                                 if ( $plug->getVersion() )\r
234                                 {\r
235                                         echo '<dt>' . _LIST_PLUGS_VER, "</dt>\n";\r
236                                         echo '<dd>' . Entity::hsc($plug->getVersion()) . "</dd>\n";\r
237                                 }\r
238                                 \r
239                                 if ( $plug->getURL() )\r
240                                 {\r
241                                         echo '<dt>' . _LIST_PLUGS_SITE . "<dt>\n";\r
242                                         echo '<dd><a href="' .  Entity::hsc($plug->getURL()) . '" tabindex="' . $template['tabindex'] . '">リンク</a></dd>' . "\n";\r
243                                 }\r
244                                 echo "</dl>\n";\r
245                                 echo "</td>\n";\r
246                                 \r
247                                 echo "<td>\n";\r
248                                 echo "<dl>\n";\r
249                                 echo '<dt>' . _LIST_PLUGS_DESC ."</dt>\n";\r
250                                 echo '<dd>' . Entity::hen($plug->getDescription()) ."</dd>\n";\r
251                                 if ( sizeof($plug->getEventList()) > 0 )\r
252                                 {\r
253                                         echo '<dt>' . _LIST_PLUGS_SUBS ."</dt>\n";\r
254                                         echo '<dd>' . Entity::hsc(implode(', ', $plug->getEventList())) ."</dd>\n";\r
255                                 }\r
256                                 \r
257                                 if ( sizeof($plug->getPluginDep()) > 0 )\r
258                                 {\r
259                                         echo '<dt>' . _LIST_PLUGS_DEP ."</dt>\n";\r
260                                         echo '<dd>' . Entity::hsc(implode(', ', $plug->getPluginDep())) ."</dd>\n";\r
261                                 }\r
262                                 \r
263                                 /* check dependency */\r
264                                 $req = array();\r
265                                 $res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));\r
266                                 while( $o = sql_fetch_object($res) )\r
267                                 {\r
268                                         $preq =& $manager->getPlugin($o->pfile);\r
269                                         if ( $preq )\r
270                                         {\r
271                                                 $depList = $preq->getPluginDep();\r
272                                                 foreach ( $depList as $depName )\r
273                                                 {\r
274                                                         if ( $current->pfile == $depName )\r
275                                                         {\r
276                                                                 $req[] = $o->pfile;\r
277                                                         }\r
278                                                 }\r
279                                         }\r
280                                 }\r
281                                 \r
282                                 if ( count($req) > 0 )\r
283                                 {\r
284                                         echo '<dt>' . _LIST_PLUGS_DEPREQ . "</dt>\n";\r
285                                         echo '<dd>' . Entity::hsc(implode(', ', $req)) . "</dd>\n";\r
286                                 }\r
287                                 \r
288                                 /* check the database to see if it is up-to-date and notice the user if not */\r
289                                 if ( !$plug->subscribtionListIsUptodate() )\r
290                                 {\r
291                                         echo '<dt>' . 'NOTICE:' . "</dt>\n";\r
292                                         echo '<dd>' . _LIST_PLUG_SUBS_NEEDUPDATE . "</dd>\n";\r
293                                 }\r
294                                 \r
295                                 echo "</dl>\n";\r
296                                 echo "</td>\n";\r
297                         }\r
298                         else\r
299                         {\r
300                                 echo '<td colspan="2">' . sprintf(_PLUGINFILE_COULDNT_BELOADED, Entity::hsc($current->pfile)) . "</td>\n";\r
301                         }\r
302                         \r
303                         echo "<td>\n";\r
304                         echo "<ul>\n";\r
305                         $current->pid = (integer) $current->pid;\r
306                         \r
307                         $url = Entity::hsc($manager->addTicketToUrl("index.php?plugid={$current->pid}&action=pluginup"));\r
308                         echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" , _LIST_PLUGS_UP , "</a></li>\n";\r
309                         \r
310                         $url = Entity::hsc($manager->addTicketToUrl("index.php?plugid={$current->pid}&action=plugindown"));\r
311                         echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_DOWN , "</a></li>\n";\r
312                         echo "<li><a href=\"index.php?action=plugindelete&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_UNINSTALL , "</a></li>\n";\r
313                         \r
314                         if ( $plug && ($plug->hasAdminArea() > 0) )\r
315                         {\r
316                                 echo '<li><a href="' , Entity::hsc($plug->getAdminURL()) , '" tabindex="' , $template['tabindex'] , '">' , _LIST_PLUGS_ADMIN , "</a></li>\n";\r
317                         }\r
318                         \r
319                         if ( $plug && ($plug->supportsFeature('HelpPage') > 0) )\r
320                         {\r
321                                 echo "<li><a href=\"index.php?action=pluginhelp&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_HELP , "</a></li>\n";\r
322                         }\r
323                         \r
324                         $query = "SELECT COUNT(*) AS result FROM %s WHERE ocontext='global' and opid=%s;";\r
325                         $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $current->pid);\r
326                         if ( quickQuery($query) > 0 )\r
327                         {\r
328                                 echo "<li><a href=\"index.php?action=pluginoptions&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_OPTIONS . "</a></li>\n";\r
329                         }\r
330                         echo "</ul>\n";\r
331                         echo "</td>\n";\r
332                         break;\r
333         }\r
334         return;\r
335 }\r
336 \r
337 function listplug_table_plugoptionlist($template, $type)\r
338 {\r
339         global $manager;\r
340         switch( $type )\r
341         {\r
342                 case 'HEAD':\r
343                         echo '<th>' . _LISTS_INFO . "</th>\n";\r
344                         echo '<th>' . _LISTS_VALUE . "</th>\n";\r
345                         break;\r
346                 case 'BODY':\r
347                         listplug_plugOptionRow($template['current']);\r
348                         break;\r
349                 case 'FOOT':\r
350                         echo "<tr>\n";\r
351                         echo '<th colspan=\"2\">' . _PLUGS_SAVE . "</th>\n";\r
352                         echo "</tr>\n";\r
353                         echo "<tr>\n";\r
354                         echo "<td>" . _PLUGS_SAVE . "</td>\n";\r
355                         echo "<td><input type=\"submit\" value=\"".  _PLUGS_SAVE . "\" /></td>\n";\r
356                         echo "</tr>\n";\r
357                         break;\r
358         }\r
359         return;\r
360 }\r
361 \r
362 function listplug_plugOptionRow($current)\r
363 {\r
364         $varname = "plugoption[{$current['oid']}][{$current['contextid']}]";\r
365         \r
366         // retreive the optionmeta\r
367         $meta = NucleusPlugin::getOptionMeta($current['typeinfo']);\r
368         \r
369         // only if it is not a hidden option write the controls to the page\r
370         if ( in_array('access', $meta) && $meta['access'] == 'hidden' )\r
371         {\r
372                 return;\r
373         }\r
374         \r
375         if ( !$current['description'] )\r
376         {\r
377                 echo '<td>' , Entity::hsc($current['name']) . "</td>\n";\r
378         }\r
379         else\r
380         {\r
381                 if ( !defined($current['description']) )\r
382                 {\r
383                         echo '<td>' , Entity::hsc($current['description']) . "</td>\n";\r
384                 }\r
385                 else\r
386                 {\r
387                         echo '<td>' , Entity::hsc(constant($current['description'])) . "</td>\n";\r
388                 }\r
389         }\r
390         echo "<td>\n";\r
391         switch($current['type'])\r
392         {\r
393                 case 'yesno':\r
394                         Admin::input_yesno($varname, $current['value'], 0, 'yes', 'no');\r
395                         break;\r
396                 case 'password':\r
397                         echo '<input type="password" size="40" maxlength="128" name="',Entity::hsc($varname),'" value="',Entity::hsc($current['value']),"\" />\n";\r
398                         break;\r
399                 case 'select':\r
400                         echo '<select name="'.Entity::hsc($varname)."\">\n";\r
401                         $options = NucleusPlugin::getOptionSelectValues($current['typeinfo']);\r
402                         $options = i18n::explode('|', $options);\r
403                         \r
404                         for ( $i=0; $i<(count($options)-1); $i+=2 )\r
405                         {\r
406                                 if ($options[$i+1] == $current['value'])\r
407                                 {\r
408                                         echo '<option value="' . Entity::hsc($options[$i+1]) . '" selected="selected">';\r
409                                 }\r
410                                 else\r
411                                 {\r
412                                         echo '<option value="' . Entity::hsc($options[$i+1]) . '">';\r
413                                 }\r
414                                 if ( defined($options[$i]) )\r
415                                 {\r
416                                         echo Entity::hsc(constant($options[$i]));\r
417                                 }\r
418                                 else\r
419                                 {\r
420                                         echo Entity::hsc($options[$i]);\r
421                                 }\r
422                                 echo "</option>\n";\r
423                         }\r
424                         echo "</select>\n";\r
425                         \r
426                         break;\r
427                 case 'textarea':\r
428                         //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);\r
429                         if ( array_key_exists('access', $meta) && $meta['access'] == 'readonly' )\r
430                         {\r
431                                 echo '<textarea class="pluginoption" cols="30" rows="5" name="' . Entity::hsc($varname) . "\" readonly=\"readonly\">\n";\r
432                         }\r
433                         else\r
434                         {\r
435                                 echo '<textarea class="pluginoption" cols="30" rows="5" name="' . Entity::hsc($varname) . "\">\n";\r
436                         }\r
437                         echo Entity::hsc($current['value']) . "\n";\r
438                         echo "</textarea>\n";\r
439                         break;\r
440                 case 'text':\r
441                 default:\r
442                         //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);\r
443                         echo '<input type="text" size="40" maxlength="128" name="',Entity::hsc($varname),'" value="',Entity::hsc($current['value']),'"';\r
444                         if ( array_key_exists('datatype', $meta) && $meta['datatype'] == 'numerical' )\r
445                         {\r
446                                 echo ' onkeyup="checkNumeric(this)" onblur="checkNumeric(this)"';\r
447                         }\r
448                         if ( array_key_exists('access', $current) && $meta['access'] == 'readonly')\r
449                         {\r
450                                 echo ' readonly="readonly"';\r
451                         }\r
452                         echo " />\n";\r
453         }\r
454         if ( array_key_exists('extra', $current) )\r
455         {\r
456                 echo $current['extra'];\r
457         }\r
458         echo "</td>\n";\r
459         \r
460         return;\r
461 }\r
462 \r
463 function listplug_table_itemlist($template, $type)\r
464 {\r
465         $cssclass = '';\r
466         \r
467         switch( $type )\r
468         {\r
469                 case 'HEAD':\r
470                         echo "<th>"._LIST_ITEM_INFO."</th>\n";\r
471                         echo "<th>"._LIST_ITEM_CONTENT."</th>\n";\r
472                         echo "<th colspan='1'>"._LISTS_ACTIONS."</th>";\r
473                         break;\r
474                 case 'BODY':\r
475                         $current = $template['current'];\r
476                         // string -> unix timestamp\r
477                         $current->itime = strtotime($current->itime);\r
478                         \r
479                         if ( $current->idraft == 1 )\r
480                         {\r
481                                 $cssclass = " class='draft'";\r
482                         }\r
483                         \r
484                         // (can't use offset time since offsets might vary between blogs)\r
485                         if ( $current->itime > $template['now'] )\r
486                         {\r
487                                 $cssclass = " class='future'";\r
488                         }\r
489                         \r
490                         echo "<td{$cssclass}>\n";\r
491                         echo "<dl>\n";\r
492                         echo '<dt>' . _LIST_ITEM_BLOG . "</dt>\n";\r
493                         echo '<dd>' . Entity::hsc($current->bshortname) . "</dd>\n";\r
494                         echo '<dt>' . _LIST_ITEM_CAT . "</dt>\n";\r
495                         echo '<dd>' . Entity::hsc($current->cname) . "</dd>\n";\r
496                         echo '<dt>' . _LIST_ITEM_AUTHOR . "</dt>\n";\r
497                         echo '<dd>' . Entity::hsc($current->mname) . "</dd>\n";\r
498                         echo '<dt>' . _LIST_ITEM_DATE . "</dt>\n";\r
499                         echo '<dd>' . date("Y-m-d",$current->itime) . "</dd>\n";\r
500                         echo '<dt>' . _LIST_ITEM_TIME . "</dt>\n";\r
501                         echo '<dd>' . date("H:i",$current->itime) . "</dd>\n";\r
502                         echo "</dl>\n";\r
503                         echo "</td>\n";\r
504                         \r
505                         $id = listplug_nextBatchId();\r
506                         \r
507                         echo "<td{$cssclass}>\n";\r
508                         echo "<h3>\n";\r
509                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->inumber}\" />\n";\r
510                         echo "<label for=\"batch{$id}\">" . Entity::hsc(strip_tags($current->ititle)) . "</label>\n";\r
511                         echo "</h3>\n";\r
512                         \r
513                         $current->ibody = strip_tags($current->ibody);\r
514                         $current->ibody = Entity::hsc(Entity::shorten($current->ibody, 300, '...'));\r
515                         echo "<p>$current->ibody</p>\n";\r
516                         echo "</td>\n";\r
517                         \r
518                         echo "<td{$cssclass}>\n";\r
519                         echo "<ul>\n";\r
520                         echo "<li><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></li>\n";\r
521                         \r
522                         // evaluate amount of comments for the item\r
523                         $COMMENTS = new Comments($current->inumber);\r
524                         $camount = $COMMENTS->amountComments();\r
525                         if ( $camount > 0 )\r
526                         {\r
527                                 echo "<li><a href=\"index.php?action=itemcommentlist&amp;itemid=$current->inumber\">( ";\r
528                                 echo sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments()) . " )</a></li>\n";\r
529                         }\r
530                         else\r
531                         {\r
532                                 echo '<li>' . _LIST_ITEM_NOCONTENT . "</li>\n";\r
533                         }\r
534                         \r
535                         echo "<li><a href=\"index.php?action=itemmove&amp;itemid={$current->inumber}\">" . _LISTS_MOVE . "</a></li>\n";\r
536                         echo "<li><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></li>\n";\r
537                         echo "</ul>\n";\r
538                         echo "</td>\n";\r
539                         break;\r
540         }\r
541         return;\r
542 }\r
543 \r
544 // for batch operations: generates the index numbers for checkboxes\r
545 function listplug_nextBatchId()\r
546 {\r
547         static $id = 0;\r
548         return $id++;\r
549 }\r
550 \r
551 function listplug_table_commentlist($template, $type)\r
552 {\r
553         switch( $type )\r
554         {\r
555                 case 'HEAD':\r
556                         echo '<th>' . _LISTS_INFO . "</th>\n";\r
557                         echo '<th>' . _LIST_COMMENT . "</th>\n";\r
558                         echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>";\r
559                         break;\r
560                 case 'BODY':\r
561                         $current = $template['current'];\r
562                         $current->ctime = strtotime($current->ctime);   // string -> unix timestamp\r
563                         \r
564                         echo "<td>\n";\r
565                         echo "<ul>\n";\r
566                         echo '<li>' . date("Y-m-d@H:i",$current->ctime) . "</li>\n";\r
567                         if ( isset($current->mname) )\r
568                         {\r
569                                 echo '<li>' . Entity::hsc($current->mname) ,' ', _LIST_COMMENTS_MEMBER . "</li>\n";\r
570                         }\r
571                         else\r
572                         {\r
573                                 echo '<li>' . Entity::hsc($current->cuser) . "</li>\n";\r
574                         }\r
575                         if ( isset($current->cmail) && $current->cmail )\r
576                         {\r
577                                 echo '<li>' . Entity::hsc($current->cmail) . "</li>\n";\r
578                         }\r
579                         if ( isset($current->cemail) && $current->cemail )\r
580                         {\r
581                                 echo '<li>' . Entity::hsc($current->cemail) . "</li>\n";\r
582                         }\r
583                         echo "</ul>\n";\r
584                         echo "</td>\n";\r
585 \r
586                         $id = listplug_nextBatchId();\r
587                         \r
588                         echo '<td>';\r
589                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}\" value=\"{$current->cnumber}\" />\n";\r
590                         echo "<label for=\"batch{$id}\">\n";\r
591                         $current->cbody = strip_tags($current->cbody);\r
592                         $current->cbody = Entity::hsc(Entity::shorten($current->cbody, 300, '...'));\r
593                         echo $current->cbody;\r
594                         echo '</label>';\r
595                         echo '</td>';\r
596                         \r
597                         echo '<td><a href="index.php?action=commentedit&amp;commentid=' . $current->cnumber . '">' . _LISTS_EDIT . "</a></td>\n";\r
598                         echo '<td><a href="index.php?action=commentdelete&amp;commentid=' . $current->cnumber . '">' . _LISTS_DELETE . "</a></td>\n";\r
599                         if ( $template['canAddBan'] )\r
600                         {\r
601                                 echo '<td><a href="index.php?action=banlistnewfromitem&amp;itemid=' . $current->citem . '&amp;ip=' . Entity::hsc($current->cip), '" title="' . Entity::hsc($current->chost) . '">' . _LIST_COMMENT_BANIP . "</a></td>\n";\r
602                         }\r
603                         break;\r
604         }\r
605         return;\r
606 }\r
607 \r
608 function listplug_table_bloglist($template, $type)\r
609 {\r
610         switch( $type )\r
611         {\r
612                 case 'HEAD':\r
613                         echo '<th>' . _NAME . "</th>\n";\r
614                         echo '<th colspan="7">' . _LISTS_ACTIONS . "</th>\n";\r
615                         break;\r
616                 case 'BODY':\r
617                         $current = $template['current'];\r
618                         $current->bname = Entity::hsc($current->bname);\r
619                         \r
620                         echo "<td title=\"blogid:{$current->bnumber} shortname:{$current->bshortname}\"><a href=\"{$current->burl}\"><img src=\"images/globe.gif\" width=\"13\" height=\"13\" alt=\"". _BLOGLIST_TT_VISIT."\" /></a>{$current->bname}</td>\n";\r
621                         echo "<td><a href=\"index.php?action=createitem&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_ADD ."\">" . _BLOGLIST_ADD . "</a></td>\n";\r
622                         echo "<td><a href=\"index.php?action=itemlist&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_EDIT."\">". _BLOGLIST_EDIT."</a></td>\n";\r
623                         echo "<td><a href=\"index.php?action=blogcommentlist&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_COMMENTS."\">". _BLOGLIST_COMMENTS."</a></td>\n";\r
624                         echo "<td><a href=\"index.php?action=bookmarklet&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_BMLET."\">". _BLOGLIST_BMLET . "</a></td>\n";\r
625                         \r
626                         if ( $current->tadmin == 1 )\r
627                         {\r
628                                 echo "<td><a href=\"index.php?action=blogsettings&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_SETTINGS . "\">" . _BLOGLIST_SETTINGS . "</a></td>\n";\r
629                                 echo "<td><a href=\"index.php?action=banlist&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_BANS . "\">" . _BLOGLIST_BANS . "</a></td>\n";\r
630                         }\r
631                         \r
632                         if ( $template['superadmin'] )\r
633                         {\r
634                                 echo "<td><a href=\"index.php?action=deleteblog&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_DELETE."\">" ._BLOGLIST_DELETE. "</a></td>\n";\r
635                         }\r
636                         break;\r
637         }\r
638         return;\r
639 }\r
640 \r
641 function listplug_table_shortblognames($template, $type)\r
642 {\r
643         switch( $type )\r
644         {\r
645                 case 'HEAD':\r
646                         echo '<th>' . _EBLOG_SHORTNAME . "</th>\n";\r
647                         echo '<th>' . _EBLOG_NAME. "</th>";\r
648                         break;\r
649                 case 'BODY':\r
650                         $current = $template['current'];\r
651                         $current->bshortname = Entity::hsc($current->bshortname);\r
652                         $current->bname = Entity::hsc($current->bname);\r
653                         \r
654                         echo "<td>{$current->bshortname}</td>\n";\r
655                         echo "<td>{$current->bname}</td>\n";\r
656                         break;\r
657         }\r
658         return;\r
659 }\r
660 \r
661 function listplug_table_shortnames($template, $type)\r
662 {\r
663         switch( $type )\r
664         {\r
665                 case 'HEAD':\r
666                         echo '<th>' . _NAME . "</th>\n";\r
667                         echo '<th>' . _LISTS_DESC. "</th>\n";\r
668                         break;\r
669                 case 'BODY':\r
670                         $current = $template['current'];\r
671                         $current->name = Entity::hsc($current->name);\r
672                         $current->description = Entity::hsc($current->description);\r
673                         \r
674                         echo "<td>{$current->name}</td>\n";\r
675                         echo "<td>{$current->description}</td>\n";\r
676                         break;\r
677         }\r
678         return;\r
679 }\r
680 \r
681 \r
682 function listplug_table_categorylist($template, $type)\r
683 {\r
684         switch( $type )\r
685         {\r
686                 case 'HEAD':\r
687                         echo '<th>' . _LISTS_NAME . "</th>";\r
688                         echo '<th>' . _LISTS_DESC."</th>\n";\r
689                         echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";\r
690                         break;\r
691                 case 'BODY':\r
692                         $id = listplug_nextBatchId();\r
693                         \r
694                         $current = $template['current'];\r
695                         $current->cname = Entity::hsc($current->cname);\r
696                         $current->cdesc = Entity::hsc($current->cdesc);\r
697                         \r
698                         echo "<td>\n";\r
699                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->catid}\" />\n";\r
700                         echo "<label for=\"batch{$id}\">{$current->cname}</label>\n";\r
701                         echo "</td>\n";\r
702                         echo "<td>{$current->cdesc}</td>\n";\r
703                         echo "<td><a href=\"index.php?action=categoryedit&amp;blogid={$current->cblog}&amp;catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a></td>\n";\r
704                         echo "<td><a href=\"index.php?action=categorydelete&amp;blogid={$current->cblog}&amp;catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";\r
705                         break;\r
706         }\r
707         return;\r
708 }\r
709 \r
710 function listplug_table_templatelist($template, $type)\r
711 {\r
712         global $manager;\r
713         switch( $type )\r
714         {\r
715                 case 'HEAD':\r
716                         echo '<th>' . _LISTS_NAME . "</th>\n";\r
717                         echo '<th>' . _LISTS_DESC . "</th>\n";\r
718                         echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";\r
719                         break;\r
720                 case 'BODY':\r
721                         $current = $template['current'];\r
722                         $current->tdnumber = (integer) $current->tdnumber;\r
723                         $current->tdname = Entity::hsc($current->tdname);\r
724                         $current->tddesc = Entity::hsc($current->tddesc);\r
725                         \r
726                         $url = "index.php?action=templateclone&templateid={$current->tdnumber}";\r
727                         $url = Entity::hsc($manager->addTicketToUrl($url));\r
728                         \r
729                         echo "<td>{$current->tdname}</td>\n";\r
730                         echo "<td>{$current->tddesc}</td>\n";\r
731                         echo "<td>\n";\r
732                         echo "<a href=\"index.php?action=templateedit&amp;templateid={$current->tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a>\n";\r
733                         echo "</td>\n";\r
734                         echo "<td>\n";\r
735                         echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";\r
736                         echo "</td>\n";\r
737                         echo "<td>\n";\r
738                         echo "<a href=\"index.php?action=templatedelete&amp;templateid={$current->tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a>\n";\r
739                         echo "</td>\n";\r
740                         break;\r
741         }\r
742         return;\r
743 }\r
744 \r
745 function listplug_table_skinlist($template, $type)\r
746 {\r
747         global $CONF, $DIR_SKINS, $manager;\r
748         switch( $type )\r
749         {\r
750                 case 'HEAD':\r
751                         echo '<th>' . _LISTS_NAME . "</th>\n";\r
752                         echo '<th>' . _LISTS_DESC . "</th>\n";\r
753                         echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";\r
754                         break;\r
755                 case 'BODY':\r
756                         $current = $template['current'];\r
757                         $current->sdnumber = (integer) $current->sdnumber;\r
758                         $current->sdname = Entity::hsc($current->sdname);\r
759                         $current->sdtype = Entity::hsc($current->sdtype);\r
760                         \r
761                         echo "<td>\n";\r
762                         \r
763                         // use a special style for the default skin\r
764                         if ( $current->sdnumber == $CONF['BaseSkin'] )\r
765                         {\r
766                                 echo '<h3 id="base_skin">' . $current->sdname . "</h3>\n";\r
767                         }\r
768                         else\r
769                         {\r
770                                 echo '<h3>' . $current->sdname . "</h3>\n";\r
771                         }\r
772                         \r
773                         echo "<dl>\n";\r
774                         echo '<dt>' . _LISTS_TYPE . "</dt>\n";\r
775                         echo '<dd>' . $current->sdtype . "</dd>\n";\r
776                         \r
777                         echo '<dt>' . _LIST_SKINS_INCMODE . "</dt>\n";\r
778                         \r
779                         if ( $current->sdincmode == 'skindir' )\r
780                         {\r
781                                 echo '<dd>' . _PARSER_INCMODE_SKINDIR . "</dd>\n";\r
782                         }\r
783                         else\r
784                         {\r
785                                 echo '<dd>' . _PARSER_INCMODE_NORMAL . "</dd>\n";\r
786                         }\r
787                         \r
788                         if ( $current->sdincpref )\r
789                         {\r
790                                 echo '<dt>' . _LIST_SKINS_INCPREFIX . "</dt>\n";\r
791                                 echo '<dd>' . Entity::hsc($current->sdincpref) . "</dd>\n";\r
792                         }\r
793                         echo "</dl>\n";\r
794                         \r
795                         // add preview image when present\r
796                         if ( $current->sdincpref && @file_exists("{$DIR_SKINS}{$current->sdincpref}preview.png") )\r
797                         {\r
798                                 echo "<p>\n";\r
799                                 \r
800                                 $alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current->sdname);\r
801                                 $has_enlargement = @file_exists($DIR_SKINS . $current->sdincpref . 'preview-large.png');\r
802                                 if ( $has_enlargement )\r
803                                 {\r
804                                         echo '<a href="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview-large.png" title="' . _LIST_SKIN_PREVIEW_VIEWLARGER . "\">\n";\r
805                                         echo '<img class="skinpreview" src="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" />\n";\r
806                                         echo "</a><br />\n";\r
807                                 }\r
808                                 else\r
809                                 {\r
810                                         echo '<img class="skinpreview" src="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" /><br />\n";\r
811                                 }\r
812                                 \r
813                                 if ( @file_exists("{$DIR_SKINS}{$current->sdincpref}readme.html") )\r
814                                 {\r
815                                         $url = $CONF['SkinsURL'] . Entity::hsc($current->sdincpref) . 'readme.html';\r
816                                         $title = sprintf(_LIST_SKIN_README, $current->sdname);\r
817                                         echo "<a href=\"{$url}\" title=\"{$title}\">" . _LIST_SKIN_README_TXT . "</a>\n";\r
818                                 }\r
819                                 \r
820                                 echo "</p>\n";\r
821                         }\r
822                         \r
823                         echo "</td>\n";\r
824                         \r
825                         echo "<td>\n";\r
826                         echo '<p>' . Entity::hsc($current->sddesc) . "</p>\n";\r
827                         \r
828                         /* show list of defined parts */\r
829                         $query = "SELECT stype FROM %s WHERE sdesc=%d ORDER BY stype";\r
830                         $query = sprintf($query, sql_table('skin'), $current->sdnumber);\r
831                         $r = sql_query($query);\r
832                         \r
833                         $types = array();\r
834                         while ( $o = sql_fetch_object($r) )\r
835                         {\r
836                                 array_push($types, $o->stype);\r
837                         }\r
838                         if ( sizeof($types) > 0 )\r
839                         {\r
840                                 $friendlyNames = SKIN::getFriendlyNames();\r
841                                 for ( $i = 0; $i < sizeof($types); $i++ )\r
842                                 {\r
843                                         $type = $types[$i];\r
844                                         if ( !in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup')) )\r
845                                         {\r
846                                                 $article = 'skinpartspecial';\r
847                                         }\r
848                                         else\r
849                                         {\r
850                                                 $article = "skinpart{$type}";\r
851                                         }\r
852                                         $types[$i]  = "<li>\n";\r
853                                         $types[$i] .= helpHtml($article) . "\n";\r
854                                         $types[$i] .= "<a href=\"index.php?action=skinedittype&amp;skinid={$current->sdnumber}&amp;type={$type}\" tabindex=\"{$template['tabindex']}\">" . Entity::hsc($friendlyNames[$type]) . "</a>\n";\r
855                                         $types[$i] .= "</li>\n";\r
856                                 }\r
857                                 echo _LIST_SKINS_DEFINED;\r
858                                 echo '<ul>' . implode('', $types) . "</ul>\n";\r
859                         }\r
860                         echo "</td>";\r
861                         echo "<td>\n";\r
862                         echo "<a href=\nindex.php?action=skinedit&amp;skinid={$current->sdnumber}\n tabindex=\n{$template['tabindex']}>" . _LISTS_EDIT . "</a>\n";\r
863                         echo "</td>\n";\r
864                         \r
865                         $url = "index.php?action=skinclone&skinid={$current->sdnumber}";\r
866                         $url = Entity::hsc($manager->addTicketToUrl($url));\r
867                         echo "<td>\n";\r
868                         echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";\r
869                         echo "</td>\n";\r
870                         echo "<td>\n";\r
871                         echo "<a href=\"index.php?action=skindelete&amp;skinid={$current->sdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";\r
872                         break;\r
873         }\r
874         return;\r
875 }\r
876 \r
877 function listplug_table_draftlist($template, $type)\r
878 {\r
879         switch( $type )\r
880         {\r
881                 case 'HEAD':\r
882                         echo '<th>' . _LISTS_BLOG . "</th>\n";\r
883                         echo '<th>' . _LISTS_TITLE . "</th>\n";\r
884                         echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";\r
885                         break;\r
886                 case 'BODY':\r
887                         $current = $template['current'];\r
888                         $current->bshortname = Entity::hsc($current->bshortname);\r
889                         $current->ititle = Entity::hsc(strip_tags($current->ititle));\r
890                         \r
891                         echo "<td>{$current->bshortname}</td>\n";\r
892                         echo "<td>{$current->ititle}</td>\n";\r
893                         echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></td>\n";\r
894                         echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></td>\n";\r
895                         break;\r
896         }\r
897         return;\r
898 }\r
899 \r
900 function listplug_table_otherdraftlist($template, $type)\r
901 {\r
902         switch( $type )\r
903         {\r
904                 case 'HEAD':\r
905                         echo '<th>' . _LISTS_BLOG . "</th>\n";\r
906                         echo '<th>' . _LISTS_TITLE . "</th>\n";\r
907                         echo '<th>' . _LISTS_AUTHOR . "</th>\n";\r
908                         echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";\r
909                         break;\r
910                 case 'BODY':\r
911                         $current = $template['current'];\r
912                         $current->bshortname = Entity::hsc($current->bshortname);\r
913                         $current->ititle = Entity::hsc(strip_tags($current->ititle));\r
914                         $current->mname = Entity::hsc($current->mname);\r
915                         \r
916                         echo "<td>{$current->bshortname}</td>\n";\r
917                         echo "<td>{$current->ititle}</td>\n";\r
918                         echo "<td>{$current->mname}</td>\n";\r
919                         echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></td>\n";\r
920                         echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></td>\n";\r
921                         break;\r
922         }\r
923         return;\r
924 }\r
925 \r
926 function listplug_table_actionlist($template, $type)\r
927 {\r
928         switch( $type )\r
929         {\r
930                 case 'HEAD':\r
931                         echo '<th>' . _LISTS_TIME . "</th>\n";\r
932                         echo '<th>' . _LIST_ACTION_MSG . "</th>\n";\r
933                         break;\r
934                 case 'BODY':\r
935                         $current = $template['current'];\r
936                         $current->timestamp = Entity::hsc($current->timestamp);\r
937                         $current->message = Entity::hsc($current->message);\r
938                         \r
939                         echo "<td>{$current->timestamp}</td>\n";\r
940                         echo "<td>{$current->message}</td>\n";\r
941                         break;\r
942         }\r
943         return;\r
944 }\r
945 \r
946 function listplug_table_banlist($template, $type)\r
947 {\r
948         switch( $type )\r
949         {\r
950                 case 'HEAD':\r
951                         echo '<th>' . _LIST_BAN_IPRANGE . "</th>\n";\r
952                         echo '<th>' . _LIST_BAN_REASON."</th>\n";\r
953                         echo '<th>' . _LISTS_ACTIONS . "</th>\n";\r
954                         break;\r
955                 case 'BODY':\r
956                         $current = $template['current'];\r
957                         $current->blogid = (integer) $current->blogid;\r
958                         $current->iprange = Entity::hsc($current->iprange);\r
959                         $current->reason = Entity::hsc($current->reason);\r
960                         \r
961                         echo "<td>{$current->iprange}</td>\n";\r
962                         echo "<td>{$current->reason}</td>\n";\r
963                         echo "<td><a href=\"index.php?action=banlistdelete&amp;blogid=\"{$current->blogid}&amp;iprange=\"Entity::hsc($current->iprange}\">" . _LISTS_DELETE . "</a></td>\n";\r
964                         break;\r
965         }\r
966         return;\r
967 }\r