OSDN Git Service

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