OSDN Git Service

Merge branch 'skinnable-master'
[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 <<<<<<< HEAD
18  * @version $Id: showlist.php 1785 2012-04-22 11:25:14Z sakamocchi $
19 =======
20  * @version $Id: showlist.php 1886 2012-06-17 08:27:27Z sakamocchi $
21 >>>>>>> skinnable-master
22  */
23
24
25 // can take either an array of objects, or an SQL query
26 <<<<<<< HEAD
27 function showlist($query, $type, $template)
28 {
29         if ( is_array($query) )
30         {
31                 if ( sizeof($query) == 0 )
32                 {
33                         return 0;
34                 }
35                 
36                 call_user_func("listplug_{$type}", $template, 'HEAD');
37                 
38                 foreach ( $query as $currentObj )
39                 {
40                         $template['current'] = $currentObj;
41                         call_user_func("listplug_{$type}", $template, 'BODY');
42                 }
43                 
44                 call_user_func("listplug_{$type}", $template, 'FOOT');
45                 
46                 return sizeof($query);
47         }
48         else
49         {
50                 $res = DB::getResult($query);
51                 
52                 // don't do anything if there are no results
53                 $numrows = $res->rowCount();
54                 if ( $numrows == 0 )
55                 {
56                         return 0;
57                 }
58                 call_user_func("listplug_{$type}", $template, 'HEAD');
59                 
60                 foreach ( $res as $row )
61                 {
62                         $template['current'] = $row;
63                         call_user_func("listplug_{$type}", $template, 'BODY');
64                 }
65                 
66                 call_user_func("listplug_{$type}", $template, 'FOOT');
67                 
68                 $res->closeCursor();
69                 
70                 // return amount of results
71                 return $numrows;
72         }
73 }
74
75 function listplug_select($template, $type)
76 {
77         switch( $type )
78         {
79                 case 'HEAD':
80                         echo "<select name=\"{$template['name']}\" tabindex=\"{$template['tabindex']}\"";
81                         if ( array_key_exists('javascript', $template) && !empty($template['javascript']) )
82                         {
83                                 echo " {$template['javascript']}";
84                         }
85                         echo ">\n";
86                         
87                         // add extra row if needed
88                         if ( array_key_exists('extra', $template) && !empty($template['extra']) )
89                         {
90                                 echo "<option value=\"{$template['extraval']}\">{$template['extra']}</option>\n";
91                         }
92                         
93                         break;
94                 case 'BODY':
95                         $current = $template['current'];
96
97                         echo '<option value="' . Entity::hsc($current['value']) . '"';
98                         if ( array_key_exists('selected', $template) && $template['selected'] == $current['value'] )
99                         {
100                                 echo ' selected="selected" ';
101                         }
102                         if ( isset($template['shorten']) && $template['shorten'] > 0 )
103                         {
104                                 echo ' title="'. Entity::hsc($current['text']).'"';
105                                 $current['text'] = Entity::hsc(Entity::shorten($current['text'], $template['shorten'], $template['shortenel']));
106                         }
107                         echo '>' . Entity::hsc($current['text']) . "</option>\n";
108                         break;
109                 case 'FOOT':
110                         echo '</select>';
111                         break;
112         }
113         return;
114 }
115
116 function listplug_table($template, $type)
117 {
118         switch( $type )
119         {
120                 case 'HEAD':
121                         echo "\n\n";
122                         echo "<table frame=\"box\" rules=\"all\" summary=\"{$template['content']}\">\n";
123                         echo "<thead>\n";
124                         echo "<tr>\n";
125                         // print head
126                         call_user_func("listplug_table_{$template['content']}" , $template, 'HEAD');
127                         echo "</tr>\n";
128                         echo "</thead>\n";
129                         echo "<tbody>\n";
130                         break;
131                 case 'BODY':
132                         // print tabletype specific thingies
133                         echo "<tr>\n";
134                         call_user_func("listplug_table_{$template['content']}" , $template,  'BODY');
135                         echo "</tr>\n";
136                         break;
137                 case 'FOOT':
138                         call_user_func("listplug_table_{$template['content']}" , $template,  'FOOT');
139                         echo "</tbody>\n";
140                         echo "</table>\n";
141                         echo "\n";
142                         break;
143         }
144         return;
145 }
146
147 function listplug_table_memberlist($template, $type)
148 {
149         switch( $type )
150         {
151                 case 'HEAD':
152                         echo '<th>' . _LIST_MEMBER_NAME . "</th>\n";
153                         echo '<th>' . _LIST_MEMBER_RNAME . "</th>\n";
154                         echo '<th>' . _LIST_MEMBER_URL . "</th>\n";
155                         echo '<th>' . _LIST_MEMBER_ADMIN;
156                         help('superadmin');
157                         echo "</th>\n";
158                         echo '<th>' . _LIST_MEMBER_LOGIN;
159                         help('canlogin');
160                         echo "</th>\n";
161                         echo '<th colspan="2">' . _LISTS_ACTIONS. "</th>\n";
162                         break;
163                 case 'BODY':
164                         $current = $template['current'];
165                         echo '<td>';
166                         $id = listplug_nextBatchId();
167                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current['mnumber']}\" />\n";
168                         echo "<label for=\"batch{$id}\">\n";
169                         echo '<a href="mailto:' . Entity::hsc($current['memail']) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current['mname']), "</a>\n";
170                         echo "</label>\n";
171                         echo "</td>";
172                         echo "<td>" . Entity::hsc($current['mrealname']) . "</td>\n";
173                         echo '<td><a href="' . Entity::hsc($current['murl']) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current['murl']) . "</a></td>\n";
174                         echo '<td>' . ($current['madmin'] ? _YES : _NO) . "</td>\n";
175                         echo '<td>' . ($current['mcanlogin'] ? _YES : _NO) . "</td>\n";
176                         echo '<td><a href="index.php?action=memberedit&amp;memberid=' . $current['mnumber'] . '" tabindex="' . $template['tabindex'] . '">' . _LISTS_EDIT . "</a></td>\n";
177                         echo '<td><a href="index.php?action=memberdelete&amp;memberid=' . $current['mnumber'] . '" tabindex="' . $template['tabindex'].'">' . _LISTS_DELETE . "</a></td>\n";
178                         break;
179         }
180         return;
181 }
182
183 function listplug_table_teamlist($template, $type)
184 {
185         global $manager;
186         switch( $type )
187         {
188                 case 'HEAD':
189                         echo "<th>" . _LIST_MEMBER_NAME . "</th>\n";
190                         echo "<th>" . _LIST_MEMBER_RNAME . "</th>\n";
191                         echo "<th>" . _LIST_TEAM_ADMIN;
192                         help('teamadmin');
193                         echo "</th>\n";
194                         echo "<th colspan=\"2\">"._LISTS_ACTIONS."</th>\n";
195                         break;
196                 case 'BODY':
197                         $current = $template['current'];
198                         
199                         echo '<td>';
200                         $id = listplug_nextBatchId();
201                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current['tmember']}\" />\n";
202                         echo '<label for="batch',$id,'">';
203                         echo '<a href="mailto:' . Entity::hsc($current['memail']) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current['mname']), "</a>\n";
204                         echo "</label>\n";
205                         echo "</td>";
206                         echo '<td>', Entity::hsc($current['mrealname']), "</td>\n";
207                         echo '<td>', ($current['tadmin'] ? _YES : _NO) , "</td>\n";
208                         echo '<td><a href="index.php?action=teamdelete&amp;memberid=' . $current['tmember'] . '&amp;blogid=' . $current['tblog'] . '" tabindex="' . $template['tabindex'] . '">' . _LISTS_DELETE . "</a></td>\n";
209                         
210                         $url = "index.php?action=teamchangeadmin&memberid={$current['tmember']}&blogid={$current['tblog']}";
211                         $url = $manager->addTicketToUrl($url);
212                         echo '<td><a href="' . Entity::hsc($url) . '" tabindex="' . $template['tabindex'] . '">' . _LIST_TEAM_CHADMIN . "</a></td>\n";
213                         break;
214         }
215         return;
216 }
217
218 function listplug_table_pluginlist($template, $type)
219 {
220         global $manager;
221         switch( $type )
222         {
223                 case 'HEAD':
224                         echo '<th>' . _LISTS_INFO . "</th>\n";
225                         echo '<th>' . _LISTS_DESC . "</th>\n";
226                         echo '<th>' . _LISTS_ACTIONS . "</th>\n";
227                         break;
228                 case 'BODY':
229                         $current = $template['current'];
230 =======
231 function showlist($query, $type, $vars, $template_name = '')
232 {
233         $contents = '';
234         
235         /* count */
236         if ( is_string($query) )
237         {
238                 $resource = DB::getResult($query);
239         }
240         else
241         {
242                 $resource = $query;
243         }
244         
245         /* HEAD */
246         $contents .= call_user_func("listplug_{$type}", $vars, 'HEAD', $template_name);
247         
248         /* BODY */
249         foreach ( $resource as $row )
250         {
251                 $vars['current'] = $row;
252                 $contents .= call_user_func("listplug_{$type}", $vars, 'BODY', $template_name);
253         }
254         
255         /* FOOT */
256         $contents .= call_user_func("listplug_{$type}", $vars, 'FOOT', $template_name);
257         
258         /* close SQL resource */
259         if ( is_string($query) )
260         {
261                 $resource->closeCursor();
262         }
263         
264         return $contents;
265 }
266
267 function listplug_select($vars, $type, $template_name = '')
268 {
269         global $manager;
270         
271         $templates = array();
272         if ( !empty($template_name) )
273         {
274                 $templates =& $manager->getTemplate($template_name);
275         }
276         
277         switch( $type )
278         {
279                 case 'HEAD':
280                         if ( !array_key_exists('SHOWLIST_LISTPLUG_SELECT_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_SELECT_HEAD']) )
281                         {
282                                 $template = "<select name=\"<%name%>\" tabindex=\"<%tabindex%>\" <%javascript%>>\n"
283                                           . "<%extraoption%>\n";
284                         }
285                         else
286                         {
287                                 $template = $templates['SHOWLIST_LISTPLUG_SELECT_HEAD'];
288                         }
289                         $data = array(
290                                 'name'                  => $vars['name'],
291                                 'tabindex'              => $vars['tabindex'],
292                                 'javascript'    => !array_key_exists('javascript', $vars) ? '' : $vars['javascript'],
293                                 'extraoption'   => !array_key_exists('extra', $vars) ? '' : "<option value=\"\">{$vars['extra']}</option>"
294                         );
295                         break;
296                 case 'BODY':
297                         $current = $vars['current'];
298                         if ( !array_key_exists('SHOWLIST_LISTPLUG_SELECT_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_SELECT_BODY']) )
299                         {
300                                 $template = "<option value=\"<%value%>\" <%selected%> title=\"<%title%>\"><%option%></option>\n";
301                         }
302                         else
303                         {
304                                 $template = $templates['SHOWLIST_LISTPLUG_SELECT_BODY'];
305                         }
306                         $data = array(
307                                 'value'         => Entity::hsc($current['value']),
308                                 'selected'      => ($vars['selected'] == $current['value']) ? 'selected="selected"' : '',
309                         );
310                         if ( array_key_exists('shorten', $vars) && $vars['shorten'] > 0 )
311                         {
312                                 $data['title'] = Entity::hsc($current['text']);
313                                 $data['option'] = Entity::hsc(Entity::shorten($current['text'], $vars['shorten'], $vars['shortenel']));
314                         }
315                         else
316                         {
317                                 $data['title'] = '';
318                         }
319                         $data['option'] = Entity::hsc($current['text']);
320                         break;
321                 case 'FOOT':
322                         if ( !array_key_exists('SHOWLIST_LISTPLUG_SELECT_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_SELECT_FOOT']) )
323                         {
324                                 $template = "</select>\n";
325                         }
326                         else
327                         {
328                                 $template = $templates['SHOWLIST_LISTPLUG_SELECT_FOOT'];
329                         }
330                         $data = array();
331                         break;
332         }
333         
334         return Template::fill($template, $data);
335 }
336
337 function listplug_table($vars, $type, $template_name = '')
338 {
339         global $manager;
340         
341         $templates = array();
342         if ( !empty($template_name) )
343         {
344                 $templates =& $manager->getTemplate($template_name);
345         }
346         
347         switch( $type )
348         {
349                 case 'HEAD':
350                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_HEAD']) )
351                         {
352                                 $template = "<table frame=\"box\" rules=\"all\" summary=\"{$vars['content']}\">\n"
353                                           . "<thead>\n"
354                                           . "<tr>\n"
355                                           . "<%typehead%>\n"
356                                           . "</tr>\n"
357                                           . "</thead>\n"
358                                           . "<tbody>\n";
359                         }
360                         else
361                         {
362                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_HEAD'];
363                         }
364                         $data = array(
365                                 'summary'       =>      $vars['content'],
366                                 'typehead' => call_user_func("listplug_table_" . $vars['content'] , $vars, 'HEAD', $template_name)
367                         );
368                         break;
369                 case 'BODY':
370                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BODY']) )
371                         {
372                                 $template = "<tr onmouseover=\"focusRow(this);\" onmouseout=\"blurRow(this);\">\n"
373                                           . "<%typebody%>\n"
374                                           . "</tr>\n";
375                         }
376                         else
377                         {
378                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_BODY'];
379                         }
380                         // tabletype specific thingies
381                         $data = array(
382                                 'typebody' => call_user_func("listplug_table_" . $vars['content'] , $vars, 'BODY', $template_name)
383                         );
384                         break;
385                 case 'FOOT':
386                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_FOOT']) )
387                         {
388                                 $template = "<%typefoot%>\n"
389                                           . "</tbody>\n"
390                                           . "</table>\n";
391                         }
392                         else
393                         {
394                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_FOOT'];
395                         }
396                         // tabletype specific thingies
397                         $data = array(
398                                 'typefoot' => call_user_func("listplug_table_" . $vars['content'] , $vars, 'FOOT', $template_name)
399                         );
400                         break;
401         }
402         
403         return Template::fill($template, $data);
404 }
405
406 function listplug_table_memberlist($vars, $type, $template_name = '')
407 {
408         global $manager;
409         
410         $templates = array();
411         if ( !empty($template_name) )
412         {
413                 $templates =& $manager->getTemplate($template_name);
414         }
415         
416         switch( $type )
417         {
418                 case 'HEAD':
419                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD']) )
420                         {
421                                 $template = "<th><%colmembername%></th>\n"
422                                           . "<th><%colmemberrname%></th>\n"
423                                           . "<th><%colmemberurl%></th>\n"
424                                           . "<th><%colmemberadmin%><%helplink(superadmin)%></th>\n"
425                                           . "<th><%colmemberlogin%><%helplink(canlogin)%></th>\n"
426                                           . "<th colspan=\"2\"><%colactions%></th>\n";
427                         }
428                         else
429                         {
430                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD'];
431                         }
432                         $data = array(
433                                 'colmembername'         => _LIST_MEMBER_NAME,
434                                 'colmemberrname'        => _LIST_MEMBER_RNAME,
435                                 'colmemberurl'          => _LIST_MEMBER_URL,
436                                 'colmemberadmin'        => _LIST_MEMBER_ADMIN,
437                                 'colmemberlogin'        => _LIST_MEMBER_LOGIN,
438                                 'colactions'            => _LISTS_ACTIONS,
439                         );
440                         break;
441                 case 'BODY':
442                         $current = $vars['current'];
443                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY']) )
444                         {
445                                 $template = "<td>\n"
446                                           . "<input type=\"checkbox\" id=\"batch<%id%>\" name=\"batch[<%id%>]\" value=\"<%memberid%>\" />\n"
447                                           . "<label for=\"batch<%id%>\">\n"
448                                           . "<a href=\"mailto:<%mailaddress%>\" tabindex=\"<%tabindex%>\"><%name%></a>\n"
449                                           . "</label>\n</td>\n"
450                                           . "<td><%realname%></td>\n"
451                                           . "<td><a href=\"<%url%>\" tabindex=\"<%tabindex%>\"><%url%></a></td>\n"
452                                           . "<td><%admin%></td>\n"
453                                           . "<td><%login%></td>\n"
454                                           . "<td><a href=\"index.php?action=memberedit&amp;memberid=<%memberid%>\" tabindex=\"<%tabindex%>\"><%editbtn%></a></td>\n"
455                                           . "<td><a href=\"index.php?action=memberdelete&amp;memberid=<%memberid%>\" tabindex=\"<%tabindex%>\"><%deletebtn%></a></td>\n";
456                         }
457                         else
458                         {
459                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY'];
460                         }
461                         $data = array(
462                                 'id'                    => listplug_nextBatchId(),
463                                 'memberid'              => $current['mnumber'],
464                                 'mailaddress'   => Entity::hsc($current['memail']),
465                                 'tabindex'              => $vars['tabindex'],
466                                 'name'                  => Entity::hsc($current['mname']),
467                                 'realname'              => Entity::hsc($current['mrealname']),
468                                 'url'                   => Entity::hsc($current['murl']),
469                                 'admin'                 => $current['madmin'] ? _YES : _NO,
470                                 'login'                 => $current['mcanlogin'] ? _YES : _NO,
471                                 'editbtn'               => _LISTS_EDIT,
472                                 'deletebtn'             => _LISTS_DELETE,
473                         );
474                         break;
475                 case 'FOOT':
476                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT']) )
477                         {
478                                 $template = "";
479                         }
480                         else
481                         {
482                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT'];
483                         }
484                         $data = array();
485                         break;
486         }
487         return Template::fill($template, $data);
488 }
489
490 function listplug_table_teamlist($vars, $type, $template_name = '')
491 {
492         global $manager;
493         
494         $templates = array();
495         if ( !empty($template_name) )
496         {
497                 $templates =& $manager->getTemplate($template_name);
498         }
499         
500         switch( $type )
501         {
502                 case 'HEAD':
503                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD']) )
504                         {
505                                 $template = "<th><%colmembername%></th>\n"
506                                           . "<th><%colmemberrname%></th>\n"
507                                           . "<th><%colteamadmin%><%helplink(teamadmin)%></th>\n"
508                                           . "<th colspan=\"2\"><%colactions%></th>\n";
509                         }
510                         else
511                         {
512                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD'];
513                         }
514                         $data = array(
515                                 'colmembername'         => _LIST_MEMBER_NAME,
516                                 'colmemberrname'        => _LIST_MEMBER_RNAME,
517                                 'colteamadmin'          => _LIST_TEAM_ADMIN,
518                                 'colactions'            => _LISTS_ACTIONS,
519                         );
520                         break;
521                 case 'BODY':
522                         $current = $vars['current'];
523                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY']) )
524                         {
525                                 $template = "<td>\n"
526                                           . "<input type=\"checkbox\" id=\"batch<%id%>\" name=\"batch[<%id%>]\" value=\"<%memberid%>\" />\n"
527                                           . "<label for=\"batch<%id%>\">\n"
528                                           . "<a href=\"mailto:<%mailaddress%>\" tabindex=\"<%tabindex%>\"><%name%></a>\n"
529                                           . "</label>\n</td>\n"
530                                           . "<td><%realname%></td>\n"
531                                           . "<td><%admin%></td>\n"
532                                           . "<td><a href=\"index.php?action=teamdelete&amp;memberid=<%memberid%>&amp;blogid=<%blogid%>\" tabindex=\"<%tabindex%>\"><%deletebtn%></a></td>\n"
533                                           . "<td><a href=\"<%chadminurl%>\" tabindex=\"<%tabindex%>\"><%chadminbtn%></a></td>\n";
534                         }
535                         else
536                         {
537                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY'];
538                         }
539                         $url  = 'index.php?action=teamchangeadmin&memberid=' . intval($current['tmember']) . '&blogid=' . intval($current['tblog']);
540                         $url  = $manager->addTicketToUrl($url);
541                         $data = array(
542                                         'id'                    => listplug_nextBatchId(),
543                                         'memberid'              => $current['tmember'],
544                                         'mailaddress'   => Entity::hsc($current['memail']),
545                                         'tabindex'              => $vars['tabindex'],
546                                         'name'                  => Entity::hsc($current['mname']),
547                                         'realname'              => Entity::hsc($current['mrealname']),
548                                         'admin'                 => ($current['tadmin'] ? _YES : _NO),
549                                         'blogid'                => $current['tblog'],
550                                         'deletebtn'             => '<%text(_LISTS_DELETE)%>',
551                                         'chadminurl'    => Entity::hsc($url),
552                                         'chadminbtn'    => '<%text(_LIST_TEAM_CHADMIN)%>'
553                         );
554                         break;
555                 case 'FOOT':
556                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT']) )
557                         {
558                                 $template = "";
559                         }
560                         else
561                         {
562                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT'];
563                         }
564                         $data = array();
565                         break;
566         }
567         return Template::fill($template, $data);
568 }
569
570 function listplug_table_pluginlist($vars, $type, $template_name = '')
571 {
572         static $plugins = array();
573         global $manager;
574         
575         $templates = array();
576         if ( !empty($template_name) )
577         {
578                 $templates =& $manager->getTemplate($template_name);
579         }
580         
581         switch( $type )
582         {
583                 case 'HEAD':
584                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD']) )
585                         {
586                                 $template = "<th><%colinfo%></th>\n"
587                                           . "<th><%coldesc%></th>\n"
588                                           . "<th colspan=\"2\"><%colactions%></th>\n";
589                         }
590                         else
591                         {
592                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD'];
593                         }
594                         $data = array(
595                                 'colinfo'    => _LISTS_INFO,
596                                 'coldesc'    => _LISTS_DESC,
597                                 'colactions' => _LISTS_ACTIONS,
598                         );
599                         break;
600                 case 'BODY':
601                         $current = $vars['current'];
602 >>>>>>> skinnable-master
603                         
604                         $plug =& $manager->getPlugin($current['pfile']);
605                         if ( $plug )
606                         {
607 <<<<<<< HEAD
608                                 echo "<td>\n";
609                                 echo '<h3>' . Entity::hsc($plug->getName()) . "</h3>\n";
610                                 
611                                 echo "<dl>\n";
612                                 if ( $plug->getAuthor() )
613                                 {
614                                         echo '<dt>' . _LIST_PLUGS_AUTHOR . "</dt>\n";
615                                         echo '<dd>' . Entity::hsc($plug->getAuthor()) , "</dd>\n";
616                                 }
617                                 
618                                 if ( $plug->getVersion() )
619                                 {
620                                         echo '<dt>' . _LIST_PLUGS_VER, "</dt>\n";
621                                         echo '<dd>' . Entity::hsc($plug->getVersion()) . "</dd>\n";
622                                 }
623                                 
624                                 if ( $plug->getURL() )
625                                 {
626                                         echo '<dt>' . _LIST_PLUGS_SITE . "<dt>\n";
627                                         echo '<dd><a href="' .  Entity::hsc($plug->getURL()) . '" tabindex="' . $template['tabindex'] . '">リンク</a></dd>' . "\n";
628                                 }
629                                 echo "</dl>\n";
630                                 echo "</td>\n";
631                                 
632                                 echo "<td>\n";
633                                 echo "<dl>\n";
634                                 echo '<dt>' . _LIST_PLUGS_DESC ."</dt>\n";
635                                 echo '<dd>' . Entity::hen($plug->getDescription()) ."</dd>\n";
636                                 if ( sizeof($plug->getEventList()) > 0 )
637                                 {
638                                         echo '<dt>' . _LIST_PLUGS_SUBS ."</dt>\n";
639                                         echo '<dd>' . Entity::hsc(implode(', ', $plug->getEventList())) ."</dd>\n";
640                                 }
641                                 
642                                 if ( sizeof($plug->getPluginDep()) > 0 )
643                                 {
644                                         echo '<dt>' . _LIST_PLUGS_DEP ."</dt>\n";
645                                         echo '<dd>' . Entity::hsc(implode(', ', $plug->getPluginDep())) ."</dd>\n";
646                                 }
647                                 
648                                 /* check dependency */
649                                 $req = array();
650                                 $res = DB::getResult('SELECT pfile FROM ' . sql_table('plugin'));
651                                 foreach ( $res as $row )
652                                 {
653                                         $preq =& $manager->getPlugin($row['pfile']);
654 =======
655                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY']) )
656                                 {
657                                         $template = "<td>\n"
658                                                   . "<strong><%plugname%></strong><br />\n"
659                                                   . "<%autherlabel%> <%plugauther%><br />\n"
660                                                   . "<%versionlabel%> <%plugversion%><br />\n"
661                                                   . "<%pluggeturl%><br />\n"
662                                                   . "</td>\n"
663                                                   . "<td>\n"
664                                                   . "<%desclabel%><br /><%plugdesc%>\n"
665                                                   . "<%eventlist%>\n"
666                                                   . "<%needupdate%>\n"
667                                                   . "<%dependlist%>\n"
668                                                   . "<%depreqlist%>\n"
669                                                   . "</td>\n";
670                                 }
671                                 else
672                                 {
673                                         $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY'];
674                                 }
675                                 $data = array(
676                                         'plugname'              => Entity::hsc($plug->getName()),
677                                         'autherlabel'   => _LIST_PLUGS_AUTHOR,
678                                         'plugauther'    => Entity::hsc($plug->getAuthor()),
679                                         'versionlabel'  => _LIST_PLUGS_VER,
680                                         'plugversion'   => Entity::hsc($plug->getVersion()),
681                                         'tabindex'              => $vars['tabindex'],
682                                         'desclabel'             => _LIST_PLUGS_DESC,
683                                         'plugdesc'              => Entity::hen($plug->getDescription()),
684                                 );
685                                 if ( $plug->getURL() )
686                                 {
687                                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL']) )
688                                         {
689                                                 $subTpl = "<a href=\"<%plugurl%>\" tabindex=\"<%tabindex%>\"><%plugsite%></a>";
690                                         }
691                                         else
692                                         {
693                                                 $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL'];
694                                         }
695                                         $subData = array(
696                                                 'plugurl'       => Entity::hsc($plug->getURL()),
697                                                 'tabindex'      => $vars['tabindex'],
698                                                 'plugsite'      => _LIST_PLUGS_SITE,
699                                         );
700                                         $data['pluggeturl'] = Template::fill($subTpl, $subData);
701                                 }
702                                 else
703                                 {
704                                         $data['pluggeturl'] = '';
705                                 }
706                                 if ( count($plug->getEventList()) > 0 )
707                                 {
708                                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST']) )
709                                         {
710                                                 $subTpl = "<br /><br /><%evntlstlbl%><br /><%eventlist%>";
711                                         }
712                                         else
713                                         {
714                                                 $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST'];
715                                         }
716                                         $subData = array(
717                                                 'evntlstlbl'    => _LIST_PLUGS_SUBS,
718                                                 'eventlist'             => Entity::hsc(implode(', ', $plug->getEventList())),
719                                         );
720                                         $data['eventlist'] = Template::fill($subTpl, $subData);
721                                 }
722                                 else
723                                 {
724                                         $data['eventlist'] = '';
725                                 }
726                                 if ( !$plug->subscribtionListIsUptodate() )
727                                 {
728                                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE']) )
729                                         {
730                                                 $subTpl = "<br /><br /><strong><%updatealert%></strong>";
731                                         }
732                                         else
733                                         {
734                                                 $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE'];
735                                         }
736                                         $subData = array(
737                                                 'updatealert' => _LIST_PLUG_SUBS_NEEDUPDATE,
738                                         );
739                                         $data['needupdate'] = Template::fill($subTpl, $subData);
740                                 }
741                                 else
742                                 {
743                                         $data['needupdate'] = '';
744                                 }
745                                 if ( count($plug->getPluginDep() ) > 0)
746                                 {
747                                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND']) )
748                                         {
749                                                 $subTpl = "<br /><br /><%deplistlbl%><br /><%dependlist%>";
750                                         }
751                                         else
752                                         {
753                                                 $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND'];
754                                         }
755                                         $subData = array(
756                                                 'deplistlbl' => _LIST_PLUGS_DEP,
757                                                 'dependlist' => Entity::hsc(implode(', ', $plug->getPluginDep())),
758                                         );
759                                         $data['dependlist'] = Template::fill($subTpl, $subData);
760                                 }
761                                 else
762                                 {
763                                         $data['dependlist'] = '';
764                                 }
765                                 /* check dependency */
766                                 if ( empty($plugins) )
767                                 {
768                                         $plugins = DB::getResult('SELECT pfile FROM ' . sql_table('plugin'));
769                                 }
770                                 $req = array();
771                                 foreach ( $plugins as $plugin )
772                                 {
773                                         $preq =& $manager->getPlugin($plugin['pfile']);
774 >>>>>>> skinnable-master
775                                         if ( $preq )
776                                         {
777                                                 $depList = $preq->getPluginDep();
778                                                 foreach ( $depList as $depName )
779                                                 {
780                                                         if ( $current['pfile'] == $depName )
781                                                         {
782 <<<<<<< HEAD
783                                                                 $req[] = $row['pfile'];
784 =======
785                                                                 $req[] = $plugin['pfile'];
786 >>>>>>> skinnable-master
787                                                         }
788                                                 }
789                                         }
790                                 }
791                                 
792                                 if ( count($req) > 0 )
793                                 {
794 <<<<<<< HEAD
795                                         echo '<dt>' . _LIST_PLUGS_DEPREQ . "</dt>\n";
796                                         echo '<dd>' . Entity::hsc(implode(', ', $req)) . "</dd>\n";
797                                 }
798                                 
799                                 /* check the database to see if it is up-to-date and notice the user if not */
800                                 if ( !$plug->subscribtionListIsUptodate() )
801                                 {
802                                         echo '<dt>' . 'NOTICE:' . "</dt>\n";
803                                         echo '<dd>' . _LIST_PLUG_SUBS_NEEDUPDATE . "</dd>\n";
804                                 }
805                                 
806                                 echo "</dl>\n";
807                                 echo "</td>\n";
808                         }
809                         else
810                         {
811                                 echo '<td colspan="2">' . sprintf(_PLUGINFILE_COULDNT_BELOADED, Entity::hsc($current['pfile'])) . "</td>\n";
812                         }
813                         
814                         echo "<td>\n";
815                         echo "<ul>\n";
816                         $current['pid'] = (integer) $current['pid'];
817                         
818                         $url = Entity::hsc($manager->addTicketToUrl("index.php?plugid={$current['pid']}&action=pluginup"));
819                         echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" , _LIST_PLUGS_UP , "</a></li>\n";
820                         
821                         $url = Entity::hsc($manager->addTicketToUrl("index.php?plugid={$current['pid']}&action=plugindown"));
822                         echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_DOWN , "</a></li>\n";
823                         echo "<li><a href=\"index.php?action=plugindelete&amp;plugid={$current['pid']}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_UNINSTALL , "</a></li>\n";
824                         
825                         if ( $plug && ($plug->hasAdminArea() > 0) )
826                         {
827                                 echo '<li><a href="' , Entity::hsc($plug->getAdminURL()) , '" tabindex="' , $template['tabindex'] , '">' , _LIST_PLUGS_ADMIN , "</a></li>\n";
828                         }
829                         
830                         if ( $plug && ($plug->supportsFeature('HelpPage') > 0) )
831                         {
832                                 echo "<li><a href=\"index.php?action=pluginhelp&amp;plugid={$current['pid']}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_HELP , "</a></li>\n";
833                         }
834                         
835                         $query = "SELECT COUNT(*) AS result FROM %s WHERE ocontext='global' and opid=%s;";
836                         $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $current['pid']);
837                         if ( DB::getValue($query) > 0 )
838                         {
839                                 echo "<li><a href=\"index.php?action=pluginoptions&amp;plugid={$current['pid']}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_OPTIONS . "</a></li>\n";
840                         }
841                         echo "</ul>\n";
842                         echo "</td>\n";
843                         break;
844         }
845         return;
846 }
847
848 function listplug_table_plugoptionlist($template, $type)
849 {
850         global $manager;
851         switch( $type )
852         {
853                 case 'HEAD':
854                         echo '<th>' . _LISTS_INFO . "</th>\n";
855                         echo '<th>' . _LISTS_VALUE . "</th>\n";
856                         break;
857                 case 'BODY':
858                         listplug_plugOptionRow($template['current']);
859                         break;
860                 case 'FOOT':
861                         echo "<tr>\n";
862                         echo '<th colspan="2">' . _PLUGS_SAVE . "</th>\n";
863                         echo "</tr>\n";
864                         echo "<tr>\n";
865                         echo "<td>" . _PLUGS_SAVE . "</td>\n";
866                         echo "<td><input type=\"submit\" value=\"".  _PLUGS_SAVE . "\" /></td>\n";
867                         echo "</tr>\n";
868                         break;
869         }
870         return;
871 }
872
873 function listplug_plugOptionRow($current)
874 {
875 =======
876                                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ']) )
877                                         {
878                                                 $subTpl = "<br /><br /><%deprlstlbl%><br /><%depreqlist%>";
879                                         }
880                                         else
881                                         {
882                                                 $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ'];
883                                         }
884                                         $subData = array(
885                                                 'deprlstlbl' => _LIST_PLUGS_DEPREQ,
886                                                 'depreqlist' => Entity::hsc(implode(', ', $req)),
887                                         );
888                                         $data['depreqlist'] = Template::fill($subTpl, $subData);
889                                 }
890                                 else
891                                 {
892                                         $data['depreqlist'] = '';
893                                 }
894                         }
895                         else
896                         {
897                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE']) )
898                                 {
899                                         $template = "<td colspan=\"2\"><%noplugalert%></td>\n";
900                                 }
901                                 else
902                                 {
903                                         $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE'];
904                                 }
905                                 $data = array(
906                                         'noplugalert' => sprintf(_PLUGINFILE_COULDNT_BELOADED, Entity::hsc($current['pfile'])),
907                                 );
908                         }
909                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN']) )
910                         {
911                                 $template .= "<td>\n"
912                                            . "<a href=\"<%actionupurl%>\" tabindex=\"<%tabindex%>\"><%actionuptxt%></a><br />\n"
913                                            . "<a href=\"<%actiondownurl%>\" tabindex=\"<%tabindex%>\"><%actiondowntxt%></a><br />\n"
914                                            . "<a href=\"<%actuninsturl%>\" tabindex=\"<%tabindex%>\"><%actuninsttxt%></a><br />"
915                                            . "<%plugadminurl%>\n"
916                                            . "<%plughelpurl%>\n"
917                                            . "<%plugoptsetting%>\n"
918                                            . "</td>\n";
919                         }
920                         else
921                         {
922                                 $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN'];
923                         }
924                         
925                         $baseUrl        = 'index.php?plugid=' . $current['pid'] . '&action=';
926                         $upUrl          = $manager->addTicketToUrl($baseUrl . 'pluginup');
927                         $downUrl        = $manager->addTicketToUrl($baseUrl . 'plugindown');
928                         
929                         $data['actionuptxt']    = _LIST_PLUGS_UP;
930                         $data['actionupurl']    = Entity::hsc($upUrl);
931                         $data['actiondowntxt']  = _LIST_PLUGS_DOWN;
932                         $data['actiondownurl']  = Entity::hsc($downUrl);
933                         $data['actuninsttxt']   = _LIST_PLUGS_UNINSTALL;
934                         $data['actuninsturl']   = 'index.php?action=plugindelete&amp;plugid=' . $current['pid'];
935                         
936                         if ( $plug && ($plug->hasAdminArea() > 0) )
937                         {
938                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN']) )
939                                 {
940                                         $subTpl = "<a href=\"<%actadminurl%>\" tabindex=\"<%tabindex%>\"><%actadmintxt%></a><br />\n";
941                                 }
942                                 else
943                                 {
944                                         $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN'];
945                                 }
946                                 $subData = array(
947                                         'actadminurl'   => Entity::hsc($plug->getAdminURL()),
948                                         'tabindex'              => $vars['tabindex'],
949                                         'actadmintxt'   => _LIST_PLUGS_ADMIN,
950                                 );
951                                 $data['plugadminurl'] = Template::fill($subTpl, $subData);
952                         }
953                         else
954                         {
955                                 $data['plugadminurl'] = '';
956                         }
957                         if ( $plug && ($plug->supportsFeature('HelpPage') > 0) )
958                         {
959                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP']) )
960                                 {
961                                         $subTpl = "<a href=\"<%acthelpurl%>\" tabindex=\"<%tabindex%>\"><%acthelptxt%></a><br />\n";
962                                 }
963                                 else
964                                 {
965                                         $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP'];
966                                 }
967                                 $subData = array(
968                                         'acthelpurl'    => 'index.php?action=pluginhelp&amp;plugid=' . $current['pid'],
969                                         'tabindex'              => $vars['tabindex'],
970                                         'acthelptxt'    => _LIST_PLUGS_HELP,
971                                 );
972                                 $data['plughelpurl'] = Template::fill($subTpl, $subData);
973                         }
974                         else
975                         {
976                                 $data['plughelpurl'] = '';
977                         }
978                         $optQuery = 'SELECT '
979                                   . '    COUNT(*) AS result '
980                                   . 'FROM '
981                                   .      sql_table('plugin_option_desc') . ' '
982                                   . 'WHERE '
983                                   . '    ocontext = "global" '
984                                   . 'AND opid     = %d';
985                         $pOptions = DB::getValue(sprintf($optQuery, $current['pid']));
986                         if ( $pOptions > 0 )
987                         {
988                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL']) )
989                                 {
990                                         $subTpl = "<a href=\"<%actoptionurl%>\" tabindex=\"<%tabindex%>\"><%actoptiontxt%></a>\n";
991                                 }
992                                 else
993                                 {
994                                         $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL'];
995                                 }
996                                 $subData = array(
997                                         'actoptionurl'  => 'index.php?action=pluginoptions&amp;plugid=' . $current['pid'],
998                                         'tabindex'              => $vars['tabindex'],
999                                         'actoptiontxt'  => _LIST_PLUGS_OPTIONS,
1000                                 );
1001                                 $data['plugoptsetting'] = Template::fill($subTpl, $subData);
1002                         }
1003                         else
1004                         {
1005                                 $data['plugoptsetting'] = '';
1006                         }
1007                         break;
1008                 case 'FOOT':
1009                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT']) )
1010                         {
1011                                 $template = "";
1012                         }
1013                         else
1014                         {
1015                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT'];
1016                         }
1017                         $data = array();
1018                         break;
1019         }
1020         return Template::fill($template, $data);
1021 }
1022
1023 function listplug_table_plugoptionlist($vars, $type, $template_name = '')
1024 {
1025         global $manager;
1026         
1027         $templates = array();
1028         if ( !empty($template_name) )
1029         {
1030                 $templates =& $manager->getTemplate($template_name);
1031         }
1032         
1033         switch( $type )
1034         {
1035                 case 'HEAD':
1036                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD']) )
1037                         {
1038                                 $template = "<th><%colinfo%></th>\n"
1039                                           . "<th><%colvalue%></th>\n";
1040                         }
1041                         else
1042                         {
1043                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD'];
1044                         }
1045                         $data = array(
1046                                 'colinfo'       => _LISTS_INFO,
1047                                 'colvalue'      => _LISTS_VALUE,
1048                         );
1049                         break;
1050                 case 'BODY':
1051                         $current = $vars['current'];
1052                         $template = listplug_plugOptionRow($current, $template_name);
1053                         $data = array();
1054                         break;
1055                 case 'FOOT':
1056                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT']) )
1057                         {
1058                                 $template = "<tr>\n"
1059                                           . "<th colspan=\"2\"><%savetext%></th>\n"
1060                                           . "</tr>\n"
1061                                           . "<tr>\n"
1062                                           . "<td><%savetext%></td>\n"
1063                                           . "<td><input type=\"submit\" value=\"<%savetext%>\" /></td>\n"
1064                                           . "</tr>\n";
1065                         }
1066                         else
1067                         {
1068                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT'];
1069                         }
1070                         $data = array(
1071                                 'savetext' => _PLUGS_SAVE,
1072                         );
1073                         break;
1074         }
1075         
1076         return Template::fill($template, $data);
1077 }
1078
1079 function listplug_plugOptionRow($current, $template_name = '')
1080 {
1081         global $manager;
1082         
1083         $templates = array();
1084         if ( !empty($template_name) )
1085         {
1086                 $templates =& $manager->getTemplate($template_name);
1087         }
1088         
1089 >>>>>>> skinnable-master
1090         $varname = "plugoption[{$current['oid']}][{$current['contextid']}]";
1091         
1092         // retreive the optionmeta
1093         $meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
1094         
1095         // only if it is not a hidden option write the controls to the page
1096         if ( in_array('access', $meta) && $meta['access'] == 'hidden' )
1097         {
1098 <<<<<<< HEAD
1099                 return;
1100         }
1101         
1102         if ( !$current['description'] )
1103         {
1104                 echo '<td>' , Entity::hsc($current['name']) . "</td>\n";
1105         }
1106         else
1107         {
1108                 if ( !defined($current['description']) )
1109                 {
1110                         echo '<td>' , Entity::hsc($current['description']) . "</td>\n";
1111                 }
1112                 else
1113                 {
1114                         echo '<td>' , Entity::hsc(constant($current['description'])) . "</td>\n";
1115                 }
1116         }
1117         echo "<td>\n";
1118         switch($current['type'])
1119         {
1120                 case 'yesno':
1121                         Admin::input_yesno($varname, $current['value'], 0, 'yes', 'no');
1122                         break;
1123                 case 'password':
1124                         echo '<input type="password" size="40" maxlength="128" name="',Entity::hsc($varname),'" value="',Entity::hsc($current['value']),"\" />\n";
1125                         break;
1126                 case 'select':
1127                         echo '<select name="'.Entity::hsc($varname)."\">\n";
1128                         $options = NucleusPlugin::getOptionSelectValues($current['typeinfo']);
1129                         $options = preg_split('/\|/', $options);
1130                         
1131                         for ( $i=0; $i<(count($options)-1); $i+=2 )
1132                         {
1133                                 if ($options[$i+1] == $current['value'])
1134                                 {
1135                                         echo '<option value="' . Entity::hsc($options[$i+1]) . '" selected="selected">';
1136                                 }
1137                                 else
1138                                 {
1139                                         echo '<option value="' . Entity::hsc($options[$i+1]) . '">';
1140                                 }
1141                                 if ( defined($options[$i]) )
1142                                 {
1143                                         echo Entity::hsc(constant($options[$i]));
1144                                 }
1145                                 else
1146                                 {
1147                                         echo Entity::hsc($options[$i]);
1148                                 }
1149                                 echo "</option>\n";
1150                         }
1151                         echo "</select>\n";
1152                         
1153                         break;
1154                 case 'textarea':
1155                         //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
1156                         if ( array_key_exists('access', $meta) && $meta['access'] == 'readonly' )
1157                         {
1158                                 echo '<textarea class="pluginoption" cols="30" rows="5" name="' . Entity::hsc($varname) . "\" readonly=\"readonly\">\n";
1159                         }
1160                         else
1161                         {
1162                                 echo '<textarea class="pluginoption" cols="30" rows="5" name="' . Entity::hsc($varname) . "\">\n";
1163                         }
1164                         echo Entity::hsc($current['value']) . "\n";
1165                         echo "</textarea>\n";
1166                         break;
1167                 case 'text':
1168                 default:
1169                         //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
1170                         echo '<input type="text" size="40" maxlength="128" name="',Entity::hsc($varname),'" value="',Entity::hsc($current['value']),'"';
1171                         if ( array_key_exists('datatype', $meta) && $meta['datatype'] == 'numerical' )
1172                         {
1173                                 echo ' onkeyup="checkNumeric(this)" onblur="checkNumeric(this)"';
1174                         }
1175                         if ( array_key_exists('access', $current) && $meta['access'] == 'readonly')
1176                         {
1177                                 echo ' readonly="readonly"';
1178                         }
1179                         echo " />\n";
1180         }
1181         if ( array_key_exists('extra', $current) )
1182         {
1183                 echo $current['extra'];
1184         }
1185         echo "</td>\n";
1186         
1187         return;
1188 }
1189
1190 function listplug_table_itemlist($template, $type)
1191 {
1192         $cssclass = '';
1193 =======
1194                 return false;
1195         }
1196         else
1197         {
1198                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY']) )
1199                 {
1200                         $template = "<td><%description%></td>\n"
1201                                   . "<td>\n";
1202                 }
1203                 else
1204                 {
1205                         $template = $templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY'];
1206                 }
1207                 
1208                 $data = array();
1209                 
1210                 switch($current['type'])
1211                 {
1212                         case 'yesno':
1213                                 $template .= listplug_input_yesno($varname, $current['value'], 0, 'yes', 'no', _YES, _NO, 0, $template_name, 1);
1214                                 break;
1215                         case 'password':
1216                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD']) )
1217                                 {
1218                                         $template .= "<input type=\"password\" size=\"40\" maxlength=\"128\" name=\"<%varname%>\" value=\"<%value%>\" />\n";
1219                                 }
1220                                 else
1221                                 {
1222                                         $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD'];
1223                                 }
1224                                 $data = array(
1225                                         'varname'       => Entity::hsc($varname),
1226                                         'value'         => Entity::hsc($current['value']),
1227                                 );
1228                                 break;
1229                         case 'select':
1230                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP']) )
1231                                 {
1232                                         $template .= "<select name=\"<%varname%>\">\n";
1233                                 }
1234                                 else
1235                                 {
1236                                         $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP'];
1237                                 }
1238                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO']) )
1239                                 {
1240                                         $subTpl = "<option value=\"<%value%>\"<%selected%>><%optname%></option>\n";
1241                                 }
1242                                 else
1243                                 {
1244                                         $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO'];
1245                                 }
1246                                 $options = NucleusPlugin::getOptionSelectValues($current['typeinfo']);
1247                                 $options = preg_split('#\|#', $options);
1248                                 
1249                                 for ( $i=0; $i<(count($options)-1); $i+=2 )
1250                                 {
1251                                         $name   = $options[$i];
1252                                         $value  = $options[$i+1];
1253                                         if ( defined($name) )
1254                                         {
1255                                                 $name = constant($name);
1256                                         }
1257                                         
1258                                         $subData = array(
1259                                                 'optname'       => Entity::hsc($name),
1260                                                 'value'         => Entity::hsc($value)
1261                                         );
1262                                         if ($value != $current['value'])
1263                                         {
1264                                                 $subData['selected'] = '';
1265                                         }
1266                                         else
1267                                         {
1268                                                 $subData['selected'] = ' selected="selected"';
1269                                         }
1270                                         $template .= Template::fill($subTpl, $subData);
1271                                 }
1272                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC']) )
1273                                 {
1274                                         $template .= "</select>\n";
1275                                 }
1276                                 else
1277                                 {
1278                                         $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC'];
1279                                 }
1280                                 $data['varname'] = Entity::hsc($varname);
1281                                 break;
1282                         case 'textarea':
1283                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA']) )
1284                                 {
1285                                         $template .= "<textarea class=\"pluginoption\" cols=\"30\" rows=\"5\" name=\"<%varname%>\"<%readonly%>><%value%></textarea>\n";
1286                                 }
1287                                 else
1288                                 {
1289                                         $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA'];
1290                                 }
1291                                 $data = array(
1292                                         'varname'       => Entity::hsc($varname),
1293                                         'value'         => Entity::hsc($current['value'])
1294                                 );
1295                                 if ( !array_key_exists('access', $current) || $current['access'] != 'readonly')
1296                                 {
1297                                         $data['readonly'] = '';
1298                                 }
1299                                 else
1300                                 {
1301                                         $data['readonly'] = ' readonly="readonly"';
1302                                 }
1303                                 break;
1304                         case 'text':
1305                         default:
1306                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT']) )
1307                                 {
1308                                         $template .= "<input type=\"text\" size=\"40\" maxlength=\"128\" name=\"<%varname%>\" value=\"<%value%>\"<%datatype%><%readonly%> />\n";
1309                                 }
1310                                 else
1311                                 {
1312                                         $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT'];
1313                                 }
1314                                 $data = array(
1315                                         'varname'       => Entity::hsc($varname),
1316                                         'value'         => Entity::hsc($current['value'])
1317                                 );
1318                                 if ( !array_key_exists('datatype', $current) || $current['datatype'] != 'numerical')
1319                                 {
1320                                         $data['datatype'] = '';
1321                                 }
1322                                 else
1323                                 {
1324                                         $data['datatype'] = ' onkeyup="checkNumeric(this)" onblur="checkNumeric(this)"';
1325                                 }
1326                                 if ( !array_key_exists('access', $current) || $current['access'] != 'readonly')
1327                                 {
1328                                         $data['readonly'] = '';
1329                                 }
1330                                 else
1331                                 {
1332                                         $data['readonly'] = ' readonly="readonly"';
1333                                 }
1334                 }
1335                 
1336                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT']) )
1337                 {
1338                         $template .= "<%extra%></td>\n";
1339                 }
1340                 else
1341                 {
1342                         $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT'];
1343                 }
1344                 
1345                 if ( !array_key_exists('extra', $current) )
1346                 {
1347                         $data['extra'] = '';
1348                 }
1349                 else
1350                 {
1351                         $data['extra'] = Entity::hsc($current['extra']);
1352                 }
1353                 
1354                 if ( !array_key_exists('description', $current) )
1355                 {
1356                         $data['description'] = Entity::hsc($current['name']);
1357                 }
1358                 else if ( !defined($current['description']) )
1359                 {
1360                         $data['description'] = Entity::hsc($current['description']);
1361                 }
1362                 else
1363                 {
1364                         $data['description'] = Entity::hsc(constant($current['description']));
1365                 }
1366         }
1367         return Template::fill($template, $data, 1);
1368 }
1369
1370 /**
1371  * listplug_templateEditRow()
1372  * 
1373  * @param       array   $content                content of target template
1374  * @param       string  $desc                   description of target template
1375  * @param       string  $name                   name of target template
1376  * @param       string  $help                   help text
1377  * @param       integer $tabindex               a number for tab index
1378  * @param       boolean $big                    large or small textarea
1379  * @param       array   $template_name  name of template for filling
1380  * @return      void
1381  */
1382 function listplug_templateEditRow($content, $desc, $name, $help = '', $tabindex = 0, $big = 0, $template_name = '')
1383 {
1384         global $manager;
1385         
1386         static $count = 0;
1387         
1388         $tmplt = array();
1389         $base  = array();
1390         
1391         $templates = array();
1392         if ( $template_name )
1393         {
1394                 $templates =& $manager->getTemplate($template_name);
1395         }
1396         
1397         $data = array(
1398                 'description'   => $desc,
1399                 'help'                  => empty($help) ? '' : helpHtml('template' . $help),
1400                 'count'                 => $count++,
1401                 'name'                  => $name,
1402                 'tabindex'              => $tabindex,
1403                 'rows'                  => $big ? 10 : 5,
1404         );
1405         
1406         $message = '';
1407         
1408         /* row head */
1409         if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $templates) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
1410         {
1411                 $template = "<tr>\n"
1412                           . "<td><%description%><%help%></td>\n"
1413                           . "<td id=\"td<%count%>\">\n"
1414                           . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">";
1415         }
1416         else
1417         {
1418                 $template = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
1419         }
1420         $message .= TEMPLATE::fill($template, $data);
1421         
1422         /* row content */
1423         $message .= ENTITY::hsc($content);
1424         
1425         /* row tail */
1426         if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $templates) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
1427         {
1428                 $template = "</textarea>\n"
1429                           . "</td>\n"
1430                           . "</tr>\n";
1431         }
1432         else
1433         {
1434                 $template = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
1435         }
1436         $message .= TEMPLATE::fill($template, $data);
1437         
1438         return $message;
1439 }
1440
1441 function listplug_table_itemlist($vars, $type, $template_name = '')
1442 {
1443         global $manager;
1444         
1445         $cssclass  = '';
1446         
1447         $templates = array();
1448         if ( !empty($template_name) )
1449         {
1450                 $templates =& $manager->getTemplate($template_name);
1451         }
1452 >>>>>>> skinnable-master
1453         
1454         switch( $type )
1455         {
1456                 case 'HEAD':
1457 <<<<<<< HEAD
1458                         echo "<th>"._LIST_ITEM_INFO."</th>\n";
1459                         echo "<th>"._LIST_ITEM_CONTENT."</th>\n";
1460                         echo "<th colspan='1'>"._LISTS_ACTIONS."</th>";
1461                         break;
1462                 case 'BODY':
1463                         $current = $template['current'];
1464                         // string -> unix timestamp
1465                         $current['itime'] = strtotime($current['itime']);
1466                         
1467                         if ( $current['idraft'] == 1 )
1468                         {
1469                                 $cssclass = " class='draft'";
1470                         }
1471                         
1472                         // (can't use offset time since offsets might vary between blogs)
1473                         if ( $current['itime'] > $template['now'] )
1474                         {
1475                                 $cssclass = " class='future'";
1476                         }
1477                         
1478                         echo "<td{$cssclass}>\n";
1479                         echo "<dl>\n";
1480                         echo '<dt>' . _LIST_ITEM_BLOG . "</dt>\n";
1481                         echo '<dd>' . Entity::hsc($current['bshortname']) . "</dd>\n";
1482                         echo '<dt>' . _LIST_ITEM_CAT . "</dt>\n";
1483                         echo '<dd>' . Entity::hsc($current['cname']) . "</dd>\n";
1484                         echo '<dt>' . _LIST_ITEM_AUTHOR . "</dt>\n";
1485                         echo '<dd>' . Entity::hsc($current['mname']) . "</dd>\n";
1486                         echo '<dt>' . _LIST_ITEM_DATE . "</dt>\n";
1487                         echo '<dd>' . date("Y-m-d",$current['itime']) . "</dd>\n";
1488                         echo '<dt>' . _LIST_ITEM_TIME . "</dt>\n";
1489                         echo '<dd>' . date("H:i",$current['itime']) . "</dd>\n";
1490                         echo "</dl>\n";
1491                         echo "</td>\n";
1492                         
1493                         $id = listplug_nextBatchId();
1494                         
1495                         echo "<td{$cssclass}>\n";
1496                         echo "<h3>\n";
1497                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current['inumber']}\" />\n";
1498                         echo "<label for=\"batch{$id}\">" . Entity::hsc(strip_tags($current['ititle'])) . "</label>\n";
1499                         echo "</h3>\n";
1500                         
1501                         $current['ibody'] = strip_tags($current['ibody']);
1502                         $current['ibody'] = Entity::hsc(Entity::shorten($current['ibody'], 300, '...'));
1503                         echo "<p>{$current['ibody']}</p>\n";
1504                         echo "</td>\n";
1505                         
1506                         echo "<td{$cssclass}>\n";
1507                         echo "<ul>\n";
1508                         echo "<li><a href=\"index.php?action=itemedit&amp;itemid={$current['inumber']}\">" . _LISTS_EDIT . "</a></li>\n";
1509                         
1510                         // evaluate amount of comments for the item
1511                         $COMMENTS = new Comments($current['inumber']);
1512                         $camount = $COMMENTS->amountComments();
1513                         if ( $camount > 0 )
1514                         {
1515                                 echo "<li><a href=\"index.php?action=itemcommentlist&amp;itemid={$current['inumber']}\">( ";
1516                                 echo sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments()) . " )</a></li>\n";
1517                         }
1518                         else
1519                         {
1520                                 echo '<li>' . _LIST_ITEM_NOCONTENT . "</li>\n";
1521                         }
1522                         
1523                         echo "<li><a href=\"index.php?action=itemmove&amp;itemid={$current['inumber']}\">" . _LISTS_MOVE . "</a></li>\n";
1524                         echo "<li><a href=\"index.php?action=itemdelete&amp;itemid={$current['inumber']}\">" . _LISTS_DELETE . "</a></li>\n";
1525                         echo "</ul>\n";
1526                         echo "</td>\n";
1527                         break;
1528         }
1529         return;
1530 =======
1531                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD']) )
1532                         {
1533                                 $template = "<th><%colinfo%></th>\n"
1534                                           . "<th><%colcontent%></th>\n"
1535                                           . "<th style=\"white-space:nowrap\"><%colaction%></th>\n";
1536                         }
1537                         else
1538                         {
1539                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD'];
1540                         }
1541                         $data = array(
1542                                 'colinfo'               => _LIST_ITEM_INFO,
1543                                 'colcontent'    => _LIST_ITEM_CONTENT,
1544                                 'colaction'             => _LISTS_ACTIONS
1545                         );
1546                         break;
1547                 case 'BODY':
1548                         $current = $vars['current'];
1549                         // string -> unix timestamp
1550                         $current['itime'] = strtotime($current['itime']);
1551                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY']) )
1552                         {
1553                                 $template = "<td<%cssclass%>>\n"
1554                                           . "<%bshortlabel%> <%bshortnameval%><br />\n"
1555                                           . "<%categorylabel%> <%categorynameval%><br />\n"
1556                                           . "<%authorlabel%> <%authornameval%><br />\n"
1557                                           . "<%itemdatelabel%> <%itemdateval%><br />\n"
1558                                           . "<%itemtimelabel%> <%itemtimeval%>\n"
1559                                           . "</td>\n"
1560                                           . "<td<%cssclass%>>\n"
1561                                           . "<input type=\"checkbox\" id=\"batch<%batchid%>\" name=\"batch[<%batchid%>]\" value=\"<%itemid%>\" />\n"
1562                                           . "<label for=\"batch<%batchid%>\"><b><%itemtitle%></b></label><br />\n"
1563                                           . "<%itembody%>\n"
1564                                           . "</td>\n"
1565                                           . "<td<%cssclass%>>\n"
1566                                           . "<a href=\"index.php?action=itemedit&amp;itemid=<%itemid%>\"><%editbtn%></a><br />\n"
1567                                           . "<a href=\"index.php?action=itemmove&amp;itemid=<%itemid%>\"><%movebtn%></a><br />\n"
1568                                           . "<a href=\"index.php?action=itemdelete&amp;itemid=<%itemid%>\"><%delbtn%></a><br />\n"
1569                                           . "<%camount%>\n"
1570                                           . "</td>\n";
1571                         }
1572                         else
1573                         {
1574                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY'];
1575                         }
1576                         $cssclass  = '';
1577                         
1578                         if ( $current['idraft'] == 1 )
1579                         {
1580                                 $cssclass = ' class="draft"';
1581                         }
1582                         
1583                         // (can't use offset time since offsets might vary between blogs)
1584                         if ( $current['itime'] > $vars['now'] )
1585                         {
1586                                 $cssclass = ' class="future"';
1587                         }
1588                         $body = strip_tags($current['ibody']);
1589                         $data = array(
1590                                 'cssclass'                      => $cssclass,
1591                                 'bshortlabel'           => _LIST_ITEM_BLOG,
1592                                 'bshortnameval'         => Entity::hsc($current['bshortname']),
1593                                 'categorylabel'         => _LIST_ITEM_CAT,
1594                                 'categorynameval'       => Entity::hsc($current['cname']),
1595                                 'authorlabel'           => _LIST_ITEM_AUTHOR,
1596                                 'authornameval'         => Entity::hsc($current['mname']),
1597                                 'itemdatelabel'         => _LIST_ITEM_DATE,
1598                                 'itemdateval'           => date("Y-m-d",$current['itime']),
1599                                 'itemdatelabel'         => _LIST_ITEM_TIME,
1600                                 'itemdateval'           => date("H:i",$current['itime']),
1601                                 'batchid'                       => listplug_nextBatchId(),
1602                                 'itemid'                        => $current['inumber'],
1603                                 'itemtitle'                     => Entity::hsc(strip_tags($current['ititle'])),
1604                                 'itembody'                      => Entity::hsc(Entity::shorten($body, 300, '...')),
1605                                 'editbtn'                       => _LISTS_EDIT,
1606                                 'movebtn'                       => _LISTS_MOVE,
1607                                 'delbtn'                        => _LISTS_DELETE,
1608                         );
1609                         // evaluate amount of comments for the item
1610                         $comment = new Comments($current['inumber']);
1611                         $camount = $comment->amountComments();
1612                         if ( $camount > 0 )
1613                         {
1614                                 $data['camount'] = "<a href=\"index.php?action=itemcommentlist&amp;itemid={$current['inumber']}\">(" . sprintf(_LIST_ITEM_COMMENTS, $comment->amountComments()) . ")</a><br />\n";
1615                         }
1616                         else
1617                         {
1618                                 $data['camount'] = _LIST_ITEM_NOCONTENT . "<br />\n";
1619                         }
1620                         break;
1621                 case 'FOOT':
1622                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT']) )
1623                         {
1624                                 $template = "\n";
1625                         }
1626                         else
1627                         {
1628                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT'];
1629                         }
1630                         $data = array();
1631                         break;
1632         }
1633         return Template::fill($template, $data);
1634 >>>>>>> skinnable-master
1635 }
1636
1637 // for batch operations: generates the index numbers for checkboxes
1638 function listplug_nextBatchId()
1639 {
1640         static $id = 0;
1641         return $id++;
1642 }
1643
1644 <<<<<<< HEAD
1645 function listplug_table_commentlist($template, $type)
1646 {
1647         switch( $type )
1648         {
1649                 case 'HEAD':
1650                         echo '<th>' . _LISTS_INFO . "</th>\n";
1651                         echo '<th>' . _LIST_COMMENT . "</th>\n";
1652                         echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>";
1653                         break;
1654                 case 'BODY':
1655                         $current = $template['current'];
1656                         $current['ctime'] = strtotime($current['ctime']);       // string -> unix timestamp
1657                         
1658                         echo "<td>\n";
1659                         echo "<ul>\n";
1660                         echo '<li>' . date("Y-m-d@H:i",$current['ctime']) . "</li>\n";
1661                         if ( isset($current['mname']) )
1662                         {
1663                                 echo '<li>' . Entity::hsc($current['mname']) ,' ', _LIST_COMMENTS_MEMBER . "</li>\n";
1664                         }
1665                         else
1666                         {
1667                                 echo '<li>' . Entity::hsc($current['cuser']) . "</li>\n";
1668                         }
1669                         if ( isset($current['cmail']) && $current['cmail'] )
1670                         {
1671                                 echo '<li>' . Entity::hsc($current['cmail']) . "</li>\n";
1672                         }
1673                         if ( isset($current['cemail']) && $current['cemail'] )
1674                         {
1675                                 echo '<li>' . Entity::hsc($current['cemail']) . "</li>\n";
1676                         }
1677                         echo "</ul>\n";
1678                         echo "</td>\n";
1679
1680                         $id = listplug_nextBatchId();
1681                         
1682                         echo '<td>';
1683                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}\" value=\"{$current['cnumber']}\" />\n";
1684                         echo "<label for=\"batch{$id}\">\n";
1685                         $current['cbody'] = strip_tags($current['cbody']);
1686                         $current['cbody'] = Entity::hsc(Entity::shorten($current['cbody'], 300, '...'));
1687                         echo $current['cbody'];
1688                         echo '</label>';
1689                         echo '</td>';
1690                         
1691                         echo '<td><a href="index.php?action=commentedit&amp;commentid=' . $current['cnumber'] . '">' . _LISTS_EDIT . "</a></td>\n";
1692                         echo '<td><a href="index.php?action=commentdelete&amp;commentid=' . $current['cnumber'] . '">' . _LISTS_DELETE . "</a></td>\n";
1693                         if ( $template['canAddBan'] )
1694                         {
1695                                 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";
1696                         }
1697                         break;
1698         }
1699         return;
1700 }
1701
1702 function listplug_table_bloglist($template, $type)
1703 {
1704         switch( $type )
1705         {
1706                 case 'HEAD':
1707                         echo '<th>' . _NAME . "</th>\n";
1708                         echo '<th colspan="7">' . _LISTS_ACTIONS . "</th>\n";
1709                         break;
1710                 case 'BODY':
1711                         $current = $template['current'];
1712                         $current['bname'] = Entity::hsc($current['bname']);
1713                         
1714                         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";
1715                         echo "<td><a href=\"index.php?action=createitem&amp;blogid={$current['bnumber']}\" title=\"" . _BLOGLIST_TT_ADD ."\">" . _BLOGLIST_ADD . "</a></td>\n";
1716                         echo "<td><a href=\"index.php?action=itemlist&amp;blogid={$current['bnumber']}\" title=\"". _BLOGLIST_TT_EDIT."\">". _BLOGLIST_EDIT."</a></td>\n";
1717                         echo "<td><a href=\"index.php?action=blogcommentlist&amp;blogid={$current['bnumber']}\" title=\"". _BLOGLIST_TT_COMMENTS."\">". _BLOGLIST_COMMENTS."</a></td>\n";
1718                         echo "<td><a href=\"index.php?action=bookmarklet&amp;blogid={$current['bnumber']}\" title=\"". _BLOGLIST_TT_BMLET."\">". _BLOGLIST_BMLET . "</a></td>\n";
1719                         
1720                         if ( $current['tadmin'] == 1 )
1721                         {
1722                                 echo "<td><a href=\"index.php?action=blogsettings&amp;blogid={$current['bnumber']}\" title=\"" . _BLOGLIST_TT_SETTINGS . "\">" . _BLOGLIST_SETTINGS . "</a></td>\n";
1723                                 echo "<td><a href=\"index.php?action=banlist&amp;blogid={$current['bnumber']}\" title=\"" . _BLOGLIST_TT_BANS . "\">" . _BLOGLIST_BANS . "</a></td>\n";
1724                         }
1725                         
1726                         if ( $template['superadmin'] )
1727                         {
1728                                 echo "<td><a href=\"index.php?action=deleteblog&amp;blogid={$current['bnumber']}\" title=\"". _BLOGLIST_TT_DELETE."\">" ._BLOGLIST_DELETE. "</a></td>\n";
1729                         }
1730                         break;
1731         }
1732         return;
1733 }
1734
1735 function listplug_table_shortblognames($template, $type)
1736 {
1737         switch( $type )
1738         {
1739                 case 'HEAD':
1740                         echo '<th>' . _EBLOG_SHORTNAME . "</th>\n";
1741                         echo '<th>' . _EBLOG_NAME. "</th>";
1742                         break;
1743                 case 'BODY':
1744                         $current = $template['current'];
1745                         $current['bshortname'] = Entity::hsc($current['bshortname']);
1746                         $current['bname'] = Entity::hsc($current['bname']);
1747                         
1748                         echo "<td>{$current['bshortname']}</td>\n";
1749                         echo "<td>{$current['bname']}</td>\n";
1750                         break;
1751         }
1752         return;
1753 }
1754
1755 function listplug_table_shortnames($template, $type)
1756 {
1757         switch( $type )
1758         {
1759                 case 'HEAD':
1760                         echo '<th>' . _NAME . "</th>\n";
1761                         echo '<th>' . _LISTS_DESC. "</th>\n";
1762                         break;
1763                 case 'BODY':
1764                         $current = $template['current'];
1765                         $current['name'] = Entity::hsc($current['name']);
1766                         $current['description'] = Entity::hsc($current['description']);
1767                         
1768                         echo "<td>{$current['name']}</td>\n";
1769                         echo "<td>{$current['description']}</td>\n";
1770                         break;
1771         }
1772         return;
1773 }
1774
1775
1776 function listplug_table_categorylist($template, $type)
1777 {
1778         switch( $type )
1779         {
1780                 case 'HEAD':
1781                         echo '<th>' . _LISTS_NAME . "</th>";
1782                         echo '<th>' . _LISTS_DESC."</th>\n";
1783                         echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
1784                         break;
1785                 case 'BODY':
1786                         $id = listplug_nextBatchId();
1787                         
1788                         $current = $template['current'];
1789                         $current['cname'] = Entity::hsc($current['cname']);
1790                         $current['cdesc'] = Entity::hsc($current['cdesc']);
1791                         
1792                         echo "<td>\n";
1793                         echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current['catid']}\" />\n";
1794                         echo "<label for=\"batch{$id}\">{$current['cname']}</label>\n";
1795                         echo "</td>\n";
1796                         echo "<td>{$current['cdesc']}</td>\n";
1797                         echo "<td><a href=\"index.php?action=categoryedit&amp;blogid={$current['cblog']}&amp;catid={$current['catid']}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a></td>\n";
1798                         echo "<td><a href=\"index.php?action=categorydelete&amp;blogid={$current['cblog']}&amp;catid={$current['catid']}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";
1799                         break;
1800         }
1801         return;
1802 }
1803
1804 function listplug_table_templatelist($template, $type)
1805 {
1806         global $manager;
1807         switch( $type )
1808         {
1809                 case 'HEAD':
1810                         echo '<th>' . _LISTS_NAME . "</th>\n";
1811                         echo '<th>' . _LISTS_DESC . "</th>\n";
1812                         echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";
1813                         break;
1814                 case 'BODY':
1815                         $current = $template['current'];
1816                         $current['tdnumber'] = (integer) $current['tdnumber'];
1817                         $current['tdname'] = Entity::hsc($current['tdname']);
1818                         $current['tddesc'] = Entity::hsc($current['tddesc']);
1819                         
1820                         $url = "index.php?action=templateclone&templateid={$current['tdnumber']}";
1821                         $url = Entity::hsc($manager->addTicketToUrl($url));
1822                         
1823                         echo "<td>{$current['tdname']}</td>\n";
1824                         echo "<td>{$current['tddesc']}</td>\n";
1825                         echo "<td>\n";
1826                         echo "<a href=\"index.php?action=templateedit&amp;templateid={$current['tdnumber']}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a>\n";
1827                         echo "</td>\n";
1828                         echo "<td>\n";
1829                         echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";
1830                         echo "</td>\n";
1831                         echo "<td>\n";
1832                         echo "<a href=\"index.php?action=templatedelete&amp;templateid={$current['tdnumber']}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a>\n";
1833                         echo "</td>\n";
1834                         break;
1835         }
1836         return;
1837 }
1838
1839 function listplug_table_skinlist($template, $type)
1840 {
1841         global $CONF, $DIR_SKINS, $manager;
1842         switch( $type )
1843         {
1844                 case 'HEAD':
1845                         echo '<th>' . _LISTS_NAME . "</th>\n";
1846                         echo '<th>' . _LISTS_DESC . "</th>\n";
1847                         echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";
1848                         break;
1849                 case 'BODY':
1850                         $current = $template['current'];
1851                         $current['sdnumber'] = (integer) $current['sdnumber'];
1852                         $current['sdname'] = Entity::hsc($current['sdname']);
1853                         $current['sdtype'] = Entity::hsc($current['sdtype']);
1854                         
1855                         echo "<td>\n";
1856                         
1857                         // use a special style for the default skin
1858                         if ( $current['sdnumber'] == $CONF['BaseSkin'] )
1859                         {
1860                                 echo '<h3 id="base_skin">' . $current['sdname'] . "</h3>\n";
1861                         }
1862                         else
1863                         {
1864                                 echo '<h3>' . $current['sdname'] . "</h3>\n";
1865                         }
1866                         
1867                         echo "<dl>\n";
1868                         echo '<dt>' . _LISTS_TYPE . "</dt>\n";
1869                         echo '<dd>' . $current['sdtype'] . "</dd>\n";
1870                         
1871                         echo '<dt>' . _LIST_SKINS_INCMODE . "</dt>\n";
1872                         
1873                         if ( $current['sdincmode'] == 'skindir' )
1874                         {
1875                                 echo '<dd>' . _PARSER_INCMODE_SKINDIR . "</dd>\n";
1876                         }
1877                         else
1878                         {
1879                                 echo '<dd>' . _PARSER_INCMODE_NORMAL . "</dd>\n";
1880                         }
1881                         
1882                         if ( $current['sdincpref'] )
1883                         {
1884                                 echo '<dt>' . _LIST_SKINS_INCPREFIX . "</dt>\n";
1885                                 echo '<dd>' . Entity::hsc($current['sdincpref']) . "</dd>\n";
1886                         }
1887                         echo "</dl>\n";
1888 =======
1889 function listplug_table_commentlist($vars, $type, $template_name = '')
1890 {
1891         global $manager;
1892         
1893         $templates = array();
1894         if ( !empty($template_name) )
1895         {
1896                 $templates =& $manager->getTemplate($template_name);
1897         }
1898         
1899         switch( $type )
1900         {
1901                 case 'HEAD':
1902                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD']) )
1903                         {
1904                                 $template = "<th><%colinfo%></th>\n"
1905                                           . "<th><%colcontent%></th>\n"
1906                                           . "<th colspan=\"3\"><%colaction%></th>\n";
1907                         }
1908                         else
1909                         {
1910                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD'];
1911                         }
1912                         $data = array(
1913                                 'colinfo'               => _LISTS_INFO,
1914                                 'colcontent'    => _LIST_COMMENT,
1915                                 'colaction'             => _LISTS_ACTIONS
1916                         );
1917                         break;
1918                 case 'BODY':
1919                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY']) )
1920                         {
1921                                 $template = "<td><%commentdate%><br /><%commentator%><br /><%commentsite%><br /><%commentmail%><br /></td>\n"
1922                                           . "<td>\n"
1923                                           . "<input type=\"checkbox\" id=\"batch<%batchid%>\" name=\"batch[<%batchid%>]\" value=\"<%commentid%>\" />"
1924                                           . "<label for=\"batch<%batchid%>\"><%commentbody%></label>\n"
1925                                           . "</td>\n"
1926                                           . "<td style=\"white-space:nowrap\">\n"
1927                                           . "<a href=\"index.php?action=commentedit&amp;commentid=<%commentid%>\"><%editbtn%></a>\n"
1928                                           . "</td>\n"
1929                                           . "<td style=\"white-space:nowrap\">\n"
1930                                           . "<a href=\"index.php?action=commentdelete&amp;commentid=<%commentid%>\"><%delbtn%></a>\n"
1931                                           . "</td>\n"
1932                                           . "<%addbanlist%>";
1933                         }
1934                         else
1935                         {
1936                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY'];
1937                         }
1938                         $current = $vars['current'];
1939                         $body = strip_tags($current['cbody']);
1940                         $data = array(
1941                                 'commentdate'   => date("Y-m-d@H:i", strtotime($current['ctime'])),
1942                                 'batchid'               => listplug_nextBatchId(),
1943                                 'commentid'             => $current['cnumber'],
1944                                 'commentbody'   => Entity::hsc(Entity::shorten($current['cbody'], 300, '...')),
1945                                 'editbtn'               => _LISTS_EDIT,
1946                                 'delbtn'                => _LISTS_DELETE,
1947                         );
1948                         if ( isset($current['mname']) )
1949                         {
1950                                 $data['commentator'] = Entity::hsc($current['mname']) . ' ' . _LIST_COMMENTS_MEMBER;
1951                         }
1952                         else
1953                         {
1954                                 $data['commentator'] = Entity::hsc($current['cuser']);
1955                         }
1956                         if ( isset($current['cmail']) && $current['cmail'] )
1957                         {
1958                                 $data['commentsite'] = Entity::hsc($current['cmail']);
1959                         }
1960                                 else
1961                         {
1962                                 $data['commentsite'] = '';
1963                         }
1964                         if ( isset($current['cemail']) && $current['cemail'] )
1965                         {
1966                                 $data['commentmail'] = Entity::hsc($current['cemail']);
1967                         }
1968                                 else
1969                         {
1970                                 $data['commentmail'] = '';
1971                         }
1972                         if ( $vars['canAddBan'] )
1973                         {
1974                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN']) )
1975                                 {
1976                                         $subTpl = "<td style=\"white-space:nowrap\">"
1977                                                 . "<a href=\"index.php?action=banlistnewfromitem&amp;itemid=<%itemid%>&amp;ip=<%banip%>\" title=\"<%banhost%>\"><%banbtn%></a>"
1978                                                 . "</td>\n";
1979                                 }
1980                                 else
1981                                 {
1982                                         $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN'];
1983                                 }
1984                                 $subData = array(
1985                                         'itemid'        => $current['citem'],
1986                                         'banip'         => Entity::hsc($current['cip']),
1987                                         'banbtn'        => _LIST_COMMENT_BANIP,
1988                                 );
1989                                 $data['addbanlist'] = Template::fill($subTpl, $subData);
1990                         }
1991                         break;
1992                 case 'FOOT':
1993                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT']) )
1994                         {
1995                                 $template = "";
1996                         }
1997                         else
1998                         {
1999                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT'];
2000                         }
2001                         $data = array();
2002                         break;
2003         }
2004         return Template::fill($template, $data);
2005 }
2006
2007 function listplug_table_bloglist($vars, $type, $template_name = '')
2008 {
2009         global $manager;
2010         
2011         $templates = array();
2012         if ( !empty($template_name) )
2013         {
2014                 $templates =& $manager->getTemplate($template_name);
2015         }
2016         
2017         switch( $type )
2018         {
2019                 case 'HEAD':
2020                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD']) )
2021                         {
2022                                 $template = "<th><%blognames%></th>\n"
2023                                           . "<th colspan=\"7\"><%actionshead%></th>\n";
2024                         }
2025                         else
2026                         {
2027                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD'];
2028                         }
2029                         $data = array(
2030                                 'blognames'   => _NAME,
2031                                 'actionshead' => _LISTS_ACTIONS,
2032                         );
2033                         break;
2034                 case 'BODY':
2035                         $current = $vars['current'];
2036                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY']) )
2037                         {
2038                                 $template = "<td title=\"blogid:<%blogid%> shortname:<%shortname%>\">\n"
2039                                           . "<a href=\"<%blogurl%>\"><img src=\"images/globe.gif\" width=\"13\" height=\"13\" alt=\"<%iconalt%>\" /></a><%blogname%></td>\n"
2040                                           . "<td><a href=\"index.php?action=createitem&amp;blogid=<%blogid%>\" title=\"<%ttaddtext%>\"><%addtext%></a></td>\n"
2041                                           . "<td><a href=\"index.php?action=itemlist&amp;blogid=<%blogid%>\" title=\"<%ttedittext%>\"><%edittext%></a></td>\n"
2042                                           . "<td><a href=\"index.php?action=blogcommentlist&amp;blogid=<%blogid%>\" title=\"<%ttcommenttext%>\"><%commenttext%></a></td>\n"
2043                                           . "<td><a href=\"index.php?action=bookmarklet&amp;blogid=<%blogid%>\" title=\"<%ttbmlettext%>\"><%bmlettext%></a></td>\n";
2044                         }
2045                         else
2046                         {
2047                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY'];
2048                         }
2049                         $data = array(
2050                                 'blogid'                => $current['bnumber'],
2051                                 'shortname'             => Entity::hsc($current['bshortname']),
2052                                 'blogurl'               => $current['burl'],
2053                                 'blogname'              => Entity::hsc($current['bname']),
2054                                 'ttaddtext'             => _BLOGLIST_TT_ADD,
2055                                 'addtext'               => _BLOGLIST_ADD,
2056                                 'ttedittext'    => _BLOGLIST_TT_EDIT,
2057                                 'edittext'              => _BLOGLIST_EDIT,
2058                                 'ttcommenttext' => _BLOGLIST_TT_COMMENTS,
2059                                 'commenttext'   => _BLOGLIST_COMMENTS,
2060                                 'ttbmlettext'   => _BLOGLIST_TT_BMLET,
2061                                 'bmlettext'             => _BLOGLIST_BMLET,
2062                         );
2063                         if ( $current['tadmin'] == 1 )
2064                         {
2065                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM']) )
2066                                 {
2067                                         $template .= "<td><a href=\"index.php?action=blogsettings&amp;blogid=<%blogid%>\" title=\"<%ttsettingtext%>\"><%settingtext%></a></td>\n"
2068                                                    . "<td><a href=\"index.php?action=banlist&amp;blogid=<%blogid%>\" title=\"<%ttbanstext%>\"><%banstext%></a></td>\n";
2069                                 }
2070                                 else
2071                                 {
2072                                         $template .= $templates['SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM'];
2073                                 }
2074                                 $data['ttsettingtext']  = _BLOGLIST_TT_SETTINGS;
2075                                 $data['settingtext']    = _BLOGLIST_SETTINGS;
2076                                 $data['ttbanstext']             = _BLOGLIST_TT_BANS;
2077                                 $data['banstext']               = _BLOGLIST_BANS;
2078                         }
2079                         
2080                         if ( $vars['superadmin'] )
2081                         {
2082                                 if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLIST_BD_SADM', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM']) )
2083                                 {
2084                                         $template .= "<td><a href=\"index.php?action=deleteblog&amp;blogid=<%blogid%>\" title=\"<%ttdeletetext%>\"><%deletetext%></a></td>\n";
2085                                 }
2086                                 else
2087                                 {
2088                                         $template .= $templates['SHOWLIST_LISTPLUG_TABLE_BLIST_BD_SADM'];
2089                                 }
2090                                 $data['ttdeletetext']   = _BLOGLIST_TT_DELETE;
2091                                 $data['deletetext']             = _BLOGLIST_DELETE;
2092                         }
2093                         break;
2094                 case 'FOOT':
2095                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT']) )
2096                         {
2097                                 $template = "\n";
2098                         }
2099                         else
2100                         {
2101                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT'];
2102                         }
2103                         $data = array();
2104                         break;
2105         }
2106         return Template::fill($template, $data);
2107 }
2108
2109 function listplug_table_shortblognames($vars, $type, $template_name = '')
2110 {
2111         global $manager;
2112         
2113         $templates = array();
2114         if ( !empty($template_name) )
2115         {
2116                 $templates =& $manager->getTemplate($template_name);
2117         }
2118         
2119         switch( $type )
2120         {
2121                 case 'HEAD':
2122                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD']) )
2123                         {
2124                                 $template = "<th><%colshortname%></th>\n"
2125                                           . "<th><%colblogname%></th>\n";
2126                         }
2127                         else
2128                         {
2129                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD'];
2130                         }
2131                         $data = array(
2132                                 'colshortname' => _EBLOG_SHORTNAME,
2133                                 'colblogname'  => _EBLOG_NAME,
2134                         );
2135                         break;
2136                 case 'BODY':
2137                         $current = $vars['current'];
2138                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY']) )
2139                         {
2140                                 $template = "<td><%bshortname%></td>\n"
2141                                           . "<td><%blogname%></td>\n";
2142                         }
2143                         else
2144                         {
2145                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY'];
2146                         }
2147                         $data = array(
2148                                 'bshortname' => Entity::hsc($current['bshortname']),
2149                                 'blogname'   => Entity::hsc($current['bname']),
2150                         );
2151                         break;
2152                 case 'FOOT':
2153                         $current = $vars['current'];
2154                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT']) )
2155                         {
2156                                 $template = "\n";
2157                         }
2158                         else
2159                         {
2160                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT'];
2161                         }
2162                         $data = array();
2163                         break;
2164         }
2165         return Template::fill($template, $data);
2166 }
2167
2168 function listplug_table_shortnames($vars, $type, $template_name = '')
2169 {
2170         global $manager;
2171         
2172         $templates = array();
2173         if ( !empty($template_name) )
2174         {
2175                 $templates =& $manager->getTemplate($template_name);
2176         }
2177         
2178         switch( $type )
2179         {
2180                 case 'HEAD':
2181                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD']) )
2182                         {
2183                                 $template = "<th><%colname%></th>\n"
2184                                           . "<th><%coldesc%></th>\n";
2185                         }
2186                         else
2187                         {
2188                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD'];
2189                         }
2190                         $data = array(
2191                                 'colname' => _NAME,
2192                                 'coldesc' => _LISTS_DESC,
2193                         );
2194                         break;
2195                 case 'BODY':
2196                         $current = $vars['current'];
2197                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY']) )
2198                         {
2199                                 $template = "<td><%name%></td>\n"
2200                                           . "<td><%desc%></td>\n";
2201                         }
2202                         else
2203                         {
2204                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY'];
2205                         }
2206                         $data = array(
2207                                 'name' => Entity::hsc($current['name']),
2208                                 'desc' => Entity::hsc($current['description']),
2209                         );
2210                         break;
2211                 case 'FOOT':
2212                         $current = $vars['current'];
2213                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT']) )
2214                         {
2215                                 $template = "\n";
2216                         }
2217                         else
2218                         {
2219                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT'];
2220                         }
2221                         $data = array();
2222                         break;
2223         }
2224         return Template::fill($template, $data);
2225 }
2226
2227 function listplug_table_categorylist($vars, $type, $template_name = '')
2228 {
2229         global $manager;
2230         
2231         $templates = array();
2232         if ( !empty($template_name) )
2233         {
2234                 $templates =& $manager->getTemplate($template_name);
2235         }
2236         
2237         switch( $type )
2238         {
2239                 case 'HEAD':
2240                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD']) )
2241                         {
2242                                 $template = "<th><%colname%></th>\n"
2243                                           . "<th><%coldesc%></th>\n"
2244                                           . "<th colspan=\"2\"><%colact%></th>\n";
2245                         }
2246                         else
2247                         {
2248                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD'];
2249                         }
2250                         $data = array(
2251                                 'colname' => _LISTS_NAME,
2252                                 'coldesc' => _LISTS_DESC,
2253                                 'colact'  => _LISTS_ACTIONS,
2254                         );
2255                         break;
2256                 case 'BODY':
2257                         $current = $vars['current'];
2258                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY']) )
2259                         {
2260                                 $template = "<td>\n"
2261                                           . "<input type=\"checkbox\" id=\"batch<%batchid%>\" name=\"batch[<%batchid%>]\" value=\"<%catid%>\" />\n"
2262                                           . "<label for=\"batch<%batchid%>\"><%catname%></label>\n"
2263                                           . "</td>\n"
2264                                           . "<td><%catdesc%></td>\n"
2265                                           . "<td><a href=\"index.php?action=categoryedit&amp;blogid=<%blogid%>&amp;catid=<%catid%>\" tabindex=\"<%tabindex%>\"><%editbtn%></a></td>\n"
2266                                           . "<td><a href=\"index.php?action=categorydelete&amp;blogid=<%blogid%>&amp;catid=<%catid%>\" tabindex=\"<%tabindex%>\"><%delbtn%></a></td>\n";
2267                         }
2268                         else
2269                         {
2270                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY'];
2271                         }
2272                         
2273                         $data = array(
2274                                 'batchid'       => listplug_nextBatchId(),
2275                                 'catid'         => intval($current['catid']),
2276                                 'catname'       => Entity::hsc($current['cname']),
2277                                 'catdesc'       => Entity::hsc($current['cdesc']),
2278                                 'blogid'        => intval($current['cblog']),
2279                                 'tabindex'      => intval($vars['tabindex']),
2280                                 'editbtn'       => _LISTS_EDIT,
2281                                 'delbtn'        => _LISTS_DELETE,
2282                         );
2283                         break;
2284                 case 'FOOT':
2285                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT']) )
2286                         {
2287                                 $template = "\n";
2288                         }
2289                         else
2290                         {
2291                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT'];
2292                         }
2293                         $data = array();
2294                         break;
2295         }
2296         return Template::fill($template, $data);
2297 }
2298
2299 function listplug_table_templatelist($vars, $type, $template_name = '')
2300 {
2301         global $manager, $CONF;
2302         
2303         $templates = array();
2304         if ( !empty($template_name) )
2305         {
2306                 $templates =& $manager->getTemplate($template_name);
2307         }
2308         
2309         switch( $type )
2310         {
2311                 case 'HEAD':
2312                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD']) )
2313                         {
2314                                 $template = "<th><%colname%></th>\n"
2315                                           . "<th><%coldesc%></th>\n"
2316                                           . "<th colspan=\"3\"><%colact%></th>\n";
2317                         }
2318                         else
2319                         {
2320                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD'];
2321                         }
2322                         $data = array(
2323                                 'colname' => _LISTS_NAME,
2324                                 'coldesc' => _LISTS_DESC,
2325                                 'colact'  => _LISTS_ACTIONS,
2326                         );
2327                         break;
2328                 case 'BODY':
2329                         $current = $vars['current'];
2330                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY']) )
2331                         {
2332                                 $template = "<td><%templatename%></td>\n"
2333                                           . "<td><%templatedesc%></td>\n"
2334                                           . "<td style=\"white-space:nowrap\">"
2335                                           . "<a href=\"<%editurl%>\" tabindex=\"<%tabindex%>\"><%editbtn%></a>\n"
2336                                           . "</td>\n"
2337                                           . "<td style=\"white-space:nowrap\">\n"
2338                                           . "<a href=\"<%cloneurl%>\" tabindex=\"<%tabindex%>\"><%clonebtn%></a>\n"
2339                                           . "</td>\n"
2340                                           . "<td style=\"white-space:nowrap\">\n"
2341                                           . "<a href=\"<%deleteurl%>\" tabindex=\"<%tabindex%>\"><%delbtn%></a>\n"
2342                                           . "</td>\n";
2343                         }
2344                         else
2345                         {
2346                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY'];
2347                         }
2348                         
2349                         $data = array(
2350                                 'templatename'  => Entity::hsc($current['tdname']),
2351                                 'templatedesc'  => Entity::hsc($current['tddesc']),
2352                                 'templateid'    => (integer) $current['tdnumber'],
2353                                 'tabindex'              => (integer) $vars['tabindex'],
2354                                 
2355                                 'clonebtn'              => _LISTS_CLONE,
2356                                 'cloneaction'   => $vars['cloneaction'],
2357                                 'cloneurl'              => "{$CONF['AdminURL']}index.php?action={$vars['cloneaction']}&amp;templateid={$current['tdnumber']}",
2358                                 
2359                                 'delbtn'                => _LISTS_DELETE,
2360                                 'deleteaction'  => $vars['deleteaction'],
2361                                 'deleteurl'             => "{$CONF['AdminURL']}index.php?action={$vars['deleteaction']}&amp;templateid={$current['tdnumber']}",
2362                                 
2363                                 'editbtn'               => _LISTS_EDIT,
2364                                 'editaction'    => $vars['editaction'],
2365                                 'editurl'               => "{$CONF['AdminURL']}index.php?action={$vars['editaction']}&amp;templateid={$current['tdnumber']}"
2366                         );
2367                         break;
2368                 case 'FOOT':
2369                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT']) )
2370                         {
2371                                 $template = "\n";
2372                         }
2373                         else
2374                         {
2375                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT'];
2376                         }
2377                         $data = array();
2378                         break;
2379         }
2380         return Template::fill($template, $data);
2381 }
2382
2383 function listplug_table_skinlist($vars, $type, $template_name = '')
2384 {
2385         global $CONF, $DIR_SKINS, $manager;
2386         
2387         $templates = array();
2388         if ( !empty($template_name) )
2389         {
2390                 $templates =& $manager->getTemplate($template_name);
2391         }
2392         
2393         switch( $type )
2394         {
2395                 case 'HEAD':
2396                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD']) )
2397                         {
2398                                 $template = "<th><%colname%></th>\n"
2399                                           . "<th><%coldesc%></th>\n"
2400                                           . "<th colspan=\"3\"><%colact%></th>\n";
2401                         }
2402                         else
2403                         {
2404                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD'];
2405                         }
2406                         $data = array(
2407                                 'colname'       => _LISTS_NAME,
2408                                 'coldesc'       => _LISTS_DESC,
2409                                 'colact'        => _LISTS_ACTIONS,
2410                         );
2411                         break;
2412                 case 'BODY':
2413                         $current = $vars['current'];
2414                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY']) )
2415                         {
2416                                 $template = "<td><%skinname%><br /><br />\n"
2417                                           . "<%skintypelabel%> <%skintype%><br />\n"
2418                                           . "<%incmodelabel%> <%incmode%><br />\n"
2419                                           . "<%incpreflabel%> <%incpref%><br />\n"
2420                                           . "<%skinthumb%>"
2421                                           . "<%readme%></td>\n"
2422                                           . "<td class=\"availableSkinTypes\"><%skindesc%><%skinparts%></td>\n"
2423                                           . "<td style=\"white-space:nowrap\">"
2424                                           . "<a href=\"index.php?action=skinedit&amp;skinid=<%skinid%>\" tabindex=\"<%tabindex%>\"><%editbtn%></a>"
2425                                           . "</td>\n"
2426                                           . "<td style=\"white-space:nowrap\">"
2427                                           . "<a href=\"<%cloneurl%>\" tabindex=\"<%tabindex%>\"><%clonebtn%></a>"
2428                                           . "</td>\n"
2429                                           . "<td style=\"white-space:nowrap\">"
2430                                           . "<a href=\"index.php?action=skindelete&amp;skinid=<%skinid%>\" tabindex=\"<%tabindex%>\"><%delbtn%></a>"
2431                                           . "</td>\n";
2432                         }
2433                         else
2434                         {
2435                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY'];
2436                         }
2437                         
2438                         $data = array(
2439                                 'tabindex'              => $vars['tabindex']++,
2440                                 
2441                                 'skinid'                => (integer) $current['sdnumber'],
2442                                 'skindesc'              => Entity::hsc($current['sddesc']),
2443                                 
2444                                 'skintypelabel' => _LISTS_TYPE,
2445                                 'skintype'              => Entity::hsc($current['sdtype']),
2446                                 
2447                                 'incmodelabel'  => _LIST_SKINS_INCMODE,
2448                                 'incmode'               => ($current['sdincmode'] == 'skindir') ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL,
2449                                 
2450                                 'incpreflabel'  => ($current['sdincpref']) ? _SKIN_INCLUDE_PREFIX : '',
2451                                 'incpref'               => ($current['sdincpref']) ? Entity::hsc($current['sdincpref']) : '',
2452                                 
2453                                 'editbtn'               => _LISTS_EDIT,
2454                                 'editaction'    => $vars['editaction'],
2455                                 'editurl'               => "{$CONF['AdminURL']}index.php?action={$vars['editaction']}&skinid={$current['sdnumber']}",
2456                                 
2457                                 'clonebtn'              => _LISTS_CLONE,
2458                                 'cloneaction'   => $vars['cloneaction'],
2459                                 'cloneurl'              => "{$CONF['AdminURL']}index.php?action={$vars['cloneaction']}&skinid={$current['sdnumber']}",
2460                                 
2461                                 'delbtn'                => _LISTS_DELETE,
2462                                 'deleteaction'  => $vars['deleteaction'],
2463                                 'deleteurl'             => "{$CONF['AdminURL']}index.php?action={$vars['deleteaction']}&skinid={$current['sdnumber']}"
2464                         );
2465                         
2466                         if ( $current['sdnumber'] != $vars['default'] )
2467                         {
2468                                 $data['skinname'] = Entity::hsc($current['sdname']);
2469                         }
2470                         else
2471                         {
2472                                 $data['skinname'] = '<strong>' . Entity::hsc($current['sdname']) . '</strong>';
2473                         }
2474 >>>>>>> skinnable-master
2475                         
2476                         // add preview image when present
2477                         if ( $current['sdincpref'] && @file_exists("{$DIR_SKINS}{$current['sdincpref']}preview.png") )
2478                         {
2479 <<<<<<< HEAD
2480                                 echo "<p>\n";
2481 =======
2482                                 $data['skinthumb'] = "<p>\n";
2483 >>>>>>> skinnable-master
2484                                 
2485                                 $alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current['sdname']);
2486                                 $has_enlargement = @file_exists($DIR_SKINS . $current['sdincpref'] . 'preview-large.png');
2487                                 if ( $has_enlargement )
2488                                 {
2489 <<<<<<< HEAD
2490                                         echo '<a href="',$CONF['SkinsURL'], Entity::hsc($current['sdincpref']),'preview-large.png" title="' . _LIST_SKIN_PREVIEW_VIEWLARGER . "\">\n";
2491                                         echo '<img class="skinpreview" src="',$CONF['SkinsURL'], Entity::hsc($current['sdincpref']),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" />\n";
2492                                         echo "</a><br />\n";
2493                                 }
2494                                 else
2495                                 {
2496                                         echo '<img class="skinpreview" src="',$CONF['SkinsURL'], Entity::hsc($current['sdincpref']),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" /><br />\n";
2497 =======
2498                                         $data['skinthumb'] .= '<a href="' . $CONF['SkinsURL'] . Entity::hsc($current['sdincpref']) . 'preview-large.png" title="' . _LIST_SKIN_PREVIEW_VIEWLARGER . "\">\n";
2499                                 }
2500                                 $data['skinthumb'] .= '<img class="skinpreview" src="' . $CONF['SkinsURL'] . Entity::hsc($current['sdincpref']) . 'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" />\n";
2501                                 if ( $has_enlargement )
2502                                 {
2503                                         $data['skinthumb'] .= "</a><br />\n";
2504 >>>>>>> skinnable-master
2505                                 }
2506                                 
2507                                 if ( @file_exists("{$DIR_SKINS}{$current['sdincpref']}readme.html") )
2508                                 {
2509                                         $url = $CONF['SkinsURL'] . Entity::hsc($current['sdincpref']) . 'readme.html';
2510                                         $title = sprintf(_LIST_SKIN_README, $current['sdname']);
2511 <<<<<<< HEAD
2512                                         echo "<a href=\"{$url}\" title=\"{$title}\">" . _LIST_SKIN_README_TXT . "</a>\n";
2513                                 }
2514                                 
2515                                 echo "</p>\n";
2516                         }
2517                         
2518                         echo "</td>\n";
2519                         
2520                         echo "<td>\n";
2521                         echo '<p>' . Entity::hsc($current['sddesc']) . "</p>\n";
2522                         
2523                         /* make list of defined skins */
2524                         $skin = new Skin($current['sdnumber']);
2525                         $available_skin_types = $skin->getAvailableTypes();
2526                         
2527                         echo _LIST_SKINS_DEFINED;
2528                         echo "<ul>\n";
2529                         foreach ( $available_skin_types as $type => $friendlyName )
2530                         {
2531                                 if ( $friendlyName === FALSE )
2532                                 {
2533                                         $friendlyName = ucfirst($type);
2534 =======
2535                                         $data['readme'] = "<a href=\"{$url}\" title=\"{$title}\">" . _LIST_SKIN_README_TXT . "</a>\n";
2536                                 }
2537                                 else
2538                                 {
2539                                         $data['readme'] ="";
2540                                 }
2541                                 
2542                                 $data['skinthumb'] .=  "</p>\n";
2543                         }
2544                         
2545                         $skin =& $manager->getSkin($current['sdnumber'], $vars['handler']);
2546                         $available_types = $skin->getAvailableTypes();
2547                         
2548                         $data['skinparts'] = _LIST_SKINS_DEFINED
2549                                            . "<ul>\n";
2550                         foreach ( $available_types as $type => $label )
2551                         {
2552                                 if ( $label === FALSE )
2553                                 {
2554                                         $label = ucfirst($type);
2555 >>>>>>> skinnable-master
2556                                         $article = 'skinpartspecial';
2557                                 }
2558                                 else
2559                                 {
2560                                         $article = "skinpart{$type}";
2561                                 }
2562 <<<<<<< HEAD
2563                                 echo "<li>\n";
2564                                 echo helpHtml($article) . "\n";
2565                                 echo "<a href=\"index.php?action=skinedittype&amp;skinid={$current['sdnumber']}&amp;type={$type}\" tabindex=\"{$template['tabindex']}\">";
2566                                 echo Entity::hsc($friendlyName);
2567                                 echo "</a>\n";
2568                                 echo "</li>\n";
2569                         }
2570                         echo "</ul>\n";
2571                         
2572                         echo "</td>";
2573                         echo "<td>\n";
2574                         echo "<a href=\nindex.php?action=skinedit&amp;skinid={$current['sdnumber']}\n tabindex=\n{$template['tabindex']}>" . _LISTS_EDIT . "</a>\n";
2575                         echo "</td>\n";
2576                         
2577                         $url = "index.php?action=skinclone&skinid={$current['sdnumber']}";
2578                         $url = Entity::hsc($manager->addTicketToUrl($url));
2579                         echo "<td>\n";
2580                         echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";
2581                         echo "</td>\n";
2582                         echo "<td>\n";
2583                         echo "<a href=\"index.php?action=skindelete&amp;skinid={$current['sdnumber']}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";
2584                         break;
2585         }
2586         return;
2587 }
2588
2589 function listplug_table_draftlist($template, $type)
2590 {
2591         switch( $type )
2592         {
2593                 case 'HEAD':
2594                         echo '<th>' . _LISTS_BLOG . "</th>\n";
2595                         echo '<th>' . _LISTS_TITLE . "</th>\n";
2596                         echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
2597                         break;
2598                 case 'BODY':
2599                         $current = $template['current'];
2600                         $current['bshortname'] = Entity::hsc($current['bshortname']);
2601                         $current['ititle'] = Entity::hsc(strip_tags($current['ititle']));
2602                         
2603                         echo "<td>{$current['bshortname']}</td>\n";
2604                         echo "<td>{$current['ititle']}</td>\n";
2605                         echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current['inumber']}\">" . _LISTS_EDIT . "</a></td>\n";
2606                         echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current['inumber']}\">" . _LISTS_DELETE . "</a></td>\n";
2607                         break;
2608         }
2609         return;
2610 }
2611
2612 function listplug_table_otherdraftlist($template, $type)
2613 {
2614         switch( $type )
2615         {
2616                 case 'HEAD':
2617                         echo '<th>' . _LISTS_BLOG . "</th>\n";
2618                         echo '<th>' . _LISTS_TITLE . "</th>\n";
2619                         echo '<th>' . _LISTS_AUTHOR . "</th>\n";
2620                         echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
2621                         break;
2622                 case 'BODY':
2623                         $current = $template['current'];
2624                         $current['bshortname'] = Entity::hsc($current['bshortname']);
2625                         $current['ititle'] = Entity::hsc(strip_tags($current['ititle']));
2626                         $current['mname'] = Entity::hsc($current['mname']);
2627                         
2628                         echo "<td>{$current['bshortname']}</td>\n";
2629                         echo "<td>{$current['ititle']}</td>\n";
2630                         echo "<td>{$current['mname']}</td>\n";
2631                         echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current['inumber']}\">" . _LISTS_EDIT . "</a></td>\n";
2632                         echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current['inumber']}\">" . _LISTS_DELETE . "</a></td>\n";
2633                         break;
2634         }
2635         return;
2636 }
2637
2638 function listplug_table_actionlist($template, $type)
2639 {
2640         switch( $type )
2641         {
2642                 case 'HEAD':
2643                         echo '<th>' . _LISTS_TIME . "</th>\n";
2644                         echo '<th>' . _LIST_ACTION_MSG . "</th>\n";
2645                         break;
2646                 case 'BODY':
2647                         $current = $template['current'];
2648                         $current['timestamp'] = Entity::hsc($current['timestamp']);
2649                         $current['message'] = Entity::hsc($current['message']);
2650                         
2651                         echo "<td>{$current['timestamp']}</td>\n";
2652                         echo "<td>{$current['message']}</td>\n";
2653                         break;
2654         }
2655         return;
2656 }
2657
2658 function listplug_table_banlist($template, $type)
2659 {
2660         switch( $type )
2661         {
2662                 case 'HEAD':
2663                         echo '<th>' . _LIST_BAN_IPRANGE . "</th>\n";
2664                         echo '<th>' . _LIST_BAN_REASON."</th>\n";
2665                         echo '<th>' . _LISTS_ACTIONS . "</th>\n";
2666                         break;
2667                 case 'BODY':
2668                         $current = $template['current'];
2669                         $current['blogid'] = (integer) $current['blogid'];
2670                         $current['iprange'] = Entity::hsc($current['iprange']);
2671                         $current['reason'] = Entity::hsc($current['reason']);
2672                         
2673                         echo "<td>{$current['iprange']}</td>\n";
2674                         echo "<td>{$current['reason']}</td>\n";
2675                         echo '<td><a href="index.php?action=banlistdelete&amp;blogid=' . $current['blogid'] . '&amp;iprange=' . Entity::hsc($current['iprange']) . '">' . _LISTS_DELETE . "</a></td>\n";
2676                         break;
2677         }
2678         return;
2679 =======
2680                                 $data['skinparts'] .= "<li>\n"
2681                                                    . helpHtml($article) . "\n"
2682                                                    . "<a href=\"{$CONF['AdminURL']}index.php?action={$vars['edittypeaction']}&amp;skinid={$current['sdnumber']}&amp;type={$type}\" tabindex=\"{$vars['tabindex']}\">"
2683                                                    . Entity::hsc($label)
2684                                                    . "</a>\n"
2685                                                    . "</li>\n";
2686                         }
2687                         $data['skinparts'] .= "</ul>\n";
2688                         break;
2689                 case 'FOOT':
2690                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT']) )
2691                         {
2692                                 $template = "";
2693                         }
2694                         else
2695                         {
2696                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT'];
2697                         }
2698                         $data = array();
2699                         break;
2700         }
2701         return Template::fill($template, $data);
2702 }
2703
2704 function listplug_table_draftlist($vars, $type, $template_name = '')
2705 {
2706         global $manager;
2707         
2708         $templates = array();
2709         if ( !empty($template_name) )
2710         {
2711                 $templates =& $manager->getTemplate($template_name);
2712         }
2713         switch( $type )
2714         {
2715                 case 'HEAD':
2716                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD']) )
2717                         {
2718                                 $template = "<th><%colblog%></th>\n"
2719                                           . "<th><%coldesc%></th>\n"
2720                                           . "<th colspan=\"2\"><%colact%></th>\n";
2721                         }
2722                         else
2723                         {
2724                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD'];
2725                         }
2726                         $data = array(
2727                                 'colblog'       => _LISTS_BLOG,
2728                                 'coldesc'       => _LISTS_TITLE,
2729                                 'colact'        => _LISTS_ACTIONS,
2730                         );
2731                         break;
2732                 case 'BODY':
2733                         $current = $vars['current'];
2734                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY']) )
2735                         {
2736                                 $template = "<td><%bshortname%></td>\n"
2737                                           . "<td><%ititle%></td>\n"
2738                                           . "<td><a href=\"index.php?action=itemedit&amp;itemid=<%itemid%>\"><%editbtn%></a></td>\n"
2739                                           . "<td><a href=\"index.php?action=itemdelete&amp;itemid=<%itemid%>\"><%delbtn%></a></td>\n";
2740                         }
2741                         else
2742                         {
2743                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY'];
2744                         }
2745                         $data = array(
2746                                 'bshortname'    => Entity::hsc($current['bshortname']),
2747                                 'ititle'                => Entity::hsc(strip_tags($current['ititle'])),
2748                                 'itemid'                => intval($current['inumber']),
2749                                 'editbtn'               => _LISTS_EDIT,
2750                                 'delbtn'                => _LISTS_DELETE,
2751                         );
2752                         break;
2753                 case 'FOOT':
2754                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT']) )
2755                         {
2756                                 $template = "\n";
2757                         }
2758                         else
2759                         {
2760                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT'];
2761                         }
2762                         $data = array();
2763                         break;
2764         }
2765         return Template::fill($template, $data);
2766 }
2767
2768 function listplug_table_otherdraftlist($vars, $type, $template_name = '')
2769 {
2770         global $manager;
2771         
2772         $templates = array();
2773         if ( !empty($template_name) )
2774         {
2775                 $templates =& $manager->getTemplate($template_name);
2776         }
2777         
2778         switch( $type )
2779         {
2780                 case 'HEAD':
2781                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_HEAD']) )
2782                         {
2783                                 $template = "<th><%colblog%></th>\n"
2784                                           . "<th><%coldesc%></th>\n"
2785                                           . "<th><%colautr%></th>\n"
2786                                           . "<th colspan=\"2\"><%colact%></th>\n";
2787                         }
2788                         else
2789                         {
2790                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_HEAD'];
2791                         }
2792                         $data = array(
2793                                 'colblog'       => _LISTS_BLOG,
2794                                 'coldesc'       => _LISTS_TITLE,
2795                                 'colautr'       => _LISTS_AUTHOR,
2796                                 'colact'        => _LISTS_ACTIONS,
2797                         );
2798                         break;
2799                 case 'BODY':
2800                         $current = $vars['current'];
2801                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_BODY']) )
2802                         {
2803                                 $template = "<td><%bshortname%></td>\n"
2804                                           . "<td><%ititle%></td>\n"
2805                                           . "<td><%iauthor%></td>\n"
2806                                           . "<td><a href=\"index.php?action=itemedit&amp;itemid=<%itemid%>\"><%editbtn%></a></td>\n"
2807                                           . "<td><a href=\"index.php?action=itemdelete&amp;itemid=<%itemid%>\"><%delbtn%></a></td>\n";
2808                         }
2809                         else
2810                         {
2811                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_BODY'];
2812                         }
2813                         $data = array(
2814                                 'bshortname'    => Entity::hsc($current['bshortname']),
2815                                 'ititle'                => Entity::hsc(strip_tags($current['ititle'])),
2816                                 'iauthor'               => Entity::hsc(strip_tags($current['mname'])),
2817                                 'itemid'                => intval($current['inumber']),
2818                                 'editbtn'               => _LISTS_EDIT,
2819                                 'delbtn'                => _LISTS_DELETE,
2820                         );
2821                         break;
2822                 case 'FOOT':
2823                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_FOOT']) )
2824                         {
2825                                 $template = "\n";
2826                         }
2827                         else
2828                         {
2829                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_FOOT'];
2830                         }
2831                         $data = array();
2832                         break;
2833         }
2834         return Template::fill($template, $data);
2835 }
2836
2837 function listplug_table_actionlist($vars, $type, $template_name = '')
2838 {
2839         global $manager;
2840         
2841         $templates = array();
2842         if ( !empty($template_name) )
2843         {
2844                 $templates =& $manager->getTemplate($template_name);
2845         }
2846         
2847         switch( $type )
2848         {
2849                 case 'HEAD':
2850                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD']) )
2851                         {
2852                                 $template = "<th><%coltime%></th>\n"
2853                                           . "<th><%colmesg%></th>\n";
2854                         }
2855                         else
2856                         {
2857                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD'];
2858                         }
2859                         $data = array(
2860                                 'coltime' => _LISTS_TIME,
2861                                 'colmesg' => _LIST_ACTION_MSG,
2862                         );
2863                         break;
2864                 case 'BODY':
2865                         $current = $vars['current'];
2866                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY']) )
2867                         {
2868                                 $template = "<td><%timestamp%></td>\n"
2869                                           . "<td><%message%></td>\n";
2870                         }
2871                         else
2872                         {
2873                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY'];
2874                         }
2875                         $data = array(
2876                                 'timestamp'     => Entity::hsc($current['timestamp']),
2877                                 'message'       => Entity::hsc($current['message']),
2878                         );
2879                         break;
2880                 case 'FOOT':
2881                         $current = $vars['current'];
2882                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT']) )
2883                         {
2884                                 $template = "\n";
2885                         }
2886                         else
2887                         {
2888                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT'];
2889                         }
2890                         $data = array();
2891                         break;
2892         }
2893         return Template::fill($template, $data);
2894 }
2895
2896 function listplug_table_banlist($vars, $type, $template_name = '')
2897 {
2898         global $manager;
2899         
2900         $templates = array();
2901         if ( !empty($template_name) )
2902         {
2903                 $templates =& $manager->getTemplate($template_name);
2904         }
2905         
2906         switch( $type )
2907         {
2908                 case 'HEAD':
2909                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD']) )
2910                         {
2911                                 $template = "<th><%iprange%></th>\n"
2912                                           . "<th><%reason%></th>\n"
2913                                           . "<th><%colact%></th>\n";
2914                         }
2915                         else
2916                         {
2917                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD'];
2918                         }
2919                         $data = array(
2920                                 'iprange'       => _LIST_BAN_IPRANGE,
2921                                 'reason'        => _LIST_BAN_REASON,
2922                                 'colact'        => _LISTS_ACTIONS,
2923                         );
2924                         break;
2925                 case 'BODY':
2926                         $current = $vars['current'];
2927                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY']) )
2928                         {
2929                                 $template = "<td><%iprange%></td>\n"
2930                                           . "<td><%reason%></td>\n"
2931                                           . "<td><a href=\"index.php?action=banlistdelete&amp;blogid=<%blogid%>&amp;iprange=<%iprange%>\"><%delbtn%></a></td>\n";
2932                         }
2933                         else
2934                         {
2935                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY'];
2936                         }
2937                         $data = array(
2938                                 'iprange'       => Entity::hsc($current['iprange']),
2939                                 'reason'        => Entity::hsc($current['reason']),
2940                                 'blogid'        => intval($current['blogid']),
2941                                 'delbtn'        => _LISTS_DELETE,
2942                         );
2943                         break;
2944                 case 'FOOT':
2945                         $current = $vars['current'];
2946                         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT']) )
2947                         {
2948                                 $template = "\n";
2949                         }
2950                         else
2951                         {
2952                                 $template = $templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT'];
2953                         }
2954                         $data = array();
2955                         break;
2956         }
2957         return Template::fill($template, $data);
2958 }
2959
2960 /**
2961  * listplug_list_normalskinlist()
2962  * 
2963  * @param       array   $vars                   array for variables
2964  * @param       string  $type                   HEAD/BODY/FOOT
2965  * @param       string  $template_name  name of template
2966  * @return      string  marked-up string
2967  */
2968 function listplug_list_normalskinlist($vars, $type, $template_name = '')
2969 {
2970         global $manager, $CONF;
2971         
2972         /* available variables as a default */
2973         $data = array(
2974                 'skinid'        => (integer) $vars['skinid'],
2975                 'skinname'      => Entity::hsc($vars['skinname']),
2976         );
2977         
2978         $templates = array();
2979         if ( $template_name )
2980         {
2981                 $templates =& $manager->getTemplate($template_name);
2982         }
2983         
2984         switch ( $type )
2985         {
2986                 case 'HEAD':
2987                         if ( !array_key_exists('NORMALSKINLIST_HEAD', $templates) || empty($templates['NORMALSKINLIST_HEAD']) )
2988                         {
2989                                 $template = "<ul>\n";
2990                         }
2991                         else
2992                         {
2993                                 $template = $templates['NORMALSKINLIST_HEAD'];
2994                         }
2995                         
2996                         break;
2997                 case 'BODY':
2998                         $current = $vars['current'];
2999                         if ( !array_key_exists('NORMALSKINLIST_BODY', $templates) || empty($templates['NORMALSKINLIST_BODY']) )
3000                         {
3001                                 $template = "<li>"
3002                                           . "<a href=\"<%editurl%>\" tabindex=\"<%tabindex%>\"><%skintypename%></a>"
3003                                           . " <%help%>"
3004                                           . "</li>\n";
3005                         }
3006                         else
3007                         {
3008                                 $template = $templates['NORMALSKINLIST_BODY'];
3009                         }
3010                         
3011                         $data['tabindex']               = $vars['tabindex']++;
3012                         $data['skintype']               = $current['skintype'];
3013                         $data['skintypename']   = $current['skintypename'];
3014                         $data['editaction']             = $vars['editaction'];
3015                         $data['editurl']                = "{$CONF['AdminURL']}?action={$vars['editaction']}&amp;skinid={$vars['skinid']}&amp;type={$current['skintype']}";
3016                         /* TODO: removeaction? */
3017                         /* TODO: customHelpHtml("skinpart{$skintype}-{$template_name}") */
3018                         $data['help']                   = '';
3019                         break;
3020                 case 'FOOT':
3021                         if ( !array_key_exists('NORMALSKINLIST_FOOT', $templates) || empty($templates['NORMALSKINLIST_FOOT']) )
3022                         {
3023                                 $template = "</ul>\n";
3024                         }
3025                         else
3026                         {
3027                                 $template = $templates['NORMALSKINLIST_FOOT'];
3028                         }
3029                         
3030                         break;
3031         }
3032         
3033         return Template::fill($template, $data);
3034 }
3035
3036 /**
3037  * listplug_list_specialskinlist()
3038  * 
3039  * @param       array   $vars                   array for variables
3040  * @param       string  $type                   HEAD/BODY/FOOT
3041  * @param       string  $template_name  name of template
3042  * @return      string  marked-up string
3043  */
3044 function listplug_list_specialskinlist($vars, $type, $template_name = '')
3045 {
3046         global $manager, $CONF;
3047         
3048         /* available variables as a default */
3049         $data = array(
3050                 'skinid'        => (integer) $vars['skinid'],
3051                 'skinname'      => Entity::hsc($vars['skinname']),
3052         );
3053         
3054         /* retrieve templates */
3055         $templates = array();
3056         if ( $template_name )
3057         {
3058                 $templates =& $manager->getTemplate($template_name);
3059         }
3060         
3061         switch ( $type )
3062         {
3063                 case 'HEAD':
3064                         if ( !array_key_exists('SPECIALSKINLIST_HEAD', $templates) || empty($templates['SPECIALSKINLIST_HEAD']) )
3065                         {
3066                                 $template = "<ul>\n";
3067                         }
3068                         else
3069                         {
3070                                 $template = $templates['SPECIALSKINLIST_HEAD'];
3071                         }
3072                         break;
3073                 case 'BODY':
3074                         $current = $vars['current'];
3075                         if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
3076                         {
3077                                 $template = "<li>"
3078                                           . "<a href=\"<%editurl%>\" tabindex=\"<%tabindex%>\">"
3079                                           . "<%skintype%>"
3080                                           . "</a>"
3081                                           . " ("
3082                                           . "<a href=\"<%removeurl%>\" tabindex=\"<%tabindex%>\" >"
3083                                           . "<%text(_LISTS_DELETE)%>"
3084                                           . "</a>"
3085                                           . ")"
3086                                           . "</li>\n";
3087                         }
3088                         else
3089                         {
3090                                 $template = $templates['SPECIALSKINLIST_BODY'];
3091                         }
3092                         
3093                         $data['tabindex']               = (integer) $vars['tabindex']++;
3094                         $data['skintype']               = Entity::hsc($current['skintype']);
3095                         $data['skintypename']   = Entity::hsc($current['skintypename']);
3096                         $data['editaction']             = $vars['editaction'];
3097                         $data['editurl']                = "{$CONF['AdminURL']}?action={$vars['editaction']}&amp;skinid={$vars['skinid']}&amp;type={$current['skintype']}";
3098                         $data['removeaction']   = $vars['editaction'];
3099                         $data['removeurl']              = "{$CONF['AdminURL']}?action={$vars['removeaction']}&amp;skinid={$vars['skinid']}&amp;type={$current['skintype']}";
3100                         
3101                         break;
3102                 case 'FOOT':
3103                         if ( !array_key_exists('SPECIALSKINLIST_FOOT', $templates) || empty($templates['SPECIALSKINLIST_FOOT']) )
3104                         {
3105                                 $template = "</ul>\n";
3106                         }
3107                         else
3108                         {
3109                                 $template = $templates['SPECIALSKINLIST_FOOT'];
3110                         }
3111                         break;
3112         }
3113         
3114         return Template::fill($template, $data);
3115 }
3116
3117 /**
3118  * listplug_input_yesno()
3119  *
3120  * @param       string  $name                   name of input element with radio type attribute
3121  * @param       string  $checkedval             value which should be checked
3122  * @param       integer $tabindex               tabindex number
3123  * @param       string  $value1                 value of radio 1
3124  * @param       string  $value2                 value of radio 2
3125  * @param       string  $yesval                 label for yes
3126  * @param       string  $noval                  label for no
3127  * @param       boolean $isAdmin                super admin or not
3128  * @param       string  $template_name  name of template
3129  * @param       boolean $showlist               used in showlist or not
3130  * @return      string  marked-up string
3131  */
3132 function listplug_input_yesno($name, $checkedval, $tabindex = 0,
3133         $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO,
3134         $isAdmin = 0, $template_name = '', $showlist = FALSE)
3135 {
3136         global $manager;
3137         
3138         $templates = array();
3139         if ( $template_name )
3140         {
3141                 $templates =& $manager->getTemplate($template_name);
3142         }
3143         
3144         if ( $name == 'admin' )
3145         {
3146                 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
3147                 {
3148                         $template = "<input type=\"radio\" id=\"<%yesid%>\" name=\"<%name%>\" value=\"<%yesval%>\" <%yescheckedval%> onclick=\"selectCanLogin(true);\" />\n"
3149                                   . "<label for=\"<%yesid%>\"><%yesvaltext%></label>\n"
3150                                   . "<input type=\"radio\" id=\"<%noid%>\" name=\"<%name%>\" value=\"<%noval%>\" <%nocheckedval%> <%disabled%> onclick=\"selectCanLogin(false);\" />\n"
3151                                   . "<label for=\"<%noid%>\"><%novaltext%></label>\n";
3152                 }
3153                 else
3154                 {
3155                         $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
3156                 }
3157         }
3158         else
3159         {
3160                 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
3161                 {
3162                         $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
3163                 }
3164                 else if ( $showlist && array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
3165                 {
3166                         $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
3167                 }
3168                 else
3169                 {
3170                 $template = "<input type=\"radio\" id=\"<%yesid%>\" name=\"<%name%>\" value=\"<%yesval%>\" <%yescheckedval%> />\n"
3171                           . "<label for=\"<%yesid%>\"><%yesvaltext%></label>\n"
3172                           . "<input type=\"radio\" id=\"<%noid%>\" name=\"<%name%>\" value=\"<%noval%>\" <%nocheckedval%> <%disabled%> />\n"
3173                           . "<label for=\"<%noid%>\"><%novaltext%></label>\n";
3174                 }
3175         }
3176         
3177         $id             = preg_replace('#[|]#', '-', $name);
3178         $id1    = $id . $value1;
3179         $id2    = $id . $value2;
3180         $dat = array(
3181                 'name'                  => Entity::hsc($name),
3182                 'yesval'                => Entity::hsc($value1),
3183                 'noval'                 => Entity::hsc($value2),
3184                 'yesid'                 => Entity::hsc($id1),
3185                 'noid'                  => Entity::hsc($id2),
3186                 'yesvaltext'    => $yesval,
3187                 'novaltext'             => $noval,
3188                 'yescheckedval' => ($checkedval == $value1) ? 'checked="checked" tabindex="' . $tabindex . '"': '',
3189                 'nocheckedval'  => ($checkedval != $value1) ? 'checked="checked" tabindex="' . $tabindex . '"': '',
3190                 'disabled'              => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
3191         );
3192         
3193         return Template::fill($template, $dat);
3194 }
3195
3196 /**
3197  * listplug_batchlist()
3198  * 
3199  * @param       string          $attr   item/member/team/category/comment
3200  * @param       resource        $query  SQL resorce
3201  * @param       string          $type   type for showlist()
3202  * @param       array           $vars   array for variables
3203  */
3204 function listplug_batchlist($attr, $query, $type, $vars, $template_name)
3205 {
3206         global $manager;
3207         
3208         /* HEAD */
3209         $content = "<form method=\"post\" action=\"index.php\">\n";
3210         
3211         /* BODY */
3212         $content .= showlist($query, $type, $vars, $template_name);
3213         
3214         /* FOOT */
3215         switch ( $attr )
3216         {
3217                 case 'item':
3218                         $options = array(
3219                                 'delete'        => _BATCH_ITEM_DELETE,
3220                                 'move'          => _BATCH_ITEM_MOVE
3221                         );
3222                         break;
3223                 case 'member':
3224                         $options = array(
3225                                 'delete'        => _BATCH_MEMBER_DELETE,
3226                                 'setadmin'      => _BATCH_MEMBER_SET_ADM,
3227                                 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM
3228                         );
3229                         break;
3230                 case 'team':
3231                         $options = array(
3232                                 'delete'        => _BATCH_TEAM_DELETE,
3233                                 'setadmin'      => _BATCH_TEAM_SET_ADM,
3234                                 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,
3235                         );
3236                         break;
3237                 case 'category':
3238                         $options = array(
3239                                 'delete'        => _BATCH_CAT_DELETE,
3240                                 'move'          => _BATCH_CAT_MOVE,
3241                         );
3242                         break;
3243                 case 'comment':
3244                         $options = array(
3245                                 'delete'        => _BATCH_COMMENT_DELETE,
3246                         );
3247                         break;
3248                 default:
3249                         $options = array();
3250                         break;
3251         }
3252         
3253         $content .= "<p class=\"batchoperations\">\n"
3254                    . _BATCH_WITH_SEL
3255                    . "<select name=\"batchaction\">\n";
3256         
3257         foreach ( $options as $option => $label )
3258         {
3259                 $content .= "<option value=\"{$option}\">{$label}</option>\n";
3260         }
3261         $content .= "</select>\n";
3262         
3263         if ( $attr == 'team' )
3264         {
3265                 $content .= '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . '" />';
3266         }
3267         else if ( $attr == 'comment' )
3268         {
3269                 $content .= '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . '" />';
3270         }
3271         
3272         $content .= '<input type="submit" value="' . _BATCH_EXEC . '" />'
3273                    . "("
3274                    . "<a href=\"\" onclick=\"if( event &amp;&amp; event.preventDefault ) event.preventDefault(); return batchSelectAll(1); \">" . _BATCH_SELECTALL . "</a>"
3275                    . " - "
3276                    . "<a href=\"\" onclick=\"if( event &amp;&amp; event.preventDefault ) event.preventDefault(); return batchSelectAll(0); \">" . _BATCH_DESELECTALL . "</a>"
3277                    . ")\n"
3278                    . "<input type=\"hidden\" name=\"action\" value=\"batch{$attr}\" />\n"
3279                    . '<input type="hidden" name="ticket" value="' . Entity::hsc($manager->getNewTicket()) . '" />' . "\n"
3280                    . "</p>\n"
3281                    . "</form>\n";
3282         
3283         return $content;
3284 }
3285
3286 /**
3287  * listplug_navlist()
3288  * 
3289  * @param       string          $attr                   item/member/team/category/comment
3290  * @param       resource        $query                  SQL resorce
3291  * @param       string          $type                   type for showlist()
3292  * @param       array           $vars                   array for variables
3293  * @param       string          $template_name  name of template
3294  * @return      string          contents
3295  */
3296 function listplug_navlist($attribute, $query, $type, $vars, $template_name)
3297 {
3298         global $CONF, $manager;
3299         $dat['adminurl'] = $CONF['AdminURL'];
3300         
3301         $templates = array();
3302         if ( $template_name )
3303         {
3304                 $templates =& $manager->getTemplate($template_name);
3305         }
3306         
3307         $dat['prev'] = $vars['start'] - $vars['amount'];
3308         if ( $dat['prev'] < $vars['minamount'] )
3309         {
3310                 $dat['prev'] = $vars['minamount'];
3311         }
3312         
3313         $dat['next'] = $vars['start'] + $vars['amount'];
3314         
3315         $navi = "\n";
3316         if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_NAVILIST', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_NAVILIST']) )
3317         {
3318                 $navi .= "<table frame=\"box\" rules=\"all\" sumamry=\"navigation actions\" class=\"navigation\">\n"
3319                        . "<tr>\n";
3320                 $navi .= "<td>\n"
3321                        . "<form method=\"post\" action=\"<%adminurl%>\">\n"
3322                        . "<input type=\"hidden\" name=\"start\" value=\"<%prev%>\" />\n"
3323                        . "<button type=\"submit\" name=\"action\" value=\"<%action%>\">&lt; &lt; <%listsprev%></button>\n"
3324                        . "<input type=\"hidden\" name=\"blogid\" value=\"<%blogid%>\" />\n"
3325                        . "<input type=\"hidden\" name=\"itemid\" value=\"<%itemid%>\" />\n"
3326                        . "<input type=\"hidden\" name=\"search\" value=\"<%search%>\" />\n"
3327                        . "<input type=\"hidden\" name=\"amount\" value=\"<%amount%>\" />\n"
3328                        . "</form>\n"
3329                        . "</td>\n";
3330                 $navi .= "<td>\n"
3331                        . "<form method=\"post\" action=\"<%adminurl%>\">\n"
3332                        . "<input type=\"text\" name=\"amount\" size=\"3\" value=\"<%amount%>\" />\n"
3333                        . "<%listsperpage%>"
3334                        . "<input type=\"hidden\" name=\"start\" value=\"0\" />\n"
3335                        . "<button type=\"submit\" name=\"action\" value=\"<%action%>\">&gt; <%listschange%></button>\n"
3336                        . "<input type=\"hidden\" name=\"blogid\" value=\"<%blogid%>\" />\n"
3337                        . "<input type=\"hidden\" name=\"itemid\" value=\"<%itemid%>\" />\n"
3338                        . "<input type=\"hidden\" name=\"search\" value=\"<%search%>\" />\n"
3339                        . "<input type=\"hidden\" name=\"amount\" value=\"<%amount%>\" />\n"
3340                        . "</form>\n"
3341                        . "</td>\n";
3342                 $navi .= "<td>\n"
3343                        . "<form method=\"post\" action=\"<%adminurl%>\">\n"
3344                        . "<input type=\"text\" name=\"search\" value=\"<%search%>\" size=\"7\" />\n"
3345                        . "<input type=\"hidden\" name=\"start\" value=\"0\" />\n"
3346                        . "<button type=\"submit\" name=\"action\" value=\"<%action%>\">&gt; <%listssearch%></button>\n"
3347                        . "<input type=\"hidden\" name=\"blogid\" value=\"<%blogid%>\" />\n"
3348                        . "<input type=\"hidden\" name=\"itemid\" value=\"<%itemid%>\" />\n"
3349                        . "<input type=\"hidden\" name=\"search\" value=\"<%search%>\" />\n"
3350                        . "<input type=\"hidden\" name=\"amount\" value=\"<%amount%>\" />\n"
3351                        . "</form>\n"
3352                        . "</td>\n";
3353                 $navi .= "<td>\n"
3354                        . "<form method=\"post\" action=\"<%adminurl%>\">\n"
3355                        . "<input type=\"hidden\" name=\"start\" value=\"<%next%>\" />\n"
3356                        . "<button type=\"submit\" name=\"action\" value=\"<%action%>\"><%listsnext%>&gt; &gt; </button>\n"
3357                        . "<input type=\"hidden\" name=\"blogid\" value=\"<%blogid%>\" />\n"
3358                        . "<input type=\"hidden\" name=\"itemid\" value=\"<%itemid%>\" />\n"
3359                        . "<input type=\"hidden\" name=\"search\" value=\"<%search%>\" />\n"
3360                        . "<input type=\"hidden\" name=\"amount\" value=\"<%amount%>\" />\n"
3361                        . "</form>\n"
3362                        . "</td>\n";
3363                 $navi .= "</tr>\n"
3364                        . "</table>\n";
3365         }
3366         else
3367         {
3368                 $navi .= $templates['SHOWLIST_LISTPLUG_TABLE_NAVILIST'];
3369         }
3370         $dat['listsprev']               = _LISTS_PREV;
3371         $dat['listschange']             = _LISTS_CHANGE;
3372         $dat['listssearch']             = _LISTS_SEARCH;
3373         $dat['listsnext']               = _LISTS_NEXT;
3374         $dat['listsperpage']    = _LISTS_PERPAGE;
3375         /* HEAD */
3376         $template = Template::fill($navi, $dat);
3377         
3378         /* BODY */
3379         $template .= listplug_batchlist($attribute, $query, $type, $vars, $template_name);
3380         
3381         /* FOOT */
3382         $template .= Template::fill($navi, $dat);
3383         
3384         return $template;
3385 >>>>>>> skinnable-master
3386 }