OSDN Git Service

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