OSDN Git Service

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