OSDN Git Service

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