OSDN Git Service

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