OSDN Git Service

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