OSDN Git Service

FIX: ラベル「includeプリフィックス」が表示されないバグ(skinoverview/adminskinoverview)
[nucleus-jp/nucleus-next.git] / nucleus / libs / showlist.php
index 3943413..31e3665 100644 (file)
-<?php
-/*
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2009 The Nucleus Group
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * (see nucleus/documentation/index.html#license for more info)
- */
-/**
- * Functions to create lists of things inside the admin are
- *
- * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: showlist.php 1662 2012-02-12 12:18:37Z sakamocchi $
- */
-
-
-// can take either an array of objects, or an SQL query
-function showlist($query, $type, $template)
-{
-       if ( is_array($query) )
-       {
-               if ( sizeof($query) == 0 )
-               {
-                       return 0;
-               }
-               
-               call_user_func("listplug_{$type}", $template, 'HEAD');
-               
-               foreach ( $query as $currentObj )
-               {
-                       $template['current'] = $currentObj;
-                       call_user_func("listplug_{$type}", $template, 'BODY');
-               }
-               
-               call_user_func("listplug_{$type}", $template, 'FOOT');
-               
-               return sizeof($query);
-       }
-       else
-       {
-               $res = sql_query($query);
-               
-               // don't do anything if there are no results
-               $numrows = sql_num_rows($res);
-               if ( $numrows == 0 )
-               {
-                       return 0;
-               }
-               call_user_func("listplug_{$type}", $template, 'HEAD');
-               
-               while( $template['current'] = sql_fetch_object($res) )
-               {
-                       call_user_func("listplug_{$type}", $template, 'BODY');
-               }
-               
-               call_user_func("listplug_{$type}", $template, 'FOOT');
-               
-               sql_free_result($res);
-               
-               // return amount of results
-               return $numrows;
-       }
-}
-
-function listplug_select($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<select name="' . ifset($template['name']) . '" tabindex="' . ifset($template['tabindex']) . '" ' . ifset($template['javascript']) . ">\n";
-                       
-                       // add extra row if needed
-                       if ( ifset($template['extra']) )
-                       {
-                               echo '<option value="', ifset($template['extraval']), '">', $template['extra'], "</option>\n";
-                       }
-                       
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-
-                       echo '<option value="' . ENTITY::hsc($current->value) . '"';
-                       if ( $template['selected'] == $current->value )
-                       {
-                               echo ' selected="selected" ';
-                       }
-                       if ( isset($template['shorten']) && $template['shorten'] > 0 )
-                       {
-                               echo ' title="'. ENTITY::hsc($current->text).'"';
-                               $current->text = ENTITY::hsc(ENTITY::shorten($current->text, $template['shorten'], $template['shortenel']));
-                       }
-                       echo '>' . ENTITY::hsc($current->text) . "</option>\n";
-                       break;
-               case 'FOOT':
-                       echo '</select>';
-                       break;
-       }
-       return;
-}
-
-function listplug_table($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo "\n\n";
-                       echo "<table frame=\"box\" rules=\"all\" summary=\"{$template['content']}\">\n";
-                       echo "<thead>\n";
-                       echo "<tr>\n";
-                       // print head
-                       call_user_func("listplug_table_{$template['content']}" , $template, 'HEAD');
-                       echo "</tr>\n";
-                       echo "</thead>\n";
-                       echo "<tbody>\n";
-                       break;
-               case 'BODY':
-                       // print tabletype specific thingies
-                       echo "<tr>\n";
-                       call_user_func("listplug_table_{$template['content']}" , $template,  'BODY');
-                       echo "</tr>\n";
-                       break;
-               case 'FOOT':
-                       call_user_func("listplug_table_{$template['content']}" , $template,  'FOOT');
-                       echo "</tbody>\n";
-                       echo "</table>\n";
-                       echo "\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_memberlist($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LIST_MEMBER_NAME . "</th>\n";
-                       echo '<th>' . _LIST_MEMBER_RNAME . "</th>\n";
-                       echo '<th>' . _LIST_MEMBER_URL . "</th>\n";
-                       echo '<th>' . _LIST_MEMBER_ADMIN . "</th>\n";
-                       help('superadmin');
-                       echo "</th>\n";
-                       echo '<th>' . _LIST_MEMBER_LOGIN;
-                       help('canlogin');
-                       echo "</th>\n";
-                       echo '<th colspan="2">' . _LISTS_ACTIONS. "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       echo '<td>';
-                       $id = listplug_nextBatchId();
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->mnumber}\" />\n";
-                       echo "<label for=\"batch{$id}\">\n";
-                       echo '<a href="mailto:' . ENTITY::hsc($current->memail) . '" tabindex="' . $template['tabindex'] . '">' . ENTITY::hsc($current->mname), "</a>\n";
-                       echo "</label>\n";
-                       echo "</td>";
-                       echo "<td>" . ENTITY::hsc($current->mrealname) . "</td>\n";
-                       echo '<td><a href="' . ENTITY::hsc($current->murl) . '" tabindex="' . $template['tabindex'] . '">' . ENTITY::hsc($current->murl) . "</a></td>\n";
-                       echo '<td>' . ($current->madmin ? _YES : _NO) . "</td>\n";
-                       echo '<td>' . ($current->mcanlogin ? _YES : _NO) . "</td>\n";
-                       echo '<td><a href="index.php?action=memberedit&amp;memberid=$current->mnumber" tabindex="' . $template['tabindex'] . '">' . _LISTS_EDIT . "</a></td>\n";
-                       echo '<td><a href="index.php?action=memberdelete&amp;memberid=$current->mnumber" tabindex="' . $template['tabindex'].'">' . _LISTS_DELETE . "</a></td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_teamlist($template, $type)
-{
-       global $manager;
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo "<th>" . _LIST_MEMBER_NAME . "</th>\n";
-                       echo "<th>" . _LIST_MEMBER_RNAME . "</th>\n";
-                       echo "<th>" . _LIST_TEAM_ADMIN . "</th>\n";
-                       help('teamadmin');
-                       echo "</th>\n";
-                       echo "<th colspan=\"2\">"._LISTS_ACTIONS."</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       
-                       echo '<td>';
-                       $id = listplug_nextBatchId();
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->tmember}\" />\n";
-                       echo '<label for="batch',$id,'">';
-                       echo '<a href="mailto:' . ENTITY::hsc($current->memail) . '" tabindex="' . $template['tabindex'] . '">' . ENTITY::hsc($current->mname), "</a>\n";
-                       echo "</label>\n";
-                       echo "</td>";
-                       echo '<td>', ENTITY::hsc($current->mrealname), "</td>\n";
-                       echo '<td>', ($current->tadmin ? _YES : _NO) , "</td>\n";
-                       echo "<td><a href=\"index.php?action=teamdelete&amp;memberid=$current->tmember&amp;blogid={$current->tblog}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";
-                       
-                       $url = "index.php?action=teamchangeadmin&memberid={$current->tmember}&blogid={$current->tblog}";
-                       $url = $manager->addTicketToUrl($url);
-                       echo '<td><a href="' . ENTITY::hsc($url) . '" tabindex="' . $template['tabindex'] . '">' . _LIST_TEAM_CHADMIN . "</a></td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_pluginlist($template, $type)
-{
-       global $manager;
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_INFO . "</th>\n";
-                       echo '<th>' . _LISTS_DESC . "</th>\n";
-                       echo '<th>' . _LISTS_ACTIONS . "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       
-                       $plug =& $manager->getPlugin($current->pfile);
-                       if ( $plug )
-                       {
-                               echo "<td>\n";
-                               echo '<h3>' . ENTITY::hsc($plug->getName()) . "</h3>\n";
-                               
-                               echo "<dl>\n";
-                               if ( $plug->getAuthor() )
-                               {
-                                       echo '<dt>' . _LIST_PLUGS_AUTHOR . "</dt>\n";
-                                       echo '<dd>' . ENTITY::hsc($plug->getAuthor()) , "</dd>\n";
-                               }
-                               
-                               if ( $plug->getVersion() )
-                               {
-                                       echo '<dt>' . _LIST_PLUGS_VER, "</dt>\n";
-                                       echo '<dd>' . ENTITY::hsc($plug->getVersion()) . "</dd>\n";
-                               }
-                               
-                               if ( $plug->getURL() )
-                               {
-                                       echo '<dt>' . _LIST_PLUGS_SITE . "<dt>\n";
-                                       echo '<dd><a href="' .  ENTITY::hsc($plug->getURL()) . '" tabindex="' . $template['tabindex'] . '">リンク</a></dd>' . "\n";
-                               }
-                               echo "</dl>\n";
-                               echo "</td>\n";
-                               
-                               echo "<td>\n";
-                               echo "<dl>\n";
-                               echo '<dt>' . _LIST_PLUGS_DESC ."</dt>\n";
-                               echo '<dd>' . ENTITY::hen($plug->getDescription()) ."</dd>\n";
-                               if ( sizeof($plug->getEventList()) > 0 )
-                               {
-                                       echo '<dt>' . _LIST_PLUGS_SUBS ."</dt>\n";
-                                       echo '<dd>' . ENTITY::hsc(implode(', ', $plug->getEventList())) ."</dd>\n";
-                               }
-                               
-                               if ( sizeof($plug->getPluginDep()) > 0 )
-                               {
-                                       echo '<dt>' . _LIST_PLUGS_DEP ."</dt>\n";
-                                       echo '<dd>' . ENTITY::hsc(implode(', ', $plug->getPluginDep())) ."</dd>\n";
-                               }
-                               
-                               /* check dependency */
-                               $req = array();
-                               $res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));
-                               while( $o = sql_fetch_object($res) )
-                               {
-                                       $preq =& $manager->getPlugin($o->pfile);
-                                       if ( $preq )
-                                       {
-                                               $depList = $preq->getPluginDep();
-                                               foreach ( $depList as $depName )
-                                               {
-                                                       if ( $current->pfile == $depName )
-                                                       {
-                                                               $req[] = $o->pfile;
-                                                       }
-                                               }
-                                       }
-                               }
-                               
-                               if ( count($req) > 0 )
-                               {
-                                       echo '<dt>' . _LIST_PLUGS_DEPREQ . "</dt>\n";
-                                       echo '<dd>' . ENTITY::hsc(implode(', ', $req)) . "</dd>\n";
-                               }
-                               
-                               /* check the database to see if it is up-to-date and notice the user if not */
-                               if ( !$plug->subscribtionListIsUptodate() )
-                               {
-                                       echo '<dt>' . 'NOTICE:' . "</dt>\n";
-                                       echo '<dd>' . _LIST_PLUG_SUBS_NEEDUPDATE . "</dd>\n";
-                               }
-                               
-                               echo "</dl>\n";
-                               echo "</td>\n";
-                       }
-                       else
-                       {
-                               echo '<td colspan="2">' . sprintf(_PLUGINFILE_COULDNT_BELOADED, ENTITY::hsc($current->pfile)) . "</td>\n";
-                       }
-                       
-                       echo "<td>\n";
-                       echo "<ul>\n";
-                       $current->pid = (integer) $current->pid;
-                       
-                       $url = ENTITY::hsc($manager->addTicketToUrl("index.php?plugid={$current->pid}&action=pluginup"));
-                       echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" , _LIST_PLUGS_UP , "</a></li>\n";
-                       
-                       $url = ENTITY::hsc($manager->addTicketToUrl("index.php?plugid={$current->pid}&action=plugindown"));
-                       echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_DOWN , "</a></li>\n";
-                       echo "<li><a href=\"index.php?action=plugindelete&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_UNINSTALL , "</a></li>\n";
-                       
-                       if ( $plug && ($plug->hasAdminArea() > 0) )
-                       {
-                               echo '<li><a href="' , ENTITY::hsc($plug->getAdminURL()) , '" tabindex="' , $template['tabindex'] , '">' , _LIST_PLUGS_ADMIN , "</a></li>\n";
-                       }
-                       
-                       if ( $plug && ($plug->supportsFeature('HelpPage') > 0) )
-                       {
-                               echo "<li><a href=\"index.php?action=pluginhelp&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_HELP , "</a></li>\n";
-                       }
-                       
-                       $query = "SELECT COUNT(*) AS result FROM %s WHERE ocontext='global' and opid=%s;";
-                       $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $current->pid);
-                       if ( quickQuery($query) > 0 )
-                       {
-                               echo "<li><a href=\"index.php?action=pluginoptions&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_OPTIONS . "</a></li>\n";
-                       }
-                       echo "</ul>\n";
-                       echo "</td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_plugoptionlist($template, $type)
-{
-       global $manager;
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_INFO . "</th>\n";
-                       echo '<th>' . _LISTS_VALUE . "</th>\n";
-                       break;
-               case 'BODY':
-                       listplug_plugOptionRow($template['current']);
-                       break;
-               case 'FOOT':
-                       echo "<tr>\n";
-                       echo '<th colspan=\"2\">' . _PLUGS_SAVE . "</th>\n";
-                       echo "</tr>\n";
-                       echo "<tr>\n";
-                       echo "<td>" . _PLUGS_SAVE . "</td>\n";
-                       echo "<td><input type=\"submit\" value=\"".  _PLUGS_SAVE . "\" /></td>\n";
-                       echo "</tr>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_plugOptionRow($current)
-{
-       $varname = "plugoption[{$current['oid']}][{$current['contextid']}]";
-       
-       // retreive the optionmeta
-       $meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
-       
-       // only if it is not a hidden option write the controls to the page
-       if ( in_array('access', $meta) && $meta['access'] == 'hidden' )
-       {
-               return;
-       }
-       
-       if ( !$current['description'] )
-       {
-               echo '<td>' , ENTITY::hsc($current['name']) . "</td>\n";
-       }
-       else
-       {
-               if ( !defined($current['description']) )
-               {
-                       echo '<td>' , ENTITY::hsc($current['description']) . "</td>\n";
-               }
-               else
-               {
-                       echo '<td>' , ENTITY::hsc(constant($current['description'])) . "</td>\n";
-               }
-       }
-       echo "<td>\n";
-       switch($current['type'])
-       {
-               case 'yesno':
-                       ADMIN::input_yesno($varname, $current['value'], 0, 'yes', 'no');
-                       break;
-               case 'password':
-                       echo '<input type="password" size="40" maxlength="128" name="',ENTITY::hsc($varname),'" value="',ENTITY::hsc($current['value']),"\" />\n";
-                       break;
-               case 'select':
-                       echo '<select name="'.ENTITY::hsc($varname)."\">\n";
-                       $options = NucleusPlugin::getOptionSelectValues($current['typeinfo']);
-                       $options = i18n::explode('|', $options);
-                       
-                       for ( $i=0; $i<(count($options)-1); $i+=2 )
-                       {
-                               if ($options[$i+1] == $current['value'])
-                               {
-                                       echo '<option value="' . ENTITY::hsc($options[$i+1]) . '" selected="selected">';
-                               }
-                               else
-                               {
-                                       echo '<option value="' . ENTITY::hsc($options[$i+1]) . '">';
-                               }
-                               if ( defined($options[$i]) )
-                               {
-                                       echo ENTITY::hsc(constant($options[$i]));
-                               }
-                               else
-                               {
-                                       echo ENTITY::hsc($options[$i]);
-                               }
-                               echo "</option>\n";
-                       }
-                       echo "</select>\n";
-                       
-                       break;
-               case 'textarea':
-                       //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
-                       if ( array_key_exists('access', $meta) && $meta['access'] == 'readonly' )
-                       {
-                               echo '<textarea class="pluginoption" cols="30" rows="5" name="' . ENTITY::hsc($varname) . "\" readonly=\"readonly\">\n";
-                       }
-                       else
-                       {
-                               echo '<textarea class="pluginoption" cols="30" rows="5" name="' . ENTITY::hsc($varname) . "\">\n";
-                       }
-                       echo ENTITY::hsc($current['value']) . "\n";
-                       echo "</textarea>\n";
-                       break;
-               case 'text':
-               default:
-                       //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
-                       echo '<input type="text" size="40" maxlength="128" name="',ENTITY::hsc($varname),'" value="',ENTITY::hsc($current['value']),'"';
-                       if ( array_key_exists('datatype', $meta) && $meta['datatype'] == 'numerical' )
-                       {
-                               echo ' onkeyup="checkNumeric(this)" onblur="checkNumeric(this)"';
-                       }
-                       if ( array_key_exists('access', $current) && $meta['access'] == 'readonly')
-                       {
-                               echo ' readonly="readonly"';
-                       }
-                       echo " />\n";
-       }
-       if ( array_key_exists('extra', $current) )
-       {
-               echo $current['extra'];
-       }
-       echo "</td>\n";
-       
-       return;
-}
-
-function listplug_table_itemlist($template, $type)
-{
-       $cssclass = '';
-       
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo "<th>"._LIST_ITEM_INFO."</th>\n";
-                       echo "<th>"._LIST_ITEM_CONTENT."</th>\n";
-                       echo "<th colspan='1'>"._LISTS_ACTIONS."</th>";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       // string -> unix timestamp
-                       $current->itime = strtotime($current->itime);
-                       
-                       if ( $current->idraft == 1 )
-                       {
-                               $cssclass = " class='draft'";
-                       }
-                       
-                       // (can't use offset time since offsets might vary between blogs)
-                       if ( $current->itime > $template['now'] )
-                       {
-                               $cssclass = " class='future'";
-                       }
-                       
-                       echo "<td{$cssclass}>\n";
-                       echo "<dl>\n";
-                       echo '<dt>' . _LIST_ITEM_BLOG . "</dt>\n";
-                       echo '<dd>' . ENTITY::hsc($current->bshortname) . "</dd>\n";
-                       echo '<dt>' . _LIST_ITEM_CAT . "</dt>\n";
-                       echo '<dd>' . ENTITY::hsc($current->cname) . "</dd>\n";
-                       echo '<dt>' . _LIST_ITEM_AUTHOR . "</dt>\n";
-                       echo '<dd>' . ENTITY::hsc($current->mname) . "</dd>\n";
-                       echo '<dt>' . _LIST_ITEM_DATE . "</dt>\n";
-                       echo '<dd>' . date("Y-m-d",$current->itime) . "</dd>\n";
-                       echo '<dt>' . _LIST_ITEM_TIME . "</dt>\n";
-                       echo '<dd>' . date("H:i",$current->itime) . "</dd>\n";
-                       echo "</dl>\n";
-                       echo "</td>\n";
-                       
-                       $id = listplug_nextBatchId();
-                       
-                       echo "<td{$cssclass}>\n";
-                       echo "<h3>\n";
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->inumber}\" />\n";
-                       echo "<label for=\"batch{$id}\">" . ENTITY::hsc(strip_tags($current->ititle)) . "</label>\n";
-                       echo "</h3>\n";
-                       
-                       $current->ibody = strip_tags($current->ibody);
-                       $current->ibody = ENTITY::hsc(ENTITY::shorten($current->ibody, 300, '...'));
-                       echo "<p>$current->ibody</p>\n";
-                       echo "</td>\n";
-                       
-                       echo "<td{$cssclass}>\n";
-                       echo "<ul>\n";
-                       echo "<li><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></li>\n";
-                       
-                       // evaluate amount of comments for the item
-                       $COMMENTS = new COMMENTS($current->inumber);
-                       $camount = $COMMENTS->amountComments();
-                       if ( $camount > 0 )
-                       {
-                               echo "<li><a href=\"index.php?action=itemcommentlist&amp;itemid=$current->inumber\">( ";
-                               echo sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments()) . " )</a></li>\n";
-                       }
-                       else
-                       {
-                               echo '<li>' . _LIST_ITEM_NOCONTENT . "</li>\n";
-                       }
-                       
-                       echo "<li><a href=\"index.php?action=itemmove&amp;itemid={$current->inumber}\">" . _LISTS_MOVE . "</a></li>\n";
-                       echo "<li><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></li>\n";
-                       echo "</ul>\n";
-                       echo "</td>\n";
-                       break;
-       }
-       return;
-}
-
-// for batch operations: generates the index numbers for checkboxes
-function listplug_nextBatchId()
-{
-       static $id = 0;
-       return $id++;
-}
-
-function listplug_table_commentlist($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_INFO . "</th>\n";
-                       echo '<th>' . _LIST_COMMENT . "</th>\n";
-                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->ctime = strtotime($current->ctime);   // string -> unix timestamp
-                       
-                       echo "<td>\n";
-                       echo "<ul>\n";
-                       echo '<li>' . date("Y-m-d@H:i",$current->ctime) . "</li>\n";
-                       if ( isset($current->mname) )
-                       {
-                               echo '<li>' . ENTITY::hsc($current->mname) ,' ', _LIST_COMMENTS_MEMBER . "</li>\n";
-                       }
-                       else
-                       {
-                               echo '<li>' . ENTITY::hsc($current->cuser) . "</li>\n";
-                       }
-                       if ( isset($current->cmail) && $current->cmail )
-                       {
-                               echo '<li>' . ENTITY::hsc($current->cmail) . "</li>\n";
-                       }
-                       if ( isset($current->cemail) && $current->cemail )
-                       {
-                               echo '<li>' . ENTITY::hsc($current->cemail) . "</li>\n";
-                       }
-                       echo "</ul>\n";
-                       echo "</td>\n";
-
-                       $id = listplug_nextBatchId();
-                       
-                       echo '<td>';
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}\" value=\"{$current->cnumber}\" />\n";
-                       echo "<label for=\"batch{$id}\">\n";
-                       $current->cbody = strip_tags($current->cbody);
-                       $current->cbody = ENTITY::hsc(ENTITY::shorten($current->cbody, 300, '...'));
-                       echo $current->cbody;
-                       echo '</label>';
-                       echo '</td>';
-                       
-                       echo '<td><a href="index.php?action=commentedit&amp;commentid=' . $current->cnumber . '">' . _LISTS_EDIT . "</a></td>\n";
-                       echo '<td><a href="index.php?action=commentdelete&amp;commentid=' . $current->cnumber . '">' . _LISTS_DELETE . "</a></td>\n";
-                       if ( $template['canAddBan'] )
-                       {
-                               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";
-                       }
-                       break;
-       }
-       return;
-}
-
-function listplug_table_bloglist($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _NAME . "</th>\n";
-                       echo '<th colspan="7">' . _LISTS_ACTIONS . "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->bname = ENTITY::hsc($current->bname);
-                       
-                       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";
-                       echo "<td><a href=\"index.php?action=createitem&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_ADD ."\">" . _BLOGLIST_ADD . "</a></td>\n";
-                       echo "<td><a href=\"index.php?action=itemlist&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_EDIT."\">". _BLOGLIST_EDIT."</a></td>\n";
-                       echo "<td><a href=\"index.php?action=blogcommentlist&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_COMMENTS."\">". _BLOGLIST_COMMENTS."</a></td>\n";
-                       echo "<td><a href=\"index.php?action=bookmarklet&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_BMLET."\">". _BLOGLIST_BMLET . "</a></td>\n";
-                       
-                       if ( $current->tadmin == 1 )
-                       {
-                               echo "<td><a href=\"index.php?action=blogsettings&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_SETTINGS . "\">" . _BLOGLIST_SETTINGS . "</a></td>\n";
-                               echo "<td><a href=\"index.php?action=banlist&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_BANS . "\">" . _BLOGLIST_BANS . "</a></td>\n";
-                       }
-                       
-                       if ( $template['superadmin'] )
-                       {
-                               echo "<td><a href=\"index.php?action=deleteblog&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_DELETE."\">" ._BLOGLIST_DELETE. "</a></td>\n";
-                       }
-                       break;
-       }
-       return;
-}
-
-function listplug_table_shortblognames($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _EBLOG_SHORTNAME . "</th>\n";
-                       echo '<th>' . _EBLOG_NAME. "</th>";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->bshortname = ENTITY::hsc($current->bshortname);
-                       $current->bname = ENTITY::hsc($current->bname);
-                       
-                       echo "<td>{$current->bshortname}</td>\n";
-                       echo "<td>{$current->bname}</td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_shortnames($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _NAME . "</th>\n";
-                       echo '<th>' . _LISTS_DESC. "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->name = ENTITY::hsc($current->name);
-                       $current->description = ENTITY::hsc($current->description);
-                       
-                       echo "<td>{$current->name}</td>\n";
-                       echo "<td>{$current->description}</td>\n";
-                       break;
-       }
-       return;
-}
-
-
-function listplug_table_categorylist($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_NAME . "</th>";
-                       echo '<th>' . _LISTS_DESC."</th>\n";
-                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
-                       break;
-               case 'BODY':
-                       $id = listplug_nextBatchId();
-                       
-                       $current = $template['current'];
-                       $current->cname = ENTITY::hsc($current->cname);
-                       $current->cdesc = ENTITY::hsc($current->cdesc);
-                       
-                       echo "<td>\n";
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->catid}\" />\n";
-                       echo "<label for=\"batch{$id}\">{$current->cname}</label>\n";
-                       echo '</td>\n';
-                       echo "<td>{$current->cdesc}</td>\n";
-                       echo "<td><a href=\"index.php?action=categoryedit&amp;blogid=}$current->cblog}&amp;catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a></td>\n";
-                       echo "<td><a href=\"index.php?action=categorydelete&amp;blogid={$current->cblog}&amp;catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_templatelist($template, $type)
-{
-       global $manager;
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_NAME . "</th>\n";
-                       echo '<th>' . _LISTS_DESC . "</th>\n";
-                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->tdnumber = (integer) $current->tdnumber;
-                       $current->tdname = ENTITY::hsc($current->tdname);
-                       $current->tddesc = ENTITY::hsc($current->tddesc);
-                       
-                       $url = "index.php?action=templateclone&templateid={$current->tdnumber}";
-                       $url = ENTITY::hsc($manager->addTicketToUrl($url));
-                       
-                       echo "<td>{$current->tdname}</td>\n";
-                       echo "<td>{$current->tddesc}</td>\n";
-                       echo "<td>\n";
-                       echo "<a href=\"index.php?action=templateedit&amp;templateid={$current->tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a>\n";
-                       echo "</td>\n";
-                       echo "<td>\n";
-                       echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";
-                       echo "</td>\n";
-                       echo "<td>\n";
-                       echo "<a href=\"index.php?action=templatedelete&amp;templateid={$current->tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a>\n";
-                       echo "</td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_skinlist($template, $type)
-{
-       global $CONF, $DIR_SKINS, $manager;
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_NAME . "</th>\n";
-                       echo '<th>' . _LISTS_DESC . "</th>\n";
-                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->sdnumber = (integer) $current->sdnumber;
-                       $current->sdname = ENTITY::hsc($current->sdname);
-                       $current->sdtype = ENTITY::hsc($current->sdtype);
-                       
-                       echo "<td>\n";
-                       
-                       // use a special style for the default skin
-                       if ( $current->sdnumber == $CONF['BaseSkin'] )
-                       {
-                               echo '<h3 id="base_skin">' . $current->sdname . "</h3>\n";
-                       }
-                       else
-                       {
-                               echo '<h3>' . $current->sdname . "</h3>\n";
-                       }
-                       
-                       echo "<dl>\n";
-                       echo '<dt>' . _LISTS_TYPE . "</dt>\n";
-                       echo '<dd>' . $current->sdtype . "</dd>\n";
-                       
-                       echo '<dt>' . _LIST_SKINS_INCMODE . "</dt>\n";
-                       
-                       if ( $current->sdincmode == 'skindir' )
-                       {
-                               echo '<dd>' . _PARSER_INCMODE_SKINDIR . "</dd>\n";
-                       }
-                       else
-                       {
-                               echo '<dd>' . _PARSER_INCMODE_NORMAL . "</dd>\n";
-                       }
-                       
-                       if ( $current->sdincpref )
-                       {
-                               echo '<dt>' . _LIST_SKINS_INCPREFIX . "</dt>\n";
-                               echo '<dd>' . ENTITY::hsc($current->sdincpref) . "</dd>\n";
-                       }
-                       echo "</dl>\n";
-                       
-                       // add preview image when present
-                       if ( $current->sdincpref && @file_exists("{$DIR_SKINS}{$current->sdincpref}preview.png") )
-                       {
-                               echo "<p>\n";
-                               
-                               $alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current->sdname);
-                               $has_enlargement = @file_exists($DIR_SKINS . $current->sdincpref . 'preview-large.png');
-                               if ( $has_enlargement )
-                               {
-                                       echo '<a href="',$CONF['SkinsURL'], ENTITY::hsc($current->sdincpref),'preview-large.png" title="' . _LIST_SKIN_PREVIEW_VIEWLARGER . "\">\n";
-                                       echo '<img class="skinpreview" src="',$CONF['SkinsURL'], ENTITY::hsc($current->sdincpref),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" />\n";
-                                       echo "</a><br />\n";
-                               }
-                               else
-                               {
-                                       echo '<img class="skinpreview" src="',$CONF['SkinsURL'], ENTITY::hsc($current->sdincpref),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" /><br />\n";
-                               }
-                               
-                               if ( @file_exists("{$DIR_SKINS}{$current->sdincpref}readme.html") )
-                               {
-                                       $url = $CONF['SkinsURL'] . ENTITY::hsc($current->sdincpref) . 'readme.html';
-                                       $title = sprintf(_LIST_SKIN_README, $current->sdname);
-                                       echo "<a href=\"{$url}\" title=\"{$title}\">" . _LIST_SKIN_README_TXT . "</a>\n";
-                               }
-                               
-                               echo "</p>\n";
-                       }
-                       
-                       echo "</td>\n";
-                       
-                       echo "<td>\n";
-                       echo '<p>' . ENTITY::hsc($current->sddesc) . "</p>\n";
-                       
-                       /* show list of defined parts */
-                       $query = "SELECT stype FROM %s WHERE sdesc=%d ORDER BY stype";
-                       $query = sprintf($query, sql_table('skin'), $current->sdnumber);
-                       $r = sql_query($query);
-                       
-                       $types = array();
-                       while ( $o = sql_fetch_object($r) )
-                       {
-                               array_push($types, $o->stype);
-                       }
-                       if ( sizeof($types) > 0 )
-                       {
-                               $friendlyNames = SKIN::getFriendlyNames();
-                               for ( $i = 0; $i < sizeof($types); $i++ )
-                               {
-                                       $type = $types[$i];
-                                       if ( !in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup')) )
-                                       {
-                                               $article = 'skinpartspecial';
-                                       }
-                                       else
-                                       {
-                                               $article = "skinpart{$type}";
-                                       }
-                                       $types[$i]  = "<li>\n";
-                                       $types[$i] .= helpHtml($article) . "\n";
-                                       $types[$i] .= "<a href=\"index.php?action=skinedittype&amp;skinid={$current->sdnumber}&amp;type={$type}\" tabindex=\"{$template['tabindex']}\">" . ENTITY::hsc($friendlyNames[$type]) . "</a>\n";
-                                       $types[$i] .= "</li>\n";
-                               }
-                               echo _LIST_SKINS_DEFINED;
-                               echo '<ul>' . implode('', $types) . "</ul>\n";
-                       }
-                       echo "</td>";
-                       echo "<td>\n";
-                       echo "<a href=\nindex.php?action=skinedit&amp;skinid={$current->sdnumber}\n tabindex=\n{$template['tabindex']}>" . _LISTS_EDIT . "</a>\n";
-                       echo "</td>\n";
-                       
-                       $url = "index.php?action=skinclone&skinid={$current->sdnumber}";
-                       $url = ENTITY::hsc($manager->addTicketToUrl($url));
-                       echo "<td>\n";
-                       echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";
-                       echo "</td>\n";
-                       echo "<td>\n";
-                       echo "<a href=\"index.php?action=skindelete&amp;skinid={$current->sdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_draftlist($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_BLOG . "</th>\n";
-                       echo '<th>' . _LISTS_TITLE . "</th>\n";
-                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->bshortname = ENTITY::hsc($current->bshortname);
-                       $current->ititle = ENTITY::hsc(strip_tags($current->ititle));
-                       
-                       echo "<td>{$current->bshortname}</td>\n";
-                       echo "<td>{$current->ititle}</td>\n";
-                       echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></td>\n";
-                       echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_otherdraftlist($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_BLOG . "</th>\n";
-                       echo '<th>' . _LISTS_TITLE . "</th>\n";
-                       echo '<th>' . _LISTS_AUTHOR . "</th>\n";
-                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->bshortname = ENTITY::hsc($current->bshortname);
-                       $current->ititle = ENTITY::hsc(strip_tags($current->ititle));
-                       $current->mname = ENTITY::hsc($current->mname);
-                       
-                       echo "<td>{$current->bshortname}</td>\n";
-                       echo "<td>{$current->ititle}</td>\n";
-                       echo "<td>{$current->mname}</td>\n";
-                       echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></td>\n";
-                       echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_actionlist($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LISTS_TIME . "</th>\n";
-                       echo '<th>' . _LIST_ACTION_MSG . "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->timestamp = ENTITY::hsc($current->timestamp);
-                       $current->message = ENTITY::hsc($current->message);
-                       
-                       echo "<td>{$current->timestamp}</td>\n";
-                       echo "<td>{$current->message}</td>\n";
-                       break;
-       }
-       return;
-}
-
-function listplug_table_banlist($template, $type)
-{
-       switch( $type )
-       {
-               case 'HEAD':
-                       echo '<th>' . _LIST_BAN_IPRANGE . "</th>\n";
-                       echo '<th>' . _LIST_BAN_REASON."</th>\n";
-                       echo '<th>' . _LISTS_ACTIONS . "</th>\n";
-                       break;
-               case 'BODY':
-                       $current = $template['current'];
-                       $current->blogid = (integer) $current->blogid;
-                       $current->iprange = ENTITY::hsc($current->iprange);
-                       $current->reason = ENTITY::hsc($current->reason);
-                       
-                       echo "<td>{$current->iprange}</td>\n";
-                       echo "<td>{$current->reason}</td>\n";
-                       echo "<td><a href=\"index.php?action=banlistdelete&amp;blogid=\"{$current->blogid}&amp;iprange=\"ENTITY::hsc($current->iprange}\">" . _LISTS_DELETE . "</a></td>\n";
-                       break;
-       }
-       return;
-}
+<?php\r
+/*\r
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
+ * Copyright (C) 2002-2012 The Nucleus Group\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * (see nucleus/documentation/index.html#license for more info)\r
+ */\r
+/**\r
+ * Functions to create lists of things inside the admin are\r
+ *\r
+ * @license http://nucleuscms.org/license.txt GNU General Public License\r
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
+ * @version $Id: showlist.php 1662 2012-02-12 12:18:37Z sakamocchi $\r
+ */\r
+\r
+\r
+// can take either an array of objects, or an SQL query\r
+function showlist($query, $type, $vars, $template_name = '')\r
+{\r
+       $contents = '';\r
+       \r
+       /* count */\r
+       if ( is_string($query) )\r
+       {\r
+               $resource = DB::getResult($query);\r
+       }\r
+       else\r
+       {\r
+               $resource = $query;\r
+       }\r
+       \r
+       /* HEAD */\r
+       $contents .= call_user_func("listplug_{$type}", $vars, 'HEAD', $template_name);\r
+       \r
+       /* BODY */\r
+       foreach ( $resource as $row )\r
+       {\r
+               $vars['current'] = $row;\r
+               $contents .= call_user_func("listplug_{$type}", $vars, 'BODY', $template_name);\r
+       }\r
+       \r
+       /* FOOT */\r
+       $contents .= call_user_func("listplug_{$type}", $vars, 'FOOT', $template_name);\r
+       \r
+       /* close SQL resource */\r
+       if ( is_string($query) )\r
+       {\r
+               $resource->closeCursor();\r
+       }\r
+       \r
+       return $contents;\r
+}\r
+\r
+function listplug_select($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_SELECT_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_SELECT_HEAD']) )\r
+                       {\r
+                               $template = "<select name=\"<%name%>\" tabindex=\"<%tabindex%>\" <%javascript%>>\n"\r
+                                         . "<%extraoption%>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_SELECT_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'name'                  => $vars['name'],\r
+                               'tabindex'              => $vars['tabindex'],\r
+                               'javascript'    => !array_key_exists('javascript', $vars) ? '' : $vars['javascript'],\r
+                               'extraoption'   => !array_key_exists('extra', $vars) ? '' : "<option value=\"\">{$vars['extra']}</option>"\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_SELECT_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_SELECT_BODY']) )\r
+                       {\r
+                               $template = "<option value=\"<%value%>\" <%selected%> title=\"<%title%>\"><%option%></option>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_SELECT_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'value'         => Entity::hsc($current['value']),\r
+                               'selected'      => ($vars['selected'] == $current['value']) ? 'selected="selected"' : '',\r
+                       );\r
+                       if ( array_key_exists('shorten', $vars) && $vars['shorten'] > 0 )\r
+                       {\r
+                               $data['title'] = Entity::hsc($current['text']);\r
+                               $data['option'] = Entity::hsc(Entity::shorten($current['text'], $vars['shorten'], $vars['shortenel']));\r
+                       }\r
+                       else\r
+                       {\r
+                               $data['title'] = '';\r
+                       }\r
+                       $data['option'] = Entity::hsc($current['text']);\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_SELECT_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_SELECT_FOOT']) )\r
+                       {\r
+                               $template = "</select>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_SELECT_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       \r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_HEAD']) )\r
+                       {\r
+                               $template = "<table frame=\"box\" rules=\"all\" summary=\"{$vars['content']}\">\n"\r
+                                         . "<thead>\n"\r
+                                         . "<tr>\n"\r
+                                         . "<%typehead%>\n"\r
+                                         . "</tr>\n"\r
+                                         . "</thead>\n"\r
+                                         . "<tbody>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'summary'       =>      $vars['content'],\r
+                               'typehead' => call_user_func("listplug_table_" . $vars['content'] , $vars, 'HEAD', $template_name)\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BODY']) )\r
+                       {\r
+                               $template = "<tr onmouseover=\"focusRow(this);\" onmouseout=\"blurRow(this);\">\n"\r
+                                         . "<%typebody%>\n"\r
+                                         . "</tr>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_BODY'];\r
+                       }\r
+                       // tabletype specific thingies\r
+                       $data = array(\r
+                               'typebody' => call_user_func("listplug_table_" . $vars['content'] , $vars, 'BODY', $template_name)\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_FOOT']) )\r
+                       {\r
+                               $template = "<%typefoot%>\n"\r
+                                         . "</tbody>\n"\r
+                                         . "</table>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_FOOT'];\r
+                       }\r
+                       // tabletype specific thingies\r
+                       $data = array(\r
+                               'typefoot' => call_user_func("listplug_table_" . $vars['content'] , $vars, 'FOOT', $template_name)\r
+                       );\r
+                       break;\r
+       }\r
+       \r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_memberlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colmembername%></th>\n"\r
+                                         . "<th><%colmemberrname%></th>\n"\r
+                                         . "<th><%colmemberurl%></th>\n"\r
+                                         . "<th><%colmemberadmin%><%helplink(superadmin)%></th>\n"\r
+                                         . "<th><%colmemberlogin%><%helplink(canlogin)%></th>\n"\r
+                                         . "<th colspan=\"2\"><%colactions%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colmembername'         => _LIST_MEMBER_NAME,\r
+                               'colmemberrname'        => _LIST_MEMBER_RNAME,\r
+                               'colmemberurl'          => _LIST_MEMBER_URL,\r
+                               'colmemberadmin'        => _LIST_MEMBER_ADMIN,\r
+                               'colmemberlogin'        => _LIST_MEMBER_LOGIN,\r
+                               'colactions'            => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY']) )\r
+                       {\r
+                               $template = "<td>\n"\r
+                                         . "<input type=\"checkbox\" id=\"batch<%id%>\" name=\"batch[<%id%>]\" value=\"<%memberid%>\" />\n"\r
+                                         . "<label for=\"batch<%id%>\">\n"\r
+                                         . "<a href=\"mailto:<%mailaddress%>\" tabindex=\"<%tabindex%>\"><%name%></a>\n"\r
+                                         . "</label>\n</td>\n"\r
+                                         . "<td><%realname%></td>\n"\r
+                                         . "<td><a href=\"<%url%>\" tabindex=\"<%tabindex%>\"><%url%></a></td>\n"\r
+                                         . "<td><%admin%></td>\n"\r
+                                         . "<td><%login%></td>\n"\r
+                                         . "<td><a href=\"index.php?action=memberedit&amp;memberid=<%memberid%>\" tabindex=\"<%tabindex%>\"><%editbtn%></a></td>\n"\r
+                                         . "<td><a href=\"index.php?action=memberdelete&amp;memberid=<%memberid%>\" tabindex=\"<%tabindex%>\"><%deletebtn%></a></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'id'                    => listplug_nextBatchId(),\r
+                               'memberid'              => $current['mnumber'],\r
+                               'mailaddress'   => Entity::hsc($current['memail']),\r
+                               'tabindex'              => $vars['tabindex'],\r
+                               'name'                  => Entity::hsc($current['mname']),\r
+                               'realname'              => Entity::hsc($current['mrealname']),\r
+                               'url'                   => Entity::hsc($current['murl']),\r
+                               'admin'                 => $current['madmin'] ? _YES : _NO,\r
+                               'login'                 => $current['mcanlogin'] ? _YES : _NO,\r
+                               'editbtn'               => _LISTS_EDIT,\r
+                               'deletebtn'             => _LISTS_DELETE,\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT']) )\r
+                       {\r
+                               $template = "";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_teamlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colmembername%></th>\n"\r
+                                         . "<th><%colmemberrname%></th>\n"\r
+                                         . "<th><%colteamadmin%><%helplink(teamadmin)%></th>\n"\r
+                                         . "<th colspan=\"2\"><%colactions%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colmembername'         => _LIST_MEMBER_NAME,\r
+                               'colmemberrname'        => _LIST_MEMBER_RNAME,\r
+                               'colteamadmin'          => _LIST_TEAM_ADMIN,\r
+                               'colactions'            => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY']) )\r
+                       {\r
+                               $template = "<td>\n"\r
+                                         . "<input type=\"checkbox\" id=\"batch<%id%>\" name=\"batch[<%id%>]\" value=\"<%memberid%>\" />\n"\r
+                                         . "<label for=\"batch<%id%>\">\n"\r
+                                         . "<a href=\"mailto:<%mailaddress%>\" tabindex=\"<%tabindex%>\"><%name%></a>\n"\r
+                                         . "</label>\n</td>\n"\r
+                                         . "<td><%realname%></td>\n"\r
+                                         . "<td><%admin%></td>\n"\r
+                                         . "<td><a href=\"index.php?action=teamdelete&amp;memberid=<%memberid%>&amp;blogid=<%blogid%>\" tabindex=\"<%tabindex%>\"><%deletebtn%></a></td>\n"\r
+                                         . "<td><a href=\"<%chadminurl%>\" tabindex=\"<%tabindex%>\"><%chadminbtn%></a></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY'];\r
+                       }\r
+                       $url  = 'index.php?action=teamchangeadmin&memberid=' . intval($current['tmember']) . '&blogid=' . intval($current['tblog']);\r
+                       $url  = $manager->addTicketToUrl($url);\r
+                       $data = array(\r
+                                       'id'                    => listplug_nextBatchId(),\r
+                                       'memberid'              => $current['tmember'],\r
+                                       'mailaddress'   => Entity::hsc($current['memail']),\r
+                                       'tabindex'              => $vars['tabindex'],\r
+                                       'name'                  => Entity::hsc($current['mname']),\r
+                                       'realname'              => Entity::hsc($current['mrealname']),\r
+                                       'admin'                 => ($current['tadmin'] ? _YES : _NO),\r
+                                       'blogid'                => $current['tblog'],\r
+                                       'deletebtn'             => '<%text(_LISTS_DELETE)%>',\r
+                                       'chadminurl'    => Entity::hsc($url),\r
+                                       'chadminbtn'    => '<%text(_LIST_TEAM_CHADMIN)%>'\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT']) )\r
+                       {\r
+                               $template = "";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_pluginlist($vars, $type, $template_name = '')\r
+{\r
+       static $plugins = array();\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colinfo%></th>\n"\r
+                                         . "<th><%coldesc%></th>\n"\r
+                                         . "<th colspan=\"2\"><%colactions%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colinfo'    => _LISTS_INFO,\r
+                               'coldesc'    => _LISTS_DESC,\r
+                               'colactions' => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       \r
+                       $plug =& $manager->getPlugin($current['pfile']);\r
+                       if ( $plug )\r
+                       {\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY']) )\r
+                               {\r
+                                       $template = "<td>\n"\r
+                                                 . "<strong><%plugname%></strong><br />\n"\r
+                                                 . "<%autherlabel%> <%plugauther%><br />\n"\r
+                                                 . "<%versionlabel%> <%plugversion%><br />\n"\r
+                                                 . "<%pluggeturl%><br />\n"\r
+                                                 . "</td>\n"\r
+                                                 . "<td>\n"\r
+                                                 . "<%desclabel%><br /><%plugdesc%>\n"\r
+                                                 . "<%eventlist%>\n"\r
+                                                 . "<%needupdate%>\n"\r
+                                                 . "<%dependlist%>\n"\r
+                                                 . "<%depreqlist%>\n"\r
+                                                 . "</td>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY'];\r
+                               }\r
+                               $data = array(\r
+                                       'plugname'              => Entity::hsc($plug->getName()),\r
+                                       'autherlabel'   => _LIST_PLUGS_AUTHOR,\r
+                                       'plugauther'    => Entity::hsc($plug->getAuthor()),\r
+                                       'versionlabel'  => _LIST_PLUGS_VER,\r
+                                       'plugversion'   => Entity::hsc($plug->getVersion()),\r
+                                       'tabindex'              => $vars['tabindex'],\r
+                                       'desclabel'             => _LIST_PLUGS_DESC,\r
+                                       'plugdesc'              => Entity::hen($plug->getDescription()),\r
+                               );\r
+                               if ( $plug->getURL() )\r
+                               {\r
+                                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL']) )\r
+                                       {\r
+                                               $subTpl = "<a href=\"<%plugurl%>\" tabindex=\"<%tabindex%>\"><%plugsite%></a>";\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL'];\r
+                                       }\r
+                                       $subData = array(\r
+                                               'plugurl'       => Entity::hsc($plug->getURL()),\r
+                                               'tabindex'      => $vars['tabindex'],\r
+                                               'plugsite'      => _LIST_PLUGS_SITE,\r
+                                       );\r
+                                       $data['pluggeturl'] = Template::fill($subTpl, $subData);\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['pluggeturl'] = '';\r
+                               }\r
+                               if ( count($plug->getEventList()) > 0 )\r
+                               {\r
+                                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST']) )\r
+                                       {\r
+                                               $subTpl = "<br /><br /><%evntlstlbl%><br /><%eventlist%>";\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST'];\r
+                                       }\r
+                                       $subData = array(\r
+                                               'evntlstlbl'    => _LIST_PLUGS_SUBS,\r
+                                               'eventlist'             => Entity::hsc(implode(', ', $plug->getEventList())),\r
+                                       );\r
+                                       $data['eventlist'] = Template::fill($subTpl, $subData);\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['eventlist'] = '';\r
+                               }\r
+                               if ( !$plug->subscribtionListIsUptodate() )\r
+                               {\r
+                                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE']) )\r
+                                       {\r
+                                               $subTpl = "<br /><br /><strong><%updatealert%></strong>";\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE'];\r
+                                       }\r
+                                       $subData = array(\r
+                                               'updatealert' => _LIST_PLUG_SUBS_NEEDUPDATE,\r
+                                       );\r
+                                       $data['needupdate'] = Template::fill($subTpl, $subData);\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['needupdate'] = '';\r
+                               }\r
+                               if ( count($plug->getPluginDep() ) > 0)\r
+                               {\r
+                                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND']) )\r
+                                       {\r
+                                               $subTpl = "<br /><br /><%deplistlbl%><br /><%dependlist%>";\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND'];\r
+                                       }\r
+                                       $subData = array(\r
+                                               'deplistlbl' => _LIST_PLUGS_DEP,\r
+                                               'dependlist' => Entity::hsc(implode(', ', $plug->getPluginDep())),\r
+                                       );\r
+                                       $data['dependlist'] = Template::fill($subTpl, $subData);\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['dependlist'] = '';\r
+                               }\r
+                               /* check dependency */\r
+                               if ( empty($plugins) )\r
+                               {\r
+                                       $plugins = DB::getResult('SELECT pfile FROM ' . sql_table('plugin'));\r
+                               }\r
+                               $req = array();\r
+                               foreach ( $plugins as $plugin )\r
+                               {\r
+                                       $preq =& $manager->getPlugin($plugin['pfile']);\r
+                                       if ( $preq )\r
+                                       {\r
+                                               $depList = $preq->getPluginDep();\r
+                                               foreach ( $depList as $depName )\r
+                                               {\r
+                                                       if ( $current['pfile'] == $depName )\r
+                                                       {\r
+                                                               $req[] = $plugin['pfile'];\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                               \r
+                               if ( count($req) > 0 )\r
+                               {\r
+                                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ']) )\r
+                                       {\r
+                                               $subTpl = "<br /><br /><%deprlstlbl%><br /><%depreqlist%>";\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ'];\r
+                                       }\r
+                                       $subData = array(\r
+                                               'deprlstlbl' => _LIST_PLUGS_DEPREQ,\r
+                                               'depreqlist' => Entity::hsc(implode(', ', $req)),\r
+                                       );\r
+                                       $data['depreqlist'] = Template::fill($subTpl, $subData);\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['depreqlist'] = '';\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE']) )\r
+                               {\r
+                                       $template = "<td colspan=\"2\"><%noplugalert%></td>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE'];\r
+                               }\r
+                               $data = array(\r
+                                       'noplugalert' => sprintf(_PLUGINFILE_COULDNT_BELOADED, Entity::hsc($current['pfile'])),\r
+                               );\r
+                       }\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN']) )\r
+                       {\r
+                               $template .= "<td>\n"\r
+                                          . "<a href=\"<%actionupurl%>\" tabindex=\"<%tabindex%>\"><%actionuptxt%></a><br />\n"\r
+                                          . "<a href=\"<%actiondownurl%>\" tabindex=\"<%tabindex%>\"><%actiondowntxt%></a><br />\n"\r
+                                          . "<a href=\"<%actuninsturl%>\" tabindex=\"<%tabindex%>\"><%actuninsttxt%></a><br />"\r
+                                          . "<%plugadminurl%>\n"\r
+                                          . "<%plughelpurl%>\n"\r
+                                          . "<%plugoptsetting%>\n"\r
+                                          . "</td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN'];\r
+                       }\r
+                       \r
+                       $baseUrl        = 'index.php?plugid=' . $current['pid'] . '&action=';\r
+                       $upUrl          = $manager->addTicketToUrl($baseUrl . 'pluginup');\r
+                       $downUrl        = $manager->addTicketToUrl($baseUrl . 'plugindown');\r
+                       \r
+                       $data['actionuptxt']    = _LIST_PLUGS_UP;\r
+                       $data['actionupurl']    = Entity::hsc($upUrl);\r
+                       $data['actiondowntxt']  = _LIST_PLUGS_DOWN;\r
+                       $data['actiondownurl']  = Entity::hsc($downUrl);\r
+                       $data['actuninsttxt']   = _LIST_PLUGS_UNINSTALL;\r
+                       $data['actuninsturl']   = 'index.php?action=plugindelete&amp;plugid=' . $current['pid'];\r
+                       \r
+                       if ( $plug && ($plug->hasAdminArea() > 0) )\r
+                       {\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN']) )\r
+                               {\r
+                                       $subTpl = "<a href=\"<%actadminurl%>\" tabindex=\"<%tabindex%>\"><%actadmintxt%></a><br />\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN'];\r
+                               }\r
+                               $subData = array(\r
+                                       'actadminurl'   => Entity::hsc($plug->getAdminURL()),\r
+                                       'tabindex'              => $vars['tabindex'],\r
+                                       'actadmintxt'   => _LIST_PLUGS_ADMIN,\r
+                               );\r
+                               $data['plugadminurl'] = Template::fill($subTpl, $subData);\r
+                       }\r
+                       else\r
+                       {\r
+                               $data['plugadminurl'] = '';\r
+                       }\r
+                       if ( $plug && ($plug->supportsFeature('HelpPage') > 0) )\r
+                       {\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP']) )\r
+                               {\r
+                                       $subTpl = "<a href=\"<%acthelpurl%>\" tabindex=\"<%tabindex%>\"><%acthelptxt%></a><br />\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP'];\r
+                               }\r
+                               $subData = array(\r
+                                       'acthelpurl'    => 'index.php?action=pluginhelp&amp;plugid=' . $current['pid'],\r
+                                       'tabindex'              => $vars['tabindex'],\r
+                                       'acthelptxt'    => _LIST_PLUGS_HELP,\r
+                               );\r
+                               $data['plughelpurl'] = Template::fill($subTpl, $subData);\r
+                       }\r
+                       else\r
+                       {\r
+                               $data['plughelpurl'] = '';\r
+                       }\r
+                       $optQuery = 'SELECT '\r
+                                 . '    COUNT(*) AS result '\r
+                                 . 'FROM '\r
+                                 .      sql_table('plugin_option_desc') . ' '\r
+                                 . 'WHERE '\r
+                                 . '    ocontext = "global" '\r
+                                 . 'AND opid     = %d';\r
+                       $pOptions = DB::getValue(sprintf($optQuery, $current['pid']));\r
+                       if ( $pOptions > 0 )\r
+                       {\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL']) )\r
+                               {\r
+                                       $subTpl = "<a href=\"<%actoptionurl%>\" tabindex=\"<%tabindex%>\"><%actoptiontxt%></a>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL'];\r
+                               }\r
+                               $subData = array(\r
+                                       'actoptionurl'  => 'index.php?action=pluginoptions&amp;plugid=' . $current['pid'],\r
+                                       'tabindex'              => $vars['tabindex'],\r
+                                       'actoptiontxt'  => _LIST_PLUGS_OPTIONS,\r
+                               );\r
+                               $data['plugoptsetting'] = Template::fill($subTpl, $subData);\r
+                       }\r
+                       else\r
+                       {\r
+                               $data['plugoptsetting'] = '';\r
+                       }\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT']) )\r
+                       {\r
+                               $template = "";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_plugoptionlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colinfo%></th>\n"\r
+                                         . "<th><%colvalue%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colinfo'       => _LISTS_INFO,\r
+                               'colvalue'      => _LISTS_VALUE,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       $template = listplug_plugOptionRow($current, $template_name);\r
+                       $data = array();\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT']) )\r
+                       {\r
+                               $template = "<tr>\n"\r
+                                         . "<th colspan=\"2\"><%savetext%></th>\n"\r
+                                         . "</tr>\n"\r
+                                         . "<tr>\n"\r
+                                         . "<td><%savetext%></td>\n"\r
+                                         . "<td><input type=\"submit\" value=\"<%savetext%>\" /></td>\n"\r
+                                         . "</tr>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT'];\r
+                       }\r
+                       $data = array(\r
+                               'savetext' => _PLUGS_SAVE,\r
+                       );\r
+                       break;\r
+       }\r
+       \r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_plugOptionRow($current, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       $varname = "plugoption[{$current['oid']}][{$current['contextid']}]";\r
+       \r
+       // retreive the optionmeta\r
+       $meta = NucleusPlugin::getOptionMeta($current['typeinfo']);\r
+       \r
+       // only if it is not a hidden option write the controls to the page\r
+       if ( in_array('access', $meta) && $meta['access'] == 'hidden' )\r
+       {\r
+               return false;\r
+       }\r
+       else\r
+       {\r
+               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY']) )\r
+               {\r
+                       $template = "<td><%description%></td>\n"\r
+                                 . "<td>\n";\r
+               }\r
+               else\r
+               {\r
+                       $template = $templates['SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY'];\r
+               }\r
+               \r
+               $data = array();\r
+               \r
+               switch($current['type'])\r
+               {\r
+                       case 'yesno':\r
+                               $template .= listplug_input_yesno($varname, $current['value'], 0, 'yes', 'no', _YES, _NO, 0, $template_name, 1);\r
+                               break;\r
+                       case 'password':\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD']) )\r
+                               {\r
+                                       $template .= "<input type=\"password\" size=\"40\" maxlength=\"128\" name=\"<%varname%>\" value=\"<%value%>\" />\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD'];\r
+                               }\r
+                               $data = array(\r
+                                       'varname'       => Entity::hsc($varname),\r
+                                       'value'         => Entity::hsc($current['value']),\r
+                               );\r
+                               break;\r
+                       case 'select':\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP']) )\r
+                               {\r
+                                       $template .= "<select name=\"<%varname%>\">\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP'];\r
+                               }\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO']) )\r
+                               {\r
+                                       $subTpl = "<option value=\"<%value%>\"<%selected%>><%optname%></option>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO'];\r
+                               }\r
+                               $options = NucleusPlugin::getOptionSelectValues($current['typeinfo']);\r
+                               $options = preg_split('#\|#', $options);\r
+                               \r
+                               for ( $i=0; $i<(count($options)-1); $i+=2 )\r
+                               {\r
+                                       $name   = $options[$i];\r
+                                       $value  = $options[$i+1];\r
+                                       if ( defined($name) )\r
+                                       {\r
+                                               $name = constant($name);\r
+                                       }\r
+                                       \r
+                                       $subData = array(\r
+                                               'optname'       => Entity::hsc($name),\r
+                                               'value'         => Entity::hsc($value)\r
+                                       );\r
+                                       if ($value != $current['value'])\r
+                                       {\r
+                                               $subData['selected'] = '';\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               $subData['selected'] = ' selected="selected"';\r
+                                       }\r
+                                       $template .= Template::fill($subTpl, $subData);\r
+                               }\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC']) )\r
+                               {\r
+                                       $template .= "</select>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC'];\r
+                               }\r
+                               $data['varname'] = Entity::hsc($varname);\r
+                               break;\r
+                       case 'textarea':\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA']) )\r
+                               {\r
+                                       $template .= "<textarea class=\"pluginoption\" cols=\"30\" rows=\"5\" name=\"<%varname%>\"<%readonly%>><%value%></textarea>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA'];\r
+                               }\r
+                               $data = array(\r
+                                       'varname'       => Entity::hsc($varname),\r
+                                       'value'         => Entity::hsc($current['value'])\r
+                               );\r
+                               if ( !array_key_exists('access', $current) || $current['access'] != 'readonly')\r
+                               {\r
+                                       $data['readonly'] = '';\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['readonly'] = ' readonly="readonly"';\r
+                               }\r
+                               break;\r
+                       case 'text':\r
+                       default:\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT']) )\r
+                               {\r
+                                       $template .= "<input type=\"text\" size=\"40\" maxlength=\"128\" name=\"<%varname%>\" value=\"<%value%>\"<%datatype%><%readonly%> />\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT'];\r
+                               }\r
+                               $data = array(\r
+                                       'varname'       => Entity::hsc($varname),\r
+                                       'value'         => Entity::hsc($current['value'])\r
+                               );\r
+                               if ( !array_key_exists('datatype', $current) || $current['datatype'] != 'numerical')\r
+                               {\r
+                                       $data['datatype'] = '';\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['datatype'] = ' onkeyup="checkNumeric(this)" onblur="checkNumeric(this)"';\r
+                               }\r
+                               if ( !array_key_exists('access', $current) || $current['access'] != 'readonly')\r
+                               {\r
+                                       $data['readonly'] = '';\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['readonly'] = ' readonly="readonly"';\r
+                               }\r
+               }\r
+               \r
+               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT']) )\r
+               {\r
+                       $template .= "<%extra%></td>\n";\r
+               }\r
+               else\r
+               {\r
+                       $template .= $templates['SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT'];\r
+               }\r
+               \r
+               if ( !array_key_exists('extra', $current) )\r
+               {\r
+                       $data['extra'] = '';\r
+               }\r
+               else\r
+               {\r
+                       $data['extra'] = Entity::hsc($current['extra']);\r
+               }\r
+               \r
+               if ( !array_key_exists('description', $current) )\r
+               {\r
+                       $data['description'] = Entity::hsc($current['name']);\r
+               }\r
+               else if ( !defined($current['description']) )\r
+               {\r
+                       $data['description'] = Entity::hsc($current['description']);\r
+               }\r
+               else\r
+               {\r
+                       $data['description'] = Entity::hsc(constant($current['description']));\r
+               }\r
+       }\r
+       return Template::fill($template, $data, 1);\r
+}\r
+\r
+/**\r
+ * listplug_templateEditRow()\r
+ * \r
+ * @param      array   $content                content of target template\r
+ * @param      string  $desc                   description of target template\r
+ * @param      string  $name                   name of target template\r
+ * @param      string  $help                   help text\r
+ * @param      integer $tabindex               a number for tab index\r
+ * @param      boolean $big                    large or small textarea\r
+ * @param      array   $template_name  name of template for filling\r
+ * @return     void\r
+ */\r
+function listplug_templateEditRow($content, $desc, $name, $help = '', $tabindex = 0, $big = 0, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       static $count = 0;\r
+       \r
+       $tmplt = array();\r
+       $base  = array();\r
+       \r
+       $templates = array();\r
+       if ( $template_name )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       $data = array(\r
+               'description'   => $desc,\r
+               'help'                  => empty($help) ? '' : helpHtml('template' . $help),\r
+               'count'                 => $count++,\r
+               'name'                  => $name,\r
+               'tabindex'              => $tabindex,\r
+               'rows'                  => $big ? 10 : 5,\r
+       );\r
+       \r
+       $message = '';\r
+       \r
+       /* row head */\r
+       if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $templates) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )\r
+       {\r
+               $template = "</tr>"\r
+                         . "<tr>\n"\r
+                         . "<td><%description%><%help%></td>\n"\r
+                         . "<td id=\"td<%count%>\">\n"\r
+                         . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">";\r
+       }\r
+       else\r
+       {\r
+               $template = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];\r
+       }\r
+       $message .= TEMPLATE::fill($template, $data);\r
+       \r
+       /* row content */\r
+       $message .= ENTITY::hsc($content);\r
+       \r
+       /* row tail */\r
+       if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $templates) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )\r
+       {\r
+               $template = "</textarea>\n"\r
+                         . "</td>\n";\r
+       }\r
+       else\r
+       {\r
+               $template = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];\r
+       }\r
+       $message .= TEMPLATE::fill($template, $data);\r
+       \r
+       return $message;\r
+}\r
+\r
+function listplug_table_itemlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $cssclass  = '';\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colinfo%></th>\n"\r
+                                         . "<th><%colcontent%></th>\n"\r
+                                         . "<th style=\"white-space:nowrap\"><%colaction%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colinfo'               => _LIST_ITEM_INFO,\r
+                               'colcontent'    => _LIST_ITEM_CONTENT,\r
+                               'colaction'             => _LISTS_ACTIONS\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       // string -> unix timestamp\r
+                       $current['itime'] = strtotime($current['itime']);\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY']) )\r
+                       {\r
+                               $template = "<td<%cssclass%>>\n"\r
+                                         . "<%bshortlabel%> <%bshortnameval%><br />\n"\r
+                                         . "<%categorylabel%> <%categorynameval%><br />\n"\r
+                                         . "<%authorlabel%> <%authornameval%><br />\n"\r
+                                         . "<%itemdatelabel%> <%itemdateval%><br />\n"\r
+                                         . "<%itemtimelabel%> <%itemtimeval%>\n"\r
+                                         . "</td>\n"\r
+                                         . "<td<%cssclass%>>\n"\r
+                                         . "<input type=\"checkbox\" id=\"batch<%batchid%>\" name=\"batch[<%batchid%>]\" value=\"<%itemid%>\" />\n"\r
+                                         . "<label for=\"batch<%batchid%>\"><b><%itemtitle%></b></label><br />\n"\r
+                                         . "<%itembody%>\n"\r
+                                         . "</td>\n"\r
+                                         . "<td<%cssclass%>>\n"\r
+                                         . "<a href=\"index.php?action=itemedit&amp;itemid=<%itemid%>\"><%editbtn%></a><br />\n"\r
+                                         . "<a href=\"index.php?action=itemmove&amp;itemid=<%itemid%>\"><%movebtn%></a><br />\n"\r
+                                         . "<a href=\"index.php?action=itemdelete&amp;itemid=<%itemid%>\"><%delbtn%></a><br />\n"\r
+                                         . "<%camount%>\n"\r
+                                         . "</td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY'];\r
+                       }\r
+                       $cssclass  = '';\r
+                       \r
+                       if ( $current['idraft'] == 1 )\r
+                       {\r
+                               $cssclass = ' class="draft"';\r
+                       }\r
+                       \r
+                       // (can't use offset time since offsets might vary between blogs)\r
+                       if ( $current['itime'] > $vars['now'] )\r
+                       {\r
+                               $cssclass = ' class="future"';\r
+                       }\r
+                       $body = strip_tags($current['ibody']);\r
+                       $data = array(\r
+                               'cssclass'                      => $cssclass,\r
+                               'bshortlabel'           => _LIST_ITEM_BLOG,\r
+                               'bshortnameval'         => Entity::hsc($current['bshortname']),\r
+                               'categorylabel'         => _LIST_ITEM_CAT,\r
+                               'categorynameval'       => Entity::hsc($current['cname']),\r
+                               'authorlabel'           => _LIST_ITEM_AUTHOR,\r
+                               'authornameval'         => Entity::hsc($current['mname']),\r
+                               'itemdatelabel'         => _LIST_ITEM_DATE,\r
+                               'itemdateval'           => date("Y-m-d",$current['itime']),\r
+                               'itemdatelabel'         => _LIST_ITEM_TIME,\r
+                               'itemdateval'           => date("H:i",$current['itime']),\r
+                               'batchid'                       => listplug_nextBatchId(),\r
+                               'itemid'                        => $current['inumber'],\r
+                               'itemtitle'                     => Entity::hsc(strip_tags($current['ititle'])),\r
+                               'itembody'                      => Entity::hsc(Entity::shorten($body, 300, '...')),\r
+                               'editbtn'                       => _LISTS_EDIT,\r
+                               'movebtn'                       => _LISTS_MOVE,\r
+                               'delbtn'                        => _LISTS_DELETE,\r
+                       );\r
+                       // evaluate amount of comments for the item\r
+                       $comment = new Comments($current['inumber']);\r
+                       $camount = $comment->amountComments();\r
+                       if ( $camount > 0 )\r
+                       {\r
+                               $data['camount'] = "<a href=\"index.php?action=itemcommentlist&amp;itemid={$current['inumber']}\">(" . sprintf(_LIST_ITEM_COMMENTS, $comment->amountComments()) . ")</a><br />\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $data['camount'] = _LIST_ITEM_NOCONTENT . "<br />\n";\r
+                       }\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+// for batch operations: generates the index numbers for checkboxes\r
+function listplug_nextBatchId()\r
+{\r
+       static $id = 0;\r
+       return $id++;\r
+}\r
+\r
+function listplug_table_commentlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colinfo%></th>\n"\r
+                                         . "<th><%colcontent%></th>\n"\r
+                                         . "<th colspan=\"3\"><%colaction%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colinfo'               => _LISTS_INFO,\r
+                               'colcontent'    => _LIST_COMMENT,\r
+                               'colaction'             => _LISTS_ACTIONS\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY']) )\r
+                       {\r
+                               $template = "<td><%commentdate%><br /><%commentator%><br /><%commentsite%><br /><%commentmail%><br /></td>\n"\r
+                                         . "<td>\n"\r
+                                         . "<input type=\"checkbox\" id=\"batch<%batchid%>\" name=\"batch[<%batchid%>]\" value=\"<%commentid%>\" />"\r
+                                         . "<label for=\"batch<%batchid%>\"><%commentbody%></label>\n"\r
+                                         . "</td>\n"\r
+                                         . "<td style=\"white-space:nowrap\">\n"\r
+                                         . "<a href=\"index.php?action=commentedit&amp;commentid=<%commentid%>\"><%editbtn%></a>\n"\r
+                                         . "</td>\n"\r
+                                         . "<td style=\"white-space:nowrap\">\n"\r
+                                         . "<a href=\"index.php?action=commentdelete&amp;commentid=<%commentid%>\"><%delbtn%></a>\n"\r
+                                         . "</td>\n"\r
+                                         . "<%addbanlist%>";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY'];\r
+                       }\r
+                       $current = $vars['current'];\r
+                       $body = strip_tags($current['cbody']);\r
+                       $data = array(\r
+                               'commentdate'   => date("Y-m-d@H:i", strtotime($current['ctime'])),\r
+                               'batchid'               => listplug_nextBatchId(),\r
+                               'commentid'             => $current['cnumber'],\r
+                               'commentbody'   => Entity::hsc(Entity::shorten($current['cbody'], 300, '...')),\r
+                               'editbtn'               => _LISTS_EDIT,\r
+                               'delbtn'                => _LISTS_DELETE,\r
+                       );\r
+                       if ( isset($current['mname']) )\r
+                       {\r
+                               $data['commentator'] = Entity::hsc($current['mname']) . ' ' . _LIST_COMMENTS_MEMBER;\r
+                       }\r
+                       else\r
+                       {\r
+                               $data['commentator'] = Entity::hsc($current['cuser']);\r
+                       }\r
+                       if ( isset($current['cmail']) && $current['cmail'] )\r
+                       {\r
+                               $data['commentsite'] = Entity::hsc($current['cmail']);\r
+                       }\r
+                               else\r
+                       {\r
+                               $data['commentsite'] = '';\r
+                       }\r
+                       if ( isset($current['cemail']) && $current['cemail'] )\r
+                       {\r
+                               $data['commentmail'] = Entity::hsc($current['cemail']);\r
+                       }\r
+                               else\r
+                       {\r
+                               $data['commentmail'] = '';\r
+                       }\r
+                       if ( $vars['canAddBan'] )\r
+                       {\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN']) )\r
+                               {\r
+                                       $subTpl = "<td style=\"white-space:nowrap\">"\r
+                                               . "<a href=\"index.php?action=banlistnewfromitem&amp;itemid=<%itemid%>&amp;ip=<%banip%>\" title=\"<%banhost%>\"><%banbtn%></a>"\r
+                                               . "</td>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $subTpl = $templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN'];\r
+                               }\r
+                               $subData = array(\r
+                                       'itemid'        => $current['citem'],\r
+                                       'banip'         => Entity::hsc($current['cip']),\r
+                                       'banbtn'        => _LIST_COMMENT_BANIP,\r
+                               );\r
+                               $data['addbanlist'] = Template::fill($subTpl, $subData);\r
+                       }\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT']) )\r
+                       {\r
+                               $template = "";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_bloglist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%blognames%></th>\n"\r
+                                         . "<th colspan=\"7\"><%actionshead%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'blognames'   => _NAME,\r
+                               'actionshead' => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY']) )\r
+                       {\r
+                               $template = "<td title=\"blogid:<%blogid%> shortname:<%shortname%>\">\n"\r
+                                         . "<a href=\"<%blogurl%>\"><img src=\"images/globe.gif\" width=\"13\" height=\"13\" alt=\"<%iconalt%>\" /></a><%blogname%></td>\n"\r
+                                         . "<td><a href=\"index.php?action=createitem&amp;blogid=<%blogid%>\" title=\"<%ttaddtext%>\"><%addtext%></a></td>\n"\r
+                                         . "<td><a href=\"index.php?action=itemlist&amp;blogid=<%blogid%>\" title=\"<%ttedittext%>\"><%edittext%></a></td>\n"\r
+                                         . "<td><a href=\"index.php?action=blogcommentlist&amp;blogid=<%blogid%>\" title=\"<%ttcommenttext%>\"><%commenttext%></a></td>\n"\r
+                                         . "<td><a href=\"index.php?action=bookmarklet&amp;blogid=<%blogid%>\" title=\"<%ttbmlettext%>\"><%bmlettext%></a></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'blogid'                => $current['bnumber'],\r
+                               'shortname'             => Entity::hsc($current['bshortname']),\r
+                               'blogurl'               => $current['burl'],\r
+                               'blogname'              => Entity::hsc($current['bname']),\r
+                               'ttaddtext'             => _BLOGLIST_TT_ADD,\r
+                               'addtext'               => _BLOGLIST_ADD,\r
+                               'ttedittext'    => _BLOGLIST_TT_EDIT,\r
+                               'edittext'              => _BLOGLIST_EDIT,\r
+                               'ttcommenttext' => _BLOGLIST_TT_COMMENTS,\r
+                               'commenttext'   => _BLOGLIST_COMMENTS,\r
+                               'ttbmlettext'   => _BLOGLIST_TT_BMLET,\r
+                               'bmlettext'             => _BLOGLIST_BMLET,\r
+                       );\r
+                       if ( $current['tadmin'] == 1 )\r
+                       {\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM']) )\r
+                               {\r
+                                       $template .= "<td><a href=\"index.php?action=blogsettings&amp;blogid=<%blogid%>\" title=\"<%ttsettingtext%>\"><%settingtext%></a></td>\n"\r
+                                                  . "<td><a href=\"index.php?action=banlist&amp;blogid=<%blogid%>\" title=\"<%ttbanstext%>\"><%banstext%></a></td>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template .= $templates['SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM'];\r
+                               }\r
+                               $data['ttsettingtext']  = _BLOGLIST_TT_SETTINGS;\r
+                               $data['settingtext']    = _BLOGLIST_SETTINGS;\r
+                               $data['ttbanstext']             = _BLOGLIST_TT_BANS;\r
+                               $data['banstext']               = _BLOGLIST_BANS;\r
+                       }\r
+                       \r
+                       if ( $vars['superadmin'] )\r
+                       {\r
+                               if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLIST_BD_SADM', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM']) )\r
+                               {\r
+                                       $template .= "<td><a href=\"index.php?action=deleteblog&amp;blogid=<%blogid%>\" title=\"<%ttdeletetext%>\"><%deletetext%></a></td>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $template .= $templates['SHOWLIST_LISTPLUG_TABLE_BLIST_BD_SADM'];\r
+                               }\r
+                               $data['ttdeletetext']   = _BLOGLIST_TT_DELETE;\r
+                               $data['deletetext']             = _BLOGLIST_DELETE;\r
+                       }\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_shortblognames($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colshortname%></th>\n"\r
+                                         . "<th><%colblogname%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colshortname' => _EBLOG_SHORTNAME,\r
+                               'colblogname'  => _EBLOG_NAME,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY']) )\r
+                       {\r
+                               $template = "<td><%bshortname%></td>\n"\r
+                                         . "<td><%blogname%></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'bshortname' => Entity::hsc($current['bshortname']),\r
+                               'blogname'   => Entity::hsc($current['bname']),\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_shortnames($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colname%></th>\n"\r
+                                         . "<th><%coldesc%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colname' => _NAME,\r
+                               'coldesc' => _LISTS_DESC,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY']) )\r
+                       {\r
+                               $template = "<td><%name%></td>\n"\r
+                                         . "<td><%desc%></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'name' => Entity::hsc($current['name']),\r
+                               'desc' => Entity::hsc($current['description']),\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_categorylist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colname%></th>\n"\r
+                                         . "<th><%coldesc%></th>\n"\r
+                                         . "<th colspan=\"2\"><%colact%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colname' => _LISTS_NAME,\r
+                               'coldesc' => _LISTS_DESC,\r
+                               'colact'  => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY']) )\r
+                       {\r
+                               $template = "<td>\n"\r
+                                         . "<input type=\"checkbox\" id=\"batch<%batchid%>\" name=\"batch[<%batchid%>]\" value=\"<%catid%>\" />\n"\r
+                                         . "<label for=\"batch<%batchid%>\"><%catname%></label>\n"\r
+                                         . "</td>\n"\r
+                                         . "<td><%catdesc%></td>\n"\r
+                                         . "<td><a href=\"index.php?action=categoryedit&amp;blogid=<%blogid%>&amp;catid=<%catid%>\" tabindex=\"<%tabindex%>\"><%editbtn%></a></td>\n"\r
+                                         . "<td><a href=\"index.php?action=categorydelete&amp;blogid=<%blogid%>&amp;catid=<%catid%>\" tabindex=\"<%tabindex%>\"><%delbtn%></a></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY'];\r
+                       }\r
+                       \r
+                       $data = array(\r
+                               'batchid'       => listplug_nextBatchId(),\r
+                               'catid'         => intval($current['catid']),\r
+                               'catname'       => Entity::hsc($current['cname']),\r
+                               'catdesc'       => Entity::hsc($current['cdesc']),\r
+                               'blogid'        => intval($current['cblog']),\r
+                               'tabindex'      => intval($vars['tabindex']),\r
+                               'editbtn'       => _LISTS_EDIT,\r
+                               'delbtn'        => _LISTS_DELETE,\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_templatelist($vars, $type, $template_name = '')\r
+{\r
+       global $manager, $CONF;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colname%></th>\n"\r
+                                         . "<th><%coldesc%></th>\n"\r
+                                         . "<th colspan=\"3\"><%colact%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colname' => _LISTS_NAME,\r
+                               'coldesc' => _LISTS_DESC,\r
+                               'colact'  => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY']) )\r
+                       {\r
+                               $template = "<td><%templatename%></td>\n"\r
+                                         . "<td><%templatedesc%></td>\n"\r
+                                         . "<td style=\"white-space:nowrap\">"\r
+                                         . "<a href=\"<%editurl%>\" tabindex=\"<%tabindex%>\"><%editbtn%></a>\n"\r
+                                         . "</td>\n"\r
+                                         . "<td style=\"white-space:nowrap\">\n"\r
+                                         . "<a href=\"<%cloneurl%>\" tabindex=\"<%tabindex%>\"><%clonebtn%></a>\n"\r
+                                         . "</td>\n"\r
+                                         . "<td style=\"white-space:nowrap\">\n"\r
+                                         . "<a href=\"<%deleteurl%>\" tabindex=\"<%tabindex%>\"><%delbtn%></a>\n"\r
+                                         . "</td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY'];\r
+                       }\r
+                       \r
+                       $data = array(\r
+                               'templatename'  => Entity::hsc($current['tdname']),\r
+                               'templatedesc'  => Entity::hsc($current['tddesc']),\r
+                               'templateid'    => (integer) $current['tdnumber'],\r
+                               'tabindex'              => (integer) $vars['tabindex'],\r
+                               \r
+                               'clonebtn'              => _LISTS_CLONE,\r
+                               'cloneaction'   => $vars['cloneaction'],\r
+                               'cloneurl'              => "{$CONF['AdminURL']}index.php?action={$vars['cloneaction']}&amp;templateid={$current['tdnumber']}",\r
+                               \r
+                               'delbtn'                => _LISTS_DELETE,\r
+                               'deleteaction'  => $vars['deleteaction'],\r
+                               'deleteurl'             => "{$CONF['AdminURL']}index.php?action={$vars['deleteaction']}&amp;templateid={$current['tdnumber']}",\r
+                               \r
+                               'editbtn'               => _LISTS_EDIT,\r
+                               'editaction'    => $vars['editaction'],\r
+                               'editurl'               => "{$CONF['AdminURL']}index.php?action={$vars['editaction']}&amp;templateid={$current['tdnumber']}"\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_skinlist($vars, $type, $template_name = '')\r
+{\r
+       global $CONF, $DIR_SKINS, $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colname%></th>\n"\r
+                                         . "<th><%coldesc%></th>\n"\r
+                                         . "<th colspan=\"3\"><%colact%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colname'       => _LISTS_NAME,\r
+                               'coldesc'       => _LISTS_DESC,\r
+                               'colact'        => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY']) )\r
+                       {\r
+                               $template = "<td><%skinname%><br /><br />\n"\r
+                                         . "<%skintypelabel%> <%skintype%><br />\n"\r
+                                         . "<%incmodelabel%> <%incmode%><br />\n"\r
+                                         . "<%incpreflabel%> <%incpref%><br />\n"\r
+                                         . "<%skinthumb%>"\r
+                                         . "<%readme%></td>\n"\r
+                                         . "<td class=\"availableSkinTypes\"><%skindesc%><%skinparts%></td>\n"\r
+                                         . "<td style=\"white-space:nowrap\">"\r
+                                         . "<a href=\"index.php?action=skinedit&amp;skinid=<%skinid%>\" tabindex=\"<%tabindex%>\"><%editbtn%></a>"\r
+                                         . "</td>\n"\r
+                                         . "<td style=\"white-space:nowrap\">"\r
+                                         . "<a href=\"<%cloneurl%>\" tabindex=\"<%tabindex%>\"><%clonebtn%></a>"\r
+                                         . "</td>\n"\r
+                                         . "<td style=\"white-space:nowrap\">"\r
+                                         . "<a href=\"index.php?action=skindelete&amp;skinid=<%skinid%>\" tabindex=\"<%tabindex%>\"><%delbtn%></a>"\r
+                                         . "</td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY'];\r
+                       }\r
+                       \r
+                       $data = array(\r
+                               'tabindex'              => $vars['tabindex']++,\r
+                               \r
+                               'skinid'                => (integer) $current['sdnumber'],\r
+                               'skindesc'              => Entity::hsc($current['sddesc']),\r
+                               \r
+                               'skintypelabel' => _LISTS_TYPE,\r
+                               'skintype'              => Entity::hsc($current['sdtype']),\r
+                               \r
+                               'incmodelabel'  => _LIST_SKINS_INCMODE,\r
+                               'incmode'               => ($current['sdincmode'] == 'skindir') ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL,\r
+                               \r
+                               'incpreflabel'  => ($current['sdincpref']) ? _SKIN_INCLUDE_PREFIX : '',\r
+                               'incpref'               => ($current['sdincpref']) ? Entity::hsc($current['sdincpref']) : '',\r
+                               \r
+                               'editbtn'               => _LISTS_EDIT,\r
+                               'editaction'    => $vars['editaction'],\r
+                               'editurl'               => "{$CONF['AdminURL']}index.php?action={$vars['editaction']}&skinid={$current['sdnumber']}",\r
+                               \r
+                               'clonebtn'              => _LISTS_CLONE,\r
+                               'cloneaction'   => $vars['cloneaction'],\r
+                               'cloneurl'              => "{$CONF['AdminURL']}index.php?action={$vars['cloneaction']}&skinid={$current['sdnumber']}",\r
+                               \r
+                               'delbtn'                => _LISTS_DELETE,\r
+                               'deleteaction'  => $vars['deleteaction'],\r
+                               'deleteurl'             => "{$CONF['AdminURL']}index.php?action={$vars['deleteaction']}&skinid={$current['sdnumber']}"\r
+                       );\r
+                       \r
+                       if ( $current['sdnumber'] != $vars['default'] )\r
+                       {\r
+                               $data['skinname'] = Entity::hsc($current['sdname']);\r
+                       }\r
+                       else\r
+                       {\r
+                               $data['skinname'] = '<strong>' . Entity::hsc($current['sdname']) . '</strong>';\r
+                       }\r
+                       \r
+                       // add preview image when present\r
+                       if ( $current['sdincpref'] && @file_exists("{$DIR_SKINS}{$current['sdincpref']}preview.png") )\r
+                       {\r
+                               $data['skinthumb'] = "<p>\n";\r
+                               \r
+                               $alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current['sdname']);\r
+                               $has_enlargement = @file_exists($DIR_SKINS . $current['sdincpref'] . 'preview-large.png');\r
+                               if ( $has_enlargement )\r
+                               {\r
+                                       $data['skinthumb'] .= '<a href="' . $CONF['SkinsURL'] . Entity::hsc($current['sdincpref']) . 'preview-large.png" title="' . _LIST_SKIN_PREVIEW_VIEWLARGER . "\">\n";\r
+                               }\r
+                               $data['skinthumb'] .= '<img class="skinpreview" src="' . $CONF['SkinsURL'] . Entity::hsc($current['sdincpref']) . 'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" />\n";\r
+                               if ( $has_enlargement )\r
+                               {\r
+                                       $data['skinthumb'] .= "</a><br />\n";\r
+                               }\r
+                               \r
+                               if ( @file_exists("{$DIR_SKINS}{$current['sdincpref']}readme.html") )\r
+                               {\r
+                                       $url = $CONF['SkinsURL'] . Entity::hsc($current['sdincpref']) . 'readme.html';\r
+                                       $title = sprintf(_LIST_SKIN_README, $current['sdname']);\r
+                                       $data['readme'] = "<a href=\"{$url}\" title=\"{$title}\">" . _LIST_SKIN_README_TXT . "</a>\n";\r
+                               }\r
+                               else\r
+                               {\r
+                                       $data['readme'] ="";\r
+                               }\r
+                               \r
+                               $data['skinthumb'] .=  "</p>\n";\r
+                       }\r
+                       \r
+                       $skin =& $manager->getSkin($current['sdnumber'], $vars['handler']);\r
+                       $available_types = $skin->getAvailableTypes();\r
+                       \r
+                       $data['skinparts'] = _LIST_SKINS_DEFINED\r
+                                          . "<ul>\n";\r
+                       foreach ( $available_types as $type => $label )\r
+                       {\r
+                               if ( $label === FALSE )\r
+                               {\r
+                                       $label = ucfirst($type);\r
+                                       $article = 'skinpartspecial';\r
+                               }\r
+                               else\r
+                               {\r
+                                       $article = "skinpart{$type}";\r
+                               }\r
+                               $data['skinparts'] .= "<li>\n"\r
+                                                  . helpHtml($article) . "\n"\r
+                                                  . "<a href=\"{$CONF['AdminURL']}index.php?action={$vars['edittypeaction']}&amp;skinid={$current['sdnumber']}&amp;type={$type}\" tabindex=\"{$vars['tabindex']}\">"\r
+                                                  . Entity::hsc($label)\r
+                                                  . "</a>\n"\r
+                                                  . "</li>\n";\r
+                       }\r
+                       $data['skinparts'] .= "</ul>\n";\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT']) )\r
+                       {\r
+                               $template = "";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_draftlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colblog%></th>\n"\r
+                                         . "<th><%coldesc%></th>\n"\r
+                                         . "<th colspan=\"2\"><%colact%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colblog'       => _LISTS_BLOG,\r
+                               'coldesc'       => _LISTS_TITLE,\r
+                               'colact'        => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY']) )\r
+                       {\r
+                               $template = "<td><%bshortname%></td>\n"\r
+                                         . "<td><%ititle%></td>\n"\r
+                                         . "<td><a href=\"index.php?action=itemedit&amp;itemid=<%itemid%>\"><%editbtn%></a></td>\n"\r
+                                         . "<td><a href=\"index.php?action=itemdelete&amp;itemid=<%itemid%>\"><%delbtn%></a></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'bshortname'    => Entity::hsc($current['bshortname']),\r
+                               'ititle'                => Entity::hsc(strip_tags($current['ititle'])),\r
+                               'itemid'                => intval($current['inumber']),\r
+                               'editbtn'               => _LISTS_EDIT,\r
+                               'delbtn'                => _LISTS_DELETE,\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_otherdraftlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%colblog%></th>\n"\r
+                                         . "<th><%coldesc%></th>\n"\r
+                                         . "<th><%colautr%></th>\n"\r
+                                         . "<th colspan=\"2\"><%colact%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'colblog'       => _LISTS_BLOG,\r
+                               'coldesc'       => _LISTS_TITLE,\r
+                               'colautr'       => _LISTS_AUTHOR,\r
+                               'colact'        => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_BODY']) )\r
+                       {\r
+                               $template = "<td><%bshortname%></td>\n"\r
+                                         . "<td><%ititle%></td>\n"\r
+                                         . "<td><%iauthor%></td>\n"\r
+                                         . "<td><a href=\"index.php?action=itemedit&amp;itemid=<%itemid%>\"><%editbtn%></a></td>\n"\r
+                                         . "<td><a href=\"index.php?action=itemdelete&amp;itemid=<%itemid%>\"><%delbtn%></a></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'bshortname'    => Entity::hsc($current['bshortname']),\r
+                               'ititle'                => Entity::hsc(strip_tags($current['ititle'])),\r
+                               'iauthor'               => Entity::hsc(strip_tags($current['mname'])),\r
+                               'itemid'                => intval($current['inumber']),\r
+                               'editbtn'               => _LISTS_EDIT,\r
+                               'delbtn'                => _LISTS_DELETE,\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ODRFTLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_actionlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%coltime%></th>\n"\r
+                                         . "<th><%colmesg%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'coltime' => _LISTS_TIME,\r
+                               'colmesg' => _LIST_ACTION_MSG,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY']) )\r
+                       {\r
+                               $template = "<td><%timestamp%></td>\n"\r
+                                         . "<td><%message%></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'timestamp'     => Entity::hsc($current['timestamp']),\r
+                               'message'       => Entity::hsc($current['message']),\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+function listplug_table_banlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( !empty($template_name) )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD']) )\r
+                       {\r
+                               $template = "<th><%iprange%></th>\n"\r
+                                         . "<th><%reason%></th>\n"\r
+                                         . "<th><%colact%></th>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD'];\r
+                       }\r
+                       $data = array(\r
+                               'iprange'       => _LIST_BAN_IPRANGE,\r
+                               'reason'        => _LIST_BAN_REASON,\r
+                               'colact'        => _LISTS_ACTIONS,\r
+                       );\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY']) )\r
+                       {\r
+                               $template = "<td><%iprange%></td>\n"\r
+                                         . "<td><%reason%></td>\n"\r
+                                         . "<td><a href=\"index.php?action=banlistdelete&amp;blogid=<%blogid%>&amp;iprange=<%iprange%>\"><%delbtn%></a></td>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY'];\r
+                       }\r
+                       $data = array(\r
+                               'iprange'       => Entity::hsc($current['iprange']),\r
+                               'reason'        => Entity::hsc($current['reason']),\r
+                               'blogid'        => intval($current['blogid']),\r
+                               'delbtn'        => _LISTS_DELETE,\r
+                       );\r
+                       break;\r
+               case 'FOOT':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT', $templates) || empty($templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT']) )\r
+                       {\r
+                               $template = "\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT'];\r
+                       }\r
+                       $data = array();\r
+                       break;\r
+       }\r
+       return Template::fill($template, $data);\r
+}\r
+\r
+/**\r
+ * listplug_list_normalskinlist()\r
+ * \r
+ * @param      array   $vars                   array for variables\r
+ * @param      string  $type                   HEAD/BODY/FOOT\r
+ * @param      string  $template_name  name of template\r
+ * @return     string  marked-up string\r
+ */\r
+function listplug_list_normalskinlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager, $CONF;\r
+       \r
+       /* available variables as a default */\r
+       $data = array(\r
+               'skinid'        => (integer) $vars['skinid'],\r
+               'skinname'      => Entity::hsc($vars['skinname']),\r
+       );\r
+       \r
+       $templates = array();\r
+       if ( $template_name )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch ( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('NORMALSKINLIST_HEAD', $templates) || empty($templates['NORMALSKINLIST_HEAD']) )\r
+                       {\r
+                               $template = "<ul>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['NORMALSKINLIST_HEAD'];\r
+                       }\r
+                       \r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('NORMALSKINLIST_BODY', $templates) || empty($templates['NORMALSKINLIST_BODY']) )\r
+                       {\r
+                               $template = "<li>"\r
+                                         . "<a href=\"<%editurl%>\" tabindex=\"<%tabindex%>\"><%skintypename%></a>"\r
+                                         . " <%help%>"\r
+                                         . "</li>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['NORMALSKINLIST_BODY'];\r
+                       }\r
+                       \r
+                       $data['tabindex']               = $vars['tabindex']++;\r
+                       $data['skintype']               = $current['skintype'];\r
+                       $data['skintypename']   = $current['skintypename'];\r
+                       $data['editaction']             = $vars['editaction'];\r
+                       $data['editurl']                = "{$CONF['AdminURL']}?action={$vars['editaction']}&amp;skinid={$vars['skinid']}&amp;type={$current['skintype']}";\r
+                       /* TODO: removeaction? */\r
+                       /* TODO: customHelpHtml("skinpart{$skintype}-{$template_name}") */\r
+                       $data['help']                   = '';\r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('NORMALSKINLIST_FOOT', $templates) || empty($templates['NORMALSKINLIST_FOOT']) )\r
+                       {\r
+                               $template = "</ul>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['NORMALSKINLIST_FOOT'];\r
+                       }\r
+                       \r
+                       break;\r
+       }\r
+       \r
+       return Template::fill($template, $data);\r
+}\r
+\r
+/**\r
+ * listplug_list_specialskinlist()\r
+ * \r
+ * @param      array   $vars                   array for variables\r
+ * @param      string  $type                   HEAD/BODY/FOOT\r
+ * @param      string  $template_name  name of template\r
+ * @return     string  marked-up string\r
+ */\r
+function listplug_list_specialskinlist($vars, $type, $template_name = '')\r
+{\r
+       global $manager, $CONF;\r
+       \r
+       /* available variables as a default */\r
+       $data = array(\r
+               'skinid'        => (integer) $vars['skinid'],\r
+               'skinname'      => Entity::hsc($vars['skinname']),\r
+       );\r
+       \r
+       /* retrieve templates */\r
+       $templates = array();\r
+       if ( $template_name )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       switch ( $type )\r
+       {\r
+               case 'HEAD':\r
+                       if ( !array_key_exists('SPECIALSKINLIST_HEAD', $templates) || empty($templates['SPECIALSKINLIST_HEAD']) )\r
+                       {\r
+                               $template = "<ul>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SPECIALSKINLIST_HEAD'];\r
+                       }\r
+                       break;\r
+               case 'BODY':\r
+                       $current = $vars['current'];\r
+                       if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )\r
+                       {\r
+                               $template = "<li>"\r
+                                         . "<a href=\"<%editurl%>\" tabindex=\"<%tabindex%>\">"\r
+                                         . "<%skintype%>"\r
+                                         . "</a>"\r
+                                         . " ("\r
+                                         . "<a href=\"<%removeurl%>\" tabindex=\"<%tabindex%>\" >"\r
+                                         . "<%text(_LISTS_DELETE)%>"\r
+                                         . "</a>"\r
+                                         . ")"\r
+                                         . "</li>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SPECIALSKINLIST_BODY'];\r
+                       }\r
+                       \r
+                       $data['tabindex']               = (integer) $vars['tabindex']++;\r
+                       $data['skintype']               = Entity::hsc($current['skintype']);\r
+                       $data['skintypename']   = Entity::hsc($current['skintypename']);\r
+                       $data['editaction']             = $vars['editaction'];\r
+                       $data['editurl']                = "{$CONF['AdminURL']}?action={$vars['editaction']}&amp;skinid={$vars['skinid']}&amp;type={$current['skintype']}";\r
+                       $data['removeaction']   = $vars['editaction'];\r
+                       $data['removeurl']              = "{$CONF['AdminURL']}?action={$vars['removeaction']}&amp;skinid={$vars['skinid']}&amp;type={$current['skintype']}";\r
+                       \r
+                       break;\r
+               case 'FOOT':\r
+                       if ( !array_key_exists('SPECIALSKINLIST_FOOT', $templates) || empty($templates['SPECIALSKINLIST_FOOT']) )\r
+                       {\r
+                               $template = "</ul>\n";\r
+                       }\r
+                       else\r
+                       {\r
+                               $template = $templates['SPECIALSKINLIST_FOOT'];\r
+                       }\r
+                       break;\r
+       }\r
+       \r
+       return Template::fill($template, $data);\r
+}\r
+\r
+/**\r
+ * listplug_input_yesno()\r
+ *\r
+ * @param      string  $name                   name of input element with radio type attribute\r
+ * @param      string  $checkedval             value which should be checked\r
+ * @param      integer $tabindex               tabindex number\r
+ * @param      string  $value1                 value of radio 1\r
+ * @param      string  $value2                 value of radio 2\r
+ * @param      string  $yesval                 label for yes\r
+ * @param      string  $noval                  label for no\r
+ * @param      boolean $isAdmin                super admin or not\r
+ * @param      string  $template_name  name of template\r
+ * @param      boolean $showlist               used in showlist or not\r
+ * @return     string  marked-up string\r
+ */\r
+function listplug_input_yesno($name, $checkedval, $tabindex = 0,\r
+       $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO,\r
+       $isAdmin = 0, $template_name = '', $showlist = FALSE)\r
+{\r
+       global $manager;\r
+       \r
+       $templates = array();\r
+       if ( $template_name )\r
+       {\r
+               $templates =& $manager->getTemplate($template_name);\r
+       }\r
+       \r
+       if ( $name == 'admin' )\r
+       {\r
+               if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )\r
+               {\r
+                       $template = "<input type=\"radio\" id=\"<%yesid%>\" name=\"<%name%>\" value=\"<%yesval%>\" <%yescheckedval%> onclick=\"selectCanLogin(true);\" />\n"\r
+                                 . "<label for=\"<%yesid%>\"><%yesvaltext%></label>\n"\r
+                                 . "<input type=\"radio\" id=\"<%noid%>\" name=\"<%name%>\" value=\"<%noval%>\" <%nocheckedval%> <%disabled%> onclick=\"selectCanLogin(false);\" />\n"\r
+                                 . "<label for=\"<%noid%>\"><%novaltext%></label>\n";\r
+               }\r
+               else\r
+               {\r
+                       $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )\r
+               {\r
+                       $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];\r
+               }\r
+               else if ( $showlist && array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )\r
+               {\r
+                       $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];\r
+               }\r
+               else\r
+               {\r
+               $template = "<input type=\"radio\" id=\"<%yesid%>\" name=\"<%name%>\" value=\"<%yesval%>\" <%yescheckedval%> />\n"\r
+                         . "<label for=\"<%yesid%>\"><%yesvaltext%></label>\n"\r
+                         . "<input type=\"radio\" id=\"<%noid%>\" name=\"<%name%>\" value=\"<%noval%>\" <%nocheckedval%> <%disabled%> />\n"\r
+                         . "<label for=\"<%noid%>\"><%novaltext%></label>\n";\r
+               }\r
+       }\r
+       \r
+       $id             = preg_replace('#[|]#', '-', $name);\r
+       $id1    = $id . $value1;\r
+       $id2    = $id . $value2;\r
+       $dat = array(\r
+               'name'                  => Entity::hsc($name),\r
+               'yesval'                => Entity::hsc($value1),\r
+               'noval'                 => Entity::hsc($value2),\r
+               'yesid'                 => Entity::hsc($id1),\r
+               'noid'                  => Entity::hsc($id2),\r
+               'yesvaltext'    => $yesval,\r
+               'novaltext'             => $noval,\r
+               'yescheckedval' => ($checkedval == $value1) ? 'checked="checked" tabindex="' . $tabindex . '"': '',\r
+               'nocheckedval'  => ($checkedval != $value1) ? 'checked="checked" tabindex="' . $tabindex . '"': '',\r
+               'disabled'              => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',\r
+       );\r
+       \r
+       return Template::fill($template, $dat);\r
+}\r
+\r
+/**\r
+ * listplug_batchlist()\r
+ * \r
+ * @param      string          $attr   item/member/team/category/comment\r
+ * @param      resource        $query  SQL resorce\r
+ * @param      string          $type   type for showlist()\r
+ * @param      array           $vars   array for variables\r
+ */\r
+function listplug_batchlist($attr, $query, $type, $vars, $template_name)\r
+{\r
+       global $manager;\r
+       \r
+       /* HEAD */\r
+       $content = "<form method=\"post\" action=\"index.php\">\n";\r
+       \r
+       /* BODY */\r
+       $content .= showlist($query, $type, $vars, $template_name);\r
+       \r
+       /* FOOT */\r
+       switch ( $attr )\r
+       {\r
+               case 'item':\r
+                       $options = array(\r
+                               'delete'        => _BATCH_ITEM_DELETE,\r
+                               'move'          => _BATCH_ITEM_MOVE\r
+                       );\r
+                       break;\r
+               case 'member':\r
+                       $options = array(\r
+                               'delete'        => _BATCH_MEMBER_DELETE,\r
+                               'setadmin'      => _BATCH_MEMBER_SET_ADM,\r
+                               'unsetadmin' => _BATCH_MEMBER_UNSET_ADM\r
+                       );\r
+                       break;\r
+               case 'team':\r
+                       $options = array(\r
+                               'delete'        => _BATCH_TEAM_DELETE,\r
+                               'setadmin'      => _BATCH_TEAM_SET_ADM,\r
+                               'unsetadmin' => _BATCH_TEAM_UNSET_ADM,\r
+                       );\r
+                       break;\r
+               case 'category':\r
+                       $options = array(\r
+                               'delete'        => _BATCH_CAT_DELETE,\r
+                               'move'          => _BATCH_CAT_MOVE,\r
+                       );\r
+                       break;\r
+               case 'comment':\r
+                       $options = array(\r
+                               'delete'        => _BATCH_COMMENT_DELETE,\r
+                       );\r
+                       break;\r
+               default:\r
+                       $options = array();\r
+                       break;\r
+       }\r
+       \r
+       $content .= "<p class=\"batchoperations\">\n"\r
+                  . _BATCH_WITH_SEL\r
+                  . "<select name=\"batchaction\">\n";\r
+       \r
+       foreach ( $options as $option => $label )\r
+       {\r
+               $content .= "<option value=\"{$option}\">{$label}</option>\n";\r
+       }\r
+       $content .= "</select>\n";\r
+       \r
+       if ( $attr == 'team' )\r
+       {\r
+               $content .= '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . '" />';\r
+       }\r
+       else if ( $attr == 'comment' )\r
+       {\r
+               $content .= '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . '" />';\r
+       }\r
+       \r
+       $content .= '<input type="submit" value="' . _BATCH_EXEC . '" />'\r
+                  . "("\r
+                  . "<a href=\"\" onclick=\"if( event &amp;&amp; event.preventDefault ) event.preventDefault(); return batchSelectAll(1); \">" . _BATCH_SELECTALL . "</a>"\r
+                  . " - "\r
+                  . "<a href=\"\" onclick=\"if( event &amp;&amp; event.preventDefault ) event.preventDefault(); return batchSelectAll(0); \">" . _BATCH_DESELECTALL . "</a>"\r
+                  . ")\n"\r
+                  . "<input type=\"hidden\" name=\"action\" value=\"batch{$attr}\" />\n"\r
+                  . '<input type="hidden" name="ticket" value="' . Entity::hsc($manager->getNewTicket()) . '" />' . "\n"\r
+                  . "</p>\n"\r
+                  . "</form>\n";\r
+       \r
+       return $content;\r
+}\r
+\r
+/**\r
+ * listplug_navlist()\r
+ * \r
+ * @param      string          $attr                   item/member/team/category/comment\r
+ * @param      resource        $query                  SQL resorce\r
+ * @param      string          $type                   type for showlist()\r
+ * @param      array           $vars                   array for variables\r
+ * @param      string          $template_name  name of template\r
+ * @return     string          contents\r
+ */\r
+function listplug_navlist($attribute, $query, $type, $vars, $template_name)\r
+{\r
+       global $CONF;\r
+       \r
+       $prev = $vars['start'] - $vars['amount'];\r
+       if ( $prev < $vars['minamount'] )\r
+       {\r
+               $prev = $vars['minamount'];\r
+       }\r
+       \r
+       $next = $vars['start'] + $vars['amount'];\r
+       \r
+       $navi = "\n";\r
+       $navi .= "<table frame=\"box\" rules=\"all\" sumamry=\"navigation actions\" class=\"navigation\">\n"\r
+              . "<tr>\n";\r
+       $navi .= "<td>\n"\r
+              . "<form method=\"post\" action=\"{$CONF['AdminURL']}\">\n"\r
+              . "<input type=\"hidden\" name=\"start\" value=\"{$prev}\" />\n"\r
+              . "<button type=\"submit\" name=\"action\" value=\"{$vars['action']}\">&lt; &lt; " . _LISTS_PREV . "</button>\n"\r
+              . "<input type=\"hidden\" name=\"blogid\" value=\"{$vars['blogid']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"itemid\" value=\"{$vars['itemid']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"search\" value=\"{$vars['search']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"amount\" value=\"{$vars['amount']}\" />\n"\r
+              . "</form>\n"\r
+              . "</td>\n";\r
+       $navi .= "<td>\n"\r
+              . "<form method=\"post\" action=\"{$CONF['AdminURL']}\">\n"\r
+              . "<input type=\"text\" name=\"amount\" size=\"3\" value=\"{$vars['amount']}\" />\n"\r
+              . _LISTS_PERPAGE\r
+              . "<input type=\"hidden\" name=\"start\" value=\"0\" />\n"\r
+              . "<button type=\"submit\" name=\"action\" value=\"{$vars['action']}\">&gt; " . _LISTS_CHANGE . "</button>\n"\r
+              . "<input type=\"hidden\" name=\"blogid\" value=\"{$vars['blogid']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"itemid\" value=\"{$vars['itemid']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"search\" value=\"{$vars['search']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"amount\" value=\"{$vars['amount']}\" />\n"\r
+              . "</form>\n"\r
+              . "</td>\n";\r
+       $navi .= "<td>\n"\r
+              . "<form method=\"post\" action=\"{$CONF['AdminURL']}\">\n"\r
+              . "<input type=\"text\" name=\"search\" value=\"{$vars['search']}\" size=\"7\" />\n"\r
+              . "<input type=\"hidden\" name=\"start\" value=\"0\" />\n"\r
+              . "<button type=\"submit\" name=\"action\" value=\"{$vars['action']}\">&gt; " . _LISTS_SEARCH . "</button>\n"\r
+              . "<input type=\"hidden\" name=\"blogid\" value=\"{$vars['blogid']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"itemid\" value=\"{$vars['itemid']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"search\" value=\"{$vars['search']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"amount\" value=\"{$vars['amount']}\" />\n"\r
+              . "</form>\n"\r
+              . "</td>\n";\r
+       $navi .= "<td>\n"\r
+              . "<form method=\"post\" action=\"{$CONF['AdminURL']}\">\n"\r
+              . "<input type=\"hidden\" name=\"start\" value=\"{$next}\" />\n"\r
+              . "<button type=\"submit\" name=\"action\" value=\"{$vars['action']}\">" . _LISTS_NEXT . "&gt; &gt; </button>\n"\r
+              . "<input type=\"hidden\" name=\"blogid\" value=\"{$vars['blogid']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"itemid\" value=\"{$vars['itemid']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"search\" value=\"{$vars['search']}\" />\n"\r
+              . "<input type=\"hidden\" name=\"amount\" value=\"{$vars['amount']}\" />\n"\r
+              . "</form>\n"\r
+              . "</td>\n";\r
+       $navi .= "</tr>\n"\r
+              . "</table>\n";\r
+       \r
+       /* HEAD */\r
+       $template = $navi;\r
+       \r
+       /* BODY */\r
+       $template .= listplug_batchlist($attribute, $query, $type, $vars, $template_name);\r
+       \r
+       /* FOOT */\r
+       $template .= $navi;\r
+       \r
+       return $template;\r
+}\r