2 class AdminActions extends BaseActions
5 * TODO: I believe we can push them into Admin class
6 * if Admin class is just a static class.
11 private $actions = array(
21 'adminskineditallowedlist',
24 'adminspecialskinlist',
25 'admintemplateoverview',
26 'allowedadminskinactions',
46 'configsettingsyesno',
48 'defaultadminskintypes',
58 'editadmintemplateinfo',
67 'editplugoptionslist',
78 'insertpluginoptions',
82 'languageselectoptions',
83 'listplugplugoptionrow',
100 'selectlocaladminskinfiles',
101 'selectlocalskinfiles',
102 'skineditallowedlist',
114 'adminstyleselectoptions',
115 /* FIXME: typo of adminstylesheets */
117 'adminskinselectoptions'
118 /* FIXME: lack entries. need to be review
119 * parse_banlistdeletedlist
122 * parse_customhelplink
124 * parse_insertpluginfo
125 * parse_insplugoptcontent
131 * AdminActions::getDefinedActions()
132 * Returns an array with the actions that are defined
133 * in the AdminActions class
138 public function getDefinedActions()
140 return $this->actions;
144 * AdminActions::parse_actionloglist()
145 * Parse skinvar actionloglist
147 * @param string $templateName name of template to use
150 public function parse_actionloglist($templateName = '')
152 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
153 $query = sprintf($query, sql_table('actionlog'));
155 $template['content'] = 'actionlist';
156 $amount = skinableShowlist($query, 'table', $template, $templateName);
161 * AdminActions::parse_activationmessage()
162 * Parse skinvar activationmessage
164 * @param string $type type of message
165 * @param string $templateName name of template to use
168 public function parse_activationmessage($type, $templateName = '')
170 global $CONF, $manager;
174 if ( !empty($templateName))
176 $template = skinableTEMPLATE::read($templateName);
179 $key = postVar('ackey');
182 $this->objAdmin->error(_ERROR_ACTIVATE);
185 $info = MEMBER::getActivationInfo($key);
188 $this->objAdmin->error(_ERROR_ACTIVATE);
191 $mem = MEMBER::createFromId($info->vmember);
194 $this->objAdmin->error(_ERROR_ACTIVATE);
196 switch ( $info->vtype )
199 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
201 $title = $template['ACTIVATE_FORGOT_TITLE'];
205 $title = _ACTIVATE_FORGOT_TITLE;
207 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
209 $text = $template['ACTIVATE_FORGOT_TEXT'];
213 $text = _ACTIVATE_FORGOT_TEXT;
217 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
219 $title = $template['ACTIVATE_REGISTER_TITLE'];
223 $title = _ACTIVATE_REGISTER_TITLE;
225 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
227 $text = $template['ACTIVATE_REGISTER_TEXT'];
231 $text = _ACTIVATE_REGISTER_TEXT;
234 case 'addresschange':
235 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
237 $title = $template['ACTIVATE_CHANGE_TITLE'];
241 $title = _ACTIVATE_CHANGE_TITLE;
243 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
245 $text = $template['ACTIVATE_CHANGE_TEXT'];
249 $text = _ACTIVATE_CHANGE_TEXT;
254 'memberName' => Entity::hsc($mem->getDisplayName()),
255 'realName' => Entity::hsc($mem->getRealName()),
260 echo TEMPLATE::fill($title, $aVars);
263 echo TEMPLATE::fill($text, $aVars);
266 echo Entity::hsc($key);
273 * Actions::parse_addtickettourl()
274 * Parse skinvar addtickettourl
276 * @param string $url URI for ticket
279 public function parse_addtickettourl($url)
282 $url = $manager->addTicketToUrl($url);
283 echo Entity::hsc($url);
288 * Actions::parse_adminbanlist()
289 * Parse skinvar adminbanlist
291 * @param string $templateName name of template to use
294 public function parse_adminbanlist($templateName = '')
296 $blogid = intRequestVar('blogid');
298 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
299 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
301 $template['content'] = 'banlist';
303 $amount = Showlist($query, 'table', $template, $templateName);
313 * Actions::parse_adminbatchaction()
314 * Parse skinvar adminbatchaction
319 public function parse_adminbatchaction()
321 echo Entity::hsc(requestVar('batchaction'));
326 * Actions::parse_adminbatchlist()
327 * Parse skinvar adminbatchlist
329 * @param string $templateName name of template to use
332 public function parse_adminbatchlist($templateName = '')
335 $templates = array();
336 if ( !empty($templateName) )
338 $templates = Template::read($templateName);
340 if ( isset($templates['ADMIN_BATCHLIST']) || !empty($templates['ADMIN_BATCHLIST']) )
342 $template = $templates['ADMIN_BATCHLIST'];
346 $template = '<li><%text(_BATCH_EXECUTING)%><b><%adminbatchaction%></b>'
347 . '<%batchlisttype%> <b><%batchid%></b>...'
348 . '<b><%batchlistmsg%></b></li>' . "\n";
351 $selected = requestIntArray('batch');
352 $action = requestVar('batchaction');
354 switch ( $this->skintype )
357 $batchlisttype = _BATCH_ONITEM;
358 $deleteaction = 'deleteOneItem';
359 $moveaction = 'moveOneItem';
360 $destid = intRequestVar('destcatid');
363 $batchlisttype = _BATCH_ONCOMMENT;
364 $deleteaction = 'deleteOneComment';
367 $batchlisttype = _BATCH_ONMEMBER;
368 $deleteaction = 'deleteOneMember';
369 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
370 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
371 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
372 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
375 $blogid = intRequestVar('blogid');
376 $batchlisttype = _BATCH_ONTEAM;
377 $deleteaction = 'deleteOneTeamMember';
378 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
379 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
380 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
381 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
383 case 'batchcategory':
384 $batchlisttype = _BATCH_ONCATEGORY;
385 $deleteaction = 'deleteOneCategory';
386 $moveaction = 'moveOneCategory';
387 $destid = intRequestVar('destblogid');
391 // walk over all selectedids and perform action
392 foreach ( $selected as $selectedid )
395 $selectedid = intval($selectedid);
399 if ( $this->skintype != 'batchteam' )
401 $error = $this->objAdmin->$deleteaction($selectedid);
405 $error = $this->objAdmin->deleteOneTeamMember($blogid, $selectedid);
409 $error = $this->objAdmin->$moveaction($selectedid, $destid);
413 sql_query('UPDATE ' . $setadminsql . $selectedid);
417 // there should always remain at least one super-admin
418 $r = sql_query($unsetchksql);
419 if ( sql_num_rows($r) < 2 )
421 $error = $unseterrmsg;
425 sql_query('UPDATE ' . $unsetupsql . $selectedid);
429 $error = _BATCH_UNKNOWN . Entity::hsc($action);
432 'batchid' => $selectedid,
433 'batchlisttype' => Entity::hsc($batchlisttype),
434 'adminbatchaction' => Entity::hsc($action),
435 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
437 $handler = new Actions('template', $template, new ADMIN);
438 $parser = new Parser($handler);
441 $parser->parse($template);
442 $template = ob_get_contents();
445 echo TEMPLATE::fill($template, $data);
451 * Actions::parse_adminbloglink()
452 * Parse skinvar adminbloglink
454 * @param string $templateName name of template to use
457 public function parse_adminbloglink($templateName = '')
460 $blogid = intRequestVar('blogid');
461 $blog =& $manager->getBlog($blogid);
462 $templates = array();
464 if ( !empty($templateName) )
466 $templates = Template::read($templateName);
469 if ( isset($templates['ADMIN_BLOGLINK']) || !empty($templates['ADMIN_BLOGLINK']) )
471 $template = $templates['ADMIN_BLOGLINK'];
475 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
479 'url' => Entity::hsc($blog->getURL()),
480 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
481 'blogname' => Entity::hsc($blog->getName())
484 echo TEMPLATE::fill($template, $data);
489 * Actions::parse_adminerrormesg()
490 * Parse skinvar adminerrormesg
495 public function parse_adminerrormesg()
500 if ( requestVar('errormessage') )
502 $message = requestVar('errormessage');
504 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
506 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
508 elseif ( $this->objAdmin->sessionVar($CONF['CookiePrefix'] . 'errormessage') )
510 $message = $this->objAdmin->sessionVar($CONF['CookiePrefix'] . 'errormessage');
512 echo Entity::hsc($message);
517 * Actions::parse_adminparsedinclude()
518 * Parse skinvar adminparsedinclude
520 * @param string $filename name of file
523 public function parse_adminparsedinclude($filename)
525 // check current level
526 if ( $this->level > 3)
528 // max. depth reached (avoid endless loop)
531 $skin = new Skin($this->skin->id);
532 $file = $this->getIncludeFileName($filename);
534 if ( !$skin->isValid && !file_exists($file) )
539 $contents = $skin->getContent($filename);
543 if ( !file_exists($file) )
547 $contents = file_get_contents($file);
548 if ( empty($contents) )
553 $this->level = $this->level + 1;
554 // parse file contents
555 $this->parser->parse($contents);
557 $this->level = $this->level - 1;
562 * Actions::parse_adminskineditallowedlist()
563 * Parse skinvar adminskineditallowedlist
565 * @param string $type template/blog
566 * @param string $templateName name of template to use
569 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
573 /* TODO: blog seems not to be used */
575 $query = "SELECT bshortname, bname FROM %s";
576 $query = sprintf($query, sql_table('blog'));
578 'content' => 'shortblognames'
582 $query = "SELECT tdname as name, tddesc as description FROM %s;";
583 $query = sprintf($query, sql_table('admintemplate_desc'));
585 'content' => 'shortnames'
589 Showlist($query, 'table', $show, $templateName);
594 * Actions::parse_adminskinielist()
595 * Parse skinvar adminskinielist
597 * @param string $type skin/template
598 * @param string $templateName name of template to use
601 public function parse_adminskinielist($type, $templateName = '')
603 $templates = array();
606 $templates = Template::read($templateName);
608 if ( isset($templates['SKINIE_EXPORT_LIST']) && !empty($templates['SKINIE_EXPORT_LIST']) )
610 $template = $templates['SKINIE_EXPORT_LIST'];
614 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
615 . "<td><%expdesc%></td>\n"
621 $query = "SELECT * FROM %s;";
622 $query = sprintf($query, sql_table('adminskin_desc'));
623 $res = sql_query($query);
625 while ( $skinObj = sql_fetch_object($res) )
628 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
629 'expid' => 'skinexp' . $skinObj->sdnumber,
630 'expname' => Entity::hsc($skinObj->sdname),
631 'expdesc' => Entity::hsc($skinObj->sddesc),
633 echo TEMPLATE::fill($template, $data);
637 $query = "SELECT * FROM %s;";
638 $query = sprintf($query, sql_table('admintemplate_desc'));
639 $res = sql_query($query);
640 while ( $templateObj = sql_fetch_object($res) )
643 'typeid' => 'template[' . $templateObj->tdnumber . ']',
644 'expid' => 'templateexp' . $templateObj->tdnumber,
645 'expname' => Entity::hsc($templateObj->tdname),
646 'expdesc' => Entity::hsc($templateObj->tddesc),
648 echo TEMPLATE::fill($template, $data);
656 * Actions::parse_adminskinoverview()
657 * Parse skinvar adminskinoverview
659 * @param string $templateName name of template to use
662 public function parse_adminskinoverview($templateName = '')
664 $query = "SELECT * FROM %s ORDER BY sdname;";
665 $query = sprintf($query, sql_table('adminskin_desc'));
667 $template['content'] = 'adminskinlist';
668 $template['tabindex'] = 10;
669 Showlist($query, 'table', $template, $templateName);
674 * Actions::parse_adminskinselectoptions()
675 * Parse skinvar adminskinselectoptions
680 public function parse_adminskinselectoptions()
683 $query = "SELECT sdname as text, sdnumber as value FROM %s;";
684 $query = sprintf($query, sql_table('adminskin_desc'));
686 $template['name'] = 'adminskin';
687 $template['selected'] = $CONF['DefaultAdminSkin'];
688 $template['tabindex'] = 110;
689 Showlist($query, 'select', $template, '');
694 * Actions::parse_adminspecialskinlist()
695 * Parse skinvar adminspecialskinlist
697 * @param string $templateName name of template to use
699 public function parse_adminspecialskinlist($templateName = '')
701 $templates = array();
704 $templates = Template::read($templateName);
707 $nType = Skin::getAdminskinDefaultTypes();
708 $skinid = intRequestVar('skinid');
710 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
711 $query = sprintf($query, sql_table('adminskin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
713 $res = sql_query($query);
714 if ( $res && sql_num_rows($res) > 0 )
717 if ( isset($templates['ADMIN_SPECIALSKINLIST_HEAD']) && !empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
719 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
723 $template['head'] = "<ul>\n";
725 echo TEMPLATE::fill($template['head'], $data);
726 if ( isset($templates['ADMIN_SPECIALSKINLIST_BODY']) && !empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
728 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
732 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>'
733 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
734 . 'action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
737 while ( $row = sql_fetch_assoc($res) )
740 'tabindex' => $tabstart++,
742 'skintype' => Entity::hsc(strtolower($row['stype']))
744 echo TEMPLATE::fill($template['body'], $data);
748 if ( isset($templates['ADMIN_SPECIALSKINLIST_FOOT']) && !empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
750 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
754 $template['foot'] = "<ul>\n";
756 echo TEMPLATE::fill($template['foot'], $data);
762 * Actions::parse_adminstylesheets()
763 * Parse skinvar adminstylesheets
768 public function parse_adminstylesheets()
771 $includePrefix = $this->skin->includePrefix;
773 if ( strlen($includePrefix) > 0 )
775 $styleURL = Entity::hsc($CONF['AdminURL']) . 'adminskins/' . $includePrefix . 'admin_' . $CONF['AdminCSS'] . '.css';
779 $styleURL = Entity::hsc($CONF['AdminURL']) . 'styles/admin_' . $CONF['AdminCSS'] . '.css';
786 * Actions::parse_adminstyleselectoptions()
787 * Parse skinvar adminstyleselectoptions
792 public function parse_adminstyleselectoptions()
794 global $CONF, $manager, $DIR_NUCLEUS;
795 if ( strlen($this->skin->includePrefix) > 0 )
797 $scndir = $DIR_NUCLEUS . 'adminskins/' . $this->skin->includePrefix;
801 $scndir = $DIR_NUCLEUS . 'styles/';
803 $files = scandir($scndir);
805 foreach ( $files as $file )
807 if ( !preg_match("#^admin_(.*)\.css$#", $file, $matches) )
813 $opts = '<option value="' . $name . '"';
814 if ( $name != $CONF['AdminCSS'] )
816 $opts .= "<option value=\"{$name}\">{$name}</option>\n";
820 $opts .= "<option value=\"{$name}\" selected=\"selected\">{$name}</option>\n";
828 * Actions::parse_admintemplateoverview()
829 * Parse skinvar admintemplateoverview
831 * @param string $templateName name of template to use
834 public function parse_admintemplateoverview($templateName = '')
836 $query = "SELECT * FROM %s ORDER BY tdname;";
837 $query = sprintf($query, sql_table('admintemplate_desc'));
839 $template['content'] = 'admintemplatelist';
840 $template['tabindex'] = 10;
842 Showlist($query, 'table', $template, $templateName);
847 * Actions::parse_allowedadminskinactions()
848 * Parse skinvar allowedadminskinactions
853 public function parse_allowedadminskinactions()
855 global $DIR_ADMINSKINS;
856 $skinType = strtolower(trim(requestVar('type')));
857 $actions = Skin::getAllowedActionsForType($skinType);
860 while ( $current = array_shift($actions) )
862 // skip deprecated vars
863 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
868 echo "<a href=\"{$DIR_ADMINSKINS}documentation/help.html#{$current}\" onclick=\"if (event && event.preventDefault) event.preventDefault(); return help(this.href);\">{$current}</a>\n";
870 if ( count($actions) != 0 )
879 * Actions::parse_allowedskinactions()
880 * Parse skinvar allowedskinactions
885 public function parse_allowedskinactions()
887 $skinType = strtolower(trim(requestVar('type')));
888 $actions = SKIN::getAllowedActionsForType($skinType);
891 while ( $current = array_shift($actions) )
893 // skip deprecated vars
894 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
899 /* TODO: alternative function should be used or not? */
900 echo helplink("skinvar-{$current}") . "$current</a>\n";
902 if ( count($actions) != 0 )
911 * Action::parse_banlistdeletedlist()
912 * Parse skinvar banlistdeletedlist
914 * @param string $templateName name of template to use
917 public function parse_banlistdeletedlist($templateName = '')
920 $templates = array();
924 $templates = Template::read($templateName);
926 if ( isset($templates['BANLIST_DELETED_LIST']) && !empty($templates['BANLIST_DELETED_LIST']) )
928 $template = $templates['BANLIST_DELETED_LIST'];
932 $template = "<li><%blogname%></li>\n";
934 $deleted = requestArray('delblogs');
935 foreach ( $deleted as $delblog )
937 $blog =& $manager->getBlog($delblog);
939 Entity::hsc($blog->getName())
941 TEMPLATE::fill($template, $data);
947 * Actions::parse_batchdeletelist()
948 * Parse skinvar batchdeletelist
953 public function parse_batchdeletelist()
955 $selected = requestIntArray('batch');
958 foreach ( $selected as $select )
960 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
962 // add hidden vars for team & comment
963 if ( requestVar('action') == 'batchteam' )
965 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
967 if ( requestVar('action') == 'batchcomment' )
969 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
975 * Actions::parse_batchdeletetype()
976 * Parse skinvar batchdeletetype
981 public function parse_batchdeletetype()
983 echo Entity::hsc(requestVar('action'));
988 * Actions::parse_batchmovebtn()
989 * Parse skinvar batchmovebtn
994 public function parse_batchmovebtn()
996 $actionType = requestVar('action');
997 switch ( $actionType )
1002 case 'batchcategory':
1010 * Actions::parse_batchmovelist()
1011 * Parse skinvar batchmovelist
1016 public function parse_batchmovelist()
1018 $selected = requestIntArray('batch');
1019 foreach ( $selected as $select )
1021 echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1027 * Actions::parse_batchmovetitle()
1028 * Parse skinvar batchmovetitle
1033 public function parse_batchmovetitle()
1035 $actionType = requestVar('action');
1036 switch ( $actionType )
1041 case 'batchcategory':
1042 echo _MOVECAT_TITLE;
1049 * Actions::parse_batchmovetype()
1050 * Parse skinvar batchmovetype
1055 public function parse_batchmovetype()
1057 echo Entity::hsc(requestVar('action'));
1062 * Actions::parse_blogcatlist()
1063 * Parse skinvar blogcatlist
1068 public function parse_blogcatlist()
1071 $blogid = intRequestVar('blogid');
1072 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1073 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1075 $template['content'] = 'categorylist';
1076 $template['tabindex'] = 200;
1078 $batch = new Batch('member');
1079 $batch->showlist($query, 'table', $template);
1084 * Actions::parse_blognotifysetting()
1085 * Parse skinvar blognotifysetting
1090 public function parse_blognotifysetting($type)
1093 $blogid = intRequestVar('blogid');
1094 $blog = $manager->getBlog($blogid);
1099 if ( !$blog->notifyOnComment() )
1105 if ( !$blog->notifyOnVote() )
1111 if ( !$blog->notifyOnNewItem() )
1117 echo ' checked="checked"';
1122 * AdminAction::parse_blogselectbox()
1123 * Parse skinvar blogselectbox
1128 public function parse_blogselectbox()
1132 $selectData = requestVar('selectData');
1133 $mode = $selectData['mode'];
1134 $name = ENTITY::hsc($selectData['name'], ENT_QUOTES);
1135 $tabindex = ENTITY::hsc($selectData['tabindex'], ENT_QUOTES);
1136 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1137 $showNewCat = intval($selectData['showNewCat']);
1138 $selected = intval($selectData['selected']);
1140 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1142 // 1. select blogs (we'll create optiongroups)
1143 // (only select those blogs that have the user on the team)
1144 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1145 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1146 $blogs = sql_query($queryBlogs);
1148 if ( $mode == 'category' )
1150 if ( sql_num_rows($blogs) > 1 )
1154 while ( $oBlog = sql_fetch_object($blogs) )
1156 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1158 echo '<optgroup label="' . ENTITY::hsc($oBlog->bname, ENT_QUOTES) . "\>\n";
1161 // show selection to create new category when allowed/wanted
1164 // check if allowed to do so
1165 if ( $member->blogAdminRights($oBlog->bnumber) )
1167 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1171 // 2. for each category in that blog
1172 $catQueriy = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1173 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1174 $categories = sql_query(sprintf($catQueriy));
1175 while ( $oCat = sql_fetch_object($categories) )
1177 if ( $oCat->catid == $selected )
1179 $selectText = ' selected="selected" ';
1185 echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . ENTITY::hsc($oCat->cname, ENT_QUOTES) . "</option>\n";
1188 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1197 while ( $oBlog = sql_fetch_object($blogs) )
1199 echo '<option value="' . $oBlog->bnumber . '"';
1200 if ( $oBlog->bnumber == $selected )
1202 echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . ENTITY::hsc($oBlog->bname, ENT_QUOTES) . "</option>\n";
1206 echo '<option value="' . $oBlog->bnumber . '">' . ENTITY::hsc($oBlog->bname, ENT_QUOTES) . "</option>\n";
1215 * Actions::parse_blogsetting()
1216 * Parse skinvar blogsetting
1218 * @param string $which name of weblog setting
1221 public function parse_blogsetting($which)
1223 echo $this->parse_getblogsetting($which);
1228 * Actions::parse_blogsettingyesno()
1229 * Parse skinvar blogsettingyesno
1231 * @param string $type type of weblog setting
1232 * @param string $templateName name of template to use
1235 public function parse_blogsettingyesno($type, $templateName = '')
1239 $blogid = intRequestVar('blogid');
1240 $blog = $manager->getBlog($blogid);
1244 case 'convertbreaks':
1245 $checkedval = $blog->convertBreaks();
1248 case 'allowpastposting':
1249 $checkedval = $blog->allowPastPosting();
1253 $checkedval = $blog->commentsEnabled();
1257 $checkedval = $blog->isPublic();
1261 $checkedval = $blog->emailRequired();
1265 $checkedval = $blog->getSearchable();
1269 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1274 * Actions::parse_blogteamlist()
1275 * Parse skinvar blogteamlist
1277 * @param string $templateName name of template to use
1280 public function parse_blogteamlist($templateName = '')
1283 $blogid = intRequestVar('blogid');
1284 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1286 . "WHERE tmember=mnumber AND tblog= %d";
1287 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1289 $template['content'] = 'teamlist';
1290 $template['tabindex'] = 10;
1292 $batch = new Batch('team');
1293 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1298 * Actions::parse_blogteammembers()
1299 * Parse skinvar blogteammembers
1304 public function parse_blogteammembers()
1306 $blogid = intRequestVar('blogid');
1307 $query = "SELECT mname, mrealname "
1309 . "WHERE mnumber=tmember AND tblog=%d;";
1310 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1311 $res = sql_query($query);
1312 $memberNames = array();
1313 while ($o = sql_fetch_object($res)) {
1314 $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1316 echo implode(',', $memberNames);
1320 * Actions::parse_blogtime()
1321 * Parse skinvar blogtime
1323 * @param string $type type of time
1324 * @param string $format format for time expression
1325 * @param integer $offset offset of time
1328 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1332 if ( $type != 'blogtime' )
1334 /* return server time */
1335 $timestamp = time() + $offset;
1339 $bid = intRequestVar('blogid');
1340 $b = $manager->getBlog($bid);
1341 $timestamp = $b->getCorrectTime() + $offset;
1344 echo i18n::formatted_datetime($format, $timestamp);
1349 * Actions::parse_bookmarkletadmin()
1350 * Parse skinvar bookmarkletadmin
1352 * @param string $type type of anchor element for bookmarklet
1355 public function parse_bookmarkletadmin($type)
1359 $blogid = intRequestVar('blogid');
1361 if ( $type != 'regfile' )
1363 echo Entity::hsc(getBookmarklet($blogid));
1367 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
1368 $url = $manager->addTicketToUrl($url);
1369 /* TODO: Shift-JIS is not always correct, I think... */
1370 echo Entity::hsc($url, 'SJIS');
1376 * Actions::parse_category()
1377 * Parse skinvar category
1379 * @param string $type name of setting for category
1382 public function parse_category($type = 'name')
1384 echo $this->parse_getcategory($type);
1389 * Actions::parse_categorysetting()
1390 * Parse skinvar categorysetting
1392 * @param string $type type in category setting
1395 public function parse_categorysetting($type)
1397 $catid = intRequestVar('catid');
1398 if ( $type == 'id' )
1403 $blogid = intRequestVar('blogid');
1404 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1405 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1406 $res = sql_query($query);
1407 $obj = sql_fetch_object($res);
1409 if ( $type != desc )
1411 echo Entity::hsc($obj->cdesc);
1415 echo Entity::hsc($obj->cname);
1422 * Actions::parse_codename()
1423 * Parse templatevar codename
1428 * TODO: is this need???
1430 public function parse_codename()
1433 echo $nucleus['codename'];
1438 * Actions::parse_commentnavlist()
1439 * Parse skinvar commentnavlist
1444 public function parse_commentnavlist()
1446 global $CONF, $manager, $member;
1449 if ( postVar('start') )
1451 $start = intPostVar('start');
1458 // amount of items to show
1459 if ( postVar('amount') )
1461 $amount = intPostVar('amount');
1465 $amount = (integer) $CONF['DefaultListSize'];
1471 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1473 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1475 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1477 if ( $this->skintype == 'itemcommentlist' )
1479 $itemid = intRequestVar('itemid');
1480 $query .= " citem={$itemid}";
1481 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1483 $nonComments = _NOCOMMENTS;
1485 elseif ( $this->skintype == 'browseowncomments' )
1488 $query .= ' cmember=' . $member->getID();
1489 $template['canAddBan'] = 0;
1491 $nonComments = _NOCOMMENTS_YOUR;
1493 elseif ( $this->skintype == 'blogcommentlist' )
1496 $query .= ' cblog=' . intRequestVar('blogid');
1497 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1498 $bid = intRequestVar('blogid');
1499 $nonComments = _NOCOMMENTS_BLOG;
1502 $search = postVar('search');
1503 if ( !empty($search) )
1505 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1508 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1510 $template['content'] = 'commentlist';
1512 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
1513 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
1518 * Actions::parse_configsettingsedit()
1519 * Parse skinvar configsettingsedit
1521 * @param string $type type of global configuration
1524 public function parse_configsettingsedit($type)
1529 case 'DefaultListSize':
1530 if ( !array_key_exists('DefaultListSize', $CONF) )
1532 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1533 $query = sprintf($query, sql_table('config'));
1535 $CONF['DefaultListSize'] = 10;
1537 elseif ( intval($CONF['DefaultListSize']) < 1 )
1539 $CONF['DefaultListSize'] = 10;
1541 echo intval($CONF['DefaultListSize']);
1543 case 'SessionCookie':
1544 $value = $CONF['SessionCookie'];
1545 $txt1 = _SETTINGS_COOKIESESSION;
1546 $txt2 = _SETTINGS_COOKIEMONTH;
1547 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1550 $value = $CONF['URLMode'];
1551 $txt1 = _SETTINGS_URLMODE_NORMAL;
1552 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1553 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1556 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1558 echo Entity::hsc($CONF[$type]);
1566 * Actions::parse_configsettingsyesno()
1567 * Parse skinvar configsettingsyesno
1569 * @param string $type type of global setting
1570 * @param integer $tabindex tabindex attribute of input element
1573 public function parse_configsettingsyesno($type, $tabindex)
1576 if ( array_key_exists($type, $CONF) )
1578 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1584 * Actions::parse_customhelplink()
1585 * Parse skinvar customhelplink
1587 * @param string $topic name of topic
1588 * @param string $tplName name of template
1589 * @param string $url string as URI
1590 * @param string $iconURL string as URI for icon
1591 * @param string $alt alternative text for image element
1592 * @param string $title title for anchor element
1595 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1597 $this->customHelp($topic, $url, $iconURL);
1602 * Actions::parse_date()
1603 * Parse skinvar date
1605 public function parse_date($format = 'c')
1607 global $CONF, $manager;
1608 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
1613 * Actions::parse_defaultadminskintypes()
1614 * Parse skinvar defaultadminskintypes
1616 * @param string $tabindex index number for tabindex attribute of input element
1617 * @param string $templateName name of template
1620 public function parse_defaultadminskintypes($tabindex, $templateName = '')
1622 $templates = array();
1623 if ( $templateName )
1625 $templates = Template::read($templateName);
1628 $types = Skin::getAdminskinDefaultTypeFriendlyNames();
1631 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
1633 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
1637 $template['head'] = "<ul>\n";
1640 echo $template['head'];
1642 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
1644 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
1648 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1649 . "<%name%></a> <%help%></li>\n";
1651 $handler = new Actions('template', $template, new ADMIN);
1652 $parser = new PARSER(Actions::getDefinedActions(), $handler);
1654 foreach ( $types as $type => $fName )
1656 $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
1658 'tabindex' => $tabindex,
1659 'skintype' => $type,
1661 'help' => $helplink,
1662 'skinid' => intrequestVar('skinid'),
1664 $templateBody = Template::fill($template['body'], $data);
1665 $parser->parse($templateBody);
1668 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
1670 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
1674 $template['foot'] = " </ul>\n";
1676 echo $template['foot'];
1681 * Actions::parse_defblogselect()
1682 * Parse skinvar defblogselect
1684 * @param string $templateName name of template
1687 public function parse_defblogselect($templateName = '')
1690 $query = "SELECT bname as text, bnumber as value FROM %s;";
1691 $query = sprintf($query, sql_table('blog'));
1692 $template['name'] = 'DefaultBlog';
1693 $template['selected'] = $CONF['DefaultBlog'];
1694 $template['tabindex'] = 10;
1695 Showlist($query, 'select', $template, $templateName);
1700 * Actions::parse_defcatselect()
1701 * Parse skinvar defcatselect
1703 * @param string $templateName name of template
1706 public function parse_defcatselect($templateName = '')
1709 $blogid = intRequestVar('blogid');
1710 $blog = $manager->getBlog($blogid);
1711 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
1712 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
1713 $template['name'] = 'defcat';
1714 $template['selected'] = $blog->getDefaultCategory();
1715 $template['tabindex'] = 110;
1716 Showlist($query, 'select', $template, $templateName);
1721 * Actions::parse_defskinselect()
1722 * Parse skinvar defskinselect
1724 * @param string $type type of skin
1725 * @param string $templateName name of template
1728 public function parse_defskinselect($type = 'blog', $templateName = '')
1731 $query = "SELECT sdname as text, sdnumber as value FROM %s;";
1732 $query = sprintf($query, sql_table('skin_desc'));
1734 $blogid = intRequestVar('blogid');
1739 $template['selected'] = $CONF['BaseSkin'];
1743 $blog = $manager->getBlog($blogid);
1744 $template['selected'] = $blog->getDefaultSkin();
1747 if ( $type != 'blog' )
1749 $nname = 'BaseSkin';
1756 $template['name'] = $nname;
1757 $template['tabindex'] = 50;
1758 Showlist($query, 'select', $template, $templateName);
1763 * AdminActions::parse_deletecomment()
1764 * Parse skinvar deletecomment
1766 * @param string $type type of infomation for comment
1769 public function parse_deletecomment($type = 'id')
1771 $commentid = intRequestVar('commentid');
1772 $comment = COMMENT::getComment($commentid);
1777 echo intRequestVar('commentid');
1780 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
1782 echo $comment['member'];
1786 echo $comment['user'];
1790 $body = strip_tags($comment['body']);
1791 echo ENTITY::hsc(shorten($body, 300, '...'), ENT_QUOTES);
1797 * Actions::parse_deleteitembody()
1798 * Parse skinvar deleteitembody
1803 public function parse_deleteitembody()
1806 $itemid = intRequestVar('itemid');
1807 $item =& $manager->getItem($itemid, 1, 1);
1808 $body = strip_tags($item['body']);
1809 echo Entity::hsc(shorten($body, 300, '...'));
1814 * Actions::parse_deleteitemid()
1815 * Parse skinvar deleteitemid
1820 public function parse_deleteitemid()
1822 echo (integer) intRequestVar('itemid');
1827 * Actions::parse_deleteitemtitle()
1828 * Parse skinvar deleteitemtitle
1833 public function parse_deleteitemtitle()
1836 $itemid = intRequestVar('itemid');
1837 $item =& $manager->getItem($itemid, 1, 1);
1838 echo Entity::hsc(strip_tags($item['title']));
1843 * Actions::parse_editadminskin()
1844 * Parse skinvar editadminskin
1846 * @param string $type type of skin setting
1849 public function parse_editadminskin($type = 'id')
1851 $skinid = intRequestVar('skinid');
1852 $skin = new Skin($skinid);
1856 echo intRequestVar('skinid');
1859 echo Entity::hsc($skin->getName());
1862 echo Entity::hsc($skin->getDescription());
1865 echo Entity::hsc($skin->getContentType());
1868 echo Entity::hsc($skin->getIncludePrefix());
1871 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
1879 * Actions::parse_editadminskintype()
1880 * Parse skinvar editadminskintype
1882 * @param string $type name of skin type
1885 public function parse_editadminskintype($type = 'id')
1887 global $CONF, $manager, $member;
1888 $skinid = intRequestVar('skinid');
1889 $skin = new Skin($skinid);
1890 $fNames = Skin::getFriendlyNames();
1891 $sType = strtolower(trim(requestVar('type')));
1896 echo intRequestVar('skinid');
1899 echo Entity::hsc($skin->getName());
1902 echo Entity::hsc($skin->getDescription());
1905 echo Entity::hsc($skin->getContentType());
1908 echo Entity::hsc($skin->getContent($sType));
1911 $skinType = isset($fNames[$sType]) ? $fNames[$sType] : ucfirst($sType);
1912 echo Entity::hsc($skinType);
1915 echo Entity::hsc($sType);
1918 echo Entity::hsc($skin->getIncludePrefix());
1921 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
1922 echo Entity::hsc($incMode);
1931 * Actions::parse_editadmintemplateinfo()
1932 * Parse skinvar editadmintemplateinfo
1934 * @param string $type type of skin template
1935 * @param string $description description of template
1936 * @param string $name name of stemplate
1937 * @param string $tabindex index number for tabindex attribute of input element
1938 * @param string $big
1939 * @param string $tplt
1941 public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
1944 $templateid = intRequestVar('templateid');
1945 $templatename = Template::getNameFromId($templateid);
1946 $templatedescription = Template::getDesc($templateid);
1947 $template =& Template::read($templatename);
1951 echo intval($templateid);
1954 echo Entity::hsc($templatename);
1957 echo Entity::hsc($templatedescription);
1959 case 'extratemplate':
1961 $pluginfields = array();
1963 'AdminTemplateExtraFields',
1965 'fields' => &$pluginfields
1971 $tmplt = Template::read($description);
1973 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
1975 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
1981 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
1983 foreach ( $pluginfields as $pfkey => $pfvalue )
1986 'explugtplname' => Entity::hsc($pfkey)
1988 echo TEMPLATE::fill($base, $data);
1989 foreach ( $pfvalue as $pffield => $pfdesc )
1991 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
1996 $desc = defined($description) ? constant($description) : $description;
1997 $name = defined($name) ? constant($name) : $name;
1998 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2005 * Actions::parse_editcomment()
2006 * Parse skinvar editcomment
2008 * @param string $type type of comment setting
2011 public function parse_editcomment($type = 'id')
2014 $commentid = intRequestVar('commentid');
2015 $comment = COMMENT::getComment($commentid);
2017 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2022 echo intRequestVar('commentid');
2025 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2027 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2031 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2035 echo date("Y-m-d @ H:i", $comment['timestamp']);
2038 $comment['body'] = str_replace('<br />', '', $comment['body']);
2039 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2040 echo $comment['body'];
2042 echo $comment[$type];
2049 * Actions::parse_editdesturl()
2050 * Parse skinvar editdesturl
2052 public function parse_editdesturl()
2054 if ( requestVar('desturl') )
2056 echo Entity::hsc(requestVar('desturl'));
2062 * Actions::parse_editmemberlist()
2063 * Parse skinvar editmemberlist
2065 * @param string $templateName name of template
2068 public function parse_editmemberlist($templateName = '')
2071 // show list of members with actions
2072 $query = 'SELECT * FROM '.sql_table('member');
2073 $template['content'] = 'memberlist';
2074 $template['tabindex'] = 10;
2076 $batch = new Batch('member');
2077 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2082 * AdminActions::parse_editmember()
2083 * Parse skinvar editmember
2085 * @param string $type type of information for member
2086 * @return string $tempateName name of template to use
2089 public function parse_editmember($type = 'id', $templateName = '')
2091 global $CONF, $manager, $member;
2092 $memberid = intRequestVar('memberid');
2093 $mem = MEMBER::createFromID($memberid);
2098 echo intRequestVar('memberid');
2101 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2103 echo ENTITY::hsc($mem->getDisplayName(), ENT_QUOTES);
2107 $dispName = ENTITY::hsc($mem->getDisplayName(), ENT_QUOTES);
2108 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2110 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2119 echo ENTITY::hsc($mem->getRealName(), ENT_QUOTES);
2122 echo ENTITY::hsc($mem->getEmail(), ENT_QUOTES);
2125 echo ENTITY::hsc($mem->getURL(), ENT_QUOTES);
2128 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2131 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2134 echo ENTITY::hsc($mem->getNotes(), ENT_QUOTES);
2137 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2146 * Actions::parse_editpluginfo()
2147 * Parse skinvar editpluginfo
2149 * @param string $type type of plugin info
2152 public function parse_editpluginfo($type)
2154 $pid = intRequestVar('plugid');
2161 echo Entity::hsc(getPluginNameFromPid($pid));
2168 * Actions::parse_editplugoptionslist()
2169 * Parse skinvar editplugoptionslist
2171 * @param string $templateName name of template
2174 public function parse_editplugoptionslist($templateName = '')
2178 $pid = intRequestVar('plugid');
2179 $aOptions = array();
2182 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2183 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2184 $resource = sql_query($query);
2186 while ( $o = sql_fetch_object($resource) )
2188 array_push($aOIDs, $o->oid);
2189 $aOptions[$o->oid] = array(
2192 'value' => $o->odef,
2193 'name' => $o->oname,
2194 'description' => $o->odesc,
2195 'type' => $o->otype,
2196 'typeinfo' => $o->oextra,
2201 // fill out actual values
2202 if ( count($aOIDs) > 0 )
2204 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2205 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2207 $result = sql_query($query);
2209 while ( $o = sql_fetch_object($result) )
2211 $aOptions[$o->oid]['value'] = $o->ovalue;
2217 'PrePluginOptionsEdit',
2219 'context' => 'global',
2221 'options' => &$aOptions
2225 $template['content'] = 'plugoptionlist';
2226 $amount = Showlist($aOptions, 'table', $template, $templateName);
2229 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2235 * Actions::parse_editskin()
2236 * Parse skinvar editskin
2238 * @param string $type type of skin
2241 public function parse_editskin($type = 'id')
2243 $skinid = intRequestVar('skinid');
2244 $skin = new SKIN($skinid);
2248 echo intRequestVar('skinid');
2251 echo Entity::hsc($skin->getName());
2254 echo Entity::hsc($skin->getDescription());
2257 echo Entity::hsc($skin->getContentType());
2260 echo Entity::hsc($skin->getIncludePrefix());
2263 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2271 * Actions::parse_editskintype()
2272 * Parse skinvar editskintype
2274 * @param string $type name of type for skin type
2277 public function parse_editskintype($type = 'id')
2279 global $CONF, $manager, $member;
2280 $skinid = intRequestVar('skinid');
2281 $skin = new SKIN($skinid);
2282 $fNames = SKIN::getFriendlyNames();
2283 $sType = strtolower(trim(requestVar('type')));
2288 echo intRequestVar('skinid');
2291 echo Entity::hsc($skin->getName());
2294 echo Entity::hsc($skin->getDescription());
2297 echo Entity::hsc($skin->getContentType());
2300 echo Entity::hsc($skin->getContent($sType));
2303 $skinType = isset($fNames[$sType]) ? $fNames[$sType] : ucfirst($sType);
2304 echo Entity::hsc($skinType);
2307 echo Entity::hsc($sType);
2310 echo Entity::hsc($skin->getIncludePrefix());
2313 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2314 echo Entity::hsc($incMode);
2323 * Actions::parse_edittemplateinfo()
2324 * Parse skinvar edittemplateinfo
2326 * @param string $type name of type for skin
2327 * @param string $description description for skin
2328 * @param string $name name of skin
2329 * @param string $help
2330 * @param string $tabindex index value for tabindex attribute of input element
2331 * @param string $big
2332 * @param string $tplt name of template
2334 public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2337 $templateid = intRequestVar('templateid');
2338 $templatename = TEMPLATE::getNameFromId($templateid);
2339 $templatedescription = TEMPLATE::getDesc($templateid);
2340 $template =& $manager->getTemplate($templatename);
2344 echo intval($templateid);
2347 echo Entity::hsc($templatename);
2350 echo Entity::hsc($templatedescription);
2352 case 'extratemplate':
2354 $pluginfields = array();
2356 'TemplateExtraFields',
2358 'fields' => &$pluginfields
2364 $tmplt = Template::read($description);
2366 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2368 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2372 $base = "</tr><tr>\n"
2373 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2375 foreach ( $pluginfields as $pfkey => $pfvalue )
2378 'explugtplname' => Entity::hsc($pfkey)
2380 echo TEMPLATE::fill($base, $data);
2381 foreach ( $pfvalue as $pffield => $pfdesc )
2383 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2388 $desc = defined($description) ? constant($description) : $description;
2389 $name = defined($name) ? constant($name) : $name;
2390 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2397 * Actions::parse_eventformextra()
2398 * Parse skinvar eventformextra
2400 * @param string $type name of type for event form extra
2403 public function parse_eventformextra($type = 'activation')
2409 $key = requestVar('ackey');
2412 $this->objAdmin->error(_ERROR_ACTIVATE);
2414 $info = MEMBER::getActivationInfo($key);
2417 $this->objAdmin->error(_ERROR_ACTIVATE);
2419 $mem = MEMBER::createFromId($info->vmember);
2422 $this->objAdmin->error(_ERROR_ACTIVATE);
2425 'type' => 'activation',
2429 case 'membermailform-notloggedin':
2431 'type' => 'membermailform-notloggedin',
2435 $manager->notify('FormExtra', $data);
2440 * Actions::parse_extrahead()
2441 * Parse skinvar extrahead
2443 public function parse_extrahead()
2446 $extrahead = $this->objAdmin->extrahead;
2450 'extrahead' => &$extrahead,
2451 'action' => $this->objAdmin->action
2459 * AdminActions::parse_getblogsetting()
2460 * Parse skinvar getblogsetting
2462 public function parse_getblogsetting($which)
2470 elseif ( $bid = intRequestVar('blogid') )
2473 $b = $manager->getBlog($bid);
2483 return ENTITY::hsc($b->getID(), ENT_QUOTES);
2486 return ENTITY::hsc($b->getURL(), ENT_QUOTES);
2489 return ENTITY::hsc($b->getName(), ENT_QUOTES);
2492 return ENTITY::hsc($b->getDescription(), ENT_QUOTES);
2495 return ENTITY::hsc($b->getShortName(), ENT_QUOTES);
2497 case 'notifyaddress':
2498 return ENTITY::hsc($b->getNotifyAddress(), ENT_QUOTES);
2501 return ENTITY::hsc($b->getMaxComments(), ENT_QUOTES);
2504 return ENTITY::hsc($b->getUpdateFile(), ENT_QUOTES);
2507 return ENTITY::hsc($b->getTimeOffset(), ENT_QUOTES);
2514 * Actions::parse_geteditpluginfo()
2515 * Parse skinvar geteditpluginfo
2517 * @param string $type name of setting for edit plugin info
2520 public function parse_geteditpluginfo($type)
2522 $pid = intRequestVar('plugid');
2529 return Entity::hsc(getPluginNameFromPid($pid));
2536 * Actions::parse_getmember()
2537 * Parse skinvar getmember
2538 * (includes a member info thingie)
2540 * @param string $what name of setting for member
2543 public function parse_getmember($what)
2545 global $memberinfo, $member;
2546 // 1. only allow the member-details-page specific variables on member pages
2547 if ( $this->skintype == 'member' )
2552 return Entity::hsc($memberinfo->getDisplayName());
2555 return Entity::hsc($memberinfo->getRealName());
2558 return Entity::hsc($memberinfo->getNotes());
2561 return Entity::hsc($memberinfo->getURL());
2564 return Entity::hsc($memberinfo->getEmail());
2567 return Entity::hsc($memberinfo->getID());
2571 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2572 if ( $member->isLoggedIn() )
2577 return $member->getDisplayName();
2579 case 'yourrealname':
2580 return $member->getRealName();
2583 return $member->getNotes();
2586 return $member->getURL();
2589 return $member->getEmail();
2592 return $member->getID();
2600 * Actions::parse_headmessage()
2601 * Parse skinvar headmessage
2606 public function parse_headmessage()
2608 if ( !empty($this->objAdmin->headMess) )
2610 echo '<p>' . _MESSAGE . ': ' . Entity::hsc($this->objAdmin->headMess) . "</p>\n";
2616 * Actions::parse_helplink()
2617 * Parse skinvar helplink
2619 * @param string $topic name of topic for help
2622 public function parse_helplink($topic = '')
2624 if ( empty($topic) )
2633 * Actions::parse_helpplugname()
2634 * Parse skinvar helpplugname
2639 public function parse_helpplugname()
2641 $plugid = intGetVar('plugid');
2642 Entity::hsc(getPluginNameFromPid($plugid));
2647 * Actions::parse_ilistaddnew()
2648 * Parse skinvar ilistaddnew
2653 public function parse_ilistaddnew()
2655 $blogid = intRequestVar('blogid');
2656 if ( intPostVar('start') == 0 )
2658 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
2664 * Actions::parse_importskininfo()
2665 * Parse skinvar importskininfo
2667 * @param string $type name of information for imported skin
2670 public function parse_importskininfo($type)
2675 echo Entity::hsc(requestVar('skininfo'));
2678 $dataArr = requestArray('skinnames');
2679 echo implode(' <em>' . _AND . '</em> ', $dataArr);
2682 $dataArr = requestArray('tpltnames');
2683 echo implode(' <em>' . _AND . '</em> ', $dataArr);
2686 $dataArr = requestArray('skinclashes');
2687 echo implode(' <em>' . _AND . '</em> ', $dataArr);
2690 $dataArr = requestArray('tpltclashes');
2691 echo implode(' <em>' . _AND . '</em> ', $dataArr);
2694 echo Entity::hsc(requestVar('skinfile'));
2697 echo Entity::hsc(requestVar('mode'));
2704 * Actions::parse_inputyesno()
2705 * Parse skinvar inputyesno
2707 * @param string $name
2708 * @param string $checkedval
2709 * @param string $tabindex
2710 * @param string $value1
2711 * @param string $value2
2712 * @param string $yesval
2713 * @param string $noval
2714 * @param string $isAdmin
2715 * @param string $templateName
2718 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
2720 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
2725 * Actions::parse_insertpluginfo()
2726 * Parse templatevar insertpluginfo
2728 public function parse_insertpluginfo($type)
2730 $option = $this->objAdmin;
2734 return $option['pid'];
2737 return Entity::hsc($option['pfile']);
2744 * Actions::parse_insertpluginoptions()
2745 * Parse skinvar insertpluginoptions
2747 * @param string $templateName name of template
2750 public function parse_insertpluginoptions($templateName = '')
2752 $options = $this->objAdmin->aOptions;
2753 $template = array();
2754 $templats = array();
2756 if ( $templateName )
2758 $templates = Template::read($templateName);
2760 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
2762 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
2766 $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
2768 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
2770 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
2774 $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
2779 foreach ( $options as $option )
2781 $handler = new Actions($this->skintype, $template, $option);
2782 $parser = new PARSER(Actions::getDefinedActions(), $handler);
2784 if ( $prevPid != $option['pid'] )
2786 $prevPid = $option['pid'];
2787 $parser->parse($template['title']);
2789 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
2790 if ( @$meta['access'] != 'hidden' )
2792 $parsed = $parser->parse($template['body']);
2799 * Actions::parse_insplugoptcontent()
2800 * Parse skinvar insplugoptcontent
2805 public function parse_insplugoptcontent()
2807 $option = $this->objAdmin->aOption;
2809 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
2810 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
2813 listplug_plugOptionRow($option);
2820 * Actions::parse_iprangeinput()
2821 * Parse skinvar iprangeinput
2826 public function parse_iprangeinput()
2828 if ( requestVar('ip') )
2830 $iprangeVal = Entity::hsc(requestVar('ip'));
2831 echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
2832 echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
2833 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
2834 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
2835 echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
2839 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
2840 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
2846 * Actions::parse_itemnavlist()
2847 * Parse skinvar itemnavlist
2852 public function parse_itemnavlist()
2854 global $CONF, $manager, $member;
2855 if ( $this->skintype == 'itemlist' )
2857 $blogid = intRequestVar('blogid');
2858 $blog =& $manager->getBlog($blogid);
2860 if ( postVar('start') )
2862 $start = intPostVar('start');
2869 // amount of items to show
2870 if ( postVar('amount') )
2872 $amount = intPostVar('amount');
2876 $amount = intval($CONF['DefaultListSize']);
2882 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
2883 . " FROM %s, %s, %s"
2884 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid;";
2886 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
2888 if ( $this->skintype == 'itemlist' )
2890 $query .= 'and iblog = ' . $blogid;
2891 $template['now'] = $blog->getCorrectTime(time());
2893 // non-blog-admins can only edit/delete their own items
2894 if ( !$member->blogAdminRights($blogid) )
2896 $query .= ' and iauthor = ' . $member->getID();
2899 elseif ( $this->skintype == 'browseownitems' )
2901 $query .= 'and iauthor = ' . $member->getID();
2903 $template['now'] = time();
2906 // search through items
2907 $search = postVar('search');
2909 if ( !empty($search) )
2911 $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
2912 . ' OR (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
2913 . ' OR (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
2915 $query .= ' ORDER BY itime DESC'
2916 . " LIMIT {$start},{$amount}";
2918 $template['content'] = 'itemlist';
2920 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
2921 $navList->showBatchList('item', $query, 'table', $template);
2926 * Actions::parse_jstoolbaroptions()
2927 * Parse skinvar jstoolbaroptions
2932 public function parse_jstoolbaroptions()
2936 _SETTINGS_JSTOOLBAR_NONE,
2937 _SETTINGS_JSTOOLBAR_SIMPLE,
2938 _SETTINGS_JSTOOLBAR_FULL
2941 foreach ( $options as $option )
2943 $text = "<option value=\"%d\"%s>%s</option>\n";
2944 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
2945 echo sprintf($text, $i, $extra, $option);
2952 * Actions::parse_localeselectoptions()
2953 * Parse skinvar localeselectoptions
2958 public function parse_localeselectoptions()
2960 $locales = i18n::get_available_locale_list();
2961 $memid = intRequestVar('memberid');
2964 $mem = MEMBER::createFromID($memid);
2965 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
2967 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
2971 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
2976 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
2978 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
2981 foreach ( $locales as $locale )
2985 if ( $locale == $mem->getLocale() )
2987 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
2991 echo "<option value=\"{$locale}\">{$locale}</option>\n";
2996 if ( $locale == i18n::get_current_locale() )
2998 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3002 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3010 * Actions::parse_listplugplugoptionrow()
3011 * Parse templatevar listplugplugoptionrow
3013 * @param string $templateName name of template
3016 public function parse_listplugplugoptionrow($templateName = '')
3018 $option = $this->objAdmin;
3019 echo listplug_plugOptionRow($option, $templateName);
3024 * Actions::parse_mediadirwarning()
3025 * Parse skinvar mediadirwarning
3030 public function parse_mediadirwarning()
3033 if ( !is_dir($DIR_MEDIA) )
3035 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3037 if ( !is_readable($DIR_MEDIA) )
3039 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3041 if ( !is_writeable($DIR_MEDIA) )
3043 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3049 * Actions::parse_movedistselect()
3050 * Parse skinvar movedistselect
3052 public function parse_movedistselect()
3054 $actionType = requestVar('action');
3055 switch ( $actionType )
3058 $this->objAdmin->selectBlogCategory('destcatid');
3060 case 'batchcategory':
3061 $this->objAdmin->selectBlog('destblogid');
3064 if ( $this->skintype == 'itemmove' )
3066 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3067 $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
3068 $catid = quickQuery(sprintf($query, intRequestVar('itemid')));
3069 $this->objAdmin->selectBlogCategory('catid', $catid, 10, 1);
3077 * Actions::parse_moveitemid()
3078 * Parse skinvar moveitemid
3083 public function parse_moveitemid()
3085 echo intRequestVar('itemid');
3090 * Actions::parse_newestcompare()
3091 * Parse skinvar newestcompare
3096 public function parse_newestcompare()
3099 $newestVersion = getLatestVersion();
3100 $newestCompare = str_replace('/', '.', $newestVersion);
3101 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3102 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3104 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3105 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3111 * Actions::parse_newmemberselect()
3112 * Parse skinvar newmemberselect
3114 * @param string $templateName name of template to use
3117 public function parse_newmemberselect($templateName = '')
3119 $blogid = intRequestVar('blogid');
3121 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3122 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3123 $res = sql_query($query);
3126 while ( $tmember = sql_fetch_object($res) )
3128 $tmem[] = intval($tmember->tmember);
3131 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3132 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3134 $template['name'] = 'memberid';
3135 $template['tabindex'] = 10000;
3136 Showlist($query, 'select', $template, $templateName);
3141 * Actions::parse_newpluginlist()
3142 * Parse skinvar newpluginlist
3147 public function parse_newpluginlist()
3149 $candidates = $this->newPlugCandidates;
3150 foreach ( $candidates as $name )
3152 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3158 * Actions::parse_outputspecialdirs()
3159 * Parse skinvar outputspecialdirs
3161 * @param string $type type of setting for directory
3164 public function parse_outputspecialdirs($type)
3169 global $DIR_NUCLEUS;
3170 echo Entity::hsc($DIR_NUCLEUS);
3174 echo Entity::hsc($DIR_MEDIA);
3181 * Actions::parse_passrequestvars()
3182 * Parse skinvar passrequestvars
3187 public function parse_passrequestvars()
3189 $oldaction = postVar('oldaction');
3190 if ( ($oldaction != 'logout')
3191 && ($oldaction != 'login')
3192 && $this->objAdmin->passvar
3193 && !postVar('customaction') )
3201 * Actions::parse_pluginextras()
3202 * Parse skinvar pluginextras
3204 * @param string $type type of plugin context
3207 public function parse_pluginextras($type = 'global')
3213 $id = intRequestVar('memberid');
3214 $mem = MEMBER::createFromID($id);
3216 'MemberSettingsFormExtras',
3223 $id = intRequestVar('blogid');
3224 $blg = $manager->getBlog($id);
3226 'BlogSettingsFormExtras',
3234 'GeneralSettingsFormExtras',
3244 * Actions::parse_pluginhelp()
3245 * Parse skinvar pluginhelp
3250 public function parse_pluginhelp()
3252 global $manager, $DIR_PLUGINS;
3253 $plugid = intGetVar('plugid');
3254 $plugName = getPluginNameFromPid($plugid);
3255 $plug =& $manager->getPlugin($plugName);
3257 if ( $plug->supportsFeature('HelpPage') > 0 )
3259 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3260 if ( @file_exists($helpfile . 'php') )
3262 @include($helpfile . 'php');
3265 elseif ( @file_exists($helpfile . 'html') )
3267 @include($helpfile . 'html');
3271 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3272 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3277 * Actions::parse_pluginlistlist()
3278 * Parse skinvar pluginlistlist
3280 * @param string $templateName name of template to use
3283 public function parse_pluginlistlist($templateName = '')
3285 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3286 $query = sprintf($query, sql_table('plugin'));
3287 $template['content'] = 'pluginlist';
3288 $template['tabindex'] = 10;
3289 Showlist($query, 'table', $template, $templateName);
3294 * Actions::parse_pluginoptions()
3295 * Parse skinvar pluginoptions
3297 * @param string $type type of plugin option
3300 public function parse_pluginoptions($type = 'global')
3305 $id = intRequestVar('memberid');
3308 $id = intRequestVar('blogid');
3311 $id = intRequestVar('catid');
3314 $this->objAdmin->_insertPluginOptions($type, $id);
3319 * Actions::parse_qmenuaddselect()
3320 * Parse skinvar qmanuaddselect
3322 * @param string $templateName name of template to use
3325 public function parse_qmenuaddselect($templateName = '')
3328 $showAll = requestVar('showall');
3329 if ( $member->isAdmin() && ($showAll == 'yes') )
3331 // Super-Admins have access to all blogs! (no add item support though)
3332 $query = 'SELECT bnumber as value, bname as text'
3333 . ' FROM ' . sql_table('blog')
3334 . ' ORDER BY bname';
3338 $query = 'SELECT bnumber as value, bname as text'
3339 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
3340 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
3341 . ' ORDER BY bname';
3343 $template['name'] = 'blogid';
3344 $template['tabindex'] = 15000;
3345 $template['extra'] = _QMENU_ADD_SELECT;
3346 $template['selected'] = -1;
3347 $template['shorten'] = 10;
3348 $template['shortenel'] = '';
3349 $template['javascript'] = 'onchange="return form.submit()"';
3350 Showlist($query, 'select', $template, $templateName);
3355 * Actions::parse_quickmenu()
3356 * Parse skinvar quickmenu
3358 * @param string $templateName name of template to use
3361 public function parse_quickmenu($templateName = '')
3364 $templates = array();
3365 $template = array();
3366 if ( !empty($templateName) )
3368 $templates = Template::read($templateName);
3370 $pluginExtras = array();
3374 'options' => &$pluginExtras
3377 if ( count($pluginExtras) > 0 )
3379 if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
3381 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
3385 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
3387 $handler = new Actions($this->skintype, $template, $this->objAdmin);
3388 $parser = new PARSER(Actions::getDefinedActions(), $handler);
3389 $parser->parse($template['title']);
3391 if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3393 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3397 $template['head'] = '<ul>';
3400 echo $template['head'];
3402 if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
3404 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3408 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
3411 foreach ( $pluginExtras as $aInfo )
3414 'plugadminurl' => Entity::hsc($aInfo['url']),
3415 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
3416 'plugadmintitle' => Entity::hsc($aInfo['title']),
3418 echo TEMPLATE::fill($template['body'], $data);
3420 if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3422 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3426 $template['foot'] = '</ul>';
3428 echo $template['foot'];
3434 * Actions::parse_requestblogid()
3435 * Parse skinvar requestblogid
3440 public function parse_requestblogid()
3442 echo intRequestVar('blogid');
3447 * Actions::parse_requestiprange()
3448 * Parse skinvar requestiprange
3453 public function parse_requestiprange()
3455 if ( requestVar('iprange') )
3457 echo Entity::hsc(requestVar('iprange'));
3459 elseif ( requestVar('ip') )
3461 echo Entity::hsc(requestVar('ip'));
3467 * Actions::parse_selectlocaladminskinfiles()
3468 * Parse skinvar selectlocaladminskinfiles
3473 public function parse_selectlocaladminskinfiles()
3475 global $DIR_ADMINSKINS, $manager;
3476 $candidates = SkinImport::searchForCandidates($DIR_ADMINSKINS);
3477 foreach ( $candidates as $skinname => $skinfile )
3479 $html = Entit::hsc($skinfile);
3480 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
3486 * Actions::parse_selectlocalskinfiles()
3487 * Parse skinvar selectlocalskinfiles
3492 public function parse_selectlocalskinfiles()
3495 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
3496 foreach ( $candidates as $skinname => $skinfile )
3498 $html = Entity::hsc($skinfile);
3499 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
3505 * Actions::parse_skineditallowedlist()
3506 * Parse skinvar skineditallowedlist
3508 * @param string $type type of skin
3509 * @param string $templateName name of template
3512 public function parse_skineditallowedlist($type, $templateName = '')
3517 $query = "SELECT bshortname, bname FROM %s";
3519 'content' => 'shortblognames'
3521 $query = sprintf($query, sql_table('blog'));
3522 Showlist($query, 'table', $show, $templateName);
3525 $query = "SELECT tdname as name, tddesc as description FROM %s";
3527 'content' => 'shortnames'
3529 $query = sprintf($query, sql_table('template_desc'));
3530 Showlist($query, 'table', $show, $templateName);
3537 * Actions::parse_skinfile()
3538 * Inserts an url relative to the skindir (useful when doing import/export)
3540 * e.g. <skinfile(default/myfile.sth)>
3542 * @param string $filename file name for skin
3545 public function parse_skinfile($filename)
3548 * TODO: we should decide to use different directory or default $DIR_SKINS
3549 $base = NP_SkinableAdmin::getAdminSkinURL();
3550 $pref = PARSER::getProperty('IncludePrefix');
3551 echo $base . $pref . $filename;
3553 $pref = PARSER::getProperty('IncludePrefix');
3554 echo $pref . $filename;
3559 * Actions::parse_skinielist()
3560 * Parse skinvar skinielist
3562 * @param string $type type of skin
3563 * @param string $templateName name of template to use
3566 public function parse_skinielist($type, $templateName = '')
3568 $templates = array();
3569 if ( $templateName )
3571 $templates = Template::read($templateName);
3573 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
3575 $template = $templates['SKINIE_EXPORT_LIST'];
3579 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
3580 . "<td><%expdesc%></td>\n"
3586 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
3587 while ( $skinObj = sql_fetch_object($res) )
3590 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
3591 'expid' => 'skinexp' . $skinObj->sdnumber,
3592 'expname' => Entity::hsc($skinObj->sdname),
3593 'expdesc' => Entity::hsc($skinObj->sddesc),
3595 echo TEMPLATE::fill($template, $data);
3599 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3600 while ($templateObj = sql_fetch_object($res)) {
3602 'typeid' => 'template[' . $templateObj->tdnumber . ']',
3603 'expid' => 'templateexp' . $templateObj->tdnumber,
3604 'expname' => Entity::hsc($templateObj->tdname),
3605 'expdesc' => Entity::hsc($templateObj->tddesc),
3607 echo TEMPLATE::fill($template, $data);
3615 * Actions::parse_skinoverview()
3616 * Parse skinvar skinoverview
3618 * @param string $templateName name of template to use
3621 public function parse_skinoverview($templateName = '')
3623 $query = "SELECT * FROM %s ORDER BY sdname";
3624 $query = sprintf($query, sql_table('skin_desc'));
3626 $template['content'] = 'skinlist';
3627 $template['tabindex'] = 10;
3629 Showlist($query, 'table', $template, $templateName);
3634 * Actions::parse_skintypehelp()
3635 * Check editing skintypehelp
3640 public function parse_skintypehelp()
3642 $nowSkinType = strtolower(trim(requestVar('type')));
3643 $regularType = array(
3654 if ( in_array($nowSkinType, $regularType) )
3656 help('skinpart' . $nowSkinType);
3660 help('skinpartspecial');
3666 * Actions::parse_specialskinlist()
3667 * Parse skinvar specialskinlist
3669 * @param string $templateName name of template to use
3672 public function parse_specialskinlist($templateName = '')
3674 $templates = array();
3675 if ( $templateName )
3677 $templates = Template::read($templateName);
3689 $skinid = intRequestVar('skinid');
3690 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
3691 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
3693 $res = sql_query($query);
3694 if ( $res && sql_num_rows($res) > 0 )
3697 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
3699 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
3703 $template['head'] = "<ul>\n";
3705 echo TEMPLATE::fill($template['head'], $data);
3706 if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
3708 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
3712 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
3713 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
3714 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
3717 while ( $row = sql_fetch_assoc($res) )
3720 'tabindex' => $tabstart++,
3721 'skinid' => $skinid,
3722 'skintype' => Entity::hsc(strtolower($row['stype']))
3724 echo TEMPLATE::fill($template['body'], $data);
3727 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
3729 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
3733 $template['foot'] = "</ul>\n";
3735 echo TEMPLATE::fill($template['foot'], $data);
3741 * Actions::parse_sprinttext()
3744 * @param string $which
3745 * @param string $val
3748 public function parse_sprinttext($which, $val)
3750 if ( !defined($which) )
3756 $base = constant($which);
3759 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
3761 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
3763 $met = 'parse_' . $matchies[0];
3767 $arg = trim($args[0], '()');
3768 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
3771 if ( method_exists($this, $met) )
3773 $value = call_user_func(array(&$this, $met), $arg);
3777 if ( !isset($value) || empty($value) )
3781 echo sprintf($base, $value);
3786 * Actions::parse_systemsettings()
3787 * Parse skinvar systemsettings
3789 * @param string $type type of settings for system
3790 * @param string $templateName name of template to use
3793 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
3795 global $member, $CONF, $nucleus;
3797 $member->isAdmin() or $this->objAdmin->disallow();
3799 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
3800 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
3807 case 'sqlserverinfo':
3808 echo sql_get_server_info();
3810 case 'sqlclientinfo':
3811 echo sql_get_client_info();
3813 case 'magicquotesgpc':
3814 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
3816 case 'magicquotesruntime':
3817 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
3819 case 'registerglobals':
3820 echo ini_get('register_globals') ? 'On' : 'Off';
3823 $templates = array();
3824 if ( $templateName )
3826 $templates = Template::read($templateName);
3828 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
3830 $template = $templates['SYSTEMINFO_GDSETTINGS'];
3834 $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
3837 $gdinfo = gd_info();
3839 foreach ( $gdinfo as $key => $value )
3841 if ( is_bool($value) )
3843 $value = $value ? $enable : $disable;
3847 $value = Entity::hsc($value);
3853 echo TEMPLATE::fill($template, $data);
3858 phpinfo(INFO_MODULES);
3859 $im = ob_get_contents();
3861 echo (strstr($im, 'mod_rewrite') != '') ? $enable : $disable;
3863 case 'nucleusversion':
3864 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
3866 case 'nucleuspatchlevel':
3867 echo getNucleusPatchLevel();
3873 echo $CONF['ItemURL'];
3875 case 'alertonheaderssent':
3876 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
3878 case 'nucleuscodename':
3879 if ( $nucleus['codename'] != '' )
3881 echo ' "' . $nucleus['codename'] . '"';
3884 case 'versioncheckurl':
3885 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
3892 * Actions::parse_templateoverview()
3893 * Parse skinvar templateoverview
3895 * @param string $templateName name of template to use
3898 public function parse_templateoverview($templateName = '')
3900 $query = "SELECT * FROM %s ORDER BY tdname";
3901 $query = sprintf($query, sql_table('template_desc'));
3902 $template['content'] = 'templatelist';
3903 $template['tabindex'] = 10;
3904 Showlist($query, 'table', $template, $templateName);
3909 * AdminActions::parse_ticket()
3915 public function parse_ticket()
3918 $manager->addTicketHidden();
3923 * Actions::parse_versioncheckurl()
3924 * Parse skinvar versioncheckurl
3929 public function parse_versioncheckurl()
3931 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
3936 * Actions::parse_yrbloglist()
3937 * Parse skinvar yrbloglist
3939 * @param string $templateName name of template to use
3942 public function parse_yrbloglist($templateName = '')
3945 $showAll = requestVar('showall');
3947 if ( $member->isAdmin() && ($showAll == 'yes') )
3949 // Super-Admins have access to all blogs! (no add item support though)
3950 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
3952 . " ORDER BY bnumber";
3953 $query = sprintf($query, sql_table('blog'));
3957 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
3959 . " WHERE tblog=bnumber and tmember=%d"
3960 . " ORDER BY bnumber";
3961 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3964 $template['content'] = 'bloglist';
3965 $template['superadmin'] = $member->isAdmin();
3967 $amount = Showlist($query, 'table', $template, $templateName);
3969 if ( ($showAll != 'yes') && ($member->isAdmin()) )
3971 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
3973 $total = quickQuery($query);
3974 if ( $total > $amount )
3976 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
3982 echo _OVERVIEW_NOBLOGS;
3984 elseif( $amount != 0 )
3986 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
3988 $query = "SELECT ititle, inumber, bshortname"
3990 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
3991 $query = sprintf($query. sql_table('item'), sql_table('blog'), (integer) $member->getID());
3993 $template['content'] = 'draftlist';
3995 $amountdrafts = Showlist($query, 'table', $template, $templateName);
3996 if ( $amountdrafts == 0 )
3998 echo _OVERVIEW_NODRAFTS;
4005 * Actions::customHelp()
4006 * shows a link to custom help file
4008 * @param integer $id
4009 * @param string $tplName
4010 * @param string $url
4011 * @param string $iconURL
4012 * @param string $alt
4013 * @param string $title
4017 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4019 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4023 * Actions::customHelpHtml()
4025 * @param integer $id
4026 * @param string $tplName
4027 * @param string $url
4028 * @param string $iconURL
4029 * @param string $alt
4030 * @param string $title
4031 * @param string $onclick
4032 * @return string anchor element with help uri
4034 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4036 $templates = array();
4039 $templates = Template::read($tplName);
4041 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
4043 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
4047 $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
4050 if ( empty($iconURL) )
4053 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
4055 if ( function_exists('getimagesize') )
4057 $size = getimagesize($iconURL);
4058 $width = 'width="' . $size[0] . '" ';
4059 $height = 'height="' . $size[1] . '" ';
4062 'iconurl' => $iconURL,
4064 'height' => $height,
4065 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
4066 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
4068 $icon = TEMPLATE::fill($template, $data);
4069 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
4070 return $help . $icon;
4074 * Actions::input_yesno
4077 * @param $checkedval
4084 * @param $templateName
4087 private function input_yesno($name,
4098 $templates = array();
4099 if ( $templateName )
4101 $templates = Template::read($templateName);
4104 if ( $name == 'admin' )
4106 if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
4108 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
4112 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
4113 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
4114 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
4115 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
4120 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
4122 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
4126 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
4128 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
4131 if ( !isset($template) )
4133 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
4134 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
4135 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
4136 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
4141 $id = Entity::hsc($name);
4142 $id = str_replace('[', '-', $id);
4143 $id = str_replace(']', '-', $id);
4144 $id1 = $id . Entity::hsc($value1);
4145 $id2 = $id . Entity::hsc($value2);
4147 'name' => Entity::hsc($name),
4148 'yesval' => Entity::hsc($value1),
4149 'noval' => Entity::hsc($value2),
4152 'yesvaltext' => $yesval,
4153 'novaltext' => $noval,
4154 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
4155 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
4156 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
4161 return Template::fill($template, $dat);
4165 echo TEMPLATE::fill($template, $dat);
4171 * AdminActions::parse_text()
4174 * FIXME: is this really needed?
4176 * @param string $which constant vallue
4179 public function parse_text($which)
4181 if ( defined($which) )
4183 echo constant($which);