OSDN Git Service

Merge branch 'skinnable-master' of git.sourceforge.jp:/gitroot/nucleus-jp/nucleus...
[nucleus-jp/nucleus-next.git] / nucleus / libs / AdminActions.php
1 <?php
2 if ( !class_exists('BaseActions') )
3 {
4         include $DIR_LIBS . 'BaseActions.php';
5 }
6
7
8 class AdminActions extends BaseActions
9 {
10         // reference to the skin object for which a part is being parsed
11         private $skin;
12         
13         private $skintype;
14         
15         /* NOTE: list of whole available action names for tags
16                 'actionloglist',
17                 'activationmessage',
18                 'addtickettourl',
19                 'adminbanlist',
20                 'adminbatchaction',
21                 'adminbatchlist',
22                 'adminbloglink',
23                 'adminerrormesg',
24                 'adminskineditallowedlist',
25                 'adminskinielist',
26                 'adminskinoverview',
27                 'adminskinselectoptions',
28                 'adminspecialskinlist',
29                 'admintemplateoverview',
30                 'allowedadminskinactions',
31                 'allowedskinactions',
32                 'banlistdeletedlist',
33                 'batchdeletelist',
34                 'batchdeletetype',
35                 'batchmovebtn',
36                 'batchmovelist',
37                 'batchmovetitle',
38                 'batchmovetype',
39                 'blogcatlist',
40                 'blognotifysetting',
41                 'blogselectbox',
42                 'blogsetting',
43                 'blogsettingyesno',
44                 'blogteamlist',
45                 'blogteammembers',
46                 'blogtime',
47                 'bookmarkletadmin',
48                 'category',
49                 'categorysetting',
50                 'codename',
51                 'commentnavlist',
52                 'configsettingsedit',
53                 'configsettingsyesno',
54                 'customhelplink',
55                 'date',
56                 'defaultadminskintypes',
57                 'defblogselect',
58                 'defcatselect',
59                 'defskinselect',
60                 'deletecomment',
61                 'deleteitembody',
62                 'deleteitemid',
63                 'deleteitemtitle',
64                 'editadminskin',
65                 'editadminskintype',
66                 'editadmintemplateinfo',
67                 'editcomment',
68                 'editdesturl',
69                 'editmember',
70                 'editmemberlist',
71                 'editpluginfo',
72                 'editplugoptionslist',
73                 'editskin',
74                 'editskintype',
75                 'edittemplateinfo',
76                 'eventformextra',
77                 'extrahead',
78                 'getblogsetting',
79                 'geteditpluginfo',
80                 'getmember',
81                 'headmessage',
82                 'helplink',
83                 'helpplugname',
84                 'ilistaddnew',
85                 'importskininfo',
86                 'inputyesno',
87                 'insertpluginfo',
88                 'insertpluginoptions',
89                 'insplugoptcontent',
90                 'iprangeinput',
91                 'itemnavlist',
92                 'jstoolbaroptions',
93                 'listplugplugoptionrow',
94                 'mediadirwarning',
95                 'movedistselect',
96                 'moveitemid',
97                 'newestcompare',
98                 'newmemberselect',
99                 'newpluginlist',
100                 'outputspecialdirs',
101                 'passrequestvars',
102                 'pluginextras',
103                 'pluginhelp',
104                 'pluginlistlist',
105                 'pluginoptions',
106                 'qmenuaddselect',
107                 'quickmenu',
108                 'requestblogid',
109                 'requestiprange',
110                 'selectlocaladminskinfiles',
111                 'selectlocalskinfiles',
112                 'skineditallowedlist',
113                 'skinfile',
114                 'skinielist',
115                 'skinoverview',
116                 'skintypehelp',
117                 'specialskinlist',
118                 'sprinttext',
119                 'systemsettings',
120                 'templateoverview',
121                 'text',
122                 'ticket',
123                 'versioncheckurl',
124                 'yrbloglist'
125         );
126          */
127         
128         /**
129          * AdminActions::$default_actions
130          * list of whole action names with which this class can deal
131          */
132         static private $default_actions = array(
133                 'addtickettourl',
134                 'adminurl',
135                 'customhelplink',
136                 'headmessage',
137                 'helplink',
138                 'sprinttext',
139                 'ticket'
140         );
141         
142         /**
143          * AdminActions::$skin_type_friendly_names
144          * friendly name for wrapped page types
145          */
146         static private $default_skin_types = array(
147                 'actionlog'                             => _ADM_SKPRT_ACTIONLOG,
148                 'activate'                              => _ADM_SKPRT_ACTIVATE,
149                 'activatesetpwd'                => _ADM_SKPRT_ACTIVATESETPWD,
150                 'addnewlog'                             => _ADM_SKPRT_ADDNEWLOG,
151                 'adminerrorpage'                => _ADM_SKPRT_ADMINERRORPAGE,
152                 'adminskindelete'               => _ADM_SKPRT_ADMINSKINDELETE,
153                 'adminskinedit'                 => _ADM_SKPRT_ADMINSKINEDIT,
154                 'adminskinedittype'             => _ADM_SKPRT_ADMINSKINEDITTYPE,
155                 'adminskiniedoimport'   => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
156                 'adminskinieimport'             => _ADM_SKPRT_ADMINSKINIEIMPORT,
157                 'adminskinieoverview'   => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
158                 'adminskinoverview'             => _ADM_SKPRT_ADMINSKINOVERVIEW,
159                 'adminskinremovetype'   => _ADM_SKPRT_ADMINSKINREMOVETYPE,
160                 'admintemplatedelete'   => _ADM_SKPRT_ADMINTEMPLATEDELETE,
161                 'admintemplateedit'             => _ADM_SKPRT_ADMINTEMPLATEEDIT,
162                 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
163                 'backupoverview'                => _ADM_SKPRT_BACKUPOVERVIEW,
164                 'backuprestore'                 => _ADM_SKPRT_BACKUPRESTORE,
165                 'banlist'                               => _ADM_SKPRT_BANLIST,
166                 'banlistdelete'                 => _ADM_SKPRT_BANLISTDELETE,
167                 'banlistdeleteconfirm'  => _ADM_SKPRT_BANLISTDELETECONFIRM,
168                 'banlistnew'                    => _ADM_SKPRT_BANLISTNEW,
169                 'batchcategory'                 => _ADM_SKPRT_BATCHCATEGORY,
170                 'batchcomment'                  => _ADM_SKPRT_BATCHCOMMENT,
171                 'batchdelete'                   => _ADM_SKPRT_BATCHDELETE,
172                 'batchitem'                             => _ADM_SKPRT_BATCHITEM,
173                 'batchmember'                   => _ADM_SKPRT_BATCHMEMBER,
174                 'batchmove'                             => _ADM_SKPRT_BATCHMOVE,
175                 'batchmovecat'                  => _ADM_SKPRT_BATCHMOVECAT,
176                 'batchteam'                             => _ADM_SKPRT_BATCHTEAM,
177                 'blogcommentlist'               => _ADM_SKPRT_BLOGCOMMENTLIST,
178                 'blogselectbox'                 => _ADM_SKPRT_BLOGSELECTBOX,
179                 'blogsettings'                  => _ADM_SKPRT_BLOGSETTINGS,
180                 'bookmarklet'                   => _ADM_SKPRT_BOOKMARKLET,
181                 'browseowncomments'             => _ADM_SKPRT_BROWSEOWNCOMMENTS,
182                 'browseownitems'                => _ADM_SKPRT_BROWSEOWNITEMS,
183                 'categorydelete'                => _ADM_SKPRT_CATEGORYDELETE,
184                 'categoryedit'                  => _ADM_SKPRT_CATEGORYEDIT,
185                 'commentdelete'                 => _ADM_SKPRT_COMMENTDELETE,
186                 'commentedit'                   => _ADM_SKPRT_COMMENTEDIT,
187                 'createitem'                    => _ADM_SKPRT_CREATEITEM,
188                 'createnewlog'                  => _ADM_SKPRT_CREATENEWLOG,
189                 'deleteblog'                    => _ADM_SKPRT_DELETEBLOG,
190                 'editmembersettings'    => _ADM_SKPRT_EDITMEMBERSETTINGS,
191                 'insertpluginoptions'   => _ADM_SKPRT_INSERTPLUGINO,
192                 'itemcommentlist'               => _ADM_SKPRT_ITEMCOMMENTLIST,
193                 'itemdelete'                    => _ADM_SKPRT_ITEMDELETE,
194                 'itemedit'                              => _ADM_SKPRT_ITEMEDIT,
195                 'itemlist'                              => _ADM_SKPRT_ITEMLIST,
196                 'itemmove'                              => _ADM_SKPRT_ITEMMOVE,
197                 'login'                                 => FALSE,       //missing
198                 'manage'                                => _ADM_SKPRT_MANAGE,
199                 'manageteam'                    => _ADM_SKPRT_MANAGETEAM,
200                 'memberdelete'                  => _ADM_SKPRT_MEMBERDELETE,
201                 'memberedit'                    => FALSE,       //missing
202                 'overview'                              => _ADM_SKPRT_OVERVIEW,
203                 'pagefoot'                              => _ADM_SKPRT_PAGEFOOT,
204                 'pagehead'                              => _ADM_SKPRT_PAGEHEAD,
205                 'plugindelete'                  => _ADM_SKPRT_PLUGINDELETE,
206                 'pluginhelp'                    => _ADM_SKPRT_PLUGINHELP,
207                 'pluginlist'                    => _ADM_SKPRT_PLUGINLIST,
208                 'pluginoptions'                 => _ADM_SKPRT_PLUGINOPTIONS,
209                 'settingsedit'                  => _ADM_SKPRT_SETTINGSEDIT,
210                 'showlogin'                             => _ADM_SKPRT_SHOWLOGIN,
211                 'skindelete'                    => _ADM_SKPRT_SKINDELETE,
212                 'skinedit'                              => _ADM_SKPRT_SKINEDIT,
213                 'skinedittype'                  => _ADM_SKPRT_SKINEDITTYPE,
214                 'skiniedoimport'                => _ADM_SKPRT_SKINIEDOIMPORT,
215                 'skinieimport'                  => _ADM_SKPRT_SKINIEIMPORT,
216                 'skinieoverview'                => _ADM_SKPRT_SKINIEOVERVIEW,
217                 'skinoverview'                  => _ADM_SKPRT_SKINOVERVIEW,
218                 'skinremovetype'                => _ADM_SKPRT_SKINREMOVETYPE,
219                 'systemoverview'                => _ADM_SKPRT_SYSTEMOVERVIEW,
220                 'teamdelete'                    => _ADM_SKPRT_TEAMDELETE,
221                 'templatedelete'                => _ADM_SKPRT_TEMPLATEDELETE,
222                 'templateedit'                  => _ADM_SKPRT_TEMPLATEEDIT,
223                 'templateoverview'              => _ADM_SKPRT_TEMPLATEOVERVIEW,
224                 'usermanagement'                => _ADM_SKPRT_USERMANAGEMENT,
225         );
226         
227         /**
228          * AdminActions::getAvailableSkinTypes()
229          * 
230          * @static
231          * @param       void
232          * @return      array   list of friendly names for page actions
233          */
234         static public function getAvailableSkinTypes()
235         {
236                 return self::$default_skin_types;
237         }
238         
239         /**
240          * AdminActions::getDefaultTypes()
241          *
242          * @static
243          * @param       void
244          * @return      array   list of friendly names for page actions
245          */
246         static public function getDefaultTypes()
247         {
248                 return self::$default_skin_types;
249         }
250         
251         /**
252          * AdminActions::__construct()
253          * Constructor for a new Actions object
254          * 
255          * @param       string  $type
256          * @return      void
257          */
258         public function __construct($type)
259         {
260                 // call constructor of superclass first
261                 parent::__construct();
262                 $this->skintype = $type;
263                 if ( !class_exists('Navlist') || !class_exists('Batch') )
264                 {
265                         global $DIR_LIBS;
266                         include $DIR_LIBS . 'ENCAPSULATE.php';
267                 }
268                 return;
269         }
270         
271         /**
272          * AdminActions::getAvailableActions()
273          * 
274          * @param       void
275          * @return      array   allowed actions for the page type
276          */
277         public function getAvailableActions()
278         {
279                 $extra_actions = array();
280                 
281                 switch ( $this->skintype )
282                 {
283                         case 'actionlog':
284                                 $extra_actions = array(
285                                         'actionloglist',
286                                 );
287                                 break;
288                         case 'activate':
289                                 $extra_actions = array(
290                                         'activationmessage',
291                                         'eventformextra',
292                                 );
293                                 break;
294                         case 'activatesetpwd':
295                                 $extra_actions = array(
296                                 );
297                                 break;
298                         case 'addnewlog':
299                                 $extra_actions = array(
300                                         'getblogsetting',
301                                         'blogsetting',
302                                         'requestblogid',
303                                         );
304                                 break;
305                         case 'adminerrorpage':
306                                 $extra_actions = array(
307                                 );
308                                 break;
309                         case 'adminskindelete':
310                                 $extra_actions = array(
311                                         'editadminskintype',
312                                 );
313                                 break;
314                         case 'adminskinedit':
315                                 $extra_actions = array(
316                                         'editadminskin',
317                                         'defaultadminskintypes',
318                                         'adminspecialskinlist',
319                                 );
320                                 break;
321                         case 'adminskinedittype':
322                                 $extra_actions = array(
323                                         'editadminskintype',
324                                         'skintypehelp',
325                                         'allowedadminskinactions',
326                                         'adminskineditallowedlist',
327                                 );
328                                 break;
329                         case 'adminskiniedoimport':
330                                 $extra_actions = array(
331                                         'importskininfo',
332                                 );
333                                 break;
334                         case 'adminskinieimport':
335                                 $extra_actions = array(
336                                         'importskininfo',
337                                 );
338                                 break;
339                         case 'adminskinieoverview':
340                                 $extra_actions = array(
341                                         'selectlocaladminskinfiles',
342                                         'adminskinielist',
343                                 );
344                                 break;
345                         case 'adminskinoverview':
346                                 $extra_actions = array(
347                                         'adminskinoverview',
348                                 );
349                                 break;
350                         case 'adminskinremovetype':
351                                 $extra_actions = array(
352                                         'editadminskintype',
353                                 );
354                                 break;
355                         case 'admintemplatedelete':
356                                 $extra_actions = array(
357                                         'editadmintemplateinfo',
358                                 );
359                         case 'admintemplateedit':
360                                 $extra_actions = array(
361                                         'editadmintemplateinfo',
362                                 );
363                                 break;
364                         case 'admntemplateoverview':
365                                 $extra_actions = array(
366                                         'admintemplateoverview',
367                                 );
368                                 break;
369                         case 'backupoverview':
370                                 $extra_actions = array(
371                                 );
372                                 break;
373                         case 'backuprestore':
374                                 $extra_actions = array(
375                                 );
376                                 break;
377                         case 'banlist':
378                                 $extra_actions = array(
379                                         'adminbloglink',
380                                         'adminbanlist',
381                                         'requestblogid',
382                                 );
383                                 break;
384                         case 'banlistdelete':
385                                 $extra_actions = array(
386                                         'requestiprange',
387                                         'requestblogid',
388                                 );
389                                 break;
390                         case 'banlistdeleteconfirm':
391                                 $extra_actions = array(
392                                         'banlistdeletedlist',
393                                         'requestblogid',
394                                 );
395                                 break;
396                         case 'banlistnew':
397                                 $extra_actions = array(
398                                         'iprangeinput',
399                                         'requestblogid',
400                                         'blogsetting',
401                                 );
402                                 break;
403                         case 'batchcategory':
404                                 $extra_actions = array(
405                                         'adminbatchaction',
406                                         'adminbatchlist',
407                                 );
408                                 break;
409                         case 'batchcomment':
410                                 $extra_actions = array(
411                                         'adminbatchaction',
412                                         'adminbatchlist',
413                                 );
414                                 break;
415                         case 'batchdelete':
416                                 $extra_actions = array(
417                                         'batchdeletetype',
418                                         'batchdeletelist',
419                                 );
420                                 break;
421                         case 'batchitem':
422                                 $extra_actions = array(
423                                         'adminbatchaction',
424                                         'adminbatchlist',
425                                 );
426                                 break;
427                         case 'batchmember':
428                                 $extra_actions = array(
429                                         'adminbatchaction',
430                                         'adminbatchlist',
431                                 );
432                                 break;
433                         case 'batchmove':
434                                 $extra_actions = array(
435                                         'batchmovetitle',
436                                         'batchmovetype',
437                                         'batchmovelist',
438                                         'movedistselect',
439                                         'batchmovebtn',
440                                 );
441                                 break;
442                         case 'batchmovecat':
443                                 $extra_actions = array(
444                                         'batchmovetitle',
445                                         'batchmovetype',
446                                         'batchmovelist',
447                                         'movedistselect',
448                                         'batchmovebtn',
449                                 );
450                                 break;
451                         case 'batchteam':
452                                 $extra_actions = array(
453                                         'requestblogid',
454                                         'adminbatchaction',
455                                         'adminbatchlist',
456                                 );
457                                 break;
458                         case 'blogcommentlist':
459                                 $extra_actions = array(
460                                         'adminbloglink',
461                                         'commentnavlist',
462                                         'adminbatchlist',
463                                 );
464                                 break;
465                         case 'blogselectbox':
466                                 $extra_actions = array(
467                                         'blogselectbox',
468                                 );
469                                 break;
470                         case 'blogsettings':
471                                 $extra_actions = array(
472                                         'adminbloglink',
473                                         'blogcatlist',
474                                         'blognotifysetting',
475                                         'blogsetting',
476                                         'blogsettingyesno',
477                                         'blogteammembers',
478                                         'blogtime',
479                                         'defcatselect',
480                                         'defskinselect',
481                                         'pluginextras',
482                                         'pluginoptions',
483                                         'requestblogid',
484                                 );
485                                 break;
486                         case 'bookmarklet':
487                                 $extra_actions = array(
488                                         'bookmarkletadmin',
489                                 );
490                                 break;
491                         case 'browseowncomments':
492                                 $extra_actions = array(
493                                         'commentnavlist',
494                                 );
495                                 break;
496                         case 'browseownitems':
497                                 $extra_actions = array(
498                                         'itemnavlist',
499                                 );
500                                 break;
501                         case 'categorydelete':
502                                 $extra_actions = array(
503                                         'categorysetting',
504                                         'requestblogid',
505                                 );
506                                 break;
507                         case 'categoryedit':
508                                 $extra_actions = array(
509                                         'requestblogid',
510                                         'categorysetting',
511                                         'editdesturl',
512                                         'pluginoptions'
513                                 );
514                                 break;
515                         case 'commentdelete':
516                                 $extra_actions = array(
517                                         'deletecomment',
518                                 );
519                                 break;
520                         case 'commentedit':
521                                 $extra_actions = array(
522                                         'editcomment',
523                                 );
524                                 break;
525                         case 'createitem':
526                                 $extra_actions = array(
527                                         'adminbloglink',
528                                         'blogid',
529                                         'contents',
530                                         'categories',
531                                         'currenttime',
532                                         'init',
533                                         'itemoptions',
534                                         'pluginextras'
535                                 );
536                                 break;
537                         case 'createnewlog':
538                                 $extra_actions = array(
539                                         'defskinselect',
540                                         'blogtime',
541                                 );
542                                 break;
543                         case 'deleteblog':
544                                 $extra_actions = array(
545                                         'blogsetting',
546                                         'requestblogid',
547                                 );
548                                 break;
549                         case 'editmembersettings':
550                                 $extra_actions = array(
551                                         'editmember',
552                                         'adminskinselectoptions',
553                                         'pluginoptions',
554                                 );
555                                 break;
556                         case 'insertpluginoptions':
557                                 $extra_actions = array(
558                                         'insertpluginoptions',
559                                 );
560                                 break;
561                         case 'itemcommentlist':
562                                 $extra_actions = array(
563                                         'requestblogid',
564                                         'commentnavlist',
565                                 );
566                                 break;
567                         case 'itemdelete':
568                                 $extra_actions = array(
569                                         'deleteitemtitle',
570                                         'deleteitembody',
571                                         'deleteitemid',
572                                 );
573                                 break;
574                         case 'itemedit':
575                                 $extra_actions = array(
576                                         'init',
577                                         'contents',
578                                         'checkedonval',
579                                         'categories',
580                                         'currenttime',
581                                         'itemtime',
582                                         'pluginextras',
583                                         'itemoptions'
584                                 );
585                                 break;
586                         case 'itemlist':
587                                 $extra_actions = array(
588                                         'adminbloglink',
589                                         'ilistaddnew',
590                                         'itemnavlist',
591                                 );
592                                 break;
593                         case 'itemmove':
594                                 $extra_actions = array(
595                                         'moveitemid',
596                                         'movedistselect',
597                                 );
598                                 break;
599                         case 'manage':
600                                 $extra_actions = array(
601                                 );
602                                 break;
603                         case 'manageteam':
604                                 $extra_actions = array(
605                                         'requestblogid',
606                                         'blogsetting',
607                                         'blogteamlist',
608                                         'newmemberselect',
609                                         'inputyesno',
610                                 );
611                                 break;
612                         case 'memberdelete':
613                                 $extra_actions = array(
614                                         'editmember',
615                                 );
616                                 break;
617                         case 'overview':
618                                 $extra_actions = array(
619                                         'yrbloglist',
620                                 );
621                                 break;
622                         case 'pagefoot':
623                                 $extra_actions = array(
624                                         'date',
625                                         'qmenuaddselect',
626                                         'member',
627                                         'quickmenu',
628                                 );
629                                 break;
630                         case 'pagehead':
631                                 $extra_actions = array(
632                                         'charset',
633                                         'sitevar',
634                                         'adminurl',
635                                         'extrahead',
636                                         'member',
637                                         'versioncheckurl',
638                                         'version',
639                                         'codename',
640                                         'newestcompare',
641                                 );
642                                 break;
643                         case 'plugindelete':
644                                 $extra_actions = array(
645                                         'editpluginfo',
646                                 );
647                                 break;
648                         case 'pluginhelp':
649                                 $extra_actions = array(
650                                         'helpplugname',
651                                         'pluginhelp',
652                                 );
653                                 break;
654                         case 'pluginlist':
655                                 $extra_actions = array(
656                                         'pluginlistlist',
657                                         'newpluginlist',
658                                 );
659                                 break;
660                         case 'pluginoptions':
661                                 $extra_actions = array(
662                                         'editpluginfo',
663                                         'editplugoptionslist',
664                                 );
665                                 break;
666                         case 'settingsedit':
667                                 $extra_actions = array(
668                                         'defblogselect',
669                                         'defskinselect',
670                                         'configsettingsedit',
671                                         'configsettingsyesno',
672                                         'outputspecialdirs',
673                                         'jstoolbaroptions',
674                                         'mediadirwarning',
675                                         'pluginextras',
676                                 );
677                                 break;
678                         case 'showlogin':
679                                 $extra_actions = array(
680                                         'passrequestvars',
681                                 );
682                                 break;
683                         case 'skindelete':
684                                 $extra_actions = array(
685                                         'editskintype',
686                                 );
687                                 break;
688                         case 'skinedit':
689                                 $extra_actions = array(
690                                         'editskin',
691                                         'specialskinlist',
692                                 );
693                                 break;
694                         case 'skinedittype':
695                                 $extra_actions = array(
696                                         'editskintype',
697                                         'skintypehelp',
698                                         'allowedskinactions',
699                                         'skineditallowedlist',
700                                         'skineditallowedlist',
701                                 );
702                                 break;
703                         case 'skiniedoimport':
704                                 $extra_actions = array(
705                                         'importskininfo',
706                                 );
707                                 break;
708                         case 'skinieimport':
709                                 $extra_actions = array(
710                                         'importskininfo',
711                                 );
712                                 break;
713                         case 'skinieoverview':
714                                 $extra_actions = array(
715                                         'selectlocalskinfiles',
716                                         'skinielist',
717                                 );
718                                 break;
719                         case 'skinoverview':
720                                 $extra_actions = array(
721                                         'skinoverview',
722                                 );
723                                 break;
724                         case 'skinremovetype':
725                                 $extra_actions = array(
726                                         'editskintype',
727                                 );
728                                 break;
729                         case 'systemoverview':
730                                 $extra_actions = array(
731                                         'systemsettings',
732                                 );
733                                 break;
734                         case 'teamdelete':
735                                 $extra_actions = array(
736                                         'editmember',
737                                         'blogsetting',
738                                         'requestblogid',
739                                 );
740                                 break;
741                         case 'templatedelete':
742                                 $extra_actions = array(
743                                         'edittemplateinfo',
744                                 );
745                                 break;
746                         case 'templateedit':
747                                 $extra_actions = array(
748                                         'edittemplateinfo',
749                                 );
750                                 break;
751                         case 'templateoverview':
752                                 $extra_actions = array(
753                                         'templateoverview',
754                                 );
755                                 break;
756                         case 'usermanagement':
757                                 $extra_actions = array(
758                                         'editmemberlist',
759                                         'inputyesno',
760                                 );
761                                 break;
762                         case 'importAdmin':
763                                 $extra_actions = array(
764                                         'charset',
765                                         'sitevar',
766                                         'adminurl',
767                                         'extrahead',
768                                         'member',
769                                         'versioncheckurl',
770                                         'version',
771                                         'codename',
772                                         'newestcompare',
773                                         'selectlocaladminskinfiles',
774                                         'adminskinielist',
775                                 );
776                                 break;
777                         default:
778                                 break;
779                 }
780                 
781                 $defined_actions = array_merge(self::$default_actions, $extra_actions);
782                 
783                 return array_merge($defined_actions, parent::getAvailableActions());
784         }
785         
786         /**
787          * AdminActions::setSkin()
788          * Set the skin
789          * @param       object  $skin   an instance of Skin class
790          * @return      void
791          */
792         public function setSkin(&$skin)
793         {
794                 $this->skin =& $skin;
795                 return;
796         }
797         
798         /**
799          * AdminActions::parse_actionloglist()
800          * Parse skinvar actionloglist
801          * 
802          * @param       string  $templateName   name of template to use
803          * @return      void
804          */
805         public function parse_actionloglist($templateName = '')
806         {
807                 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
808                 $query = sprintf($query, sql_table('actionlog'));       
809                 
810                 $template['content'] = 'actionlist';
811                 $amount = showlist($query, 'table', $template, $templateName);
812                 return;
813         }
814         
815         
816         /**
817          * AdminActions::parse_activationmessage()
818          * Parse skinvar activationmessage
819          * 
820          * @param       string  $type                   type of message
821          * @param       string  $templateName   name of template to use
822          * @return      void
823          */
824         public function parse_activationmessage($type, $templateName = '')
825         {
826                 global $CONF, $manager;
827                 
828                 $template = array();
829                 
830                 if ( !empty($templateName))
831                 {
832                         $template = Template::read($templateName);
833                 }
834                 
835                 $key = postVar('ackey');
836                 if ( !$key )
837                 {
838                         Admin::error(_ERROR_ACTIVATE);
839                 }
840                 
841                 $info = MEMBER::getActivationInfo($key);
842                 if ( !$info )
843                 {
844                         Admin::error(_ERROR_ACTIVATE);
845                 }
846                 
847                 $mem  = MEMBER::createFromId($info->vmember);
848                 if ( !$mem )
849                 {
850                         Admin::error(_ERROR_ACTIVATE);
851                 }
852                 switch ( $info->vtype )
853                 {
854                         case 'forgot':
855                                 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
856                                 {
857                                         $title = $template['ACTIVATE_FORGOT_TITLE'];
858                                 }
859                                 else
860                                 {
861                                         $title = _ACTIVATE_FORGOT_TITLE;
862                                 }
863                                 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
864                                 {
865                                         $text = $template['ACTIVATE_FORGOT_TEXT'];
866                                 }
867                                 else
868                                 {
869                                         $text = _ACTIVATE_FORGOT_TEXT;
870                                 }
871                                 break;
872                         case 'register':
873                                 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
874                                 {
875                                         $title = $template['ACTIVATE_REGISTER_TITLE'];
876                                 }
877                                 else
878                                 {
879                                         $title = _ACTIVATE_REGISTER_TITLE;
880                                 }
881                                 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
882                                 {
883                                         $text = $template['ACTIVATE_REGISTER_TEXT'];
884                                 }
885                                 else
886                                 {
887                                         $text = _ACTIVATE_REGISTER_TEXT;
888                                 }
889                                 break;
890                         case 'addresschange':
891                                 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
892                                 {
893                                         $title = $template['ACTIVATE_CHANGE_TITLE'];
894                                 }
895                                 else
896                                 {
897                                         $title = _ACTIVATE_CHANGE_TITLE;
898                                 }
899                                 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
900                                 {
901                                         $text = $template['ACTIVATE_CHANGE_TEXT'];
902                                 }
903                                 else
904                                 {
905                                         $text = _ACTIVATE_CHANGE_TEXT;
906                                 }
907                                 break;
908                 }
909                 $aVars = array(
910                         'memberName'    => Entity::hsc($mem->getDisplayName()),
911                         'realName'              => Entity::hsc($mem->getRealName()),
912                 );
913                 switch ( $type )
914                 {
915                         case 'title':
916                                 echo Template::fill($title, $aVars);
917                                 break;
918                         case 'text':
919                                 echo Template::fill($text,  $aVars);
920                                 break;
921                         case 'ackey':
922                                 echo Entity::hsc($key);
923                                 break;
924                 }
925                 return;
926         }
927         
928         /**
929          * AdminActions::parse_addtickettourl()
930          * Parse skinvar addtickettourl
931          * 
932          * @param       string  $url    URI for ticket
933          * @return      void
934          */
935         public function parse_addtickettourl($url)
936         {
937                 global $manager;
938                 $url = $manager->addTicketToUrl($url);
939                 echo Entity::hsc($url);
940                 return;
941         }
942         
943         /**
944          * AdminActions::parse_adminbanlist()
945          * Parse skinvar adminbanlist
946          * 
947          * @param       string  $templateName   name of template to use
948          * @return      void
949          */
950         public function parse_adminbanlist($templateName = '')
951         {
952                 $blogid = intRequestVar('blogid');
953                 
954                 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
955                 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
956                 
957                 $template['content'] = 'banlist';
958                 
959                 $amount = Showlist($query, 'table', $template, $templateName);
960                 
961                 if ( $amount == 0 )
962                 {
963                         echo _BAN_NONE;
964                 }
965                 return;
966         }
967         
968         /**
969          * AdminActions::parse_adminbatchaction()
970          * Parse skinvar adminbatchaction
971          * 
972          * @param       void
973          * @return      void
974          */
975         public function parse_adminbatchaction()
976         {
977                 echo Entity::hsc(requestVar('batchaction'));
978                 return;
979         }
980         
981         /**
982          * AdminActions::parse_adminbatchlist()
983          * Parse skinvar adminbatchlist
984          * 
985          * @param       string  $templateName   name of template to use
986          * @return      void
987          */
988         public function parse_adminbatchlist($templateName = '')
989         {
990                 global $manager;
991                 $templates = array();
992                 
993                 if ( !empty($templateName) )
994                 {
995                         $templates = Template::read($templateName);
996                 }
997                 
998                 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
999                 {
1000                         $template = '<li><%text(_BATCH_EXECUTING)%>'
1001                                   . '<b><%adminbatchaction%></b>'
1002                                   . '<%batchlisttype%>'
1003                                   . '<b><%batchid%></b>...'
1004                                   . '<b><%batchlistmsg%></b>'
1005                                   . '</li>' . "\n";
1006                 }
1007                 else
1008                 {
1009                         $template = $templates['ADMIN_BATCHLIST'];
1010                 }
1011                 
1012                 $selected = requestIntArray('batch');
1013                 $action   = requestVar('batchaction');
1014                 
1015                 switch ( $this->skintype )
1016                 {
1017                         case 'batchitem':
1018                                 $batchlisttype  = _BATCH_ONITEM;
1019                                 $deleteaction   = 'deleteOneItem';
1020                                 $moveaction             = 'moveOneItem';
1021                                 $destid                 = intRequestVar('destcatid');
1022                                 break;
1023                         case 'batchcomment':
1024                                 $batchlisttype  = _BATCH_ONCOMMENT;
1025                                 $deleteaction   = 'deleteOneComment';
1026                                 break;
1027                         case 'batchmember':
1028                                 $batchlisttype  = _BATCH_ONMEMBER;
1029                                 $deleteaction   = 'deleteOneMember';
1030                                 $setadminsql    = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1031                                 $unsetchksql    = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1032                                 $unsetupsql             = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1033                                 $unseterrmsg    = _ERROR_ATLEASTONEADMIN;
1034                                 break;
1035                         case 'batchteam':
1036                                 $blogid                 = intRequestVar('blogid');
1037                                 $batchlisttype  = _BATCH_ONTEAM;
1038                                 $deleteaction   = 'deleteOneTeamMember';
1039                                 $setadminsql    = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1040                                 $unsetchksql    = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1041                                 $unseterrmsg    = _ERROR_ATLEASTONEBLOGADMIN;
1042                                 $unsetupsql             = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1043                                 break;
1044                         case 'batchcategory':
1045                                 $batchlisttype  = _BATCH_ONCATEGORY;
1046                                 $deleteaction   = 'deleteOneCategory';
1047                                 $moveaction             = 'moveOneCategory';
1048                                 $destid                 = intRequestVar('destblogid');
1049                                 break;
1050                 }
1051                 
1052                 // walk over all selectedids and perform action
1053                 foreach ( $selected as $selectedid )
1054                 {
1055                         $error = '';
1056                         $selectedid = intval($selectedid);
1057                         
1058                         switch ( $action )
1059                         {
1060                                 case 'delete':
1061                                         if ( $this->skintype != 'batchteam' )
1062                                         {
1063                                                 $error = Admin::deleteaction($selectedid);
1064                                         }
1065                                         else
1066                                         {
1067                                                 $error  = Admin::deleteOneTeamMember($blogid, $selectedid);
1068                                         }
1069                                         break;
1070                                 case 'move':
1071                                         $error = Admin::moveaction($selectedid, $destid);
1072                                         break;
1073                                 case 'setadmin':
1074                                         // always succeeds
1075                                         sql_query("UPDATE {$setadminsql} {$selectedid};");
1076                                         $error = '';
1077                                         break;
1078                                 case 'unsetadmin':
1079                                         // there should always remain at least one super-admin
1080                                         $r = sql_query($unsetchksql);
1081                                         if ( sql_num_rows($r) < 2 )
1082                                         {
1083                                                 $error = $unseterrmsg;
1084                                         }
1085                                         else
1086                                         {
1087                                                 sql_query("UPDATE {$setadminsql} {$selectedid};");
1088                                         }
1089                                         break;
1090                                 default:
1091                                         $error = _BATCH_UNKNOWN . Entity::hsc($action);
1092                         }
1093                         
1094                         $data = array(
1095                                 'batchid'                       => $selectedid,
1096                                 'batchlisttype'         => Entity::hsc($batchlisttype),
1097                                 'adminbatchaction'      => Entity::hsc($action),
1098                                 'batchlistmsg'          => $error ? $error : _BATCH_SUCCESS,
1099                         );
1100                         
1101                         $handler = new AdminActions('template');
1102                         $parser = new Parser($handler);
1103                         
1104                         ob_start();
1105                         $parser->parse($template);
1106                         $template = ob_get_contents();
1107                         ob_end_clean();
1108                         
1109                         echo Template::fill($template, $data);
1110                         return;
1111                 }
1112         }
1113         
1114         /**
1115          * AdminActions::parse_adminbloglink()
1116          * Parse skinvar adminbloglink
1117          * 
1118          * @param       string  $templateName   name of template to use
1119          * @return      void
1120          */
1121         public function parse_adminbloglink($templateName = '')
1122         {
1123                 global $manager;
1124                 $blogid =  intRequestVar('blogid');
1125                 $blog   =& $manager->getBlog($blogid);
1126                 $templates = array();
1127                 
1128                 if ( !empty($templateName) )
1129                 {
1130                         $templates = Template::read($templateName);
1131                 }
1132                 
1133                 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1134                 {
1135                         $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1136                 }
1137                 else
1138                 {
1139                         $template = $templates['ADMIN_BLOGLINK'];
1140                 }
1141                 
1142                 $data = array(
1143                         'url'                                   => Entity::hsc($blog->getURL()),
1144                         'adminbloglinktitle'    => _BLOGLIST_TT_VISIT,
1145                         'blogname'                              => Entity::hsc($blog->getName())
1146                 );
1147                 
1148                 echo Template::fill($template, $data);
1149                 return;
1150         }
1151         
1152         /**
1153          * AdminActions::parse_adminerrormesg()
1154          * Parse skinvar adminerrormesg
1155          * 
1156          * @param       void
1157          * @return      void
1158          */
1159         public function parse_adminerrormesg()
1160         {
1161                 global $CONF;
1162                 $message = '';
1163                 
1164                 if ( requestVar('errormessage') )
1165                 {
1166                         $message = requestVar('errormessage');
1167                 }
1168                 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1169                 {
1170                         $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1171                 }
1172                 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1173                 {
1174                         $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1175                 }
1176                 echo Entity::hsc($message);
1177                 return;
1178         }
1179         
1180         /**
1181          * AdminActions::parse_adminskineditallowedlist()
1182          * Parse skinvar adminskineditallowedlist
1183          * 
1184          * @param       string  $type                   template/blog
1185          * @param       string  $templateName   name of template to use
1186          * @return      void
1187          */
1188         public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1189         {
1190                 switch ( $type )
1191                 {
1192                         /* TODO: blog seems not to be used */
1193                         case 'blog':
1194                                 $query = "SELECT bshortname, bname FROM %s";
1195                                 $query = sprintf($query, sql_table('blog'));
1196                                 $show  = array(
1197                                         'content' => 'shortblognames'
1198                                 );
1199                                 Showlist($query, 'table', $show, $templateName);
1200                                 break;
1201                         case 'template':
1202                                 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1203                                 $query = sprintf($query, sql_table('template_desc'));
1204                                 $show  = array(
1205                                         'content' => 'shortnames'
1206                                 );
1207                                 Showlist($query, 'table', $show, $templateName);
1208                                 break;
1209                 }
1210                 return;
1211         }
1212         
1213         /**
1214          * AdminActions::parse_adminskinielist()
1215          * Parse skinvar adminskinielist
1216          * 
1217          * @param       string  $type                   skin/template
1218          * @param       string  $templateName   name of template to use
1219          * @return      void
1220          */
1221         public function parse_adminskinielist($type, $templateName = '')
1222         {
1223                 $templates = array();
1224                 if ( $templateName )
1225                 {
1226                         $templates = Template::read($templateName);
1227                 }
1228                 
1229                 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1230                 {
1231                         $template = "<td>"
1232                                   . "<input type=\"checkbox\" name=\"<%typeid%>\"  id=\"<%expid%>\" />\n"
1233                                   . "<label for=\"<%expid%>\"><%expname%></label>"
1234                                   . "</td>\n"
1235                                   . "<td><%expdesc%></td>\n"
1236                                   . "</tr>\n"
1237                                   . "<tr>\n";
1238                 }
1239                 else
1240                 {
1241                         $template = $templates['SKINIE_EXPORT_LIST'];
1242                 }
1243                 
1244                 switch ( $type )
1245                 {
1246                         case 'skin':
1247                                 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1248                                 $query = sprintf($query, sql_table('skin_desc'));
1249                                 $res = sql_query($query);
1250                                 
1251                                 while ( $skinObj = sql_fetch_object($res) )
1252                                 {
1253                                         $data = array(
1254                                                 'typeid'        => 'skin[' . $skinObj->sdnumber . ']',
1255                                                 'expid'         => 'skinexp' . $skinObj->sdnumber,
1256                                                 'expname'       => Entity::hsc($skinObj->sdname),
1257                                                 'expdesc'       => Entity::hsc($skinObj->sddesc),
1258                                         );
1259                                         echo Template::fill($template, $data);
1260                                 }
1261                                 break;
1262                         case 'template':
1263                                 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1264                                 $query = sprintf($query, sql_table('template_desc'));
1265                                 $res = sql_query($query);
1266                                 while ( $templateObj = sql_fetch_object($res) )
1267                                 {
1268                                         $data = array(
1269                                                 'typeid'        => 'template[' . $templateObj->tdnumber . ']',
1270                                                 'expid'         => 'templateexp' . $templateObj->tdnumber,
1271                                                 'expname'       => Entity::hsc($templateObj->tdname),
1272                                                 'expdesc'       => Entity::hsc($templateObj->tddesc),
1273                                         );
1274                                         echo Template::fill($template, $data);
1275                                 }
1276                                 break;
1277                 }
1278                 return;
1279         }
1280         
1281         /**
1282          * AdminActions::parse_adminskinoverview()
1283          * Parse skinvar adminskinoverview
1284          * 
1285          * @param       string  $templateName   name of template to use
1286          * @return      void
1287          */
1288         public function parse_adminskinoverview($templateName = '')
1289         {
1290                 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1291                 $query = sprintf($query, sql_table('skin_desc'));
1292                 
1293                 $template['content'] = 'adminskinlist';
1294                 $template['tabindex'] = 10;
1295                 $template['friendly_names'] = $this->skin->getAvailableTypes();
1296                 Showlist($query, 'table', $template, $templateName);
1297                 return;
1298         }
1299         
1300         /**
1301          * AdminActions::parse_adminskinselectoptions()
1302          * Parse skinvar adminskinselectoptions
1303          * 
1304          * @param       void
1305          * @return      void
1306          */     
1307         public function parse_adminskinselectoptions()
1308         {
1309                 global $CONF;
1310                 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1311                 $query = sprintf($query, sql_table('skin_desc'));
1312                 
1313                 $template['name'] = 'adminskin';
1314                 $template['selected'] = $CONF['DefaultAdminSkin'];
1315                 $template['tabindex'] = 110;
1316                 Showlist($query, 'select', $template, '');
1317                 return;
1318         }
1319         
1320         /**
1321          * AdminActions::parse_adminspecialskinlist()
1322          * Parse skinvar adminspecialskinlist
1323          * 
1324          * @param       string  $templateName   name of template to use
1325          */
1326         public function parse_adminspecialskinlist($templateName = '')
1327         {
1328                 $templates = array();
1329                 if ( $templateName )
1330                 {
1331                         $templates = Template::read($templateName);
1332                 }
1333                 
1334                 $nType  = $this->skin->getAvailableTypes();
1335                 $skinid = intRequestVar('skinid');
1336                 
1337                 $query = "SELECT stype FROM  %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1338                 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1339                 
1340                 $res    = sql_query($query);
1341                 if ( $res && sql_num_rows($res) > 0 )
1342                 {
1343                         /* NOTE: set templates for HEAD/BODY/FOOT */
1344                         if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1345                         {
1346                                 $template['head'] = "<ul>\n";
1347                         }
1348                         else
1349                         {
1350                                 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1351                         }
1352                         if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1353                         {
1354                                 $template['body'] = '<li>'
1355                                                   . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">'
1356                                                   . '<%skintype%>'
1357                                                   . '</a>'
1358                                                   . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">'
1359                                                   . 'remove'
1360                                                   . '</a>)'
1361                                                   . "</li>\n";
1362                         }
1363                         else
1364                         {
1365                                 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1366                         }
1367                         if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1368                         {
1369                                 $template['foot'] = "</ul>\n";
1370                         }
1371                         else
1372                         {
1373                                 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1374                         }
1375                         
1376                         $tabstart = 120;
1377                         
1378                         /* NOTE: do echo */
1379                         $data = array();
1380                         echo $template['head'];
1381                         while ( $row = sql_fetch_assoc($res) )
1382                         {
1383                                 $data = array(
1384                                         'tabindex'      => $tabstart++,
1385                                         'skinid'        => $skinid,
1386                                         'skintype'      => Entity::hsc(strtolower($row['stype']))
1387                                 );
1388                                 echo Template::fill($template['body'], $data);
1389                         }
1390                         $data = array();
1391                         echo $template['foot'];
1392                 }
1393                 return;
1394         }
1395         
1396         /**
1397          * AdminActions::parse_admintemplateoverview()
1398          * Parse skinvar admintemplateoverview
1399          * 
1400          * @param       string  $templateName   name of template to use
1401          * @return      void
1402          */
1403         public function parse_admintemplateoverview($templateName = '')
1404         {
1405                 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1406                 $query = sprintf($query, sql_table('template_desc'));
1407                 
1408                 $template['content'] = 'admintemplatelist';
1409                 $template['tabindex'] = 10;
1410                 
1411                 Showlist($query, 'table', $template, $templateName);
1412                 return;
1413         }
1414         
1415         /**
1416          * AdminActions::parse_allowedadminskinactions()
1417          * Parse skinvar allowedadminskinactions
1418          * 
1419          * @param       void
1420          * @return      void
1421          */
1422         public function parse_allowedadminskinactions()
1423         {
1424                 global $DIR_ADMINSKINS;
1425                 $skinType = strtolower(trim(requestVar('type')));
1426                 $actions  = $this->skin->getAllowedActionsForType($skinType);
1427                 sort($actions);
1428                 
1429                 while ( $current = array_shift($actions) )
1430                 {
1431                         // TODO: remove this
1432                         // skip deprecated vars
1433                         if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1434                         {
1435                                 continue;
1436                         }
1437                         
1438                         echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1439                         
1440                         if ( count($actions) != 0 )
1441                         {
1442                                 echo ", ";
1443                         }
1444                 }
1445                 return;
1446         }
1447         
1448         /**
1449          * AdminActions::parse_allowedskinactions()
1450          * Parse skinvar allowedskinactions
1451          * 
1452          * @param       void
1453          * @return      void
1454          */
1455         public function parse_allowedskinactions()
1456         {
1457                 $skinType = strtolower(trim(requestVar('type')));
1458                 $skinid = intRequestVar('skinid');
1459                 
1460                 $skin = new Skin($skinid);
1461                 $actions = $skin->getAllowedActionsForType($skinType);
1462                 sort($actions);
1463                 
1464                 while ( $current = array_shift($actions) )
1465                 {
1466                         // TODO: remove this
1467                         // skip deprecated vars
1468                         if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1469                         {
1470                                 continue;
1471                         }
1472                         
1473                         /* TODO: alternative function should be used or not?  */
1474                         echo helplink("skinvar-{$current}") . "$current</a>\n";
1475                         
1476                         if ( count($actions) != 0 )
1477                         {
1478                                 echo ", ";
1479                         }
1480                 }
1481                 return;
1482         }
1483         
1484         /**
1485          * AdminActions::parse_banlistdeletedlist()
1486          * Parse skinvar banlistdeletedlist
1487          * 
1488          * @param       string  $templateName   name of template to use
1489          * @return      void
1490          */
1491         public function parse_banlistdeletedlist($templateName = '')
1492         {
1493                 global $manager;
1494                 $templates = array();
1495                 
1496                 if ( $templateName )
1497                 {
1498                         $templates = Template::read($templateName);
1499                 }
1500                 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1501                 {
1502                         $template = "<li><%blogname%></li>\n";
1503                 }
1504                 else
1505                 {
1506                         $template = $templates['BANLIST_DELETED_LIST'];
1507                 }
1508                 
1509                 $deleted = requestArray('delblogs');
1510                 foreach ( $deleted as $delblog )
1511                 {
1512                         $blog =& $manager->getBlog($delblog);
1513                         $data =  array(
1514                                 Entity::hsc($blog->getName())
1515                         );
1516                         Template::fill($template, $data);
1517                 }
1518                 return;
1519         }
1520         
1521         /**
1522          * AdminActions::parse_batchdeletelist()
1523          * Parse skinvar batchdeletelist
1524          * 
1525          * @param       void
1526          * @return      void
1527          */
1528         public function parse_batchdeletelist()
1529         {
1530                 $selected = requestIntArray('batch');
1531                 $index  = 0;
1532                 
1533                 foreach ( $selected as $select )
1534                 {
1535                         echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1536                 }
1537                 // add hidden vars for team & comment
1538                 if ( requestVar('action') == 'batchteam' )
1539                 {
1540                         echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1541                 }
1542                 if ( requestVar('action') == 'batchcomment' )
1543                 {
1544                         echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1545                 }
1546                 return;
1547         }
1548         
1549         /**
1550          * AdminActions::parse_batchdeletetype()
1551          * Parse skinvar batchdeletetype
1552          * 
1553          * @param       void
1554          * @return      void
1555          */
1556         public function parse_batchdeletetype()
1557         {
1558                 echo Entity::hsc(requestVar('action'));
1559                 return;
1560         }
1561
1562         /**
1563          * AdminActions::parse_batchmovebtn()
1564          * Parse skinvar batchmovebtn
1565          * 
1566          * @param       void
1567          * @return      void
1568          */
1569         public function parse_batchmovebtn()
1570         {
1571                 $actionType = requestVar('action');
1572                 switch ( $actionType )
1573                 {
1574                         case 'batchitem':
1575                                 echo _MOVE_BTN;
1576                                 break;
1577                         case 'batchcategory':
1578                                 echo _MOVECAT_BTN;
1579                                 break;
1580                 }
1581                 return;
1582         }
1583         
1584         /**
1585          * AdminActions::parse_batchmovelist()
1586          * Parse skinvar batchmovelist
1587          * 
1588          * @param       void
1589          * @param       void
1590          */
1591         public function parse_batchmovelist()
1592         {
1593                 $selected = requestIntArray('batch');
1594                 foreach ( $selected as $select )
1595                 {
1596                         echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1597                 }
1598                 return;
1599         }
1600         
1601         /**
1602          * AdminActions::parse_batchmovetitle()
1603          * Parse skinvar batchmovetitle
1604          * 
1605          * @param       void
1606          * @return      void
1607          */
1608         public function parse_batchmovetitle()
1609         {
1610                 $actionType = requestVar('action');
1611                 switch ( $actionType )
1612                 {
1613                         case 'batchitem':
1614                                 echo _MOVE_TITLE;
1615                                 break;
1616                         case 'batchcategory':
1617                                 echo _MOVECAT_TITLE;
1618                                 break;
1619                 }
1620                 return;
1621         }
1622         
1623         /**
1624          * AdminActions::parse_batchmovetype()
1625          * Parse skinvar batchmovetype
1626          * 
1627          * @param       void
1628          * @return      void
1629          */
1630         public function parse_batchmovetype()
1631         {
1632                 echo Entity::hsc(requestVar('action'));
1633                 return;
1634         }
1635         
1636         /**
1637          * AdminActions::parse_blogcatlist()
1638          * Parse skinvar blogcatlist
1639          * 
1640          * @param       void
1641          * @return      void
1642          */
1643         public function parse_blogcatlist()
1644         {
1645                 global $manager;
1646                 $blogid = intRequestVar('blogid');
1647                 $query  = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1648                 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1649                 
1650                 $template['content']  = 'categorylist';
1651                 $template['tabindex'] = 200;
1652                 
1653                 $batch = new Batch('category');
1654                 $batch->showlist($query, 'table', $template);
1655                 return;
1656         }
1657         
1658         /**
1659          * AdminActions::parse_blogid()
1660          * Parse skinvar blogid
1661          * 
1662          * @param       void
1663          * @return      void
1664          */
1665         function parse_blogid()
1666         {
1667                 echo intRequestVar('blogid');
1668                 return;
1669         }
1670         
1671         /**
1672          * AdminActions::parse_blognotifysetting()
1673          * Parse skinvar blognotifysetting
1674          * 
1675          * @param       void
1676          * @return      void
1677          */
1678         public function parse_blognotifysetting($type)
1679         {
1680                 global $manager;
1681                 $blogid = intRequestVar('blogid');
1682                 $blog   = $manager->getBlog($blogid);
1683                 
1684                 switch ( $type )
1685                 {
1686                         case 'comment':
1687                                 if ( !$blog->notifyOnComment() )
1688                                 {
1689                                         return;
1690                                 }
1691                                 break;
1692                         case 'vote':
1693                                 if ( !$blog->notifyOnVote() )
1694                                 {
1695                                         return;
1696                                 }
1697                                 break;
1698                         case 'newitem':
1699                                 if ( !$blog->notifyOnNewItem() )
1700                                 {
1701                                         return;
1702                                 }
1703                                 break;
1704                 }
1705                 echo ' checked="checked"';
1706                 return;
1707         }
1708         
1709         /**
1710          * AdminActions::parse_blogselectbox()
1711          * Parse skinvar blogselectbox
1712          * 
1713          * @param       void
1714          * @return      void
1715          */
1716         public function parse_blogselectbox()
1717         {
1718                 global $member;
1719                 
1720                 $selectData     = requestVar('selectData');
1721                 $mode           = $selectData['mode'];
1722                 $name           = Entity::hsc($selectData['name']);
1723                 $tabindex       = Entity::hsc($selectData['tabindex']);
1724                 $aBlogIds       = array_map('intval', $selectData['aBlogIds']);
1725                 $showNewCat     = intval($selectData['showNewCat']);
1726                 $selected       = intval($selectData['selected']);
1727                 
1728                 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1729                 
1730                 // 1. select blogs (we'll create optiongroups)
1731                 // (only select those blogs that have the user on the team)
1732                 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1733                 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1734                 $blogs = sql_query($queryBlogs);
1735                 
1736                 if ( $mode == 'category' )
1737                 {
1738                         if ( sql_num_rows($blogs) > 1 )
1739                         {
1740                                 $multipleBlogs = 1;
1741                         }
1742                         while ( $oBlog = sql_fetch_object($blogs) )
1743                         {
1744                                 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1745                                 {
1746                                         echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\">\n";
1747                                 }
1748                                 
1749                                 // show selection to create new category when allowed/wanted
1750                                 if ( $showNewCat )
1751                                 {
1752                                         // check if allowed to do so
1753                                         if ( $member->blogAdminRights($oBlog->bnumber) )
1754                                         {
1755                                                 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1756                                         }
1757                                 }
1758                                 
1759                                 // 2. for each category in that blog
1760                                 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1761                                 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1762                                 $categories = sql_query($catQuery);
1763                                 while ( $oCat = sql_fetch_object($categories) )
1764                                 {
1765                                         if ( $oCat->catid == $selected )
1766                                         {
1767                                                 $selectText = ' selected="selected" ';
1768                                         }
1769                                         else
1770                                         {
1771                                                 $selectText = '';
1772                                         }
1773                                         echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . Entity::hsc($oCat->cname) . "</option>\n";
1774                                 }
1775                                 
1776                                 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1777                                 {
1778                                         echo '</optgroup>';
1779                                 }
1780                         }
1781                 }
1782                 else
1783                 {
1784                         // blog mode
1785                         while ( $oBlog = sql_fetch_object($blogs) )
1786                         {
1787                                 echo '<option value="' . $oBlog->bnumber . '"';
1788                                 if ( $oBlog->bnumber == $selected )
1789                                 {
1790                                         echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . Entity::hsc($oBlog->bname) . "</option>\n";
1791                                 }
1792                                 else
1793                                 {
1794                                         echo '<option value="' . $oBlog->bnumber . '">' . Entity::hsc($oBlog->bname) . "</option>\n";
1795                                 }
1796                         }
1797                 }
1798                 echo "</select>\n";
1799                 return;
1800         }
1801         
1802         /**
1803          * AdminActions::parse_blogsetting()
1804          * Parse skinvar blogsetting
1805          * 
1806          * @param       string  $which  name of weblog setting
1807          * @return      void
1808          */
1809         public function parse_blogsetting($which)
1810         {
1811                 echo $this->parse_getblogsetting($which);
1812                 return;
1813         }
1814         
1815         /**
1816          * AdminActions::parse_blogsettingyesno()
1817          * Parse skinvar blogsettingyesno
1818          * 
1819          * @param       string  $type                   type of weblog setting
1820          * @param       string  $templateName   name of template to use
1821          * @return      void
1822          */
1823         public function parse_blogsettingyesno($type, $templateName = '')
1824         {
1825                 global $manager;
1826                 
1827                 $blogid = intRequestVar('blogid');
1828                 $blog   = $manager->getBlog($blogid);
1829                 
1830                 switch ( $type )
1831                 {
1832                         case 'convertbreaks':
1833                                 $checkedval = $blog->convertBreaks();
1834                                 $tabindex   = 55;
1835                                 break;
1836                         case 'allowpastposting':
1837                                 $checkedval = $blog->allowPastPosting();
1838                                 $tabindex   = 57;
1839                                 break;
1840                         case 'comments':
1841                                 $checkedval = $blog->commentsEnabled();
1842                                 $tabindex   = 60;
1843                                 break;
1844                         case 'public':
1845                                 $checkedval = $blog->isPublic();
1846                                 $tabindex   = 70;
1847                                 break;
1848                         case 'reqemail':
1849                                 $checkedval = $blog->emailRequired();
1850                                 $tabindex   = 72;
1851                                 break;
1852                         case 'searchable':
1853                                 $checkedval = $blog->getSearchable();
1854                                 $tabindex   = 122;
1855                                 break;
1856                 }
1857                 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1858                 return;
1859         }
1860         
1861         /**
1862          * AdminActions::parse_blogteamlist()
1863          * Parse skinvar blogteamlist
1864          * 
1865          * @param       string  $templateName   name of template to use
1866          * @return      void
1867          */
1868         public function parse_blogteamlist($templateName = '')
1869         {
1870                 global $manager;
1871                 $blogid = intRequestVar('blogid');
1872                 $query  = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1873                         . "FROM %s, %s "
1874                         . "WHERE tmember=mnumber AND tblog= %d";
1875                 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1876                 
1877                 $template['content']  = 'teamlist';
1878                 $template['tabindex'] = 10;
1879
1880                 $batch = new Batch('team');
1881                 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1882                 return;
1883         }
1884         
1885         /**
1886          * AdminActions::parse_blogteammembers()
1887          * Parse skinvar blogteammembers
1888          * 
1889          * @param       void
1890          * @return      void
1891          */
1892         public function parse_blogteammembers()
1893         {
1894                 $blogid = intRequestVar('blogid');
1895                 $query  = "SELECT mname, mrealname "
1896                                 . "FROM %s, %s "
1897                                 . "WHERE mnumber=tmember AND tblog=%d;";
1898                 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1899                 $res = sql_query($query);
1900                 $memberNames = array();
1901                 while ( $o = sql_fetch_object($res) )
1902                 {
1903                         $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1904                 }
1905                 echo implode(',', $memberNames);
1906         }
1907         
1908         /**
1909          * AdminActions::parse_blogtime()
1910          * Parse skinvar blogtime
1911          * 
1912          * @param       string  $type   type of time
1913          * @param       string  $format format for time expression
1914          * @param       integer $offset offset of time
1915          * @return      void
1916          */
1917         public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1918         {
1919                 global $manager;
1920                 
1921                 if ( $type != 'blogtime' )
1922                 {
1923                         /* return server time */
1924                         $timestamp = time() + $offset;
1925                 }
1926                 else
1927                 {
1928                         $bid = intRequestVar('blogid');
1929                         $b = $manager->getBlog($bid);
1930                         $timestamp = $b->getCorrectTime() + $offset;
1931                 }
1932                 
1933                 echo i18n::formatted_datetime($format, $timestamp);
1934                 return;
1935         }
1936         
1937         /**
1938          * AdminActions::parse_bookmarkletadmin()
1939          * Parse skinvar bookmarkletadmin
1940          * 
1941          * @param       void
1942          * @return      void
1943          */
1944         public function parse_bookmarkletadmin()
1945         {
1946                 global $manager;
1947                 
1948                 $blogid = intRequestVar('blogid');
1949                 
1950                 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1951                 return;
1952         }
1953
1954         /**
1955          * AdminActions::parse_categories()
1956          * Parse skinvar categories
1957          * 
1958          * create category dropdown box
1959          * 
1960          * @param       string  $type   name of setting for category
1961          * @return      void
1962          */
1963         function parse_categories($startidx = 0)
1964         {
1965                 global $manager;
1966                 
1967                 $item = false;
1968                 $itemid = intRequestVar('itemid');
1969                 
1970                 $item =& $manager->getItem($itemid, 1, 1);
1971                 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1972                 
1973                 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1974                 {
1975                         $item['body'] = removeBreaks($item['body']);
1976                         $item['more'] = removeBreaks($item['more']);
1977                 }
1978                 
1979                 $contents = array();
1980                 if ( requestVar('action') == 'itemedit' )
1981                 {
1982                         $contents = $item;
1983                 }
1984                 if ( isset($contents['catid']) && $contents['catid'] )
1985                 {
1986                         $catid = $contents['catid'];    // on edit item
1987                 }
1988                 else
1989                 {
1990                         $catid = $blog->getDefaultCategory();   // on add item
1991                 }
1992                 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
1993                 return;
1994         }
1995         
1996         /**
1997          * AdminActions::parse_category()
1998          * Parse skinvar category
1999          * 
2000          * @param       string  $type   name of setting for category
2001          * @return      void
2002          */
2003         public function parse_category($type = 'name')
2004         {
2005                 echo $this->parse_getcategory($type);
2006                 return;
2007         }
2008         
2009         /**
2010          * AdminActions::parse_categorysetting()
2011          * Parse skinvar categorysetting
2012          * 
2013          * @param       string  $type   type in category setting
2014          * @return      void
2015          */
2016         public function parse_categorysetting($type)
2017         {
2018                 $catid  = intRequestVar('catid');
2019                 if ( $type == 'id' )
2020                 {
2021                         echo $catid;
2022                         return;
2023                 }
2024                 $blogid = intRequestVar('blogid');
2025                 $query  = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2026                 $query  = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2027                 $res    = sql_query($query);
2028                 $obj    = sql_fetch_object($res);
2029                 
2030                 if ( $type != 'name' )
2031                 {
2032                         echo Entity::hsc($obj->cdesc);
2033                 }
2034                 else
2035                 {
2036                         echo Entity::hsc($obj->cname);
2037                 }
2038                 
2039                 return;
2040         }
2041         
2042         /**
2043          * AdminActions::parse_codename()
2044          * Parse templatevar codename
2045          * 
2046          * @param       $value
2047          * @param       $name
2048          * 
2049          */
2050         function parse_checkedonval($value, $name)
2051         {
2052                 global $manager;
2053                 
2054                 $item = false;
2055                 $itemid = intRequestVar('itemid');
2056                 $item =& $manager->getItem($itemid, 1, 1);
2057                 
2058                 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2059                 
2060                 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
2061                 {
2062                         $item['body'] = removeBreaks($item['body']);
2063                         $item['more'] = removeBreaks($item['more']);
2064                 }
2065                 
2066                 $contents = array();
2067                 if ( requestVar('action') == 'itemedit' )
2068                 {
2069                         $contents = $item;
2070                 }
2071                 if ( !isset($contents[$name]) )
2072                 {
2073                         $contents[$name] = '';
2074                 }
2075                 if ($contents[$name] == $value)
2076                 {
2077                         echo 'checked="checked"';
2078                 }
2079                 return;
2080         }
2081         
2082         /**
2083          * AdminActions::parse_codename()
2084          * Parse templatevar codename
2085          * 
2086          * @param       void
2087          * @return      void
2088          * 
2089          * TODO: is this need???
2090          */
2091         public function parse_codename()
2092         {
2093                 global $nucleus;
2094                 echo $nucleus['codename'];
2095                 return;
2096         }
2097         
2098         /**
2099          * AdminActions::parse_commentnavlist()
2100          * Parse skinvar commentnavlist
2101          * 
2102          * @param       void
2103          * @return      void
2104          */
2105         public function parse_commentnavlist()
2106         {
2107                 global $CONF, $manager, $member;
2108                 
2109                 // start index
2110                 if ( postVar('start') )
2111                 {
2112                         $start = intPostVar('start');
2113                 }
2114                 else
2115                 {
2116                         $start = 0;
2117                 }
2118                 
2119                 // amount of items to show
2120                 if ( postVar('amount') )
2121                 {
2122                         $amount = intPostVar('amount');
2123                 }
2124                 else
2125                 {
2126                         $amount = (integer) $CONF['DefaultListSize'];
2127                         if ( $amount < 1 )
2128                         {
2129                                 $amount = 10;
2130                         }
2131                 }
2132                 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2133                        . 'FROM %s '
2134                        . 'LEFT OUTER JOIN %s ON  mnumber=cmember '
2135                        . 'WHERE ';
2136                 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2137                 
2138                 if ( $this->skintype == 'itemcommentlist' )
2139                 {
2140                         $itemid                                 = intRequestVar('itemid');
2141                         $query                                  .= " citem={$itemid}";
2142                         $template['canAddBan']  = $member->blogAdminRights(intRequestVar('blogid'));
2143                         $bid                                    = 0;
2144                         $nonComments                    = _NOCOMMENTS;
2145                 }
2146                 elseif ( $this->skintype == 'browseowncomments' )
2147                 {
2148                         $itemid                                 = 0;
2149                         $query                                  .= ' cmember=' . $member->getID();
2150                         $template['canAddBan']  = 0;
2151                         $bid                                    = 0;
2152                         $nonComments                    = _NOCOMMENTS_YOUR;
2153                 }
2154                 elseif ( $this->skintype == 'blogcommentlist' )
2155                 {
2156                         $itemid                                 = 0;
2157                         $query                                  .= ' cblog=' . intRequestVar('blogid');
2158                         $template['canAddBan']  = $member->blogAdminRights(intRequestVar('blogid'));
2159                         $bid                                    = intRequestVar('blogid');
2160                         $nonComments                    = _NOCOMMENTS_BLOG;
2161                 }
2162                 
2163                 $search = postVar('search');
2164                 if ( !empty($search) )
2165                 {
2166                         $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
2167                 }
2168                 
2169                 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2170                 
2171                 $template['content'] = 'commentlist';
2172                 
2173                 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2174                 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2175                 return;
2176         }
2177         
2178         /**
2179          * AdminActions::parse_configsettingsedit()
2180          * Parse skinvar configsettingsedit
2181          * 
2182          * @param       string  $type   type of global configuration
2183          * @return      void
2184          */
2185         public function parse_configsettingsedit($type)
2186         {
2187                 global $CONF;
2188                 switch ( $type )
2189                 {
2190                         case 'DefaultListSize':
2191                                 if ( !array_key_exists('DefaultListSize', $CONF) )
2192                                 {
2193                                         $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2194                                         $query = sprintf($query, sql_table('config'));
2195                                         sql_query($query);
2196                                         $CONF['DefaultListSize'] = 10;
2197                                 }
2198                                 elseif ( intval($CONF['DefaultListSize']) < 1 )
2199                                 {
2200                                         $CONF['DefaultListSize'] = 10;
2201                                 }
2202                                 echo intval($CONF['DefaultListSize']);
2203                                 break;
2204                         case 'SessionCookie':
2205                                 $value = $CONF['SessionCookie'];
2206                                 $txt1  = _SETTINGS_COOKIESESSION;
2207                                 $txt2  = _SETTINGS_COOKIEMONTH;
2208                                 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2209                                 break;
2210                         case 'URLMode':
2211                                 $value = $CONF['URLMode'];
2212                                 $txt1  = _SETTINGS_URLMODE_NORMAL;
2213                                 $txt2  = _SETTINGS_URLMODE_PATHINFO;
2214                                 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2215                                 break;
2216                         default:
2217                                 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2218                                 {
2219                                         echo  Entity::hsc($CONF[$type]);
2220                                 }
2221                                 break;
2222                 }
2223                 return;
2224         }
2225         
2226         /**
2227          * AdminActions::parse_configsettingsyesno()
2228          * Parse skinvar configsettingsyesno
2229          * 
2230          * @param       string  $type           type of global setting
2231          * @param       integer $tabindex       tabindex attribute of input element
2232          * @return      void
2233          */
2234         public function parse_configsettingsyesno($type, $tabindex)
2235         {
2236                 global $CONF;
2237                 if ( array_key_exists($type, $CONF) )
2238                 {
2239                         $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2240                 }
2241                 return;
2242         }
2243         
2244         /**
2245          * AdminActions::parse_contents()
2246          * Parse skinvar contents
2247          * 
2248          * @param       string  $which          part for item
2249          * @return      void
2250          */
2251         function parse_contents($which)
2252         {
2253                 global $manager;
2254                 
2255                 $item = false;
2256                 $contents = array();
2257                 
2258                 if ( requestVar('action') == 'itemedit' )
2259                 {
2260                         $itemid = intRequestVar('itemid');
2261                         $item =& $manager->getItem($itemid, 1, 1);
2262                         
2263                         $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2264                         
2265                         if ( $item && $blog->convertBreaks() )
2266                         {
2267                                 $item['body'] = removeBreaks($item['body']);
2268                                 $item['more'] = removeBreaks($item['more']);
2269                         }
2270                         $contents = $item;
2271                 }
2272                 elseif ( requestVar('action') == 'createitem' )
2273                 {
2274                         $blogid = intRequestVar('blogid');
2275                         $blog =& $manager->getBlog($blogid);
2276                         $manager->notify(
2277                                 'PreAddItemForm',
2278                                 array(
2279                                         'contents' => &$contents,
2280                                         'blog'     => &$blog
2281                                 )
2282                         );
2283                 }
2284                 
2285                 if ( !array_key_exists($which, $contents) )
2286                 {
2287                         $contents[$which] = '';
2288                 }
2289                 echo Entity::hsc($contents[$which],ENT_QUOTES);
2290         }
2291         
2292         /**
2293          * AdminActions::parse_currenttime()
2294          * Parse skinvar currenttime
2295          * 
2296          * @param       string  $what
2297          */
2298         // for future items
2299         function parse_currenttime($what)
2300         {
2301                 global $manager;
2302                 if ( requestVar('action') == 'itemedit' )
2303                 {
2304                         $itemid = intRequestVar('itemid');
2305                         $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2306                 } 
2307                 elseif ( requestVar('action') == 'createitem' )
2308                 {
2309                         $blog =& $manager->getBlog(intRequestVar('blogid'));
2310                 }
2311                 $nu = getdate($blog->getCorrectTime());
2312                 echo $nu[$what];
2313         }
2314         
2315         /**
2316          * AdminActions::parse_customhelplink()
2317          * Parse skinvar customhelplink
2318          * 
2319          * @param       string  $topic          name of topic
2320          * @param       string  $tplName        name of template
2321          * @param       string  $url            string as URI
2322          * @param       string  $iconURL        string as URI for icon
2323          * @param       string  $alt            alternative text for image element
2324          * @param       string  $title          title for anchor element
2325          * @return      void
2326          */
2327         public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2328         {
2329                 $this->customHelp($topic, $url, $iconURL);
2330                 return;
2331         }
2332         
2333         /**
2334          * AdminActions::parse_date()
2335          * Parse skinvar date
2336          */
2337         public function parse_date($format = 'c')
2338         {
2339                 global $CONF, $manager;
2340                 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2341                 return;
2342         }
2343         
2344         /**
2345          * AdminActions::parse_defaultadminskintypes()
2346          * Parse skinvar defaultadminskintypes
2347          * 
2348          * @param       string  $tabindex               index number for tabindex attribute of input element
2349          * @param       string  $templateName   name of template
2350          * @return      void
2351          */
2352         public function parse_defaultadminskintypes($tabindex, $templateName = '')
2353         {
2354                 $templates = array();
2355                 
2356                 if ( $templateName )
2357                 {
2358                         $templates = Template::read($templateName);
2359                 }
2360                 
2361                 $types = $this->skin->getAvailableTypes();
2362                 ksort($types);
2363                 
2364                 /* NOTE: set templates for HEAD/BODY/FOOT */
2365                 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2366                 {
2367                         $template['head'] = "<ul>\n";
2368                 }
2369                 else
2370                 {
2371                         $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2372                 }
2373                 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2374                 {
2375                         $template['body'] = "<li>"
2376                                           . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&amp;skinid=<%skinid%>&amp;type=<%skintype%>\"><%name%></a> <%help%>"
2377                                           . "</li>\n";
2378                 }
2379                 else
2380                 {
2381                         $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2382                 }
2383                 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2384                 {
2385                         $template['foot'] = "</ul>\n";
2386                 }
2387                 else
2388                 {
2389                         $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2390                 }
2391                 
2392                 $handler = new AdminActions('template');
2393                 $parser = new PARSER($handler);
2394                 
2395                 /* NOTE: do output */
2396                 echo $template['head'];
2397                 foreach ( $types as $type => $fName )
2398                 {
2399                         $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2400                         $data = array(
2401                                 'tabindex'      => $tabindex,
2402                                 'skintype'      => $type,
2403                                 'name'          => $fName,
2404                                 'help'          => $helplink,
2405                                 'skinid'        => intrequestVar('skinid'),
2406                         );
2407                         $parser->parse(Template::fill($template['body'], $data));
2408                         $tabindex++;
2409                 }
2410                 echo $template['foot'];
2411                 
2412                 return;
2413         }
2414         
2415         /**
2416          * AdminActions::parse_defblogselect()
2417          * Parse skinvar defblogselect
2418          * 
2419          * @param       string  $templateName   name of template
2420          * @return      void
2421          */
2422         public function parse_defblogselect($templateName = '')
2423         {
2424                 global $CONF;
2425                 
2426                 $query = "SELECT bname as text, bnumber as value FROM %s;";
2427                 $query = sprintf($query, sql_table('blog'));
2428                 
2429                 $template['name'] = 'DefaultBlog';
2430                 $template['selected'] = $CONF['DefaultBlog'];
2431                 $template['tabindex'] = 10;
2432                 
2433                 Showlist($query, 'select', $template, $templateName);
2434                 
2435                 return;
2436         }
2437         
2438         /**
2439          * AdminActions::parse_defcatselect()
2440          * Parse skinvar defcatselect
2441          * 
2442          * @param       string  $templateName   name of template
2443          * @return      void
2444          */
2445         public function parse_defcatselect($templateName = '')
2446         {
2447                 global $manager;
2448                 
2449                 $blogid = intRequestVar('blogid');
2450                 $blog = $manager->getBlog($blogid);
2451                 
2452                 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2453                 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2454                 
2455                 $template['name']        = 'defcat';
2456                 $template['selected'] = $blog->getDefaultCategory();
2457                 $template['tabindex'] = 110;
2458                 
2459                 Showlist($query, 'select', $template, $templateName);
2460                 
2461                 return;
2462         }
2463         
2464         /**
2465          * AdminActions::parse_defskinselect()
2466          * Parse skinvar defskinselect
2467          * 
2468          * @param       string  $type                   type of skin
2469          * @param       string  $templateName   name of template
2470          * @return      void
2471          */
2472         public function parse_defskinselect($type = 'blog', $templateName = '')
2473         {
2474                 global $CONF, $manager;
2475                 
2476                 $query  = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2477                 $query = sprintf($query, sql_table('skin_desc'));
2478                 
2479                 $blogid = intRequestVar('blogid');
2480                 
2481                 if ( !$blogid )
2482                 {
2483                         $template['selected'] = $CONF['BaseSkin'];
2484                 }
2485                 else
2486                 {
2487                         $blog = $manager->getBlog($blogid);
2488                         $template['selected'] = $blog->getDefaultSkin();
2489                 }
2490                 
2491                 if ( $type != 'blog' )
2492                 {
2493                         $nname = 'BaseSkin';
2494                 }
2495                 else
2496                 {
2497                         $nname = 'defskin';
2498                 }
2499                 
2500                 $template['name']        = $nname;
2501                 $template['tabindex'] = 50;
2502                 
2503                 Showlist($query, 'select', $template, $templateName);
2504                 
2505                 return;
2506         }
2507         
2508         /**
2509          * AdminActions::parse_deletecomment()
2510          * Parse skinvar deletecomment
2511          * 
2512          * @param       string  $type   type of infomation for comment
2513          * @return      void
2514          */
2515         public function parse_deletecomment($type = 'id')
2516         {
2517                 $commentid      = intRequestVar('commentid');
2518                 $comment        = COMMENT::getComment($commentid);
2519                 
2520                 switch ( $type )
2521                 {
2522                         case 'id':
2523                                 echo intRequestVar('commentid');
2524                                 break;
2525                         case 'author':
2526                                 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2527                                 {
2528                                         echo $comment['member'];
2529                                 }
2530                                 else
2531                                 {
2532                                         echo $comment['user'];
2533                                 }
2534                                 break;
2535                         case 'body':
2536                                 $body = strip_tags($comment['body']);
2537                                 echo Entity::hsc(shorten($body, 300, '...'));
2538                 }
2539                 return;
2540         }
2541         
2542         /**
2543          * AdminActions::parse_deleteitembody()
2544          * Parse skinvar deleteitembody
2545          * 
2546          * @param       void
2547          * @return      void
2548          */
2549         public function parse_deleteitembody()
2550         {
2551                 global $manager;
2552                 
2553                 $itemid =  intRequestVar('itemid');
2554                 $item =& $manager->getItem($itemid, 1, 1);
2555                 
2556                 $body =  strip_tags($item['body']);
2557                 
2558                 echo Entity::hsc(shorten($body, 300, '...'));
2559                 
2560                 return;
2561         }
2562         
2563         /**
2564          * AdminActions::parse_deleteitemid()
2565          * Parse skinvar deleteitemid
2566          * 
2567          * @param       void
2568          * @return      void
2569          */
2570         public function parse_deleteitemid()
2571         {
2572                 echo (integer) intRequestVar('itemid');
2573                 return;
2574         }
2575         
2576         /**
2577          * AdminActions::parse_deleteitemtitle()
2578          * Parse skinvar deleteitemtitle
2579          * 
2580          * @param       void
2581          * @return      void
2582          */
2583         public function parse_deleteitemtitle()
2584         {
2585                 global $manager;
2586                 
2587                 $itemid = intRequestVar('itemid');
2588                 $item =& $manager->getItem($itemid, 1, 1);
2589                 
2590                 echo Entity::hsc(strip_tags($item['title']));
2591                 
2592                 return;
2593         }
2594         
2595         /**
2596          * AdminActions::parse_editadminskin()
2597          * Parse skinvar editadminskin
2598          * 
2599          * @param       string  $type   type of skin setting
2600          * @return      void
2601          */
2602         public function parse_editadminskin($type = 'id')
2603         {
2604                 $skinid = intRequestVar('skinid');
2605                 $skin   = new Skin($skinid);
2606                 switch ( $type )
2607                 {
2608                         case 'id':
2609                                 echo intRequestVar('skinid');
2610                                 break;
2611                         case 'name':
2612                                 echo Entity::hsc($skin->getName());
2613                                 break;
2614                         case 'desc':
2615                                 echo Entity::hsc($skin->getDescription());
2616                                 break;
2617                         case 'type':
2618                                 echo Entity::hsc($skin->getContentType());
2619                                 break;
2620                         case 'prefix':
2621                                 echo Entity::hsc($skin->getIncludePrefix());
2622                                 break;
2623                         case 'mode':
2624                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2625                         default:
2626                                 break;
2627                 }
2628                 return;
2629         }
2630         
2631         /**
2632          * AdminActions::parse_editadminskintype()
2633          * Parse skinvar editadminskintype
2634          * 
2635          * @param       string  $type   name of skin type
2636          * @return      void
2637          */
2638         public function parse_editadminskintype($type = 'id')
2639         {
2640                 global $CONF, $manager, $member;
2641                 
2642                 $fNames = $this->skin->getAvailableTypes();
2643                 $sType  = strtolower(trim(requestVar('type')));
2644                 
2645                 switch ( $type )
2646                 {
2647                         case 'id':
2648                                 echo intRequestVar('skinid');
2649                                 break;
2650                         case 'name':
2651                                 echo Entity::hsc($this->skin->getName());
2652                                 break;
2653                         case 'desc':
2654                                 echo Entity::hsc($this->skin->getDescription());
2655                                 break;
2656                         case 'type':
2657                                 echo Entity::hsc($this->skin->getContentType());
2658                                 break;
2659                         case 'content':
2660                                 echo Entity::hsc($this->skin->getContentFromDB($sType));
2661                                 break;
2662                         case 'skintype':
2663                                 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2664                                 echo Entity::hsc($skinType);
2665                                 break;
2666                         case 'skintyperaw':
2667                                 echo Entity::hsc($sType);
2668                                 break;
2669                         case 'prefix':
2670                                 echo Entity::hsc($this->skin->getIncludePrefix());
2671                                 break;
2672                         case 'mode':
2673                                 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2674                                 echo Entity::hsc($incMode);
2675                                 break;
2676                         default:
2677                                 break;
2678                 }
2679                 return;
2680         }
2681         
2682         /**
2683          * AdminActions::parse_editcomment()
2684          * Parse skinvar editcomment
2685          * 
2686          * @param       string  $type   type of comment setting
2687          * @return      void
2688          */
2689         public function parse_editcomment($type = 'id')
2690         {
2691                 global $manager;
2692                 
2693                 $commentid      = intRequestVar('commentid');
2694                 $comment        = COMMENT::getComment($commentid);
2695                 
2696                 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2697                 
2698                 switch ( $type )
2699                 {
2700                         case 'id':
2701                                 echo intRequestVar('commentid');
2702                                 break;
2703                         case 'user':
2704                                 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2705                                 {
2706                                         echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2707                                 }
2708                                 else
2709                                 {
2710                                         echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2711                                 }
2712                                 break;
2713                         case 'date':
2714                                 echo date("Y-m-d @ H:i", $comment['timestamp']);
2715                                 break;
2716                         case 'body':
2717                                 $comment['body'] = str_replace('<br />', '', $comment['body']);
2718                                 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2719                                 echo $comment['body'];
2720                         default:
2721                                 echo $comment[$type];
2722                                 break;
2723                 }
2724                 return;
2725         }
2726         
2727         /**
2728          * AdminActions::parse_editdesturl()
2729          * Parse skinvar editdesturl
2730          */
2731         public function parse_editdesturl()
2732         {
2733                 if ( requestVar('desturl') )
2734                 {
2735                         echo Entity::hsc(requestVar('desturl'));
2736                 }
2737                 return;
2738         }
2739         
2740         /**
2741          * AdminActions::parse_editmemberlist()
2742          * Parse skinvar editmemberlist
2743          * 
2744          * @param       string  $templateName   name of template
2745          * @return      void
2746          */
2747         public function parse_editmemberlist($templateName = '')
2748         {
2749                 global $manager;
2750                 // show list of members with actions
2751                 $query =  'SELECT * FROM '.sql_table('member');
2752                 $template['content'] = 'memberlist';
2753                 $template['tabindex'] = 10;
2754                 
2755                 $batch = new Batch('member');
2756                 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2757                 return;
2758         }
2759         
2760         /**
2761          * AdminActions::parse_editmember()
2762          * Parse skinvar editmember
2763          * 
2764          * @param       string  $type                   type of information for member
2765          * @return      string  $tempateName    name of template to use
2766          * @return      void
2767          */
2768         public function parse_editmember($type = 'id', $templateName = '')
2769         {
2770                 global $CONF, $manager, $member;
2771                 
2772                 $memberid = intRequestVar('memberid');
2773                 $mem = MEMBER::createFromID($memberid);
2774                 
2775                 switch ( $type )
2776                 {
2777                         case 'id':
2778                                 echo intRequestVar('memberid');
2779                                 break;
2780                         case 'displayname':
2781                                 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2782                                 {
2783                                         echo Entity::hsc($mem->getDisplayName());
2784                                 }
2785                                 else
2786                                 {
2787                                         $dispName = Entity::hsc($mem->getDisplayName());
2788                                         if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2789                                         {
2790                                                 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2791                                         }
2792                                         else
2793                                         {
2794                                                 echo $dispName;
2795                                         }
2796                                 }
2797                                 break;
2798                         case 'realname':
2799                                 echo Entity::hsc($mem->getRealName());
2800                                 break;
2801                         case 'email':
2802                                 echo Entity::hsc($mem->getEmail());
2803                                 break;
2804                         case 'url':
2805                                 echo Entity::hsc($mem->getURL());
2806                                 break;
2807                         case 'admin':
2808                                 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2809                                 break;
2810                         case 'canlogin':
2811                                 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2812                                 break;
2813                         case 'notes':
2814                                 echo Entity::hsc($mem->getNotes());
2815                                 break;
2816                         case 'autosave':
2817                                 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2818                                 break;
2819                         default:
2820                                 break;
2821                 }
2822                 return;
2823         }
2824         
2825         /**
2826          * AdminActions::parse_editpluginfo()
2827          * Parse skinvar editpluginfo
2828          * 
2829          * @param       string  $type   type of plugin info
2830          * @return      void
2831          */
2832         public function parse_editpluginfo($type)
2833         {
2834                 $pid = intRequestVar('plugid');
2835                 switch ( $type )
2836                 {
2837                         case 'id':
2838                                 echo $pid;
2839                                 break;
2840                         case 'name':
2841                                 echo Entity::hsc(getPluginNameFromPid($pid));
2842                                 break;
2843                 }
2844                 return;
2845         }
2846         
2847         /**
2848          * AdminActions::parse_editplugoptionslist()
2849          * Parse skinvar editplugoptionslist
2850          * 
2851          * @param       string  $templateName   name of template
2852          * @return      void
2853          */
2854         public function parse_editplugoptionslist($templateName = '')
2855         {
2856                 global $manager;
2857                 
2858                 $pid = intRequestVar('plugid');
2859                 $aOptions = array();
2860                 $aOIDs  = array();
2861                 
2862                 $query  = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2863                 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2864                 $resource = sql_query($query);
2865                 
2866                 while ( $o = sql_fetch_object($resource) )
2867                 {
2868                         array_push($aOIDs, $o->oid);
2869                         $aOptions[$o->oid] = array(
2870                                 'oid'                   => $o->oid,
2871                                 'value'                 => $o->odef,
2872                                 'name'                  => $o->oname,
2873                                 'description'   => $o->odesc,
2874                                 'type'                  => $o->otype,
2875                                 'typeinfo'              => $o->oextra,
2876                                 'contextid'             => 0
2877                         );
2878                 }
2879                 
2880                 // fill out actual values
2881                 if ( count($aOIDs) > 0 )
2882                 {
2883                         $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2884                         $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2885                         
2886                         $result = sql_query($query);
2887                         
2888                         while ( $o = sql_fetch_object($result) )
2889                         {
2890                                 $aOptions[$o->oid]['value'] = $o->ovalue;
2891                         }
2892                 }
2893                 
2894                 // call plugins
2895                 $data = array(
2896                         'context'       =>  'global',
2897                         'plugid'        =>  $pid,
2898                         'options'       => &$aOptions
2899                 );
2900                 $manager->notify('PrePluginOptionsEdit', $data);
2901                 
2902                 $template['content'] = 'plugoptionlist';
2903                 
2904                 $amount = Showlist($aOptions, 'table', $template, $templateName);
2905                 
2906                 if ( $amount == 0 )
2907                 {
2908                         echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2909                 }
2910                 return;
2911         }
2912         
2913         /**
2914          * AdminActions::parse_editskin()
2915          * Parse skinvar editskin
2916          * 
2917          * @param       string  $type   type of skin
2918          * @return      void
2919          */
2920         public function parse_editskin($type = 'id')
2921         {
2922                 $skinid = intRequestVar('skinid');
2923                 $skin   = new SKIN($skinid);
2924                 switch ( $type )
2925                 {
2926                         case 'id':
2927                                 echo intRequestVar('skinid');
2928                                 break;
2929                         case 'name':
2930                                 echo Entity::hsc($skin->getName());
2931                                 break;
2932                         case 'desc':
2933                                 echo Entity::hsc($skin->getDescription());
2934                                 break;
2935                         case 'type':
2936                                 echo Entity::hsc($skin->getContentType());
2937                                 break;
2938                         case 'prefix':
2939                                 echo Entity::hsc($skin->getIncludePrefix());
2940                                 break;
2941                         case 'mode':
2942                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2943                         default:
2944                                 break;
2945                 }
2946                 return;
2947         }
2948         
2949         /**
2950          * AdminActions::parse_editskintype()
2951          * Parse skinvar editskintype
2952          * 
2953          * @param       string  $type   name of type for skin type
2954          * @return      void
2955          */
2956         public function parse_editskintype($type = 'id')
2957         {
2958                 global $CONF, $manager, $member;
2959                 $skinid = intRequestVar('skinid');
2960                 $skin   = new SKIN($skinid);
2961                 $fNames = $skin->getAvailableTypes();
2962                 $sType  = strtolower(trim(requestVar('type')));
2963                 
2964                 switch ( $type )
2965                 {
2966                         case 'id':
2967                                 echo intRequestVar('skinid');
2968                                 break;
2969                         case 'name':
2970                                 echo Entity::hsc($skin->getName());
2971                                 break;
2972                         case 'desc':
2973                                 echo Entity::hsc($skin->getDescription());
2974                                 break;
2975                         case 'type':
2976                                 echo Entity::hsc($skin->getContentType());
2977                                 break;
2978                         case 'content':
2979                                 echo Entity::hsc($skin->getContentFromDB($sType));
2980                                 break;
2981                         case 'skintype':
2982                                 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2983                                 echo Entity::hsc($skinType);
2984                                 break;
2985                         case 'skintyperaw':
2986                                 echo Entity::hsc($sType);
2987                                 break;
2988                         case 'prefix':
2989                                 echo Entity::hsc($skin->getIncludePrefix());
2990                                 break;
2991                         case 'mode':
2992                                 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2993                                 echo Entity::hsc($incMode);
2994                                 break;
2995                         default:
2996                                 break;
2997                 }
2998                 return;
2999         }
3000         
3001         /**
3002          * AdminActions::parse_adminurl()
3003          * Parse skinvar adminurl
3004          * (shortcut for admin url)
3005          *
3006          * @param       void
3007          * @return      void
3008          */
3009         public function parse_adminurl()
3010         {
3011                 $this->parse_sitevar('adminurl');
3012                 return;
3013         }
3014         
3015         /**
3016          * AdminActions::parse_edittemplateinfo()
3017          * Parse skinvar edittemplateinfo
3018          * 
3019          * @param       string  $type                   name of type for skin
3020          * @param       string  $description    description for skin
3021          * @param       string  $name                   name of skin
3022          * @param       string  $help                   
3023          * @param       string  $tabindex               index value for tabindex attribute of input element
3024          * @param       string  $big                    
3025          * @param       string  $tplt                   name of template
3026          * @return      boolean 
3027          */
3028         public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3029         {
3030                 global $manager;
3031                 
3032                 $t_id           =  intRequestVar('templateid');
3033                 $t_name         =  Template::getNameFromId($t_id);
3034                 $t_desc         =  Template::getDesc($t_id);
3035                 $template       = &Template::read($t_name);
3036                 
3037                 switch ( $type )
3038                 {
3039                         case 'id':
3040                                 echo intval($t_id);
3041                                 break;
3042                         case 'name':
3043                                 echo Entity::hsc($t_name);
3044                                 break;
3045                         case 'desc':
3046                                 echo Entity::hsc($t_desc);
3047                                 break;
3048                         case 'extratemplate':
3049                                 $tabidx = 600;
3050                                 $pluginfields = array();
3051                                 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
3052                                 
3053                                 $tmplt = array();
3054                                 if ( $desc )
3055                                 {
3056                                         $tmplt = Template::read($desc);
3057                                 }
3058                                 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3059                                 {
3060                                         $base = "</tr>\n"
3061                                               . "<tr>\n"
3062                                               . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3063                                 }
3064                                 else
3065                                 {
3066                                         $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3067                                 }
3068                                 
3069                                 foreach ( $pluginfields as $pfkey => $pfvalue )
3070                                 {
3071                                         $data = array('explugtplname' => Entity::hsc($pfkey));
3072                                         
3073                                         echo Template::fill($base, $data);
3074                                         
3075                                         foreach ( $pfvalue as $pffield => $pfdesc )
3076                                         {
3077                                                 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3078                                         }
3079                                 }
3080                                 break;
3081                         default:
3082                                 $desc = defined($desc) ? constant($desc) : $desc;
3083                                 $name = defined($name) ? constant($name) : $name;
3084                                 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3085                                 break;
3086                 }
3087                 
3088                 return;
3089         }
3090         
3091         /**
3092          * AdminActions::parse_editadmintemplateinfo()
3093          * Parse skinvar editadmintemplateinfo
3094          * 
3095          * @param       string  $type                   type of skin template
3096          * @param       string  $description    description of template
3097          * @param       string  $name                   name of stemplate
3098          * @param       string  $tabindex               index number for tabindex attribute of input element
3099          * @param       string  $big                    
3100          * @param       string  $tplt                   
3101          */
3102         public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3103         {
3104                 global $manager;
3105                 
3106                 $t_id           =  intRequestVar('templateid');
3107                 $t_name         =  Template::getNameFromId($t_id);
3108                 $t_desc         =  Template::getDesc($t_id);
3109                 $template       = &Template::read($t_name);
3110                 
3111                 switch ( $type )
3112                 {
3113                         case 'id':
3114                                 echo intval($t_id);
3115                                 break;
3116                         case 'name':
3117                                 echo Entity::hsc($t_name);
3118                                 break;
3119                         case 'desc':
3120                                 echo Entity::hsc($t_desc);
3121                                 break;
3122                         case 'extratemplate':
3123                                 $tabidx = 600;
3124                                 $pluginfields = array();
3125                                 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3126                                 
3127                                 $tmplt = array();
3128                                 if ( $desc )
3129                                 {
3130                                         $tmplt = Template::read($desc);
3131                                 }
3132                                 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3133                                 {
3134                                         $base = "</tr>\n"
3135                                               . "<tr>\n"
3136                                               . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3137                                 }
3138                                 else
3139                                 {
3140                                         $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3141                                 }
3142                                 
3143                                 foreach ( $pluginfields as $pfkey => $pfvalue )
3144                                 {
3145                                         $data = array('explugtplname' => Entity::hsc($pfkey));
3146                                         
3147                                         echo Template::fill($base, $data);
3148                                         
3149                                         foreach ( $pfvalue as $pffield => $pfdesc )
3150                                         {
3151                                                 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3152                                         }
3153                                 }
3154                                 break;
3155                         default:
3156                                 $desc = defined($desc) ? constant($desc) : $desc;
3157                                 $name = defined($name) ? constant($name) : $name;
3158                                 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3159                                 break;
3160                 }
3161                 return;
3162         }
3163         
3164         /**
3165          * AdminActions::parse_eventformextra()
3166          * Parse skinvar eventformextra
3167          * 
3168          * @param       string  $type   name of type for event form extra
3169          * @return      void
3170          */
3171         public function parse_eventformextra($type = 'activation')
3172         {
3173                 global $manager;
3174                 
3175                 $data = array();
3176                 
3177                 switch ( $type )
3178                 {
3179                         case 'activation':
3180                                 $key = requestVar('ackey');
3181                                 if ( !$key )
3182                                 {
3183                                         Admin::error(_ERROR_ACTIVATE);
3184                                 }
3185                                 $info = MEMBER::getActivationInfo($key);
3186                                 if ( !$info )
3187                                 {
3188                                         Admin::error(_ERROR_ACTIVATE);
3189                                 }
3190                                 $mem  = MEMBER::createFromId($info->vmember);
3191                                 if ( !$mem )
3192                                 {
3193                                         Admin::error(_ERROR_ACTIVATE);
3194                                 }
3195                                 $data = array(
3196                                         'type'          => 'activation',
3197                                         'member'        => $mem
3198                                 );
3199                                 break;
3200                         case 'membermailform-notloggedin':
3201                                 $data = array('type' => 'membermailform-notloggedin',);
3202                                 break;
3203                 }
3204                 $manager->notify('FormExtra', $data);
3205                 return;
3206         }
3207         
3208         /**
3209          * AdminActions::parse_extrahead()
3210          * Parse skinvar extrahead
3211          */
3212         public function parse_extrahead()
3213         {
3214                 global $manager;
3215                 
3216                 $extrahead = Admin::getAdminextrahead();
3217                 
3218                 $data = array(
3219                         'extrahead'     => &$extrahead,
3220                         'action'        => Admin::getAdminAction()
3221                 );
3222                 
3223                 $manager->notify('AdminPrePageHead', $data);
3224                 echo $extrahead;
3225                 return;
3226         }
3227         
3228         /**
3229          * AdminActions::parse_member()
3230          * Parse skinvar member
3231          * (includes a member info thingie)
3232          * 
3233          * @param       string  $what   which memberdata is needed
3234          * @return      void
3235          */
3236         public function parse_member($what)
3237         {
3238                 global $memberinfo, $member, $CONF;
3239                 
3240                 // 1. only allow the member-details-page specific variables on member pages
3241                 if ( $this->skintype == 'member' )
3242                 {
3243                         switch( $what )
3244                         {
3245                                 case 'name':
3246                                         echo Entity::hsc($memberinfo->getDisplayName());
3247                                         break;
3248                                 case 'realname':
3249                                         echo Entity::hsc($memberinfo->getRealName());
3250                                         break;
3251                                 case 'notes':
3252                                         echo Entity::hsc($memberinfo->getNotes());
3253                                         break;
3254                                 case 'url':
3255                                         echo Entity::hsc($memberinfo->getURL());
3256                                         break;
3257                                 case 'email':
3258                                         echo Entity::hsc($memberinfo->getEmail());
3259                                         break;
3260                                 case 'id':
3261                                         echo Entity::hsc($memberinfo->getID());
3262                                         break;
3263                         }
3264                 }
3265                 
3266                 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3267                 if ( $member->isLoggedIn() )
3268                 {
3269                         switch( $what )
3270                         {
3271                                 case 'yourname':
3272                                         echo $member->getDisplayName();
3273                                         break;
3274                                 case 'yourrealname':
3275                                         echo $member->getRealName();
3276                                         break;
3277                                 case 'yournotes':
3278                                         echo $member->getNotes();
3279                                         break;
3280                                 case 'yoururl':
3281                                         echo $member->getURL();
3282                                         break;
3283                                 case 'youremail':
3284                                         echo $member->getEmail();
3285                                         break;
3286                                 case 'yourid':
3287                                         echo $member->getID();
3288                                         break;
3289                                 case 'yourprofileurl':
3290                                         if ( $CONF['URLMode'] == 'pathinfo' )
3291                                         {
3292                                                 echo Link::create_member_link($member->getID());
3293                                         }
3294                                         else
3295                                         {
3296                                                 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3297                                         }
3298                                         break;
3299                         }
3300                 }
3301                 return;
3302         }
3303         
3304         /**
3305          * AdminActions::parse_version()
3306          * Parse skinvar version
3307          * (include nucleus versionnumber)
3308          *
3309          * @param       void
3310          * @return      void
3311          */
3312         public function parse_version()
3313         {
3314                 global $nucleus;
3315                 echo 'Nucleus CMS ' . $nucleus['version'];
3316                 return;
3317         }
3318         
3319         /**
3320          * AdminActions::parse_sitevar()
3321          * Parse skinvar sitevar
3322          * (include a sitevar)
3323          *
3324          * @param       string  $which
3325          * @return      void
3326          */
3327         public function parse_sitevar($which)
3328         {
3329                 global $CONF;
3330                 switch ( $which )
3331                 {
3332                         case 'url':
3333                                 echo $CONF['IndexURL'];
3334                                 break;
3335                         case 'name':
3336                                 echo $CONF['SiteName'];
3337                                 break;
3338                         case 'admin':
3339                                 echo $CONF['AdminEmail'];
3340                                 break;
3341                         case 'adminurl':
3342                                 echo $CONF['AdminURL'];
3343                 }
3344                 return;
3345         }
3346         
3347         /**
3348          * AdminActions::parse_charset()
3349          * Parse skinvar charset
3350          *
3351          * @param       void
3352          * @return      void
3353          */
3354         public function parse_charset()
3355         {
3356                 echo i18n::get_current_charset();
3357                 return;
3358         }
3359         
3360         /**
3361          * AdminActions::parse_getblogsetting()
3362          * Parse skinvar getblogsetting
3363          */
3364         public function parse_getblogsetting($which)
3365         {
3366                 global $blog;
3367                 
3368                 if ( $blog )
3369                 {
3370                         $b =& $blog;
3371                 }
3372                 elseif ( $bid = intRequestVar('blogid') )
3373                 {
3374                         global $manager;
3375                         $b = $manager->getBlog($bid);
3376                 }
3377                 else
3378                 {
3379                         return;
3380                 }
3381                 
3382                 switch ( $which )
3383                 {
3384                         case 'id':
3385                                 return Entity::hsc($b->getID());
3386                                 break;
3387                         case 'url':
3388                                 return Entity::hsc($b->getURL());
3389                                 break;
3390                         case 'name':
3391                                 return Entity::hsc($b->getName());
3392                                 break;
3393                         case 'desc':
3394                                 return Entity::hsc($b->getDescription());
3395                                 break;
3396                         case 'short':
3397                                 return Entity::hsc($b->getShortName());
3398                                 break;
3399                         case 'notifyaddress':
3400                                 return Entity::hsc($b->getNotifyAddress());
3401                                 break;
3402                         case 'maxcomments':
3403                                 return Entity::hsc($b->getMaxComments());
3404                                 break;
3405                         case 'updatefile':
3406                                 return Entity::hsc($b->getUpdateFile());
3407                                 break;
3408                         case 'timeoffset':
3409                                 return Entity::hsc($b->getTimeOffset());
3410                                 break;
3411                 }
3412                 return;
3413         }
3414         
3415         /**
3416          * AdminActions::parse_geteditpluginfo()
3417          * Parse skinvar geteditpluginfo
3418          * 
3419          * @param       string  $type   name of setting for edit plugin info
3420          * @return      void
3421          */
3422         public function parse_geteditpluginfo($type)
3423         {
3424                 $pid = intRequestVar('plugid');
3425                 switch ( $type )
3426                 {
3427                         case 'id':
3428                                 return $pid;
3429                                 break;
3430                         case 'name':
3431                                 return Entity::hsc(getPluginNameFromPid($pid));
3432                                 break;
3433                 }
3434                 return;
3435         }
3436         
3437         /**
3438          * AdminActions::parse_getmember()
3439          * Parse skinvar getmember
3440          * (includes a member info thingie)
3441          * 
3442          * @param       string  $what   name of setting for member
3443          * @return      void
3444          */
3445         public function parse_getmember($what)
3446         {
3447                 global $memberinfo, $member;
3448                 // 1. only allow the member-details-page specific variables on member pages
3449                 if ( $this->skintype == 'member' )
3450                 {
3451                         switch ( $what )
3452                         {
3453                                 case 'name':
3454                                         return Entity::hsc($memberinfo->getDisplayName());
3455                                         break;
3456                                 case 'realname':
3457                                         return Entity::hsc($memberinfo->getRealName());
3458                                         break;
3459                                 case 'notes':
3460                                         return Entity::hsc($memberinfo->getNotes());
3461                                         break;
3462                                 case 'url':
3463                                         return Entity::hsc($memberinfo->getURL());
3464                                         break;
3465                                 case 'email':
3466                                         return Entity::hsc($memberinfo->getEmail());
3467                                         break;
3468                                 case 'id':
3469                                         return Entity::hsc($memberinfo->getID());
3470                                         break;
3471                         }
3472                 }
3473                 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3474                 if ( $member->isLoggedIn() )
3475                 {
3476                         switch ( $what )
3477                         {
3478                                 case 'yourname':
3479                                         return $member->getDisplayName();
3480                                         break;
3481                                 case 'yourrealname':
3482                                         return $member->getRealName();
3483                                         break;
3484                                 case 'yournotes':
3485                                         return $member->getNotes();
3486                                         break;
3487                                 case 'yoururl':
3488                                         return $member->getURL();
3489                                         break;
3490                                 case 'youremail':
3491                                         return $member->getEmail();
3492                                         break;
3493                                 case 'yourid':
3494                                         return $member->getID();
3495                                         break;
3496                         }
3497                 }
3498                 return;
3499         }
3500         
3501         /**
3502          * AdminActions::parse_headmessage()
3503          * Parse skinvar headmessage
3504          * 
3505          * @param       void
3506          * @return      void
3507          */
3508         public function parse_headmessage()
3509         {
3510                 if ( !empty(Admin::$headMess) )
3511                 {
3512                         echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3513                 }
3514                 return;
3515         }
3516         
3517         /**
3518          * AdminActions::parse_helplink()
3519          * Parse skinvar helplink
3520          * 
3521          * @param       string  $topic  name of topic for help
3522          * @return      void
3523          */
3524         public function parse_helplink($topic = '')
3525         {
3526                 if ( !empty($topic) )
3527                 {
3528                         help($topic);
3529                 }
3530                 return;
3531         }
3532         
3533         /**
3534          * AdminActions::parse_helpplugname()
3535          * Parse skinvar helpplugname
3536          * 
3537          * @param       void
3538          * @return      void
3539          */
3540         public function parse_helpplugname()
3541         {
3542                 $plugid = intGetVar('plugid');
3543                 Entity::hsc(getPluginNameFromPid($plugid));
3544                 return;
3545         }
3546         
3547         /**
3548          * AdminActions::parse_ilistaddnew()
3549          * Parse skinvar ilistaddnew
3550          * 
3551          * @param       void
3552          * @return      void
3553          */
3554         public function parse_ilistaddnew()
3555         {
3556                 $blogid = intRequestVar('blogid');
3557                 if ( intPostVar('start') == 0 )
3558                 {
3559                         echo '<p><a href="index.php?action=createitem&amp;blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3560                 }
3561                 return;
3562         }
3563         
3564         /**
3565          * AdminActions::parse_importskininfo()
3566          * Parse skinvar importskininfo
3567          * 
3568          * @param       string  $type   name of information for imported skin
3569          * @return      void
3570          */
3571         public function parse_importskininfo($type)
3572         {
3573                 switch ( $type )
3574                 {
3575                         case 'info':
3576                                 echo Entity::hsc(requestVar('skininfo'));
3577                                 break;
3578                         case 'snames':
3579                                 $dataArr = requestArray('skinnames');
3580                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3581                                 break;
3582                         case 'tnames':
3583                                 $dataArr = requestArray('tpltnames');
3584                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3585                                 break;
3586                         case 'sclashes':
3587                                 $dataArr = requestArray('skinclashes');
3588                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3589                                 break;
3590                         case 'tclashes':
3591                                 $dataArr = requestArray('tpltclashes');
3592                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3593                                 break;
3594                         case 'skinfile':
3595                                 echo Entity::hsc(requestVar('skinfile'));
3596                                 break;
3597                         case 'mode':
3598                                 echo Entity::hsc(requestVar('mode'));
3599                                 break;
3600                 }
3601                 return;
3602         }
3603         
3604         /**
3605          * AdminActions::parse_inputyesno()
3606          * Parse skinvar inputyesno
3607          * 
3608          * some init stuff for all forms
3609          * 
3610          * @param       void
3611          * @return      void
3612          */
3613         function parse_init()
3614         {
3615                 global $manager;
3616                 
3617                 $item = false;
3618                 if ( requestVar('action') == 'itemedit' )
3619                 {
3620                         $itemid = intRequestVar('itemid');
3621                         $item =& $manager->getItem($itemid, 1, 1);
3622                         
3623                         $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3624                         if ( $item && $blog->convertBreaks() )
3625                         {
3626                                 $item['body'] = removeBreaks($item['body']);
3627                                 $item['more'] = removeBreaks($item['more']);
3628                         }
3629                         $contents = $item;
3630                         $authorid = $contents['authorid'];
3631                 }
3632                 elseif ( requestVar('action') == 'createitem' )
3633                 {
3634                         $blogid = intRequestVar('blogid');
3635                         $blog =& $manager->getBlog($blogid);
3636                         $authorid = '';
3637                 }
3638                 $blog->insertJavaScriptInfo($authorid);
3639                 return;
3640         }
3641         
3642         /**
3643          * AdminActions::parse_inputyesno()
3644          * Parse skinvar inputyesno
3645          * 
3646          * @param       string  $name                   
3647          * @param       string  $checkedval             
3648          * @param       string  $tabindex               
3649          * @param       string  $value1                 
3650          * @param       string  $value2                 
3651          * @param       string  $yesval                 
3652          * @param       string  $noval                  
3653          * @param       string  $isAdmin                
3654          * @param       string  $templateName   
3655          * @return      void
3656          */
3657         public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3658         {
3659                 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3660                 return;
3661         }
3662         
3663         /**
3664          * AdminActions::parse_insertpluginfo()
3665          * Parse templatevar insertpluginfo
3666          */
3667         public function parse_insertpluginfo($type)
3668         {
3669                 $option = Admin::$aOptions;
3670                 switch ( $type )
3671                 {
3672                         case 'id':
3673                                 return $option['pid'];
3674                                 break;
3675                         case 'name':
3676                                 return Entity::hsc($option['pfile']);
3677                                 break;
3678                 }
3679                 return;
3680         }
3681         
3682         /**
3683          * AdminActions::parse_insertpluginoptions()
3684          * Parse skinvar insertpluginoptions
3685          * 
3686          * @param       string  $templateName   name of template
3687          * @return      void
3688          */
3689         public function parse_insertpluginoptions($templateName = '')
3690         {
3691                 $options        = Admin::getAdminaOption();
3692                 $template       = array();
3693                 $templats       = array();
3694                 
3695                 if ( $templateName )
3696                 {
3697                         $templates = Template::read($templateName);
3698                 }
3699                 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3700                 {
3701                         $template['title'] = "<tr>"
3702                                            . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3703                                            . "</tr>\n";
3704                 }
3705                 else
3706                 {
3707                         $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3708                 }
3709                 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3710                 {
3711                         $template['body'] = "<tr>"
3712                                           . "<%listplugplugoptionrow%>"
3713                                           . "</tr>\n";
3714                 }
3715                 else
3716                 {
3717                         $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3718                 }
3719                 
3720                 $prevPid = -1;
3721                 
3722                 include_libs('ACTIONS.php');
3723                 $handler = new Actions($this->skintype);
3724                 $parser = new PARSER($handler);
3725                         
3726                 foreach ( $options as $option )
3727                 {
3728                         
3729                         // new plugin?
3730                         if ( $prevPid != $option['pid'] )
3731                         {
3732                                 $prevPid  = $option['pid'];
3733                                 $parser->parse($template['title']);
3734                         }
3735                         
3736                         $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3737                         
3738                         if ( @$meta['access'] != 'hidden' )
3739                         {
3740                                 $parsed = $parser->parse($template['body']);
3741                         }
3742                 }
3743                 return;
3744         }
3745         
3746         /**
3747          * AdminActions::parse_insplugoptcontent()
3748          * Parse skinvar insplugoptcontent
3749          * 
3750          * @param       void
3751          * @return      void
3752          */
3753         public function parse_insplugoptcontent()
3754         {
3755                 $option = Admin::$aOption;
3756                 
3757                 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3758                 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3759                 {
3760                         echo '<tr>';
3761                         listplug_plugOptionRow($option);
3762                         echo '</tr>';
3763                 }
3764                 return;
3765         }
3766         
3767         /**
3768          * AdminActions::parse_iprangeinput()
3769          * Parse skinvar iprangeinput
3770          * 
3771          * @param       void
3772          * @return      void
3773          */
3774         public function parse_iprangeinput()
3775         {
3776                 if ( requestVar('ip') )
3777                 {
3778                         $iprangeVal = Entity::hsc(requestVar('ip'));
3779                         echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3780                         echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3781                         echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3782                         echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3783                         echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3784                 }
3785                 else
3786                 {
3787                         echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3788                         echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3789                 }
3790                 return;
3791         }
3792         
3793         /**
3794          * AdminActions::parse_itemnavlist()
3795          * Parse skinvar itemnavlist
3796          * 
3797          * @param       void
3798          * @return      void
3799          */
3800         public function parse_itemnavlist()
3801         {
3802                 global $CONF, $manager, $member;
3803                 if ( $this->skintype == 'itemlist' )
3804                 {
3805                         $blogid =  intRequestVar('blogid');
3806                         $blog   =& $manager->getBlog($blogid);
3807                 }
3808                 if ( postVar('start') )
3809                 {
3810                         $start = intPostVar('start');
3811                 }
3812                 else
3813                 {
3814                         $start = 0;
3815                 }
3816                 
3817                 // amount of items to show
3818                 if ( postVar('amount') )
3819                 {
3820                         $amount = intPostVar('amount');
3821                 }
3822                 else
3823                 {
3824                         $amount = intval($CONF['DefaultListSize']);
3825                         if ( $amount < 1 )
3826                         {
3827                                 $amount = 10;
3828                         }
3829                 }
3830                 $query  = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3831                         . " FROM %s, %s, %s, %s"
3832                         . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3833                 
3834                 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3835                 
3836                 if ( $this->skintype == 'itemlist' )
3837                 {
3838                         $query .= ' AND iblog   = ' . $blogid;
3839                         $template['now'] = $blog->getCorrectTime(time());
3840                         
3841                         // non-blog-admins can only edit/delete their own items
3842                         if ( !$member->blogAdminRights($blogid) )
3843                         {
3844                                 $query .= ' AND iauthor = ' . $member->getID();
3845                         }
3846                 }
3847                 elseif ( $this->skintype == 'browseownitems' )
3848                 {
3849                         $query .= ' AND iauthor   = ' . $member->getID();
3850                         $blogid = 0;
3851                         $template['now'] = time();
3852                 }
3853                 
3854                 // search through items
3855                 $search = postVar('search');
3856                 
3857                 if ( !empty($search) )
3858                 {
3859                         $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3860                                 . '  OR  (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3861                                 . '  OR  (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3862                 }
3863                 $query .= ' ORDER BY itime DESC'
3864                         . " LIMIT {$start},{$amount}";
3865                 
3866                 $template['content'] = 'itemlist';
3867                 
3868                 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3869                 $navList->showBatchList('item', $query, 'table', $template);
3870                 return;
3871         }
3872         
3873         /**
3874          * AdminActions::parse_itemoptions()
3875          * Parse skinvar itemoptions
3876          * Adds the itemOptions of a plugin to a page
3877          * @author TeRanEX
3878          */
3879         function parse_itemoptions()
3880         {
3881                 $this->parse_pluginoptions('item');
3882                 return;
3883         }
3884         
3885         /**
3886          * AdminActions::parse_itemoptions()
3887          * 
3888          * date change on edit item
3889          * 
3890          * Parse skinvar itemoptions
3891          * Adds the itemOptions of a plugin to a page
3892          * @author TeRanEX
3893          */
3894         function parse_itemtime($what)
3895         {
3896                 global $manager;
3897                 
3898                 $item = false;
3899                 $itemid = intRequestVar('itemid');
3900                 $item =& $manager->getItem($itemid, 1, 1);
3901                 
3902                 $blog   =& $manager->getBlog(getBlogIDFromItemID($itemid));
3903                 
3904                 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3905                 {
3906                         $item['body'] = removeBreaks($item['body']);
3907                         $item['more'] = removeBreaks($item['more']);
3908                 }
3909                 
3910                 $contents = array();
3911                 if ( requestVar('action') == 'itemedit' )
3912                 {
3913                         $contents = $item;
3914                 } 
3915                 elseif ( requestVar('action') == 'createitem' )
3916                 {
3917                         $data = array(
3918                                 'contents' => &$contents,
3919                                 'blog'     => &$this->blog
3920                         );
3921                         $manager->notify('PreAddItemForm', $data);
3922                 }
3923                 $itemtime = getdate($contents['timestamp']);
3924                 echo $itemtime[$what];
3925                 return;
3926         }
3927         
3928         /**
3929          * AdminActions::parse_jstoolbaroptions()
3930          * Parse skinvar jstoolbaroptions
3931          * 
3932          * @param       void
3933          * @return      void
3934          */
3935         public function parse_jstoolbaroptions()
3936         {
3937                 global $CONF;
3938                 $options = array(
3939                         _SETTINGS_JSTOOLBAR_NONE,
3940                         _SETTINGS_JSTOOLBAR_SIMPLE,
3941                         _SETTINGS_JSTOOLBAR_FULL
3942                 );
3943                 
3944                 $i = 1;
3945                 foreach ( $options as $option )
3946                 {
3947                         $text  = "<option value=\"%d\"%s>%s</option>\n";
3948                         $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3949                         echo sprintf($text, $i, $extra, $option);
3950                         $i++;
3951                 }
3952                 return;
3953         }
3954         /**
3955          * AdminActions::parse_localeselectoptions()
3956          * Parse skinvar localeselectoptions
3957          * 
3958          * @param       void
3959          * @return      void
3960          */
3961         public function parse_localeselectoptions()
3962         {
3963                 $locales = i18n::get_available_locale_list();
3964                 
3965                 $memid = intRequestVar('memberid');
3966                 if ( $memid )
3967                 {
3968                         $mem = MEMBER::createFromID($memid);
3969                         if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3970                         {
3971                                 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3972                         }
3973                         else
3974                         {
3975                                 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3976                         }
3977                 }
3978                 else
3979                 {
3980                         if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3981                         {
3982                                 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3983                         }
3984                 }
3985                 foreach ( $locales as $locale )
3986                 {
3987                         if ($memid)
3988                         {
3989                                 if ( $locale == $mem->getLocale() )
3990                                 {
3991                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3992                                 }
3993                                 else
3994                                 {
3995                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
3996                                 }
3997                         }
3998                         else
3999                         {
4000                                 if ( $locale == i18n::get_current_locale() )
4001                                 {
4002                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4003                                 }
4004                                 else
4005                                 {
4006                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
4007                                 }
4008                         }
4009                 }
4010                 return;
4011         }
4012         
4013         /**
4014          * AdminActions::parse_listplugplugoptionrow()
4015          * Parse templatevar listplugplugoptionrow
4016          * 
4017          * @param       string  $templateName   name of template
4018          * @return      void
4019          */
4020         public function parse_listplugplugoptionrow($templateName = '')
4021         {
4022                 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
4023                 return;
4024         }
4025         
4026         /**
4027          * AdminActions::parse_mediadirwarning()
4028          * Parse skinvar mediadirwarning
4029          * 
4030          * @param       void
4031          * @return      void
4032          */
4033         public function parse_mediadirwarning()
4034         {
4035                 global $DIR_MEDIA;
4036                 if ( !is_dir($DIR_MEDIA) )
4037                 {
4038                         echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4039                 }
4040                 if ( !is_readable($DIR_MEDIA) )
4041                 {
4042                         echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4043                 }
4044                 if ( !is_writeable($DIR_MEDIA) )
4045                 {
4046                         echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4047                 }
4048                 return;
4049         }
4050         
4051         /**
4052          * AdminActions::parse_movedistselect()
4053          * Parse skinvar movedistselect
4054          */
4055         public function parse_movedistselect()
4056         {
4057                 $actionType = requestVar('action');
4058                 switch ( $actionType )
4059                 {
4060                         case 'batchitem':
4061                                 Admin::selectBlogCategory('destcatid');
4062                                 break;
4063                         case 'batchcategory':
4064                                 Admin::selectBlog('destblogid');
4065                                 break;
4066                         default:
4067                                 if ( $this->skintype == 'itemmove' )
4068                                 {
4069                                         $query  = "SELECT icat as result FROM %s WHERE inumber=%d;";
4070                                         $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
4071                                         $catid  = quickQuery(sprintf($query, intRequestVar('itemid')));
4072                                         Admin::selectBlogCategory('catid', $catid, 10, 1);
4073                                 }
4074                                 break;
4075                 }
4076                 return;
4077         }
4078         
4079         /**
4080          * AdminActions::parse_moveitemid()
4081          * Parse skinvar moveitemid
4082          * 
4083          * @param       void
4084          * @return      void
4085          */
4086         public function parse_moveitemid()
4087         {
4088                 echo intRequestVar('itemid');
4089                 return;
4090         }
4091         
4092         /**
4093          * AdminActions::parse_newestcompare()
4094          * Parse skinvar newestcompare
4095          * 
4096          * @param       void
4097          * @return      void
4098          */
4099         public function parse_newestcompare()
4100         {
4101                 global $nucleus;
4102                 
4103                 $newestVersion  = getLatestVersion();
4104                 $newestCompare  = str_replace('/', '.', $newestVersion);
4105                 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4106                 
4107                 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4108                 {
4109                         echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4110                         echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4111                 }
4112                 return;
4113         }
4114         
4115         /**
4116          * AdminActions::parse_newmemberselect()
4117          * Parse skinvar newmemberselect
4118          * 
4119          * @param       string  $templateName   name of template to use
4120          * @return      void
4121          */
4122         public function parse_newmemberselect($templateName = '')
4123         {
4124                 $blogid = intRequestVar('blogid');
4125                 
4126                 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4127                 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4128                 $res = sql_query($query);
4129                 
4130                 $tmem = array();
4131                 while ( $tmember = sql_fetch_object($res) ) 
4132                 {
4133                         $tmem[] = intval($tmember->tmember);
4134                 }
4135                 
4136                 $query  = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4137                 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4138                 
4139                 $template['name']        = 'memberid';
4140                 $template['tabindex'] = 10000;
4141                 Showlist($query, 'select', $template, $templateName);
4142                 return;
4143         }
4144         
4145         /**
4146          * AdminActions::parse_newpluginlist()
4147          * Parse skinvar newpluginlist
4148          * 
4149          * @param       void
4150          * @return      void
4151          */
4152         public function parse_newpluginlist()
4153         {
4154                 $candidates = $this->newPlugCandidates;
4155                 foreach ( $candidates as $name )
4156                 {
4157                         echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4158                 }
4159                 return;
4160         }
4161         
4162         /**
4163          * AdminActions::parse_outputspecialdirs()
4164          * Parse skinvar outputspecialdirs
4165          * 
4166          * @param       string  $type   type of setting for directory
4167          * @return      void
4168          */
4169         public function parse_outputspecialdirs($type)
4170         {
4171                 global $DIR_MEDIA, $DIR_NUCLEUS;
4172                 
4173                 switch ( $type )
4174                 {
4175                         case 'nucleusdir':
4176                                 echo Entity::hsc($DIR_NUCLEUS);
4177                                 break;
4178                         case 'mediadir':
4179                                 echo Entity::hsc($DIR_MEDIA);
4180                                 break;
4181                 }
4182                 return;
4183         }
4184         
4185         /**
4186          * AdminActions::parse_passrequestvars()
4187          * Parse skinvar passrequestvars
4188          * 
4189          * @param       void
4190          * @return      void
4191          */
4192         public function parse_passrequestvars()
4193         {
4194                 $passvar   = Admin::getAdminpassvar();
4195                 $oldaction = postVar('oldaction');
4196                 
4197                 if ( ($oldaction != 'logout')
4198                   && ($oldaction != 'login')
4199                   && $passvar
4200                   && !postVar('customaction') )
4201                 {
4202                         passRequestVars();
4203                 }
4204                 return;
4205         }
4206         
4207         /**
4208          * AdminActions::parse_pluginextras()
4209          * Parse skinvar pluginextras
4210          * 
4211          * @param       string  $type   type of plugin context
4212          * @return      void
4213          */
4214         public function parse_pluginextras($type = 'global')
4215         {
4216                 global $manager;
4217                 switch ( $type )
4218                 {
4219                         case 'member':
4220                                 $id  = intRequestVar('memberid');
4221                                 $mem = MEMBER::createFromID($id);
4222                                 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4223                                 break;
4224                         case 'blog':
4225                                 $id  = intRequestVar('blogid');
4226                                 $blg = $manager->getBlog($id);
4227                                 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4228                                 break;
4229                         default:
4230                                 $manager->notify(
4231                                         'GeneralSettingsFormExtras',
4232                                         array(
4233                                         )
4234                                 );
4235                                 break;
4236                 }
4237                 return;
4238         }
4239         
4240         /**
4241          * AdminActions::parse_pluginhelp()
4242          * Parse skinvar pluginhelp
4243          * 
4244          * @param       void
4245          * @return      void
4246          */
4247         public function parse_pluginhelp()
4248         {
4249                 global $manager, $DIR_PLUGINS;
4250                 
4251                 $plugid = intGetVar('plugid');
4252                 $plugName =  getPluginNameFromPid($plugid);
4253                 $plug =& $manager->getPlugin($plugName);
4254                 
4255                 if ( $plug->supportsFeature('HelpPage') > 0 )
4256                 {
4257                         $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4258                         if ( @file_exists($helpfile . 'php') )
4259                         {
4260                                 @include($helpfile . 'php');
4261                                 return;
4262                         }
4263                         elseif ( @file_exists($helpfile . 'html') )
4264                         {
4265                                 @include($helpfile . 'html');
4266                                 return;
4267                         }
4268                 }
4269                 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4270                 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4271                 return;
4272         }
4273         
4274         /**
4275          * AdminActions::parse_pluginlistlist()
4276          * Parse skinvar pluginlistlist
4277          * 
4278          * @param       string  $templateName   name of template to use
4279          * @return      void
4280          */
4281         public function parse_pluginlistlist($templateName = '')
4282         {
4283                 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4284                 $query = sprintf($query, sql_table('plugin'));
4285                 
4286                 $template['content']  = 'pluginlist';
4287                 $template['tabindex'] = 10;
4288                 
4289                 Showlist($query, 'table', $template, $templateName);
4290                 
4291                 return;
4292         }
4293         
4294         /**
4295          * AdminActions::parse_pluginoptions()
4296          * Parse skinvar pluginoptions
4297          * 
4298          * @param       string  $type   type of plugin option
4299          * @return      void
4300          */
4301         public function parse_pluginoptions($type = 'global')
4302         {
4303                 global $itemid;
4304                 
4305                 switch ( $type )
4306                 {
4307                         case 'member':
4308                                 $id = intRequestVar('memberid');
4309                                 break;
4310                         case 'blog':
4311                                 $id = intRequestVar('blogid');
4312                                 break;
4313                         case 'category':
4314                                 $id = intRequestVar('catid');
4315                                 break;
4316                         case 'item':
4317                                 $id = $itemid;
4318                                 break;
4319                 }
4320                 Admin::insertPluginOptions($type, $id);
4321                 return;
4322         }
4323         
4324         /**
4325          * AdminActions::parse_qmenuaddselect()
4326          * Parse skinvar qmanuaddselect
4327          * 
4328          * @param       string  $templateName   name of template to use
4329          * @return      void
4330          */
4331         public function parse_qmenuaddselect($templateName = '')
4332         {
4333                 global $member;
4334                 $showAll = requestVar('showall');
4335                 if ( $member->isAdmin() && ($showAll == 'yes') )
4336                 {
4337                         // Super-Admins have access to all blogs! (no add item support though)
4338                         $query =  'SELECT bnumber as value, bname as text'
4339                                . ' FROM ' . sql_table('blog')
4340                                . ' ORDER BY bname';
4341                 }
4342                 else
4343                 {
4344                         $query =  'SELECT bnumber as value, bname as text'
4345                                . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4346                                . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4347                                . ' ORDER BY bname';
4348                 }
4349                 
4350                 $template['name']               = 'blogid';
4351                 $template['tabindex']   = 15000;
4352                 $template['extra']              = _QMENU_ADD_SELECT;
4353                 $template['selected']   = -1;
4354                 $template['shorten']    = 10;
4355                 $template['shortenel']  = '';
4356                 $template['javascript'] = 'onchange="return form.submit()"';
4357                 
4358                 Showlist($query, 'select', $template, $templateName);
4359                 
4360                 return;
4361         }
4362
4363         /**
4364          * AdminActions::parse_quickmenu()
4365          * Parse skinvar quickmenu
4366          * 
4367          * @param       string  $templateName   name of template to use
4368          * @return      void
4369          */
4370         public function parse_quickmenu($templateName = '')
4371         {
4372                 global $manager;
4373                 $templates = array();
4374                 $template  = array();
4375                 if ( !empty($templateName) )
4376                 {
4377                         $templates = Template::read($templateName);
4378                 }
4379                 $pluginExtras = array();
4380                 $manager->notify(
4381                         'QuickMenu',
4382                         array(
4383                                 'options' => &$pluginExtras
4384                         )
4385                 );
4386                 if ( count($pluginExtras) > 0 )
4387                 {
4388                         if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4389                         {
4390                                 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4391                         }
4392                         else
4393                         {
4394                                 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4395                         }
4396                         if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4397                         {
4398                                 $template['head'] = "<ul>\n";
4399                         }
4400                         else
4401                         {
4402                                 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4403                         }
4404                         if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4405                         {
4406                                 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4407                         }
4408                         else
4409                         {
4410                                 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4411                         }
4412                         if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4413                         {
4414                                 $template['foot'] = "</ul>\n";
4415                         }
4416                         else
4417                         {
4418                                 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4419                         }
4420                         
4421                         $handler = new Actions($this->skintype);
4422                         $parser = new PARSER($handler);
4423                         
4424                         $parser->parse($template['title']);
4425                         echo $template['head'];
4426                         foreach ( $pluginExtras as $aInfo )
4427                         {
4428                                 $data = array(
4429                                         'plugadminurl'          => Entity::hsc($aInfo['url']),
4430                                         'plugadmintooltip'      => Entity::hsc($aInfo['tooltip']),
4431                                         'plugadmintitle'        => Entity::hsc($aInfo['title']),
4432                                 );
4433                                 echo Template::fill($template['body'], $data);
4434                         }
4435                         echo $template['foot'];
4436                 }
4437                 return;
4438         }
4439         
4440         /**
4441          * AdminActions::parse_requestblogid()
4442          * Parse skinvar requestblogid
4443          * 
4444          * @param       void
4445          * @return      void
4446          */
4447         public function parse_requestblogid()
4448         {
4449                 echo intRequestVar('blogid');
4450                 return;
4451         }
4452         
4453         /**
4454          * AdminActions::parse_requestiprange()
4455          * Parse skinvar requestiprange
4456          * 
4457          * @param       void
4458          * @return      void
4459          */
4460         public function parse_requestiprange()
4461         {
4462                 if ( requestVar('iprange') )
4463                 {
4464                         echo Entity::hsc(requestVar('iprange'));
4465                 }
4466                 elseif ( requestVar('ip') )
4467                 {
4468                         echo Entity::hsc(requestVar('ip'));
4469                 }
4470                 return;
4471         }
4472         
4473         /**
4474          * AdminActions::parse_selectlocaladminskinfiles()
4475          * Parse skinvar selectlocaladminskinfiles
4476          * 
4477          * @param       void
4478          * @return      void
4479          */
4480         public function parse_selectlocaladminskinfiles()
4481         {
4482                 global $DIR_SKINS, $manager;
4483                 
4484                 $adminskindir = $DIR_SKINS . 'admin/';
4485                 $candidates = SkinImport::searchForCandidates($adminskindir);
4486                 
4487                 foreach ( $candidates as $skinname => $skinfile )
4488                 {
4489                         $html = Entity::hsc($skinfile);
4490                         echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4491                 }
4492                 
4493                 return;
4494         }
4495         
4496         /**
4497          * AdminActions::parse_selectlocalskinfiles()
4498          * Parse skinvar selectlocalskinfiles
4499          * 
4500          * @param       void
4501          * @return      void
4502          */
4503         public function parse_selectlocalskinfiles()
4504         {
4505                 global $DIR_SKINS;
4506                 
4507                 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4508                 
4509                 foreach ( $candidates as $skinname => $skinfile )
4510                 {
4511                         $html = Entity::hsc($skinfile);
4512                         echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4513                 }
4514                 
4515                 return;
4516         }
4517         
4518         /**
4519          * AdminActions::parse_skineditallowedlist()
4520          * Parse skinvar skineditallowedlist
4521          * 
4522          * @param       string  $type                   type of skin
4523          * @param       string  $templateName   name of template
4524          * @return      void
4525          */
4526         public function parse_skineditallowedlist($type, $templateName = '')
4527         {
4528                 switch ( $type )
4529                 {
4530                         case 'blog':
4531                                 $query = "SELECT bshortname, bname FROM %s;";
4532                                 $show  = array(
4533                                         'content' => 'shortblognames'
4534                                 );
4535                                 $query = sprintf($query, sql_table('blog'));
4536                                 Showlist($query, 'table', $show, $templateName);
4537                                 break;
4538                         case 'template':
4539                                 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4540                                 $show  = array(
4541                                         'content' => 'shortnames'
4542                                 );
4543                                 $query = sprintf($query, sql_table('template_desc'));
4544                                 Showlist($query, 'table', $show, $templateName);
4545                                 break;
4546                 }
4547                 return;
4548         }
4549         
4550         /**
4551          * AdminActions::parse_skinielist()
4552          * Parse skinvar skinielist
4553          * 
4554          * @param       string  $type                   type of skin
4555          * @param       string  $templateName   name of template to use
4556          * @return      void
4557          */
4558         public function parse_skinielist($type, $templateName = '')
4559         {
4560                 $templates = array();
4561                 if ( $templateName )
4562                 {
4563                         $templates = Template::read($templateName);
4564                 }
4565                 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4566                 {
4567                         $template = $templates['SKINIE_EXPORT_LIST'];
4568                 }
4569                 else
4570                 {
4571                         $template = "<td>"
4572                                   . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4573                                   . "<label for=\"<%expid%>\"><%expname%></label>\n"
4574                                   . "</td>\n"
4575                                   . "<td><%expdesc%></td>\n"
4576                                   . "</tr>\n"
4577                                   . "<tr>\n";
4578                 }
4579                 switch ( $type )
4580                 {
4581                         case 'skin':
4582                                 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4583                                 while ( $skinObj = sql_fetch_object($res) )
4584                                 {
4585                                         $data = array(
4586                                                 'typeid'        => 'skin[' . $skinObj->sdnumber . ']',
4587                                                 'expid'         => 'skinexp' . $skinObj->sdnumber,
4588                                                 'expname'       => Entity::hsc($skinObj->sdname),
4589                                                 'expdesc'       => Entity::hsc($skinObj->sddesc),
4590                                         );
4591                                         echo Template::fill($template, $data);
4592                                 }
4593                                 break;
4594                         case 'template':
4595                                 $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4596                                 while ($templateObj = sql_fetch_object($res)) {
4597                                         $data = array(
4598                                                 'typeid'        => 'template[' . $templateObj->tdnumber . ']',
4599                                                 'expid'         => 'templateexp' . $templateObj->tdnumber,
4600                                                 'expname'       => Entity::hsc($templateObj->tdname),
4601                                                 'expdesc'       => Entity::hsc($templateObj->tddesc),
4602                                         );
4603                                         echo Template::fill($template, $data);
4604                                 }
4605                                 break;
4606                 }
4607                 return;
4608         }
4609         
4610         /**
4611          * AdminActions::parse_skinoverview()
4612          * Parse skinvar skinoverview
4613          * 
4614          * @param       string  $templateName   name of template to use
4615          * @return      void
4616          */
4617         public function parse_skinoverview($templateName = '')
4618         {
4619                 global $CONF;
4620                 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4621                 $query = sprintf($query, sql_table('skin_desc'));
4622                 
4623                 $template['content']  = 'skinlist';
4624                 $template['tabindex'] = 10;
4625                 
4626                 Showlist($query, 'table', $template, $templateName);
4627                 return;
4628         }
4629         
4630         /**
4631          * AdminActions::parse_skintypehelp()
4632          * Check editing skintypehelp
4633          * 
4634          * @param       void
4635          * @return      void
4636          */
4637         public function parse_skintypehelp()
4638         {
4639                 $nowSkinType = strtolower(trim(requestVar('type')));
4640                 
4641                 /* TODO: use Skin class */
4642                 $regularType = array(
4643                         'index',
4644                         'item',
4645                         'archivelist',
4646                         'archive',
4647                         'search',
4648                         'error',
4649                         'member',
4650                         'imagepopup'
4651                 );
4652                 
4653                 if ( in_array($nowSkinType, $regularType) )
4654                 {
4655                         help('skinpart' . $nowSkinType);
4656                 }
4657                 else
4658                 {
4659                         help('skinpartspecial');
4660                 }
4661                 return;
4662         }
4663         
4664         /**
4665          * AdminActions::parse_specialskinlist()
4666          * Parse skinvar specialskinlist
4667          * 
4668          * @param       string  $templateName   name of template to use
4669          * @return      void
4670          */
4671         public function parse_specialskinlist($templateName = '')
4672         {
4673                 $templates = array();
4674                 if ( $templateName )
4675                 {
4676                         $templates = Template::read($templateName);
4677                 }
4678                 
4679                 /* TODO: use Skin class */
4680                 $nType  = array(
4681                         'index',
4682                         'item',
4683                         'error',
4684                         'search',
4685                         'archive',
4686                         'archivelist',
4687                         'imagepopup',
4688                         'member'
4689                 );
4690                 $skinid = intRequestVar('skinid');
4691                 $query  = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4692                 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4693                 
4694                 $res    = sql_query($query);
4695                 if ( $res && sql_num_rows($res) > 0 )
4696                 {
4697                         $data = array();
4698                         if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4699                         {
4700                                 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4701                         }
4702                         else
4703                         {
4704                                 $template['head'] = "<ul>\n";
4705                         }
4706                         echo Template::fill($template['head'], $data);
4707                         if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4708                         {
4709                                 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&amp;skinid=<%skinid%>'
4710                                                                   . '&amp;type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4711                                                                   . 'action=skinremovetype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">remove</a>)</li>';
4712                         }
4713                         else
4714                         {
4715                                 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4716                         }
4717                         
4718                         $tabstart = 75;
4719                         while ( $row = sql_fetch_assoc($res) )
4720                         {
4721                                 $data = array(
4722                                         'tabindex'      => $tabstart++,
4723                                         'skinid'        => $skinid,
4724                                         'skintype'      => Entity::hsc(strtolower($row['stype']))
4725                                 );
4726                                 echo Template::fill($template['body'], $data);
4727                         }
4728                         $data = array();
4729                         if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4730                         {
4731                                 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4732                         }
4733                         else
4734                         {
4735                                 $template['foot'] = "</ul>\n";
4736                         }
4737                         echo Template::fill($template['foot'], $data);
4738                         return;
4739                 }
4740         }
4741         
4742         /**
4743          * AdminActions::parse_sprinttext()
4744          * Parse sprinttext
4745          * 
4746          * @param       string  $which  
4747          * @param       string  $val    
4748          * @return      void
4749          */
4750         public function parse_sprinttext($which, $val)
4751         {
4752                 if ( !defined($which) )
4753                 {
4754                         $base = $which;
4755                 }
4756                 else
4757                 {
4758                         $base = constant($which);
4759                 }
4760                 
4761                 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4762                 {
4763                         if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4764                         {
4765                                 $met = 'parse_' . $matchies[0];
4766                         }
4767                         else
4768                         {
4769                                 $arg = trim($args[0], '()');
4770                                 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4771                         }
4772                         
4773                         if ( method_exists($this, $met) )
4774                         {
4775                                 $value = call_user_func(array(&$this, $met), $arg);
4776                         }
4777                 }
4778                 
4779                 if ( !isset($value) || empty($value) )
4780                 {
4781                         $value = $val;
4782                 }
4783                 echo sprintf($base, $value);
4784                 return;
4785         }
4786         
4787         /**
4788          * AdminActions::parse_systemsettings()
4789          * Parse skinvar systemsettings
4790          * 
4791          * @param       string  $type                   type of settings for system
4792          * @param       string  $templateName   name of template to use 
4793          * @return      void
4794          */
4795         public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4796         {
4797                 global $member, $CONF, $nucleus;
4798                 
4799                 $member->isAdmin() or Admin::disallow();
4800                 
4801                 $enable  = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4802                 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4803                 
4804                 switch ( $type )
4805                 {
4806                         case 'phpversion':
4807                                 echo phpversion();
4808                                 break;
4809                         case 'sqlserverinfo':
4810                                 echo sql_get_server_info();
4811                                 break;
4812                         case 'sqlclientinfo':
4813                                 echo sql_get_client_info();
4814                                 break;
4815                         case 'magicquotesgpc':
4816                                 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4817                                 break;
4818                         case 'magicquotesruntime':
4819                                 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4820                                 break;
4821                         case 'registerglobals':
4822                                 echo ini_get('register_globals') ? 'On' : 'Off';
4823                                 break;
4824                         case 'gdinfo':
4825                                 $templates = array();
4826                                 if ( $templateName )
4827                                 {
4828                                         $templates = Template::read($templateName);
4829                                 }
4830                                 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4831                                 {
4832                                         $template = "<tr>\n"
4833                                                   . "<td><%key%></td>\n"
4834                                                   . "<td><%value%></td>\n"
4835                                                   . "</tr>\n";
4836                                 }
4837                                 else
4838                                 {
4839                                         $template = $templates['SYSTEMINFO_GDSETTINGS'];
4840                                 }
4841                                 
4842                                 $gdinfo = gd_info();
4843                                 
4844                                 foreach ( $gdinfo as $key => $value )
4845                                 {
4846                                         if ( is_bool($value) )
4847                                         {
4848                                                 $value = $value ? $enable : $disable;
4849                                         }
4850                                         else
4851                                         {
4852                                                 $value = Entity::hsc($value);
4853                                         }
4854                                         $data = array(
4855                                                 'key'   => $key,
4856                                                 'value' => $value,
4857                                         );
4858                                         echo Template::fill($template, $data);
4859                                 }
4860                                 break;
4861                         case 'modrewrite':
4862                                 ob_start();
4863                                 phpinfo(INFO_MODULES);
4864                                 $im = ob_get_contents();
4865                                 ob_end_clean();
4866                                 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4867                                 break;
4868                         case 'nucleusversion':
4869                                 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4870                                 break;
4871                         case 'nucleuspatchlevel':
4872                                 echo getNucleusPatchLevel();
4873                                 break;
4874                         case 'confself':
4875                                 echo $CONF['Self'];
4876                                 break;
4877                         case 'confitemurl':
4878                                 echo $CONF['ItemURL'];
4879                                 break;
4880                         case 'alertonheaderssent':
4881                                 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4882                                 break;
4883                         case 'nucleuscodename':
4884                                 if ( $nucleus['codename'] != '' )
4885                                 {
4886                                         echo ' &quot;' . $nucleus['codename'] . '&quot;';
4887                                 }
4888                                 break;
4889                         case 'versioncheckurl':
4890                                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4891                                 break;
4892                 }
4893                 return;
4894         }
4895         
4896         /**
4897          * AdminActions::parse_templateoverview()
4898          * Parse skinvar templateoverview
4899          * 
4900          * @param       string  $templateName   name of template to use
4901          * @return      void
4902          */
4903         public function parse_templateoverview($templateName = '')
4904         {
4905                 $query  = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4906                 $query = sprintf($query, sql_table('template_desc'));
4907                 
4908                 $template['content']  = 'templatelist';
4909                 $template['tabindex'] = 10;
4910                 
4911                 Showlist($query, 'table', $template, $templateName);
4912                 
4913                 return;
4914         }
4915         
4916         /**
4917          * AdminActions::parse_ticket()
4918          * Parse ticket
4919          * 
4920          * @param       void
4921          * @return      void
4922          */
4923         public function parse_ticket()
4924         {
4925                 global $manager;
4926                 $manager->addTicketHidden();
4927                 return;
4928         }
4929         
4930         /**
4931          * AdminActions::parse_versioncheckurl()
4932          * Parse skinvar versioncheckurl
4933          * 
4934          * @param       void
4935          * @return      void
4936          */
4937         public function parse_versioncheckurl()
4938         {
4939                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4940                 return;
4941         }
4942         
4943         /**
4944          * AdminActions::parse_yrbloglist()
4945          * Parse skinvar yrbloglist
4946          * 
4947          * @param       string  $templateName   name of template to use
4948          * @return      void
4949          */
4950         public function parse_yrbloglist($templateName = '')
4951         {
4952                 global $member;
4953                 $showAll = requestVar('showall');
4954                 
4955                 if ( $member->isAdmin() && ($showAll == 'yes') )
4956                 {
4957                         // Super-Admins have access to all blogs! (no add item support though)
4958                         $query =  "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4959                                 . " FROM %s"
4960                                 . " ORDER BY bnumber;";
4961                         $query = sprintf($query, sql_table('blog'));
4962                 }
4963                 else
4964                 {
4965                         $query =  "SELECT bnumber, bname, tadmin, burl, bshortname"
4966                                 . " FROM %s,%s"
4967                                 . " WHERE tblog=bnumber and tmember=%d"
4968                                 . " ORDER BY bnumber;";
4969                         $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4970                 }
4971                 
4972                 $template['content']    = 'bloglist';
4973                 $template['superadmin'] = $member->isAdmin();
4974                 
4975                 $amount = Showlist($query, 'table', $template, $templateName);
4976                 
4977                 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4978                 {
4979                         $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4980                         
4981                         $total = quickQuery($query);
4982                         if ( $total > $amount )
4983                         {
4984                                 echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4985                         }
4986                 }
4987                 
4988                 if ( $amount == 0 )
4989                 {
4990                         echo _OVERVIEW_NOBLOGS;
4991                 }
4992                 elseif( $amount != 0 )
4993                 {
4994                         echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4995                         
4996                         $query =  "SELECT ititle, inumber, bshortname"
4997                                . " FROM %s,%s"
4998                                . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4999                         $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
5000                         
5001                         $template['content'] = 'draftlist';
5002                         
5003                         $amountdrafts = Showlist($query, 'table', $template, $templateName);
5004                         if ( $amountdrafts == 0 )
5005                         {
5006                                 echo _OVERVIEW_NODRAFTS;
5007                         }
5008                 }
5009                 return;
5010         }
5011         
5012         /**
5013          * AdminActions::checkCondition()
5014          * Checks conditions for if statements
5015          *
5016          * @param       string  $field type of <%if%>
5017          * @param       string  $name property of field
5018          * @param       string  $value value of property
5019          * @return      boolean condition
5020          */
5021         protected function checkCondition($field, $name='', $value = '')
5022         {
5023                 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
5024                 
5025                 $condition = 0;
5026                 switch ( $field )
5027                 {
5028                         case 'category':
5029                                 if ( !$blog )
5030                                 {
5031                                         if ( $blogid )
5032                                         {
5033                                                 global $manager;
5034                                                 $blog =& $manager->getBlog($blogid);
5035                                         }
5036                                         elseif ( $catid )
5037                                         {
5038                                                 $blogid = getBlogIDFromCatID($catid);
5039                                                 global $manager;
5040                                                 $blog =& $manager->getBlog($blogid);
5041                                         }
5042                                         elseif ( intRequestVar('catid') )
5043                                         {
5044                                                 $catid = intRequestVar('catid');
5045                                                 $blogid = getBlogIDFromCatID($catid);
5046                                                 global $manager;
5047                                                 $blog =& $manager->getBlog($blogid);
5048                                         }
5049                                         else
5050                                         {
5051                                                 return;
5052                                         }
5053                                 }
5054                                 $condition = ($blog && $this->ifCategory($name, $value));
5055                                 break;
5056                         case 'blogsetting':
5057                                 $condition = ($blog && ($blog->getSetting($name) == $value));
5058                                 break;
5059                         case 'loggedin':
5060                                 $condition = $member->isLoggedIn();
5061                                 break;
5062                         case 'onteam':
5063                                 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5064                                 break;
5065                         case 'admin':
5066                                 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5067                                 break;
5068                         case 'superadmin':
5069                                 $condition = $member->isLoggedIn() && $member->isAdmin();
5070                                 break;
5071                         case 'allowloginedit':
5072                                 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5073                                 break;
5074                         case 'nextitem':
5075                                 $condition = ($itemidnext != '');
5076                                 break;
5077                         case 'previtem':
5078                                 $condition = ($itemidprev != '');
5079                                 break;
5080                         case 'archiveprevexists':
5081                                 $condition = ($archiveprevexists == true);
5082                                 break;
5083                         case 'archivenextexists':
5084                                 $condition = ($archivenextexists == true);
5085                                 break;
5086                         case 'skintype':
5087                                 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5088                                 break;
5089                         case 'hasplugin':
5090                                 $condition = $this->ifHasPlugin($name, $value);
5091                                 break;
5092                         case 'adminaction':
5093                                 $condition = (Admin::getAdminAction() == $name);
5094                                 break;
5095                         case 'adminoldaction':
5096                                 $condition = (Admin::getAdminAction() == $name);
5097                                 break;
5098                         case 'addresschange':
5099                                 $condition = ($this->ifAddresscange());
5100                                 break;
5101                         case 'bechangepass':
5102                                 $condition = ($this->beChangePassword());
5103                                 break;
5104                         case 'skincandidates':
5105                                 $condition = ($this->ifSkincandidates());
5106                                 break;
5107                         case 'nameclashes':
5108                                 $condition = requestVar('nameclashes');
5109                                 break;
5110                         case 'existsnewplugin':
5111                                 $condition = ($this->existsNewPlugin());
5112                                 break;
5113                         case 'autosave':
5114                                 $condition = (boolean) ($member->getAutosave() == $value);
5115                                 break;
5116                         default:
5117                                 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5118                                 break;
5119                 }
5120                 return $condition;
5121         }
5122         
5123         /**
5124          * Actions::_ifHasPlugin()
5125          *      hasplugin,PlugName
5126          *         -> checks if plugin exists
5127          *      hasplugin,PlugName,OptionName
5128          *         -> checks if the option OptionName from plugin PlugName is not set to 'no'
5129          *      hasplugin,PlugName,OptionName=value
5130          *         -> checks if the option OptionName from plugin PlugName is set to value
5131          *
5132          * @param       string  $name   name of plugin
5133          * @param       string  $value  
5134          * @return      
5135          */
5136         private function ifHasPlugin($name, $value)
5137         {
5138                 global $manager;
5139                 $condition = false;
5140                 // (pluginInstalled method won't write a message in the actionlog on failure)
5141                 if ( $manager->pluginInstalled("NP_{$name}") )
5142                 {
5143                         $plugin =& $manager->getPlugin("NP_{$name}");
5144                         if ( $plugin != NULL )
5145                         {
5146                                 if ( $value == "" )
5147                                 {
5148                                         $condition = true;
5149                                 }
5150                                 else
5151                                 {
5152                                         list($name2, $value2) = preg_split('#=#', $value, 2);
5153                                         if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5154                                         {
5155                                                 $condition = true;
5156                                         }
5157                                         else if ( $plugin->getOption($name2) == $value2 )
5158                                         {
5159                                                 $condition = true;
5160                                         }
5161                                 }
5162                         }
5163                 }
5164                 return $condition;
5165         }
5166         
5167         /**
5168          * Actions::beChangePassword()
5169          * 
5170          * @param       void
5171          * @return      void
5172          */
5173         private function beChangePassword()
5174         {
5175                 return intRequestVar('bNeedsPasswordChange');
5176         }
5177         
5178         /**
5179          * Actions::ifSkincandidates()
5180          * Checks if a plugin exists and call its doIf function
5181          * 
5182          * @param       void
5183          * @return      void
5184          * @return      boolean
5185          */
5186         private function ifSkincandidates()
5187         {
5188                 global $DIR_SKINS;
5189                 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5190                 return (count($candidates) > 0);
5191         }
5192         
5193         /**
5194          * Actions::ifPlugin()
5195          * Checks if a plugin exists and call its doIf function
5196          * 
5197          * @param       string  $name   name of plugin
5198          * @param       string  $key    
5199          * @param       string  $value  
5200          * @return      callback
5201          */
5202         private function ifPlugin($name, $key = '', $value = '')
5203         {
5204                 global $manager;
5205
5206                 $plugin =& $manager->getPlugin("NP_{$name}");
5207                 if ( !$plugin )
5208                 {
5209                         return;
5210                 }
5211                 
5212                 $params = func_get_args();
5213                 array_shift($params);
5214                 
5215                 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5216         }
5217
5218         /**
5219          * AdminActions::ifCategory()
5220          *  Different checks for a category
5221          * 
5222          * @param       string  $key    key for information of category
5223          * @param       string  $value  value for information of category
5224          * @return      boolean
5225          */
5226         private function ifCategory($key = '', $value='')
5227         {
5228                 global $blog, $catid;
5229                 
5230                 // when no parameter is defined, just check if a category is selected
5231                 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5232                 {
5233                         return $blog->isValidCategory($catid);
5234                 }
5235                 
5236                 // check category name
5237                 if ( $key == 'catname' )
5238                 {
5239                         $value = $blog->getCategoryIdFromName($value);
5240                         if ($value == $catid)
5241                         {
5242                                 return $blog->isValidCategory($catid);
5243                         }
5244                 }
5245                 
5246                 // check category id
5247                 if (($key == 'catid') && ($value == $catid))
5248                 {
5249                         return $blog->isValidCategory($catid);
5250                 }
5251                 
5252                 return FALSE;
5253         }
5254         
5255         /**
5256          * AdminActions::ifOnTeam()
5257          * Checks if a member is on the team of a blog and return his rights
5258          * 
5259          * @param       string  $blogName       name of weblog
5260          * @return      boolean
5261          */
5262         private function ifOnTeam($blogName = '')
5263         {
5264                 global $blog, $member, $manager;
5265                 
5266                 // when no blog found
5267                 if ( ($blogName == '') && !is_object($blog) )
5268                 {
5269                         return 0;
5270                 }
5271                 
5272                 // explicit blog selection
5273                 if ($blogName != '')
5274                 {
5275                         $blogid = getBlogIDFromName($blogName);
5276                 }
5277                 
5278                 if (($blogName == '') || !$manager->existsBlogID($blogid))
5279                 {
5280                         // use current blog
5281                         $blogid = $blog->getID();
5282                 }
5283                 return $member->teamRights($blogid);
5284         }
5285         
5286         /**
5287          * AdminActions::ifAdmin()
5288          * Checks if a member is admin of a blog
5289          * 
5290          * @param       string  $blogName       name of weblog
5291          * @return      boolean
5292          */
5293         private function ifAdmin($blogName = '')
5294         {
5295                 global $blog, $member, $manager;
5296                 
5297                 // when no blog found
5298                 if (($blogName == '') && (!is_object($blog)))
5299                 {
5300                         return 0;
5301                 }
5302                 
5303                 // explicit blog selection
5304                 if ($blogName != '')
5305                 {
5306                         $blogid = getBlogIDFromName($blogName);
5307                 }
5308                 
5309                 if (($blogName == '') || !$manager->existsBlogID($blogid))
5310                 {
5311                         // use current blog
5312                         $blogid = $blog->getID();
5313                 }
5314                 
5315                 return $member->isBlogAdmin($blogid);
5316         }
5317         
5318         /**
5319          * AdminActions::ifAddresscange()
5320          * Check e-Mail address is changed
5321          * 
5322          * @param       void
5323          * @return      boolean
5324          */
5325         private function ifAddresscange()
5326         {
5327                 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5328                 if ( !$key )
5329                 {
5330                         return FALSE;
5331                 }
5332                 $info = MEMBER::getActivationInfo($key);
5333                 if ( !$info )
5334                 {
5335                         return FALSE;
5336                 }
5337                 $mem  = MEMBER::createFromId($info->vmember);
5338                 if ( !$mem )
5339                 {
5340                         return FALSE;
5341                 }
5342                 if ( $info->vtype == 'addresschange' )
5343                 {
5344                         return TRUE;
5345                 }
5346                 return FALSE;
5347         }
5348         
5349         /**
5350          * AdminActions::templateEditRow()
5351          * Template edit box
5352          * 
5353          * @param       array   $template       
5354          * @param       string  $desc           
5355          * @param       string  $name           
5356          * @param       string  $help           
5357          * @param       integer $tabindex       
5358          * @param       boolean $big            
5359          * @param       array   $tmplt          
5360          * @return      void
5361          */
5362         private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5363         {
5364                 static $count = 1;
5365                 
5366                 if ( !array_key_exists($name, $template) )
5367                 {
5368                         $template[$name] = '';
5369                 }
5370                 
5371                 $tmplt = array();
5372                 $base  = array();
5373                 
5374                 if ( $tplt )
5375                 {
5376                         $tmplt = skinableTEMPLATE::read($tplt);
5377                 }
5378                 
5379                 $data = array(
5380                         'description'   => $desc,
5381                         'help'                  => empty($help) ? '' : helpHtml('template' . $help),
5382                         'count'                 => $count,
5383                         'name'                  => $name,
5384                         'tabindex'              => $tabindex,
5385                         'rows'                  => $big ? 10 : 5,
5386                 );
5387                 
5388                 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5389                 {
5390                         $base['head'] = "</tr>"
5391                                       . "<tr>\n"
5392                                       . "<td><%description%><%help%></td>\n"
5393                                       . "<td id=\"td<%count%>\">\n"
5394                                       . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5395                 }
5396                 else
5397                 {
5398                         $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5399                 }
5400                 
5401                 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5402                 {
5403                         $base['tail'] = "</textarea>\n"
5404                                       . "</td>\n";
5405                 }
5406                 else
5407                 {
5408                         $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5409                 }
5410                 
5411                 echo TEMPLATE::fill($base['head'], $data);
5412                 echo ENTITY::hsc($template[$name]);
5413                 echo TEMPLATE::fill($base['tail'], $data);
5414                 
5415                 $count++;
5416                 
5417                 return;
5418         }
5419         
5420         /**
5421          * AdminActions::customHelp()
5422          * shows a link to custom help file
5423          * 
5424          * @param       string  $id                     
5425          * @param       string  $tplName        
5426          * @param       string  $url            
5427          * @param       string  $iconURL        
5428          * @param       string  $alt            
5429          * @param       string  $title          
5430          * @param       $onclick
5431          * 
5432          */
5433         private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5434         {
5435                 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5436         }
5437         
5438         /**
5439          * AdminActions::customHelp()
5440          * shows a link to custom help file
5441          * 
5442          * @param       string  $id                     
5443          * @param       string  $tplName        
5444          * @param       string  $url            
5445          * @param       string  $iconURL        
5446          * @param       string  $alt            
5447          * @param       string  $title          
5448          * @param       $onclick
5449          * 
5450          */
5451         static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5452         {
5453                 global $CONF;
5454                 
5455                 $templates = array();
5456                 
5457                 if ( $tplName )
5458                 {
5459                         $templates = Template::read($tplName);
5460                 }
5461                 
5462                 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5463                 {
5464                         $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5465                 }
5466                 else
5467                 {
5468                         $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5469                 }
5470                 
5471                 if ( empty($url) )
5472                 {
5473                         $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5474                 }
5475                 
5476                 if ( empty($onclick) )
5477                 {
5478                         $onclick = 'onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);"';
5479                 }
5480                 elseif ( preg_match('#^onclick#', $onclick) )
5481                 {
5482                         $onclick = $onclick;
5483                 }
5484                 else
5485                 {
5486                         $onclick = 'onclick="' . $onclick . '"';
5487                 }
5488                 
5489                 $data = array(
5490                         'helpurl'               => $url,
5491                         'helptarget'    => $id,
5492                         'onclick'               => $onclick,
5493                         'title'                 => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5494                 );
5495                 return Template::fill($template, $data);
5496         }
5497         
5498         /**
5499          * AdminActions::customHelpHtml()
5500          * 
5501          * @param       string  $id                     
5502          * @param       string  $tplName        
5503          * @param       string  $url            
5504          * @param       string  $iconURL        
5505          * @param       string  $alt            
5506          * @param       string  $title          
5507          * @param       string  $onclick        
5508          * @return      string  anchor element with help uri
5509          */
5510         private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5511         {
5512                 global $CONF;
5513                 
5514                 $templates = array();
5515                 
5516                 if ( $tplName )
5517                 {
5518                         $templates = Template::read($tplName);
5519                 }
5520                 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5521                 {
5522                         $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5523                 }
5524                 else
5525                 {
5526                         $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5527                 }
5528                 
5529                 if ( empty($iconURL) )
5530                 {
5531                         $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5532                 }
5533                 
5534                 if ( function_exists('getimagesize') )
5535                 {
5536                         $size   = getimagesize($iconURL);
5537                         $width  = 'width="'  . $size[0] . '" ';
5538                         $height = 'height="' . $size[1] . '" ';
5539                 }
5540                 
5541                 $data = array(
5542                         'iconurl'       => $iconURL,
5543                         'width'         => $width,
5544                         'height'        => $height,
5545                         'alt'           => (isset($alt) && !empty($alt))         ? $alt   : _HELP_TT,
5546                         'title'         => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5547                 );
5548                 
5549                 $icon = Template::fill($template, $data);
5550                 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5551                 
5552                 return $help . $icon;
5553         }
5554         
5555         /**
5556          * AdminActions::input_yesno
5557          * 
5558          * @param               $name
5559          * @param               $checkedval
5560          * @param               $tabindex
5561          * @param               $value1
5562          * @param               $value2
5563          * @param               $yesval
5564          * @param               $noval
5565          * @param               $isAdmin
5566          * @param               $templateName
5567          * @param               $showlist
5568          */
5569         private function input_yesno($name,
5570                                                                 $checkedval,
5571                                                                 $tabindex        = 0,
5572                                                                 $value1    = 1,
5573                                                                 $value2    = 0,
5574                                                                 $yesval    = _YES,
5575                                                                 $noval          = _NO,
5576                                                                 $isAdmin          = 0,
5577                                                                 $templateName = '',
5578                                                                 $showlist        = false)
5579         {
5580                 $templates = array();
5581                 if ( $templateName )
5582                 {
5583                         $templates = Template::read($templateName);
5584                 }
5585                 
5586                 if ( $name == 'admin' )
5587                 {
5588                         if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5589                         {
5590                                 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5591                                           . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5592                                           . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5593                                           . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5594                         }
5595                         else
5596                         {
5597                                 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5598                         }
5599                 }
5600                 else
5601                 {
5602                         if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5603                         {
5604                                 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5605                         }
5606                         if ( $showlist )
5607                         {
5608                                 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5609                                 {
5610                                         $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5611                                 }
5612                         }
5613                         if ( !isset($template) )
5614                         {
5615                                 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5616                                           . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5617                                           . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5618                                           . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5619                         }
5620                 }
5621                 
5622                 //echo $template;
5623                 $id             = Entity::hsc($name);
5624                 $id             = str_replace('[', '-', $id);
5625                 $id             = str_replace(']', '-', $id);
5626                 $id1    = $id . Entity::hsc($value1);
5627                 $id2    = $id . Entity::hsc($value2);
5628                 $dat = array(
5629                         'name'                  => Entity::hsc($name),
5630                         'yesval'                => Entity::hsc($value1),
5631                         'noval'                 => Entity::hsc($value2),
5632                         'yesid'                 => $id1,
5633                         'noid'                  => $id2,
5634                         'yesvaltext'    => $yesval,
5635                         'novaltext'             => $noval,
5636                         'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5637                         'nocheckedval'  => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5638                         'disabled'              => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5639                 );
5640                 
5641                 if ( $showlist )
5642                 {
5643                         return Template::fill($template, $dat);
5644                 }
5645                 else
5646                 {
5647                         echo Template::fill($template, $dat);
5648                 }
5649                 return;
5650         }
5651         
5652         /**
5653          * AdminActions::existsNewPlugin()
5654          * Check exists new plugin
5655          * 
5656          * @param       void
5657          * @return      boolean exists or not
5658          */
5659         private function existsNewPlugin()
5660         {
5661                 global $DIR_PLUGINS;
5662                 
5663                 $candidates = array();
5664                 $files = scandir($DIR_PLUGINS);
5665                 
5666                 foreach ( $files as $file )
5667                 {
5668                         if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
5669                         {
5670                                 $name = $matches[1];
5671                                 $query = "SELECT * FROM %s WHERE pfile='%s';";
5672                                 $query = sprintf($query, sql_table('plugin'), sql_real_escape_string("{NP_{$name}"));
5673                                 $res  = sql_query($query);
5674                                 
5675                                 if ( sql_num_rows($res) == 0 )
5676                                 {
5677                                         $candidates[] = $name;
5678                                 }
5679                         }
5680                         continue;
5681                 }
5682                 $this->newPlugCandidates = $candidates;
5683                 return (count($candidates) > 0);
5684         }
5685 }