OSDN Git Service

FIX: warningの修正。適用されてない翻訳メッセージの修正。admintemplateoverview。
[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                 'admintemplateoverview' => _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                 
2220                 $item = false;
2221                 $contents = array();
2222                 
2223                 if ( requestVar('action') == 'itemedit' )
2224                 {
2225                         $itemid = intRequestVar('itemid');
2226                         $item   =& $manager->getItem($itemid, 1, 1);
2227                         $blog   =& $manager->getBlog(getBlogIDFromItemID($itemid));
2228                         if ( $item && $blog->convertBreaks() )
2229                         {
2230                                 $item['body'] = removeBreaks($item['body']);
2231                                 $item['more'] = removeBreaks($item['more']);
2232                         }
2233                         $contents = $item;
2234                 }
2235                 elseif ( requestVar('action') == 'createitem' )
2236                 {
2237                         $blogid = intRequestVar('blogid');
2238                         $blog =& $manager->getBlog($blogid);
2239                         $manager->notify(
2240                                 'PreAddItemForm',
2241                                 array(
2242                                         'contents' => &$contents,
2243                                         'blog'     => &$blog
2244                                 )
2245                         );
2246                 }
2247                 if ( !isset($contents[$which]) )
2248                 {
2249                         $contents[$which] = '';
2250                 }
2251                 echo Entity::hsc($contents[$which],ENT_QUOTES);
2252         }
2253         
2254         /**
2255          * AdminActions::parse_currenttime()
2256          * Parse skinvar currenttime
2257          * 
2258          * @param       string  $what
2259          */
2260         // for future items
2261         function parse_currenttime($what)
2262         {
2263                 global $manager;
2264                 if ( requestVar('action') == 'itemedit' )
2265                 {
2266                         $itemid = intRequestVar('itemid');
2267                         $blog   =& $manager->getBlog(getBlogIDFromItemID($itemid));
2268                 } 
2269                 elseif ( requestVar('action') == 'createitem' )
2270                 {
2271                         $blog   =& $manager->getBlog(intRequestVar('blogid'));
2272                 }
2273                 $nu     = getdate($blog->getCorrectTime());
2274                 echo $nu[$what];
2275         }
2276         
2277         /**
2278          * AdminActions::parse_customhelplink()
2279          * Parse skinvar customhelplink
2280          * 
2281          * @param       string  $topic          name of topic
2282          * @param       string  $tplName        name of template
2283          * @param       string  $url            string as URI
2284          * @param       string  $iconURL        string as URI for icon
2285          * @param       string  $alt            alternative text for image element
2286          * @param       string  $title          title for anchor element
2287          * @return      void
2288          */
2289         public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2290         {
2291                 $this->customHelp($topic, $url, $iconURL);
2292                 return;
2293         }
2294         
2295         /**
2296          * AdminActions::parse_date()
2297          * Parse skinvar date
2298          */
2299         public function parse_date($format = 'c')
2300         {
2301                 global $CONF, $manager;
2302                 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2303                 return;
2304         }
2305         
2306         /**
2307          * AdminActions::parse_defaultadminskintypes()
2308          * Parse skinvar defaultadminskintypes
2309          * 
2310          * @param       string  $tabindex               index number for tabindex attribute of input element
2311          * @param       string  $templateName   name of template
2312          * @return      void
2313          */
2314         public function parse_defaultadminskintypes($tabindex, $templateName = '')
2315         {
2316                 $templates = array();
2317                 if ( $templateName )
2318                 {
2319                         $templates = Template::read($templateName);
2320                 }
2321                 
2322                 $types   = $this->skin->getAvailableTypes();
2323                 ksort($types);
2324                 
2325                 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
2326                 {
2327                         $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2328                 }
2329                 else
2330                 {
2331                         $template['head'] = "<ul>\n";
2332                 }
2333                 
2334                 echo $template['head'];
2335                 
2336                 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
2337                 {
2338                         $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2339                 }
2340                 else
2341                 {
2342                         $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">'
2343                                           . "<%name%></a> <%help%></li>\n";
2344                 }
2345                 $handler = new Actions('template', $template, new ADMIN);
2346                 
2347                 $parser = new PARSER($handler);
2348                 
2349                 foreach ( $types as $type => $fName )
2350                 {
2351                         $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
2352                         $data = array(
2353                                 'tabindex'      => $tabindex,
2354                                 'skintype'      => $type,
2355                                 'name'          => $fName,
2356                                 'help'          => $helplink,
2357                                 'skinid'        => intrequestVar('skinid'),
2358                         );
2359                         $templateBody = Template::fill($template['body'], $data);
2360                         $parser->parse($templateBody);
2361                         $tabindex++;
2362                 }
2363                 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
2364                 {
2365                         $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2366                 }
2367                 else
2368                 {
2369                         $template['foot'] = "           </ul>\n";
2370                 }
2371                 echo $template['foot'];
2372                 return;
2373         }
2374         
2375         /**
2376          * AdminActions::parse_defblogselect()
2377          * Parse skinvar defblogselect
2378          * 
2379          * @param       string  $templateName   name of template
2380          * @return      void
2381          */
2382         public function parse_defblogselect($templateName = '')
2383         {
2384                 global $CONF;
2385                 $query  = "SELECT bname as text, bnumber as value FROM %s;";
2386                 $query = sprintf($query, sql_table('blog'));
2387                 $template['name']        = 'DefaultBlog';
2388                 $template['selected'] = $CONF['DefaultBlog'];
2389                 $template['tabindex'] = 10;
2390                 Showlist($query, 'select', $template, $templateName);
2391                 return;
2392         }
2393         
2394         /**
2395          * AdminActions::parse_defcatselect()
2396          * Parse skinvar defcatselect
2397          * 
2398          * @param       string  $templateName   name of template
2399          * @return      void
2400          */
2401         public function parse_defcatselect($templateName = '')
2402         {
2403                 global $manager;
2404                 $blogid = intRequestVar('blogid');
2405                 $blog   = $manager->getBlog($blogid);
2406                 $query  = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2407                 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2408                 $template['name']        = 'defcat';
2409                 $template['selected'] = $blog->getDefaultCategory();
2410                 $template['tabindex'] = 110;
2411                 Showlist($query, 'select', $template, $templateName);
2412                 return;
2413         }
2414         
2415         /**
2416          * AdminActions::parse_defskinselect()
2417          * Parse skinvar defskinselect
2418          * 
2419          * @param       string  $type                   type of skin
2420          * @param       string  $templateName   name of template
2421          * @return      void
2422          */
2423         public function parse_defskinselect($type = 'blog', $templateName = '')
2424         {
2425                 global $manager;
2426                 $query  = "SELECT sdname as text, sdnumber as value FROM %s;";
2427                 $query = sprintf($query, sql_table('skin_desc'));
2428                 
2429                 $blogid = intRequestVar('blogid');
2430                 
2431                 if ( !$blogid )
2432                 {
2433                         global $CONF;
2434                         $template['selected'] = $CONF['BaseSkin'];
2435                 }
2436                 else
2437                 {
2438                         $blog                            = $manager->getBlog($blogid);
2439                         $template['selected'] = $blog->getDefaultSkin();
2440                 }
2441                 
2442                 if ( $type != 'blog' )
2443                 {
2444                         $nname = 'BaseSkin';
2445                 }
2446                 else
2447                 {
2448                         $nname = 'defskin';
2449                 }
2450                 
2451                 $template['name']        = $nname;
2452                 $template['tabindex'] = 50;
2453                 Showlist($query, 'select', $template, $templateName);
2454                 return;
2455         }
2456         
2457         /**
2458          * AdminActions::parse_deletecomment()
2459          * Parse skinvar deletecomment
2460          * 
2461          * @param       string  $type   type of infomation for comment
2462          * @return      void
2463          */
2464         public function parse_deletecomment($type = 'id')
2465         {
2466                 $commentid      = intRequestVar('commentid');
2467                 $comment        = COMMENT::getComment($commentid);
2468                 
2469                 switch ( $type )
2470                 {
2471                         case 'id':
2472                                 echo intRequestVar('commentid');
2473                                 break;
2474                         case 'author':
2475                                 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2476                                 {
2477                                         echo $comment['member'];
2478                                 }
2479                                 else
2480                                 {
2481                                         echo $comment['user'];
2482                                 }
2483                                 break;
2484                         case 'body':
2485                                 $body = strip_tags($comment['body']);
2486                                 echo Entity::hsc(shorten($body, 300, '...'));
2487                 }
2488                 return;
2489         }
2490         
2491         /**
2492          * AdminActions::parse_deleteitembody()
2493          * Parse skinvar deleteitembody
2494          * 
2495          * @param       void
2496          * @return      void
2497          */
2498         public function parse_deleteitembody()
2499         {
2500                 global $manager;
2501                 $itemid =  intRequestVar('itemid');
2502                 $item   =& $manager->getItem($itemid, 1, 1);
2503                 $body   =  strip_tags($item['body']);
2504                 echo Entity::hsc(shorten($body, 300, '...'));
2505                 return;
2506         }
2507         
2508         /**
2509          * AdminActions::parse_deleteitemid()
2510          * Parse skinvar deleteitemid
2511          * 
2512          * @param       void
2513          * @return      void
2514          */
2515         public function parse_deleteitemid()
2516         {
2517                 echo (integer) intRequestVar('itemid');
2518                 return;
2519         }
2520         
2521         /**
2522          * AdminActions::parse_deleteitemtitle()
2523          * Parse skinvar deleteitemtitle
2524          * 
2525          * @param       void
2526          * @return      void
2527          */
2528         public function parse_deleteitemtitle()
2529         {
2530                 global $manager;
2531                 $itemid = intRequestVar('itemid');
2532                 $item  =& $manager->getItem($itemid, 1, 1);
2533                 echo Entity::hsc(strip_tags($item['title']));
2534                 return;
2535         }
2536         
2537         /**
2538          * AdminActions::parse_editadminskin()
2539          * Parse skinvar editadminskin
2540          * 
2541          * @param       string  $type   type of skin setting
2542          * @return      void
2543          */
2544         public function parse_editadminskin($type = 'id')
2545         {
2546                 $skinid = intRequestVar('skinid');
2547                 $skin   = new Skin($skinid);
2548                 switch ( $type )
2549                 {
2550                         case 'id':
2551                                 echo intRequestVar('skinid');
2552                                 break;
2553                         case 'name':
2554                                 echo Entity::hsc($skin->getName());
2555                                 break;
2556                         case 'desc':
2557                                 echo Entity::hsc($skin->getDescription());
2558                                 break;
2559                         case 'type':
2560                                 echo Entity::hsc($skin->getContentType());
2561                                 break;
2562                         case 'prefix':
2563                                 echo Entity::hsc($skin->getIncludePrefix());
2564                                 break;
2565                         case 'mode':
2566                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2567                         default:
2568                                 break;
2569                 }
2570                 return;
2571         }
2572         
2573         /**
2574          * AdminActions::parse_editadminskintype()
2575          * Parse skinvar editadminskintype
2576          * 
2577          * @param       string  $type   name of skin type
2578          * @return      void
2579          */
2580         public function parse_editadminskintype($type = 'id')
2581         {
2582                 global $CONF, $manager, $member;
2583 //              $skinid = intRequestVar('skinid');
2584 //              $skin   = new Skin($skinid);
2585                 $fNames = $this->skin->getAvailableTypes();
2586                 $sType  = strtolower(trim(requestVar('type')));
2587                 
2588                 switch ( $type )
2589                 {
2590                         case 'id':
2591                                 echo intRequestVar('skinid');
2592                                 break;
2593                         case 'name':
2594                                 echo Entity::hsc($this->skin->getName());
2595                                 break;
2596                         case 'desc':
2597                                 echo Entity::hsc($this->skin->getDescription());
2598                                 break;
2599                         case 'type':
2600                                 echo Entity::hsc($this->skin->getContentType());
2601                                 break;
2602                         case 'content':
2603                                 echo Entity::hsc($this->skin->getContentFromDB($sType));
2604                                 break;
2605                         case 'skintype':
2606                                 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2607                                 echo Entity::hsc($skinType);
2608                                 break;
2609                         case 'skintyperaw':
2610                                 echo Entity::hsc($sType);
2611                                 break;
2612                         case 'prefix':
2613                                 echo Entity::hsc($this->skin->getIncludePrefix());
2614                                 break;
2615                         case 'mode':
2616                                 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2617                                 echo Entity::hsc($incMode);
2618                                 break;
2619                         default:
2620                                 break;
2621                 }
2622                 return;
2623         }
2624         
2625         /**
2626          * AdminActions::parse_editadmintemplateinfo()
2627          * Parse skinvar editadmintemplateinfo
2628          * 
2629          * @param       string  $type                   type of skin template
2630          * @param       string  $description    description of template
2631          * @param       string  $name                   name of stemplate
2632          * @param       string  $tabindex               index number for tabindex attribute of input element
2633          * @param       string  $big                    
2634          * @param       string  $tplt                   
2635          */
2636         public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2637         {
2638                 global $manager;
2639                 $templateid                             =  intRequestVar('templateid');
2640                 $templatename                   =  Template::getNameFromId($templateid);
2641                 $templatedescription    =  Template::getDesc($templateid);
2642                 $template                               =& Template::read($templatename);
2643                 switch ( $type )
2644                 {
2645                         case 'id':
2646                                 echo intval($templateid);
2647                                 break;
2648                         case 'name':
2649                                 echo Entity::hsc($templatename);
2650                                 break;
2651                         case 'desc':
2652                                 echo Entity::hsc($templatedescription);
2653                                 break;
2654                         case 'extratemplate':
2655                                 $tabidx    = 600;
2656                                 $pluginfields = array();
2657                                 $manager->notify(
2658                                         'AdminTemplateExtraFields',
2659                                         array(
2660                                                 'fields' => &$pluginfields
2661                                         )
2662                                 );
2663                                 $tmplt = array();
2664                                 if ( $description )
2665                                 {
2666                                         $tmplt = Template::read($description);
2667                                 }
2668                                 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2669                                 {
2670                                         $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2671                                 }
2672                                 else
2673                                 {
2674                                         $base = "</tr>\n"
2675                                               . "<tr>\n"
2676                                               . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2677                                 }
2678                                 foreach ( $pluginfields as $pfkey => $pfvalue )
2679                                 {
2680                                         $data = array(
2681                                                 'explugtplname' => Entity::hsc($pfkey)
2682                                         );
2683                                         echo Template::fill($base, $data);
2684                                         foreach ( $pfvalue as $pffield => $pfdesc )
2685                                         {
2686                                                 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2687                                         }
2688                                 }
2689                                 break;
2690                         default:
2691                                 $desc = defined($description) ? constant($description) : $description;
2692                                 $name = defined($name) ? constant($name) : $name;
2693                                 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2694                                 break;
2695                 }
2696                 return;
2697         }
2698         
2699         /**
2700          * AdminActions::parse_editcomment()
2701          * Parse skinvar editcomment
2702          * 
2703          * @param       string  $type   type of comment setting
2704          * @return      void
2705          */
2706         public function parse_editcomment($type = 'id')
2707         {
2708                 global $manager;
2709                 $commentid      = intRequestVar('commentid');
2710                 $comment        = COMMENT::getComment($commentid);
2711                 
2712                 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2713                 
2714                 switch ( $type )
2715                 {
2716                         case 'id':
2717                                 echo intRequestVar('commentid');
2718                                 break;
2719                         case 'user':
2720                                 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2721                                 {
2722                                         echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2723                                 }
2724                                 else
2725                                 {
2726                                         echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2727                                 }
2728                                 break;
2729                         case 'date':
2730                                 echo date("Y-m-d @ H:i", $comment['timestamp']);
2731                                 break;
2732                         case 'body':
2733                                 $comment['body'] = str_replace('<br />', '', $comment['body']);
2734                                 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2735                                 echo $comment['body'];
2736                         default:
2737                                 echo $comment[$type];
2738                                 break;
2739                 }
2740                 return;
2741         }
2742         
2743         /**
2744          * AdminActions::parse_editdesturl()
2745          * Parse skinvar editdesturl
2746          */
2747         public function parse_editdesturl()
2748         {
2749                 if ( requestVar('desturl') )
2750                 {
2751                         echo Entity::hsc(requestVar('desturl'));
2752                 }
2753                 return;
2754         }
2755         
2756         /**
2757          * AdminActions::parse_editmemberlist()
2758          * Parse skinvar editmemberlist
2759          * 
2760          * @param       string  $templateName   name of template
2761          * @return      void
2762          */
2763         public function parse_editmemberlist($templateName = '')
2764         {
2765                 global $manager;
2766                 // show list of members with actions
2767                 $query =  'SELECT * FROM '.sql_table('member');
2768                 $template['content']  = 'memberlist';
2769                 $template['tabindex'] = 10;
2770                 
2771                 $batch = new Batch('member');
2772                 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2773                 return;
2774         }
2775         
2776         /**
2777          * AdminActions::parse_editmember()
2778          * Parse skinvar editmember
2779          * 
2780          * @param       string  $type                   type of information for member
2781          * @return      string  $tempateName    name of template to use
2782          * @return      void
2783          */
2784         public function parse_editmember($type = 'id', $templateName = '')
2785         {
2786                 global $CONF, $manager, $member;
2787                 $memberid       = intRequestVar('memberid');
2788                 $mem            = MEMBER::createFromID($memberid);
2789                 
2790                 switch ( $type )
2791                 {
2792                         case 'id':
2793                                 echo intRequestVar('memberid');
2794                                 break;
2795                         case 'displayname':
2796                                 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2797                                 {
2798                                         echo Entity::hsc($mem->getDisplayName());
2799                                 }
2800                                 else
2801                                 {
2802                                         $dispName = Entity::hsc($mem->getDisplayName());
2803                                         if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2804                                         {
2805                                                 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2806                                         }
2807                                         else
2808                                         {
2809                                                 echo $dispName;
2810                                         }
2811                                 }
2812                                 break;
2813                         case 'realname':
2814                                 echo Entity::hsc($mem->getRealName());
2815                                 break;
2816                         case 'email':
2817                                 echo Entity::hsc($mem->getEmail());
2818                                 break;
2819                         case 'url':
2820                                 echo Entity::hsc($mem->getURL());
2821                                 break;
2822                         case 'admin':
2823                                 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2824                                 break;
2825                         case 'canlogin':
2826                                 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2827                                 break;
2828                         case 'notes':
2829                                 echo Entity::hsc($mem->getNotes());
2830                                 break;
2831                         case 'autosave':
2832                                 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2833                                 break;
2834                         default:
2835                                 break;
2836                 }
2837                 return;
2838         }
2839         
2840         /**
2841          * AdminActions::parse_editpluginfo()
2842          * Parse skinvar editpluginfo
2843          * 
2844          * @param       string  $type   type of plugin info
2845          * @return      void
2846          */
2847         public function parse_editpluginfo($type)
2848         {
2849                 $pid = intRequestVar('plugid');
2850                 switch ( $type )
2851                 {
2852                         case 'id':
2853                                 echo $pid;
2854                                 break;
2855                         case 'name':
2856                                 echo Entity::hsc(getPluginNameFromPid($pid));
2857                                 break;
2858                 }
2859                 return;
2860         }
2861         
2862         /**
2863          * AdminActions::parse_editplugoptionslist()
2864          * Parse skinvar editplugoptionslist
2865          * 
2866          * @param       string  $templateName   name of template
2867          * @return      void
2868          */
2869         public function parse_editplugoptionslist($templateName = '')
2870         {
2871                 global $manager;
2872                 
2873                 $pid = intRequestVar('plugid');
2874                 $aOptions = array();
2875                 $aOIDs  = array();
2876                 
2877                 $query  = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2878                 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2879                 $resource = sql_query($query);
2880                 
2881                 while ( $o = sql_fetch_object($resource) )
2882                 {
2883                         array_push($aOIDs, $o->oid);
2884                         $aOptions[$o->oid] = array(
2885                                 
2886                                 'oid'                   => $o->oid,
2887                                 'value'                 => $o->odef,
2888                                 'name'                  => $o->oname,
2889                                 'description'   => $o->odesc,
2890                                 'type'                  => $o->otype,
2891                                 'typeinfo'              => $o->oextra,
2892                                 'contextid'             => 0
2893                         );
2894                 }
2895                 
2896                 // fill out actual values
2897                 if ( count($aOIDs) > 0 )
2898                 {
2899                         $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2900                         $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2901                         
2902                         $result = sql_query($query);
2903                         
2904                         while ( $o = sql_fetch_object($result) )
2905                         {
2906                                 $aOptions[$o->oid]['value'] = $o->ovalue;
2907                         }
2908                 }
2909                 
2910                 // call plugins
2911                 $manager->notify(
2912                         'PrePluginOptionsEdit',
2913                         array(
2914                                 'context'       =>  'global',
2915                                 'plugid'        =>  $pid,
2916                                 'options'       => &$aOptions
2917                         )
2918                 );
2919                 
2920                 $template['content'] = 'plugoptionlist';
2921                 $amount                   = Showlist($aOptions, 'table', $template, $templateName);
2922                 if ( $amount == 0 )
2923                 {
2924                         echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2925                 }
2926                 return;
2927         }
2928         
2929         /**
2930          * AdminActions::parse_editskin()
2931          * Parse skinvar editskin
2932          * 
2933          * @param       string  $type   type of skin
2934          * @return      void
2935          */
2936         public function parse_editskin($type = 'id')
2937         {
2938                 $skinid = intRequestVar('skinid');
2939                 $skin   = new SKIN($skinid);
2940                 switch ( $type )
2941                 {
2942                         case 'id':
2943                                 echo intRequestVar('skinid');
2944                                 break;
2945                         case 'name':
2946                                 echo Entity::hsc($skin->getName());
2947                                 break;
2948                         case 'desc':
2949                                 echo Entity::hsc($skin->getDescription());
2950                                 break;
2951                         case 'type':
2952                                 echo Entity::hsc($skin->getContentType());
2953                                 break;
2954                         case 'prefix':
2955                                 echo Entity::hsc($skin->getIncludePrefix());
2956                                 break;
2957                         case 'mode':
2958                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2959                         default:
2960                                 break;
2961                 }
2962                 return;
2963         }
2964         
2965         /**
2966          * AdminActions::parse_editskintype()
2967          * Parse skinvar editskintype
2968          * 
2969          * @param       string  $type   name of type for skin type
2970          * @return      void
2971          */
2972         public function parse_editskintype($type = 'id')
2973         {
2974                 global $CONF, $manager, $member;
2975                 $skinid = intRequestVar('skinid');
2976                 $skin   = new SKIN($skinid);
2977                 $fNames = $skin->getAvailableTypes();
2978                 $sType  = strtolower(trim(requestVar('type')));
2979                 
2980                 switch ( $type )
2981                 {
2982                         case 'id':
2983                                 echo intRequestVar('skinid');
2984                                 break;
2985                         case 'name':
2986                                 echo Entity::hsc($skin->getName());
2987                                 break;
2988                         case 'desc':
2989                                 echo Entity::hsc($skin->getDescription());
2990                                 break;
2991                         case 'type':
2992                                 echo Entity::hsc($skin->getContentType());
2993                                 break;
2994                         case 'content':
2995                                 echo Entity::hsc($skin->getContentFromDB($sType));
2996                                 break;
2997                         case 'skintype':
2998                                 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2999                                 echo Entity::hsc($skinType);
3000                                 break;
3001                         case 'skintyperaw':
3002                                 echo Entity::hsc($sType);
3003                                 break;
3004                         case 'prefix':
3005                                 echo Entity::hsc($skin->getIncludePrefix());
3006                                 break;
3007                         case 'mode':
3008                                 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
3009                                 echo Entity::hsc($incMode);
3010                                 break;
3011                         default:
3012                                 break;
3013                 }
3014                 return;
3015         }
3016         
3017         /**
3018          * AdminActions::parse_adminurl()
3019          * Parse skinvar adminurl
3020          * (shortcut for admin url)
3021          *
3022          * @param       void
3023          * @return      void
3024          */
3025         public function parse_adminurl()
3026         {
3027                 $this->parse_sitevar('adminurl');
3028                 return;
3029         }
3030         
3031         /**
3032          * AdminActions::parse_edittemplateinfo()
3033          * Parse skinvar edittemplateinfo
3034          * 
3035          * @param       string  $type                   name of type for skin
3036          * @param       string  $description    description for skin
3037          * @param       string  $name                   name of skin
3038          * @param       string  $help                   
3039          * @param       string  $tabindex               index value for tabindex attribute of input element
3040          * @param       string  $big                    
3041          * @param       string  $tplt                   name of template
3042          */
3043         public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3044         {
3045                 global $manager;
3046                 $templateid                             =  intRequestVar('templateid');
3047                 $templatename                   =  Template::getNameFromId($templateid);
3048                 $templatedescription    =  Template::getDesc($templateid);
3049                 $template                               =& $manager->getTemplate($templatename);
3050                 switch ( $type )
3051                 {
3052                         case 'id':
3053                                 echo intval($templateid);
3054                                 break;
3055                         case 'name':
3056                                 echo Entity::hsc($templatename);
3057                                 break;
3058                         case 'desc':
3059                                 echo Entity::hsc($templatedescription);
3060                                 break;
3061                         case 'extratemplate':
3062                                 $tabidx    = 600;
3063                                 $pluginfields = array();
3064                                 $manager->notify(
3065                                         'TemplateExtraFields',
3066                                         array(
3067                                                 'fields' => &$pluginfields
3068                                         )
3069                                 );
3070                                 $tmplt = array();
3071                                 if ( $description )
3072                                 {
3073                                         $tmplt = Template::read($description);
3074                                 }
3075                                 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3076                                 {
3077                                         $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3078                                 }
3079                                 else
3080                                 {
3081                                         $base = "</tr><tr>\n"
3082                                                   . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3083                                 }
3084                                 foreach ( $pluginfields as $pfkey => $pfvalue )
3085                                 {
3086                                         $data = array(
3087                                                 'explugtplname' => Entity::hsc($pfkey)
3088                                         );
3089                                         echo Template::fill($base, $data);
3090                                         foreach ( $pfvalue as $pffield => $pfdesc )
3091                                         {
3092                                                 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3093                                         }
3094                                 }
3095                                 break;
3096                         default:
3097                                 $desc = defined($description) ? constant($description) : $description;
3098                                 $name = defined($name) ? constant($name) : $name;
3099                                 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3100                                 break;
3101                 }
3102                 return;
3103         }
3104         
3105         /**
3106          * AdminActions::parse_eventformextra()
3107          * Parse skinvar eventformextra
3108          * 
3109          * @param       string  $type   name of type for event form extra
3110          * @return      void
3111          */
3112         public function parse_eventformextra($type = 'activation')
3113         {
3114                 global $manager;
3115                 switch ( $type )
3116                 {
3117                         case 'activation':
3118                                 $key = requestVar('ackey');
3119                                 if ( !$key )
3120                                 {
3121                                         Admin::error(_ERROR_ACTIVATE);
3122                                 }
3123                                 $info = MEMBER::getActivationInfo($key);
3124                                 if ( !$info )
3125                                 {
3126                                         Admin::error(_ERROR_ACTIVATE);
3127                                 }
3128                                 $mem  = MEMBER::createFromId($info->vmember);
3129                                 if ( !$mem )
3130                                 {
3131                                         Admin::error(_ERROR_ACTIVATE);
3132                                 }
3133                                 $data = array(
3134                                         'type'   => 'activation',
3135                                         'member' => $mem
3136                                 );
3137                                 break;
3138                         case 'membermailform-notloggedin':
3139                                 $data = array(
3140                                         'type' => 'membermailform-notloggedin',
3141                                 );
3142                                 break;
3143                 }
3144                 $manager->notify('FormExtra', $data);
3145                 return;
3146         }
3147         
3148         /**
3149          * AdminActions::parse_extrahead()
3150          * Parse skinvar extrahead
3151          */
3152         public function parse_extrahead()
3153         {
3154                 global $manager;
3155                 $extrahead = Admin::getAdminextrahead();
3156                 $manager->notify(
3157                         'AdminPrePageHead',
3158                         array(
3159                                 'extrahead'     => &$extrahead,
3160                                 'action'        => Admin::getAdminAction()
3161                         )
3162                 );
3163                 echo $extrahead;
3164                 return;
3165         }
3166         
3167         
3168         /**
3169          * AdminActions::parse_member()
3170          * Parse skinvar member
3171          * (includes a member info thingie)
3172          * 
3173          * @param       string  $what   which memberdata is needed
3174          * @return      void
3175          */
3176         public function parse_member($what)
3177         {
3178                 global $memberinfo, $member, $CONF;
3179                 
3180                 // 1. only allow the member-details-page specific variables on member pages
3181                 if ( $this->skintype == 'member' )
3182                 {
3183                         switch( $what )
3184                         {
3185                                 case 'name':
3186                                         echo Entity::hsc($memberinfo->getDisplayName());
3187                                         break;
3188                                 case 'realname':
3189                                         echo Entity::hsc($memberinfo->getRealName());
3190                                         break;
3191                                 case 'notes':
3192                                         echo Entity::hsc($memberinfo->getNotes());
3193                                         break;
3194                                 case 'url':
3195                                         echo Entity::hsc($memberinfo->getURL());
3196                                         break;
3197                                 case 'email':
3198                                         echo Entity::hsc($memberinfo->getEmail());
3199                                         break;
3200                                 case 'id':
3201                                         echo Entity::hsc($memberinfo->getID());
3202                                         break;
3203                         }
3204                 }
3205                 
3206                 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3207                 if ( $member->isLoggedIn() )
3208                 {
3209                         switch( $what )
3210                         {
3211                                 case 'yourname':
3212                                         echo $member->getDisplayName();
3213                                         break;
3214                                 case 'yourrealname':
3215                                         echo $member->getRealName();
3216                                         break;
3217                                 case 'yournotes':
3218                                         echo $member->getNotes();
3219                                         break;
3220                                 case 'yoururl':
3221                                         echo $member->getURL();
3222                                         break;
3223                                 case 'youremail':
3224                                         echo $member->getEmail();
3225                                         break;
3226                                 case 'yourid':
3227                                         echo $member->getID();
3228                                         break;
3229                                 case 'yourprofileurl':
3230                                         if ($CONF['URLMode'] == 'pathinfo')
3231                                                 echo Link::create_member_link($member->getID());
3232                                         else
3233                                                 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3234                                         break;
3235                         }
3236                 }
3237                 return;
3238         }
3239         
3240         /**
3241          * AdminActions::parse_version()
3242          * Parse skinvar version
3243          * (include nucleus versionnumber)
3244          *
3245          * @param       void
3246          * @return      void
3247          */
3248         public function parse_version()
3249         {
3250                 global $nucleus;
3251                 echo 'Nucleus CMS ' . $nucleus['version'];
3252                 return;
3253         }
3254         
3255         /**
3256          * AdminActions::parse_sitevar()
3257          * Parse skinvar sitevar
3258          * (include a sitevar)
3259          *
3260          * @param       string  $which
3261          * @return      void
3262          */
3263         public function parse_sitevar($which)
3264         {
3265                 global $CONF;
3266                 switch ( $which )
3267                 {
3268                         case 'url':
3269                                 echo $CONF['IndexURL'];
3270                                 break;
3271                         case 'name':
3272                                 echo $CONF['SiteName'];
3273                                 break;
3274                         case 'admin':
3275                                 echo $CONF['AdminEmail'];
3276                                 break;
3277                         case 'adminurl':
3278                                 echo $CONF['AdminURL'];
3279                 }
3280                 return;
3281         }
3282         
3283         /**
3284          * AdminActions::parse_charset()
3285          * Parse skinvar charset
3286          *
3287          * @param       void
3288          * @return      void
3289          */
3290         public function parse_charset()
3291         {
3292                 echo i18n::get_current_charset();
3293                 return;
3294         }
3295         
3296         /**
3297          * AdminActions::parse_getblogsetting()
3298          * Parse skinvar getblogsetting
3299          */
3300         public function parse_getblogsetting($which)
3301         {
3302                 global $blog;
3303                 
3304                 if ( $blog )
3305                 {
3306                         $b =& $blog;
3307                 }
3308                 elseif ( $bid = intRequestVar('blogid') )
3309                 {
3310                         global $manager;
3311                         $b = $manager->getBlog($bid);
3312                 }
3313                 else
3314                 {
3315                         return;
3316                 }
3317                 
3318                 switch ( $which )
3319                 {
3320                         case 'id':
3321                                 return Entity::hsc($b->getID());
3322                                 break;
3323                         case 'url':
3324                                 return Entity::hsc($b->getURL());
3325                                 break;
3326                         case 'name':
3327                                 return Entity::hsc($b->getName());
3328                                 break;
3329                         case 'desc':
3330                                 return Entity::hsc($b->getDescription());
3331                                 break;
3332                         case 'short':
3333                                 return Entity::hsc($b->getShortName());
3334                                 break;
3335                         case 'notifyaddress':
3336                                 return Entity::hsc($b->getNotifyAddress());
3337                                 break;
3338                         case 'maxcomments':
3339                                 return Entity::hsc($b->getMaxComments());
3340                                 break;
3341                         case 'updatefile':
3342                                 return Entity::hsc($b->getUpdateFile());
3343                                 break;
3344                         case 'timeoffset':
3345                                 return Entity::hsc($b->getTimeOffset());
3346                                 break;
3347                 }
3348                 return;
3349         }
3350         
3351         /**
3352          * AdminActions::parse_geteditpluginfo()
3353          * Parse skinvar geteditpluginfo
3354          * 
3355          * @param       string  $type   name of setting for edit plugin info
3356          * @return      void
3357          */
3358         public function parse_geteditpluginfo($type)
3359         {
3360                 $pid = intRequestVar('plugid');
3361                 switch ( $type )
3362                 {
3363                         case 'id':
3364                                 return $pid;
3365                                 break;
3366                         case 'name':
3367                                 return Entity::hsc(getPluginNameFromPid($pid));
3368                                 break;
3369                 }
3370                 return;
3371         }
3372         
3373         /**
3374          * AdminActions::parse_getmember()
3375          * Parse skinvar getmember
3376          * (includes a member info thingie)
3377          * 
3378          * @param       string  $what   name of setting for member
3379          * @return      void
3380          */
3381         public function parse_getmember($what)
3382         {
3383                 global $memberinfo, $member;
3384                 // 1. only allow the member-details-page specific variables on member pages
3385                 if ( $this->skintype == 'member' )
3386                 {
3387                         switch ( $what )
3388                         {
3389                                 case 'name':
3390                                         return Entity::hsc($memberinfo->getDisplayName());
3391                                         break;
3392                                 case 'realname':
3393                                         return Entity::hsc($memberinfo->getRealName());
3394                                         break;
3395                                 case 'notes':
3396                                         return Entity::hsc($memberinfo->getNotes());
3397                                         break;
3398                                 case 'url':
3399                                         return Entity::hsc($memberinfo->getURL());
3400                                         break;
3401                                 case 'email':
3402                                         return Entity::hsc($memberinfo->getEmail());
3403                                         break;
3404                                 case 'id':
3405                                         return Entity::hsc($memberinfo->getID());
3406                                         break;
3407                         }
3408                 }
3409                 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3410                 if ( $member->isLoggedIn() )
3411                 {
3412                         switch ( $what )
3413                         {
3414                                 case 'yourname':
3415                                         return $member->getDisplayName();
3416                                         break;
3417                                 case 'yourrealname':
3418                                         return $member->getRealName();
3419                                         break;
3420                                 case 'yournotes':
3421                                         return $member->getNotes();
3422                                         break;
3423                                 case 'yoururl':
3424                                         return $member->getURL();
3425                                         break;
3426                                 case 'youremail':
3427                                         return $member->getEmail();
3428                                         break;
3429                                 case 'yourid':
3430                                         return $member->getID();
3431                                         break;
3432                         }
3433                 }
3434                 return;
3435         }
3436         
3437         /**
3438          * AdminActions::parse_headmessage()
3439          * Parse skinvar headmessage
3440          * 
3441          * @param       void
3442          * @return      void
3443          */
3444         public function parse_headmessage()
3445         {
3446                 if ( !empty(Admin::$headMess) )
3447                 {
3448                         echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3449                 }
3450                 return;
3451         }
3452         
3453         /**
3454          * AdminActions::parse_helplink()
3455          * Parse skinvar helplink
3456          * 
3457          * @param       string  $topic  name of topic for help
3458          * @return      void
3459          */
3460         public function parse_helplink($topic = '')
3461         {
3462                 if ( empty($topic) )
3463                 {
3464                         return;
3465                 }
3466                 help($topic);
3467                 return;
3468         }
3469         
3470         /**
3471          * AdminActions::parse_helpplugname()
3472          * Parse skinvar helpplugname
3473          * 
3474          * @param       void
3475          * @return      void
3476          */
3477         public function parse_helpplugname()
3478         {
3479                 $plugid = intGetVar('plugid');
3480                 Entity::hsc(getPluginNameFromPid($plugid));
3481                 return;
3482         }
3483         
3484         /**
3485          * AdminActions::parse_ilistaddnew()
3486          * Parse skinvar ilistaddnew
3487          * 
3488          * @param       void
3489          * @return      void
3490          */
3491         public function parse_ilistaddnew()
3492         {
3493                 $blogid = intRequestVar('blogid');
3494                 if ( intPostVar('start') == 0 )
3495                 {
3496                         echo '<p><a href="index.php?action=createitem&amp;blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3497                 }
3498                 return;
3499         }
3500         
3501         /**
3502          * AdminActions::parse_importskininfo()
3503          * Parse skinvar importskininfo
3504          * 
3505          * @param       string  $type   name of information for imported skin
3506          * @return      void
3507          */
3508         public function parse_importskininfo($type)
3509         {
3510                 switch ( $type )
3511                 {
3512                         case 'info':
3513                                 echo Entity::hsc(requestVar('skininfo'));
3514                                 break;
3515                         case 'snames':
3516                                 $dataArr = requestArray('skinnames');
3517                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3518                                 break;
3519                         case 'tnames':
3520                                 $dataArr = requestArray('tpltnames');
3521                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3522                                 break;
3523                         case 'sclashes':
3524                                 $dataArr = requestArray('skinclashes');
3525                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3526                                 break;
3527                         case 'tclashes':
3528                                 $dataArr = requestArray('tpltclashes');
3529                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3530                                 break;
3531                         case 'skinfile':
3532                                 echo Entity::hsc(requestVar('skinfile'));
3533                                 break;
3534                         case 'mode':
3535                                 echo Entity::hsc(requestVar('mode'));
3536                                 break;
3537                 }
3538                 return;
3539         }
3540         
3541         /**
3542          * AdminActions::parse_inputyesno()
3543          * Parse skinvar inputyesno
3544          * 
3545          * some init stuff for all forms
3546          * 
3547          * @param       void
3548          */
3549         function parse_init()
3550         {
3551                 global $manager;
3552                 $item   = false;
3553                 if ( requestVar('action') == 'itemedit' )
3554                 {
3555                         $itemid = intRequestVar('itemid');
3556                         $item   =& $manager->getItem($itemid, 1, 1);
3557                         $blog   =& $manager->getBlog(getBlogIDFromItemID($itemid));
3558                         if ( $item && $blog->convertBreaks() )
3559                         {
3560                                 $item['body'] = removeBreaks($item['body']);
3561                                 $item['more'] = removeBreaks($item['more']);
3562                         }
3563                         $contents = $item;
3564                         $authorid = $contents['authorid'];
3565                 }
3566                 elseif ( requestVar('action') == 'createitem' )
3567                 {
3568                         $blog     =& $manager->getBlog(intRequestVar($blogid));
3569                         $authorid = '';
3570                 }
3571                 $blog->insertJavaScriptInfo($authorid);
3572         }
3573         
3574         /**
3575          * AdminActions::parse_inputyesno()
3576          * Parse skinvar inputyesno
3577          * 
3578          * @param       string  $name                   
3579          * @param       string  $checkedval             
3580          * @param       string  $tabindex               
3581          * @param       string  $value1                 
3582          * @param       string  $value2                 
3583          * @param       string  $yesval                 
3584          * @param       string  $noval                  
3585          * @param       string  $isAdmin                
3586          * @param       string  $templateName   
3587          * @return      void
3588          */
3589         public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3590         {
3591                 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3592                 return;
3593         }
3594         
3595         /**
3596          * AdminActions::parse_insertpluginfo()
3597          * Parse templatevar insertpluginfo
3598          */
3599         public function parse_insertpluginfo($type)
3600         {
3601                 $option = Admin::$aOptions;
3602                 switch ( $type )
3603                 {
3604                         case 'id':
3605                                 return $option['pid'];
3606                                 break;
3607                         case 'name':
3608                                 return Entity::hsc($option['pfile']);
3609                                 break;
3610                 }
3611                 return;
3612         }
3613         
3614         /**
3615          * AdminActions::parse_insertpluginoptions()
3616          * Parse skinvar insertpluginoptions
3617          * 
3618          * @param       string  $templateName   name of template
3619          * @return      void
3620          */
3621         public function parse_insertpluginoptions($templateName = '')
3622         {
3623                 $options        = Admin::getAdminaOption();
3624                 $template       = array();
3625                 $templats       = array();
3626                 
3627                 if ( $templateName )
3628                 {
3629                         $templates = Template::read($templateName);
3630                 }
3631                 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
3632                 {
3633                         $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3634                 }
3635                 else
3636                 {
3637                         $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
3638                 }
3639                 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
3640                 {
3641                         $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3642                 }
3643                 else
3644                 {
3645                         $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
3646                 }
3647                 
3648                 $prevPid = -1;
3649                 
3650                 foreach ( $options as $option )
3651                 {
3652                         $handler = new Actions($this->skintype, $template, $option);
3653                         
3654                         $parser = new PARSER($handler);
3655                         
3656                         // new plugin?
3657                         if ( $prevPid != $option['pid'] )
3658                         {
3659                                 $prevPid  = $option['pid'];
3660                                 $parser->parse($template['title']);
3661                         }
3662                         $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3663                         if ( @$meta['access'] != 'hidden' )
3664                         {
3665                                 $parsed = $parser->parse($template['body']);
3666                         }
3667                 }
3668                 return;
3669         }
3670         
3671         /**
3672          * AdminActions::parse_insplugoptcontent()
3673          * Parse skinvar insplugoptcontent
3674          * 
3675          * @param       void
3676          * @return      void
3677          */
3678         public function parse_insplugoptcontent()
3679         {
3680                 $option = Admin::$aOption;
3681                 
3682                 $meta   = NucleusPlugin::getOptionMeta($option['typeinfo']);
3683                 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
3684                 {
3685                         echo '<tr>';
3686                         listplug_plugOptionRow($option);
3687                         echo '</tr>';
3688                 }
3689                 return;
3690         }
3691         
3692         /**
3693          * AdminActions::parse_iprangeinput()
3694          * Parse skinvar iprangeinput
3695          * 
3696          * @param       void
3697          * @return      void
3698          */
3699         public function parse_iprangeinput()
3700         {
3701                 if ( requestVar('ip') )
3702                 {
3703                         $iprangeVal = Entity::hsc(requestVar('ip'));
3704                         echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
3705                         echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
3706                         echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3707                         echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3708                         echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
3709                 }
3710                 else
3711                 {
3712                         echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3713                         echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3714                 }
3715                 return;
3716         }
3717         
3718         /**
3719          * AdminActions::parse_itemnavlist()
3720          * Parse skinvar itemnavlist
3721          * 
3722          * @param       void
3723          * @return      void
3724          */
3725         public function parse_itemnavlist()
3726         {
3727                 global $CONF, $manager, $member;
3728                 if ( $this->skintype == 'itemlist' )
3729                 {
3730                         $blogid =  intRequestVar('blogid');
3731                         $blog   =& $manager->getBlog($blogid);
3732                 }
3733                 if ( postVar('start') )
3734                 {
3735                         $start = intPostVar('start');
3736                 }
3737                 else
3738                 {
3739                         $start = 0;
3740                 }
3741                 
3742                 // amount of items to show
3743                 if ( postVar('amount') )
3744                 {
3745                         $amount = intPostVar('amount');
3746                 }
3747                 else
3748                 {
3749                         $amount = intval($CONF['DefaultListSize']);
3750                         if ( $amount < 1 )
3751                         {
3752                                 $amount = 10;
3753                         }
3754                 }
3755                 $query  = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3756                         . " FROM %s, %s, %s, %s"
3757                         . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3758                 
3759                 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3760                 
3761                 if ( $this->skintype == 'itemlist' )
3762                 {
3763                         $query .= ' AND iblog   = ' . $blogid;
3764                         $template['now'] = $blog->getCorrectTime(time());
3765                         
3766                         // non-blog-admins can only edit/delete their own items
3767                         if ( !$member->blogAdminRights($blogid) )
3768                         {
3769                                 $query .= ' AND iauthor = ' . $member->getID();
3770                         }
3771                 }
3772                 elseif ( $this->skintype == 'browseownitems' )
3773                 {
3774                         $query .= ' AND iauthor   = ' . $member->getID();
3775                         $blogid = 0;
3776                         $template['now'] = time();
3777                 }
3778                 
3779                 // search through items
3780                 $search = postVar('search');
3781                 
3782                 if ( !empty($search) )
3783                 {
3784                         $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3785                                 . '  OR  (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3786                                 . '  OR  (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3787                 }
3788                 $query .= ' ORDER BY itime DESC'
3789                         . " LIMIT {$start},{$amount}";
3790                 
3791                 $template['content'] = 'itemlist';
3792                 
3793                 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3794                 $navList->showBatchList('item', $query, 'table', $template);
3795                 return;
3796         }
3797         
3798         /**
3799          * AdminActions::parse_itemoptions()
3800          * Parse skinvar itemoptions
3801          * Adds the itemOptions of a plugin to a page
3802          * @author TeRanEX
3803          */
3804         function parse_itemoptions()
3805         {
3806                 $this->parse_pluginoptions($type = 'item');
3807 //              global $itemid;
3808 //              Admin::insertPluginOptions('item', $itemid);
3809         }
3810         
3811         /**
3812          * AdminActions::parse_itemoptions()
3813          * 
3814          * date change on edit item
3815          * 
3816          * Parse skinvar itemoptions
3817          * Adds the itemOptions of a plugin to a page
3818          * @author TeRanEX
3819          */
3820         function parse_itemtime($what)
3821         {
3822                 global $manager;
3823                 $item   = false;
3824                 $itemid = intRequestVar('itemid');
3825                 $item   =& $manager->getItem($itemid, 1, 1);
3826                 $blog   =& $manager->getBlog(getBlogIDFromItemID($itemid));
3827                 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3828                 {
3829                         $item['body'] = removeBreaks($item['body']);
3830                         $item['more'] = removeBreaks($item['more']);
3831                 }
3832                 $contents = array();
3833                 if ( requestVar('action') == 'itemedit' )
3834                 {
3835                         $contents = $item;
3836                 } 
3837                 elseif ( requestVar('action') == 'createitem' )
3838                 {
3839                         $manager->notify(
3840                                 'PreAddItemForm',
3841                                 array(
3842                                         'contents' => &$contents,
3843                                         'blog'     => &$this->blog
3844                                 )
3845                         );
3846                 }
3847                 $itemtime = getdate($contents['timestamp']);
3848                 echo $itemtime[$what];
3849         }
3850         
3851         /**
3852          * AdminActions::parse_jstoolbaroptions()
3853          * Parse skinvar jstoolbaroptions
3854          * 
3855          * @param       void
3856          * @return      void
3857          */
3858         public function parse_jstoolbaroptions()
3859         {
3860                 global $CONF;
3861                 $options = array(
3862                         _SETTINGS_JSTOOLBAR_NONE,
3863                         _SETTINGS_JSTOOLBAR_SIMPLE,
3864                         _SETTINGS_JSTOOLBAR_FULL
3865                 );
3866                 $i = 1;
3867                 foreach ( $options as $option )
3868                 {
3869                         $text  = "<option value=\"%d\"%s>%s</option>\n";
3870                         $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3871                         echo sprintf($text, $i, $extra, $option);
3872                         $i++;
3873                 }
3874                 return;
3875         }
3876         /**
3877          * Parse skinvar languageselectoptions
3878          */
3879         function parse_languageselectoptions()
3880         {
3881                 $locales = i18n::get_available_locale_list();
3882                 $memid   = intRequestVar('memberid');
3883                 if ($memid)
3884                 {
3885                         $mem = MEMBER::createFromID($memid);
3886                         if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3887                         {
3888                                 echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3889                         }
3890                         else
3891                         {
3892                                 echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3893                         }
3894                 }
3895                 else
3896                 {
3897                         if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3898                         {
3899                                 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3900                         }
3901                 }
3902                 foreach ( $locales as $locale )
3903                 {
3904                         if ($memid)
3905                         {
3906                                 if ( $locale == $mem->getLocale() )
3907                                 {
3908                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3909                                 }
3910                                 else
3911                                 {
3912                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
3913                                 }
3914                         }
3915                         else
3916                         {
3917                                 if ( $locale == i18n::get_current_locale() )
3918                                 {
3919                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3920                                 }
3921                                 else
3922                                 {
3923                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
3924                                 }
3925                         }
3926                 }
3927         }
3928         
3929         /**
3930          * AdminActions::parse_localeselectoptions()
3931          * Parse skinvar localeselectoptions
3932          * 
3933          * @param       void
3934          * @return      void
3935          */
3936         public function parse_localeselectoptions()
3937         {
3938                 $locales = i18n::get_available_locale_list();
3939                 $memid   = intRequestVar('memberid');
3940                 if ( $memid )
3941                 {
3942                         $mem = MEMBER::createFromID($memid);
3943                         if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3944                         {
3945                                 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3946                         }
3947                         else
3948                         {
3949                                 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3950                         }
3951                 }
3952                 else
3953                 {
3954                         if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3955                         {
3956                                 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3957                         }
3958                 }
3959                 foreach ( $locales as $locale )
3960                 {
3961                         if ($memid)
3962                         {
3963                                 if ( $locale == $mem->getLocale() )
3964                                 {
3965                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3966                                 }
3967                                 else
3968                                 {
3969                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
3970                                 }
3971                         }
3972                         else
3973                         {
3974                                 if ( $locale == i18n::get_current_locale() )
3975                                 {
3976                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3977                                 }
3978                                 else
3979                                 {
3980                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
3981                                 }
3982                         }
3983                 }
3984                 return;
3985         }
3986         
3987         /**
3988          * AdminActions::parse_listplugplugoptionrow()
3989          * Parse templatevar listplugplugoptionrow
3990          * 
3991          * @param       string  $templateName   name of template
3992          * @return      void
3993          */
3994         public function parse_listplugplugoptionrow($templateName = '')
3995         {
3996                 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
3997                 return;
3998         }
3999         
4000         /**
4001          * AdminActions::parse_mediadirwarning()
4002          * Parse skinvar mediadirwarning
4003          * 
4004          * @param       void
4005          * @return      void
4006          */
4007         public function parse_mediadirwarning()
4008         {
4009                 global $DIR_MEDIA;
4010                 if ( !is_dir($DIR_MEDIA) )
4011                 {
4012                         echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4013                 }
4014                 if ( !is_readable($DIR_MEDIA) )
4015                 {
4016                         echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4017                 }
4018                 if ( !is_writeable($DIR_MEDIA) )
4019                 {
4020                         echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4021                 }
4022                 return;
4023         }
4024         
4025         /**
4026          * AdminActions::parse_movedistselect()
4027          * Parse skinvar movedistselect
4028          */
4029         public function parse_movedistselect()
4030         {
4031                 $actionType = requestVar('action');
4032                 switch ( $actionType )
4033                 {
4034                         case 'batchitem':
4035                                 Admin::selectBlogCategory('destcatid');
4036                                 break;
4037                         case 'batchcategory':
4038                                 Admin::selectBlog('destblogid');
4039                                 break;
4040                         default:
4041                                 if ( $this->skintype == 'itemmove' )
4042                                 {
4043                                         $query  = "SELECT icat as result FROM %s WHERE inumber=%d;";
4044                                         $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
4045                                         $catid  = quickQuery(sprintf($query, intRequestVar('itemid')));
4046                                         Admin::selectBlogCategory('catid', $catid, 10, 1);
4047                                 }
4048                                 break;
4049                 }
4050                 return;
4051         }
4052         
4053         /**
4054          * AdminActions::parse_moveitemid()
4055          * Parse skinvar moveitemid
4056          * 
4057          * @param       void
4058          * @return      void
4059          */
4060         public function parse_moveitemid()
4061         {
4062                 echo intRequestVar('itemid');
4063                 return;
4064         }
4065         
4066         /**
4067          * AdminActions::parse_newestcompare()
4068          * Parse skinvar newestcompare
4069          * 
4070          * @param       void
4071          * @return      void
4072          */
4073         public function parse_newestcompare()
4074         {
4075                 global $nucleus;
4076                 $newestVersion  = getLatestVersion();
4077                 $newestCompare  = str_replace('/', '.', $newestVersion);
4078                 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4079                 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4080                 {
4081                         echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4082                         echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4083                 }
4084                 return;
4085         }
4086         
4087         /**
4088          * AdminActions::parse_newmemberselect()
4089          * Parse skinvar newmemberselect
4090          * 
4091          * @param       string  $templateName   name of template to use
4092          * @return      void
4093          */
4094         public function parse_newmemberselect($templateName = '')
4095         {
4096                 $blogid = intRequestVar('blogid');
4097                 
4098                 $query  = "SELECT tmember FROM %s WHERE tblog=%d;";
4099                 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4100                 $res = sql_query($query);
4101                 
4102                 $tmem = array();
4103                 while ( $tmember = sql_fetch_object($res) ) 
4104                 {
4105                         $tmem[] = intval($tmember->tmember);
4106                 }
4107                 
4108                 $query  = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4109                 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4110                 
4111                 $template['name']        = 'memberid';
4112                 $template['tabindex'] = 10000;
4113                 Showlist($query, 'select', $template, $templateName);
4114                 return;
4115         }
4116         
4117         /**
4118          * AdminActions::parse_newpluginlist()
4119          * Parse skinvar newpluginlist
4120          * 
4121          * @param       void
4122          * @return      void
4123          */
4124         public function parse_newpluginlist()
4125         {
4126                 $candidates = $this->newPlugCandidates;
4127                 foreach ( $candidates as $name )
4128                 {
4129                         echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4130                 }
4131                 return;
4132         }
4133         
4134         /**
4135          * AdminActions::parse_outputspecialdirs()
4136          * Parse skinvar outputspecialdirs
4137          * 
4138          * @param       string  $type   type of setting for directory
4139          * @return      void
4140          */
4141         public function parse_outputspecialdirs($type)
4142         {
4143                 switch ( $type )
4144                 {
4145                         case 'nucleusdir':
4146                                 global $DIR_NUCLEUS;
4147                                 echo Entity::hsc($DIR_NUCLEUS);
4148                                 break;
4149                         case 'mediadir':
4150                                 global $DIR_MEDIA;
4151                                 echo Entity::hsc($DIR_MEDIA);
4152                                 break;
4153                 }
4154                 return;
4155         }
4156         
4157         /**
4158          * AdminActions::parse_passrequestvars()
4159          * Parse skinvar passrequestvars
4160          * 
4161          * @param       void
4162          * @return      void
4163          */
4164         public function parse_passrequestvars()
4165         {
4166                 $passvar   = Admin::getAdminpassvar();
4167                 $oldaction = postVar('oldaction');
4168                 if ( ($oldaction != 'logout')
4169                   && ($oldaction != 'login')
4170                   && $passvar
4171                   && !postVar('customaction') )
4172                 {
4173                         passRequestVars();
4174                 }
4175                 return;
4176         }
4177         
4178         /**
4179          * AdminActions::parse_pluginextras()
4180          * Parse skinvar pluginextras
4181          * 
4182          * @param       string  $type   type of plugin context
4183          * @return      void
4184          */
4185         public function parse_pluginextras($type = 'global')
4186         {
4187                 global $manager;
4188                 switch ( $type )
4189                 {
4190                         case 'member':
4191                                 $id  = intRequestVar('memberid');
4192                                 $mem = MEMBER::createFromID($id);
4193                                 $manager->notify(
4194                                         'MemberSettingsFormExtras',
4195                                         array(
4196                                                 'member' => &$mem
4197                                         )
4198                                 );
4199                                 break;
4200                         case 'blog':
4201                                 $id  = intRequestVar('blogid');
4202                                 $blg = $manager->getBlog($id);
4203                                 $manager->notify(
4204                                         'BlogSettingsFormExtras',
4205                                         array(
4206                                                 'member' => &$blg
4207                                         )
4208                                 );
4209                                 break;
4210                         default:
4211                                 $manager->notify(
4212                                         'GeneralSettingsFormExtras',
4213                                         array(
4214                                         )
4215                                 );
4216                                 break;
4217                 }
4218                 return;
4219         }
4220         
4221         /**
4222          * AdminActions::parse_pluginhelp()
4223          * Parse skinvar pluginhelp
4224          * 
4225          * @param       void
4226          * @return      void
4227          */
4228         public function parse_pluginhelp()
4229         {
4230                 global $manager, $DIR_PLUGINS;
4231                 $plugid = intGetVar('plugid');
4232                 $plugName =  getPluginNameFromPid($plugid);
4233                 $plug =& $manager->getPlugin($plugName);
4234                 
4235                 if ( $plug->supportsFeature('HelpPage') > 0 )
4236                 {
4237                         $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4238                         if ( @file_exists($helpfile . 'php') )
4239                         {
4240                                 @include($helpfile . 'php');
4241                                 return;
4242                         }
4243                         elseif ( @file_exists($helpfile . 'html') )
4244                         {
4245                                 @include($helpfile . 'html');
4246                                 return;
4247                         }
4248                 }
4249                 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4250                 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4251                 return;
4252         }
4253         
4254         /**
4255          * AdminActions::parse_pluginlistlist()
4256          * Parse skinvar pluginlistlist
4257          * 
4258          * @param       string  $templateName   name of template to use
4259          * @return      void
4260          */
4261         public function parse_pluginlistlist($templateName = '')
4262         {
4263                 $query  = "SELECT * FROM %s ORDER BY porder ASC;";
4264                 $query = sprintf($query, sql_table('plugin'));
4265                 $template['content']  = 'pluginlist';
4266                 $template['tabindex'] = 10;
4267                 Showlist($query, 'table', $template, $templateName);
4268                 return;
4269         }
4270         
4271         /**
4272          * AdminActions::parse_pluginoptions()
4273          * Parse skinvar pluginoptions
4274          * 
4275          * @param       string  $type   type of plugin option
4276          * @return      void
4277          */
4278         public function parse_pluginoptions($type = 'global')
4279         {
4280                 switch ( $type )
4281                 {
4282                         case 'member':
4283                                 $id = intRequestVar('memberid');
4284                                 break;
4285                         case 'blog':
4286                                 $id = intRequestVar('blogid');
4287                                 break;
4288                         case 'category':
4289                                 $id = intRequestVar('catid');
4290                                 break;
4291                         case 'item':
4292                                 global $itemid;
4293                                 $id = $itemid;
4294                 }
4295                 Admin::insertPluginOptions($type, $id);
4296                 return;
4297         }
4298         
4299         /**
4300          * AdminActions::parse_qmenuaddselect()
4301          * Parse skinvar qmanuaddselect
4302          * 
4303          * @param       string  $templateName   name of template to use
4304          * @return      void
4305          */
4306         public function parse_qmenuaddselect($templateName = '')
4307         {
4308                 global $member;
4309                 $showAll = requestVar('showall');
4310                 if ( $member->isAdmin() && ($showAll == 'yes') )
4311                 {
4312                         // Super-Admins have access to all blogs! (no add item support though)
4313                         $query =  'SELECT bnumber as value, bname as text'
4314                                . ' FROM ' . sql_table('blog')
4315                                . ' ORDER BY bname';
4316                 }
4317                 else
4318                 {
4319                         $query =  'SELECT bnumber as value, bname as text'
4320                                . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4321                                . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4322                                . ' ORDER BY bname';
4323                 }
4324                 $template['name']          = 'blogid';
4325                 $template['tabindex']   = 15000;
4326                 $template['extra']        = _QMENU_ADD_SELECT;
4327                 $template['selected']   = -1;
4328                 $template['shorten']    = 10;
4329                 $template['shortenel']  = '';
4330                 $template['javascript'] = 'onchange="return form.submit()"';
4331                 Showlist($query, 'select', $template, $templateName);
4332                 return;
4333         }
4334
4335         /**
4336          * AdminActions::parse_quickmenu()
4337          * Parse skinvar quickmenu
4338          * 
4339          * @param       string  $templateName   name of template to use
4340          * @return      void
4341          */
4342         public function parse_quickmenu($templateName = '')
4343         {
4344                 global $manager;
4345                 $templates = array();
4346                 $template  = array();
4347                 if ( !empty($templateName) )
4348                 {
4349                         $templates = Template::read($templateName);
4350                 }
4351                 $pluginExtras = array();
4352                 $manager->notify(
4353                         'QuickMenu',
4354                         array(
4355                                 'options' => &$pluginExtras
4356                         )
4357                 );
4358                 if ( count($pluginExtras) > 0 )
4359                 {
4360                         if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4361                         {
4362                                 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4363                         }
4364                         else
4365                         {
4366                                 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
4367                         }
4368                         $handler = new Actions($this->skintype);
4369                         
4370                         $parser = new PARSER($handler);
4371                         $parser->parse($template['title']);
4372                         
4373                         if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4374                         {
4375                                 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4376                         }
4377                         else
4378                         {
4379                                 $template['head'] = '<ul>';
4380                         }
4381                         
4382                         echo $template['head'];
4383                         
4384                         if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
4385                         {
4386                                 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4387                         }
4388                         else
4389                         {
4390                                 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
4391                         }
4392                         
4393                         foreach ( $pluginExtras as $aInfo )
4394                         {
4395                                 $data = array(
4396                                         'plugadminurl'          => Entity::hsc($aInfo['url']),
4397                                         'plugadmintooltip'      => Entity::hsc($aInfo['tooltip']),
4398                                         'plugadmintitle'        => Entity::hsc($aInfo['title']),
4399                                 );
4400                                 echo Template::fill($template['body'], $data);
4401                         }
4402                         if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4403                         {
4404                                 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4405                         }
4406                         else
4407                         {
4408                                 $template['foot'] = '</ul>';
4409                         }
4410                         echo $template['foot'];
4411                 }
4412                 return;
4413         }
4414         
4415         /**
4416          * AdminActions::parse_requestblogid()
4417          * Parse skinvar requestblogid
4418          * 
4419          * @param       void
4420          * @return      void
4421          */
4422         public function parse_requestblogid()
4423         {
4424                 echo intRequestVar('blogid');
4425                 return;
4426         }
4427         
4428         /**
4429          * AdminActions::parse_requestiprange()
4430          * Parse skinvar requestiprange
4431          * 
4432          * @param       void
4433          * @return      void
4434          */
4435         public function parse_requestiprange()
4436         {
4437                 if ( requestVar('iprange') )
4438                 {
4439                         echo Entity::hsc(requestVar('iprange'));
4440                 }
4441                 elseif ( requestVar('ip') )
4442                 {
4443                         echo Entity::hsc(requestVar('ip'));
4444                 }
4445                 return;
4446         }
4447         
4448         /**
4449          * AdminActions::parse_selectlocaladminskinfiles()
4450          * Parse skinvar selectlocaladminskinfiles
4451          * 
4452          * @param       void
4453          * @return      void
4454          */
4455         public function parse_selectlocaladminskinfiles()
4456         {
4457                 echo 'UUU';
4458                 global $DIR_SKINS, $manager;
4459                 $adminskindir = $DIR_SKINS . 'admin/';
4460                 $candidates = SkinImport::searchForCandidates($adminskindir);
4461                 foreach ( $candidates as $skinname => $skinfile )
4462                 {
4463                         $html = Entity::hsc($skinfile);
4464                         echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4465                 }
4466                 return;
4467         }
4468         
4469         /**
4470          * AdminActions::parse_selectlocalskinfiles()
4471          * Parse skinvar selectlocalskinfiles
4472          * 
4473          * @param       void
4474          * @return      void
4475          */
4476         public function parse_selectlocalskinfiles()
4477         {
4478                 global $DIR_SKINS;
4479                 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4480                 foreach ( $candidates as $skinname => $skinfile )
4481                 {
4482                         $html = Entity::hsc($skinfile);
4483                         echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4484                 }
4485                 return;
4486         }
4487         
4488         /**
4489          * AdminActions::parse_skineditallowedlist()
4490          * Parse skinvar skineditallowedlist
4491          * 
4492          * @param       string  $type                   type of skin
4493          * @param       string  $templateName   name of template
4494          * @return      void
4495          */
4496         public function parse_skineditallowedlist($type, $templateName = '')
4497         {
4498                 switch ( $type )
4499                 {
4500                         case 'blog':
4501                                 $query = "SELECT bshortname, bname FROM %s";
4502                                 $show  = array(
4503                                         'content' => 'shortblognames'
4504                                 );
4505                                 $query = sprintf($query, sql_table('blog'));
4506                                 Showlist($query, 'table', $show, $templateName);
4507                                 break;
4508                         case 'template':
4509                                 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%'";
4510                                 $show  = array(
4511                                         'content' => 'shortnames'
4512                                 );
4513                                 $query = sprintf($query, sql_table('template_desc'));
4514                                 Showlist($query, 'table', $show, $templateName);
4515                                 break;
4516                 }
4517                 return;
4518         }
4519         
4520         /**
4521          * AdminActions::parse_skinielist()
4522          * Parse skinvar skinielist
4523          * 
4524          * @param       string  $type                   type of skin
4525          * @param       string  $templateName   name of template to use
4526          * @return      void
4527          */
4528         public function parse_skinielist($type, $templateName = '')
4529         {
4530                 $templates = array();
4531                 if ( $templateName )
4532                 {
4533                         $templates = Template::read($templateName);
4534                 }
4535                 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4536                 {
4537                         $template = $templates['SKINIE_EXPORT_LIST'];
4538                 }
4539                 else
4540                 {
4541                         $template = '<td><input type="checkbox" name="<%typeid%>"  id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
4542                                           . "<td><%expdesc%></td>\n"
4543                                           . "</tr><tr>\n";
4544                 }
4545                 switch ( $type )
4546                 {
4547                         case 'skin':
4548                                 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4549                                 while ( $skinObj = sql_fetch_object($res) )
4550                                 {
4551                                         $data = array(
4552                                                 'typeid'        => 'skin[' . $skinObj->sdnumber . ']',
4553                                                 'expid'         => 'skinexp' . $skinObj->sdnumber,
4554                                                 'expname'       => Entity::hsc($skinObj->sdname),
4555                                                 'expdesc'       => Entity::hsc($skinObj->sddesc),
4556                                         );
4557                                         echo Template::fill($template, $data);
4558                                 }
4559                                 break;
4560                         case 'template':
4561                                 $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%'");
4562                                 while ($templateObj = sql_fetch_object($res)) {
4563                                         $data = array(
4564                                                 'typeid'        => 'template[' . $templateObj->tdnumber . ']',
4565                                                 'expid'         => 'templateexp' . $templateObj->tdnumber,
4566                                                 'expname'       => Entity::hsc($templateObj->tdname),
4567                                                 'expdesc'       => Entity::hsc($templateObj->tddesc),
4568                                         );
4569                                         echo Template::fill($template, $data);
4570                                 }
4571                                 break;
4572                 }
4573                 return;
4574         }
4575         
4576         /**
4577          * AdminActions::parse_skinoverview()
4578          * Parse skinvar skinoverview
4579          * 
4580          * @param       string  $templateName   name of template to use
4581          * @return      void
4582          */
4583         public function parse_skinoverview($templateName = '')
4584         {
4585                 global $CONF;
4586                 $query = "SELECT * FROM %s WHERE sdincmode != 'admin' ORDER BY sdname";
4587                 $query = sprintf($query, sql_table('skin_desc'));
4588                 
4589                 $template['content']  = 'skinlist';
4590                 $template['tabindex'] = 10;
4591 //              $template['friendly_names'] = Skin::getFriendlyNames('Actions');
4592                 $skin = new Skin($CONF['BaseSkin']);
4593                 $template['friendly_names'] = $skin->getDefaultTypes();
4594                 
4595                 Showlist($query, 'table', $template, $templateName);
4596                 return;
4597         }
4598         
4599         /**
4600          * AdminActions::parse_skintypehelp()
4601          * Check editing skintypehelp
4602          * 
4603          * @param       void
4604          * @return      void
4605          */
4606         public function parse_skintypehelp()
4607         {
4608                 $nowSkinType = strtolower(trim(requestVar('type')));
4609                 $regularType = array(
4610                         'index',
4611                         'item',
4612                         'archivelist',
4613                         'archive',
4614                         'search',
4615                         'error',
4616                         'member',
4617                         'imagepopup'
4618                 );
4619                 
4620                 if ( in_array($nowSkinType, $regularType) )
4621                 {
4622                         help('skinpart' . $nowSkinType);
4623                 }
4624                 else
4625                 {
4626                         help('skinpartspecial');
4627                 }
4628                 return;
4629         }
4630         
4631         /**
4632          * AdminActions::parse_specialskinlist()
4633          * Parse skinvar specialskinlist
4634          * 
4635          * @param       string  $templateName   name of template to use
4636          * @return      void
4637          */
4638         public function parse_specialskinlist($templateName = '')
4639         {
4640                 $templates = array();
4641                 if ( $templateName )
4642                 {
4643                         $templates = Template::read($templateName);
4644                 }
4645                 $nType  = array(
4646                         'index',
4647                         'item',
4648                         'error',
4649                         'search',
4650                         'archive',
4651                         'archivelist',
4652                         'imagepopup',
4653                         'member'
4654                 );
4655                 $skinid = intRequestVar('skinid');
4656                 $query  = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4657                 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4658                 
4659                 $res    = sql_query($query);
4660                 if ( $res && sql_num_rows($res) > 0 )
4661                 {
4662                         $data = array();
4663                         if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4664                         {
4665                                 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4666                         }
4667                         else
4668                         {
4669                                 $template['head'] = "<ul>\n";
4670                         }
4671                         echo Template::fill($template['head'], $data);
4672                         if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
4673                         {
4674                                 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4675                         }
4676                         else
4677                         {
4678                                 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&amp;skinid=<%skinid%>'
4679                                                                   . '&amp;type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4680                                                                   . 'action=skinremovetype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">remove</a>)</li>';
4681                         }
4682                         $tabstart = 75;
4683                         while ( $row = sql_fetch_assoc($res) )
4684                         {
4685                                 $data = array(
4686                                         'tabindex' => $tabstart++,
4687                                         'skinid'   => $skinid,
4688                                         'skintype' => Entity::hsc(strtolower($row['stype']))
4689                                 );
4690                                 echo Template::fill($template['body'], $data);
4691                         }
4692                         $data = array();
4693                         if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4694                         {
4695                                 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4696                         }
4697                         else
4698                         {
4699                                 $template['foot'] = "</ul>\n";
4700                         }
4701                         echo Template::fill($template['foot'], $data);
4702                         return;
4703                 }
4704         }
4705         
4706         /**
4707          * AdminActions::parse_sprinttext()
4708          * Parse sprinttext
4709          * 
4710          * @param       string  $which  
4711          * @param       string  $val    
4712          * @return      void
4713          */
4714         public function parse_sprinttext($which, $val)
4715         {
4716                 if ( !defined($which) )
4717                 {
4718                         $base = $which;
4719                 }
4720                 else
4721                 {
4722                         $base = constant($which);
4723                 }
4724                 
4725                 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4726                 {
4727                         if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4728                         {
4729                                 $met = 'parse_' . $matchies[0];
4730                         }
4731                         else
4732                         {
4733                                 $arg = trim($args[0], '()');
4734                                 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4735                         }
4736                         
4737                         if ( method_exists($this, $met) )
4738                         {
4739                                 $value = call_user_func(array(&$this, $met), $arg);
4740                         }
4741                 }
4742                 
4743                 if ( !isset($value) || empty($value) )
4744                 {
4745                         $value = $val;
4746                 }
4747                 echo sprintf($base, $value);
4748                 return;
4749         }
4750         
4751         /**
4752          * AdminActions::parse_systemsettings()
4753          * Parse skinvar systemsettings
4754          * 
4755          * @param       string  $type                   type of settings for system
4756          * @param       string  $templateName   name of template to use 
4757          * @return      void
4758          */
4759         public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4760         {
4761                 global $member, $CONF, $nucleus;
4762                 
4763                 $member->isAdmin() or Admin::disallow();
4764                 
4765                 $enable  = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4766                 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4767                 
4768                 switch ( $type )
4769                 {
4770                         case 'phpversion':
4771                                 echo phpversion();
4772                                 break;
4773                         case 'sqlserverinfo':
4774                                 echo sql_get_server_info();
4775                                 break;
4776                         case 'sqlclientinfo':
4777                                 echo sql_get_client_info();
4778                                 break;
4779                         case 'magicquotesgpc':
4780                                 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4781                                 break;
4782                         case 'magicquotesruntime':
4783                                 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4784                                 break;
4785                         case 'registerglobals':
4786                                 echo ini_get('register_globals') ? 'On' : 'Off';
4787                                 break;
4788                         case 'gdinfo':
4789                                 $templates = array();
4790                                 if ( $templateName )
4791                                 {
4792                                         $templates = Template::read($templateName);
4793                                 }
4794                                 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
4795                                 {
4796                                         $template = $templates['SYSTEMINFO_GDSETTINGS'];
4797                                 }
4798                                 else
4799                                 {
4800                                         $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
4801                                 }
4802                                 
4803                                 $gdinfo = gd_info();
4804                                 
4805                                 foreach ( $gdinfo as $key => $value )
4806                                 {
4807                                         if ( is_bool($value) )
4808                                         {
4809                                                 $value = $value ? $enable : $disable;
4810                                         }
4811                                         else
4812                                         {
4813                                                 $value = Entity::hsc($value);
4814                                         }
4815                                         $data = array(
4816                                                 'key'   => $key,
4817                                                 'value' => $value,
4818                                         );
4819                                         echo Template::fill($template, $data);
4820                                 }
4821                                 break;
4822                         case 'modrewrite':
4823                                 ob_start();
4824                                 phpinfo(INFO_MODULES);
4825                                 $im = ob_get_contents();
4826                                 ob_end_clean();
4827                                 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4828                                 break;
4829                         case 'nucleusversion':
4830                                 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4831                                 break;
4832                         case 'nucleuspatchlevel':
4833                                 echo getNucleusPatchLevel();
4834                                 break;
4835                         case 'confself':
4836                                 echo $CONF['Self'];
4837                                 break;
4838                         case 'confitemurl':
4839                                 echo $CONF['ItemURL'];
4840                                 break;
4841                         case 'alertonheaderssent':
4842                                 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4843                                 break;
4844                         case 'nucleuscodename':
4845                                 if ( $nucleus['codename'] != '' )
4846                                 {
4847                                         echo ' &quot;' . $nucleus['codename'] . '&quot;';
4848                                 }
4849                                 break;
4850                         case 'versioncheckurl':
4851                                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4852                                 break;
4853                 }
4854                 return;
4855         }
4856         
4857         /**
4858          * AdminActions::parse_templateoverview()
4859          * Parse skinvar templateoverview
4860          * 
4861          * @param       string  $templateName   name of template to use
4862          * @return      void
4863          */
4864         public function parse_templateoverview($templateName = '')
4865         {
4866                 $query  = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4867                 $query = sprintf($query, sql_table('template_desc'));
4868                 $template['content']  = 'templatelist';
4869                 $template['tabindex'] = 10;
4870                 Showlist($query, 'table', $template, $templateName);
4871                 return;
4872         }
4873         
4874         /**
4875          * AdminActions::parse_ticket()
4876          * Parse ticket
4877          * 
4878          * @param       void
4879          * @return      void
4880          */
4881         public function parse_ticket()
4882         {
4883                 global $manager;
4884                 $manager->addTicketHidden();
4885                 return;
4886         }
4887         
4888         /**
4889          * AdminActions::parse_versioncheckurl()
4890          * Parse skinvar versioncheckurl
4891          * 
4892          * @param       void
4893          * @return      void
4894          */
4895         public function parse_versioncheckurl()
4896         {
4897                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4898                 return;
4899         }
4900         
4901         /**
4902          * AdminActions::parse_yrbloglist()
4903          * Parse skinvar yrbloglist
4904          * 
4905          * @param       string  $templateName   name of template to use
4906          * @return      void
4907          */
4908         public function parse_yrbloglist($templateName = '')
4909         {
4910                 global $member;
4911                 $showAll = requestVar('showall');
4912                 
4913                 if ( $member->isAdmin() && ($showAll == 'yes') )
4914                 {
4915                         // Super-Admins have access to all blogs! (no add item support though)
4916                         $query =  "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4917                                 . " FROM %s"
4918                                 . " ORDER BY bnumber";
4919                         $query = sprintf($query, sql_table('blog'));
4920                 }
4921                 else
4922                 {
4923                         $query =  "SELECT bnumber, bname, tadmin, burl, bshortname"
4924                                 . " FROM %s,%s"
4925                                 . " WHERE tblog=bnumber and tmember=%d"
4926                                 . " ORDER BY bnumber";
4927                         $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4928                 }
4929                 
4930                 $template['content']    = 'bloglist';
4931                 $template['superadmin'] = $member->isAdmin();
4932                 
4933                 $amount = Showlist($query, 'table', $template, $templateName);
4934                 
4935                 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4936                 {
4937                         $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4938                         
4939                         $total = quickQuery($query);
4940                         if ( $total > $amount )
4941                         {
4942                                 echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4943                         }
4944                 }
4945                 
4946                 if ( $amount == 0 )
4947                 {
4948                         echo _OVERVIEW_NOBLOGS;
4949                 }
4950                 elseif( $amount != 0 )
4951                 {
4952                         echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4953                         
4954                         $query =  "SELECT ititle, inumber, bshortname"
4955                                . " FROM %s,%s"
4956                                . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
4957                         $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4958                         
4959                         $template['content'] = 'draftlist';
4960                         
4961                         $amountdrafts = Showlist($query, 'table', $template, $templateName);
4962                         if ( $amountdrafts == 0 )
4963                         {
4964                                 echo _OVERVIEW_NODRAFTS;
4965                         }
4966                 }
4967                 return;
4968         }
4969         
4970         /**
4971          * AdminActions::checkCondition()
4972          * Checks conditions for if statements
4973          *
4974          * @param       string  $field type of <%if%>
4975          * @param       string  $name property of field
4976          * @param       string  $value value of property
4977          * @return      boolean condition
4978          */
4979         protected function checkCondition($field, $name='', $value = '')
4980         {
4981                 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
4982                 
4983                 $condition = 0;
4984                 switch ( $field )
4985                 {
4986                         case 'category':
4987                                 if ( !$blog )
4988                                 {
4989                                         if ( $blogid )
4990                                         {
4991                                                 global $manager;
4992                                                 $blog =& $manager->getBlog($blogid);
4993                                         }
4994                                         elseif ( $catid )
4995                                         {
4996                                                 $blogid = getBlogIDFromCatID($catid);
4997                                                 global $manager;
4998                                                 $blog =& $manager->getBlog($blogid);
4999                                         }
5000                                         elseif ( intRequestVar('catid') )
5001                                         {
5002                                                 $catid = intRequestVar('catid');
5003                                                 $blogid = getBlogIDFromCatID($catid);
5004                                                 global $manager;
5005                                                 $blog =& $manager->getBlog($blogid);
5006                                         }
5007                                         else
5008                                         {
5009                                                 return;
5010                                         }
5011                                 }
5012                                 $condition = ($blog && $this->ifCategory($name, $value));
5013                                 break;
5014                         case 'blogsetting':
5015                                 $condition = ($blog && ($blog->getSetting($name) == $value));
5016                                 break;
5017                         case 'loggedin':
5018                                 $condition = $member->isLoggedIn();
5019                                 break;
5020                         case 'onteam':
5021                                 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5022                                 break;
5023                         case 'admin':
5024                                 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5025                                 break;
5026                         case 'superadmin':
5027                                 $condition = $member->isLoggedIn() && $member->isAdmin();
5028                                 break;
5029                         case 'allowloginedit':
5030                                 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5031                                 break;
5032                         case 'nextitem':
5033                                 $condition = ($itemidnext != '');
5034                                 break;
5035                         case 'previtem':
5036                                 $condition = ($itemidprev != '');
5037                                 break;
5038                         case 'archiveprevexists':
5039                                 $condition = ($archiveprevexists == true);
5040                                 break;
5041                         case 'archivenextexists':
5042                                 $condition = ($archivenextexists == true);
5043                                 break;
5044                         case 'skintype':
5045                                 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5046                                 break;
5047                         case 'hasplugin':
5048                                 $condition = $this->ifHasPlugin($name, $value);
5049                                 break;
5050                         case 'adminaction':
5051                                 $condition = (Admin::getAdminAction() == $name);
5052                                 break;
5053                         case 'adminoldaction':
5054                                 $condition = (Admin::getAdminAction() == $name);
5055                                 break;
5056                         case 'addresschange':
5057                                 $condition = ($this->ifAddresscange());
5058                                 break;
5059                         case 'bechangepass':
5060                                 $condition = ($this->beChangePassword());
5061                                 break;
5062                         case 'skincandidates':
5063                                 $condition = ($this->ifSkincandidates());
5064                                 break;
5065                         case 'nameclashes':
5066                                 $condition = requestVar('nameclashes');
5067                                 break;
5068                         case 'existsnewplugin':
5069                                 $condition = ($this->existsNewPlugin());
5070                                 break;
5071                         case 'autosave':
5072                                 $condition = (boolean) ($member->getAutosave() == $value);
5073                                 break;
5074                         default:
5075                                 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5076                                 break;
5077                 }
5078                 return $condition;
5079         }
5080         
5081         /**
5082          * Actions::_ifHasPlugin()
5083          *      hasplugin,PlugName
5084          *         -> checks if plugin exists
5085          *      hasplugin,PlugName,OptionName
5086          *         -> checks if the option OptionName from plugin PlugName is not set to 'no'
5087          *      hasplugin,PlugName,OptionName=value
5088          *         -> checks if the option OptionName from plugin PlugName is set to value
5089          *
5090          * @param       string  $name   name of plugin
5091          * @param       string  $value  
5092          * @return      
5093          */
5094         private function ifHasPlugin($name, $value)
5095         {
5096                 global $manager;
5097                 $condition = false;
5098                 // (pluginInstalled method won't write a message in the actionlog on failure)
5099                 if ( $manager->pluginInstalled("NP_{$name}") )
5100                 {
5101                         $plugin =& $manager->getPlugin("NP_{$name}");
5102                         if ( $plugin != NULL )
5103                         {
5104                                 if ( $value == "" )
5105                                 {
5106                                         $condition = true;
5107                                 }
5108                                 else
5109                                 {
5110                                         list($name2, $value2) = preg_split('#=#', $value, 2);
5111                                         if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5112                                         {
5113                                                 $condition = true;
5114                                         }
5115                                         else if ( $plugin->getOption($name2) == $value2 )
5116                                         {
5117                                                 $condition = true;
5118                                         }
5119                                 }
5120                         }
5121                 }
5122                 return $condition;
5123         }
5124         
5125         /**
5126          * Actions::beChangePassword()
5127          * 
5128          * @param       void
5129          * @return      void
5130          */
5131         private function beChangePassword()
5132         {
5133                 return intRequestVar('bNeedsPasswordChange');
5134         }
5135         
5136         /**
5137          * Actions::ifSkincandidates()
5138          * Checks if a plugin exists and call its doIf function
5139          * 
5140          * @param       void
5141          * @return      void
5142          */
5143         private function ifSkincandidates()
5144         {
5145                 global $DIR_SKINS;
5146                 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5147                 return (count($candidates) > 0);
5148         }
5149         
5150         /**
5151          * Actions::ifPlugin()
5152          * Checks if a plugin exists and call its doIf function
5153          */
5154         private function ifPlugin($name, $key = '', $value = '')
5155         {
5156                 global $manager;
5157
5158                 $plugin =& $manager->getPlugin("NP_{$name}");
5159                 if ( !$plugin )
5160                 {
5161                         return;
5162                 }
5163
5164                 $params = func_get_args();
5165                 array_shift($params);
5166
5167                 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5168         }
5169
5170         /**
5171          *  Different checks for a category
5172          */
5173         private function ifCategory($name = '', $value='')
5174         {
5175                 global $blog, $catid;
5176
5177                 // when no parameter is defined, just check if a category is selected
5178                 if (($name != 'catname' && $name != 'catid') || ($value == ''))
5179                 {
5180                         return $blog->isValidCategory($catid);
5181                 }
5182
5183                 // check category name
5184                 if ( $name == 'catname' )
5185                 {
5186                         $value = $blog->getCategoryIdFromName($value);
5187                         if ($value == $catid)
5188                         {
5189                                 return $blog->isValidCategory($catid);
5190                         }
5191                 }
5192
5193                 // check category id
5194                 if (($name == 'catid') && ($value == $catid))
5195                 {
5196                         return $blog->isValidCategory($catid);
5197                 }
5198
5199                 return FALSE;
5200         }
5201
5202         /**
5203          *  Checks if a member is on the team of a blog and return his rights
5204          */
5205         private function ifOnTeam($blogName = '')
5206         {
5207                 global $blog, $member, $manager;
5208
5209                 // when no blog found
5210                 if ( ($blogName == '') && !is_object($blog) )
5211                 {
5212                         return 0;
5213                 }
5214                 
5215                 // explicit blog selection
5216                 if ($blogName != '')
5217                 {
5218                         $blogid = getBlogIDFromName($blogName);
5219                 }
5220
5221                 if (($blogName == '') || !$manager->existsBlogID($blogid))
5222                 {
5223                         // use current blog
5224                         $blogid = $blog->getID();
5225                 }
5226                 return $member->teamRights($blogid);
5227         }
5228
5229         /**
5230          *  Checks if a member is admin of a blog
5231          */
5232         private function ifAdmin($blogName = '')
5233         {
5234                 global $blog, $member, $manager;
5235
5236                 // when no blog found
5237                 if (($blogName == '') && (!is_object($blog)))
5238                 {
5239                         return 0;
5240                 }
5241
5242                 // explicit blog selection
5243                 if ($blogName != '')
5244                 {
5245                         $blogid = getBlogIDFromName($blogName);
5246                 }
5247
5248                 if (($blogName == '') || !$manager->existsBlogID($blogid))
5249                 {
5250                         // use current blog
5251                         $blogid = $blog->getID();
5252                 }
5253
5254                 return $member->isBlogAdmin($blogid);
5255         }
5256
5257         /**
5258          * Check e-Mail address is changed
5259          */
5260         private function ifAddresscange()
5261         {
5262                 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5263                 if ( !$key )
5264                 {
5265                         return FALSE;
5266                 }
5267                 $info = MEMBER::getActivationInfo($key);
5268                 if ( !$info )
5269                 {
5270                         return FALSE;
5271                 }
5272                 $mem  = MEMBER::createFromId($info->vmember);
5273                 if ( !$mem )
5274                 {
5275                         return FALSE;
5276                 }
5277                 if ( $info->vtype == 'addresschange' )
5278                 {
5279                         return TRUE;
5280                 }
5281                 return FALSE;
5282         }
5283         
5284         /**
5285          * AdminActions::customHelp()
5286          * shows a link to custom help file
5287          * 
5288          * @param       string  $id                     
5289          * @param       string  $tplName        
5290          * @param       string  $url            
5291          * @param       string  $iconURL        
5292          * @param       string  $alt            
5293          * @param       string  $title          
5294          * @param       $onclick
5295          * 
5296          */
5297         private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5298         {
5299                 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5300         }
5301         
5302         /**
5303          * AdminActions::customHelp()
5304          * shows a link to custom help file
5305          * 
5306          * @param       string  $id                     
5307          * @param       string  $tplName        
5308          * @param       string  $url            
5309          * @param       string  $iconURL        
5310          * @param       string  $alt            
5311          * @param       string  $title          
5312          * @param       $onclick
5313          * 
5314          */
5315         static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5316         {
5317                 $templates = array();
5318                 if ($tplName) {
5319                         $templates = Template::read($tplName);
5320                 }
5321                 if (isset($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) && !empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR'])) {
5322                         $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5323                 } else {
5324                         $template = '<a href="<%helpurl%>#<%helptarget%>" title="<%title%>" <%onclick%>>';
5325                 }
5326                 if (empty($url)) {
5327                         global $CONF;
5328                         $url    = $CONF['AdminURL'] . 'documentation/customHelp.html';
5329                 }
5330                 if (empty($onclick)) {
5331                         $onclick = 'onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);"';
5332                 } elseif (preg_match('/^onclick/', $onclick)) {
5333                         $onclick = $onclick;
5334                 } else {
5335                         $onclick = 'onclick="' . $onclick . '"';
5336                 }
5337                 $data = array(
5338                                 'helpurl'    => $url,
5339                                 'helptarget' => $id,
5340                                 'onclick'    => $onclick,
5341                                 'title'      => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5342                 );
5343                 return Template::fill($template, $data);
5344         }
5345         
5346         /**
5347          * AdminActions::customHelpHtml()
5348          * 
5349          * @param       string  $id                     
5350          * @param       string  $tplName        
5351          * @param       string  $url            
5352          * @param       string  $iconURL        
5353          * @param       string  $alt            
5354          * @param       string  $title          
5355          * @param       string  $onclick        
5356          * @return      string  anchor element with help uri
5357          */
5358         private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5359         {
5360                 $templates = array();
5361                 if ( $tplName )
5362                 {
5363                         $templates = Template::read($tplName);
5364                 }
5365                 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5366                 {
5367                         $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5368                 }
5369                 else
5370                 {
5371                         $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
5372                 }
5373                 
5374                 if ( empty($iconURL) )
5375                 {
5376                         global $CONF;
5377                         $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5378                 }
5379                 if ( function_exists('getimagesize') )
5380                 {
5381                         $size   = getimagesize($iconURL);
5382                         $width  = 'width="'  . $size[0] . '" ';
5383                         $height = 'height="' . $size[1] . '" ';
5384                 }
5385                 $data = array(
5386                         'iconurl'       => $iconURL,
5387                         'width'         => $width,
5388                         'height'        => $height,
5389                         'alt'           => (isset($alt) && !empty($alt))         ? $alt   : _HELP_TT,
5390                         'title'         => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5391                 );
5392                 $icon = Template::fill($template, $data);
5393                 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5394                 return $help . $icon;
5395         }
5396         
5397         /**
5398          * AdminActions::input_yesno
5399          * 
5400          * @param               $name
5401          * @param               $checkedval
5402          * @param               $tabindex
5403          * @param               $value1
5404          * @param               $value2
5405          * @param               $yesval
5406          * @param               $noval
5407          * @param               $isAdmin
5408          * @param               $templateName
5409          * @param               $showlist
5410          */
5411         private function input_yesno($name,
5412                                                                 $checkedval,
5413                                                                 $tabindex        = 0,
5414                                                                 $value1    = 1,
5415                                                                 $value2    = 0,
5416                                                                 $yesval    = _YES,
5417                                                                 $noval          = _NO,
5418                                                                 $isAdmin          = 0,
5419                                                                 $templateName = '',
5420                                                                 $showlist        = false)
5421         {
5422                 $templates = array();
5423                 if ( $templateName )
5424                 {
5425                         $templates = Template::read($templateName);
5426                 }
5427                 
5428                 if ( $name == 'admin' )
5429                 {
5430                         if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5431                         {
5432                                 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5433                         }
5434                         else
5435                         {
5436                                 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5437                                           . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5438                                           . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5439                                           . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5440                         }
5441                 }
5442                 else
5443                 {
5444                         if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5445                         {
5446                                 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5447                         }
5448                         if ( $showlist )
5449                         {
5450                                 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5451                                 {
5452                                         $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5453                                 }
5454                         }
5455                         if ( !isset($template) )
5456                         {
5457                                 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5458                                           . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5459                                           . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5460                                           . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5461                         }
5462                 }
5463                 
5464                 //echo $template;
5465                 $id             = Entity::hsc($name);
5466                 $id             = str_replace('[', '-', $id);
5467                 $id             = str_replace(']', '-', $id);
5468                 $id1    = $id . Entity::hsc($value1);
5469                 $id2    = $id . Entity::hsc($value2);
5470                 $dat = array(
5471                         'name'                  => Entity::hsc($name),
5472                         'yesval'                => Entity::hsc($value1),
5473                         'noval'                 => Entity::hsc($value2),
5474                         'yesid'                 => $id1,
5475                         'noid'                  => $id2,
5476                         'yesvaltext'    => $yesval,
5477                         'novaltext'             => $noval,
5478                         'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5479                         'nocheckedval'  => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5480                         'disabled'              => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5481                 );
5482                 
5483                 if ( $showlist )
5484                 {
5485                         return Template::fill($template, $dat);
5486                 }
5487                 else
5488                 {
5489                         echo Template::fill($template, $dat);
5490                 }
5491                 return;
5492         }
5493
5494         /**
5495          * Check exists new plugin
5496          */
5497         private function existsNewPlugin()
5498         {
5499                 global $DIR_PLUGINS;
5500                 $candidates = array();
5501                 $files      = scandir($DIR_PLUGINS);
5502                 foreach ($files as $file) {
5503                         if (preg_match("/^NP_(.*)\.php$/", $file, $matches)) {
5504                                 $name = $matches[1];
5505                                 $que  = 'SELECT '
5506                                                 . '    * '
5507                                                 . 'FROM '
5508                                                 .      sql_table('plugin') . ' '
5509                                                 . 'WHERE '
5510                                                 . '    pfile = "NP_' . sql_real_escape_string($name) . '"';
5511                                 $res  = sql_query($que);
5512                                 if (sql_num_rows($res) == 0) {
5513                                         $candidates[] = $name;
5514                                 }
5515                         }
5516                 }
5517                 $this->newPlugCandidates = $candidates;
5518                 return (count($candidates) > 0);
5519         }
5520 }