OSDN Git Service

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