OSDN Git Service

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