OSDN Git Service

管理画面用スキン変数のヘルプのリンク生成部分を変更
[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 helplink("adminskinvar-{$current}") . "$current</a>\n";
1537 //                      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";
1538                         
1539                         if ( count($actions) != 0 )
1540                         {
1541                                 echo ", ";
1542                         }
1543                 }
1544                 return;
1545         }
1546         
1547         /**
1548          * Actions::parse_allowedskinactions()
1549          * Parse skinvar allowedskinactions
1550          * 
1551          * @param       void
1552          * @return      void
1553          */
1554         public function parse_allowedskinactions()
1555         {
1556                 $skinType = strtolower(trim(requestVar('type')));
1557                 $actions  = SKIN::getAllowedActionsForType($skinType);
1558                 sort($actions);
1559                 
1560                 while ( $current = array_shift($actions) )
1561                 {
1562                         // skip deprecated vars
1563                         if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1564                         {
1565                                 continue;
1566                         }
1567                         
1568                         /* TODO: alternative function should be used or not?  */
1569                         echo helplink("skinvar-{$current}") . "$current</a>\n";
1570                         
1571                         if ( count($actions) != 0 )
1572                         {
1573                                 echo ", ";
1574                         }
1575                 }
1576                 return;
1577         }
1578         
1579         /**
1580          * Action::parse_banlistdeletedlist()
1581          * Parse skinvar banlistdeletedlist
1582          * 
1583          * @param       string  $templateName   name of template to use
1584          * @return      void
1585          */
1586         public function parse_banlistdeletedlist($templateName = '')
1587         {
1588                 global $manager;
1589                 $templates = array();
1590                 
1591                 if ( $templateName )
1592                 {
1593                         $templates = Template::read($templateName);
1594                 }
1595                 if ( isset($templates['BANLIST_DELETED_LIST']) && !empty($templates['BANLIST_DELETED_LIST']) )
1596                 {
1597                         $template = $templates['BANLIST_DELETED_LIST'];
1598                 }
1599                 else
1600                 {
1601                         $template = "<li><%blogname%></li>\n";
1602                 }
1603                 $deleted = requestArray('delblogs');
1604                 foreach ( $deleted as $delblog )
1605                 {
1606                         $blog =& $manager->getBlog($delblog);
1607                         $data =  array(
1608                                 Entity::hsc($blog->getName())
1609                         );
1610                         TEMPLATE::fill($template, $data);
1611                 }
1612                 return;
1613         }
1614         
1615         /**
1616          * Actions::parse_batchdeletelist()
1617          * Parse skinvar batchdeletelist
1618          * 
1619          * @param       void
1620          * @return      void
1621          */
1622         public function parse_batchdeletelist()
1623         {
1624                 $selected = requestIntArray('batch');
1625                 $index  = 0;
1626                 
1627                 foreach ( $selected as $select )
1628                 {
1629                         echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1630                 }
1631                 // add hidden vars for team & comment
1632                 if ( requestVar('action') == 'batchteam' )
1633                 {
1634                         echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1635                 }
1636                 if ( requestVar('action') == 'batchcomment' )
1637                 {
1638                         echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1639                 }
1640                 return;
1641         }
1642         
1643         /**
1644          * Actions::parse_batchdeletetype()
1645          * Parse skinvar batchdeletetype
1646          * 
1647          * @param       void
1648          * @return      void
1649          */
1650         public function parse_batchdeletetype()
1651         {
1652                 echo Entity::hsc(requestVar('action'));
1653                 return;
1654         }
1655
1656         /**
1657          * Actions::parse_batchmovebtn()
1658          * Parse skinvar batchmovebtn
1659          * 
1660          * @param       void
1661          * @return      void
1662          */
1663         public function parse_batchmovebtn()
1664         {
1665                 $actionType = requestVar('action');
1666                 switch ( $actionType )
1667                 {
1668                         case 'batchitem':
1669                                 echo _MOVE_BTN;
1670                                 break;
1671                         case 'batchcategory':
1672                                 echo _MOVECAT_BTN;
1673                                 break;
1674                 }
1675                 return;
1676         }
1677         
1678         /**
1679          * Actions::parse_batchmovelist()
1680          * Parse skinvar batchmovelist
1681          * 
1682          * @param       void
1683          * @param       void
1684          */
1685         public function parse_batchmovelist()
1686         {
1687                 $selected = requestIntArray('batch');
1688                 foreach ( $selected as $select )
1689                 {
1690                         echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1691                 }
1692                 return;
1693         }
1694         
1695         /**
1696          * Actions::parse_batchmovetitle()
1697          * Parse skinvar batchmovetitle
1698          * 
1699          * @param       void
1700          * @return      void
1701          */
1702         public function parse_batchmovetitle()
1703         {
1704                 $actionType = requestVar('action');
1705                 switch ( $actionType )
1706                 {
1707                         case 'batchitem':
1708                                 echo _MOVE_TITLE;
1709                                 break;
1710                         case 'batchcategory':
1711                                 echo _MOVECAT_TITLE;
1712                                 break;
1713                 }
1714                 return;
1715         }
1716         
1717         /**
1718          * Actions::parse_batchmovetype()
1719          * Parse skinvar batchmovetype
1720          * 
1721          * @param       void
1722          * @return      void
1723          */
1724         public function parse_batchmovetype()
1725         {
1726                 echo Entity::hsc(requestVar('action'));
1727                 return;
1728         }
1729         
1730         /**
1731          * Actions::parse_blogcatlist()
1732          * Parse skinvar blogcatlist
1733          * 
1734          * @param       void
1735          * @return      void
1736          */
1737         public function parse_blogcatlist()
1738         {
1739                 global $manager;
1740                 $blogid = intRequestVar('blogid');
1741                 $query  = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1742                 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1743                 
1744                 $template['content']  = 'categorylist';
1745                 $template['tabindex'] = 200;
1746                 
1747                 $batch = new Batch('member');
1748                 $batch->showlist($query, 'table', $template);
1749                 return;
1750         }
1751         
1752         /**
1753          * Actions::parse_blognotifysetting()
1754          * Parse skinvar blognotifysetting
1755          * 
1756          * @param       void
1757          * @return      void
1758          */
1759         public function parse_blognotifysetting($type)
1760         {
1761                 global $manager;
1762                 $blogid = intRequestVar('blogid');
1763                 $blog   = $manager->getBlog($blogid);
1764                 
1765                 switch ( $type )
1766                 {
1767                         case 'comment':
1768                                 if ( !$blog->notifyOnComment() )
1769                                 {
1770                                         return;
1771                                 }
1772                                 break;
1773                         case 'vote':
1774                                 if ( !$blog->notifyOnVote() )
1775                                 {
1776                                         return;
1777                                 }
1778                                 break;
1779                         case 'newitem':
1780                                 if ( !$blog->notifyOnNewItem() )
1781                                 {
1782                                         return;
1783                                 }
1784                                 break;
1785                 }
1786                 echo ' checked="checked"';
1787                 return;
1788         }
1789         
1790         /**
1791          * AdminAction::parse_blogselectbox()
1792          * Parse skinvar blogselectbox
1793          * 
1794          * @param       void
1795          * @return      void
1796          */
1797         public function parse_blogselectbox()
1798         {
1799                 global $member;
1800                 
1801                 $selectData     = requestVar('selectData');
1802                 $mode           = $selectData['mode'];
1803                 $name           = Entity::hsc($selectData['name']);
1804                 $tabindex       = Entity::hsc($selectData['tabindex']);
1805                 $aBlogIds       = array_map('intval', $selectData['aBlogIds']);
1806                 $showNewCat     = intval($selectData['showNewCat']);
1807                 $selected       = intval($selectData['selected']);
1808                 
1809                 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1810                 
1811                 // 1. select blogs (we'll create optiongroups)
1812                 // (only select those blogs that have the user on the team)
1813                 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1814                 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1815                 $blogs = sql_query($queryBlogs);
1816                 
1817                 if ( $mode == 'category' )
1818                 {
1819                         if ( sql_num_rows($blogs) > 1 )
1820                         {
1821                                 $multipleBlogs = 1;
1822                         }
1823                         while ( $oBlog = sql_fetch_object($blogs) )
1824                         {
1825                                 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1826                                 {
1827                                         echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\>\n";
1828                                 }
1829                                 
1830                                 // show selection to create new category when allowed/wanted
1831                                 if ( $showNewCat )
1832                                 {
1833                                         // check if allowed to do so
1834                                         if ( $member->blogAdminRights($oBlog->bnumber) )
1835                                         {
1836                                                 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1837                                         }
1838                                 }
1839                                 
1840                                 // 2. for each category in that blog
1841                                 $catQueriy  = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1842                                 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1843                                 $categories = sql_query(sprintf($catQueriy));
1844                                 while ( $oCat = sql_fetch_object($categories) )
1845                                 {
1846                                         if ( $oCat->catid == $selected )
1847                                         {
1848                                                 $selectText = ' selected="selected" ';
1849                                         }
1850                                         else
1851                                         {
1852                                                 $selectText = '';
1853                                         }
1854                                         echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . Entity::hsc($oCat->cname) . "</option>\n";
1855                                 }
1856                                 
1857                                 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1858                                 {
1859                                         echo '</optgroup>';
1860                                 }
1861                         }
1862                 }
1863                 else
1864                 {
1865                         // blog mode
1866                         while ( $oBlog = sql_fetch_object($blogs) )
1867                         {
1868                                 echo '<option value="' . $oBlog->bnumber . '"';
1869                                 if ( $oBlog->bnumber == $selected )
1870                                 {
1871                                         echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . Entity::hsc($oBlog->bname) . "</option>\n";
1872                                 }
1873                                 else
1874                                 {
1875                                         echo '<option value="' . $oBlog->bnumber . '">' . Entity::hsc($oBlog->bname) . "</option>\n";
1876                                 }
1877                         }
1878                 }
1879                 echo "</select>\n";
1880                 return;
1881         }
1882         
1883         /**
1884          * Actions::parse_blogsetting()
1885          * Parse skinvar blogsetting
1886          * 
1887          * @param       string  $which  name of weblog setting
1888          * @return      void
1889          */
1890         public function parse_blogsetting($which)
1891         {
1892                 echo $this->parse_getblogsetting($which);
1893                 return;
1894         }
1895         
1896         /**
1897          * Actions::parse_blogsettingyesno()
1898          * Parse skinvar blogsettingyesno
1899          * 
1900          * @param       string  $type                   type of weblog setting
1901          * @param       string  $templateName   name of template to use
1902          * @return      void
1903          */
1904         public function parse_blogsettingyesno($type, $templateName = '')
1905         {
1906                 global $manager;
1907                 
1908                 $blogid = intRequestVar('blogid');
1909                 $blog   = $manager->getBlog($blogid);
1910                 
1911                 switch ( $type )
1912                 {
1913                         case 'convertbreaks':
1914                                 $checkedval = $blog->convertBreaks();
1915                                 $tabindex   = 55;
1916                                 break;
1917                         case 'allowpastposting':
1918                                 $checkedval = $blog->allowPastPosting();
1919                                 $tabindex   = 57;
1920                                 break;
1921                         case 'comments':
1922                                 $checkedval = $blog->commentsEnabled();
1923                                 $tabindex   = 60;
1924                                 break;
1925                         case 'public':
1926                                 $checkedval = $blog->isPublic();
1927                                 $tabindex   = 70;
1928                                 break;
1929                         case 'reqemail':
1930                                 $checkedval = $blog->emailRequired();
1931                                 $tabindex   = 72;
1932                                 break;
1933                         case 'searchable':
1934                                 $checkedval = $blog->getSearchable();
1935                                 $tabindex   = 122;
1936                                 break;
1937                 }
1938                 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1939                 return;
1940         }
1941         
1942         /**
1943          * Actions::parse_blogteamlist()
1944          * Parse skinvar blogteamlist
1945          * 
1946          * @param       string  $templateName   name of template to use
1947          * @return      void
1948          */
1949         public function parse_blogteamlist($templateName = '')
1950         {
1951                 global $manager;
1952                 $blogid = intRequestVar('blogid');
1953                 $query  = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1954                         . "FROM %s, %s "
1955                         . "WHERE tmember=mnumber AND tblog= %d";
1956                 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1957                 
1958                 $template['content']  = 'teamlist';
1959                 $template['tabindex'] = 10;
1960
1961                 $batch = new Batch('team');
1962                 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1963                 return;
1964         }
1965         
1966         /**
1967          * Actions::parse_blogteammembers()
1968          * Parse skinvar blogteammembers
1969          * 
1970          * @param       void
1971          * @return      void
1972          */
1973         public function parse_blogteammembers()
1974         {
1975                 $blogid = intRequestVar('blogid');
1976                 $query  = "SELECT mname, mrealname "
1977                                 . "FROM %s, %s "
1978                                 . "WHERE mnumber=tmember AND tblog=%d;";
1979                 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1980                 $res    = sql_query($query);
1981                 $memberNames = array();
1982                 while ($o = sql_fetch_object($res)) {
1983                         $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1984                 }
1985                 echo implode(',', $memberNames);
1986         }
1987         
1988         /**
1989          * Actions::parse_blogtime()
1990          * Parse skinvar blogtime
1991          * 
1992          * @param       string  $type   type of time
1993          * @param       string  $format format for time expression
1994          * @param       integer $offset offset of time
1995          * @return      void
1996          */
1997         public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1998         {
1999                 global $manager;
2000                 
2001                 if ( $type != 'blogtime' )
2002                 {
2003                         /* return server time */
2004                         $timestamp = time() + $offset;
2005                 }
2006                 else
2007                 {
2008                         $bid            = intRequestVar('blogid');
2009                         $b                      = $manager->getBlog($bid);
2010                         $timestamp      = $b->getCorrectTime() + $offset;
2011                 }
2012                 
2013                 echo i18n::formatted_datetime($format, $timestamp);
2014                 return;
2015         }
2016         
2017         /**
2018          * Actions::parse_bookmarkletadmin()
2019          * Parse skinvar bookmarkletadmin
2020          * 
2021          * @param       string  $type   type of anchor element for bookmarklet
2022          * @return      void
2023          */
2024         public function parse_bookmarkletadmin($type)
2025         {
2026                 global $manager;
2027                 
2028                 $blogid = intRequestVar('blogid');
2029                 
2030                 if ( $type != 'regfile' )
2031                 {
2032                         echo Entity::hsc(getBookmarklet($blogid));
2033                 }
2034                 else
2035                 {
2036                         $url = 'index.php?action=regfile&blogid=' . intval($blogid);
2037                         $url = $manager->addTicketToUrl($url);
2038                         /* TODO: Shift-JIS is not always correct, I think... */
2039                         echo Entity::hsc($url, 'SJIS');
2040                 }
2041                 return;
2042         }
2043         
2044         /**
2045          * Actions::parse_category()
2046          * Parse skinvar category
2047          * 
2048          * @param       string  $type   name of setting for category
2049          * @return      void
2050          */
2051         public function parse_category($type = 'name')
2052         {
2053                 echo $this->parse_getcategory($type);
2054                 return;
2055         }
2056         
2057         /**
2058          * Actions::parse_categorysetting()
2059          * Parse skinvar categorysetting
2060          * 
2061          * @param       string  $type   type in category setting
2062          * @return      void
2063          */
2064         public function parse_categorysetting($type)
2065         {
2066                 $catid  = intRequestVar('catid');
2067                 if ( $type == 'id' )
2068                 {
2069                         echo $catid;
2070                         return;
2071                 }
2072                 $blogid = intRequestVar('blogid');
2073                 $query  = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2074                 $query  = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2075                 $res    = sql_query($query);
2076                 $obj    = sql_fetch_object($res);
2077                 
2078                 if ( $type != desc )
2079                 {
2080                         echo Entity::hsc($obj->cdesc);
2081                 }
2082                 else
2083                 {
2084                         echo Entity::hsc($obj->cname);
2085                 }
2086                 
2087                 return;
2088         }
2089         
2090         /**
2091          * Actions::parse_codename()
2092          * Parse templatevar codename
2093          * 
2094          * @param       void
2095          * @return      void
2096          * 
2097          * TODO: is this need???
2098          */
2099         public function parse_codename()
2100         {
2101                 global $nucleus;
2102                 echo $nucleus['codename'];
2103                 return;
2104         }
2105         
2106         /**
2107          * Actions::parse_commentnavlist()
2108          * Parse skinvar commentnavlist
2109          * 
2110          * @param       void
2111          * @return      void
2112          */
2113         public function parse_commentnavlist()
2114         {
2115                 global $CONF, $manager, $member;
2116                 
2117                 // start index
2118                 if ( postVar('start') )
2119                 {
2120                         $start = intPostVar('start');
2121                 }
2122                 else
2123                 {
2124                         $start = 0;
2125                 }
2126                 
2127                 // amount of items to show
2128                 if ( postVar('amount') )
2129                 {
2130                         $amount = intPostVar('amount');
2131                 }
2132                 else
2133                 {
2134                         $amount = (integer) $CONF['DefaultListSize'];
2135                         if ( $amount < 1 )
2136                         {
2137                                 $amount = 10;
2138                         }
2139                 }
2140                 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2141                        . 'FROM %s '
2142                        . 'LEFT OUTER JOIN %s ON  mnumber=cmember '
2143                        . 'WHERE ';
2144                 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2145                 
2146                 if ( $this->skintype == 'itemcommentlist' )
2147                 {
2148                         $itemid                                 = intRequestVar('itemid');
2149                         $query                                  .= " citem={$itemid}";
2150                         $template['canAddBan']  = $member->blogAdminRights(intRequestVar('blogid'));
2151                         $bid                                    = 0;
2152                         $nonComments                    = _NOCOMMENTS;
2153                 }
2154                 elseif ( $this->skintype == 'browseowncomments' )
2155                 {
2156                         $itemid                                 = 0;
2157                         $query                                  .= ' cmember=' . $member->getID();
2158                         $template['canAddBan']  = 0;
2159                         $bid                                    = 0;
2160                         $nonComments                    = _NOCOMMENTS_YOUR;
2161                 }
2162                 elseif ( $this->skintype == 'blogcommentlist' )
2163                 {
2164                         $itemid                                 = 0;
2165                         $query                                  .= ' cblog=' . intRequestVar('blogid');
2166                         $template['canAddBan']  = $member->blogAdminRights(intRequestVar('blogid'));
2167                         $bid                                    = intRequestVar('blogid');
2168                         $nonComments                    = _NOCOMMENTS_BLOG;
2169                 }
2170                 
2171                 $search = postVar('search');
2172                 if ( !empty($search) )
2173                 {
2174                         $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
2175                 }
2176                 
2177                 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2178                 
2179                 $template['content'] = 'commentlist';
2180                 
2181                 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2182                 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2183                 return;
2184         }
2185         
2186         /**
2187          * Actions::parse_configsettingsedit()
2188          * Parse skinvar configsettingsedit
2189          * 
2190          * @param       string  $type   type of global configuration
2191          * @return      void
2192          */
2193         public function parse_configsettingsedit($type)
2194         {
2195                 global $CONF;
2196                 switch ( $type )
2197                 {
2198                         case 'DefaultListSize':
2199                                 if ( !array_key_exists('DefaultListSize', $CONF) )
2200                                 {
2201                                         $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2202                                         $query = sprintf($query, sql_table('config'));
2203                                         sql_query($query);
2204                                         $CONF['DefaultListSize'] = 10;
2205                                 }
2206                                 elseif ( intval($CONF['DefaultListSize']) < 1 )
2207                                 {
2208                                         $CONF['DefaultListSize'] = 10;
2209                                 }
2210                                 echo intval($CONF['DefaultListSize']);
2211                                 break;
2212                         case 'SessionCookie':
2213                                 $value = $CONF['SessionCookie'];
2214                                 $txt1  = _SETTINGS_COOKIESESSION;
2215                                 $txt2  = _SETTINGS_COOKIEMONTH;
2216                                 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2217                                 break;
2218                         case 'URLMode':
2219                                 $value = $CONF['URLMode'];
2220                                 $txt1  = _SETTINGS_URLMODE_NORMAL;
2221                                 $txt2  = _SETTINGS_URLMODE_PATHINFO;
2222                                 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2223                                 break;
2224                         default:
2225                                 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2226                                 {
2227                                         echo  Entity::hsc($CONF[$type]);
2228                                 }
2229                                 break;
2230                 }
2231                 return;
2232         }
2233         
2234         /**
2235          * Actions::parse_configsettingsyesno()
2236          * Parse skinvar configsettingsyesno
2237          * 
2238          * @param       string  $type           type of global setting
2239          * @param       integer $tabindex       tabindex attribute of input element
2240          * @return      void
2241          */
2242         public function parse_configsettingsyesno($type, $tabindex)
2243         {
2244                 global $CONF;
2245                 if ( array_key_exists($type, $CONF) )
2246                 {
2247                         $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2248                 }
2249                 return;
2250         }
2251         
2252         /**
2253          * Actions::parse_customhelplink()
2254          * Parse skinvar customhelplink
2255          * 
2256          * @param       string  $topic          name of topic
2257          * @param       string  $tplName        name of template
2258          * @param       string  $url            string as URI
2259          * @param       string  $iconURL        string as URI for icon
2260          * @param       string  $alt            alternative text for image element
2261          * @param       string  $title          title for anchor element
2262          * @return      void
2263          */
2264         public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2265         {
2266                 $this->customHelp($topic, $url, $iconURL);
2267                 return;
2268         }
2269         
2270         /**
2271          * Actions::parse_date()
2272          * Parse skinvar date
2273          */
2274         public function parse_date($format = 'c')
2275         {
2276                 global $CONF, $manager;
2277                 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2278                 return;
2279         }
2280         
2281         /**
2282          * Actions::parse_defaultadminskintypes()
2283          * Parse skinvar defaultadminskintypes
2284          * 
2285          * @param       string  $tabindex               index number for tabindex attribute of input element
2286          * @param       string  $templateName   name of template
2287          * @return      void
2288          */
2289         public function parse_defaultadminskintypes($tabindex, $templateName = '')
2290         {
2291                 $templates = array();
2292                 if ( $templateName )
2293                 {
2294                         $templates = Template::read($templateName);
2295                 }
2296                 
2297                 $types   = Skin::getAdminskinDefaultTypeFriendlyNames();
2298                 ksort($types);
2299                 
2300                 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
2301                 {
2302                         $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2303                 }
2304                 else
2305                 {
2306                         $template['head'] = "<ul>\n";
2307                 }
2308                 
2309                 echo $template['head'];
2310                 
2311                 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
2312                 {
2313                         $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2314                 }
2315                 else
2316                 {
2317                         $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">'
2318                                           . "<%name%></a> <%help%></li>\n";
2319                 }
2320                 $handler = new Actions('template', $template, new ADMIN);
2321                 $parser  = new PARSER(Actions::getDefinedActions(), $handler);
2322                 
2323                 foreach ( $types as $type => $fName )
2324                 {
2325                         $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
2326                         $data = array(
2327                                 'tabindex'      => $tabindex,
2328                                 'skintype'      => $type,
2329                                 'name'          => $fName,
2330                                 'help'          => $helplink,
2331                                 'skinid'        => intrequestVar('skinid'),
2332                         );
2333                         $templateBody = Template::fill($template['body'], $data);
2334                         $parser->parse($templateBody);
2335                         $tabindex++;
2336                 }
2337                 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
2338                 {
2339                         $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2340                 }
2341                 else
2342                 {
2343                         $template['foot'] = "           </ul>\n";
2344                 }
2345                 echo $template['foot'];
2346                 return;
2347         }
2348         
2349         /**
2350          * Actions::parse_defblogselect()
2351          * Parse skinvar defblogselect
2352          * 
2353          * @param       string  $templateName   name of template
2354          * @return      void
2355          */
2356         public function parse_defblogselect($templateName = '')
2357         {
2358                 global $CONF;
2359                 $query  = "SELECT bname as text, bnumber as value FROM %s;";
2360                 $query = sprintf($query, sql_table('blog'));
2361                 $template['name']        = 'DefaultBlog';
2362                 $template['selected'] = $CONF['DefaultBlog'];
2363                 $template['tabindex'] = 10;
2364                 Showlist($query, 'select', $template, $templateName);
2365                 return;
2366         }
2367         
2368         /**
2369          * Actions::parse_defcatselect()
2370          * Parse skinvar defcatselect
2371          * 
2372          * @param       string  $templateName   name of template
2373          * @return      void
2374          */
2375         public function parse_defcatselect($templateName = '')
2376         {
2377                 global $manager;
2378                 $blogid = intRequestVar('blogid');
2379                 $blog   = $manager->getBlog($blogid);
2380                 $query  = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2381                 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2382                 $template['name']        = 'defcat';
2383                 $template['selected'] = $blog->getDefaultCategory();
2384                 $template['tabindex'] = 110;
2385                 Showlist($query, 'select', $template, $templateName);
2386                 return;
2387         }
2388         
2389         /**
2390          * Actions::parse_defskinselect()
2391          * Parse skinvar defskinselect
2392          * 
2393          * @param       string  $type                   type of skin
2394          * @param       string  $templateName   name of template
2395          * @return      void
2396          */
2397         public function parse_defskinselect($type = 'blog', $templateName = '')
2398         {
2399                 global $manager;
2400                 $query  = "SELECT sdname as text, sdnumber as value FROM %s;";
2401                 $query = sprintf($query, sql_table('skin_desc'));
2402                 
2403                 $blogid = intRequestVar('blogid');
2404                 
2405                 if ( !$blogid )
2406                 {
2407                         global $CONF;
2408                         $template['selected'] = $CONF['BaseSkin'];
2409                 }
2410                 else
2411                 {
2412                         $blog                            = $manager->getBlog($blogid);
2413                         $template['selected'] = $blog->getDefaultSkin();
2414                 }
2415                 
2416                 if ( $type != 'blog' )
2417                 {
2418                         $nname = 'BaseSkin';
2419                 }
2420                 else
2421                 {
2422                         $nname = 'defskin';
2423                 }
2424                 
2425                 $template['name']        = $nname;
2426                 $template['tabindex'] = 50;
2427                 Showlist($query, 'select', $template, $templateName);
2428                 return;
2429         }
2430         
2431         /**
2432          * AdminActions::parse_deletecomment()
2433          * Parse skinvar deletecomment
2434          * 
2435          * @param       string  $type   type of infomation for comment
2436          * @return      void
2437          */
2438         public function parse_deletecomment($type = 'id')
2439         {
2440                 $commentid      = intRequestVar('commentid');
2441                 $comment        = COMMENT::getComment($commentid);
2442                 
2443                 switch ( $type )
2444                 {
2445                         case 'id':
2446                                 echo intRequestVar('commentid');
2447                                 break;
2448                         case 'author':
2449                                 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2450                                 {
2451                                         echo $comment['member'];
2452                                 }
2453                                 else
2454                                 {
2455                                         echo $comment['user'];
2456                                 }
2457                                 break;
2458                         case 'body':
2459                                 $body = strip_tags($comment['body']);
2460                                 echo Entity::hsc(shorten($body, 300, '...'));
2461                 }
2462                 return;
2463         }
2464         
2465         /**
2466          * Actions::parse_deleteitembody()
2467          * Parse skinvar deleteitembody
2468          * 
2469          * @param       void
2470          * @return      void
2471          */
2472         public function parse_deleteitembody()
2473         {
2474                 global $manager;
2475                 $itemid =  intRequestVar('itemid');
2476                 $item   =& $manager->getItem($itemid, 1, 1);
2477                 $body   =  strip_tags($item['body']);
2478                 echo Entity::hsc(shorten($body, 300, '...'));
2479                 return;
2480         }
2481         
2482         /**
2483          * Actions::parse_deleteitemid()
2484          * Parse skinvar deleteitemid
2485          * 
2486          * @param       void
2487          * @return      void
2488          */
2489         public function parse_deleteitemid()
2490         {
2491                 echo (integer) intRequestVar('itemid');
2492                 return;
2493         }
2494         
2495         /**
2496          * Actions::parse_deleteitemtitle()
2497          * Parse skinvar deleteitemtitle
2498          * 
2499          * @param       void
2500          * @return      void
2501          */
2502         public function parse_deleteitemtitle()
2503         {
2504                 global $manager;
2505                 $itemid = intRequestVar('itemid');
2506                 $item  =& $manager->getItem($itemid, 1, 1);
2507                 echo Entity::hsc(strip_tags($item['title']));
2508                 return;
2509         }
2510         
2511         /**
2512          * Actions::parse_editadminskin()
2513          * Parse skinvar editadminskin
2514          * 
2515          * @param       string  $type   type of skin setting
2516          * @return      void
2517          */
2518         public function parse_editadminskin($type = 'id')
2519         {
2520                 $skinid = intRequestVar('skinid');
2521                 $skin   = new Skin($skinid);
2522                 switch ( $type )
2523                 {
2524                         case 'id':
2525                                 echo intRequestVar('skinid');
2526                                 break;
2527                         case 'name':
2528                                 echo Entity::hsc($skin->getName());
2529                                 break;
2530                         case 'desc':
2531                                 echo Entity::hsc($skin->getDescription());
2532                                 break;
2533                         case 'type':
2534                                 echo Entity::hsc($skin->getContentType());
2535                                 break;
2536                         case 'prefix':
2537                                 echo Entity::hsc($skin->getIncludePrefix());
2538                                 break;
2539                         case 'mode':
2540                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2541                         default:
2542                                 break;
2543                 }
2544                 return;
2545         }
2546         
2547         /**
2548          * Actions::parse_editadminskintype()
2549          * Parse skinvar editadminskintype
2550          * 
2551          * @param       string  $type   name of skin type
2552          * @return      void
2553          */
2554         public function parse_editadminskintype($type = 'id')
2555         {
2556                 global $CONF, $manager, $member;
2557                 $skinid = intRequestVar('skinid');
2558                 $skin   = new Skin($skinid);
2559                 $fNames = Skin::getFriendlyNames();
2560                 $sType  = strtolower(trim(requestVar('type')));
2561                 
2562                 switch ( $type )
2563                 {
2564                         case 'id':
2565                                 echo intRequestVar('skinid');
2566                                 break;
2567                         case 'name':
2568                                 echo Entity::hsc($skin->getName());
2569                                 break;
2570                         case 'desc':
2571                                 echo Entity::hsc($skin->getDescription());
2572                                 break;
2573                         case 'type':
2574                                 echo Entity::hsc($skin->getContentType());
2575                                 break;
2576                         case 'content':
2577                                 echo Entity::hsc($skin->getContent($sType));
2578                                 break;
2579                         case 'skintype':
2580                                 $skinType = isset($fNames[$sType]) ? $fNames[$sType] : ucfirst($sType);
2581                                 echo Entity::hsc($skinType);
2582                                 break;
2583                         case 'skintyperaw':
2584                                 echo Entity::hsc($sType);
2585                                 break;
2586                         case 'prefix':
2587                                 echo Entity::hsc($skin->getIncludePrefix());
2588                                 break;
2589                         case 'mode':
2590                                 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2591                                 echo Entity::hsc($incMode);
2592                                 break;
2593                         default:
2594                                 break;
2595                 }
2596                 return;
2597         }
2598         
2599         /**
2600          * Actions::parse_editadmintemplateinfo()
2601          * Parse skinvar editadmintemplateinfo
2602          * 
2603          * @param       string  $type                   type of skin template
2604          * @param       string  $description    description of template
2605          * @param       string  $name                   name of stemplate
2606          * @param       string  $tabindex               index number for tabindex attribute of input element
2607          * @param       string  $big                    
2608          * @param       string  $tplt                   
2609          */
2610         public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2611         {
2612                 global $manager;
2613                 $templateid                             =  intRequestVar('templateid');
2614                 $templatename                   =  Template::getNameFromId($templateid);
2615                 $templatedescription    =  Template::getDesc($templateid);
2616                 $template                               =& Template::read($templatename);
2617                 switch ( $type )
2618                 {
2619                         case 'id':
2620                                 echo intval($templateid);
2621                                 break;
2622                         case 'name':
2623                                 echo Entity::hsc($templatename);
2624                                 break;
2625                         case 'desc':
2626                                 echo Entity::hsc($templatedescription);
2627                                 break;
2628                         case 'extratemplate':
2629                                 $tabidx    = 600;
2630                                 $pluginfields = array();
2631                                 $manager->notify(
2632                                         'AdminTemplateExtraFields',
2633                                         array(
2634                                                 'fields' => &$pluginfields
2635                                         )
2636                                 );
2637                                 $tmplt = array();
2638                                 if ( $description )
2639                                 {
2640                                         $tmplt = Template::read($description);
2641                                 }
2642                                 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2643                                 {
2644                                         $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2645                                 }
2646                                 else
2647                                 {
2648                                         $base = "</tr>\n"
2649                                               . "<tr>\n"
2650                                               . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2651                                 }
2652                                 foreach ( $pluginfields as $pfkey => $pfvalue )
2653                                 {
2654                                         $data = array(
2655                                                 'explugtplname' => Entity::hsc($pfkey)
2656                                         );
2657                                         echo TEMPLATE::fill($base, $data);
2658                                         foreach ( $pfvalue as $pffield => $pfdesc )
2659                                         {
2660                                                 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2661                                         }
2662                                 }
2663                                 break;
2664                         default:
2665                                 $desc = defined($description) ? constant($description) : $description;
2666                                 $name = defined($name) ? constant($name) : $name;
2667                                 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2668                                 break;
2669                 }
2670                 return;
2671         }
2672         
2673         /**
2674          * Actions::parse_editcomment()
2675          * Parse skinvar editcomment
2676          * 
2677          * @param       string  $type   type of comment setting
2678          * @return      void
2679          */
2680         public function parse_editcomment($type = 'id')
2681         {
2682                 global $manager;
2683                 $commentid      = intRequestVar('commentid');
2684                 $comment        = COMMENT::getComment($commentid);
2685                 
2686                 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2687                 
2688                 switch ( $type )
2689                 {
2690                         case 'id':
2691                                 echo intRequestVar('commentid');
2692                                 break;
2693                         case 'user':
2694                                 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2695                                 {
2696                                         echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2697                                 }
2698                                 else
2699                                 {
2700                                         echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2701                                 }
2702                                 break;
2703                         case 'date':
2704                                 echo date("Y-m-d @ H:i", $comment['timestamp']);
2705                                 break;
2706                         case 'body':
2707                                 $comment['body'] = str_replace('<br />', '', $comment['body']);
2708                                 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2709                                 echo $comment['body'];
2710                         default:
2711                                 echo $comment[$type];
2712                                 break;
2713                 }
2714                 return;
2715         }
2716         
2717         /**
2718          * Actions::parse_editdesturl()
2719          * Parse skinvar editdesturl
2720          */
2721         public function parse_editdesturl()
2722         {
2723                 if ( requestVar('desturl') )
2724                 {
2725                         echo Entity::hsc(requestVar('desturl'));
2726                 }
2727                 return;
2728         }
2729         
2730         /**
2731          * Actions::parse_editmemberlist()
2732          * Parse skinvar editmemberlist
2733          * 
2734          * @param       string  $templateName   name of template
2735          * @return      void
2736          */
2737         public function parse_editmemberlist($templateName = '')
2738         {
2739                 global $manager;
2740                 // show list of members with actions
2741                 $query =  'SELECT * FROM '.sql_table('member');
2742                 $template['content']  = 'memberlist';
2743                 $template['tabindex'] = 10;
2744                 
2745                 $batch = new Batch('member');
2746                 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2747                 return;
2748         }
2749         
2750         /**
2751          * AdminActions::parse_editmember()
2752          * Parse skinvar editmember
2753          * 
2754          * @param       string  $type                   type of information for member
2755          * @return      string  $tempateName    name of template to use
2756          * @return      void
2757          */
2758         public function parse_editmember($type = 'id', $templateName = '')
2759         {
2760                 global $CONF, $manager, $member;
2761                 $memberid       = intRequestVar('memberid');
2762                 $mem            = MEMBER::createFromID($memberid);
2763                 
2764                 switch ( $type )
2765                 {
2766                         case 'id':
2767                                 echo intRequestVar('memberid');
2768                                 break;
2769                         case 'displayname':
2770                                 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2771                                 {
2772                                         echo Entity::hsc($mem->getDisplayName());
2773                                 }
2774                                 else
2775                                 {
2776                                         $dispName = Entity::hsc($mem->getDisplayName());
2777                                         if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2778                                         {
2779                                                 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2780                                         }
2781                                         else
2782                                         {
2783                                                 echo $dispName;
2784                                         }
2785                                 }
2786                                 break;
2787                         case 'realname':
2788                                 echo Entity::hsc($mem->getRealName());
2789                                 break;
2790                         case 'email':
2791                                 echo Entity::hsc($mem->getEmail());
2792                                 break;
2793                         case 'url':
2794                                 echo Entity::hsc($mem->getURL());
2795                                 break;
2796                         case 'admin':
2797                                 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2798                                 break;
2799                         case 'canlogin':
2800                                 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2801                                 break;
2802                         case 'notes':
2803                                 echo Entity::hsc($mem->getNotes());
2804                                 break;
2805                         case 'autosave':
2806                                 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2807                                 break;
2808                         default:
2809                                 break;
2810                 }
2811                 return;
2812         }
2813         
2814         /**
2815          * Actions::parse_editpluginfo()
2816          * Parse skinvar editpluginfo
2817          * 
2818          * @param       string  $type   type of plugin info
2819          * @return      void
2820          */
2821         public function parse_editpluginfo($type)
2822         {
2823                 $pid = intRequestVar('plugid');
2824                 switch ( $type )
2825                 {
2826                         case 'id':
2827                                 echo $pid;
2828                                 break;
2829                         case 'name':
2830                                 echo Entity::hsc(getPluginNameFromPid($pid));
2831                                 break;
2832                 }
2833                 return;
2834         }
2835         
2836         /**
2837          * Actions::parse_editplugoptionslist()
2838          * Parse skinvar editplugoptionslist
2839          * 
2840          * @param       string  $templateName   name of template
2841          * @return      void
2842          */
2843         public function parse_editplugoptionslist($templateName = '')
2844         {
2845                 global $manager;
2846                 
2847                 $pid = intRequestVar('plugid');
2848                 $aOptions = array();
2849                 $aOIDs  = array();
2850                 
2851                 $query  = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2852                 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2853                 $resource = sql_query($query);
2854                 
2855                 while ( $o = sql_fetch_object($resource) )
2856                 {
2857                         array_push($aOIDs, $o->oid);
2858                         $aOptions[$o->oid] = array(
2859                                 
2860                                 'oid'                   => $o->oid,
2861                                 'value'                 => $o->odef,
2862                                 'name'                  => $o->oname,
2863                                 'description'   => $o->odesc,
2864                                 'type'                  => $o->otype,
2865                                 'typeinfo'              => $o->oextra,
2866                                 'contextid'             => 0
2867                         );
2868                 }
2869                 
2870                 // fill out actual values
2871                 if ( count($aOIDs) > 0 )
2872                 {
2873                         $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2874                         $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2875                         
2876                         $result = sql_query($query);
2877                         
2878                         while ( $o = sql_fetch_object($result) )
2879                         {
2880                                 $aOptions[$o->oid]['value'] = $o->ovalue;
2881                         }
2882                 }
2883                 
2884                 // call plugins
2885                 $manager->notify(
2886                         'PrePluginOptionsEdit',
2887                         array(
2888                                 'context'       =>  'global',
2889                                 'plugid'        =>  $pid,
2890                                 'options'       => &$aOptions
2891                         )
2892                 );
2893                 
2894                 $template['content'] = 'plugoptionlist';
2895                 $amount                   = Showlist($aOptions, 'table', $template, $templateName);
2896                 if ( $amount == 0 )
2897                 {
2898                         echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2899                 }
2900                 return;
2901         }
2902         
2903         /**
2904          * Actions::parse_editskin()
2905          * Parse skinvar editskin
2906          * 
2907          * @param       string  $type   type of skin
2908          * @return      void
2909          */
2910         public function parse_editskin($type = 'id')
2911         {
2912                 $skinid = intRequestVar('skinid');
2913                 $skin   = new SKIN($skinid);
2914                 switch ( $type )
2915                 {
2916                         case 'id':
2917                                 echo intRequestVar('skinid');
2918                                 break;
2919                         case 'name':
2920                                 echo Entity::hsc($skin->getName());
2921                                 break;
2922                         case 'desc':
2923                                 echo Entity::hsc($skin->getDescription());
2924                                 break;
2925                         case 'type':
2926                                 echo Entity::hsc($skin->getContentType());
2927                                 break;
2928                         case 'prefix':
2929                                 echo Entity::hsc($skin->getIncludePrefix());
2930                                 break;
2931                         case 'mode':
2932                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2933                         default:
2934                                 break;
2935                 }
2936                 return;
2937         }
2938         
2939         /**
2940          * Actions::parse_editskintype()
2941          * Parse skinvar editskintype
2942          * 
2943          * @param       string  $type   name of type for skin type
2944          * @return      void
2945          */
2946         public function parse_editskintype($type = 'id')
2947         {
2948                 global $CONF, $manager, $member;
2949                 $skinid = intRequestVar('skinid');
2950                 $skin   = new SKIN($skinid);
2951                 $fNames = SKIN::getFriendlyNames();
2952                 $sType  = strtolower(trim(requestVar('type')));
2953                 
2954                 switch ( $type )
2955                 {
2956                         case 'id':
2957                                 echo intRequestVar('skinid');
2958                                 break;
2959                         case 'name':
2960                                 echo Entity::hsc($skin->getName());
2961                                 break;
2962                         case 'desc':
2963                                 echo Entity::hsc($skin->getDescription());
2964                                 break;
2965                         case 'type':
2966                                 echo Entity::hsc($skin->getContentType());
2967                                 break;
2968                         case 'content':
2969                                 echo Entity::hsc($skin->getContent($sType));
2970                                 break;
2971                         case 'skintype':
2972                                 $skinType = isset($fNames[$sType]) ? $fNames[$sType] : ucfirst($sType);
2973                                 echo Entity::hsc($skinType);
2974                                 break;
2975                         case 'skintyperaw':
2976                                 echo Entity::hsc($sType);
2977                                 break;
2978                         case 'prefix':
2979                                 echo Entity::hsc($skin->getIncludePrefix());
2980                                 break;
2981                         case 'mode':
2982                                 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2983                                 echo Entity::hsc($incMode);
2984                                 break;
2985                         default:
2986                                 break;
2987                 }
2988                 return;
2989         }
2990         
2991         /**
2992          * Actions::parse_edittemplateinfo()
2993          * Parse skinvar edittemplateinfo
2994          * 
2995          * @param       string  $type                   name of type for skin
2996          * @param       string  $description    description for skin
2997          * @param       string  $name                   name of skin
2998          * @param       string  $help                   
2999          * @param       string  $tabindex               index value for tabindex attribute of input element
3000          * @param       string  $big                    
3001          * @param       string  $tplt                   name of template
3002          */
3003         public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3004         {
3005                 global $manager;
3006                 $templateid                             =  intRequestVar('templateid');
3007                 $templatename                   =  TEMPLATE::getNameFromId($templateid);
3008                 $templatedescription    =  TEMPLATE::getDesc($templateid);
3009                 $template                               =& $manager->getTemplate($templatename);
3010                 switch ( $type )
3011                 {
3012                         case 'id':
3013                                 echo intval($templateid);
3014                                 break;
3015                         case 'name':
3016                                 echo Entity::hsc($templatename);
3017                                 break;
3018                         case 'desc':
3019                                 echo Entity::hsc($templatedescription);
3020                                 break;
3021                         case 'extratemplate':
3022                                 $tabidx    = 600;
3023                                 $pluginfields = array();
3024                                 $manager->notify(
3025                                         'TemplateExtraFields',
3026                                         array(
3027                                                 'fields' => &$pluginfields
3028                                         )
3029                                 );
3030                                 $tmplt = array();
3031                                 if ( $description )
3032                                 {
3033                                         $tmplt = Template::read($description);
3034                                 }
3035                                 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3036                                 {
3037                                         $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3038                                 }
3039                                 else
3040                                 {
3041                                         $base = "</tr><tr>\n"
3042                                                   . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3043                                 }
3044                                 foreach ( $pluginfields as $pfkey => $pfvalue )
3045                                 {
3046                                         $data = array(
3047                                                 'explugtplname' => Entity::hsc($pfkey)
3048                                         );
3049                                         echo TEMPLATE::fill($base, $data);
3050                                         foreach ( $pfvalue as $pffield => $pfdesc )
3051                                         {
3052                                                 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3053                                         }
3054                                 }
3055                                 break;
3056                         default:
3057                                 $desc = defined($description) ? constant($description) : $description;
3058                                 $name = defined($name) ? constant($name) : $name;
3059                                 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3060                                 break;
3061                 }
3062                 return;
3063         }
3064         
3065         /**
3066          * Actions::parse_eventformextra()
3067          * Parse skinvar eventformextra
3068          * 
3069          * @param       string  $type   name of type for event form extra
3070          * @return      void
3071          */
3072         public function parse_eventformextra($type = 'activation')
3073         {
3074                 global $manager;
3075                 switch ( $type )
3076                 {
3077                         case 'activation':
3078                                 $key = requestVar('ackey');
3079                                 if ( !$key )
3080                                 {
3081                                         $this->objAdmin->error(_ERROR_ACTIVATE);
3082                                 }
3083                                 $info = MEMBER::getActivationInfo($key);
3084                                 if ( !$info )
3085                                 {
3086                                         $this->objAdmin->error(_ERROR_ACTIVATE);
3087                                 }
3088                                 $mem  = MEMBER::createFromId($info->vmember);
3089                                 if ( !$mem )
3090                                 {
3091                                         $this->objAdmin->error(_ERROR_ACTIVATE);
3092                                 }
3093                                 $data = array(
3094                                         'type'   => 'activation',
3095                                         'member' => $mem
3096                                 );
3097                                 break;
3098                         case 'membermailform-notloggedin':
3099                                 $data = array(
3100                                         'type' => 'membermailform-notloggedin',
3101                                 );
3102                                 break;
3103                 }
3104                 $manager->notify('FormExtra', $data);
3105                 return;
3106         }
3107         
3108         /**
3109          * Actions::parse_extrahead()
3110          * Parse skinvar extrahead
3111          */
3112         public function parse_extrahead()
3113         {
3114                 global $manager;
3115                 $extrahead = $this->objAdmin->extrahead;
3116                 $manager->notify(
3117                         'AdminPrePageHead',
3118                         array(
3119                                 'extrahead'     => &$extrahead,
3120                                 'action'        => $this->objAdmin->action
3121                         )
3122                 );
3123                 echo $extrahead;
3124                 return;
3125         }
3126         
3127         /**
3128          * AdminActions::parse_getblogsetting()
3129          * Parse skinvar getblogsetting
3130          */
3131         public function parse_getblogsetting($which)
3132         {
3133                 global $blog;
3134                 
3135                 if ( $blog )
3136                 {
3137                         $b =& $blog;
3138                 }
3139                 elseif ( $bid = intRequestVar('blogid') )
3140                 {
3141                         global $manager;
3142                         $b = $manager->getBlog($bid);
3143                 }
3144                 else
3145                 {
3146                         return;
3147                 }
3148                 
3149                 switch ( $which )
3150                 {
3151                         case 'id':
3152                                 return Entity::hsc($b->getID());
3153                                 break;
3154                         case 'url':
3155                                 return Entity::hsc($b->getURL());
3156                                 break;
3157                         case 'name':
3158                                 return Entity::hsc($b->getName());
3159                                 break;
3160                         case 'desc':
3161                                 return Entity::hsc($b->getDescription());
3162                                 break;
3163                         case 'short':
3164                                 return Entity::hsc($b->getShortName());
3165                                 break;
3166                         case 'notifyaddress':
3167                                 return Entity::hsc($b->getNotifyAddress());
3168                                 break;
3169                         case 'maxcomments':
3170                                 return Entity::hsc($b->getMaxComments());
3171                                 break;
3172                         case 'updatefile':
3173                                 return Entity::hsc($b->getUpdateFile());
3174                                 break;
3175                         case 'timeoffset':
3176                                 return Entity::hsc($b->getTimeOffset());
3177                                 break;
3178                 }
3179                 return;
3180         }
3181         
3182         /**
3183          * Actions::parse_geteditpluginfo()
3184          * Parse skinvar geteditpluginfo
3185          * 
3186          * @param       string  $type   name of setting for edit plugin info
3187          * @return      void
3188          */
3189         public function parse_geteditpluginfo($type)
3190         {
3191                 $pid = intRequestVar('plugid');
3192                 switch ( $type )
3193                 {
3194                         case 'id':
3195                                 return $pid;
3196                                 break;
3197                         case 'name':
3198                                 return Entity::hsc(getPluginNameFromPid($pid));
3199                                 break;
3200                 }
3201                 return;
3202         }
3203         
3204         /**
3205          * Actions::parse_getmember()
3206          * Parse skinvar getmember
3207          * (includes a member info thingie)
3208          * 
3209          * @param       string  $what   name of setting for member
3210          * @return      void
3211          */
3212         public function parse_getmember($what)
3213         {
3214                 global $memberinfo, $member;
3215                 // 1. only allow the member-details-page specific variables on member pages
3216                 if ( $this->skintype == 'member' )
3217                 {
3218                         switch ( $what )
3219                         {
3220                                 case 'name':
3221                                         return Entity::hsc($memberinfo->getDisplayName());
3222                                         break;
3223                                 case 'realname':
3224                                         return Entity::hsc($memberinfo->getRealName());
3225                                         break;
3226                                 case 'notes':
3227                                         return Entity::hsc($memberinfo->getNotes());
3228                                         break;
3229                                 case 'url':
3230                                         return Entity::hsc($memberinfo->getURL());
3231                                         break;
3232                                 case 'email':
3233                                         return Entity::hsc($memberinfo->getEmail());
3234                                         break;
3235                                 case 'id':
3236                                         return Entity::hsc($memberinfo->getID());
3237                                         break;
3238                         }
3239                 }
3240                 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3241                 if ( $member->isLoggedIn() )
3242                 {
3243                         switch ( $what )
3244                         {
3245                                 case 'yourname':
3246                                         return $member->getDisplayName();
3247                                         break;
3248                                 case 'yourrealname':
3249                                         return $member->getRealName();
3250                                         break;
3251                                 case 'yournotes':
3252                                         return $member->getNotes();
3253                                         break;
3254                                 case 'yoururl':
3255                                         return $member->getURL();
3256                                         break;
3257                                 case 'youremail':
3258                                         return $member->getEmail();
3259                                         break;
3260                                 case 'yourid':
3261                                         return $member->getID();
3262                                         break;
3263                         }
3264                 }
3265                 return;
3266         }
3267         
3268         /**
3269          * Actions::parse_headmessage()
3270          * Parse skinvar headmessage
3271          * 
3272          * @param       void
3273          * @return      void
3274          */
3275         public function parse_headmessage()
3276         {
3277                 if ( !empty($this->objAdmin->headMess) )
3278                 {
3279                         echo '<p>' . _MESSAGE . ': ' . Entity::hsc($this->objAdmin->headMess) . "</p>\n";
3280                 }
3281                 return;
3282         }
3283         
3284         /**
3285          * Actions::parse_helplink()
3286          * Parse skinvar helplink
3287          * 
3288          * @param       string  $topic  name of topic for help
3289          * @return      void
3290          */
3291         public function parse_helplink($topic = '')
3292         {
3293                 if ( empty($topic) )
3294                 {
3295                         return;
3296                 }
3297                 help($topic);
3298                 return;
3299         }
3300         
3301         /**
3302          * Actions::parse_helpplugname()
3303          * Parse skinvar helpplugname
3304          * 
3305          * @param       void
3306          * @return      void
3307          */
3308         public function parse_helpplugname()
3309         {
3310                 $plugid = intGetVar('plugid');
3311                 Entity::hsc(getPluginNameFromPid($plugid));
3312                 return;
3313         }
3314         
3315         /**
3316          * Actions::parse_ilistaddnew()
3317          * Parse skinvar ilistaddnew
3318          * 
3319          * @param       void
3320          * @return      void
3321          */
3322         public function parse_ilistaddnew()
3323         {
3324                 $blogid = intRequestVar('blogid');
3325                 if ( intPostVar('start') == 0 )
3326                 {
3327                         echo '<p><a href="index.php?action=createitem&amp;blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3328                 }
3329                 return;
3330         }
3331         
3332         /**
3333          * Actions::parse_importskininfo()
3334          * Parse skinvar importskininfo
3335          * 
3336          * @param       string  $type   name of information for imported skin
3337          * @return      void
3338          */
3339         public function parse_importskininfo($type)
3340         {
3341                 switch ( $type )
3342                 {
3343                         case 'info':
3344                                 echo Entity::hsc(requestVar('skininfo'));
3345                                 break;
3346                         case 'snames':
3347                                 $dataArr = requestArray('skinnames');
3348                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3349                                 break;
3350                         case 'tnames':
3351                                 $dataArr = requestArray('tpltnames');
3352                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3353                                 break;
3354                         case 'sclashes':
3355                                 $dataArr = requestArray('skinclashes');
3356                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3357                                 break;
3358                         case 'tclashes':
3359                                 $dataArr = requestArray('tpltclashes');
3360                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3361                                 break;
3362                         case 'skinfile':
3363                                 echo Entity::hsc(requestVar('skinfile'));
3364                                 break;
3365                         case 'mode':
3366                                 echo Entity::hsc(requestVar('mode'));
3367                                 break;
3368                 }
3369                 return;
3370         }
3371         
3372         /**
3373          * Actions::parse_inputyesno()
3374          * Parse skinvar inputyesno
3375          * 
3376          * @param       string  $name                   
3377          * @param       string  $checkedval             
3378          * @param       string  $tabindex               
3379          * @param       string  $value1                 
3380          * @param       string  $value2                 
3381          * @param       string  $yesval                 
3382          * @param       string  $noval                  
3383          * @param       string  $isAdmin                
3384          * @param       string  $templateName   
3385          * @return      void
3386          */
3387         public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3388         {
3389                 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3390                 return;
3391         }
3392         
3393         /**
3394          * Actions::parse_insertpluginfo()
3395          * Parse templatevar insertpluginfo
3396          */
3397         public function parse_insertpluginfo($type)
3398         {
3399                 $option = $this->objAdmin;
3400                 switch ( $type )
3401                 {
3402                         case 'id':
3403                                 return $option['pid'];
3404                                 break;
3405                         case 'name':
3406                                 return Entity::hsc($option['pfile']);
3407                                 break;
3408                 }
3409                 return;
3410         }
3411         
3412         /**
3413          * Actions::parse_insertpluginoptions()
3414          * Parse skinvar insertpluginoptions
3415          * 
3416          * @param       string  $templateName   name of template
3417          * @return      void
3418          */
3419         public function parse_insertpluginoptions($templateName = '')
3420         {
3421                 $options        = $this->objAdmin->aOptions;
3422                 $template       = array();
3423                 $templats       = array();
3424                 
3425                 if ( $templateName )
3426                 {
3427                         $templates = Template::read($templateName);
3428                 }
3429                 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
3430                 {
3431                         $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3432                 }
3433                 else
3434                 {
3435                         $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
3436                 }
3437                 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
3438                 {
3439                         $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3440                 }
3441                 else
3442                 {
3443                         $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
3444                 }
3445                 
3446                 $prevPid = -1;
3447                 
3448                 foreach ( $options as $option )
3449                 {
3450                         $handler = new Actions($this->skintype, $template, $option);
3451                         $parser  = new PARSER(Actions::getDefinedActions(), $handler);
3452                         // new plugin?
3453                         if ( $prevPid != $option['pid'] )
3454                         {
3455                                 $prevPid  = $option['pid'];
3456                                 $parser->parse($template['title']);
3457                         }
3458                         $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3459                         if ( @$meta['access'] != 'hidden' )
3460                         {
3461                                 $parsed = $parser->parse($template['body']);
3462                         }
3463                 }
3464                 return;
3465         }
3466         
3467         /**
3468          * Actions::parse_insplugoptcontent()
3469          * Parse skinvar insplugoptcontent
3470          * 
3471          * @param       void
3472          * @return      void
3473          */
3474         public function parse_insplugoptcontent()
3475         {
3476                 $option = $this->objAdmin->aOption;
3477                 
3478                 $meta   = NucleusPlugin::getOptionMeta($option['typeinfo']);
3479                 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
3480                 {
3481                         echo '<tr>';
3482                         listplug_plugOptionRow($option);
3483                         echo '</tr>';
3484                 }
3485                 return;
3486         }
3487         
3488         /**
3489          * Actions::parse_iprangeinput()
3490          * Parse skinvar iprangeinput
3491          * 
3492          * @param       void
3493          * @return      void
3494          */
3495         public function parse_iprangeinput()
3496         {
3497                 if ( requestVar('ip') )
3498                 {
3499                         $iprangeVal = Entity::hsc(requestVar('ip'));
3500                         echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
3501                         echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
3502                         echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3503                         echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3504                         echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
3505                 }
3506                 else
3507                 {
3508                         echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3509                         echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3510                 }
3511                 return;
3512         }
3513         
3514         /**
3515          * Actions::parse_itemnavlist()
3516          * Parse skinvar itemnavlist
3517          * 
3518          * @param       void
3519          * @return      void
3520          */
3521         public function parse_itemnavlist()
3522         {
3523                 global $CONF, $manager, $member;
3524                 if ( $this->skintype == 'itemlist' )
3525                 {
3526                         $blogid =  intRequestVar('blogid');
3527                         $blog   =& $manager->getBlog($blogid);
3528                 }
3529                 if ( postVar('start') )
3530                 {
3531                         $start = intPostVar('start');
3532                 }
3533                 else
3534                 {
3535                         $start = 0;
3536                 }
3537                 
3538                 // amount of items to show
3539                 if ( postVar('amount') )
3540                 {
3541                         $amount = intPostVar('amount');
3542                 }
3543                 else
3544                 {
3545                         $amount = intval($CONF['DefaultListSize']);
3546                         if ( $amount < 1 )
3547                         {
3548                                 $amount = 10;
3549                         }
3550                 }
3551                 $query  = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3552                         . " FROM %s, %s, %s"
3553                         . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid;";
3554                 
3555                 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3556                 
3557                 if ( $this->skintype == 'itemlist' )
3558                 {
3559                         $query .= 'and iblog   = ' . $blogid;
3560                         $template['now'] = $blog->getCorrectTime(time());
3561                         
3562                         // non-blog-admins can only edit/delete their own items
3563                         if ( !$member->blogAdminRights($blogid) )
3564                         {
3565                                 $query .= ' and iauthor = ' . $member->getID();
3566                         }
3567                 }
3568                 elseif ( $this->skintype == 'browseownitems' )
3569                 {
3570                         $query .= 'and iauthor   = ' . $member->getID();
3571                         $blogid = 0;
3572                         $template['now'] = time();
3573                 }
3574                 
3575                 // search through items
3576                 $search = postVar('search');
3577                 
3578                 if ( !empty($search) )
3579                 {
3580                         $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3581                                 . '  OR  (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3582                                 . '  OR  (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3583                 }
3584                 $query .= ' ORDER BY itime DESC'
3585                         . " LIMIT {$start},{$amount}";
3586                 
3587                 $template['content'] = 'itemlist';
3588                 
3589                 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3590                 $navList->showBatchList('item', $query, 'table', $template);
3591                 return;
3592         }
3593         
3594         /**
3595          * Actions::parse_jstoolbaroptions()
3596          * Parse skinvar jstoolbaroptions
3597          * 
3598          * @param       void
3599          * @return      void
3600          */
3601         public function parse_jstoolbaroptions()
3602         {
3603                 global $CONF;
3604                 $options = array(
3605                         _SETTINGS_JSTOOLBAR_NONE,
3606                         _SETTINGS_JSTOOLBAR_SIMPLE,
3607                         _SETTINGS_JSTOOLBAR_FULL
3608                 );
3609                 $i = 1;
3610                 foreach ( $options as $option )
3611                 {
3612                         $text  = "<option value=\"%d\"%s>%s</option>\n";
3613                         $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3614                         echo sprintf($text, $i, $extra, $option);
3615                         $i++;
3616                 }
3617                 return;
3618         }
3619         
3620         /**
3621          * Actions::parse_localeselectoptions()
3622          * Parse skinvar localeselectoptions
3623          * 
3624          * @param       void
3625          * @return      void
3626          */
3627         public function parse_localeselectoptions()
3628         {
3629                 $locales = i18n::get_available_locale_list();
3630                 $memid   = intRequestVar('memberid');
3631                 if ( $memid )
3632                 {
3633                         $mem = MEMBER::createFromID($memid);
3634                         if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3635                         {
3636                                 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3637                         }
3638                         else
3639                         {
3640                                 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3641                         }
3642                 }
3643                 else
3644                 {
3645                         if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3646                         {
3647                                 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3648                         }
3649                 }
3650                 foreach ( $locales as $locale )
3651                 {
3652                         if ($memid)
3653                         {
3654                                 if ( $locale == $mem->getLocale() )
3655                                 {
3656                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3657                                 }
3658                                 else
3659                                 {
3660                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
3661                                 }
3662                         }
3663                         else
3664                         {
3665                                 if ( $locale == i18n::get_current_locale() )
3666                                 {
3667                                         echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3668                                 }
3669                                 else
3670                                 {
3671                                         echo "<option value=\"{$locale}\">{$locale}</option>\n";
3672                                 }
3673                         }
3674                 }
3675                 return;
3676         }
3677         
3678         /**
3679          * Actions::parse_listplugplugoptionrow()
3680          * Parse templatevar listplugplugoptionrow
3681          * 
3682          * @param       string  $templateName   name of template
3683          * @return      void
3684          */
3685         public function parse_listplugplugoptionrow($templateName = '')
3686         {
3687                 $option = $this->objAdmin;
3688                 echo listplug_plugOptionRow($option, $templateName);
3689                 return;
3690         }
3691         
3692         /**
3693          * Actions::parse_mediadirwarning()
3694          * Parse skinvar mediadirwarning
3695          * 
3696          * @param       void
3697          * @return      void
3698          */
3699         public function parse_mediadirwarning()
3700         {
3701                 global $DIR_MEDIA;
3702                 if ( !is_dir($DIR_MEDIA) )
3703                 {
3704                         echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3705                 }
3706                 if ( !is_readable($DIR_MEDIA) )
3707                 {
3708                         echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3709                 }
3710                 if ( !is_writeable($DIR_MEDIA) )
3711                 {
3712                         echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3713                 }
3714                 return;
3715         }
3716         
3717         /**
3718          * Actions::parse_movedistselect()
3719          * Parse skinvar movedistselect
3720          */
3721         public function parse_movedistselect()
3722         {
3723                 $actionType = requestVar('action');
3724                 switch ( $actionType )
3725                 {
3726                         case 'batchitem':
3727                                 $this->objAdmin->selectBlogCategory('destcatid');
3728                                 break;
3729                         case 'batchcategory':
3730                                 $this->objAdmin->selectBlog('destblogid');
3731                                 break;
3732                         default:
3733                                 if ( $this->skintype == 'itemmove' )
3734                                 {
3735                                         $query  = "SELECT icat as result FROM %s WHERE inumber=%d;";
3736                                         $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
3737                                         $catid  = quickQuery(sprintf($query, intRequestVar('itemid')));
3738                                         $this->objAdmin->selectBlogCategory('catid', $catid, 10, 1);
3739                                 }
3740                                 break;
3741                 }
3742                 return;
3743         }
3744         
3745         /**
3746          * Actions::parse_moveitemid()
3747          * Parse skinvar moveitemid
3748          * 
3749          * @param       void
3750          * @return      void
3751          */
3752         public function parse_moveitemid()
3753         {
3754                 echo intRequestVar('itemid');
3755                 return;
3756         }
3757         
3758         /**
3759          * Actions::parse_newestcompare()
3760          * Parse skinvar newestcompare
3761          * 
3762          * @param       void
3763          * @return      void
3764          */
3765         public function parse_newestcompare()
3766         {
3767                 global $nucleus;
3768                 $newestVersion  = getLatestVersion();
3769                 $newestCompare  = str_replace('/', '.', $newestVersion);
3770                 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3771                 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3772                 {
3773                         echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3774                         echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3775                 }
3776                 return;
3777         }
3778         
3779         /**
3780          * Actions::parse_newmemberselect()
3781          * Parse skinvar newmemberselect
3782          * 
3783          * @param       string  $templateName   name of template to use
3784          * @return      void
3785          */
3786         public function parse_newmemberselect($templateName = '')
3787         {
3788                 $blogid = intRequestVar('blogid');
3789                 
3790                 $query  = "SELECT tmember FROM %s WHERE tblog=%d;";
3791                 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3792                 $res = sql_query($query);
3793                 
3794                 $tmem = array();
3795                 while ( $tmember = sql_fetch_object($res) ) 
3796                 {
3797                         $tmem[] = intval($tmember->tmember);
3798                 }
3799                 
3800                 $query  = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3801                 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3802                 
3803                 $template['name']        = 'memberid';
3804                 $template['tabindex'] = 10000;
3805                 Showlist($query, 'select', $template, $templateName);
3806                 return;
3807         }
3808         
3809         /**
3810          * Actions::parse_newpluginlist()
3811          * Parse skinvar newpluginlist
3812          * 
3813          * @param       void
3814          * @return      void
3815          */
3816         public function parse_newpluginlist()
3817         {
3818                 $candidates = $this->newPlugCandidates;
3819                 foreach ( $candidates as $name )
3820                 {
3821                         echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3822                 }
3823                 return;
3824         }
3825         
3826         /**
3827          * Actions::parse_outputspecialdirs()
3828          * Parse skinvar outputspecialdirs
3829          * 
3830          * @param       string  $type   type of setting for directory
3831          * @return      void
3832          */
3833         public function parse_outputspecialdirs($type)
3834         {
3835                 switch ( $type )
3836                 {
3837                         case 'nucleusdir':
3838                                 global $DIR_NUCLEUS;
3839                                 echo Entity::hsc($DIR_NUCLEUS);
3840                                 break;
3841                         case 'mediadir':
3842                                 global $DIR_MEDIA;
3843                                 echo Entity::hsc($DIR_MEDIA);
3844                                 break;
3845                 }
3846                 return;
3847         }
3848         
3849         /**
3850          * Actions::parse_passrequestvars()
3851          * Parse skinvar passrequestvars
3852          * 
3853          * @param       void
3854          * @return      void
3855          */
3856         public function parse_passrequestvars()
3857         {
3858                 $oldaction = postVar('oldaction');
3859                 if ( ($oldaction != 'logout')
3860                   && ($oldaction != 'login')
3861                   && $this->objAdmin->passvar
3862                   && !postVar('customaction') )
3863                 {
3864                         passRequestVars();
3865                 }
3866                 return;
3867         }
3868         
3869         /**
3870          * Actions::parse_pluginextras()
3871          * Parse skinvar pluginextras
3872          * 
3873          * @param       string  $type   type of plugin context
3874          * @return      void
3875          */
3876         public function parse_pluginextras($type = 'global')
3877         {
3878                 global $manager;
3879                 switch ( $type )
3880                 {
3881                         case 'member':
3882                                 $id  = intRequestVar('memberid');
3883                                 $mem = MEMBER::createFromID($id);
3884                                 $manager->notify(
3885                                         'MemberSettingsFormExtras',
3886                                         array(
3887                                                 'member' => &$mem
3888                                         )
3889                                 );
3890                                 break;
3891                         case 'blog':
3892                                 $id  = intRequestVar('blogid');
3893                                 $blg = $manager->getBlog($id);
3894                                 $manager->notify(
3895                                         'BlogSettingsFormExtras',
3896                                         array(
3897                                                 'member' => &$blg
3898                                         )
3899                                 );
3900                                 break;
3901                         default:
3902                                 $manager->notify(
3903                                         'GeneralSettingsFormExtras',
3904                                         array(
3905                                         )
3906                                 );
3907                                 break;
3908                 }
3909                 return;
3910         }
3911         
3912         /**
3913          * Actions::parse_pluginhelp()
3914          * Parse skinvar pluginhelp
3915          * 
3916          * @param       void
3917          * @return      void
3918          */
3919         public function parse_pluginhelp()
3920         {
3921                 global $manager, $DIR_PLUGINS;
3922                 $plugid = intGetVar('plugid');
3923                 $plugName =  getPluginNameFromPid($plugid);
3924                 $plug =& $manager->getPlugin($plugName);
3925                 
3926                 if ( $plug->supportsFeature('HelpPage') > 0 )
3927                 {
3928                         $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3929                         if ( @file_exists($helpfile . 'php') )
3930                         {
3931                                 @include($helpfile . 'php');
3932                                 return;
3933                         }
3934                         elseif ( @file_exists($helpfile . 'html') )
3935                         {
3936                                 @include($helpfile . 'html');
3937                                 return;
3938                         }
3939                 }
3940                 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3941                 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3942                 return;
3943         }
3944         
3945         /**
3946          * Actions::parse_pluginlistlist()
3947          * Parse skinvar pluginlistlist
3948          * 
3949          * @param       string  $templateName   name of template to use
3950          * @return      void
3951          */
3952         public function parse_pluginlistlist($templateName = '')
3953         {
3954                 $query  = "SELECT * FROM %s ORDER BY porder ASC;";
3955                 $query = sprintf($query, sql_table('plugin'));
3956                 $template['content']  = 'pluginlist';
3957                 $template['tabindex'] = 10;
3958                 Showlist($query, 'table', $template, $templateName);
3959                 return;
3960         }
3961         
3962         /**
3963          * Actions::parse_pluginoptions()
3964          * Parse skinvar pluginoptions
3965          * 
3966          * @param       string  $type   type of plugin option
3967          * @return      void
3968          */
3969         public function parse_pluginoptions($type = 'global')
3970         {
3971                 switch ( $type )
3972                 {
3973                         case 'member':
3974                                 $id = intRequestVar('memberid');
3975                                 break;
3976                         case 'blog':
3977                                 $id = intRequestVar('blogid');
3978                                 break;
3979                         case 'category':
3980                                 $id = intRequestVar('catid');
3981                                 break;
3982                 }
3983                 $this->objAdmin->_insertPluginOptions($type, $id);
3984                 return;
3985         }
3986         
3987         /**
3988          * Actions::parse_qmenuaddselect()
3989          * Parse skinvar qmanuaddselect
3990          * 
3991          * @param       string  $templateName   name of template to use
3992          * @return      void
3993          */
3994         public function parse_qmenuaddselect($templateName = '')
3995         {
3996                 global $member;
3997                 $showAll = requestVar('showall');
3998                 if ( $member->isAdmin() && ($showAll == 'yes') )
3999                 {
4000                         // Super-Admins have access to all blogs! (no add item support though)
4001                         $query =  'SELECT bnumber as value, bname as text'
4002                                . ' FROM ' . sql_table('blog')
4003                                . ' ORDER BY bname';
4004                 }
4005                 else
4006                 {
4007                         $query =  'SELECT bnumber as value, bname as text'
4008                                . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4009                                . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4010                                . ' ORDER BY bname';
4011                 }
4012                 $template['name']          = 'blogid';
4013                 $template['tabindex']   = 15000;
4014                 $template['extra']        = _QMENU_ADD_SELECT;
4015                 $template['selected']   = -1;
4016                 $template['shorten']    = 10;
4017                 $template['shortenel']  = '';
4018                 $template['javascript'] = 'onchange="return form.submit()"';
4019                 Showlist($query, 'select', $template, $templateName);
4020                 return;
4021         }
4022
4023         /**
4024          * Actions::parse_quickmenu()
4025          * Parse skinvar quickmenu
4026          * 
4027          * @param       string  $templateName   name of template to use
4028          * @return      void
4029          */
4030         public function parse_quickmenu($templateName = '')
4031         {
4032                 global $manager;
4033                 $templates = array();
4034                 $template  = array();
4035                 if ( !empty($templateName) )
4036                 {
4037                         $templates = Template::read($templateName);
4038                 }
4039                 $pluginExtras = array();
4040                 $manager->notify(
4041                         'QuickMenu',
4042                         array(
4043                                 'options' => &$pluginExtras
4044                         )
4045                 );
4046                 if ( count($pluginExtras) > 0 )
4047                 {
4048                         if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4049                         {
4050                                 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4051                         }
4052                         else
4053                         {
4054                                 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
4055                         }
4056                         $handler = new Actions($this->skintype, $template, $this->objAdmin);
4057                         $parser  = new PARSER(Actions::getDefinedActions(), $handler);
4058                         $parser->parse($template['title']);
4059                         
4060                         if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4061                         {
4062                                 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4063                         }
4064                         else
4065                         {
4066                                 $template['head'] = '<ul>';
4067                         }
4068                         
4069                         echo $template['head'];
4070                         
4071                         if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
4072                         {
4073                                 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4074                         }
4075                         else
4076                         {
4077                                 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
4078                         }
4079                         
4080                         foreach ( $pluginExtras as $aInfo )
4081                         {
4082                                 $data = array(
4083                                         'plugadminurl'          => Entity::hsc($aInfo['url']),
4084                                         'plugadmintooltip'      => Entity::hsc($aInfo['tooltip']),
4085                                         'plugadmintitle'        => Entity::hsc($aInfo['title']),
4086                                 );
4087                                 echo TEMPLATE::fill($template['body'], $data);
4088                         }
4089                         if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4090                         {
4091                                 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4092                         }
4093                         else
4094                         {
4095                                 $template['foot'] = '</ul>';
4096                         }
4097                         echo $template['foot'];
4098                 }
4099                 return;
4100         }
4101         
4102         /**
4103          * Actions::parse_requestblogid()
4104          * Parse skinvar requestblogid
4105          * 
4106          * @param       void
4107          * @return      void
4108          */
4109         public function parse_requestblogid()
4110         {
4111                 echo intRequestVar('blogid');
4112                 return;
4113         }
4114         
4115         /**
4116          * Actions::parse_requestiprange()
4117          * Parse skinvar requestiprange
4118          * 
4119          * @param       void
4120          * @return      void
4121          */
4122         public function parse_requestiprange()
4123         {
4124                 if ( requestVar('iprange') )
4125                 {
4126                         echo Entity::hsc(requestVar('iprange'));
4127                 }
4128                 elseif ( requestVar('ip') )
4129                 {
4130                         echo Entity::hsc(requestVar('ip'));
4131                 }
4132                 return;
4133         }
4134         
4135         /**
4136          * Actions::parse_selectlocaladminskinfiles()
4137          * Parse skinvar selectlocaladminskinfiles
4138          * 
4139          * @param       void
4140          * @return      void
4141          */
4142         public function parse_selectlocaladminskinfiles()
4143         {
4144                 global $DIR_ADMINSKINS, $manager;
4145                 $candidates = SkinImport::searchForCandidates($DIR_ADMINSKINS);
4146                 foreach ( $candidates as $skinname => $skinfile )
4147                 {
4148                         $html = Entit::hsc($skinfile);
4149                         echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4150                 }
4151                 return;
4152         }
4153         
4154         /**
4155          * Actions::parse_selectlocalskinfiles()
4156          * Parse skinvar selectlocalskinfiles
4157          * 
4158          * @param       void
4159          * @return      void
4160          */
4161         public function parse_selectlocalskinfiles()
4162         {
4163                 global $DIR_SKINS;
4164                 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4165                 foreach ( $candidates as $skinname => $skinfile )
4166                 {
4167                         $html = Entity::hsc($skinfile);
4168                         echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4169                 }
4170                 return;
4171         }
4172         
4173         /**
4174          * Actions::parse_skineditallowedlist()
4175          * Parse skinvar skineditallowedlist
4176          * 
4177          * @param       string  $type                   type of skin
4178          * @param       string  $templateName   name of template
4179          * @return      void
4180          */
4181         public function parse_skineditallowedlist($type, $templateName = '')
4182         {
4183                 switch ( $type )
4184                 {
4185                         case 'blog':
4186                                 $query = "SELECT bshortname, bname FROM %s";
4187                                 $show  = array(
4188                                         'content' => 'shortblognames'
4189                                 );
4190                                 $query = sprintf($query, sql_table('blog'));
4191                                 Showlist($query, 'table', $show, $templateName);
4192                                 break;
4193                         case 'template':
4194                                 $query = "SELECT tdname as name, tddesc as description FROM %s";
4195                                 $show  = array(
4196                                         'content' => 'shortnames'
4197                                 );
4198                                 $query = sprintf($query, sql_table('template_desc'));
4199                                 Showlist($query, 'table', $show, $templateName);
4200                                 break;
4201                 }
4202                 return;
4203         }
4204         
4205         /**
4206          * Actions::parse_skinfile()
4207          * Inserts an url relative to the skindir (useful when doing import/export)
4208          *
4209          * e.g. <skinfile(default/myfile.sth)>
4210          * 
4211          * @param       string  $filename       file name for skin
4212          * @return      void
4213          */
4214         public function parse_skinfile($filename)
4215         {
4216                 /*
4217                  * TODO: we should decide to use different directory or default $DIR_SKINS
4218                 $base = NP_SkinableAdmin::getAdminSkinURL();
4219                 $pref = PARSER::getProperty('IncludePrefix');
4220                 echo $base . $pref . $filename;
4221                  */
4222                 $pref = PARSER::getProperty('IncludePrefix');
4223                 echo $pref . $filename;
4224                 return;
4225         }
4226         
4227         /**
4228          * Actions::parse_skinielist()
4229          * Parse skinvar skinielist
4230          * 
4231          * @param       string  $type                   type of skin
4232          * @param       string  $templateName   name of template to use
4233          * @return      void
4234          */
4235         public function parse_skinielist($type, $templateName = '')
4236         {
4237                 $templates = array();
4238                 if ( $templateName )
4239                 {
4240                         $templates = Template::read($templateName);
4241                 }
4242                 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4243                 {
4244                         $template = $templates['SKINIE_EXPORT_LIST'];
4245                 }
4246                 else
4247                 {
4248                         $template = '<td><input type="checkbox" name="<%typeid%>"  id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
4249                                           . "<td><%expdesc%></td>\n"
4250                                           . "</tr><tr>\n";
4251                 }
4252                 switch ( $type )
4253                 {
4254                         case 'skin':
4255                                 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4256                                 while ( $skinObj = sql_fetch_object($res) )
4257                                 {
4258                                         $data = array(
4259                                                 'typeid'        => 'skin[' . $skinObj->sdnumber . ']',
4260                                                 'expid'         => 'skinexp' . $skinObj->sdnumber,
4261                                                 'expname'       => Entity::hsc($skinObj->sdname),
4262                                                 'expdesc'       => Entity::hsc($skinObj->sddesc),
4263                                         );
4264                                         echo TEMPLATE::fill($template, $data);
4265                                 }
4266                                 break;
4267                         case 'template':
4268                                 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
4269                                 while ($templateObj = sql_fetch_object($res)) {
4270                                         $data = array(
4271                                                 'typeid'        => 'template[' . $templateObj->tdnumber . ']',
4272                                                 'expid'         => 'templateexp' . $templateObj->tdnumber,
4273                                                 'expname'       => Entity::hsc($templateObj->tdname),
4274                                                 'expdesc'       => Entity::hsc($templateObj->tddesc),
4275                                         );
4276                                         echo TEMPLATE::fill($template, $data);
4277                                 }
4278                                 break;
4279                 }
4280                 return;
4281         }
4282         
4283         /**
4284          * Actions::parse_skinoverview()
4285          * Parse skinvar skinoverview
4286          * 
4287          * @param       string  $templateName   name of template to use
4288          * @return      void
4289          */
4290         public function parse_skinoverview($templateName = '')
4291         {
4292                 $query  = "SELECT * FROM %s ORDER BY sdname";
4293                 $query = sprintf($query, sql_table('skin_desc'));
4294                 
4295                 $template['content']  = 'skinlist';
4296                 $template['tabindex'] = 10;
4297                 
4298                 Showlist($query, 'table', $template, $templateName);
4299                 return;
4300         }
4301         
4302         /**
4303          * Actions::parse_skintypehelp()
4304          * Check editing skintypehelp
4305          * 
4306          * @param       void
4307          * @return      void
4308          */
4309         public function parse_skintypehelp()
4310         {
4311                 $nowSkinType = strtolower(trim(requestVar('type')));
4312                 $regularType = array(
4313                         'index',
4314                         'item',
4315                         'archivelist',
4316                         'archive',
4317                         'search',
4318                         'error',
4319                         'member',
4320                         'imagepopup'
4321                 );
4322                 
4323                 if ( in_array($nowSkinType, $regularType) )
4324                 {
4325                         help('skinpart' . $nowSkinType);
4326                 }
4327                 else
4328                 {
4329                         help('skinpartspecial');
4330                 }
4331                 return;
4332         }
4333         
4334         /**
4335          * Actions::parse_specialskinlist()
4336          * Parse skinvar specialskinlist
4337          * 
4338          * @param       string  $templateName   name of template to use
4339          * @return      void
4340          */
4341         public function parse_specialskinlist($templateName = '')
4342         {
4343                 $templates = array();
4344                 if ( $templateName )
4345                 {
4346                         $templates = Template::read($templateName);
4347                 }
4348                 $nType  = array(
4349                         'index',
4350                         'item',
4351                         'error',
4352                         'search',
4353                         'archive',
4354                         'archivelist',
4355                         'imagepopup',
4356                         'member'
4357                 );
4358                 $skinid = intRequestVar('skinid');
4359                 $query  = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4360                 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4361                 
4362                 $res    = sql_query($query);
4363                 if ( $res && sql_num_rows($res) > 0 )
4364                 {
4365                         $data = array();
4366                         if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4367                         {
4368                                 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4369                         }
4370                         else
4371                         {
4372                                 $template['head'] = "<ul>\n";
4373                         }
4374                         echo TEMPLATE::fill($template['head'], $data);
4375                         if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
4376                         {
4377                                 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4378                         }
4379                         else
4380                         {
4381                                 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&amp;skinid=<%skinid%>'
4382                                                                   . '&amp;type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4383                                                                   . 'action=skinremovetype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">remove</a>)</li>';
4384                         }
4385                         $tabstart = 75;
4386                         while ( $row = sql_fetch_assoc($res) )
4387                         {
4388                                 $data = array(
4389                                         'tabindex' => $tabstart++,
4390                                         'skinid'   => $skinid,
4391                                         'skintype' => Entity::hsc(strtolower($row['stype']))
4392                                 );
4393                                 echo TEMPLATE::fill($template['body'], $data);
4394                         }
4395                         $data = array();
4396                         if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4397                         {
4398                                 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4399                         }
4400                         else
4401                         {
4402                                 $template['foot'] = "</ul>\n";
4403                         }
4404                         echo TEMPLATE::fill($template['foot'], $data);
4405                         return;
4406                 }
4407         }
4408         
4409         /**
4410          * Actions::parse_sprinttext()
4411          * Parse sprinttext
4412          * 
4413          * @param       string  $which  
4414          * @param       string  $val    
4415          * @return      void
4416          */
4417         public function parse_sprinttext($which, $val)
4418         {
4419                 if ( !defined($which) )
4420                 {
4421                         $base = $which;
4422                 }
4423                 else
4424                 {
4425                         $base = constant($which);
4426                 }
4427                 
4428                 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4429                 {
4430                         if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4431                         {
4432                                 $met = 'parse_' . $matchies[0];
4433                         }
4434                         else
4435                         {
4436                                 $arg = trim($args[0], '()');
4437                                 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4438                         }
4439                         
4440                         if ( method_exists($this, $met) )
4441                         {
4442                                 $value = call_user_func(array(&$this, $met), $arg);
4443                         }
4444                 }
4445                 
4446                 if ( !isset($value) || empty($value) )
4447                 {
4448                         $value = $val;
4449                 }
4450                 echo sprintf($base, $value);
4451                 return;
4452         }
4453         
4454         /**
4455          * Actions::parse_systemsettings()
4456          * Parse skinvar systemsettings
4457          * 
4458          * @param       string  $type                   type of settings for system
4459          * @param       string  $templateName   name of template to use 
4460          * @return      void
4461          */
4462         public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4463         {
4464                 global $member, $CONF, $nucleus;
4465                 
4466                 $member->isAdmin() or $this->objAdmin->disallow();
4467                 
4468                 $enable  = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4469                 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4470                 
4471                 switch ( $type )
4472                 {
4473                         case 'phpversion':
4474                                 echo phpversion();
4475                                 break;
4476                         case 'sqlserverinfo':
4477                                 echo sql_get_server_info();
4478                                 break;
4479                         case 'sqlclientinfo':
4480                                 echo sql_get_client_info();
4481                                 break;
4482                         case 'magicquotesgpc':
4483                                 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4484                                 break;
4485                         case 'magicquotesruntime':
4486                                 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4487                                 break;
4488                         case 'registerglobals':
4489                                 echo ini_get('register_globals') ? 'On' : 'Off';
4490                                 break;
4491                         case 'gdinfo':
4492                                 $templates = array();
4493                                 if ( $templateName )
4494                                 {
4495                                         $templates = Template::read($templateName);
4496                                 }
4497                                 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
4498                                 {
4499                                         $template = $templates['SYSTEMINFO_GDSETTINGS'];
4500                                 }
4501                                 else
4502                                 {
4503                                         $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
4504                                 }
4505                                 
4506                                 $gdinfo = gd_info();
4507                                 
4508                                 foreach ( $gdinfo as $key => $value )
4509                                 {
4510                                         if ( is_bool($value) )
4511                                         {
4512                                                 $value = $value ? $enable : $disable;
4513                                         }
4514                                         else
4515                                         {
4516                                                 $value = Entity::hsc($value);
4517                                         }
4518                                         $data = array(
4519                                                 'key'   => $key,
4520                                                 'value' => $value,
4521                                         );
4522                                         echo TEMPLATE::fill($template, $data);
4523                                 }
4524                                 break;
4525                         case 'modrewrite':
4526                                 ob_start();
4527                                 phpinfo(INFO_MODULES);
4528                                 $im = ob_get_contents();
4529                                 ob_end_clean();
4530                                 echo (strstr($im, 'mod_rewrite') != '') ? $enable : $disable;
4531                                 break;
4532                         case 'nucleusversion':
4533                                 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4534                                 break;
4535                         case 'nucleuspatchlevel':
4536                                 echo getNucleusPatchLevel();
4537                                 break;
4538                         case 'confself':
4539                                 echo $CONF['Self'];
4540                                 break;
4541                         case 'confitemurl':
4542                                 echo $CONF['ItemURL'];
4543                                 break;
4544                         case 'alertonheaderssent':
4545                                 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4546                                 break;
4547                         case 'nucleuscodename':
4548                                 if ( $nucleus['codename'] != '' )
4549                                 {
4550                                         echo ' &quot;' . $nucleus['codename'] . '&quot;';
4551                                 }
4552                                 break;
4553                         case 'versioncheckurl':
4554                                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4555                                 break;
4556                 }
4557                 return;
4558         }
4559         
4560         /**
4561          * Actions::parse_templateoverview()
4562          * Parse skinvar templateoverview
4563          * 
4564          * @param       string  $templateName   name of template to use
4565          * @return      void
4566          */
4567         public function parse_templateoverview($templateName = '')
4568         {
4569                 $query  = "SELECT * FROM %s ORDER BY tdname";
4570                 $query = sprintf($query, sql_table('template_desc'));
4571                 $template['content']  = 'templatelist';
4572                 $template['tabindex'] = 10;
4573                 Showlist($query, 'table', $template, $templateName);
4574                 return;
4575         }
4576         
4577         /**
4578          * AdminActions::parse_ticket()
4579          * Parse ticket
4580          * 
4581          * @param       void
4582          * @return      void
4583          */
4584         public function parse_ticket()
4585         {
4586                 global $manager;
4587                 $manager->addTicketHidden();
4588                 return;
4589         }
4590         
4591         /**
4592          * Actions::parse_versioncheckurl()
4593          * Parse skinvar versioncheckurl
4594          * 
4595          * @param       void
4596          * @return      void
4597          */
4598         public function parse_versioncheckurl()
4599         {
4600                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4601                 return;
4602         }
4603         
4604         /**
4605          * Actions::parse_yrbloglist()
4606          * Parse skinvar yrbloglist
4607          * 
4608          * @param       string  $templateName   name of template to use
4609          * @return      void
4610          */
4611         public function parse_yrbloglist($templateName = '')
4612         {
4613                 global $member;
4614                 $showAll = requestVar('showall');
4615                 
4616                 if ( $member->isAdmin() && ($showAll == 'yes') )
4617                 {
4618                         // Super-Admins have access to all blogs! (no add item support though)
4619                         $query =  "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4620                                 . " FROM %s"
4621                                 . " ORDER BY bnumber";
4622                         $query = sprintf($query, sql_table('blog'));
4623                 }
4624                 else
4625                 {
4626                         $query =  "SELECT bnumber, bname, tadmin, burl, bshortname"
4627                                 . " FROM %s,%s"
4628                                 . " WHERE tblog=bnumber and tmember=%d"
4629                                 . " ORDER BY bnumber";
4630                         $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4631                 }
4632                 
4633                 $template['content']    = 'bloglist';
4634                 $template['superadmin'] = $member->isAdmin();
4635                 
4636                 $amount = Showlist($query, 'table', $template, $templateName);
4637                 
4638                 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4639                 {
4640                         $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4641                         
4642                         $total = quickQuery($query);
4643                         if ( $total > $amount )
4644                         {
4645                                 echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4646                         }
4647                 }
4648                 
4649                 if ( $amount == 0 )
4650                 {
4651                         echo _OVERVIEW_NOBLOGS;
4652                 }
4653                 elseif( $amount != 0 )
4654                 {
4655                         echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4656                         
4657                         $query =  "SELECT ititle, inumber, bshortname"
4658                                . " FROM %s,%s"
4659                                . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
4660                         $query = sprintf($query. sql_table('item'), sql_table('blog'), (integer) $member->getID());
4661                         
4662                         $template['content'] = 'draftlist';
4663                         
4664                         $amountdrafts = Showlist($query, 'table', $template, $templateName);
4665                         if ( $amountdrafts == 0 )
4666                         {
4667                                 echo _OVERVIEW_NODRAFTS;
4668                         }
4669                 }
4670                 return;
4671         }
4672         
4673         /**
4674          * Actions::customHelp()
4675          * shows a link to custom help file
4676          * 
4677          * @param       integer $id                     
4678          * @param       string  $tplName        
4679          * @param       string  $url            
4680          * @param       string  $iconURL        
4681          * @param       string  $alt            
4682          * @param       string  $title          
4683          * @param       $onclick
4684          * 
4685          */
4686         private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4687         {
4688                 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4689         }
4690         
4691         /**
4692          * Actions::customHelpHtml()
4693          * 
4694          * @param       integer $id                     
4695          * @param       string  $tplName        
4696          * @param       string  $url            
4697          * @param       string  $iconURL        
4698          * @param       string  $alt            
4699          * @param       string  $title          
4700          * @param       string  $onclick        
4701          * @return      string  anchor element with help uri
4702          */
4703         private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4704         {
4705                 $templates = array();
4706                 if ( $tplName )
4707                 {
4708                         $templates = Template::read($tplName);
4709                 }
4710                 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
4711                 {
4712                         $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
4713                 }
4714                 else
4715                 {
4716                         $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
4717                 }
4718                 
4719                 if ( empty($iconURL) )
4720                 {
4721                         global $CONF;
4722                         $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
4723                 }
4724                 if ( function_exists('getimagesize') )
4725                 {
4726                         $size   = getimagesize($iconURL);
4727                         $width  = 'width="'  . $size[0] . '" ';
4728                         $height = 'height="' . $size[1] . '" ';
4729                 }
4730                 $data = array(
4731                         'iconurl'       => $iconURL,
4732                         'width'         => $width,
4733                         'height'        => $height,
4734                         'alt'           => (isset($alt) && !empty($alt))         ? $alt   : _HELP_TT,
4735                         'title'         => (isset($title) && !empty($title)) ? $title : _HELP_TT,
4736                 );
4737                 $icon = TEMPLATE::fill($template, $data);
4738                 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
4739                 return $help . $icon;
4740         }
4741         
4742         /**
4743          * Actions::input_yesno
4744          * 
4745          * @param               $name
4746          * @param               $checkedval
4747          * @param               $tabindex
4748          * @param               $value1
4749          * @param               $value2
4750          * @param               $yesval
4751          * @param               $noval
4752          * @param               $isAdmin
4753          * @param               $templateName
4754          * @param               $showlist
4755          */
4756         private function input_yesno($name,
4757                                                                 $checkedval,
4758                                                                 $tabindex        = 0,
4759                                                                 $value1    = 1,
4760                                                                 $value2    = 0,
4761                                                                 $yesval    = _YES,
4762                                                                 $noval          = _NO,
4763                                                                 $isAdmin          = 0,
4764                                                                 $templateName = '',
4765                                                                 $showlist        = false)
4766         {
4767                 $templates = array();
4768                 if ( $templateName )
4769                 {
4770                         $templates = Template::read($templateName);
4771                 }
4772                 
4773                 if ( $name == 'admin' )
4774                 {
4775                         if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
4776                         {
4777                                 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
4778                         }
4779                         else
4780                         {
4781                                 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
4782                                           . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
4783                                           . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
4784                                           . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
4785                         }
4786                 }
4787                 else
4788                 {
4789                         if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
4790                         {
4791                                 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
4792                         }
4793                         if ( $showlist )
4794                         {
4795                                 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
4796                                 {
4797                                         $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
4798                                 }
4799                         }
4800                         if ( !isset($template) )
4801                         {
4802                                 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
4803                                           . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
4804                                           . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
4805                                           . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
4806                         }
4807                 }
4808                 
4809                 //echo $template;
4810                 $id             = Entity::hsc($name);
4811                 $id             = str_replace('[', '-', $id);
4812                 $id             = str_replace(']', '-', $id);
4813                 $id1    = $id . Entity::hsc($value1);
4814                 $id2    = $id . Entity::hsc($value2);
4815                 $dat = array(
4816                         'name'                  => Entity::hsc($name),
4817                         'yesval'                => Entity::hsc($value1),
4818                         'noval'                 => Entity::hsc($value2),
4819                         'yesid'                 => $id1,
4820                         'noid'                  => $id2,
4821                         'yesvaltext'    => $yesval,
4822                         'novaltext'             => $noval,
4823                         'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
4824                         'nocheckedval'  => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
4825                         'disabled'              => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
4826                 );
4827                 
4828                 if ( $showlist )
4829                 {
4830                         return Template::fill($template, $dat);
4831                 }
4832                 else
4833                 {
4834                         echo TEMPLATE::fill($template, $dat);
4835                 }
4836                 return;
4837         }
4838         
4839         /**
4840          * AdminActions::parse_text()
4841          * Parse text
4842          * 
4843          * FIXME: is this really needed?
4844          * 
4845          * @param       string  $which  constant vallue
4846          * @return      void
4847          */
4848         public function parse_text($which)
4849         {
4850                 if ( defined($which) )
4851                 {
4852                         echo constant($which);
4853                 }
4854                 return;
4855         }
4856 }