OSDN Git Service

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