OSDN Git Service

7acedab646cc6d0ac0cad09936d79cc42961cded
[nucleus-jp/nucleus-next.git] / nucleus / libs / AdminActions.php
1 <?php
2 class AdminActions extends BaseActions
3 {
4         /*
5          * TODO: I believe we can push them into Admin class
6          * if Admin class is just a static class.
7          */
8         private $skintype;
9         private $objAdmin;
10         
11         private $actions = array(
12                 'actionloglist',
13                 'activationmessage',
14                 'addtickettourl',
15                 'adminbatchaction',
16                 'adminbatchlist',
17                 'adminbanlist',
18                 'adminbloglink',
19                 'adminerrormesg',
20                 'adminparsedinclude',
21                 'adminskineditallowedlist',
22                 'adminskinielist',
23                 'adminskinoverview',
24                 'adminspecialskinlist',
25                 'admintemplateoverview',
26                 'allowedadminskinactions',
27                 'allowedskinactions',
28                 'batchmovetitle',
29                 'batchmovetype',
30                 'batchmovelist',
31                 'batchmovebtn',
32                 'batchdeletelist',
33                 'batchdeletetype',
34                 'blogcatlist',
35                 'blognotifysetting',
36                 'blogselectbox',
37                 'blogsettingyesno',
38                 'blogteamlist',
39                 'blogteammembers',
40                 'blogtime',
41                 'bookmarkletadmin',
42                 'categorysetting',
43                 'codename',
44                 'commentnavlist',
45                 'configsettingsedit',
46                 'configsettingsyesno',
47                 'date',
48                 'defaultadminskintypes',
49                 'defblogselect',
50                 'defcatselect',
51                 'defskinselect',
52                 'deletecomment',
53                 'deleteitemid',
54                 'deleteitembody',
55                 'deleteitemtitle',
56                 'editadminskin',
57                 'editadminskintype',
58                 'editadmintemplateinfo',
59                 'editcomment',
60                 'editdesturl',
61                 'editmemberlist',
62                 'editmember',
63                 'editskin',
64                 'editskintype',
65                 'edittemplateinfo',
66                 'editpluginfo',
67                 'editplugoptionslist',
68                 'extrahead',
69                 'eventformextra',
70                 'getblogsetting',
71                 'geteditpluginfo',
72                 'headmessage',
73                 'helplink',
74                 'helpplugname',
75                 'ilistaddnew',
76                 'importskininfo',
77                 'inputyesno',
78                 'insertpluginoptions',
79                 'iprangeinput',
80                 'itemnavlist',
81                 'jstoolbaroptions',
82                 'languageselectoptions',
83                 'listplugplugoptionrow',
84                 'mediadirwarning',
85                 'movedistselect',
86                 'moveitemid',
87                 'newmemberselect',
88                 'newestcompare',
89                 'newpluginlist',
90                 'outputspecialdirs',
91                 'passrequestvars',
92                 'pluginhelp',
93                 'pluginlistlist',
94                 'pluginextras',
95                 'pluginoptions',
96                 'qmenuaddselect',
97                 'quickmenu',
98                 'requestblogid',
99                 'requestiprange',
100                 'selectlocaladminskinfiles',
101                 'selectlocalskinfiles',
102                 'skineditallowedlist',
103                 'skinielist',
104                 'skinoverview',
105                 'skintypehelp',
106                 'specialskinlist',
107                 'sprinttext',
108                 'systemsettings',
109                 'text',
110                 'templateoverview',
111                 'ticket',
112                 'versioncheckurl',
113                 'yrbloglist',
114                 'adminstyleselectoptions',
115         /* FIXME: typo of adminstylesheets */
116                 'adminstyleseets',
117                 'adminskinselectoptions'
118         /* FIXME: lack entries. need to be review
119          * parse_banlistdeletedlist
120          * parse_blogsetting
121          * parse_category
122          * parse_customhelplink
123          * parse_getmember
124          * parse_insertpluginfo
125          * parse_insplugoptcontent
126          * parse_skinfile
127          */
128         );
129         
130         /**
131          * AdminActions::getDefinedActions()
132          * Returns an array with the actions that are defined
133          * in the AdminActions class
134          * 
135          * @param       void
136          * @return      void
137          */
138         public function getDefinedActions()
139         {
140                 return $this->actions;
141         }
142         
143         /**
144          * AdminActions::parse_actionloglist()
145          * Parse skinvar actionloglist
146          * 
147          * @param       string  $templateName   name of template to use
148          * @return      void
149          */
150         public function parse_actionloglist($templateName = '')
151         {
152                 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
153                 $query = sprintf($query, sql_table('actionlog'));       
154                 
155                 $template['content'] = 'actionlist';
156                 $amount = skinableShowlist($query, 'table', $template, $templateName);
157                 return;
158         }
159         
160         /**
161          * AdminActions::parse_activationmessage()
162          * Parse skinvar activationmessage
163          * 
164          * @param       string  $type                   type of message
165          * @param       string  $templateName   name of template to use
166          * @return      void
167          */
168         public function parse_activationmessage($type, $templateName = '')
169         {
170                 global $CONF, $manager;
171                 
172                 $template = array();
173                 
174                 if ( !empty($templateName))
175                 {
176                         $template = skinableTEMPLATE::read($templateName);
177                 }
178                 
179                 $key = postVar('ackey');
180                 if ( !$key )
181                 {
182                         $this->objAdmin->error(_ERROR_ACTIVATE);
183                 }
184                 
185                 $info = MEMBER::getActivationInfo($key);
186                 if ( !$info )
187                 {
188                         $this->objAdmin->error(_ERROR_ACTIVATE);
189                 }
190                 
191                 $mem  = MEMBER::createFromId($info->vmember);
192                 if ( !$mem )
193                 {
194                         $this->objAdmin->error(_ERROR_ACTIVATE);
195                 }
196                 switch ( $info->vtype )
197                 {
198                         case 'forgot':
199                                 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
200                                 {
201                                         $title = $template['ACTIVATE_FORGOT_TITLE'];
202                                 }
203                                 else
204                                 {
205                                         $title = _ACTIVATE_FORGOT_TITLE;
206                                 }
207                                 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
208                                 {
209                                         $text = $template['ACTIVATE_FORGOT_TEXT'];
210                                 }
211                                 else
212                                 {
213                                         $text = _ACTIVATE_FORGOT_TEXT;
214                                 }
215                                 break;
216                         case 'register':
217                                 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
218                                 {
219                                         $title = $template['ACTIVATE_REGISTER_TITLE'];
220                                 }
221                                 else
222                                 {
223                                         $title = _ACTIVATE_REGISTER_TITLE;
224                                 }
225                                 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
226                                 {
227                                         $text = $template['ACTIVATE_REGISTER_TEXT'];
228                                 }
229                                 else
230                                 {
231                                         $text = _ACTIVATE_REGISTER_TEXT;
232                                 }
233                                 break;
234                         case 'addresschange':
235                                 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
236                                 {
237                                         $title = $template['ACTIVATE_CHANGE_TITLE'];
238                                 }
239                                 else
240                                 {
241                                         $title = _ACTIVATE_CHANGE_TITLE;
242                                 }
243                                 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
244                                 {
245                                         $text = $template['ACTIVATE_CHANGE_TEXT'];
246                                 }
247                                 else
248                                 {
249                                         $text = _ACTIVATE_CHANGE_TEXT;
250                                 }
251                                 break;
252                 }
253                 $aVars = array(
254                         'memberName'    => Entity::hsc($mem->getDisplayName()),
255                         'realName'              => Entity::hsc($mem->getRealName()),
256                 );
257                 switch ( $type )
258                 {
259                         case 'title':
260                                 echo TEMPLATE::fill($title, $aVars);
261                                 break;
262                         case 'text':
263                                 echo TEMPLATE::fill($text,  $aVars);
264                                 break;
265                         case 'ackey':
266                                 echo Entity::hsc($key);
267                                 break;
268                 }
269                 return;
270         }
271         
272         /**
273          * Actions::parse_addtickettourl()
274          * Parse skinvar addtickettourl
275          * 
276          * @param       string  $url    URI for ticket
277          * @return      void
278          */
279         public function parse_addtickettourl($url)
280         {
281                 global $manager;
282                 $url = $manager->addTicketToUrl($url);
283                 echo Entity::hsc($url);
284                 return;
285         }
286         
287         /**
288          * Actions::parse_adminbanlist()
289          * Parse skinvar adminbanlist
290          * 
291          * @param       string  $templateName   name of template to use
292          * @return      void
293          */
294         public function parse_adminbanlist($templateName = '')
295         {
296                 $blogid = intRequestVar('blogid');
297                 
298                 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
299                 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
300                 
301                 $template['content'] = 'banlist';
302                 
303                 $amount = Showlist($query, 'table', $template, $templateName);
304                 
305                 if ( $amount == 0 )
306                 {
307                         echo _BAN_NONE;
308                 }
309                 return;
310         }
311         
312         /**
313          * Actions::parse_adminbatchaction()
314          * Parse skinvar adminbatchaction
315          * 
316          * @param       void
317          * @return      void
318          */
319         public function parse_adminbatchaction()
320         {
321                 echo Entity::hsc(requestVar('batchaction'));
322                 return;
323         }
324         
325         /**
326          * Actions::parse_adminbatchlist()
327          * Parse skinvar adminbatchlist
328          * 
329          * @param       string  $templateName   name of template to use
330          * @return      void
331          */
332         public function parse_adminbatchlist($templateName = '')
333         {
334                 global $manager;
335                 $templates = array();
336                 if ( !empty($templateName) )
337                 {
338                         $templates = Template::read($templateName);
339                 }
340                 if ( isset($templates['ADMIN_BATCHLIST']) || !empty($templates['ADMIN_BATCHLIST']) )
341                 {
342                         $template = $templates['ADMIN_BATCHLIST'];
343                 }
344                 else
345                 {
346                         $template = '<li><%text(_BATCH_EXECUTING)%><b><%adminbatchaction%></b>'
347                                           . '<%batchlisttype%> <b><%batchid%></b>...'
348                                           . '<b><%batchlistmsg%></b></li>' . "\n";
349                 }
350                 
351                 $selected = requestIntArray('batch');
352                 $action   = requestVar('batchaction');
353                 
354                 switch ( $this->skintype )
355                 {
356                         case 'batchitem':
357                                 $batchlisttype  = _BATCH_ONITEM;
358                                 $deleteaction   = 'deleteOneItem';
359                                 $moveaction             = 'moveOneItem';
360                                 $destid                 = intRequestVar('destcatid');
361                                 break;
362                         case 'batchcomment':
363                                 $batchlisttype  = _BATCH_ONCOMMENT;
364                                 $deleteaction   = 'deleteOneComment';
365                                 break;
366                         case 'batchmember':
367                                 $batchlisttype  = _BATCH_ONMEMBER;
368                                 $deleteaction   = 'deleteOneMember';
369                                 $setadminsql    = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
370                                 $unsetchksql    = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
371                                 $unsetupsql             = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
372                                 $unseterrmsg    = _ERROR_ATLEASTONEADMIN;
373                                 break;
374                         case 'batchteam':
375                                 $blogid                 = intRequestVar('blogid');
376                                 $batchlisttype  = _BATCH_ONTEAM;
377                                 $deleteaction   = 'deleteOneTeamMember';
378                                 $setadminsql    = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
379                                 $unsetchksql    = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
380                                 $unseterrmsg    = _ERROR_ATLEASTONEBLOGADMIN;
381                                 $unsetupsql             = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
382                                 break;
383                         case 'batchcategory':
384                                 $batchlisttype  = _BATCH_ONCATEGORY;
385                                 $deleteaction   = 'deleteOneCategory';
386                                 $moveaction             = 'moveOneCategory';
387                                 $destid                 = intRequestVar('destblogid');
388                                 break;
389                 }
390                 
391                 // walk over all selectedids and perform action
392                 foreach ( $selected as $selectedid )
393                 {
394                         $error    = '';
395                         $selectedid = intval($selectedid);
396                         switch ( $action )
397                         {
398                                 case 'delete':
399                                         if ( $this->skintype != 'batchteam' )
400                                         {
401                                                 $error = $this->objAdmin->$deleteaction($selectedid);
402                                         }
403                                         else
404                                         {
405                                                 $error  = $this->objAdmin->deleteOneTeamMember($blogid, $selectedid);
406                                         }
407                                         break;
408                                 case 'move':
409                                         $error = $this->objAdmin->$moveaction($selectedid, $destid);
410                                         break;
411                                 case 'setadmin':
412                                         // always succeeds
413                                         sql_query('UPDATE ' . $setadminsql . $selectedid);
414                                         $error = '';
415                                         break;
416                                 case 'unsetadmin':
417                                         // there should always remain at least one super-admin
418                                         $r = sql_query($unsetchksql);
419                                         if ( sql_num_rows($r) < 2 )
420                                         {
421                                                 $error = $unseterrmsg;
422                                         }
423                                         else
424                                         {
425                                                 sql_query('UPDATE ' . $unsetupsql . $selectedid);
426                                         }
427                                         break;
428                                 default:
429                                         $error = _BATCH_UNKNOWN . Entity::hsc($action);
430                         }
431                         $data = array(
432                                 'batchid'                       => $selectedid,
433                                 'batchlisttype'         => Entity::hsc($batchlisttype),
434                                 'adminbatchaction'      => Entity::hsc($action),
435                                 'batchlistmsg'          => $error ? $error : _BATCH_SUCCESS,
436                         );
437                         $handler = new Actions('template', $template, new ADMIN);
438                         $parser  = new Parser($handler);
439                         
440                         ob_start();
441                         $parser->parse($template);
442                         $template = ob_get_contents();
443                         ob_end_clean();
444                         
445                         echo TEMPLATE::fill($template, $data);
446                         return;
447                 }
448         }
449         
450         /**
451          * Actions::parse_adminbloglink()
452          * Parse skinvar adminbloglink
453          * 
454          * @param       string  $templateName   name of template to use
455          * @return      void
456          */
457         public function parse_adminbloglink($templateName = '')
458         {
459                 global $manager;
460                 $blogid =  intRequestVar('blogid');
461                 $blog   =& $manager->getBlog($blogid);
462                 $templates = array();
463                 
464                 if ( !empty($templateName) )
465                 {
466                         $templates = Template::read($templateName);
467                 }
468                 
469                 if ( isset($templates['ADMIN_BLOGLINK']) || !empty($templates['ADMIN_BLOGLINK']) )
470                 {
471                         $template = $templates['ADMIN_BLOGLINK'];
472                 }
473                 else
474                 {
475                         $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
476                 }
477                 
478                 $data = array(
479                         'url'                                   => Entity::hsc($blog->getURL()),
480                         'adminbloglinktitle'    => _BLOGLIST_TT_VISIT,
481                         'blogname'                              => Entity::hsc($blog->getName())
482                 );
483                 
484                 echo TEMPLATE::fill($template, $data);
485                 return;
486         }
487         
488         /**
489          * Actions::parse_adminerrormesg()
490          * Parse skinvar adminerrormesg
491          * 
492          * @param       void
493          * @return      void
494          */
495         public function parse_adminerrormesg()
496         {
497                 global $CONF;
498                 $message = '';
499                 
500                 if ( requestVar('errormessage') )
501                 {
502                         $message = requestVar('errormessage');
503                 }
504                 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
505                 {
506                         $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
507                 }
508                 elseif ( $this->objAdmin->sessionVar($CONF['CookiePrefix'] . 'errormessage') )
509                 {
510                         $message = $this->objAdmin->sessionVar($CONF['CookiePrefix'] . 'errormessage');
511                 }
512                 echo Entity::hsc($message);
513                 return;
514         }
515         
516         /**
517          * Actions::parse_adminparsedinclude()
518          * Parse skinvar adminparsedinclude
519          * 
520          * @param       string  $filename       name of file
521          * @return      void
522          */
523         public function parse_adminparsedinclude($filename)
524         {
525                 // check current level
526                 if ( $this->level > 3)
527                 {
528                         // max. depth reached (avoid endless loop)
529                         return;
530                 }
531                 $skin = new Skin($this->skin->id);
532                 $file = $this->getIncludeFileName($filename);
533                 
534                 if ( !$skin->isValid && !file_exists($file) )
535                 {
536                         return;
537                 }
538                 
539                 $contents = $skin->getContent($filename);
540                 
541                 if ( !$contents )
542                 {
543                         if ( !file_exists($file) )
544                         {
545                                 return;
546                         }
547                         $contents = file_get_contents($file);
548                         if ( empty($contents) )
549                         {
550                                 return;
551                         }
552                 }
553                 $this->level = $this->level + 1;
554                 // parse file contents
555                 $this->parser->parse($contents);
556                 
557                 $this->level = $this->level - 1;
558                 return;
559         }
560         
561         /**
562          * Actions::parse_adminskineditallowedlist()
563          * Parse skinvar adminskineditallowedlist
564          * 
565          * @param       string  $type                   template/blog
566          * @param       string  $templateName   name of template to use
567          * @return      void
568          */
569         public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
570         {
571                 switch ( $type )
572                 {
573                         /* TODO: blog seems not to be used */
574                         case 'blog':
575                                 $query = "SELECT bshortname, bname FROM %s";
576                                 $query = sprintf($query, sql_table('blog'));
577                                 $show  = array(
578                                         'content' => 'shortblognames'
579                                 );
580                                 break;
581                         case 'template':
582                                 $query = "SELECT tdname as name, tddesc as description FROM %s;";
583                                 $query = sprintf($query, sql_table('admintemplate_desc'));
584                                 $show  = array(
585                                         'content' => 'shortnames'
586                                 );
587                                 break;
588                 }
589                 Showlist($query, 'table', $show, $templateName);
590                 return;
591         }
592         
593         /**
594          * Actions::parse_adminskinielist()
595          * Parse skinvar adminskinielist
596          * 
597          * @param       string  $type                   skin/template
598          * @param       string  $templateName   name of template to use
599          * @return      void
600          */
601         public function parse_adminskinielist($type, $templateName = '')
602         {
603                 $templates = array();
604                 if ( $templateName )
605                 {
606                         $templates = Template::read($templateName);
607                 }
608                 if ( isset($templates['SKINIE_EXPORT_LIST']) && !empty($templates['SKINIE_EXPORT_LIST']) )
609                 {
610                         $template = $templates['SKINIE_EXPORT_LIST'];
611                 }
612                 else
613                 {
614                         $template = '<td><input type="checkbox" name="<%typeid%>"  id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
615                                           . "<td><%expdesc%></td>\n"
616                                           . "</tr><tr>\n";
617                 }
618                 switch ( $type )
619                 {
620                         case 'skin':
621                                 $query = "SELECT * FROM %s;";
622                                 $query = sprintf($query, sql_table('adminskin_desc'));
623                                 $res = sql_query($query);
624                                 
625                                 while ( $skinObj = sql_fetch_object($res) )
626                                 {
627                                         $data = array(
628                                                 'typeid'        => 'skin[' . $skinObj->sdnumber . ']',
629                                                 'expid'         => 'skinexp' . $skinObj->sdnumber,
630                                                 'expname'       => Entity::hsc($skinObj->sdname),
631                                                 'expdesc'       => Entity::hsc($skinObj->sddesc),
632                                         );
633                                         echo TEMPLATE::fill($template, $data);
634                                 }
635                                 break;
636                         case 'template':
637                                 $query = "SELECT * FROM %s;";
638                                 $query = sprintf($query, sql_table('admintemplate_desc'));
639                                 $res = sql_query($query);
640                                 while ( $templateObj = sql_fetch_object($res) )
641                                 {
642                                         $data = array(
643                                                 'typeid'        => 'template[' . $templateObj->tdnumber . ']',
644                                                 'expid'         => 'templateexp' . $templateObj->tdnumber,
645                                                 'expname'       => Entity::hsc($templateObj->tdname),
646                                                 'expdesc'       => Entity::hsc($templateObj->tddesc),
647                                         );
648                                         echo TEMPLATE::fill($template, $data);
649                                 }
650                                 break;
651                 }
652                 return;
653         }
654         
655         /**
656          * Actions::parse_adminskinoverview()
657          * Parse skinvar adminskinoverview
658          * 
659          * @param       string  $templateName   name of template to use
660          * @return      void
661          */
662         public function parse_adminskinoverview($templateName = '')
663         {
664                 $query = "SELECT * FROM %s ORDER BY sdname;";
665                 $query = sprintf($query, sql_table('adminskin_desc'));
666                 
667                 $template['content']    = 'adminskinlist';
668                 $template['tabindex']   = 10;
669                 Showlist($query, 'table', $template, $templateName);
670                 return;
671         }
672         
673         /**
674          * Actions::parse_adminskinselectoptions()
675          * Parse skinvar adminskinselectoptions
676          * 
677          * @param       void
678          * @return      void
679          */
680         public function parse_adminskinselectoptions()
681         {
682                 global $CONF;
683                 $query = "SELECT sdname as text, sdnumber as value FROM %s;";
684                 $query = sprintf($query, sql_table('adminskin_desc'));
685                 
686                 $template['name']        = 'adminskin';
687                 $template['selected'] = $CONF['DefaultAdminSkin'];
688                 $template['tabindex'] = 110;
689                 Showlist($query, 'select', $template, '');
690                 return;
691         }
692         
693         /**
694          * Actions::parse_adminspecialskinlist()
695          * Parse skinvar adminspecialskinlist
696          * 
697          * @param       string  $templateName   name of template to use
698          */
699         public function parse_adminspecialskinlist($templateName = '')
700         {
701                 $templates = array();
702                 if ( $templateName )
703                 {
704                         $templates = Template::read($templateName);
705                 }
706                 
707                 $nType  = Skin::getAdminskinDefaultTypes();
708                 $skinid = intRequestVar('skinid');
709                 
710                 $query = "SELECT stype FROM  %s WHERE stype NOT IN (%s) AND sdesc=%d;";
711                 $query = sprintf($query, sql_table('adminskin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
712                 
713                 $res    = sql_query($query);
714                 if ( $res && sql_num_rows($res) > 0 )
715                 {
716                         $data = array();
717                         if ( isset($templates['ADMIN_SPECIALSKINLIST_HEAD']) && !empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
718                         {
719                                 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
720                         }
721                         else
722                         {
723                                 $template['head'] = "<ul>\n";
724                         }
725                         echo TEMPLATE::fill($template['head'], $data);
726                         if ( isset($templates['ADMIN_SPECIALSKINLIST_BODY']) && !empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
727                         {
728                                 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
729                         }
730                         else
731                         {
732                                 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&amp;skinid=<%skinid%>'
733                                                                   . '&amp;type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
734                                                                   . 'action=adminskinremovetype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">remove</a>)</li>';
735                         }
736                         $tabstart = 120;
737                         while ( $row = sql_fetch_assoc($res) )
738                         {
739                                 $data = array(
740                                         'tabindex'      => $tabstart++,
741                                         'skinid'        => $skinid,
742                                         'skintype'      => Entity::hsc(strtolower($row['stype']))
743                                 );
744                                 echo TEMPLATE::fill($template['body'], $data);
745                         }
746                         
747                         $data = array();
748                         if ( isset($templates['ADMIN_SPECIALSKINLIST_FOOT']) && !empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
749                         {
750                                 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
751                         }
752                         else
753                         {
754                                 $template['foot'] = "<ul>\n";
755                         }
756                         echo TEMPLATE::fill($template['foot'], $data);
757                         return;
758                 }
759         }
760         
761         /**
762          * Actions::parse_adminstylesheets()
763          * Parse skinvar adminstylesheets
764          * 
765          * @param       void
766          * @return      void
767          */
768         public function parse_adminstylesheets()
769         {
770                 global $CONF;
771                 $includePrefix = $this->skin->includePrefix;
772                 
773                 if ( strlen($includePrefix) > 0 )
774                 {
775                         $styleURL = Entity::hsc($CONF['AdminURL']) . 'adminskins/' . $includePrefix . 'admin_' . $CONF['AdminCSS'] . '.css';
776                 }
777                 else
778                 {
779                         $styleURL = Entity::hsc($CONF['AdminURL']) . 'styles/admin_' . $CONF['AdminCSS'] . '.css';
780                 }
781                 echo $styleURL;
782                 return;
783         }
784         
785         /**
786          * Actions::parse_adminstyleselectoptions()
787          * Parse skinvar adminstyleselectoptions
788          * 
789          * @param       void
790          * @return      void
791          */
792         public function parse_adminstyleselectoptions()
793         {
794                 global $CONF, $manager, $DIR_NUCLEUS;
795                 if ( strlen($this->skin->includePrefix) > 0 )
796                 {
797                         $scndir = $DIR_NUCLEUS . 'adminskins/' . $this->skin->includePrefix;
798                 }
799                 else
800                 {
801                         $scndir = $DIR_NUCLEUS . 'styles/';
802                 }
803                 $files = scandir($scndir);
804                 
805                 foreach ( $files as $file )
806                 {
807                         if ( !preg_match("#^admin_(.*)\.css$#", $file, $matches) )
808                         {
809                                 continue;
810                         }
811                         
812                         $name = $matches[1];
813                         $opts = '<option value="' . $name . '"';
814                         if ( $name != $CONF['AdminCSS'] )
815                         {
816                                 $opts .= "<option value=\"{$name}\">{$name}</option>\n";
817                         }
818                         else
819                         {
820                                 $opts .= "<option value=\"{$name}\" selected=\"selected\">{$name}</option>\n";
821                         }
822                         echo $opts;
823                 }
824                 return;
825         }
826         
827         /**
828          * Actions::parse_admintemplateoverview()
829          * Parse skinvar admintemplateoverview
830          * 
831          * @param       string  $templateName   name of template to use
832          * @return      void
833          */
834         public function parse_admintemplateoverview($templateName = '')
835         {
836                 $query  = "SELECT * FROM %s ORDER BY tdname;";
837                 $query = sprintf($query, sql_table('admintemplate_desc'));
838                 
839                 $template['content']  = 'admintemplatelist';
840                 $template['tabindex'] = 10;
841                 
842                 Showlist($query, 'table', $template, $templateName);
843                 return;
844         }
845         
846         /**
847          * Actions::parse_allowedadminskinactions()
848          * Parse skinvar allowedadminskinactions
849          * 
850          * @param       void
851          * @return      void
852          */
853         public function parse_allowedadminskinactions()
854         {
855                 global $DIR_ADMINSKINS;
856                 $skinType = strtolower(trim(requestVar('type')));
857                 $actions  = Skin::getAllowedActionsForType($skinType);
858                 sort($actions);
859                 
860                 while ( $current = array_shift($actions) )
861                 {
862                         // skip deprecated vars
863                         if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
864                         {
865                                 continue;
866                         }
867                         
868                         echo "<a href=\"{$DIR_ADMINSKINS}documentation/help.html#{$current}\" onclick=\"if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);\">{$current}</a>\n";
869                         
870                         if ( count($actions) != 0 )
871                         {
872                                 echo ", ";
873                         }
874                 }
875                 return;
876         }
877         
878         /**
879          * Actions::parse_allowedskinactions()
880          * Parse skinvar allowedskinactions
881          * 
882          * @param       void
883          * @return      void
884          */
885         public function parse_allowedskinactions()
886         {
887                 $skinType = strtolower(trim(requestVar('type')));
888                 $actions  = SKIN::getAllowedActionsForType($skinType);
889                 sort($actions);
890                 
891                 while ( $current = array_shift($actions) )
892                 {
893                         // skip deprecated vars
894                         if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
895                         {
896                                 continue;
897                         }
898                         
899                         /* TODO: alternative function should be used or not?  */
900                         echo helplink("skinvar-{$current}") . "$current</a>\n";
901                         
902                         if ( count($actions) != 0 )
903                         {
904                                 echo ", ";
905                         }
906                 }
907                 return;
908         }
909         
910         /**
911          * Action::parse_banlistdeletedlist()
912          * Parse skinvar banlistdeletedlist
913          * 
914          * @param       string  $templateName   name of template to use
915          * @return      void
916          */
917         public function parse_banlistdeletedlist($templateName = '')
918         {
919                 global $manager;
920                 $templates = array();
921                 
922                 if ( $templateName )
923                 {
924                         $templates = Template::read($templateName);
925                 }
926                 if ( isset($templates['BANLIST_DELETED_LIST']) && !empty($templates['BANLIST_DELETED_LIST']) )
927                 {
928                         $template = $templates['BANLIST_DELETED_LIST'];
929                 }
930                 else
931                 {
932                         $template = "<li><%blogname%></li>\n";
933                 }
934                 $deleted = requestArray('delblogs');
935                 foreach ( $deleted as $delblog )
936                 {
937                         $blog =& $manager->getBlog($delblog);
938                         $data =  array(
939                                 Entity::hsc($blog->getName())
940                         );
941                         TEMPLATE::fill($template, $data);
942                 }
943                 return;
944         }
945         
946         /**
947          * Actions::parse_batchdeletelist()
948          * Parse skinvar batchdeletelist
949          * 
950          * @param       void
951          * @return      void
952          */
953         public function parse_batchdeletelist()
954         {
955                 $selected = requestIntArray('batch');
956                 $index  = 0;
957                 
958                 foreach ( $selected as $select )
959                 {
960                         echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
961                 }
962                 // add hidden vars for team & comment
963                 if ( requestVar('action') == 'batchteam' )
964                 {
965                         echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
966                 }
967                 if ( requestVar('action') == 'batchcomment' )
968                 {
969                         echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
970                 }
971                 return;
972         }
973         
974         /**
975          * Actions::parse_batchdeletetype()
976          * Parse skinvar batchdeletetype
977          * 
978          * @param       void
979          * @return      void
980          */
981         public function parse_batchdeletetype()
982         {
983                 echo Entity::hsc(requestVar('action'));
984                 return;
985         }
986
987         /**
988          * Actions::parse_batchmovebtn()
989          * Parse skinvar batchmovebtn
990          * 
991          * @param       void
992          * @return      void
993          */
994         public function parse_batchmovebtn()
995         {
996                 $actionType = requestVar('action');
997                 switch ( $actionType )
998                 {
999                         case 'batchitem':
1000                                 echo _MOVE_BTN;
1001                                 break;
1002                         case 'batchcategory':
1003                                 echo _MOVECAT_BTN;
1004                                 break;
1005                 }
1006                 return;
1007         }
1008         
1009         /**
1010          * Actions::parse_batchmovelist()
1011          * Parse skinvar batchmovelist
1012          * 
1013          * @param       void
1014          * @param       void
1015          */
1016         public function parse_batchmovelist()
1017         {
1018                 $selected = requestIntArray('batch');
1019                 foreach ( $selected as $select )
1020                 {
1021                         echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1022                 }
1023                 return;
1024         }
1025         
1026         /**
1027          * Actions::parse_batchmovetitle()
1028          * Parse skinvar batchmovetitle
1029          * 
1030          * @param       void
1031          * @return      void
1032          */
1033         public function parse_batchmovetitle()
1034         {
1035                 $actionType = requestVar('action');
1036                 switch ( $actionType )
1037                 {
1038                         case 'batchitem':
1039                                 echo _MOVE_TITLE;
1040                                 break;
1041                         case 'batchcategory':
1042                                 echo _MOVECAT_TITLE;
1043                                 break;
1044                 }
1045                 return;
1046         }
1047         
1048         /**
1049          * Actions::parse_batchmovetype()
1050          * Parse skinvar batchmovetype
1051          * 
1052          * @param       void
1053          * @return      void
1054          */
1055         public function parse_batchmovetype()
1056         {
1057                 echo Entity::hsc(requestVar('action'));
1058                 return;
1059         }
1060         
1061         /**
1062          * Actions::parse_blogcatlist()
1063          * Parse skinvar blogcatlist
1064          * 
1065          * @param       void
1066          * @return      void
1067          */
1068         public function parse_blogcatlist()
1069         {
1070                 global $manager;
1071                 $blogid = intRequestVar('blogid');
1072                 $query  = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1073                 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1074                 
1075                 $template['content']  = 'categorylist';
1076                 $template['tabindex'] = 200;
1077                 
1078                 $batch = new Batch('member');
1079                 $batch->showlist($query, 'table', $template);
1080                 return;
1081         }
1082         
1083         /**
1084          * Actions::parse_blognotifysetting()
1085          * Parse skinvar blognotifysetting
1086          * 
1087          * @param       void
1088          * @return      void
1089          */
1090         public function parse_blognotifysetting($type)
1091         {
1092                 global $manager;
1093                 $blogid = intRequestVar('blogid');
1094                 $blog   = $manager->getBlog($blogid);
1095                 
1096                 switch ( $type )
1097                 {
1098                         case 'comment':
1099                                 if ( !$blog->notifyOnComment() )
1100                                 {
1101                                         return;
1102                                 }
1103                                 break;
1104                         case 'vote':
1105                                 if ( !$blog->notifyOnVote() )
1106                                 {
1107                                         return;
1108                                 }
1109                                 break;
1110                         case 'newitem':
1111                                 if ( !$blog->notifyOnNewItem() )
1112                                 {
1113                                         return;
1114                                 }
1115                                 break;
1116                 }
1117                 echo ' checked="checked"';
1118                 return;
1119         }
1120         
1121         /**
1122          * AdminAction::parse_blogselectbox()
1123          * Parse skinvar blogselectbox
1124          * 
1125          * @param       void
1126          * @return      void
1127          */
1128         public function parse_blogselectbox()
1129         {
1130                 global $member;
1131                 
1132                 $selectData     = requestVar('selectData');
1133                 $mode           = $selectData['mode'];
1134                 $name           = ENTITY::hsc($selectData['name'], ENT_QUOTES);
1135                 $tabindex       = ENTITY::hsc($selectData['tabindex'], ENT_QUOTES);
1136                 $aBlogIds       = array_map('intval', $selectData['aBlogIds']);
1137                 $showNewCat     = intval($selectData['showNewCat']);
1138                 $selected       = intval($selectData['selected']);
1139                 
1140                 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1141                 
1142                 // 1. select blogs (we'll create optiongroups)
1143                 // (only select those blogs that have the user on the team)
1144                 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1145                 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1146                 $blogs = sql_query($queryBlogs);
1147                 
1148                 if ( $mode == 'category' )
1149                 {
1150                         if ( sql_num_rows($blogs) > 1 )
1151                         {
1152                                 $multipleBlogs = 1;
1153                         }
1154                         while ( $oBlog = sql_fetch_object($blogs) )
1155                         {
1156                                 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1157                                 {
1158                                         echo '<optgroup label="' . ENTITY::hsc($oBlog->bname, ENT_QUOTES) . "\>\n";
1159                                 }
1160                                 
1161                                 // show selection to create new category when allowed/wanted
1162                                 if ( $showNewCat )
1163                                 {
1164                                         // check if allowed to do so
1165                                         if ( $member->blogAdminRights($oBlog->bnumber) )
1166                                         {
1167                                                 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1168                                         }
1169                                 }
1170                                 
1171                                 // 2. for each category in that blog
1172                                 $catQueriy  = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1173                                 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1174                                 $categories = sql_query(sprintf($catQueriy));
1175                                 while ( $oCat = sql_fetch_object($categories) )
1176                                 {
1177                                         if ( $oCat->catid == $selected )
1178                                         {
1179                                                 $selectText = ' selected="selected" ';
1180                                         }
1181                                         else
1182                                         {
1183                                                 $selectText = '';
1184                                         }
1185                                         echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . ENTITY::hsc($oCat->cname, ENT_QUOTES) . "</option>\n";
1186                                 }
1187                                 
1188                                 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1189                                 {
1190                                         echo '</optgroup>';
1191                                 }
1192                         }
1193                 }
1194                 else
1195                 {
1196                         // blog mode
1197                         while ( $oBlog = sql_fetch_object($blogs) )
1198                         {
1199                                 echo '<option value="' . $oBlog->bnumber . '"';
1200                                 if ( $oBlog->bnumber == $selected )
1201                                 {
1202                                         echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . ENTITY::hsc($oBlog->bname, ENT_QUOTES) . "</option>\n";
1203                                 }
1204                                 else
1205                                 {
1206                                         echo '<option value="' . $oBlog->bnumber . '">' . ENTITY::hsc($oBlog->bname, ENT_QUOTES) . "</option>\n";
1207                                 }
1208                         }
1209                 }
1210                 echo "</select>\n";
1211                 return;
1212         }
1213         
1214         /**
1215          * Actions::parse_blogsetting()
1216          * Parse skinvar blogsetting
1217          * 
1218          * @param       string  $which  name of weblog setting
1219          * @return      void
1220          */
1221         public function parse_blogsetting($which)
1222         {
1223                 echo $this->parse_getblogsetting($which);
1224                 return;
1225         }
1226         
1227         /**
1228          * Actions::parse_blogsettingyesno()
1229          * Parse skinvar blogsettingyesno
1230          * 
1231          * @param       string  $type                   type of weblog setting
1232          * @param       string  $templateName   name of template to use
1233          * @return      void
1234          */
1235         public function parse_blogsettingyesno($type, $templateName = '')
1236         {
1237                 global $manager;
1238                 
1239                 $blogid = intRequestVar('blogid');
1240                 $blog   = $manager->getBlog($blogid);
1241                 
1242                 switch ( $type )
1243                 {
1244                         case 'convertbreaks':
1245                                 $checkedval = $blog->convertBreaks();
1246                                 $tabindex   = 55;
1247                                 break;
1248                         case 'allowpastposting':
1249                                 $checkedval = $blog->allowPastPosting();
1250                                 $tabindex   = 57;
1251                                 break;
1252                         case 'comments':
1253                                 $checkedval = $blog->commentsEnabled();
1254                                 $tabindex   = 60;
1255                                 break;
1256                         case 'public':
1257                                 $checkedval = $blog->isPublic();
1258                                 $tabindex   = 70;
1259                                 break;
1260                         case 'reqemail':
1261                                 $checkedval = $blog->emailRequired();
1262                                 $tabindex   = 72;
1263                                 break;
1264                         case 'searchable':
1265                                 $checkedval = $blog->getSearchable();
1266                                 $tabindex   = 122;
1267                                 break;
1268                 }
1269                 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1270                 return;
1271         }
1272         
1273         /**
1274          * Actions::parse_blogteamlist()
1275          * Parse skinvar blogteamlist
1276          * 
1277          * @param       string  $templateName   name of template to use
1278          * @return      void
1279          */
1280         public function parse_blogteamlist($templateName = '')
1281         {
1282                 global $manager;
1283                 $blogid = intRequestVar('blogid');
1284                 $query  = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1285                         . "FROM %s, %s "
1286                         . "WHERE tmember=mnumber AND tblog= %d";
1287                 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1288                 
1289                 $template['content']  = 'teamlist';
1290                 $template['tabindex'] = 10;
1291
1292                 $batch = new Batch('team');
1293                 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1294                 return;
1295         }
1296         
1297         /**
1298          * Actions::parse_blogteammembers()
1299          * Parse skinvar blogteammembers
1300          * 
1301          * @param       void
1302          * @return      void
1303          */
1304         public function parse_blogteammembers()
1305         {
1306                 $blogid = intRequestVar('blogid');
1307                 $query  = "SELECT mname, mrealname "
1308                                 . "FROM %s, %s "
1309                                 . "WHERE mnumber=tmember AND tblog=%d;";
1310                 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1311                 $res    = sql_query($query);
1312                 $memberNames = array();
1313                 while ($o = sql_fetch_object($res)) {
1314                         $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1315                 }
1316                 echo implode(',', $memberNames);
1317         }
1318         
1319         /**
1320          * Actions::parse_blogtime()
1321          * Parse skinvar blogtime
1322          * 
1323          * @param       string  $type   type of time
1324          * @param       string  $format format for time expression
1325          * @param       integer $offset offset of time
1326          * @return      void
1327          */
1328         public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1329         {
1330                 global $manager;
1331                 
1332                 if ( $type != 'blogtime' )
1333                 {
1334                         /* return server time */
1335                         $timestamp = time() + $offset;
1336                 }
1337                 else
1338                 {
1339                         $bid            = intRequestVar('blogid');
1340                         $b                      = $manager->getBlog($bid);
1341                         $timestamp      = $b->getCorrectTime() + $offset;
1342                 }
1343                 
1344                 echo i18n::formatted_datetime($format, $timestamp);
1345                 return;
1346         }
1347         
1348         /**
1349          * Actions::parse_bookmarkletadmin()
1350          * Parse skinvar bookmarkletadmin
1351          * 
1352          * @param       string  $type   type of anchor element for bookmarklet
1353          * @return      void
1354          */
1355         public function parse_bookmarkletadmin($type)
1356         {
1357                 global $manager;
1358                 
1359                 $blogid = intRequestVar('blogid');
1360                 
1361                 if ( $type != 'regfile' )
1362                 {
1363                         echo Entity::hsc(getBookmarklet($blogid));
1364                 }
1365                 else
1366                 {
1367                         $url = 'index.php?action=regfile&blogid=' . intval($blogid);
1368                         $url = $manager->addTicketToUrl($url);
1369                         /* TODO: Shift-JIS is not always correct, I think... */
1370                         echo Entity::hsc($url, 'SJIS');
1371                 }
1372                 return;
1373         }
1374         
1375         /**
1376          * Actions::parse_category()
1377          * Parse skinvar category
1378          * 
1379          * @param       string  $type   name of setting for category
1380          * @return      void
1381          */
1382         public function parse_category($type = 'name')
1383         {
1384                 echo $this->parse_getcategory($type);
1385                 return;
1386         }
1387         
1388         /**
1389          * Actions::parse_categorysetting()
1390          * Parse skinvar categorysetting
1391          * 
1392          * @param       string  $type   type in category setting
1393          * @return      void
1394          */
1395         public function parse_categorysetting($type)
1396         {
1397                 $catid  = intRequestVar('catid');
1398                 if ( $type == 'id' )
1399                 {
1400                         echo $catid;
1401                         return;
1402                 }
1403                 $blogid = intRequestVar('blogid');
1404                 $query  = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1405                 $query  = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1406                 $res    = sql_query($query);
1407                 $obj    = sql_fetch_object($res);
1408                 
1409                 if ( $type != desc )
1410                 {
1411                         echo Entity::hsc($obj->cdesc);
1412                 }
1413                 else
1414                 {
1415                         echo Entity::hsc($obj->cname);
1416                 }
1417                 
1418                 return;
1419         }
1420         
1421         /**
1422          * Actions::parse_codename()
1423          * Parse templatevar codename
1424          * 
1425          * @param       void
1426          * @return      void
1427          * 
1428          * TODO: is this need???
1429          */
1430         public function parse_codename()
1431         {
1432                 global $nucleus;
1433                 echo $nucleus['codename'];
1434                 return;
1435         }
1436         
1437         /**
1438          * Actions::parse_commentnavlist()
1439          * Parse skinvar commentnavlist
1440          * 
1441          * @param       void
1442          * @return      void
1443          */
1444         public function parse_commentnavlist()
1445         {
1446                 global $CONF, $manager, $member;
1447                 
1448                 // start index
1449                 if ( postVar('start') )
1450                 {
1451                         $start = intPostVar('start');
1452                 }
1453                 else
1454                 {
1455                         $start = 0;
1456                 }
1457                 
1458                 // amount of items to show
1459                 if ( postVar('amount') )
1460                 {
1461                         $amount = intPostVar('amount');
1462                 }
1463                 else
1464                 {
1465                         $amount = (integer) $CONF['DefaultListSize'];
1466                         if ( $amount < 1 )
1467                         {
1468                                 $amount = 10;
1469                         }
1470                 }
1471                 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1472                        . 'FROM %s '
1473                        . 'LEFT OUTER JOIN %s ON  mnumber=cmember '
1474                        . 'WHERE ';
1475                 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1476                 
1477                 if ( $this->skintype == 'itemcommentlist' )
1478                 {
1479                         $itemid                                 = intRequestVar('itemid');
1480                         $query                                  .= " citem={$itemid}";
1481                         $template['canAddBan']  = $member->blogAdminRights(intRequestVar('blogid'));
1482                         $bid                                    = 0;
1483                         $nonComments                    = _NOCOMMENTS;
1484                 }
1485                 elseif ( $this->skintype == 'browseowncomments' )
1486                 {
1487                         $itemid                                 = 0;
1488                         $query                                  .= ' cmember=' . $member->getID();
1489                         $template['canAddBan']  = 0;
1490                         $bid                                    = 0;
1491                         $nonComments                    = _NOCOMMENTS_YOUR;
1492                 }
1493                 elseif ( $this->skintype == 'blogcommentlist' )
1494                 {
1495                         $itemid                                 = 0;
1496                         $query                                  .= ' cblog=' . intRequestVar('blogid');
1497                         $template['canAddBan']  = $member->blogAdminRights(intRequestVar('blogid'));
1498                         $bid                                    = intRequestVar('blogid');
1499                         $nonComments                    = _NOCOMMENTS_BLOG;
1500                 }
1501                 
1502                 $search = postVar('search');
1503                 if ( !empty($search) )
1504                 {
1505                         $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1506                 }
1507                 
1508                 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1509                 
1510                 $template['content'] = 'commentlist';
1511                 
1512                 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
1513                 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
1514                 return;
1515         }
1516         
1517         /**
1518          * Actions::parse_configsettingsedit()
1519          * Parse skinvar configsettingsedit
1520          * 
1521          * @param       string  $type   type of global configuration
1522          * @return      void
1523          */
1524         public function parse_configsettingsedit($type)
1525         {
1526                 global $CONF;
1527                 switch ( $type )
1528                 {
1529                         case 'DefaultListSize':
1530                                 if ( !array_key_exists('DefaultListSize', $CONF) )
1531                                 {
1532                                         $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1533                                         $query = sprintf($query, sql_table('config'));
1534                                         sql_query($query);
1535                                         $CONF['DefaultListSize'] = 10;
1536                                 }
1537                                 elseif ( intval($CONF['DefaultListSize']) < 1 )
1538                                 {
1539                                         $CONF['DefaultListSize'] = 10;
1540                                 }
1541                                 echo intval($CONF['DefaultListSize']);
1542                                 break;
1543                         case 'SessionCookie':
1544                                 $value = $CONF['SessionCookie'];
1545                                 $txt1  = _SETTINGS_COOKIESESSION;
1546                                 $txt2  = _SETTINGS_COOKIEMONTH;
1547                                 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1548                                 break;
1549                         case 'URLMode':
1550                                 $value = $CONF['URLMode'];
1551                                 $txt1  = _SETTINGS_URLMODE_NORMAL;
1552                                 $txt2  = _SETTINGS_URLMODE_PATHINFO;
1553                                 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1554                                 break;
1555                         default:
1556                                 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1557                                 {
1558                                         echo  Entity::hsc($CONF[$type]);
1559                                 }
1560                                 break;
1561                 }
1562                 return;
1563         }
1564         
1565         /**
1566          * Actions::parse_configsettingsyesno()
1567          * Parse skinvar configsettingsyesno
1568          * 
1569          * @param       string  $type           type of global setting
1570          * @param       integer $tabindex       tabindex attribute of input element
1571          * @return      void
1572          */
1573         public function parse_configsettingsyesno($type, $tabindex)
1574         {
1575                 global $CONF;
1576                 if ( array_key_exists($type, $CONF) )
1577                 {
1578                         $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1579                 }
1580                 return;
1581         }
1582         
1583         /**
1584          * Actions::parse_customhelplink()
1585          * Parse skinvar customhelplink
1586          * 
1587          * @param       string  $topic          name of topic
1588          * @param       string  $tplName        name of template
1589          * @param       string  $url            string as URI
1590          * @param       string  $iconURL        string as URI for icon
1591          * @param       string  $alt            alternative text for image element
1592          * @param       string  $title          title for anchor element
1593          * @return      void
1594          */
1595         public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1596         {
1597                 $this->customHelp($topic, $url, $iconURL);
1598                 return;
1599         }
1600         
1601         /**
1602          * Actions::parse_date()
1603          * Parse skinvar date
1604          */
1605         public function parse_date($format = 'c')
1606         {
1607                 global $CONF, $manager;
1608                 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
1609                 return;
1610         }
1611         
1612         /**
1613          * Actions::parse_defaultadminskintypes()
1614          * Parse skinvar defaultadminskintypes
1615          * 
1616          * @param       string  $tabindex               index number for tabindex attribute of input element
1617          * @param       string  $templateName   name of template
1618          * @return      void
1619          */
1620         public function parse_defaultadminskintypes($tabindex, $templateName = '')
1621         {
1622                 $templates = array();
1623                 if ( $templateName )
1624                 {
1625                         $templates = Template::read($templateName);
1626                 }
1627                 
1628                 $types   = Skin::getAdminskinDefaultTypeFriendlyNames();
1629                 ksort($types);
1630                 
1631                 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
1632                 {
1633                         $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
1634                 }
1635                 else
1636                 {
1637                         $template['head'] = "<ul>\n";
1638                 }
1639                 
1640                 echo $template['head'];
1641                 
1642                 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
1643                 {
1644                         $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
1645                 }
1646                 else
1647                 {
1648                         $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">'
1649                                           . "<%name%></a> <%help%></li>\n";
1650                 }
1651                 $handler = new Actions('template', $template, new ADMIN);
1652                 $parser  = new PARSER(Actions::getDefinedActions(), $handler);
1653                 
1654                 foreach ( $types as $type => $fName )
1655                 {
1656                         $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
1657                         $data = array(
1658                                 'tabindex'      => $tabindex,
1659                                 'skintype'      => $type,
1660                                 'name'          => $fName,
1661                                 'help'          => $helplink,
1662                                 'skinid'        => intrequestVar('skinid'),
1663                         );
1664                         $templateBody = Template::fill($template['body'], $data);
1665                         $parser->parse($templateBody);
1666                         $tabindex++;
1667                 }
1668                 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
1669                 {
1670                         $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
1671                 }
1672                 else
1673                 {
1674                         $template['foot'] = "           </ul>\n";
1675                 }
1676                 echo $template['foot'];
1677                 return;
1678         }
1679         
1680         /**
1681          * Actions::parse_defblogselect()
1682          * Parse skinvar defblogselect
1683          * 
1684          * @param       string  $templateName   name of template
1685          * @return      void
1686          */
1687         public function parse_defblogselect($templateName = '')
1688         {
1689                 global $CONF;
1690                 $query  = "SELECT bname as text, bnumber as value FROM %s;";
1691                 $query = sprintf($query, sql_table('blog'));
1692                 $template['name']        = 'DefaultBlog';
1693                 $template['selected'] = $CONF['DefaultBlog'];
1694                 $template['tabindex'] = 10;
1695                 Showlist($query, 'select', $template, $templateName);
1696                 return;
1697         }
1698         
1699         /**
1700          * Actions::parse_defcatselect()
1701          * Parse skinvar defcatselect
1702          * 
1703          * @param       string  $templateName   name of template
1704          * @return      void
1705          */
1706         public function parse_defcatselect($templateName = '')
1707         {
1708                 global $manager;
1709                 $blogid = intRequestVar('blogid');
1710                 $blog   = $manager->getBlog($blogid);
1711                 $query  = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
1712                 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
1713                 $template['name']        = 'defcat';
1714                 $template['selected'] = $blog->getDefaultCategory();
1715                 $template['tabindex'] = 110;
1716                 Showlist($query, 'select', $template, $templateName);
1717                 return;
1718         }
1719         
1720         /**
1721          * Actions::parse_defskinselect()
1722          * Parse skinvar defskinselect
1723          * 
1724          * @param       string  $type                   type of skin
1725          * @param       string  $templateName   name of template
1726          * @return      void
1727          */
1728         public function parse_defskinselect($type = 'blog', $templateName = '')
1729         {
1730                 global $manager;
1731                 $query  = "SELECT sdname as text, sdnumber as value FROM %s;";
1732                 $query = sprintf($query, sql_table('skin_desc'));
1733                 
1734                 $blogid = intRequestVar('blogid');
1735                 
1736                 if ( !$blogid )
1737                 {
1738                         global $CONF;
1739                         $template['selected'] = $CONF['BaseSkin'];
1740                 }
1741                 else
1742                 {
1743                         $blog                            = $manager->getBlog($blogid);
1744                         $template['selected'] = $blog->getDefaultSkin();
1745                 }
1746                 
1747                 if ( $type != 'blog' )
1748                 {
1749                         $nname = 'BaseSkin';
1750                 }
1751                 else
1752                 {
1753                         $nname = 'defskin';
1754                 }
1755                 
1756                 $template['name']        = $nname;
1757                 $template['tabindex'] = 50;
1758                 Showlist($query, 'select', $template, $templateName);
1759                 return;
1760         }
1761         
1762         /**
1763          * AdminActions::parse_deletecomment()
1764          * Parse skinvar deletecomment
1765          * 
1766          * @param       string  $type   type of infomation for comment
1767          * @return      void
1768          */
1769         public function parse_deletecomment($type = 'id')
1770         {
1771                 $commentid      = intRequestVar('commentid');
1772                 $comment        = COMMENT::getComment($commentid);
1773                 
1774                 switch ( $type )
1775                 {
1776                         case 'id':
1777                                 echo intRequestVar('commentid');
1778                                 break;
1779                         case 'author':
1780                                 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
1781                                 {
1782                                         echo $comment['member'];
1783                                 }
1784                                 else
1785                                 {
1786                                         echo $comment['user'];
1787                                 }
1788                                 break;
1789                         case 'body':
1790                                 $body = strip_tags($comment['body']);
1791                                 echo ENTITY::hsc(shorten($body, 300, '...'), ENT_QUOTES);
1792                 }
1793                 return;
1794         }
1795         
1796         /**
1797          * Actions::parse_deleteitembody()
1798          * Parse skinvar deleteitembody
1799          * 
1800          * @param       void
1801          * @return      void
1802          */
1803         public function parse_deleteitembody()
1804         {
1805                 global $manager;
1806                 $itemid =  intRequestVar('itemid');
1807                 $item   =& $manager->getItem($itemid, 1, 1);
1808                 $body   =  strip_tags($item['body']);
1809                 echo Entity::hsc(shorten($body, 300, '...'));
1810                 return;
1811         }
1812         
1813         /**
1814          * Actions::parse_deleteitemid()
1815          * Parse skinvar deleteitemid
1816          * 
1817          * @param       void
1818          * @return      void
1819          */
1820         public function parse_deleteitemid()
1821         {
1822                 echo (integer) intRequestVar('itemid');
1823                 return;
1824         }
1825         
1826         /**
1827          * Actions::parse_deleteitemtitle()
1828          * Parse skinvar deleteitemtitle
1829          * 
1830          * @param       void
1831          * @return      void
1832          */
1833         public function parse_deleteitemtitle()
1834         {
1835                 global $manager;
1836                 $itemid = intRequestVar('itemid');
1837                 $item  =& $manager->getItem($itemid, 1, 1);
1838                 echo Entity::hsc(strip_tags($item['title']));
1839                 return;
1840         }
1841         
1842         /**
1843          * Actions::parse_editadminskin()
1844          * Parse skinvar editadminskin
1845          * 
1846          * @param       string  $type   type of skin setting
1847          * @return      void
1848          */
1849         public function parse_editadminskin($type = 'id')
1850         {
1851                 $skinid = intRequestVar('skinid');
1852                 $skin   = new Skin($skinid);
1853                 switch ( $type )
1854                 {
1855                         case 'id':
1856                                 echo intRequestVar('skinid');
1857                                 break;
1858                         case 'name':
1859                                 echo Entity::hsc($skin->getName());
1860                                 break;
1861                         case 'desc':
1862                                 echo Entity::hsc($skin->getDescription());
1863                                 break;
1864                         case 'type':
1865                                 echo Entity::hsc($skin->getContentType());
1866                                 break;
1867                         case 'prefix':
1868                                 echo Entity::hsc($skin->getIncludePrefix());
1869                                 break;
1870                         case 'mode':
1871                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
1872                         default:
1873                                 break;
1874                 }
1875                 return;
1876         }
1877         
1878         /**
1879          * Actions::parse_editadminskintype()
1880          * Parse skinvar editadminskintype
1881          * 
1882          * @param       string  $type   name of skin type
1883          * @return      void
1884          */
1885         public function parse_editadminskintype($type = 'id')
1886         {
1887                 global $CONF, $manager, $member;
1888                 $skinid = intRequestVar('skinid');
1889                 $skin   = new Skin($skinid);
1890                 $fNames = Skin::getFriendlyNames();
1891                 $sType  = strtolower(trim(requestVar('type')));
1892                 
1893                 switch ( $type )
1894                 {
1895                         case 'id':
1896                                 echo intRequestVar('skinid');
1897                                 break;
1898                         case 'name':
1899                                 echo Entity::hsc($skin->getName());
1900                                 break;
1901                         case 'desc':
1902                                 echo Entity::hsc($skin->getDescription());
1903                                 break;
1904                         case 'type':
1905                                 echo Entity::hsc($skin->getContentType());
1906                                 break;
1907                         case 'content':
1908                                 echo Entity::hsc($skin->getContent($sType));
1909                                 break;
1910                         case 'skintype':
1911                                 $skinType = isset($fNames[$sType]) ? $fNames[$sType] : ucfirst($sType);
1912                                 echo Entity::hsc($skinType);
1913                                 break;
1914                         case 'skintyperaw':
1915                                 echo Entity::hsc($sType);
1916                                 break;
1917                         case 'prefix':
1918                                 echo Entity::hsc($skin->getIncludePrefix());
1919                                 break;
1920                         case 'mode':
1921                                 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
1922                                 echo Entity::hsc($incMode);
1923                                 break;
1924                         default:
1925                                 break;
1926                 }
1927                 return;
1928         }
1929         
1930         /**
1931          * Actions::parse_editadmintemplateinfo()
1932          * Parse skinvar editadmintemplateinfo
1933          * 
1934          * @param       string  $type                   type of skin template
1935          * @param       string  $description    description of template
1936          * @param       string  $name                   name of stemplate
1937          * @param       string  $tabindex               index number for tabindex attribute of input element
1938          * @param       string  $big                    
1939          * @param       string  $tplt                   
1940          */
1941         public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
1942         {
1943                 global $manager;
1944                 $templateid                             =  intRequestVar('templateid');
1945                 $templatename                   =  Template::getNameFromId($templateid);
1946                 $templatedescription    =  Template::getDesc($templateid);
1947                 $template                               =& Template::read($templatename);
1948                 switch ( $type )
1949                 {
1950                         case 'id':
1951                                 echo intval($templateid);
1952                                 break;
1953                         case 'name':
1954                                 echo Entity::hsc($templatename);
1955                                 break;
1956                         case 'desc':
1957                                 echo Entity::hsc($templatedescription);
1958                                 break;
1959                         case 'extratemplate':
1960                                 $tabidx    = 600;
1961                                 $pluginfields = array();
1962                                 $manager->notify(
1963                                         'AdminTemplateExtraFields',
1964                                         array(
1965                                                 'fields' => &$pluginfields
1966                                         )
1967                                 );
1968                                 $tmplt = array();
1969                                 if ( $description )
1970                                 {
1971                                         $tmplt = Template::read($description);
1972                                 }
1973                                 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
1974                                 {
1975                                         $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
1976                                 }
1977                                 else
1978                                 {
1979                                         $base = "</tr>\n"
1980                                               . "<tr>\n"
1981                                               . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
1982                                 }
1983                                 foreach ( $pluginfields as $pfkey => $pfvalue )
1984                                 {
1985                                         $data = array(
1986                                                 'explugtplname' => Entity::hsc($pfkey)
1987                                         );
1988                                         echo TEMPLATE::fill($base, $data);
1989                                         foreach ( $pfvalue as $pffield => $pfdesc )
1990                                         {
1991                                                 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
1992                                         }
1993                                 }
1994                                 break;
1995                         default:
1996                                 $desc = defined($description) ? constant($description) : $description;
1997                                 $name = defined($name) ? constant($name) : $name;
1998                                 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
1999                                 break;
2000                 }
2001                 return;
2002         }
2003         
2004         /**
2005          * Actions::parse_editcomment()
2006          * Parse skinvar editcomment
2007          * 
2008          * @param       string  $type   type of comment setting
2009          * @return      void
2010          */
2011         public function parse_editcomment($type = 'id')
2012         {
2013                 global $manager;
2014                 $commentid      = intRequestVar('commentid');
2015                 $comment        = COMMENT::getComment($commentid);
2016                 
2017                 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2018                 
2019                 switch ( $type )
2020                 {
2021                         case 'id':
2022                                 echo intRequestVar('commentid');
2023                                 break;
2024                         case 'user':
2025                                 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2026                                 {
2027                                         echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2028                                 }
2029                                 else
2030                                 {
2031                                         echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2032                                 }
2033                                 break;
2034                         case 'date':
2035                                 echo date("Y-m-d @ H:i", $comment['timestamp']);
2036                                 break;
2037                         case 'body':
2038                                 $comment['body'] = str_replace('<br />', '', $comment['body']);
2039                                 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2040                                 echo $comment['body'];
2041                         default:
2042                                 echo $comment[$type];
2043                                 break;
2044                 }
2045                 return;
2046         }
2047         
2048         /**
2049          * Actions::parse_editdesturl()
2050          * Parse skinvar editdesturl
2051          */
2052         public function parse_editdesturl()
2053         {
2054                 if ( requestVar('desturl') )
2055                 {
2056                         echo Entity::hsc(requestVar('desturl'));
2057                 }
2058                 return;
2059         }
2060         
2061         /**
2062          * Actions::parse_editmemberlist()
2063          * Parse skinvar editmemberlist
2064          * 
2065          * @param       string  $templateName   name of template
2066          * @return      void
2067          */
2068         public function parse_editmemberlist($templateName = '')
2069         {
2070                 global $manager;
2071                 // show list of members with actions
2072                 $query =  'SELECT * FROM '.sql_table('member');
2073                 $template['content']  = 'memberlist';
2074                 $template['tabindex'] = 10;
2075                 
2076                 $batch = new Batch('member');
2077                 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2078                 return;
2079         }
2080         
2081         /**
2082          * AdminActions::parse_editmember()
2083          * Parse skinvar editmember
2084          * 
2085          * @param       string  $type                   type of information for member
2086          * @return      string  $tempateName    name of template to use
2087          * @return      void
2088          */
2089         public function parse_editmember($type = 'id', $templateName = '')
2090         {
2091                 global $CONF, $manager, $member;
2092                 $memberid       = intRequestVar('memberid');
2093                 $mem            = MEMBER::createFromID($memberid);
2094                 
2095                 switch ( $type )
2096                 {
2097                         case 'id':
2098                                 echo intRequestVar('memberid');
2099                                 break;
2100                         case 'displayname':
2101                                 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2102                                 {
2103                                         echo ENTITY::hsc($mem->getDisplayName(), ENT_QUOTES);
2104                                 }
2105                                 else
2106                                 {
2107                                         $dispName = ENTITY::hsc($mem->getDisplayName(), ENT_QUOTES);
2108                                         if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2109                                         {
2110                                                 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2111                                         }
2112                                         else
2113                                         {
2114                                                 echo $dispName;
2115                                         }
2116                                 }
2117                                 break;
2118                         case 'realname':
2119                                 echo ENTITY::hsc($mem->getRealName(), ENT_QUOTES);
2120                                 break;
2121                         case 'email':
2122                                 echo ENTITY::hsc($mem->getEmail(), ENT_QUOTES);
2123                                 break;
2124                         case 'url':
2125                                 echo ENTITY::hsc($mem->getURL(), ENT_QUOTES);
2126                                 break;
2127                         case 'admin':
2128                                 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2129                                 break;
2130                         case 'canlogin':
2131                                 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2132                                 break;
2133                         case 'notes':
2134                                 echo ENTITY::hsc($mem->getNotes(), ENT_QUOTES);
2135                                 break;
2136                         case 'autosave':
2137                                 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2138                                 break;
2139                         default:
2140                                 break;
2141                 }
2142                 return;
2143         }
2144         
2145         /**
2146          * Actions::parse_editpluginfo()
2147          * Parse skinvar editpluginfo
2148          * 
2149          * @param       string  $type   type of plugin info
2150          * @return      void
2151          */
2152         public function parse_editpluginfo($type)
2153         {
2154                 $pid = intRequestVar('plugid');
2155                 switch ( $type )
2156                 {
2157                         case 'id':
2158                                 echo $pid;
2159                                 break;
2160                         case 'name':
2161                                 echo Entity::hsc(getPluginNameFromPid($pid));
2162                                 break;
2163                 }
2164                 return;
2165         }
2166         
2167         /**
2168          * Actions::parse_editplugoptionslist()
2169          * Parse skinvar editplugoptionslist
2170          * 
2171          * @param       string  $templateName   name of template
2172          * @return      void
2173          */
2174         public function parse_editplugoptionslist($templateName = '')
2175         {
2176                 global $manager;
2177                 
2178                 $pid = intRequestVar('plugid');
2179                 $aOptions = array();
2180                 $aOIDs  = array();
2181                 
2182                 $query  = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2183                 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2184                 $resource = sql_query($query);
2185                 
2186                 while ( $o = sql_fetch_object($resource) )
2187                 {
2188                         array_push($aOIDs, $o->oid);
2189                         $aOptions[$o->oid] = array(
2190                                 
2191                                 'oid'                   => $o->oid,
2192                                 'value'                 => $o->odef,
2193                                 'name'                  => $o->oname,
2194                                 'description'   => $o->odesc,
2195                                 'type'                  => $o->otype,
2196                                 'typeinfo'              => $o->oextra,
2197                                 'contextid'             => 0
2198                         );
2199                 }
2200                 
2201                 // fill out actual values
2202                 if ( count($aOIDs) > 0 )
2203                 {
2204                         $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2205                         $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2206                         
2207                         $result = sql_query($query);
2208                         
2209                         while ( $o = sql_fetch_object($result) )
2210                         {
2211                                 $aOptions[$o->oid]['value'] = $o->ovalue;
2212                         }
2213                 }
2214                 
2215                 // call plugins
2216                 $manager->notify(
2217                         'PrePluginOptionsEdit',
2218                         array(
2219                                 'context'       =>  'global',
2220                                 'plugid'        =>  $pid,
2221                                 'options'       => &$aOptions
2222                         )
2223                 );
2224                 
2225                 $template['content'] = 'plugoptionlist';
2226                 $amount                   = Showlist($aOptions, 'table', $template, $templateName);
2227                 if ( $amount == 0 )
2228                 {
2229                         echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2230                 }
2231                 return;
2232         }
2233         
2234         /**
2235          * Actions::parse_editskin()
2236          * Parse skinvar editskin
2237          * 
2238          * @param       string  $type   type of skin
2239          * @return      void
2240          */
2241         public function parse_editskin($type = 'id')
2242         {
2243                 $skinid = intRequestVar('skinid');
2244                 $skin   = new SKIN($skinid);
2245                 switch ( $type )
2246                 {
2247                         case 'id':
2248                                 echo intRequestVar('skinid');
2249                                 break;
2250                         case 'name':
2251                                 echo Entity::hsc($skin->getName());
2252                                 break;
2253                         case 'desc':
2254                                 echo Entity::hsc($skin->getDescription());
2255                                 break;
2256                         case 'type':
2257                                 echo Entity::hsc($skin->getContentType());
2258                                 break;
2259                         case 'prefix':
2260                                 echo Entity::hsc($skin->getIncludePrefix());
2261                                 break;
2262                         case 'mode':
2263                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2264                         default:
2265                                 break;
2266                 }
2267                 return;
2268         }
2269         
2270         /**
2271          * Actions::parse_editskintype()
2272          * Parse skinvar editskintype
2273          * 
2274          * @param       string  $type   name of type for skin type
2275          * @return      void
2276          */
2277         public function parse_editskintype($type = 'id')
2278         {
2279                 global $CONF, $manager, $member;
2280                 $skinid = intRequestVar('skinid');
2281                 $skin   = new SKIN($skinid);
2282                 $fNames = SKIN::getFriendlyNames();
2283                 $sType  = strtolower(trim(requestVar('type')));
2284                 
2285                 switch ( $type )
2286                 {
2287                         case 'id':
2288                                 echo intRequestVar('skinid');
2289                                 break;
2290                         case 'name':
2291                                 echo Entity::hsc($skin->getName());
2292                                 break;
2293                         case 'desc':
2294                                 echo Entity::hsc($skin->getDescription());
2295                                 break;
2296                         case 'type':
2297                                 echo Entity::hsc($skin->getContentType());
2298                                 break;
2299                         case 'content':
2300                                 echo Entity::hsc($skin->getContent($sType));
2301                                 break;
2302                         case 'skintype':
2303                                 $skinType = isset($fNames[$sType]) ? $fNames[$sType] : ucfirst($sType);
2304                                 echo Entity::hsc($skinType);
2305                                 break;
2306                         case 'skintyperaw':
2307                                 echo Entity::hsc($sType);
2308                                 break;
2309                         case 'prefix':
2310                                 echo Entity::hsc($skin->getIncludePrefix());
2311                                 break;
2312                         case 'mode':
2313                                 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2314                                 echo Entity::hsc($incMode);
2315                                 break;
2316                         default:
2317                                 break;
2318                 }
2319                 return;
2320         }
2321         
2322         /**
2323          * Actions::parse_edittemplateinfo()
2324          * Parse skinvar edittemplateinfo
2325          * 
2326          * @param       string  $type                   name of type for skin
2327          * @param       string  $description    description for skin
2328          * @param       string  $name                   name of skin
2329          * @param       string  $help                   
2330          * @param       string  $tabindex               index value for tabindex attribute of input element
2331          * @param       string  $big                    
2332          * @param       string  $tplt                   name of template
2333          */
2334         public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2335         {
2336                 global $manager;
2337                 $templateid                             =  intRequestVar('templateid');
2338                 $templatename                   =  TEMPLATE::getNameFromId($templateid);
2339                 $templatedescription    =  TEMPLATE::getDesc($templateid);
2340                 $template                               =& $manager->getTemplate($templatename);
2341                 switch ( $type )
2342                 {
2343                         case 'id':
2344                                 echo intval($templateid);
2345                                 break;
2346                         case 'name':
2347                                 echo Entity::hsc($templatename);
2348                                 break;
2349                         case 'desc':
2350                                 echo Entity::hsc($templatedescription);
2351                                 break;
2352                         case 'extratemplate':
2353                                 $tabidx    = 600;
2354                                 $pluginfields = array();
2355                                 $manager->notify(
2356                                         'TemplateExtraFields',
2357                                         array(
2358                                                 'fields' => &$pluginfields
2359                                         )
2360                                 );
2361                                 $tmplt = array();
2362                                 if ( $description )
2363                                 {
2364                                         $tmplt = Template::read($description);
2365                                 }
2366                                 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2367                                 {
2368                                         $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2369                                 }
2370                                 else
2371                                 {
2372                                         $base = "</tr><tr>\n"
2373                                                   . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2374                                 }
2375                                 foreach ( $pluginfields as $pfkey => $pfvalue )
2376                                 {
2377                                         $data = array(
2378                                                 'explugtplname' => Entity::hsc($pfkey)
2379                                         );
2380                                         echo TEMPLATE::fill($base, $data);
2381                                         foreach ( $pfvalue as $pffield => $pfdesc )
2382                                         {
2383                                                 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2384                                         }
2385                                 }
2386                                 break;
2387                         default:
2388                                 $desc = defined($description) ? constant($description) : $description;
2389                                 $name = defined($name) ? constant($name) : $name;
2390                                 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2391                                 break;
2392                 }
2393                 return;
2394         }
2395         
2396         /**
2397          * Actions::parse_eventformextra()
2398          * Parse skinvar eventformextra
2399          * 
2400          * @param       string  $type   name of type for event form extra
2401          * @return      void
2402          */
2403         public function parse_eventformextra($type = 'activation')
2404         {
2405                 global $manager;
2406                 switch ( $type )
2407                 {
2408                         case 'activation':
2409                                 $key = requestVar('ackey');
2410                                 if ( !$key )
2411                                 {
2412                                         $this->objAdmin->error(_ERROR_ACTIVATE);
2413                                 }
2414                                 $info = MEMBER::getActivationInfo($key);
2415                                 if ( !$info )
2416                                 {
2417                                         $this->objAdmin->error(_ERROR_ACTIVATE);
2418                                 }
2419                                 $mem  = MEMBER::createFromId($info->vmember);
2420                                 if ( !$mem )
2421                                 {
2422                                         $this->objAdmin->error(_ERROR_ACTIVATE);
2423                                 }
2424                                 $data = array(
2425                                         'type'   => 'activation',
2426                                         'member' => $mem
2427                                 );
2428                                 break;
2429                         case 'membermailform-notloggedin':
2430                                 $data = array(
2431                                         'type' => 'membermailform-notloggedin',
2432                                 );
2433                                 break;
2434                 }
2435                 $manager->notify('FormExtra', $data);
2436                 return;
2437         }
2438         
2439         /**
2440          * Actions::parse_extrahead()
2441          * Parse skinvar extrahead
2442          */
2443         public function parse_extrahead()
2444         {
2445                 global $manager;
2446                 $extrahead = $this->objAdmin->extrahead;
2447                 $manager->notify(
2448                         'AdminPrePageHead',
2449                         array(
2450                                 'extrahead'     => &$extrahead,
2451                                 'action'        => $this->objAdmin->action
2452                         )
2453                 );
2454                 echo $extrahead;
2455                 return;
2456         }
2457         
2458         /**
2459          * AdminActions::parse_getblogsetting()
2460          * Parse skinvar getblogsetting
2461          */
2462         public function parse_getblogsetting($which)
2463         {
2464                 global $blog;
2465                 
2466                 if ( $blog )
2467                 {
2468                         $b =& $blog;
2469                 }
2470                 elseif ( $bid = intRequestVar('blogid') )
2471                 {
2472                         global $manager;
2473                         $b = $manager->getBlog($bid);
2474                 }
2475                 else
2476                 {
2477                         return;
2478                 }
2479                 
2480                 switch ( $which )
2481                 {
2482                         case 'id':
2483                                 return ENTITY::hsc($b->getID(), ENT_QUOTES);
2484                                 break;
2485                         case 'url':
2486                                 return ENTITY::hsc($b->getURL(), ENT_QUOTES);
2487                                 break;
2488                         case 'name':
2489                                 return ENTITY::hsc($b->getName(), ENT_QUOTES);
2490                                 break;
2491                         case 'desc':
2492                                 return ENTITY::hsc($b->getDescription(), ENT_QUOTES);
2493                                 break;
2494                         case 'short':
2495                                 return ENTITY::hsc($b->getShortName(), ENT_QUOTES);
2496                                 break;
2497                         case 'notifyaddress':
2498                                 return ENTITY::hsc($b->getNotifyAddress(), ENT_QUOTES);
2499                                 break;
2500                         case 'maxcomments':
2501                                 return ENTITY::hsc($b->getMaxComments(), ENT_QUOTES);
2502                                 break;
2503                         case 'updatefile':
2504                                 return ENTITY::hsc($b->getUpdateFile(), ENT_QUOTES);
2505                                 break;
2506                         case 'timeoffset':
2507                                 return ENTITY::hsc($b->getTimeOffset(), ENT_QUOTES);
2508                                 break;
2509                 }
2510                 return;
2511         }
2512         
2513         /**
2514          * Actions::parse_geteditpluginfo()
2515          * Parse skinvar geteditpluginfo
2516          * 
2517          * @param       string  $type   name of setting for edit plugin info
2518          * @return      void
2519          */
2520         public function parse_geteditpluginfo($type)
2521         {
2522                 $pid = intRequestVar('plugid');
2523                 switch ( $type )
2524                 {
2525                         case 'id':
2526                                 return $pid;
2527                                 break;
2528                         case 'name':
2529                                 return Entity::hsc(getPluginNameFromPid($pid));
2530                                 break;
2531                 }
2532                 return;
2533         }
2534         
2535         /**
2536          * Actions::parse_getmember()
2537          * Parse skinvar getmember
2538          * (includes a member info thingie)
2539          * 
2540          * @param       string  $what   name of setting for member
2541          * @return      void
2542          */
2543         public function parse_getmember($what)
2544         {
2545                 global $memberinfo, $member;
2546                 // 1. only allow the member-details-page specific variables on member pages
2547                 if ( $this->skintype == 'member' )
2548                 {
2549                         switch ( $what )
2550                         {
2551                                 case 'name':
2552                                         return Entity::hsc($memberinfo->getDisplayName());
2553                                         break;
2554                                 case 'realname':
2555                                         return Entity::hsc($memberinfo->getRealName());
2556                                         break;
2557                                 case 'notes':
2558                                         return Entity::hsc($memberinfo->getNotes());
2559                                         break;
2560                                 case 'url':
2561                                         return Entity::hsc($memberinfo->getURL());
2562                                         break;
2563                                 case 'email':
2564                                         return Entity::hsc($memberinfo->getEmail());
2565                                         break;
2566                                 case 'id':
2567                                         return Entity::hsc($memberinfo->getID());
2568                                         break;
2569                         }
2570                 }
2571                 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2572                 if ( $member->isLoggedIn() )
2573                 {
2574                         switch ( $what )
2575                         {
2576                                 case 'yourname':
2577                                         return $member->getDisplayName();
2578                                         break;
2579                                 case 'yourrealname':
2580                                         return $member->getRealName();
2581                                         break;
2582                                 case 'yournotes':
2583                                         return $member->getNotes();
2584                                         break;
2585                                 case 'yoururl':
2586                                         return $member->getURL();
2587                                         break;
2588                                 case 'youremail':
2589                                         return $member->getEmail();
2590                                         break;
2591                                 case 'yourid':
2592                                         return $member->getID();
2593                                         break;
2594                         }
2595                 }
2596                 return;
2597         }
2598         
2599         /**
2600          * Actions::parse_headmessage()
2601          * Parse skinvar headmessage
2602          * 
2603          * @param       void
2604          * @return      void
2605          */
2606         public function parse_headmessage()
2607         {
2608                 if ( !empty($this->objAdmin->headMess) )
2609                 {
2610                         echo '<p>' . _MESSAGE . ': ' . Entity::hsc($this->objAdmin->headMess) . "</p>\n";
2611                 }
2612                 return;
2613         }
2614         
2615         /**
2616          * Actions::parse_helplink()
2617          * Parse skinvar helplink
2618          * 
2619          * @param       string  $topic  name of topic for help
2620          * @return      void
2621          */
2622         public function parse_helplink($topic = '')
2623         {
2624                 if ( empty($topic) )
2625                 {
2626                         return;
2627                 }
2628                 help($topic);
2629                 return;
2630         }
2631         
2632         /**
2633          * Actions::parse_helpplugname()
2634          * Parse skinvar helpplugname
2635          * 
2636          * @param       void
2637          * @return      void
2638          */
2639         public function parse_helpplugname()
2640         {
2641                 $plugid = intGetVar('plugid');
2642                 Entity::hsc(getPluginNameFromPid($plugid));
2643                 return;
2644         }
2645         
2646         /**
2647          * Actions::parse_ilistaddnew()
2648          * Parse skinvar ilistaddnew
2649          * 
2650          * @param       void
2651          * @return      void
2652          */
2653         public function parse_ilistaddnew()
2654         {
2655                 $blogid = intRequestVar('blogid');
2656                 if ( intPostVar('start') == 0 )
2657                 {
2658                         echo '<p><a href="index.php?action=createitem&amp;blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
2659                 }
2660                 return;
2661         }
2662         
2663         /**
2664          * Actions::parse_importskininfo()
2665          * Parse skinvar importskininfo
2666          * 
2667          * @param       string  $type   name of information for imported skin
2668          * @return      void
2669          */
2670         public function parse_importskininfo($type)
2671         {
2672                 switch ( $type )
2673                 {
2674                         case 'info':
2675                                 echo Entity::hsc(requestVar('skininfo'));
2676                                 break;
2677                         case 'snames':
2678                                 $dataArr = requestArray('skinnames');
2679                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
2680                                 break;
2681                         case 'tnames':
2682                                 $dataArr = requestArray('tpltnames');
2683                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
2684                                 break;
2685                         case 'sclashes':
2686                                 $dataArr = requestArray('skinclashes');
2687                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
2688                                 break;
2689                         case 'tclashes':
2690                                 $dataArr = requestArray('tpltclashes');
2691                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
2692                                 break;
2693                         case 'skinfile':
2694                                 echo Entity::hsc(requestVar('skinfile'));
2695                                 break;
2696                         case 'mode':
2697                                 echo Entity::hsc(requestVar('mode'));
2698                                 break;
2699                 }
2700                 return;
2701         }
2702         
2703         /**
2704          * Actions::parse_inputyesno()
2705          * Parse skinvar inputyesno
2706          * 
2707          * @param       string  $name                   
2708          * @param       string  $checkedval             
2709          * @param       string  $tabindex               
2710          * @param       string  $value1                 
2711          * @param       string  $value2                 
2712          * @param       string  $yesval                 
2713          * @param       string  $noval                  
2714          * @param       string  $isAdmin                
2715          * @param       string  $templateName   
2716          * @return      void
2717          */
2718         public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
2719         {
2720                 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
2721                 return;
2722         }
2723         
2724         /**
2725          * Actions::parse_insertpluginfo()
2726          * Parse templatevar insertpluginfo
2727          */
2728         public function parse_insertpluginfo($type)
2729         {
2730                 $option = $this->objAdmin;
2731                 switch ( $type )
2732                 {
2733                         case 'id':
2734                                 return $option['pid'];
2735                                 break;
2736                         case 'name':
2737                                 return Entity::hsc($option['pfile']);
2738                                 break;
2739                 }
2740                 return;
2741         }
2742         
2743         /**
2744          * Actions::parse_insertpluginoptions()
2745          * Parse skinvar insertpluginoptions
2746          * 
2747          * @param       string  $templateName   name of template
2748          * @return      void
2749          */
2750         public function parse_insertpluginoptions($templateName = '')
2751         {
2752                 $options        = $this->objAdmin->aOptions;
2753                 $template       = array();
2754                 $templats       = array();
2755                 
2756                 if ( $templateName )
2757                 {
2758                         $templates = Template::read($templateName);
2759                 }
2760                 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
2761                 {
2762                         $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
2763                 }
2764                 else
2765                 {
2766                         $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
2767                 }
2768                 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
2769                 {
2770                         $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
2771                 }
2772                 else
2773                 {
2774                         $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
2775                 }
2776                 
2777                 $prevPid = -1;
2778                 
2779                 foreach ( $options as $option )
2780                 {
2781                         $handler = new Actions($this->skintype, $template, $option);
2782                         $parser  = new PARSER(Actions::getDefinedActions(), $handler);
2783                         // new plugin?
2784                         if ( $prevPid != $option['pid'] )
2785                         {
2786                                 $prevPid  = $option['pid'];
2787                                 $parser->parse($template['title']);
2788                         }
2789                         $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
2790                         if ( @$meta['access'] != 'hidden' )
2791                         {
2792                                 $parsed = $parser->parse($template['body']);
2793                         }
2794                 }
2795                 return;
2796         }
2797         
2798         /**
2799          * Actions::parse_insplugoptcontent()
2800          * Parse skinvar insplugoptcontent
2801          * 
2802          * @param       void
2803          * @return      void
2804          */
2805         public function parse_insplugoptcontent()
2806         {
2807                 $option = $this->objAdmin->aOption;
2808                 
2809                 $meta   = NucleusPlugin::getOptionMeta($option['typeinfo']);
2810                 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
2811                 {
2812                         echo '<tr>';
2813                         listplug_plugOptionRow($option);
2814                         echo '</tr>';
2815                 }
2816                 return;
2817         }
2818         
2819         /**
2820          * Actions::parse_iprangeinput()
2821          * Parse skinvar iprangeinput
2822          * 
2823          * @param       void
2824          * @return      void
2825          */
2826         public function parse_iprangeinput()
2827         {
2828                 if ( requestVar('ip') )
2829                 {
2830                         $iprangeVal = Entity::hsc(requestVar('ip'));
2831                         echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
2832                         echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
2833                         echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
2834                         echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
2835                         echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
2836                 }
2837                 else
2838                 {
2839                         echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
2840                         echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
2841                 }
2842                 return;
2843         }
2844         
2845         /**
2846          * Actions::parse_itemnavlist()
2847          * Parse skinvar itemnavlist
2848          * 
2849          * @param       void
2850          * @return      void
2851          */
2852         public function parse_itemnavlist()
2853         {
2854                 global $CONF, $manager, $member;
2855                 if ( $this->skintype == 'itemlist' )
2856                 {
2857                         $blogid =  intRequestVar('blogid');
2858                         $blog   =& $manager->getBlog($blogid);
2859                 }
2860                 if ( postVar('start') )
2861                 {
2862                         $start = intPostVar('start');
2863                 }
2864                 else
2865                 {
2866                         $start = 0;
2867                 }
2868                 
2869                 // amount of items to show
2870                 if ( postVar('amount') )
2871                 {
2872                         $amount = intPostVar('amount');
2873                 }
2874                 else
2875                 {
2876                         $amount = intval($CONF['DefaultListSize']);
2877                         if ( $amount < 1 )
2878                         {
2879                                 $amount = 10;
2880                         }
2881                 }
2882                 $query  = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
2883                         . " FROM %s, %s, %s"
2884                         . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid;";
2885                 
2886                 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
2887                 
2888                 if ( $this->skintype == 'itemlist' )
2889                 {
2890                         $query .= 'and iblog   = ' . $blogid;
2891                         $template['now'] = $blog->getCorrectTime(time());
2892                         
2893                         // non-blog-admins can only edit/delete their own items
2894                         if ( !$member->blogAdminRights($blogid) )
2895                         {
2896                                 $query .= ' and iauthor = ' . $member->getID();
2897                         }
2898                 }
2899                 elseif ( $this->skintype == 'browseownitems' )
2900                 {
2901                         $query .= 'and iauthor   = ' . $member->getID();
2902                         $blogid = 0;
2903                         $template['now'] = time();
2904                 }
2905                 
2906                 // search through items
2907                 $search = postVar('search');
2908                 
2909                 if ( !empty($search) )
2910                 {
2911                         $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
2912                                 . '  OR  (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
2913                                 . '  OR  (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
2914                 }
2915                 $query .= ' ORDER BY itime DESC'
2916                         . " LIMIT {$start},{$amount}";
2917                 
2918                 $template['content'] = 'itemlist';
2919                 
2920                 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
2921                 $navList->showBatchList('item', $query, 'table', $template);
2922                 return;
2923         }
2924         
2925         /**
2926          * Actions::parse_jstoolbaroptions()
2927          * Parse skinvar jstoolbaroptions
2928          * 
2929          * @param       void
2930          * @return      void
2931          */
2932         public function parse_jstoolbaroptions()
2933         {
2934                 global $CONF;
2935                 $options = array(
2936                         _SETTINGS_JSTOOLBAR_NONE,
2937                         _SETTINGS_JSTOOLBAR_SIMPLE,
2938                         _SETTINGS_JSTOOLBAR_FULL
2939                 );
2940                 $i = 1;
2941                 foreach ( $options as $option )
2942                 {
2943                         $text  = "<option value=\"%d\"%s>%s</option>\n";
2944                         $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
2945                         echo sprintf($text, $i, $extra, $option);
2946                         $i++;
2947                 }
2948                 return;
2949         }
2950         
2951         /**
2952          * Actions::parse_localeselectoptions()
2953          * Parse skinvar localeselectoptions
2954          * 
2955          * @param       void
2956          * @return      void
2957          */
2958         public function parse_localeselectoptions()
2959         {
2960                 $locales = i18n::get_available_locale_list();
2961                 $memid   = intRequestVar('memberid');
2962                 if ( $memid )
2963                 {
2964                         $mem = MEMBER::createFromID($memid);
2965                         if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
2966                         {
2967                                 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
2968                         }
2969                         else
2970                         {
2971                                 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
2972                         }
2973                 }
2974                 else
2975                 {
2976                         if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
2977                         {
2978                                 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
2979                         }
2980                 }
2981                 foreach ( $locales as $locale )
2982                 {
2983                         if ($memid)
2984                         {
2985                                 if ( $locale == $mem->getLocale() )
2986                                 {
2987                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
2988                                 }
2989                                 else
2990                                 {
2991                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
2992                                 }
2993                         }
2994                         else
2995                         {
2996                                 if ( $locale == i18n::get_current_locale() )
2997                                 {
2998                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
2999                                 }
3000                                 else
3001                                 {
3002                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
3003                                 }
3004                         }
3005                 }
3006                 return;
3007         }
3008         
3009         /**
3010          * Actions::parse_listplugplugoptionrow()
3011          * Parse templatevar listplugplugoptionrow
3012          * 
3013          * @param       string  $templateName   name of template
3014          * @return      void
3015          */
3016         public function parse_listplugplugoptionrow($templateName = '')
3017         {
3018                 $option = $this->objAdmin;
3019                 echo listplug_plugOptionRow($option, $templateName);
3020                 return;
3021         }
3022         
3023         /**
3024          * Actions::parse_mediadirwarning()
3025          * Parse skinvar mediadirwarning
3026          * 
3027          * @param       void
3028          * @return      void
3029          */
3030         public function parse_mediadirwarning()
3031         {
3032                 global $DIR_MEDIA;
3033                 if ( !is_dir($DIR_MEDIA) )
3034                 {
3035                         echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3036                 }
3037                 if ( !is_readable($DIR_MEDIA) )
3038                 {
3039                         echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3040                 }
3041                 if ( !is_writeable($DIR_MEDIA) )
3042                 {
3043                         echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3044                 }
3045                 return;
3046         }
3047         
3048         /**
3049          * Actions::parse_movedistselect()
3050          * Parse skinvar movedistselect
3051          */
3052         public function parse_movedistselect()
3053         {
3054                 $actionType = requestVar('action');
3055                 switch ( $actionType )
3056                 {
3057                         case 'batchitem':
3058                                 $this->objAdmin->selectBlogCategory('destcatid');
3059                                 break;
3060                         case 'batchcategory':
3061                                 $this->objAdmin->selectBlog('destblogid');
3062                                 break;
3063                         default:
3064                                 if ( $this->skintype == 'itemmove' )
3065                                 {
3066                                         $query  = "SELECT icat as result FROM %s WHERE inumber=%d;";
3067                                         $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
3068                                         $catid  = quickQuery(sprintf($query, intRequestVar('itemid')));
3069                                         $this->objAdmin->selectBlogCategory('catid', $catid, 10, 1);
3070                                 }
3071                                 break;
3072                 }
3073                 return;
3074         }
3075         
3076         /**
3077          * Actions::parse_moveitemid()
3078          * Parse skinvar moveitemid
3079          * 
3080          * @param       void
3081          * @return      void
3082          */
3083         public function parse_moveitemid()
3084         {
3085                 echo intRequestVar('itemid');
3086                 return;
3087         }
3088         
3089         /**
3090          * Actions::parse_newestcompare()
3091          * Parse skinvar newestcompare
3092          * 
3093          * @param       void
3094          * @return      void
3095          */
3096         public function parse_newestcompare()
3097         {
3098                 global $nucleus;
3099                 $newestVersion  = getLatestVersion();
3100                 $newestCompare  = str_replace('/', '.', $newestVersion);
3101                 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3102                 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3103                 {
3104                         echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3105                         echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3106                 }
3107                 return;
3108         }
3109         
3110         /**
3111          * Actions::parse_newmemberselect()
3112          * Parse skinvar newmemberselect
3113          * 
3114          * @param       string  $templateName   name of template to use
3115          * @return      void
3116          */
3117         public function parse_newmemberselect($templateName = '')
3118         {
3119                 $blogid = intRequestVar('blogid');
3120                 
3121                 $query  = "SELECT tmember FROM %s WHERE tblog=%d;";
3122                 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3123                 $res = sql_query($query);
3124                 
3125                 $tmem = array();
3126                 while ( $tmember = sql_fetch_object($res) ) 
3127                 {
3128                         $tmem[] = intval($tmember->tmember);
3129                 }
3130                 
3131                 $query  = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3132                 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3133                 
3134                 $template['name']        = 'memberid';
3135                 $template['tabindex'] = 10000;
3136                 Showlist($query, 'select', $template, $templateName);
3137                 return;
3138         }
3139         
3140         /**
3141          * Actions::parse_newpluginlist()
3142          * Parse skinvar newpluginlist
3143          * 
3144          * @param       void
3145          * @return      void
3146          */
3147         public function parse_newpluginlist()
3148         {
3149                 $candidates = $this->newPlugCandidates;
3150                 foreach ( $candidates as $name )
3151                 {
3152                         echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3153                 }
3154                 return;
3155         }
3156         
3157         /**
3158          * Actions::parse_outputspecialdirs()
3159          * Parse skinvar outputspecialdirs
3160          * 
3161          * @param       string  $type   type of setting for directory
3162          * @return      void
3163          */
3164         public function parse_outputspecialdirs($type)
3165         {
3166                 switch ( $type )
3167                 {
3168                         case 'nucleusdir':
3169                                 global $DIR_NUCLEUS;
3170                                 echo Entity::hsc($DIR_NUCLEUS);
3171                                 break;
3172                         case 'mediadir':
3173                                 global $DIR_MEDIA;
3174                                 echo Entity::hsc($DIR_MEDIA);
3175                                 break;
3176                 }
3177                 return;
3178         }
3179         
3180         /**
3181          * Actions::parse_passrequestvars()
3182          * Parse skinvar passrequestvars
3183          * 
3184          * @param       void
3185          * @return      void
3186          */
3187         public function parse_passrequestvars()
3188         {
3189                 $oldaction = postVar('oldaction');
3190                 if ( ($oldaction != 'logout')
3191                   && ($oldaction != 'login')
3192                   && $this->objAdmin->passvar
3193                   && !postVar('customaction') )
3194                 {
3195                         passRequestVars();
3196                 }
3197                 return;
3198         }
3199         
3200         /**
3201          * Actions::parse_pluginextras()
3202          * Parse skinvar pluginextras
3203          * 
3204          * @param       string  $type   type of plugin context
3205          * @return      void
3206          */
3207         public function parse_pluginextras($type = 'global')
3208         {
3209                 global $manager;
3210                 switch ( $type )
3211                 {
3212                         case 'member':
3213                                 $id  = intRequestVar('memberid');
3214                                 $mem = MEMBER::createFromID($id);
3215                                 $manager->notify(
3216                                         'MemberSettingsFormExtras',
3217                                         array(
3218                                                 'member' => &$mem
3219                                         )
3220                                 );
3221                                 break;
3222                         case 'blog':
3223                                 $id  = intRequestVar('blogid');
3224                                 $blg = $manager->getBlog($id);
3225                                 $manager->notify(
3226                                         'BlogSettingsFormExtras',
3227                                         array(
3228                                                 'member' => &$blg
3229                                         )
3230                                 );
3231                                 break;
3232                         default:
3233                                 $manager->notify(
3234                                         'GeneralSettingsFormExtras',
3235                                         array(
3236                                         )
3237                                 );
3238                                 break;
3239                 }
3240                 return;
3241         }
3242         
3243         /**
3244          * Actions::parse_pluginhelp()
3245          * Parse skinvar pluginhelp
3246          * 
3247          * @param       void
3248          * @return      void
3249          */
3250         public function parse_pluginhelp()
3251         {
3252                 global $manager, $DIR_PLUGINS;
3253                 $plugid = intGetVar('plugid');
3254                 $plugName =  getPluginNameFromPid($plugid);
3255                 $plug =& $manager->getPlugin($plugName);
3256                 
3257                 if ( $plug->supportsFeature('HelpPage') > 0 )
3258                 {
3259                         $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3260                         if ( @file_exists($helpfile . 'php') )
3261                         {
3262                                 @include($helpfile . 'php');
3263                                 return;
3264                         }
3265                         elseif ( @file_exists($helpfile . 'html') )
3266                         {
3267                                 @include($helpfile . 'html');
3268                                 return;
3269                         }
3270                 }
3271                 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3272                 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3273                 return;
3274         }
3275         
3276         /**
3277          * Actions::parse_pluginlistlist()
3278          * Parse skinvar pluginlistlist
3279          * 
3280          * @param       string  $templateName   name of template to use
3281          * @return      void
3282          */
3283         public function parse_pluginlistlist($templateName = '')
3284         {
3285                 $query  = "SELECT * FROM %s ORDER BY porder ASC;";
3286                 $query = sprintf($query, sql_table('plugin'));
3287                 $template['content']  = 'pluginlist';
3288                 $template['tabindex'] = 10;
3289                 Showlist($query, 'table', $template, $templateName);
3290                 return;
3291         }
3292         
3293         /**
3294          * Actions::parse_pluginoptions()
3295          * Parse skinvar pluginoptions
3296          * 
3297          * @param       string  $type   type of plugin option
3298          * @return      void
3299          */
3300         public function parse_pluginoptions($type = 'global')
3301         {
3302                 switch ( $type )
3303                 {
3304                         case 'member':
3305                                 $id = intRequestVar('memberid');
3306                                 break;
3307                         case 'blog':
3308                                 $id = intRequestVar('blogid');
3309                                 break;
3310                         case 'category':
3311                                 $id = intRequestVar('catid');
3312                                 break;
3313                 }
3314                 $this->objAdmin->_insertPluginOptions($type, $id);
3315                 return;
3316         }
3317         
3318         /**
3319          * Actions::parse_qmenuaddselect()
3320          * Parse skinvar qmanuaddselect
3321          * 
3322          * @param       string  $templateName   name of template to use
3323          * @return      void
3324          */
3325         public function parse_qmenuaddselect($templateName = '')
3326         {
3327                 global $member;
3328                 $showAll = requestVar('showall');
3329                 if ( $member->isAdmin() && ($showAll == 'yes') )
3330                 {
3331                         // Super-Admins have access to all blogs! (no add item support though)
3332                         $query =  'SELECT bnumber as value, bname as text'
3333                                . ' FROM ' . sql_table('blog')
3334                                . ' ORDER BY bname';
3335                 }
3336                 else
3337                 {
3338                         $query =  'SELECT bnumber as value, bname as text'
3339                                . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
3340                                . ' WHERE tblog=bnumber and tmember=' . $member->getID()
3341                                . ' ORDER BY bname';
3342                 }
3343                 $template['name']          = 'blogid';
3344                 $template['tabindex']   = 15000;
3345                 $template['extra']        = _QMENU_ADD_SELECT;
3346                 $template['selected']   = -1;
3347                 $template['shorten']    = 10;
3348                 $template['shortenel']  = '';
3349                 $template['javascript'] = 'onchange="return form.submit()"';
3350                 Showlist($query, 'select', $template, $templateName);
3351                 return;
3352         }
3353
3354         /**
3355          * Actions::parse_quickmenu()
3356          * Parse skinvar quickmenu
3357          * 
3358          * @param       string  $templateName   name of template to use
3359          * @return      void
3360          */
3361         public function parse_quickmenu($templateName = '')
3362         {
3363                 global $manager;
3364                 $templates = array();
3365                 $template  = array();
3366                 if ( !empty($templateName) )
3367                 {
3368                         $templates = Template::read($templateName);
3369                 }
3370                 $pluginExtras = array();
3371                 $manager->notify(
3372                         'QuickMenu',
3373                         array(
3374                                 'options' => &$pluginExtras
3375                         )
3376                 );
3377                 if ( count($pluginExtras) > 0 )
3378                 {
3379                         if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
3380                         {
3381                                 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
3382                         }
3383                         else
3384                         {
3385                                 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
3386                         }
3387                         $handler = new Actions($this->skintype, $template, $this->objAdmin);
3388                         $parser  = new PARSER(Actions::getDefinedActions(), $handler);
3389                         $parser->parse($template['title']);
3390                         
3391                         if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3392                         {
3393                                 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3394                         }
3395                         else
3396                         {
3397                                 $template['head'] = '<ul>';
3398                         }
3399                         
3400                         echo $template['head'];
3401                         
3402                         if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
3403                         {
3404                                 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3405                         }
3406                         else
3407                         {
3408                                 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
3409                         }
3410                         
3411                         foreach ( $pluginExtras as $aInfo )
3412                         {
3413                                 $data = array(
3414                                         'plugadminurl'          => Entity::hsc($aInfo['url']),
3415                                         'plugadmintooltip'      => Entity::hsc($aInfo['tooltip']),
3416                                         'plugadmintitle'        => Entity::hsc($aInfo['title']),
3417                                 );
3418                                 echo TEMPLATE::fill($template['body'], $data);
3419                         }
3420                         if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3421                         {
3422                                 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3423                         }
3424                         else
3425                         {
3426                                 $template['foot'] = '</ul>';
3427                         }
3428                         echo $template['foot'];
3429                 }
3430                 return;
3431         }
3432         
3433         /**
3434          * Actions::parse_requestblogid()
3435          * Parse skinvar requestblogid
3436          * 
3437          * @param       void
3438          * @return      void
3439          */
3440         public function parse_requestblogid()
3441         {
3442                 echo intRequestVar('blogid');
3443                 return;
3444         }
3445         
3446         /**
3447          * Actions::parse_requestiprange()
3448          * Parse skinvar requestiprange
3449          * 
3450          * @param       void
3451          * @return      void
3452          */
3453         public function parse_requestiprange()
3454         {
3455                 if ( requestVar('iprange') )
3456                 {
3457                         echo Entity::hsc(requestVar('iprange'));
3458                 }
3459                 elseif ( requestVar('ip') )
3460                 {
3461                         echo Entity::hsc(requestVar('ip'));
3462                 }
3463                 return;
3464         }
3465         
3466         /**
3467          * Actions::parse_selectlocaladminskinfiles()
3468          * Parse skinvar selectlocaladminskinfiles
3469          * 
3470          * @param       void
3471          * @return      void
3472          */
3473         public function parse_selectlocaladminskinfiles()
3474         {
3475                 global $DIR_ADMINSKINS, $manager;
3476                 $candidates = SkinImport::searchForCandidates($DIR_ADMINSKINS);
3477                 foreach ( $candidates as $skinname => $skinfile )
3478                 {
3479                         $html = Entit::hsc($skinfile);
3480                         echo '<option value="' . $html . '">' . $skinname . "</option>\n";
3481                 }
3482                 return;
3483         }
3484         
3485         /**
3486          * Actions::parse_selectlocalskinfiles()
3487          * Parse skinvar selectlocalskinfiles
3488          * 
3489          * @param       void
3490          * @return      void
3491          */
3492         public function parse_selectlocalskinfiles()
3493         {
3494                 global $DIR_SKINS;
3495                 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
3496                 foreach ( $candidates as $skinname => $skinfile )
3497                 {
3498                         $html = Entity::hsc($skinfile);
3499                         echo '<option value="' . $html . '">' . $skinname . "</option>\n";
3500                 }
3501                 return;
3502         }
3503         
3504         /**
3505          * Actions::parse_skineditallowedlist()
3506          * Parse skinvar skineditallowedlist
3507          * 
3508          * @param       string  $type                   type of skin
3509          * @param       string  $templateName   name of template
3510          * @return      void
3511          */
3512         public function parse_skineditallowedlist($type, $templateName = '')
3513         {
3514                 switch ( $type )
3515                 {
3516                         case 'blog':
3517                                 $query = "SELECT bshortname, bname FROM %s";
3518                                 $show  = array(
3519                                         'content' => 'shortblognames'
3520                                 );
3521                                 $query = sprintf($query, sql_table('blog'));
3522                                 Showlist($query, 'table', $show, $templateName);
3523                                 break;
3524                         case 'template':
3525                                 $query = "SELECT tdname as name, tddesc as description FROM %s";
3526                                 $show  = array(
3527                                         'content' => 'shortnames'
3528                                 );
3529                                 $query = sprintf($query, sql_table('template_desc'));
3530                                 Showlist($query, 'table', $show, $templateName);
3531                                 break;
3532                 }
3533                 return;
3534         }
3535         
3536         /**
3537          * Actions::parse_skinfile()
3538          * Inserts an url relative to the skindir (useful when doing import/export)
3539          *
3540          * e.g. <skinfile(default/myfile.sth)>
3541          * 
3542          * @param       string  $filename       file name for skin
3543          * @return      void
3544          */
3545         public function parse_skinfile($filename)
3546         {
3547                 /*
3548                  * TODO: we should decide to use different directory or default $DIR_SKINS
3549                 $base = NP_SkinableAdmin::getAdminSkinURL();
3550                 $pref = PARSER::getProperty('IncludePrefix');
3551                 echo $base . $pref . $filename;
3552                  */
3553                 $pref = PARSER::getProperty('IncludePrefix');
3554                 echo $pref . $filename;
3555                 return;
3556         }
3557         
3558         /**
3559          * Actions::parse_skinielist()
3560          * Parse skinvar skinielist
3561          * 
3562          * @param       string  $type                   type of skin
3563          * @param       string  $templateName   name of template to use
3564          * @return      void
3565          */
3566         public function parse_skinielist($type, $templateName = '')
3567         {
3568                 $templates = array();
3569                 if ( $templateName )
3570                 {
3571                         $templates = Template::read($templateName);
3572                 }
3573                 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
3574                 {
3575                         $template = $templates['SKINIE_EXPORT_LIST'];
3576                 }
3577                 else
3578                 {
3579                         $template = '<td><input type="checkbox" name="<%typeid%>"  id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
3580                                           . "<td><%expdesc%></td>\n"
3581                                           . "</tr><tr>\n";
3582                 }
3583                 switch ( $type )
3584                 {
3585                         case 'skin':
3586                                 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
3587                                 while ( $skinObj = sql_fetch_object($res) )
3588                                 {
3589                                         $data = array(
3590                                                 'typeid'        => 'skin[' . $skinObj->sdnumber . ']',
3591                                                 'expid'         => 'skinexp' . $skinObj->sdnumber,
3592                                                 'expname'       => Entity::hsc($skinObj->sdname),
3593                                                 'expdesc'       => Entity::hsc($skinObj->sddesc),
3594                                         );
3595                                         echo TEMPLATE::fill($template, $data);
3596                                 }
3597                                 break;
3598                         case 'template':
3599                                 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3600                                 while ($templateObj = sql_fetch_object($res)) {
3601                                         $data = array(
3602                                                 'typeid'        => 'template[' . $templateObj->tdnumber . ']',
3603                                                 'expid'         => 'templateexp' . $templateObj->tdnumber,
3604                                                 'expname'       => Entity::hsc($templateObj->tdname),
3605                                                 'expdesc'       => Entity::hsc($templateObj->tddesc),
3606                                         );
3607                                         echo TEMPLATE::fill($template, $data);
3608                                 }
3609                                 break;
3610                 }
3611                 return;
3612         }
3613         
3614         /**
3615          * Actions::parse_skinoverview()
3616          * Parse skinvar skinoverview
3617          * 
3618          * @param       string  $templateName   name of template to use
3619          * @return      void
3620          */
3621         public function parse_skinoverview($templateName = '')
3622         {
3623                 $query  = "SELECT * FROM %s ORDER BY sdname";
3624                 $query = sprintf($query, sql_table('skin_desc'));
3625                 
3626                 $template['content']  = 'skinlist';
3627                 $template['tabindex'] = 10;
3628                 
3629                 Showlist($query, 'table', $template, $templateName);
3630                 return;
3631         }
3632         
3633         /**
3634          * Actions::parse_skintypehelp()
3635          * Check editing skintypehelp
3636          * 
3637          * @param       void
3638          * @return      void
3639          */
3640         public function parse_skintypehelp()
3641         {
3642                 $nowSkinType = strtolower(trim(requestVar('type')));
3643                 $regularType = array(
3644                         'index',
3645                         'item',
3646                         'archivelist',
3647                         'archive',
3648                         'search',
3649                         'error',
3650                         'member',
3651                         'imagepopup'
3652                 );
3653                 
3654                 if ( in_array($nowSkinType, $regularType) )
3655                 {
3656                         help('skinpart' . $nowSkinType);
3657                 }
3658                 else
3659                 {
3660                         help('skinpartspecial');
3661                 }
3662                 return;
3663         }
3664         
3665         /**
3666          * Actions::parse_specialskinlist()
3667          * Parse skinvar specialskinlist
3668          * 
3669          * @param       string  $templateName   name of template to use
3670          * @return      void
3671          */
3672         public function parse_specialskinlist($templateName = '')
3673         {
3674                 $templates = array();
3675                 if ( $templateName )
3676                 {
3677                         $templates = Template::read($templateName);
3678                 }
3679                 $nType  = array(
3680                         'index',
3681                         'item',
3682                         'error',
3683                         'search',
3684                         'archive',
3685                         'archivelist',
3686                         'imagepopup',
3687                         'member'
3688                 );
3689                 $skinid = intRequestVar('skinid');
3690                 $query  = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
3691                 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
3692                 
3693                 $res    = sql_query($query);
3694                 if ( $res && sql_num_rows($res) > 0 )
3695                 {
3696                         $data = array();
3697                         if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
3698                         {
3699                                 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
3700                         }
3701                         else
3702                         {
3703                                 $template['head'] = "<ul>\n";
3704                         }
3705                         echo TEMPLATE::fill($template['head'], $data);
3706                         if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
3707                         {
3708                                 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
3709                         }
3710                         else
3711                         {
3712                                 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&amp;skinid=<%skinid%>'
3713                                                                   . '&amp;type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
3714                                                                   . 'action=skinremovetype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">remove</a>)</li>';
3715                         }
3716                         $tabstart = 75;
3717                         while ( $row = sql_fetch_assoc($res) )
3718                         {
3719                                 $data = array(
3720                                         'tabindex' => $tabstart++,
3721                                         'skinid'   => $skinid,
3722                                         'skintype' => Entity::hsc(strtolower($row['stype']))
3723                                 );
3724                                 echo TEMPLATE::fill($template['body'], $data);
3725                         }
3726                         $data = array();
3727                         if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
3728                         {
3729                                 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
3730                         }
3731                         else
3732                         {
3733                                 $template['foot'] = "</ul>\n";
3734                         }
3735                         echo TEMPLATE::fill($template['foot'], $data);
3736                         return;
3737                 }
3738         }
3739         
3740         /**
3741          * Actions::parse_sprinttext()
3742          * Parse sprinttext
3743          * 
3744          * @param       string  $which  
3745          * @param       string  $val    
3746          * @return      void
3747          */
3748         public function parse_sprinttext($which, $val)
3749         {
3750                 if ( !defined($which) )
3751                 {
3752                         $base = $which;
3753                 }
3754                 else
3755                 {
3756                         $base = constant($which);
3757                 }
3758                 
3759                 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
3760                 {
3761                         if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
3762                         {
3763                                 $met = 'parse_' . $matchies[0];
3764                         }
3765                         else
3766                         {
3767                                 $arg = trim($args[0], '()');
3768                                 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
3769                         }
3770                         
3771                         if ( method_exists($this, $met) )
3772                         {
3773                                 $value = call_user_func(array(&$this, $met), $arg);
3774                         }
3775                 }
3776                 
3777                 if ( !isset($value) || empty($value) )
3778                 {
3779                         $value = $val;
3780                 }
3781                 echo sprintf($base, $value);
3782                 return;
3783         }
3784         
3785         /**
3786          * Actions::parse_systemsettings()
3787          * Parse skinvar systemsettings
3788          * 
3789          * @param       string  $type                   type of settings for system
3790          * @param       string  $templateName   name of template to use 
3791          * @return      void
3792          */
3793         public function parse_systemsettings($type = 'phpinfo', $templateName = '')
3794         {
3795                 global $member, $CONF, $nucleus;
3796                 
3797                 $member->isAdmin() or $this->objAdmin->disallow();
3798                 
3799                 $enable  = _ADMIN_SYSTEMOVERVIEW_ENABLE;
3800                 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
3801                 
3802                 switch ( $type )
3803                 {
3804                         case 'phpversion':
3805                                 echo phpversion();
3806                                 break;
3807                         case 'sqlserverinfo':
3808                                 echo sql_get_server_info();
3809                                 break;
3810                         case 'sqlclientinfo':
3811                                 echo sql_get_client_info();
3812                                 break;
3813                         case 'magicquotesgpc':
3814                                 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
3815                                 break;
3816                         case 'magicquotesruntime':
3817                                 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
3818                                 break;
3819                         case 'registerglobals':
3820                                 echo ini_get('register_globals') ? 'On' : 'Off';
3821                                 break;
3822                         case 'gdinfo':
3823                                 $templates = array();
3824                                 if ( $templateName )
3825                                 {
3826                                         $templates = Template::read($templateName);
3827                                 }
3828                                 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
3829                                 {
3830                                         $template = $templates['SYSTEMINFO_GDSETTINGS'];
3831                                 }
3832                                 else
3833                                 {
3834                                         $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
3835                                 }
3836                                 
3837                                 $gdinfo = gd_info();
3838                                 
3839                                 foreach ( $gdinfo as $key => $value )
3840                                 {
3841                                         if ( is_bool($value) )
3842                                         {
3843                                                 $value = $value ? $enable : $disable;
3844                                         }
3845                                         else
3846                                         {
3847                                                 $value = Entity::hsc($value);
3848                                         }
3849                                         $data = array(
3850                                                 'key'   => $key,
3851                                                 'value' => $value,
3852                                         );
3853                                         echo TEMPLATE::fill($template, $data);
3854                                 }
3855                                 break;
3856                         case 'modrewrite':
3857                                 ob_start();
3858                                 phpinfo(INFO_MODULES);
3859                                 $im = ob_get_contents();
3860                                 ob_end_clean();
3861                                 echo (strstr($im, 'mod_rewrite') != '') ? $enable : $disable;
3862                                 break;
3863                         case 'nucleusversion':
3864                                 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
3865                                 break;
3866                         case 'nucleuspatchlevel':
3867                                 echo getNucleusPatchLevel();
3868                                 break;
3869                         case 'confself':
3870                                 echo $CONF['Self'];
3871                                 break;
3872                         case 'confitemurl':
3873                                 echo $CONF['ItemURL'];
3874                                 break;
3875                         case 'alertonheaderssent':
3876                                 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
3877                                 break;
3878                         case 'nucleuscodename':
3879                                 if ( $nucleus['codename'] != '' )
3880                                 {
3881                                         echo ' &quot;' . $nucleus['codename'] . '&quot;';
3882                                 }
3883                                 break;
3884                         case 'versioncheckurl':
3885                                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
3886                                 break;
3887                 }
3888                 return;
3889         }
3890         
3891         /**
3892          * Actions::parse_templateoverview()
3893          * Parse skinvar templateoverview
3894          * 
3895          * @param       string  $templateName   name of template to use
3896          * @return      void
3897          */
3898         public function parse_templateoverview($templateName = '')
3899         {
3900                 $query  = "SELECT * FROM %s ORDER BY tdname";
3901                 $query = sprintf($query, sql_table('template_desc'));
3902                 $template['content']  = 'templatelist';
3903                 $template['tabindex'] = 10;
3904                 Showlist($query, 'table', $template, $templateName);
3905                 return;
3906         }
3907         
3908         /**
3909          * AdminActions::parse_ticket()
3910          * Parse ticket
3911          * 
3912          * @param       void
3913          * @return      void
3914          */
3915         public function parse_ticket()
3916         {
3917                 global $manager;
3918                 $manager->addTicketHidden();
3919                 return;
3920         }
3921         
3922         /**
3923          * Actions::parse_versioncheckurl()
3924          * Parse skinvar versioncheckurl
3925          * 
3926          * @param       void
3927          * @return      void
3928          */
3929         public function parse_versioncheckurl()
3930         {
3931                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
3932                 return;
3933         }
3934         
3935         /**
3936          * Actions::parse_yrbloglist()
3937          * Parse skinvar yrbloglist
3938          * 
3939          * @param       string  $templateName   name of template to use
3940          * @return      void
3941          */
3942         public function parse_yrbloglist($templateName = '')
3943         {
3944                 global $member;
3945                 $showAll = requestVar('showall');
3946                 
3947                 if ( $member->isAdmin() && ($showAll == 'yes') )
3948                 {
3949                         // Super-Admins have access to all blogs! (no add item support though)
3950                         $query =  "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
3951                                 . " FROM %s"
3952                                 . " ORDER BY bnumber";
3953                         $query = sprintf($query, sql_table('blog'));
3954                 }
3955                 else
3956                 {
3957                         $query =  "SELECT bnumber, bname, tadmin, burl, bshortname"
3958                                 . " FROM %s,%s"
3959                                 . " WHERE tblog=bnumber and tmember=%d"
3960                                 . " ORDER BY bnumber";
3961                         $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3962                 }
3963                 
3964                 $template['content']    = 'bloglist';
3965                 $template['superadmin'] = $member->isAdmin();
3966                 
3967                 $amount = Showlist($query, 'table', $template, $templateName);
3968                 
3969                 if ( ($showAll != 'yes') && ($member->isAdmin()) )
3970                 {
3971                         $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
3972                         
3973                         $total = quickQuery($query);
3974                         if ( $total > $amount )
3975                         {
3976                                 echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
3977                         }
3978                 }
3979                 
3980                 if ( $amount == 0 )
3981                 {
3982                         echo _OVERVIEW_NOBLOGS;
3983                 }
3984                 elseif( $amount != 0 )
3985                 {
3986                         echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
3987                         
3988                         $query =  "SELECT ititle, inumber, bshortname"
3989                                . " FROM %s,%s"
3990                                . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
3991                         $query = sprintf($query. sql_table('item'), sql_table('blog'), (integer) $member->getID());
3992                         
3993                         $template['content'] = 'draftlist';
3994                         
3995                         $amountdrafts = Showlist($query, 'table', $template, $templateName);
3996                         if ( $amountdrafts == 0 )
3997                         {
3998                                 echo _OVERVIEW_NODRAFTS;
3999                         }
4000                 }
4001                 return;
4002         }
4003         
4004         /**
4005          * Actions::customHelp()
4006          * shows a link to custom help file
4007          * 
4008          * @param       integer $id                     
4009          * @param       string  $tplName        
4010          * @param       string  $url            
4011          * @param       string  $iconURL        
4012          * @param       string  $alt            
4013          * @param       string  $title          
4014          * @param       $onclick
4015          * 
4016          */
4017         private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4018         {
4019                 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4020         }
4021         
4022         /**
4023          * Actions::customHelpHtml()
4024          * 
4025          * @param       integer $id                     
4026          * @param       string  $tplName        
4027          * @param       string  $url            
4028          * @param       string  $iconURL        
4029          * @param       string  $alt            
4030          * @param       string  $title          
4031          * @param       string  $onclick        
4032          * @return      string  anchor element with help uri
4033          */
4034         private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4035         {
4036                 $templates = array();
4037                 if ( $tplName )
4038                 {
4039                         $templates = Template::read($tplName);
4040                 }
4041                 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
4042                 {
4043                         $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
4044                 }
4045                 else
4046                 {
4047                         $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
4048                 }
4049                 
4050                 if ( empty($iconURL) )
4051                 {
4052                         global $CONF;
4053                         $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
4054                 }
4055                 if ( function_exists('getimagesize') )
4056                 {
4057                         $size   = getimagesize($iconURL);
4058                         $width  = 'width="'  . $size[0] . '" ';
4059                         $height = 'height="' . $size[1] . '" ';
4060                 }
4061                 $data = array(
4062                         'iconurl'       => $iconURL,
4063                         'width'         => $width,
4064                         'height'        => $height,
4065                         'alt'           => (isset($alt) && !empty($alt))         ? $alt   : _HELP_TT,
4066                         'title'         => (isset($title) && !empty($title)) ? $title : _HELP_TT,
4067                 );
4068                 $icon = TEMPLATE::fill($template, $data);
4069                 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
4070                 return $help . $icon;
4071         }
4072         
4073         /**
4074          * Actions::input_yesno
4075          * 
4076          * @param               $name
4077          * @param               $checkedval
4078          * @param               $tabindex
4079          * @param               $value1
4080          * @param               $value2
4081          * @param               $yesval
4082          * @param               $noval
4083          * @param               $isAdmin
4084          * @param               $templateName
4085          * @param               $showlist
4086          */
4087         private function input_yesno($name,
4088                                                                 $checkedval,
4089                                                                 $tabindex        = 0,
4090                                                                 $value1    = 1,
4091                                                                 $value2    = 0,
4092                                                                 $yesval    = _YES,
4093                                                                 $noval          = _NO,
4094                                                                 $isAdmin          = 0,
4095                                                                 $templateName = '',
4096                                                                 $showlist        = false)
4097         {
4098                 $templates = array();
4099                 if ( $templateName )
4100                 {
4101                         $templates = Template::read($templateName);
4102                 }
4103                 
4104                 if ( $name == 'admin' )
4105                 {
4106                         if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
4107                         {
4108                                 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
4109                         }
4110                         else
4111                         {
4112                                 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
4113                                           . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
4114                                           . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
4115                                           . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
4116                         }
4117                 }
4118                 else
4119                 {
4120                         if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
4121                         {
4122                                 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
4123                         }
4124                         if ( $showlist )
4125                         {
4126                                 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
4127                                 {
4128                                         $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
4129                                 }
4130                         }
4131                         if ( !isset($template) )
4132                         {
4133                                 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
4134                                           . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
4135                                           . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
4136                                           . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
4137                         }
4138                 }
4139                 
4140                 //echo $template;
4141                 $id             = Entity::hsc($name);
4142                 $id             = str_replace('[', '-', $id);
4143                 $id             = str_replace(']', '-', $id);
4144                 $id1    = $id . Entity::hsc($value1);
4145                 $id2    = $id . Entity::hsc($value2);
4146                 $dat = array(
4147                         'name'                  => Entity::hsc($name),
4148                         'yesval'                => Entity::hsc($value1),
4149                         'noval'                 => Entity::hsc($value2),
4150                         'yesid'                 => $id1,
4151                         'noid'                  => $id2,
4152                         'yesvaltext'    => $yesval,
4153                         'novaltext'             => $noval,
4154                         'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
4155                         'nocheckedval'  => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
4156                         'disabled'              => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
4157                 );
4158                 
4159                 if ( $showlist )
4160                 {
4161                         return Template::fill($template, $dat);
4162                 }
4163                 else
4164                 {
4165                         echo TEMPLATE::fill($template, $dat);
4166                 }
4167                 return;
4168         }
4169         
4170         /**
4171          * AdminActions::parse_text()
4172          * Parse text
4173          * 
4174          * FIXME: is this really needed?
4175          * 
4176          * @param       string  $which  constant vallue
4177          * @return      void
4178          */
4179         public function parse_text($which)
4180         {
4181                 if ( defined($which) )
4182                 {
4183                         echo constant($which);
4184                 }
4185                 return;
4186         }
4187
4188 }