OSDN Git Service

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