OSDN Git Service

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