OSDN Git Service

3.65sp1リリースのためにコピーライトの期間表記を「2002-2013」に変更
[nucleus-jp/nucleus-jp-ancient.git] / nucleus / libs / showlist.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2013 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  * Functions to create lists of things inside the admin are
13  */
14
15 // can take either an array of objects, or an SQL query
16 function showlist($query, $type, $template) {
17
18         if (is_array($query)) {
19                 if (sizeof($query) == 0)
20                         return 0;
21
22                 call_user_func('listplug_' . $type, $template, 'HEAD');
23
24                 foreach ($query as $currentObj) {
25                         $template['current'] = $currentObj;
26                         call_user_func('listplug_' . $type, $template, 'BODY');
27                 }
28
29                 call_user_func('listplug_' . $type, $template, 'FOOT');
30
31                 return sizeof($query);
32
33         } else {
34                 $res = sql_query($query);
35
36                 // don't do anything if there are no results
37                 $numrows = sql_num_rows($res);
38                 if ($numrows == 0)
39                         return 0;
40
41                 call_user_func('listplug_' . $type, $template, 'HEAD');
42
43                 while($template['current'] = sql_fetch_object($res))
44                         call_user_func('listplug_' . $type, $template, 'BODY');
45
46                 call_user_func('listplug_' . $type, $template, 'FOOT');
47
48                 sql_free_result($res);
49
50                 // return amount of results
51                 return $numrows;
52         }
53 }
54
55 function listplug_select($template, $type) {
56         switch($type) {
57                 case 'HEAD':
58                         echo '<select name="' . ifset($template['name']) . '" tabindex="' . ifset($template['tabindex']) . '" ' . ifset($template['javascript']) . '>';
59
60                         // add extra row if needed
61                         if (ifset($template['extra'])) {
62                                 echo '<option value="', ifset($template['extraval']), '">', $template['extra'], '</option>';
63                         }
64
65                         break;
66                 case 'BODY':
67                         $current = $template['current'];
68
69                         echo '<option value="' . htmlspecialchars($current->value) . '"';
70                         if ($template['selected'] == $current->value)
71                                 echo ' selected="selected" ';
72                         if (isset($template['shorten']) && $template['shorten'] > 0) {
73                                 echo ' title="'. htmlspecialchars($current->text).'"';
74                                 $current->text = shorten($current->text, $template['shorten'], $template['shortenel']);
75                         }
76                         echo '>' . htmlspecialchars($current->text) . '</option>';
77                         break;
78                 case 'FOOT':
79                         echo '</select>';
80                         break;
81         }
82 }
83
84 function listplug_table($template, $type) {
85         switch($type) {
86                 case 'HEAD':
87                         echo "<table>";
88                         echo "<thead><tr>";
89                         // print head
90                         call_user_func("listplug_table_" . $template['content'] , $template, 'HEAD');
91                         echo "</tr></thead><tbody>";
92                         break;
93                 case 'BODY':
94                         // print tabletype specific thingies
95                         echo "<tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'>";
96                         call_user_func("listplug_table_" . $template['content'] , $template,  'BODY');
97                         echo "</tr>";
98                         break;
99                 case 'FOOT':
100                         call_user_func("listplug_table_" . $template['content'] , $template,  'FOOT');
101                         echo "</tbody></table>";
102                         break;
103         }
104 }
105
106 function listplug_table_memberlist($template, $type) {
107         switch($type) {
108                 case 'HEAD':
109                         echo '<th>' . _LIST_MEMBER_NAME . '</th><th>' . _LIST_MEMBER_RNAME . '</th><th>' . _LIST_MEMBER_URL . '</th><th>' . _LIST_MEMBER_ADMIN;
110                         help('superadmin');
111                         echo "</th><th>" . _LIST_MEMBER_LOGIN;
112                         help('canlogin');
113                         echo "</th><th colspan='2'>" . _LISTS_ACTIONS. "</th>";
114                         break;
115                 case 'BODY':
116                         $current = $template['current'];
117
118                         echo '<td>';
119                         $id = listplug_nextBatchId();
120                         echo '<input type="checkbox" id="batch',$id,'" name="batch[',$id,']" value="',$current->mnumber,'" />';
121                         echo '<label for="batch',$id,'">';
122                         echo "<a href='mailto:", htmlspecialchars($current->memail), "' tabindex='".$template['tabindex']."'>", htmlspecialchars($current->mname), "</a>";
123                         echo '</label>';
124                         echo '</td>';
125                         echo '<td>', htmlspecialchars($current->mrealname), '</td>';
126                         echo "<td><a href='", htmlspecialchars($current->murl), "' tabindex='", $template['tabindex'] , "'>", htmlspecialchars($current->murl), "</a></td>";
127                         echo '<td>', ($current->madmin ? _YES : _NO),'</td>';
128                         echo '<td>', ($current->mcanlogin ? _YES : _NO), '</td>';
129                         echo "<td><a href='index.php?action=memberedit&amp;memberid=$current->mnumber' tabindex='".$template['tabindex']."'>"._LISTS_EDIT."</a></td>";
130                         echo "<td><a href='index.php?action=memberdelete&amp;memberid=$current->mnumber' tabindex='".$template['tabindex']."'>"._LISTS_DELETE."</a></td>";
131                         break;
132         }
133 }
134
135 function listplug_table_teamlist($template, $type) {
136         global $manager;
137         switch($type) {
138                 case 'HEAD':
139                         echo "<th>"._LIST_MEMBER_NAME."</th><th>"._LIST_MEMBER_RNAME."</th><th>"._LIST_TEAM_ADMIN;
140                         help('teamadmin');
141                         echo "</th><th colspan='2'>"._LISTS_ACTIONS."</th>";
142                         break;
143                 case 'BODY':
144                         $current = $template['current'];
145
146                         echo '<td>';
147                         $id = listplug_nextBatchId();
148                         echo '<input type="checkbox" id="batch',$id,'" name="batch[',$id,']" value="',$current->tmember,'" />';
149                         echo '<label for="batch',$id,'">';
150                         echo "<a href='mailto:", htmlspecialchars($current->memail), "' tabindex='".$template['tabindex']."'>", htmlspecialchars($current->mname), "</a>";
151                         echo '</label>';
152                         echo '</td>';
153                         echo '<td>', htmlspecialchars($current->mrealname), '</td>';
154                         echo '<td>', ($current->tadmin ? _YES : _NO) , '</td>';
155                         echo "<td><a href='index.php?action=teamdelete&amp;memberid=$current->tmember&amp;blogid=$current->tblog' tabindex='".$template['tabindex']."'>"._LISTS_DELETE."</a></td>";
156
157                         $url = 'index.php?action=teamchangeadmin&memberid=' . intval($current->tmember) . '&blogid=' . intval($current->tblog);
158                         $url = $manager->addTicketToUrl($url);
159                         echo "<td><a href='",htmlspecialchars($url),"' tabindex='".$template['tabindex']."'>"._LIST_TEAM_CHADMIN."</a></td>";
160                         break;
161         }
162 }
163
164 function listplug_table_pluginlist($template, $type) {
165         global $manager;
166         switch($type) {
167                 case 'HEAD':
168                         echo '<th>'._LISTS_INFO.'</th><th>'._LISTS_DESC.'</th>';
169                         echo '<th style="white-space:nowrap">'._LISTS_ACTIONS.'</th>';
170                         break;
171                 case 'BODY':
172                         $current = $template['current'];
173
174                         $plug =& $manager->getPlugin($current->pfile);
175                         if ($plug) {
176                                 echo '<td>';
177                                         echo '<strong>' , htmlspecialchars($plug->getName()) , '</strong><br />';
178                                         echo _LIST_PLUGS_AUTHOR, ' ' , htmlspecialchars($plug->getAuthor()) , '<br />';
179                                         echo _LIST_PLUGS_VER, ' ' , htmlspecialchars($plug->getVersion()) , '<br />';
180                                         if ($plug->getURL())
181                                         echo '<a href="',htmlspecialchars($plug->getURL()),'" tabindex="'.$template['tabindex'].'">',_LIST_PLUGS_SITE,'</a><br />';
182                                 echo '</td>';
183                                 echo '<td>';
184                                         echo _LIST_PLUGS_DESC .'<br/>'. encode_desc($plug->getDescription());
185                                         if (sizeof($plug->getEventList()) > 0) {
186                                                 echo '<br /><br />',_LIST_PLUGS_SUBS,'<br />',htmlspecialchars(implode($plug->getEventList(),', '));
187                                                 // check the database to see if it is up-to-date and notice the user if not
188                                         }
189                                         if (!$plug->subscribtionListIsUptodate()) {
190                                                 echo '<br /><br /><strong>',_LIST_PLUG_SUBS_NEEDUPDATE,'</strong>';
191                                         }
192                                         if (sizeof($plug->getPluginDep()) > 0) {
193                                                 echo '<br /><br />',_LIST_PLUGS_DEP,'<br />',htmlspecialchars(implode($plug->getPluginDep(),', '));
194                                         }
195 // <add by shizuki>
196                                 // check dependency require
197                                 $req = array();
198                                 $res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));
199                                 while($o = sql_fetch_object($res)) {
200                                         $preq =& $manager->getPlugin($o->pfile);
201                                         if ($preq) {
202                                                 $depList = $preq->getPluginDep();
203                                                 foreach ($depList as $depName) {
204                                                         if ($current->pfile == $depName) {
205                                                                 $req[] = $o->pfile;
206                                                         }
207                                                 }
208                                         }
209                                 }
210                                 if (count($req) > 0) {
211                                         echo '<h4 class="plugin_dependreq_title">' . _LIST_PLUGS_DEPREQ . "</h4>\n";
212                                         echo '<p class="plugin_dependreq_text">';
213                                         echo htmlspecialchars(implode(', ', $req), ENT_QUOTES);
214                                         echo "</p>\n";
215                                 }
216 // </add by shizuki>
217                                 echo '</td>';
218                         } else {
219                                 echo '<td colspan="2">' . sprintf(_PLUGINFILE_COULDNT_BELOADED, htmlspecialchars($current->pfile, ENT_QUOTES)) . '</td>';
220                         }
221                         echo '<td style="white-space:nowrap">';
222
223                                 $baseUrl = 'index.php?plugid=' . intval($current->pid) . '&action=';
224                                 $url = $manager->addTicketToUrl($baseUrl . 'pluginup');
225                                 echo "<a href='",htmlspecialchars($url),"' tabindex='".$template['tabindex']."'>",_LIST_PLUGS_UP,"</a>";
226                                 $url = $manager->addTicketToUrl($baseUrl . 'plugindown');
227                                 echo "<br /><a href='",htmlspecialchars($url),"' tabindex='".$template['tabindex']."'>",_LIST_PLUGS_DOWN,"</a>";
228                                 echo "<br /><a href='index.php?action=plugindelete&amp;plugid=$current->pid' tabindex='".$template['tabindex']."'>",_LIST_PLUGS_UNINSTALL,"</a>";
229                                 if ($plug && ($plug->hasAdminArea() > 0))
230                                         echo "<br /><a href='".htmlspecialchars($plug->getAdminURL())."'  tabindex='".$template['tabindex']."'>",_LIST_PLUGS_ADMIN,"</a>";
231                                 if ($plug && ($plug->supportsFeature('HelpPage') > 0))
232                                         echo "<br /><a href='index.php?action=pluginhelp&amp;plugid=$current->pid'  tabindex='".$template['tabindex']."'>",_LIST_PLUGS_HELP,"</a>";
233                                 if (quickQuery('SELECT COUNT(*) AS result FROM '.sql_table('plugin_option_desc').' WHERE ocontext=\'global\' and opid='.$current->pid) > 0)
234                                         echo "<br /><a href='index.php?action=pluginoptions&amp;plugid=$current->pid'  tabindex='".$template['tabindex']."'>",_LIST_PLUGS_OPTIONS,"</a>";
235                         echo '</td>';
236                         break;
237         }
238 }
239
240 function listplug_table_plugoptionlist($template, $type) {
241         global $manager;
242         switch($type) {
243                 case 'HEAD':
244                         echo '<th>'._LISTS_INFO.'</th><th>'._LISTS_VALUE.'</th>';
245                         break;
246                 case 'BODY':
247                         $current = $template['current'];
248                         listplug_plugOptionRow($current);
249                         break;
250                 case 'FOOT':
251                         ?>
252                         <tr>
253                                 <th colspan="2"><?php echo _PLUGS_SAVE?></th>
254                         </tr><tr>
255                                 <td><?php echo _PLUGS_SAVE?></td>
256                                 <td><input type="submit" value="<?php echo _PLUGS_SAVE?>" /></td>
257                         </tr>
258                         <?php                   break;
259         }
260 }
261
262 function listplug_plugOptionRow($current) {
263         $varname = 'plugoption['.$current['oid'].']['.$current['contextid'].']';
264         // retreive the optionmeta
265         $meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
266
267         // only if it is not a hidden option write the controls to the page
268         if (!array_key_exists('access', $meta) || $meta['access'] != 'hidden') {
269                 echo '<td>',htmlspecialchars($current['description']?$current['description']:$current['name']),'</td>';
270                 echo '<td>';
271                 switch($current['type']) {
272                         case 'yesno':
273                                 ADMIN::input_yesno($varname, $current['value'], 0, 'yes', 'no');
274                                 break;
275                         case 'password':
276                                 echo '<input type="password" size="40" maxlength="128" name="',htmlspecialchars($varname),'" value="',htmlspecialchars($current['value']),'" />';
277                                 break;
278                         case 'select':
279                                 echo '<select name="'.htmlspecialchars($varname).'">';
280                                 $aOptions = NucleusPlugin::getOptionSelectValues($current['typeinfo']);
281                                 $aOptions = explode('|', $aOptions);
282                                 for ($i=0; $i<(count($aOptions)-1); $i+=2) {
283                                         echo '<option value="'.htmlspecialchars($aOptions[$i+1]).'"';
284                                         if ($aOptions[$i+1] == $current['value'])
285                                                 echo ' selected="selected"';
286                                         echo '>'.htmlspecialchars($aOptions[$i]).'</option>';
287                                 }
288                                 echo '</select>';
289                                 break;
290                         case 'textarea':
291                                 //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
292                                 echo '<textarea class="pluginoption" cols="30" rows="5" name="',htmlspecialchars($varname),'"';
293                                 if ($meta['access'] == 'readonly') {
294                                         echo ' readonly="readonly"';
295                                 }
296                                 echo '>',htmlspecialchars($current['value']),'</textarea>';
297                                 break;
298                         case 'text':
299                         default:
300                                 //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
301
302                                 echo '<input type="text" size="40" maxlength="128" name="',htmlspecialchars($varname),'" value="',htmlspecialchars($current['value']),'"';
303                                 if (array_key_exists('datatype', $meta) && $meta['datatype'] == 'numerical') {
304                                         echo ' onkeyup="checkNumeric(this)" onblur="checkNumeric(this)"';
305                                 }
306                                 if (array_key_exists('access', $meta) && $meta['access'] == 'readonly') {
307                                         echo ' readonly="readonly"';
308                                 }
309                                 echo ' />';
310                 }
311                 if (array_key_exists('extra', $current)) {
312                         echo $current['extra'];
313                 }
314                 echo '</td>';
315         }
316 }
317
318 function listplug_table_itemlist($template, $type) {
319         $cssclass = null;
320
321         switch($type) {
322                 case 'HEAD':
323                         echo "<th>"._LIST_ITEM_INFO."</th><th>"._LIST_ITEM_CONTENT."</th><th style=\"white-space:nowrap\" colspan='1'>"._LISTS_ACTIONS."</th>";
324                         break;
325                 case 'BODY':
326                         $current = $template['current'];
327                         $current->itime = strtotime($current->itime);   // string -> unix timestamp
328
329                         if ($current->idraft == 1)
330                                 $cssclass = "class='draft'";
331
332                         // (can't use offset time since offsets might vary between blogs)
333                         if ($current->itime > $template['now'])
334                                 $cssclass = "class='future'";
335                         
336                         $action = requestVar('action');
337                         
338                         echo '<td ' . $cssclass . ' style="white-space:nowrap;">';
339                         if ($action !== 'itemlist')
340                         echo _LIST_ITEM_BLOG . ' ', htmlspecialchars($current->bshortname) . '    <br />';
341                         echo _LIST_ITEM_CAT,' ', htmlspecialchars($current->cname) . '    <br />';
342                         if ($action !== 'browseownitems')
343                         echo _LIST_ITEM_AUTHOR, ' ', htmlspecialchars($current->mname) . '    <br />';
344                         echo date("Y-m-d",$current->itime) , " " . date("H:i",$current->itime);
345                         echo "</td>";
346                         echo "<td $cssclass>";
347
348                         $id = listplug_nextBatchId();
349
350                         echo '<input type="checkbox" id="batch',$id,'" name="batch[',$id,']" value="',$current->inumber,'" />';
351                         echo '<label for="batch',$id,'">';
352                         echo "<b>" . htmlspecialchars(strip_tags($current->ititle)) . "</b>";
353                         echo '</label>';
354                         echo "<br />";
355
356
357                         $current->ibody = strip_tags($current->ibody);
358                         $current->ibody = htmlspecialchars(shorten($current->ibody,200,'...'));
359
360                         $COMMENTS = new COMMENTS($current->inumber);
361                         echo "$current->ibody</td>";
362                         echo "<td  style=\"white-space:nowrap\" $cssclass>";
363                         echo "<a href='index.php?action=itemedit&amp;itemid={$current->inumber}'>" . _LISTS_EDIT . "</a>";
364                         echo " / <a href='index.php?action=itemmove&amp;itemid={$current->inumber}'>" . _LISTS_MOVE . "</a>";
365                         echo " / <a href='index.php?action=itemdelete&amp;itemid={$current->inumber}'>" . _LISTS_DELETE . "</a><br />";
366                         // evaluate amount of comments for the item
367                         $camount = $COMMENTS->amountComments();
368                         if ($camount>0) {
369                                 echo "<a href='index.php?action=itemcommentlist&amp;itemid=$current->inumber'>";
370                                 echo "( " . sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments())." )</a>";
371                         }
372                         else {
373                                 echo _LIST_ITEM_NOCONTENT;
374                         }
375                         echo "</td>";
376                         break;
377         }
378 }
379
380 // for batch operations: generates the index numbers for checkboxes
381 function listplug_nextBatchId() {
382         static $id = 0;
383         return $id++;
384 }
385
386 function listplug_table_commentlist($template, $type) {
387         switch($type) {
388                 case 'HEAD':
389                         echo "<th>"._LISTS_INFO."</th><th>"._LIST_COMMENT."</th><th colspan='3'>"._LISTS_ACTIONS."</th>";
390                         break;
391                 case 'BODY':
392                         $current = $template['current'];
393                         $current->ctime = strtotime($current->ctime);   // string -> unix timestamp
394
395                         echo '<td>';
396                         echo date("Y-m-d@H:i",$current->ctime);
397                         echo '<br />';
398                         if ($current->mname)
399                                 echo htmlspecialchars($current->mname) ,' ', _LIST_COMMENTS_MEMBER;
400                         else
401                                 echo htmlspecialchars($current->cuser);
402                         if ($current->cmail != '') {
403                                 echo '<br />';
404                                 echo htmlspecialchars($current->cmail);
405                         }
406                         if ($current->cemail != '') {
407                                 echo '<br />';
408                                 echo htmlspecialchars($current->cemail);
409                         }
410                         echo '</td>';
411
412                         $current->cbody = strip_tags($current->cbody);
413                         $current->cbody = htmlspecialchars(shorten($current->cbody, 300, '...'));
414
415                         echo '<td>';
416                         $id = listplug_nextBatchId();
417                         echo '<input type="checkbox" id="batch',$id,'" name="batch[',$id,']" value="',$current->cnumber,'" />';
418                         echo '<label for="batch',$id,'">';
419                         echo $current->cbody;
420                         echo '</label>';
421                         echo '</td>';
422
423                         echo "<td style=\"white-space:nowrap\"><a href='index.php?action=commentedit&amp;commentid=$current->cnumber'>"._LISTS_EDIT."</a></td>";
424                         echo "<td style=\"white-space:nowrap\"><a href='index.php?action=commentdelete&amp;commentid=$current->cnumber'>"._LISTS_DELETE."</a></td>";
425                         if ($template['canAddBan'])
426                                 echo "<td style=\"white-space:nowrap\"><a href='index.php?action=banlistnewfromitem&amp;itemid=$current->citem&amp;ip=", htmlspecialchars($current->cip), "' title='", htmlspecialchars($current->chost), "'>"._LIST_COMMENT_BANIP."</a></td>";
427                         break;
428         }
429 }
430
431
432 function listplug_table_bloglist($template, $type) {
433         switch($type) {
434                 case 'HEAD':
435                         echo "<th>" . _NAME . "</th><th colspan='7'>" ._LISTS_ACTIONS. "</th>";
436                         break;
437                 case 'BODY':
438                         $current = $template['current'];
439
440                         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> " . htmlspecialchars($current->bname) . "</td>";
441                         echo "<td><a href='index.php?action=createitem&amp;blogid=$current->bnumber' title='" . _BLOGLIST_TT_ADD ."'>" . _BLOGLIST_ADD . "</a></td>";
442                         echo "<td><a href='index.php?action=itemlist&amp;blogid=$current->bnumber' title='". _BLOGLIST_TT_EDIT."'>". _BLOGLIST_EDIT."</a></td>";
443                         echo "<td><a href='index.php?action=blogcommentlist&amp;blogid=$current->bnumber' title='". _BLOGLIST_TT_COMMENTS."'>". _BLOGLIST_COMMENTS."</a></td>";
444                         echo "<td><a href='index.php?action=bookmarklet&amp;blogid=$current->bnumber' title='". _BLOGLIST_TT_BMLET."'>". _BLOGLIST_BMLET . "</a></td>";
445
446                         if ($current->tadmin == 1) {
447                                 echo "<td><a href='index.php?action=blogsettings&amp;blogid=$current->bnumber' title='" . _BLOGLIST_TT_SETTINGS . "'>" ._BLOGLIST_SETTINGS. "</a></td>";
448                                 echo "<td><a href='index.php?action=banlist&amp;blogid=$current->bnumber' title='" . _BLOGLIST_TT_BANS. "'>". _BLOGLIST_BANS."</a></td>";
449                         }
450
451                         if ($template['superadmin']) {
452                                 echo "<td><a href='index.php?action=deleteblog&amp;blogid=$current->bnumber' title='". _BLOGLIST_TT_DELETE."'>" ._BLOGLIST_DELETE. "</a></td>";
453                         }
454
455
456
457                         break;
458         }
459 }
460
461 function listplug_table_shortblognames($template, $type) {
462         switch($type) {
463                 case 'HEAD':
464                         echo "<th>" . _EBLOG_SHORTNAME . "</th><th>" . _EBLOG_NAME. "</th>";
465                         break;
466                 case 'BODY':
467                         $current = $template['current'];
468
469                         echo '<td>' , htmlspecialchars($current->bshortname) , '</td>';
470                         echo '<td>' , htmlspecialchars($current->bname) , '</td>';
471
472                         break;
473         }
474 }
475
476 function listplug_table_shortnames($template, $type) {
477         switch($type) {
478                 case 'HEAD':
479                         echo "<th>" . _NAME . "</th><th>" . _LISTS_DESC. "</th>";
480                         break;
481                 case 'BODY':
482                         $current = $template['current'];
483
484                         echo '<td>' , htmlspecialchars($current->name) , '</td>';
485                         echo '<td>' , htmlspecialchars($current->description) , '</td>';
486
487                         break;
488         }
489 }
490
491
492 function listplug_table_categorylist($template, $type) {
493         switch($type) {
494                 case 'HEAD':
495                         echo "<th>"._LISTS_NAME."</th><th>"._LISTS_DESC."</th><th colspan='2'>"._LISTS_ACTIONS."</th>";
496                         break;
497                 case 'BODY':
498                         $current = $template['current'];
499
500                         echo '<td>';
501                         $id = listplug_nextBatchId();
502                         echo '<input type="checkbox" id="batch',$id,'" name="batch[',$id,']" value="',$current->catid,'" />';
503                         echo '<label for="batch',$id,'">';
504                         echo htmlspecialchars($current->cname);
505                         echo '</label>';
506                         echo '</td>';
507
508                         echo '<td>', htmlspecialchars($current->cdesc), '</td>';
509                         echo "<td><a href='index.php?action=categorydelete&amp;blogid=$current->cblog&amp;catid=$current->catid' tabindex='".$template['tabindex']."'>"._LISTS_DELETE."</a></td>";
510                         echo "<td><a href='index.php?action=categoryedit&amp;blogid=$current->cblog&amp;catid=$current->catid' tabindex='".$template['tabindex']."'>"._LISTS_EDIT."</a></td>";
511
512                         break;
513         }
514 }
515
516
517 function listplug_table_templatelist($template, $type) {
518         global $manager;
519         switch($type) {
520                 case 'HEAD':
521                         echo "<th>"._LISTS_NAME."</th><th>"._LISTS_DESC."</th><th colspan='3'>"._LISTS_ACTIONS."</th>";
522                         break;
523                 case 'BODY':
524                         $current = $template['current'];
525
526                         echo "<td>" , htmlspecialchars($current->tdname), "</td>";
527                         echo "<td>" , htmlspecialchars($current->tddesc), "</td>";
528                         echo "<td style=\"white-space:nowrap\"><a href='index.php?action=templateedit&amp;templateid=$current->tdnumber' tabindex='".$template['tabindex']."'>"._LISTS_EDIT."</a></td>";
529
530                         $url = $manager->addTicketToUrl('index.php?action=templateclone&templateid=' . intval($current->tdnumber));
531                         echo "<td style=\"white-space:nowrap\"><a href='",htmlspecialchars($url),"' tabindex='".$template['tabindex']."'>"._LISTS_CLONE."</a></td>";
532                         echo "<td style=\"white-space:nowrap\"><a href='index.php?action=templatedelete&amp;templateid=$current->tdnumber' tabindex='".$template['tabindex']."'>"._LISTS_DELETE."</a></td>";
533
534                         break;
535         }
536 }
537
538 function listplug_table_skinlist($template, $type) {
539         global $CONF, $DIR_SKINS, $manager;
540         switch($type) {
541                 case 'HEAD':
542                         echo "<th>"._LISTS_NAME."</th><th>"._LISTS_DESC."</th><th colspan='3'>"._LISTS_ACTIONS."</th>";
543                         break;
544                 case 'BODY':
545                         $current = $template['current'];
546
547                         echo '<td>';
548
549                         // use a special style for the default skin
550                         if ($current->sdnumber == $CONF['BaseSkin']) {
551                                 echo '<strong>',htmlspecialchars($current->sdname),'</strong>';
552                         } else {
553                                 echo htmlspecialchars($current->sdname);
554                         }
555
556                         echo '<br /><br />';
557                         echo _LISTS_TYPE ,': ' , htmlspecialchars($current->sdtype);
558                         echo '<br />', _LIST_SKINS_INCMODE , ' ' , (($current->sdincmode=='skindir') ?_PARSER_INCMODE_SKINDIR:_PARSER_INCMODE_NORMAL);
559                         if ($current->sdincpref) echo '<br />' , _LIST_SKINS_INCPREFIX , ' ', htmlspecialchars($current->sdincpref);
560
561                         // add preview image when present
562                         if ($current->sdincpref && @file_exists($DIR_SKINS . $current->sdincpref . 'preview.png'))
563                         {
564                                 echo '<br /><br />';
565
566                                 $hasEnlargement = @file_exists($DIR_SKINS . $current->sdincpref . 'preview-large.png');
567                                 if ($hasEnlargement)
568                                         echo '<a href="',$CONF['SkinsURL'], htmlspecialchars($current->sdincpref),'preview-large.png" title="' . _LIST_SKIN_PREVIEW_VIEWLARGER . '">';
569
570                                 $imgAlt = sprintf(_LIST_SKIN_PREVIEW, htmlspecialchars($current->sdname, ENT_QUOTES));
571                                 echo '<img class="skinpreview" src="',$CONF['SkinsURL'], htmlspecialchars($current->sdincpref),'preview.png" width="100" height="75" alt="' . $imgAlt . '" />';
572
573                                 if ($hasEnlargement)
574                                         echo '</a>';
575
576                                 if (@file_exists($DIR_SKINS . $current->sdincpref . 'readme.html'))
577                                 {
578                                         $url         = $CONF['SkinsURL'] . htmlspecialchars($current->sdincpref, ENT_QUOTES) . 'readme.html';
579                                         $readmeTitle = sprintf(_LIST_SKIN_README, htmlspecialchars($current->sdname, ENT_QUOTES));
580                                         echo '<br /><a href="' . $url . '" title="' . $readmeTitle . '">' . _LIST_SKIN_README_TXT . '</a>';
581                                 }
582
583
584                         }
585
586                         echo "</td>";
587
588
589                         echo '<td class="availableSkinTypes">' . htmlspecialchars($current->sddesc);
590                                 // show list of defined parts
591                                 $r = sql_query('SELECT stype FROM '.sql_table('skin').' WHERE sdesc='.$current->sdnumber\r
592                                         . ' ORDER BY '\r
593                                         ." stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') ASC , "\r
594                                         .' stype ASC' );
595                                 $types = array();
596                                 while ($o = sql_fetch_object($r))
597                                         array_push($types,$o->stype);
598                                 if (sizeof($types) > 0) {
599                                         $friendlyNames = SKIN::getFriendlyNames();
600                                         for ($i=0;$i<sizeof($types);$i++) {
601                                                 $type = $types[$i];
602                                                 if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
603                                                         $types[$i] = '<li>' . helpHtml('skinpart'.$type) . ' <a href="index.php?action=skinedittype&amp;skinid='.$current->sdnumber.'&amp;type='.$type.'" tabindex="'.$template['tabindex'].'">' . htmlspecialchars($friendlyNames[$type]) . "</a></li>";
604                                                 } else {
605                                                         $types[$i] = '<li>' . helpHtml('skinpartspecial') . ' <a href="index.php?action=skinedittype&amp;skinid='.$current->sdnumber.'&amp;type='.$type.'" tabindex="'.$template['tabindex'].'">' . htmlspecialchars($friendlyNames[$type]) . "</a></li>";
606                                                 }
607                                         }
608                                         echo '<br /><br />',_LIST_SKINS_DEFINED,' <ul>',implode($types,'') ,'</ul>';
609                                 }
610                         echo "</td>";
611                         echo "<td style=\"white-space:nowrap\"><a href='index.php?action=skinedit&amp;skinid=$current->sdnumber' tabindex='".$template['tabindex']."'>"._LISTS_EDIT."</a></td>";
612
613                         $url = $manager->addTicketToUrl('index.php?action=skinclone&skinid=' . intval($current->sdnumber));
614                         echo "<td style=\"white-space:nowrap\"><a href='",htmlspecialchars($url),"' tabindex='".$template['tabindex']."'>"._LISTS_CLONE."</a></td>";
615                         echo "<td style=\"white-space:nowrap\"><a href='index.php?action=skindelete&amp;skinid=$current->sdnumber' tabindex='".$template['tabindex']."'>"._LISTS_DELETE."</a></td>";
616
617                         break;
618         }
619 }
620
621 function listplug_table_draftlist($template, $type) {
622         switch($type) {
623                 case 'HEAD':
624                         echo "<th>"._LISTS_BLOG."</th><th>"._LISTS_TITLE."</th><th colspan='2'>"._LISTS_ACTIONS."</th>";
625                         break;
626                 case 'BODY':
627                         $current = $template['current'];
628
629                         echo '<td>', htmlspecialchars($current->bshortname) , '</td>';
630                         echo '<td>', htmlspecialchars(strip_tags($current->ititle)) , '</td>';
631                         echo "<td><a href='index.php?action=itemedit&amp;itemid=$current->inumber'>"._LISTS_EDIT."</a></td>";
632                         echo "<td><a href='index.php?action=itemdelete&amp;itemid=$current->inumber'>"._LISTS_DELETE."</a></td>";
633
634                         break;
635         }
636 }
637
638
639 function listplug_table_actionlist($template, $type) {
640         switch($type) {
641                 case 'HEAD':
642                         echo '<th>'._LISTS_TIME.'</th><th>'._LIST_ACTION_MSG.'</th>';
643                         break;
644                 case 'BODY':
645                         $current = $template['current'];
646
647                         echo '<td>' , htmlspecialchars($current->timestamp), '</td>';
648                         echo '<td>' , htmlspecialchars($current->message), '</td>';
649
650                         break;
651         }
652 }
653
654 function listplug_table_banlist($template, $type) {
655         switch($type) {
656                 case 'HEAD':
657                         echo '<th>'._LIST_BAN_IPRANGE.'</th><th>'. _LIST_BAN_REASON.'</th><th>'._LISTS_ACTIONS.'</th>';
658                         break;
659                 case 'BODY':
660                         $current = $template['current'];
661
662                         echo '<td>' , htmlspecialchars($current->iprange) , '</td>';
663                         echo '<td>' , htmlspecialchars($current->reason) , '</td>';
664                         echo "<td><a href='index.php?action=banlistdelete&amp;blogid=", intval($current->blogid) , "&amp;iprange=" , htmlspecialchars($current->iprange) , "'>",_LISTS_DELETE,"</a></td>";
665                         break;
666         }
667 }
668
669 ?>