OSDN Git Service

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