OSDN Git Service

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