OSDN Git Service

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