2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
8 class AdminActions extends BaseActions
12 /* NOTE: list of whole available action names for tags
22 'adminskineditallowedlist',
25 'adminskinselectoptions',
26 'adminspecialskinlist',
27 'admintemplateoverview',
28 'allowedadminskinactions',
50 'configsettingsyesno',
52 'createaccountsuccess',
53 'createaccountdisable',
56 'defaultadminskintypes',
66 'editadmintemplateinfo',
72 'editplugoptionslist',
92 'listplugplugoptionrow',
93 'localeselectoptions',
110 'selectlocaladminskinfiles',
111 'selectlocalskinfiles',
112 'skineditallowedlist',
129 * AdminActions::$default_actions
130 * list of whole action names with which this class can deal
132 static private $default_actions = array(
156 * AdminActions::$skin_type_friendly_names
157 * friendly name for wrapped page types
159 static private $default_skin_types = array(
160 'actionlog' => _ADM_SKPRT_ACTIONLOG,
161 'activate' => _ADM_SKPRT_ACTIVATE,
162 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
163 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
164 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
165 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
166 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
167 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
168 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
169 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
170 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
171 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
172 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
173 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
174 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
175 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
176 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
177 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
178 'banlist' => _ADM_SKPRT_BANLIST,
179 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
180 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
181 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
182 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
183 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
184 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
185 'batchitem' => _ADM_SKPRT_BATCHITEM,
186 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
187 'batchmove' => _ADM_SKPRT_BATCHMOVE,
188 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
189 'batchteam' => _ADM_SKPRT_BATCHTEAM,
190 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
191 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
192 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
193 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
194 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
195 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
196 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
197 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
198 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
199 'createitem' => _ADM_SKPRT_CREATEITEM,
200 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
201 'createaccountinput' => _ADM_SKPRT_CREATEACCOUNTINPUT, /* not yet */
202 'createaccountsuccess' => _ADM_SKPRT_CREATEACCOUNTSUCCESS, /* not yet */
203 'createaccountdisable' => _ADM_SKPRT_CREATEACCOUNTDISALLOWED, /* not yet */
204 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
205 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
206 'forgotpassword' => _ADM_SKPRT_FORGOTPASSWORD, /* not yet */
207 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
208 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
209 'itemedit' => _ADM_SKPRT_ITEMEDIT,
210 'itemlist' => _ADM_SKPRT_ITEMLIST,
211 'itemmove' => _ADM_SKPRT_ITEMMOVE,
212 'login' => FALSE, //missing
213 'manage' => _ADM_SKPRT_MANAGE,
214 'manageteam' => _ADM_SKPRT_MANAGETEAM,
215 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
216 'memberedit' => FALSE, //missing
217 'overview' => _ADM_SKPRT_OVERVIEW,
218 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
219 'pagehead' => _ADM_SKPRT_PAGEHEAD,
220 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
221 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
222 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
223 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
224 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
225 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
226 'skindelete' => _ADM_SKPRT_SKINDELETE,
227 'skinedit' => _ADM_SKPRT_SKINEDIT,
228 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
229 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
230 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
231 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
232 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
233 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
234 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
235 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
236 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
237 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
238 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
239 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
243 * AdminActions::getAvailableSkinTypes()
247 * @return array list of friendly names for page actions
249 static public function getAvailableSkinTypes()
251 return self::$default_skin_types;
255 * AdminActions::getDefaultTypes()
259 * @return array list of friendly names for page actions
261 static public function getDefaultTypes()
263 return self::$default_skin_types;
267 * AdminActions::__construct()
268 * Constructor for a new Actions object
270 * @param string $type
273 public function __construct($type)
275 // call constructor of superclass first
276 parent::__construct();
277 $this->skintype = $type;
278 if ( !class_exists('Navlist') || !class_exists('Batch') )
281 include $DIR_LIBS . 'ENCAPSULATE.php';
287 * AdminActions::getAvailableActions()
290 * @return array allowed actions for the page type
292 public function getAvailableActions()
294 $extra_actions = array();
296 switch ( $this->skintype )
299 $extra_actions = array(
304 $extra_actions = array(
309 case 'activatesetpwd':
310 $extra_actions = array(
314 $extra_actions = array(
320 case 'adminerrorpage':
321 $extra_actions = array(
324 case 'adminskindelete':
325 $extra_actions = array(
329 case 'adminskinedit':
330 $extra_actions = array(
332 'defaultadminskintypes',
333 'adminspecialskinlist',
336 case 'adminskinedittype':
337 $extra_actions = array(
340 'allowedadminskinactions',
341 'adminskineditallowedlist',
344 case 'adminskiniedoimport':
345 $extra_actions = array(
349 case 'adminskinieimport':
350 $extra_actions = array(
354 case 'adminskinieoverview':
355 $extra_actions = array(
356 'selectlocaladminskinfiles',
360 case 'adminskinoverview':
361 $extra_actions = array(
365 case 'adminskinremovetype':
366 $extra_actions = array(
370 case 'admintemplatedelete':
371 $extra_actions = array(
372 'editadmintemplateinfo',
374 case 'admintemplateedit':
375 $extra_actions = array(
376 'editadmintemplateinfo',
379 case 'admntemplateoverview':
380 $extra_actions = array(
381 'admintemplateoverview',
384 case 'backupoverview':
385 $extra_actions = array(
388 case 'backuprestore':
389 $extra_actions = array(
393 $extra_actions = array(
399 case 'banlistdelete':
400 $extra_actions = array(
405 case 'banlistdeleteconfirm':
406 $extra_actions = array(
407 'banlistdeletedlist',
412 $extra_actions = array(
418 case 'batchcategory':
419 $extra_actions = array(
425 $extra_actions = array(
431 $extra_actions = array(
437 $extra_actions = array(
443 $extra_actions = array(
449 $extra_actions = array(
458 $extra_actions = array(
467 $extra_actions = array(
473 case 'blogcommentlist':
474 $extra_actions = array(
481 $extra_actions = array(
497 $extra_actions = array(
501 case 'browseowncomments':
502 $extra_actions = array(
506 case 'browseownitems':
507 $extra_actions = array(
511 case 'categorydelete':
512 $extra_actions = array(
518 $extra_actions = array(
525 case 'commentdelete':
526 $extra_actions = array(
531 $extra_actions = array(
535 case 'createaccountinput':
536 $extra_actions = array(
542 case 'createaccountsuccess':
543 $extra_actions = array(
\r
547 case 'createaccountdisable':
548 $extra_actions = array(
553 $extra_actions = array(
565 $extra_actions = array(
571 $extra_actions = array(
576 case 'editmembersettings':
577 $extra_actions = array(
578 'adminskinselectoptions',
580 'localeselectoptions',
584 case 'forgotpassword':
585 $extra_actions = array(
589 case 'itemcommentlist':
590 $extra_actions = array(
596 $extra_actions = array(
603 $extra_actions = array(
615 $extra_actions = array(
622 $extra_actions = array(
628 $extra_actions = array(
632 $extra_actions = array(
641 $extra_actions = array(
646 $extra_actions = array(
651 $extra_actions = array(
656 $extra_actions = array(
662 $extra_actions = array(
667 case 'pluginoptions':
668 $extra_actions = array(
670 'editplugoptionslist',
674 $extra_actions = array(
677 'configsettingsedit',
678 'configsettingsyesno',
681 'localeselectoptions',
687 $extra_actions = array(
692 $extra_actions = array(
697 $extra_actions = array(
703 $extra_actions = array(
706 'allowedskinactions',
707 'skineditallowedlist',
708 'skineditallowedlist',
711 case 'skiniedoimport':
712 $extra_actions = array(
717 $extra_actions = array(
721 case 'skinieoverview':
722 $extra_actions = array(
723 'selectlocalskinfiles',
728 $extra_actions = array(
732 case 'skinremovetype':
733 $extra_actions = array(
737 case 'systemoverview':
738 $extra_actions = array(
743 $extra_actions = array(
749 case 'templatedelete':
750 $extra_actions = array(
755 $extra_actions = array(
759 case 'templateoverview':
760 $extra_actions = array(
764 case 'usermanagement':
765 $extra_actions = array(
771 $extra_actions = array(
780 'selectlocaladminskinfiles',
788 $defined_actions = array_merge(self::$default_actions, $extra_actions);
790 return array_merge($defined_actions, parent::getAvailableActions());
794 * AdminActions::parse_actionloglist()
795 * Parse skinvar actionloglist
797 * @param string $templateName name of template to use
800 public function parse_actionloglist($templateName = '')
802 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
803 $query = sprintf($query, sql_table('actionlog'));
805 $template['content'] = 'actionlist';
806 $amount = showlist($query, 'table', $template, $templateName);
812 * AdminActions::parse_activationmessage()
813 * Parse skinvar activationmessage
815 * @param string $type type of message
816 * @param string $templateName name of template to use
819 public function parse_activationmessage($type, $templateName = '')
821 global $CONF, $manager;
825 if ( !empty($templateName))
827 $template =& $manager->getTemplate($templateName);
830 $key = postVar('ackey');
833 Admin::error(_ERROR_ACTIVATE);
836 $info = MEMBER::getActivationInfo($key);
839 Admin::error(_ERROR_ACTIVATE);
842 $mem =& $manager->getMember($info->vmember);
845 Admin::error(_ERROR_ACTIVATE);
847 switch ( $info->vtype )
850 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
852 $title = $template['ACTIVATE_FORGOT_TITLE'];
856 $title = _ACTIVATE_FORGOT_TITLE;
858 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
860 $text = $template['ACTIVATE_FORGOT_TEXT'];
864 $text = _ACTIVATE_FORGOT_TEXT;
868 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
870 $title = $template['ACTIVATE_REGISTER_TITLE'];
874 $title = _ACTIVATE_REGISTER_TITLE;
876 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
878 $text = $template['ACTIVATE_REGISTER_TEXT'];
882 $text = _ACTIVATE_REGISTER_TEXT;
885 case 'addresschange':
886 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
888 $title = $template['ACTIVATE_CHANGE_TITLE'];
892 $title = _ACTIVATE_CHANGE_TITLE;
894 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
896 $text = $template['ACTIVATE_CHANGE_TEXT'];
900 $text = _ACTIVATE_CHANGE_TEXT;
905 'memberName' => Entity::hsc($mem->getDisplayName()),
906 'realName' => Entity::hsc($mem->getRealName()),
911 echo Template::fill($title, $aVars);
914 echo Template::fill($text, $aVars);
917 echo Entity::hsc($key);
924 * AdminActions::parse_addtickettourl()
925 * Parse skinvar addtickettourl
927 * @param string $url URI for ticket
930 public function parse_addtickettourl($url)
933 $url = $manager->addTicketToUrl($url);
934 echo Entity::hsc($url);
939 * AdminActions::parse_adminbanlist()
940 * Parse skinvar adminbanlist
942 * @param string $templateName name of template to use
945 public function parse_adminbanlist($templateName = '')
947 $blogid = intRequestVar('blogid');
949 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
950 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
952 $template['content'] = 'banlist';
954 $amount = Showlist($query, 'table', $template, $templateName);
964 * AdminActions::parse_adminbatchaction()
965 * Parse skinvar adminbatchaction
970 public function parse_adminbatchaction()
972 echo Entity::hsc(requestVar('batchaction'));
977 * AdminActions::parse_adminbatchlist()
978 * Parse skinvar adminbatchlist
980 * @param string $templateName name of template to use
983 public function parse_adminbatchlist($templateName = '')
986 $templates = array();
988 if ( !empty($templateName) )
990 $templates =& $manager->getTemplate($templateName);
993 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
995 $template = '<li><%text(_BATCH_EXECUTING)%> '
996 . '<b><%adminbatchaction%></b> '
997 . '<%batchlisttype%> '
998 . '<b><%batchid%></b>... '
999 . '<b><%batchlistmsg%></b>'
1004 $template = $templates['ADMIN_BATCHLIST'];
1007 $selected = requestIntArray('batch');
1008 $action = requestVar('batchaction');
1010 switch ( $this->skintype )
1013 $batchlisttype = _BATCH_ONITEM;
1014 $deleteaction = 'deleteOneItem';
1015 $moveaction = 'moveOneItem';
1016 $destid = intRequestVar('destcatid');
1018 case 'batchcomment':
1019 $batchlisttype = _BATCH_ONCOMMENT;
1020 $deleteaction = 'deleteOneComment';
1023 $batchlisttype = _BATCH_ONMEMBER;
1024 $deleteaction = 'deleteOneMember';
1025 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1026 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1027 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1028 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1031 $blogid = intRequestVar('blogid');
1032 $batchlisttype = _BATCH_ONTEAM;
1033 $deleteaction = 'deleteOneTeamMember';
1034 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1035 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1036 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1037 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1039 case 'batchcategory':
1040 $batchlisttype = _BATCH_ONCATEGORY;
1041 $deleteaction = 'deleteOneCategory';
1042 $moveaction = 'moveOneCategory';
1043 $destid = intRequestVar('destblogid');
1047 // walk over all selectedids and perform action
1048 foreach ( $selected as $selectedid )
1051 $selectedid = intval($selectedid);
1055 if ( $this->skintype != 'batchteam' )
1057 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1061 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1065 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
1069 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1073 // there should always remain at least one super-admin
1074 $r = DB::getResult($unsetchksql);
1075 if ( $r->rowCount() < 2 )
1077 $error = $unseterrmsg;
1081 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
1085 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1089 'batchid' => $selectedid,
1090 'batchlisttype' => Entity::hsc($batchlisttype),
1091 'adminbatchaction' => Entity::hsc($action),
1092 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1095 $handler = new AdminActions('template');
1096 $parser = new Parser($handler);
1098 $output = Template::fill($template, $data);
1100 $parser->parse($output);
1101 $output = ob_get_contents();
1103 echo "{$output}<br />";
1109 * AdminActions::parse_adminbloglink()
1110 * Parse skinvar adminbloglink
1112 * @param string $templateName name of template to use
1115 public function parse_adminbloglink($templateName = '')
1118 $blogid = intRequestVar('blogid');
1119 $blog =& $manager->getBlog($blogid);
1120 $templates = array();
1122 if ( !empty($templateName) )
1124 $templates =& $manager->getTemplate($templateName);
1127 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1129 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1133 $template = $templates['ADMIN_BLOGLINK'];
1137 'url' => Entity::hsc($blog->getURL()),
1138 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1139 'blogname' => Entity::hsc($blog->getName())
1142 echo Template::fill($template, $data);
1147 * AdminActions::parse_adminerrormesg()
1148 * Parse skinvar adminerrormesg
1153 public function parse_adminerrormesg()
1158 if ( requestVar('errormessage') )
1160 $message = requestVar('errormessage');
1162 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1164 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1166 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1168 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1170 echo Entity::hsc($message);
1175 * AdminActions::parse_adminskineditallowedlist()
1176 * Parse skinvar adminskineditallowedlist
1178 * @param string $type template/blog
1179 * @param string $templateName name of template to use
1182 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1186 /* TODO: blog seems not to be used */
1188 $query = "SELECT bshortname, bname FROM %s";
1189 $query = sprintf($query, sql_table('blog'));
1191 'content' => 'shortblognames'
1193 Showlist($query, 'table', $show, $templateName);
1196 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1197 $query = sprintf($query, sql_table('template_desc'));
1199 'content' => 'shortnames'
1201 Showlist($query, 'table', $show, $templateName);
1208 * AdminActions::parse_adminskinielist()
1209 * Parse skinvar adminskinielist
1211 * @param string $type skin/template
1212 * @param string $templateName name of template to use
1215 public function parse_adminskinielist($type, $templateName = '')
1219 $templates = array();
1220 if ( $templateName )
1222 $templates =& $manager->getTemplate($templateName);
1225 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1228 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1229 . "<label for=\"<%expid%>\"><%expname%></label>"
1231 . "<td><%expdesc%></td>\n"
1237 $template = $templates['SKINIE_EXPORT_LIST'];
1243 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1244 $query = sprintf($query, sql_table('skin_desc'));
1245 $res = DB::getResult($query);
1247 foreach ( $res as $row )
1250 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1251 'expid' => 'skinexp' . $row['sdnumber'],
1252 'expname' => Entity::hsc($row['sdname']),
1253 'expdesc' => Entity::hsc($row['sddesc']),
1255 echo Template::fill($template, $data);
1259 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1260 $query = sprintf($query, sql_table('template_desc'));
1261 $res = DB::getResult($query);
1262 foreach ( $res as $row )
1265 'typeid' => 'template[' . $row['tdnumber'] . ']',
1266 'expid' => 'templateexp' . $row['tdnumber'],
1267 'expname' => Entity::hsc($row['tdname']),
1268 'expdesc' => Entity::hsc($row['tddesc']),
1270 echo Template::fill($template, $data);
1278 * AdminActions::parse_adminskinoverview()
1279 * Parse skinvar adminskinoverview
1281 * @param string $templateName name of template to use
1284 public function parse_adminskinoverview($templateName = '')
1286 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1287 $query = sprintf($query, sql_table('skin_desc'));
1289 $template['content'] = 'adminskinlist';
1290 $template['tabindex'] = 10;
1291 $template['friendly_names'] = $this->parser->skin->getAvailableTypes();
1292 Showlist($query, 'table', $template, $templateName);
1297 * AdminActions::parse_adminskinselectoptions()
1298 * Parse skinvar adminskinselectoptions
1303 public function parse_adminskinselectoptions($templateName = '')
1306 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1307 $query = sprintf($query, sql_table('skin_desc'));
1309 $template['name'] = 'adminskin';
1310 $template['selected'] = $CONF['AdminSkin'];
1311 $template['tabindex'] = 110;
1312 Showlist($query, 'select', $template, $templateName);
1317 * AdminActions::parse_adminspecialskinlist()
1318 * Parse skinvar adminspecialskinlist
1320 * @param string $templateName name of template to use
1322 public function parse_adminspecialskinlist($templateName = '')
1326 $templates = array();
1327 if ( $templateName )
1329 $templates =& $manager->getTemplate($templateName);
1332 $nType = $this->parser->skin->getAvailableTypes();
1333 $skinid = intRequestVar('skinid');
1335 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1336 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1338 $res = DB::getResult($query);
1339 if ( $res && $res->rowCount() > 0 )
1341 /* NOTE: set templates for HEAD/BODY/FOOT */
1342 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1344 $template['head'] = "<ul>\n";
1348 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1350 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1352 $template['body'] = '<li>'
1353 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1356 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1363 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1365 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1367 $template['foot'] = "</ul>\n";
1371 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1378 echo $template['head'];
1379 foreach ( $res as $row )
1382 'tabindex' => $tabstart++,
1383 'skinid' => $skinid,
1384 'skintype' => Entity::hsc(strtolower($row['stype']))
1386 echo Template::fill($template['body'], $data);
1389 echo $template['foot'];
1395 * AdminActions::parse_admintemplateoverview()
1396 * Parse skinvar admintemplateoverview
1398 * @param string $templateName name of template to use
1401 public function parse_admintemplateoverview($templateName = '')
1403 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1404 $query = sprintf($query, sql_table('template_desc'));
1406 $template['content'] = 'admintemplatelist';
1407 $template['tabindex'] = 10;
1409 Showlist($query, 'table', $template, $templateName);
1414 * AdminActions::parse_allowedadminskinactions()
1415 * Parse skinvar allowedadminskinactions
1420 public function parse_allowedadminskinactions()
1422 global $DIR_ADMINSKINS;
1423 $skinType = strtolower(trim(requestVar('type')));
1424 $actions = $this->parser->skin->getAllowedActionsForType($skinType);
1427 while ( $current = array_shift($actions) )
1429 // TODO: remove this
1430 // skip deprecated vars
1431 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1436 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1438 if ( count($actions) != 0 )
1447 * AdminActions::parse_allowedskinactions()
1448 * Parse skinvar allowedskinactions
1453 public function parse_allowedskinactions()
1455 $skinType = strtolower(trim(requestVar('type')));
1456 $skinid = intRequestVar('skinid');
1458 $skin = new Skin($skinid);
1459 $actions = $skin->getAllowedActionsForType($skinType);
1462 while ( $current = array_shift($actions) )
1464 // TODO: remove this
1465 // skip deprecated vars
1466 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1471 /* TODO: alternative function should be used or not? */
1472 echo helplink("skinvar-{$current}") . "$current</a>\n";
1474 if ( count($actions) != 0 )
1483 * AdminActions::parse_banlistdeletedlist()
1484 * Parse skinvar banlistdeletedlist
1486 * @param string $templateName name of template to use
1489 public function parse_banlistdeletedlist($templateName = '')
1493 $templates = array();
1494 if ( $templateName )
1496 $templates =& $manager->getTemplate($templateName);
1499 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1501 $template = "<li><%blogname%></li>\n";
1505 $template = $templates['BANLIST_DELETED_LIST'];
1508 $deleted = requestArray('delblogs');
1509 foreach ( $deleted as $delblog )
1511 $blog =& $manager->getBlog($delblog);
1513 'blogname' => Entity::hsc($blog->getName())
1515 echo Template::fill($template, $data);
1522 * AdminActions::parse_batchdeletelist()
1523 * Parse skinvar batchdeletelist
1528 public function parse_batchdeletelist()
1530 $selected = requestIntArray('batch');
1533 foreach ( $selected as $select )
1535 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1537 // add hidden vars for team & comment
1538 if ( requestVar('action') == 'batchteam' )
1540 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1542 if ( requestVar('action') == 'batchcomment' )
1544 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1550 * AdminActions::parse_batchdeletetype()
1551 * Parse skinvar batchdeletetype
1556 public function parse_batchdeletetype()
1558 echo Entity::hsc(requestVar('action'));
1563 * AdminActions::parse_batchmovebtn()
1564 * Parse skinvar batchmovebtn
1569 public function parse_batchmovebtn()
1571 $actionType = requestVar('action');
1572 switch ( $actionType )
1577 case 'batchcategory':
1585 * AdminActions::parse_batchmovelist()
1586 * Parse skinvar batchmovelist
1591 public function parse_batchmovelist()
1593 $selected = requestIntArray('batch');
1595 foreach ( $selected as $select )
1597 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1604 * AdminActions::parse_batchmovetitle()
1605 * Parse skinvar batchmovetitle
1610 public function parse_batchmovetitle()
1612 $actionType = requestVar('action');
1613 switch ( $actionType )
1618 case 'batchcategory':
1619 echo _MOVECAT_TITLE;
1626 * AdminActions::parse_batchmovetype()
1627 * Parse skinvar batchmovetype
1632 public function parse_batchmovetype()
1634 echo Entity::hsc(requestVar('action'));
1639 * AdminActions::parse_blogcatlist()
1640 * Parse skinvar blogcatlist
1645 public function parse_blogcatlist($templateName = '')
1648 $blogid = intRequestVar('blogid');
1649 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1650 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1652 $template['content'] = 'categorylist';
1653 $template['tabindex'] = 200;
1655 $batch = new Batch('category');
1656 $batch->showlist($query, 'table', $template, $templateName);
1661 * AdminActions::parse_blogid()
1662 * Parse skinvar blogid
1667 public function parse_blogid()
1669 echo intRequestVar('blogid');
1674 * AdminActions::parse_blognotifysetting()
1675 * Parse skinvar blognotifysetting
1680 public function parse_blognotifysetting($type)
1683 $blogid = intRequestVar('blogid');
1684 $blog =& $manager->getBlog($blogid);
1689 if ( !$blog->notifyOnComment() )
1695 if ( !$blog->notifyOnVote() )
1701 if ( !$blog->notifyOnNewItem() )
1707 echo ' checked="checked"';
1712 * AdminActions::parse_blogsetting()
1713 * Parse skinvar blogsetting
1715 * @param string $which name of weblog setting
1718 public function parse_blogsetting($which)
1720 echo $this->parse_getblogsetting($which);
1725 * AdminActions::parse_blogsettingyesno()
1726 * Parse skinvar blogsettingyesno
1728 * @param string $type type of weblog setting
1729 * @param string $templateName name of template to use
1732 public function parse_blogsettingyesno($type, $templateName = '')
1736 $blogid = intRequestVar('blogid');
1737 $blog =& $manager->getBlog($blogid);
1741 case 'convertbreaks':
1742 $checkedval = $blog->convertBreaks();
1745 case 'allowpastposting':
1746 $checkedval = $blog->allowPastPosting();
1750 $checkedval = $blog->commentsEnabled();
1754 $checkedval = $blog->isPublic();
1758 $checkedval = $blog->emailRequired();
1762 $checkedval = $blog->getSearchable();
1766 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1771 * AdminActions::parse_blogteamlist()
1772 * Parse skinvar blogteamlist
1774 * @param string $templateName name of template to use
1777 public function parse_blogteamlist($templateName = '')
1780 $blogid = intRequestVar('blogid');
1781 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1783 . "WHERE tmember=mnumber AND tblog= %d";
1784 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1786 $template['content'] = 'teamlist';
1787 $template['tabindex'] = 10;
1789 $batch = new Batch('team');
1790 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
1795 * AdminActions::parse_blogteammembers()
1796 * Parse skinvar blogteammembers
1801 public function parse_blogteammembers()
1803 $blogid = intRequestVar('blogid');
1804 $query = "SELECT mname, mrealname "
1806 . "WHERE mnumber=tmember AND tblog=%d;";
1807 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1808 $res = DB::getResult($query);
1809 $memberNames = array();
1810 foreach ( $res as $row )
1812 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1814 echo implode(',', $memberNames);
1818 * AdminActions::parse_blogtime()
1819 * Parse skinvar blogtime
1821 * @param string $type type of time
1822 * @param string $format format for time expression
1823 * @param integer $offset offset of time
1826 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1830 if ( $type != 'blogtime' )
1832 /* return server time */
1833 $timestamp = time() + $offset;
1837 $bid = intRequestVar('blogid');
1838 $b =& $manager->getBlog($bid);
1839 $timestamp = $b->getCorrectTime() + $offset;
1842 echo i18n::formatted_datetime($format, $timestamp);
1847 * AdminActions::parse_bookmarkletadmin()
1848 * Parse skinvar bookmarkletadmin
1853 public function parse_bookmarkletadmin()
1857 $blogid = intRequestVar('blogid');
1859 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1864 * AdminActions::parse_categories()
1865 * Parse skinvar categories
1867 * create category dropdown box
1869 * @param string $type name of setting for category
1872 public function parse_categories($startidx = 0)
1877 $itemid = intRequestVar('itemid');
1878 $item = &$manager->getItem($itemid, 1, 1);
1883 $blogid = intRequestVar('blogid');
1887 $blogid = $item['blogid'];
1889 $blog = &$manager->getBlog($blogid);
1891 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1893 $item['body'] = removeBreaks($item['body']);
1894 $item['more'] = removeBreaks($item['more']);
1897 $contents = array();
1898 if ( requestVar('action') == 'itemedit' )
1903 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1906 $catid = $blog->getDefaultCategory();
1911 $catid = $contents['catid'];
1914 $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
1920 * AdminActions::parse_category()
1921 * Parse skinvar category
1923 * @param string $type name of setting for category
1926 public function parse_category($type = 'name')
1928 echo $this->parse_getcategory($type);
1933 * AdminActions::parse_categorysetting()
1934 * Parse skinvar categorysetting
1936 * @param string $type type in category setting
1939 public function parse_categorysetting($type)
1941 $catid = intRequestVar('catid');
1942 if ( $type == 'id' )
1947 $blogid = intRequestVar('blogid');
1948 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1949 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1950 $row = DB::getRow($query);
1952 if ( $type != 'name' )
1954 echo Entity::hsc($row['cdesc']);
1958 echo Entity::hsc($row['cname']);
1965 * AdminActions::parse_codename()
1966 * Parse templatevar codename
1972 public function parse_checkedonval($value, $name)
1977 $itemid = intRequestVar('itemid');
1978 $item =& $manager->getItem($itemid, 1, 1);
1980 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1982 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1984 $item['body'] = removeBreaks($item['body']);
1985 $item['more'] = removeBreaks($item['more']);
1988 $contents = array();
1989 if ( requestVar('action') == 'itemedit' )
1993 if ( !isset($contents[$name]) )
1995 $contents[$name] = '';
1997 if ($contents[$name] == $value)
1999 echo 'checked="checked"';
2005 * AdminActions::parse_codename()
2006 * Parse templatevar codename
2011 * TODO: is this need???
2013 public function parse_codename()
2016 echo $nucleus['codename'];
2021 * AdminActions::parse_commentnavlist()
2022 * Parse skinvar commentnavlist
2027 public function parse_commentnavlist()
2029 global $CONF, $manager, $member;
2032 if ( postVar('start') )
2034 $start = intPostVar('start');
2041 // amount of items to show
2042 if ( postVar('amount') )
2044 $amount = intPostVar('amount');
2048 $amount = (integer) $CONF['DefaultListSize'];
2054 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2056 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2058 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2060 if ( $this->skintype == 'itemcommentlist' )
2062 $itemid = intRequestVar('itemid');
2063 $query .= " citem={$itemid}";
2064 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2066 $nonComments = _NOCOMMENTS;
2068 elseif ( $this->skintype == 'browseowncomments' )
2071 $query .= ' cmember=' . $member->getID();
2072 $template['canAddBan'] = 0;
2074 $nonComments = _NOCOMMENTS_YOUR;
2076 elseif ( $this->skintype == 'blogcommentlist' )
2079 $query .= ' cblog=' . intRequestVar('blogid');
2080 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2081 $bid = intRequestVar('blogid');
2082 $nonComments = _NOCOMMENTS_BLOG;
2085 $search = postVar('search');
2086 if ( !empty($search) )
2088 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2091 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2093 $template['content'] = 'commentlist';
2095 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2096 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2101 * AdminActions::parse_configsettingsedit()
2102 * Parse skinvar configsettingsedit
2104 * @param string $type type of global configuration
2107 public function parse_configsettingsedit($type)
2112 case 'DefaultListSize':
2113 if ( !array_key_exists('DefaultListSize', $CONF) )
2115 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2116 $query = sprintf($query, sql_table('config'));
2117 DB::execute($query);
2118 $CONF['DefaultListSize'] = 10;
2120 elseif ( intval($CONF['DefaultListSize']) < 1 )
2122 $CONF['DefaultListSize'] = 10;
2124 echo intval($CONF['DefaultListSize']);
2126 case 'SessionCookie':
2127 $value = $CONF['SessionCookie'];
2128 $txt1 = _SETTINGS_COOKIESESSION;
2129 $txt2 = _SETTINGS_COOKIEMONTH;
2130 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2133 $value = $CONF['URLMode'];
2134 $txt1 = _SETTINGS_URLMODE_NORMAL;
2135 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2136 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2139 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2141 echo Entity::hsc($CONF[$type]);
2149 * AdminActions::parse_configsettingsyesno()
2150 * Parse skinvar configsettingsyesno
2152 * @param string $type type of global setting
2153 * @param integer $tabindex tabindex attribute of input element
2156 public function parse_configsettingsyesno($type, $tabindex)
2159 if ( array_key_exists($type, $CONF) )
2161 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2167 * AdminActions::parse_contents()
2168 * Parse skinvar contents
2170 * @param string $which part for item
2173 public function parse_contents($which)
2175 if ( !array_key_exists($which, Admin::$contents) )
2177 Admin::$contents[$which] = '';
2179 echo Entity::hsc(Admin::$contents[$which]);
2183 * AdminActions::parse_currenttime()
2184 * Parse skinvar currenttime
2186 * @param string $what
2189 public function parse_currenttime($what)
2191 $nu = getdate(Admin::$blog->getCorrectTime());
2196 * AdminActions::parse_customhelplink()
2197 * Parse skinvar customhelplink
2199 * @param string $topic name of topic
2200 * @param string $tplName name of template
2201 * @param string $url string as URI
2202 * @param string $iconURL string as URI for icon
2203 * @param string $alt alternative text for image element
2204 * @param string $title title for anchor element
2207 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2209 $this->customHelp($topic, $url, $iconURL);
2214 * AdminActions::parse_date()
2215 * Parse skinvar date
2217 public function parse_date($format = 'c')
2219 global $CONF, $manager;
2220 /* TODO: offset is based on i18n::get_current_locale()? */
2221 echo i18n::formatted_datetime($format, time());
2226 * AdminActions::parse_defaultadminskintypes()
2227 * Parse skinvar defaultadminskintypes
2229 * @param string $tabindex index number for tabindex attribute of input element
2230 * @param string $templateName name of template
2233 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2237 $templates = array();
2239 if ( $templateName )
2241 $templates =& $manager->getTemplate($templateName);
2244 $types = $this->parser->skin->getAvailableTypes();
2247 /* NOTE: set templates for HEAD/BODY/FOOT */
2248 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2250 $template['head'] = "<ul>\n";
2254 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2256 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2258 $template['body'] = "<li>"
2259 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2264 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2266 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2268 $template['foot'] = "</ul>\n";
2272 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2275 $handler = new AdminActions('template');
2276 $parser = new PARSER($handler);
2278 /* NOTE: do output */
2279 echo $template['head'];
2280 foreach ( $types as $type => $fName )
2282 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2284 'tabindex' => $tabindex,
2285 'skintype' => $type,
2287 'help' => $helplink,
2288 'skinid' => intrequestVar('skinid'),
2290 $parser->parse(Template::fill($template['body'], $data));
2293 echo $template['foot'];
2299 * AdminActions::parse_defblogselect()
2300 * Parse skinvar defblogselect
2302 * @param string $templateName name of template
2305 public function parse_defblogselect($templateName = '')
2309 $query = "SELECT bname as text, bnumber as value FROM %s;";
2310 $query = sprintf($query, sql_table('blog'));
2312 $template['name'] = 'DefaultBlog';
2313 $template['selected'] = $CONF['DefaultBlog'];
2314 $template['tabindex'] = 10;
2316 Showlist($query, 'select', $template, $templateName);
2322 * AdminActions::parse_defcatselect()
2323 * Parse skinvar defcatselect
2325 * @param string $templateName name of template
2328 public function parse_defcatselect($templateName = '')
2332 $blogid = intRequestVar('blogid');
2333 $blog =& $manager->getBlog($blogid);
2335 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2336 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2338 $template['name'] = 'defcat';
2339 $template['selected'] = $blog->getDefaultCategory();
2340 $template['tabindex'] = 110;
2342 Showlist($query, 'select', $template, $templateName);
2348 * AdminActions::parse_defskinselect()
2349 * Parse skinvar defskinselect
2351 * @param string $type type of skin
2352 * @param string $templateName name of template
2355 public function parse_defskinselect($type = 'blog', $templateName = '')
2357 global $CONF, $manager;
2359 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2360 $query = sprintf($query, sql_table('skin_desc'));
2362 $blogid = intRequestVar('blogid');
2366 $template['selected'] = $CONF['BaseSkin'];
2370 $blog =& $manager->getBlog($blogid);
2371 $template['selected'] = $blog->getDefaultSkin();
2374 if ( $type != 'blog' )
2376 $nname = 'BaseSkin';
2383 $template['name'] = $nname;
2384 $template['tabindex'] = 50;
2386 Showlist($query, 'select', $template, $templateName);
2392 * AdminActions::parse_deletecomment()
2393 * Parse skinvar deletecomment
2395 * @param string $type type of infomation for comment
2398 public function parse_deletecomment($type = 'id')
2400 $commentid = intRequestVar('commentid');
2401 $comment = COMMENT::getComment($commentid);
2406 echo intRequestVar('commentid');
2409 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2411 echo $comment['member'];
2415 echo $comment['user'];
2419 $body = strip_tags($comment['body']);
2420 echo Entity::hsc(shorten($body, 300, '...'));
2426 * AdminActions::parse_deleteitembody()
2427 * Parse skinvar deleteitembody
2432 public function parse_deleteitembody()
2436 $itemid = intRequestVar('itemid');
2437 $item =& $manager->getItem($itemid, 1, 1);
2439 $body = strip_tags($item['body']);
2441 echo Entity::hsc(shorten($body, 300, '...'));
2447 * AdminActions::parse_deleteitemid()
2448 * Parse skinvar deleteitemid
2453 public function parse_deleteitemid()
2455 echo (integer) intRequestVar('itemid');
2460 * AdminActions::parse_deleteitemtitle()
2461 * Parse skinvar deleteitemtitle
2466 public function parse_deleteitemtitle()
2470 $itemid = intRequestVar('itemid');
2471 $item =& $manager->getItem($itemid, 1, 1);
2473 echo Entity::hsc(strip_tags($item['title']));
2479 * AdminActions::parse_editadminskin()
2480 * Parse skinvar editadminskin
2482 * @param string $type type of skin setting
2485 public function parse_editadminskin($type = 'id')
2487 $skinid = intRequestVar('skinid');
2488 $skin = new Skin($skinid);
2492 echo intRequestVar('skinid');
2495 echo Entity::hsc($skin->getName());
2498 echo Entity::hsc($skin->getDescription());
2501 echo Entity::hsc($skin->getContentType());
2504 echo Entity::hsc($skin->getIncludePrefix());
2507 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2515 * AdminActions::parse_editadminskintype()
2516 * Parse skinvar editadminskintype
2518 * @param string $type name of skin type
2521 public function parse_editadminskintype($type = 'id')
2523 global $CONF, $manager, $member;
2525 $fNames = $this->parser->skin->getAvailableTypes();
2526 $sType = strtolower(trim(requestVar('type')));
2531 echo intRequestVar('skinid');
2534 echo Entity::hsc($this->parser->skin->getName());
2537 echo Entity::hsc($this->parser->skin->getDescription());
2540 echo Entity::hsc($this->parser->skin->getContentType());
2543 echo Entity::hsc($this->parser->skin->getContentFromDB($sType));
2546 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2547 echo Entity::hsc($skinType);
2550 echo Entity::hsc($sType);
2553 echo Entity::hsc($this->parser->skin->getIncludePrefix());
2556 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2557 echo Entity::hsc($incMode);
2566 * AdminActions::parse_editcomment()
2567 * Parse skinvar editcomment
2569 * @param string $type type of comment setting
2572 public function parse_editcomment($type = 'id')
2576 $commentid = intRequestVar('commentid');
2577 $comment = COMMENT::getComment($commentid);
2579 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2584 echo intRequestVar('commentid');
2587 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2589 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2593 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2597 echo date("Y-m-d @ H:i", $comment['timestamp']);
2600 $comment['body'] = str_replace('<br />', '', $comment['body']);
2601 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2602 echo $comment['body'];
2605 echo $comment['userid'];
2608 echo $comment['userid'];
2611 echo $comment[$type];
2618 * AdminActions::parse_editdesturl()
2619 * Parse skinvar editdesturl
2621 public function parse_editdesturl()
2623 if ( requestVar('desturl') )
2625 echo Entity::hsc(requestVar('desturl'));
2631 * AdminActions::parse_editmemberlist()
2632 * Parse skinvar editmemberlist
2634 * @param string $templateName name of template
2637 public function parse_editmemberlist($templateName = '')
2640 // show list of members with actions
2641 $query = 'SELECT * FROM '.sql_table('member');
2642 $template['content'] = 'memberlist';
2643 $template['tabindex'] = 10;
2645 $batch = new Batch('member');
2646 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2651 * AdminActions::parse_editmember()
2652 * Parse skinvar editmember
2654 * @param string $type type of information for member
2655 * @return string $tempateName name of template to use
2658 public function parse_editmember($type = 'id', $templateName = '')
2660 global $CONF, $manager, $member;
2662 $memberid = intRequestVar('memberid');
2663 $mem =& $manager->getMember($memberid);
2668 echo intRequestVar('memberid');
2671 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2673 echo Entity::hsc($mem->getDisplayName());
2677 $dispName = Entity::hsc($mem->getDisplayName());
2678 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2680 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2689 echo Entity::hsc($mem->getRealName());
2692 echo Entity::hsc($mem->getEmail());
2695 echo Entity::hsc($mem->getURL());
2698 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2701 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2704 echo Entity::hsc($mem->getNotes());
2707 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2716 * AdminActions::parse_editpluginfo()
2717 * Parse skinvar editpluginfo
2719 * @param string $type type of plugin info
2722 public function parse_editpluginfo($type)
2726 $pid = intRequestVar('plugid');
2733 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2740 * AdminActions::parse_editplugoptionslist()
2741 * Parse skinvar editplugoptionslist
2743 * @param string $templateName name of template
2746 public function parse_editplugoptionslist($templateName = '')
2750 $pid = intRequestVar('plugid');
2751 $aOptions = array();
2754 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2755 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2756 $resource = DB::getResult($query);
2758 foreach ( $resource as $row )
2760 array_push($aOIDs, $row['oid']);
2761 $aOptions[$row['oid']] = array(
2762 'oid' => $row['oid'],
2763 'value' => $row['odef'],
2764 'name' => $row['oname'],
2765 'description' => $row['odesc'],
2766 'type' => $row['otype'],
2767 'typeinfo' => $row['oextra'],
2772 // fill out actual values
2773 if ( count($aOIDs) > 0 )
2775 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2776 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2778 $result = DB::getResult($query);
2780 foreach ( $result as $row )
2782 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2788 'context' => 'global',
2790 'options' => &$aOptions
2792 $manager->notify('PrePluginOptionsEdit', $data);
2794 $template['content'] = 'plugoptionlist';
2796 $amount = Showlist($aOptions, 'table', $template, $templateName);
2800 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2806 * AdminActions::parse_editskin()
2807 * Parse skinvar editskin
2809 * @param string $type type of skin
2812 public function parse_editskin($type = 'id')
2814 $skinid = intRequestVar('skinid');
2815 $skin = new SKIN($skinid);
2819 echo intRequestVar('skinid');
2822 echo Entity::hsc($skin->getName());
2825 echo Entity::hsc($skin->getDescription());
2828 echo Entity::hsc($skin->getContentType());
2831 echo Entity::hsc($skin->getIncludePrefix());
2834 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2842 * AdminActions::parse_editskintype()
2843 * Parse skinvar editskintype
2845 * @param string $type name of type for skin type
2848 public function parse_editskintype($type = 'id')
2850 global $CONF, $manager, $member;
2851 $skinid = intRequestVar('skinid');
2852 $skin = new SKIN($skinid);
2853 $fNames = $skin->getAvailableTypes();
2854 $sType = strtolower(trim(requestVar('type')));
2859 echo intRequestVar('skinid');
2862 echo Entity::hsc($skin->getName());
2865 echo Entity::hsc($skin->getDescription());
2868 echo Entity::hsc($skin->getContentType());
2871 echo Entity::hsc($skin->getContentFromDB($sType));
2874 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2875 echo Entity::hsc($skinType);
2878 echo Entity::hsc($sType);
2881 echo Entity::hsc($skin->getIncludePrefix());
2884 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2885 echo Entity::hsc($incMode);
2894 * AdminActions::parse_adminurl()
2895 * Parse skinvar adminurl
2896 * (shortcut for admin url)
2901 public function parse_adminurl()
2903 $this->parse_sitevar('adminurl');
2908 * AdminActions::parse_edittemplateinfo()
2909 * Parse skinvar edittemplateinfo
2911 * @param string $type name of type for skin
2912 * @param string $description description for skin
2913 * @param string $name name of skin
2914 * @param string $help
2915 * @param string $tabindex index value for tabindex attribute of input element
2916 * @param string $big
2917 * @param string $tplt name of template
2920 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2923 static $cache = array();
2925 if ( !array_key_exists('id', $cache) )
2927 $cache['id'] = intRequestVar('templateid');
2930 if ( !array_key_exists('name', $cache) )
2932 $cache['name'] = Template::getNameFromId($cache['id']);
2935 if ( !array_key_exists('desc', $cache) )
2937 $cache['desc'] = Template::getDesc($cache['id']);
2940 $template =& $manager->getTemplate($cache['name']);
2945 echo (integer) $cache['id'];
2948 echo Entity::hsc($cache['name']);
2951 echo Entity::hsc($cache['desc']);
2953 case 'extratemplate':
2955 $pluginfields = array();
2956 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2961 $tmplt =& $manager->getTemplate($desc);
2963 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2967 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2971 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2974 foreach ( $pluginfields as $pfkey => $pfvalue )
2976 $data = array('explugtplname' => Entity::hsc($pfkey));
2978 echo Template::fill($base, $data);
2980 foreach ( $pfvalue as $pffield => $pfdesc )
2982 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2987 $desc = defined($desc) ? constant($desc) : $desc;
2988 $name = defined($name) ? constant($name) : $name;
2989 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2997 * AdminActions::parse_editadmintemplateinfo()
2998 * Parse skinvar editadmintemplateinfo
3000 * @param string $type type of skin template
3001 * @param string $description description of template
3002 * @param string $name name of stemplate
3003 * @param string $tabindex index number for tabindex attribute of input element
3004 * @param string $big
3005 * @param string $tplt
3007 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3010 static $cache = array();
3012 if ( !array_key_exists('id', $cache) )
3014 $cache['id'] = intRequestVar('templateid');
3017 if ( !array_key_exists('name', $cache) )
3019 $cache['name'] = Template::getNameFromId($cache['id']);
3022 if ( !array_key_exists('desc', $cache) )
3024 $cache['desc'] = Template::getDesc($cache['id']);
3027 $template =& $manager->getTemplate($cache['name']);
3032 echo (integer) $cache['id'];
3035 echo Entity::hsc($cache['name']);
3038 echo Entity::hsc($cache['desc']);
3040 case 'extratemplate':
3042 $pluginfields = array();
3043 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3048 $tmplt =& $manager->getTemplate($desc);
3050 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3054 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3058 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3061 foreach ( $pluginfields as $pfkey => $pfvalue )
3063 $data = array('explugtplname' => Entity::hsc($pfkey));
3065 echo Template::fill($base, $data);
3067 foreach ( $pfvalue as $pffield => $pfdesc )
3069 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3074 $desc = defined($desc) ? constant($desc) : $desc;
3075 $name = defined($name) ? constant($name) : $name;
3076 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3083 * AdminActions::parse_eventformextra()
3084 * Parse skinvar eventformextra
3086 * @param string $type name of type for event form extra
3089 public function parse_eventformextra($type = 'activation')
3098 $key = requestVar('ackey');
3101 Admin::error(_ERROR_ACTIVATE);
3103 $info = MEMBER::getActivationInfo($key);
3106 Admin::error(_ERROR_ACTIVATE);
3108 $mem =& $manager->getMember($info->vmember);
3111 Admin::error(_ERROR_ACTIVATE);
3114 'type' => 'activation',
3118 case 'membermailform-notloggedin':
3119 $data = array('type' => 'membermailform-notloggedin',);
3122 $manager->notify('FormExtra', $data);
3127 * AdminActions::parse_extrahead()
3128 * Parse skinvar extrahead
3130 public function parse_extrahead()
3134 $extrahead = Admin::getAdminextrahead();
3137 'extrahead' => &$extrahead,
3138 'action' => Admin::getAdminAction()
3141 $manager->notify('AdminPrePageHead', $data);
3147 * AdminActions::parse_member()
3148 * Parse skinvar member
3149 * (includes a member info thingie)
3151 * @param string $what which memberdata is needed
3154 public function parse_member($what)
3156 global $memberinfo, $member, $CONF;
3158 // 1. only allow the member-details-page specific variables on member pages
3159 if ( $this->skintype == 'member' )
3164 echo Entity::hsc($memberinfo->getDisplayName());
3167 echo Entity::hsc($memberinfo->getRealName());
3170 echo Entity::hsc($memberinfo->getNotes());
3173 echo Entity::hsc($memberinfo->getURL());
3176 echo Entity::hsc($memberinfo->getEmail());
3179 echo Entity::hsc($memberinfo->getID());
3184 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3185 if ( $member->isLoggedIn() )
3190 echo $member->getDisplayName();
3192 case 'yourrealname':
3193 echo $member->getRealName();
3196 echo $member->getNotes();
3199 echo $member->getURL();
3202 echo $member->getEmail();
3205 echo $member->getID();
3207 case 'yourprofileurl':
3208 if ( $CONF['URLMode'] == 'pathinfo' )
3210 echo Link::create_member_link($member->getID());
3214 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3223 * AdminActions::parse_version()
3224 * Parse skinvar version
3225 * (include nucleus versionnumber)
3230 public function parse_version()
3233 echo 'Nucleus CMS ' . $nucleus['version'];
3238 * AdminActions::parse_sitevar()
3239 * Parse skinvar sitevar
3240 * (include a sitevar)
3242 * @param string $which
3245 public function parse_sitevar($which)
3251 echo $CONF['IndexURL'];
3254 echo $CONF['SiteName'];
3257 echo $CONF['AdminEmail'];
3260 echo $CONF['AdminURL'];
3267 * AdminActions::parse_actionurl()
3273 public function parse_actionurl()
3276 echo Entity::hsc($CONF['ActionURL']);
3281 * AdminActions::parse_getblogsetting()
3282 * Parse skinvar getblogsetting
3284 public function parse_getblogsetting($which)
3286 global $blog, $manager;
3292 elseif ( $bid = intRequestVar('blogid') )
3294 $b =& $manager->getBlog($bid);
3304 return Entity::hsc($b->getID());
3307 return Entity::hsc($b->getURL());
3310 return Entity::hsc($b->getName());
3313 return Entity::hsc($b->getDescription());
3316 return Entity::hsc($b->getShortName());
3318 case 'notifyaddress':
3319 return Entity::hsc($b->getNotifyAddress());
3322 return Entity::hsc($b->getMaxComments());
3325 return Entity::hsc($b->getUpdateFile());
3328 return Entity::hsc($b->getTimeOffset());
3335 * AdminActions::parse_geteditpluginfo()
3336 * Parse skinvar geteditpluginfo
3338 * @param string $type name of setting for edit plugin info
3341 public function parse_geteditpluginfo($type)
3344 $pid = intRequestVar('plugid');
3351 return Entity::hsc($manager->getPluginNameFromPid($pid));
3358 * AdminActions::parse_getmember()
3359 * Parse skinvar getmember
3360 * (includes a member info thingie)
3362 * @param string $what name of setting for member
3365 public function parse_getmember($what)
3367 global $memberinfo, $member;
3368 // 1. only allow the member-details-page specific variables on member pages
3369 if ( $this->skintype == 'member' )
3374 return Entity::hsc($memberinfo->getDisplayName());
3377 return Entity::hsc($memberinfo->getRealName());
3380 return Entity::hsc($memberinfo->getNotes());
3383 return Entity::hsc($memberinfo->getURL());
3386 return Entity::hsc($memberinfo->getEmail());
3389 return Entity::hsc($memberinfo->getID());
3393 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3394 if ( $member->isLoggedIn() )
3399 return $member->getDisplayName();
3401 case 'yourrealname':
3402 return $member->getRealName();
3405 return $member->getNotes();
3408 return $member->getURL();
3411 return $member->getEmail();
3414 return $member->getID();
3422 * AdminActions::parse_headmessage()
3423 * Parse skinvar headmessage
3428 public function parse_headmessage()
3430 if ( !empty(Admin::$headMess) )
3432 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3438 * AdminActions::parse_helplink()
3439 * Parse skinvar helplink
3441 * @param string $topic name of topic for help
3444 public function parse_helplink($topic = '')
3446 if ( !empty($topic) )
3454 * AdminActions::parse_helpplugname()
3455 * Parse skinvar helpplugname
3460 public function parse_helpplugname()
3462 $plugid = intGetVar('plugid');
3463 Entity::hsc($manager->getPluginNameFromPid($plugid));
3468 * AdminActions::parse_ilistaddnew()
3469 * Parse skinvar ilistaddnew
3474 public function parse_ilistaddnew()
3476 $blogid = intRequestVar('blogid');
3477 if ( intPostVar('start') == 0 )
3479 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3485 * AdminActions::parse_importskininfo()
3486 * Parse skinvar importskininfo
3488 * @param string $type name of information for imported skin
3491 public function parse_importskininfo($type)
3496 echo Entity::hsc(requestVar('skininfo'));
3499 $dataArr = requestArray('skinnames');
3500 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3503 $dataArr = requestArray('tpltnames');
3504 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3507 $dataArr = requestArray('skinclashes');
3508 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3511 $dataArr = requestArray('tpltclashes');
3512 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3515 echo Entity::hsc(requestVar('skinfile'));
3518 echo Entity::hsc(requestVar('mode'));
3525 * AdminActions::parse_inputyesno()
3526 * Parse skinvar inputyesno
3528 * some init stuff for all forms
3533 public function parse_init()
3538 if ( requestVar('action') == 'itemedit' )
3540 $authorid = Admin::$contents['authorid'];
3543 Admin::$blog->insertJavaScriptInfo($authorid);
3548 * AdminActions::parse_inputyesno()
3549 * Parse skinvar inputyesno
3551 * @param string $name
3552 * @param string $checkedval
3553 * @param string $tabindex
3554 * @param string $value1
3555 * @param string $value2
3556 * @param string $yesval
3557 * @param string $noval
3558 * @param string $isAdmin
3559 * @param string $templateName
3562 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3564 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3569 * AdminActions::parse_insertpluginfo()
3570 * Parse templatevar insertpluginfo
3572 public function parse_insertpluginfo($type)
3574 $option = Admin::getAdminaOption();
3578 return $option['pid'];
3581 return Entity::hsc($option['pfile']);
3588 * AdminActions::parse_insplugoptcontent()
3589 * Parse skinvar insplugoptcontent
3594 public function parse_insplugoptcontent()
3596 $option = Admin::getAdminaOption();
3598 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3599 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3602 listplug_plugOptionRow($option);
3609 * AdminActions::parse_iprangeinput()
3610 * Parse skinvar iprangeinput
3615 public function parse_iprangeinput()
3617 if ( requestVar('ip') )
3619 $iprangeVal = Entity::hsc(requestVar('ip'));
3620 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3621 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3622 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3623 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3624 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3628 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3629 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3635 * AdminActions::parse_itemnavlist()
3636 * Parse skinvar itemnavlist
3641 public function parse_itemnavlist($templateName)
3643 global $CONF, $manager, $member;
3645 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3646 . " FROM %s, %s, %s, %s"
3647 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3649 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3651 if ( $this->skintype == 'itemlist' )
3654 if ( array_key_exists('blogid', $_REQUEST) )
3656 $blogid = intRequestVar('blogid');
3658 else if ( array_key_exists('itemid', $_REQUEST) )
3660 $itemid = intRequestVar('itemid');
3661 $item = &$manager->getItem($itemid, 1, 1);
3662 $blogid = (integer) $item['blogid'];
3664 $blog =& $manager->getBlog($blogid);
3666 $query .= " AND iblog={$blogid}";
3667 $template['now'] = $blog->getCorrectTime(time());
3669 // non-blog-admins can only edit/delete their own items
3670 if ( !$member->blogAdminRights($blogid) )
3672 $query .= ' AND iauthor = ' . $member->getID();
3675 elseif ( $this->skintype == 'browseownitems' )
3677 $query .= ' AND iauthor = ' . $member->getID();
3679 $template['now'] = time();
3682 // search through items
3683 $search = postVar('search');
3685 if ( !empty($search) )
3687 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3688 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3689 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3692 if ( postVar('start') )
3694 $start = intPostVar('start');
3701 // amount of items to show
3702 if ( postVar('amount') )
3704 $amount = intPostVar('amount');
3708 $amount = (integer) $CONF['DefaultListSize'];
3715 $query .= ' ORDER BY itime DESC'
3716 . " LIMIT {$start},{$amount}";
3718 $template['content'] = 'itemlist';
3720 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3721 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3726 * AdminActions::parse_itemtime()
3727 * date change on edit item
3729 * @param string $key key of PHP's getDate()
3732 public function parse_itemtime($key)
3737 $itemid = intRequestVar('itemid');
3738 $item =& $manager->getItem($itemid, 1, 1);
3740 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3742 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3744 $item['body'] = removeBreaks($item['body']);
3745 $item['more'] = removeBreaks($item['more']);
3748 $contents = array();
3749 if ( requestVar('action') == 'itemedit' )
3753 elseif ( requestVar('action') == 'createitem' )
3756 'contents' => &$contents,
3757 'blog' => &$this->blog
3759 $manager->notify('PreAddItemForm', $data);
3761 $itemtime = getdate($contents['timestamp']);
3762 echo $itemtime[$key];
3767 * AdminActions::parse_jstoolbaroptions()
3768 * Parse skinvar jstoolbaroptions
3773 public function parse_jstoolbaroptions()
3777 _SETTINGS_JSTOOLBAR_NONE,
3778 _SETTINGS_JSTOOLBAR_SIMPLE,
3779 _SETTINGS_JSTOOLBAR_FULL
3783 foreach ( $options as $option )
3785 $text = "<option value=\"%d\"%s>%s</option>\n";
3786 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3787 echo sprintf($text, $i, $extra, $option);
3793 * AdminActions::parse_localeselectoptions()
3794 * Parse skinvar localeselectoptions
3799 public function parse_localeselectoptions()
3803 $locales = i18n::get_available_locale_list();
3805 $memid = intRequestVar('memberid');
3808 $mem =& $manager->getMember($memid);
3809 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3811 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3815 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3820 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3822 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3826 echo "<option value=\"\">en_Latn_US</option>\n";
3829 foreach ( $locales as $locale )
3831 if ( $locale == 'en_Latn_US' )
3837 if ( $locale == $mem->getLocale() )
3839 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3843 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3848 if ( $locale == i18n::get_current_locale() )
3850 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3854 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3862 * AdminActions::parse_listplugplugoptionrow()
3863 * Parse templatevar listplugplugoptionrow
3865 * @param string $templateName name of template
3868 public function parse_listplugplugoptionrow($templateName = '')
3870 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
3875 * AdminActions::parse_mediadirwarning()
3876 * Parse skinvar mediadirwarning
3881 public function parse_mediadirwarning()
3884 if ( !is_dir($DIR_MEDIA) )
3886 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3888 if ( !is_readable($DIR_MEDIA) )
3890 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3892 if ( !is_writeable($DIR_MEDIA) )
3894 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3900 * AdminActions::parse_movedistselect()
3901 * Parse skinvar movedistselect
3903 public function parse_movedistselect()
3905 $actionType = requestVar('action');
3906 switch ( $actionType )
3909 $this->selectBlog('destcatid', 'category');
3911 case 'batchcategory':
3912 $this->selectBlog('destblogid');
3915 if ( $this->skintype == 'itemmove' )
3917 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3918 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3919 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3920 $this->selectBlog('catid', 'category', $catid, 10, 1);
3928 * AdminActions::parse_moveitemid()
3929 * Parse skinvar moveitemid
3934 public function parse_moveitemid()
3936 echo intRequestVar('itemid');
3941 * AdminActions::parse_newestcompare()
3942 * Parse skinvar newestcompare
3947 public function parse_newestcompare()
3951 $newestVersion = getLatestVersion();
3952 $newestCompare = str_replace('/', '.', $newestVersion);
3953 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3955 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3957 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3958 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3964 * AdminActions::parse_newmemberselect()
3965 * Parse skinvar newmemberselect
3967 * @param string $templateName name of template to use
3970 public function parse_newmemberselect($templateName = '')
3972 $blogid = intRequestVar('blogid');
3974 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3975 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3976 $res = DB::getResult($query);
3979 foreach ( $res as $row )
3981 $tmem[] = intval($row['tmember']);
3984 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3985 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3988 'name' => 'memberid',
3989 'tabindex' => 10000,
3992 Showlist($query, 'select', $template, $templateName);
3997 * AdminActions::parse_newpluginlist()
3998 * Parse skinvar newpluginlist
4003 public function parse_newpluginlist()
4005 $candidates = $this->newPlugCandidates;
4006 foreach ( $candidates as $name )
4008 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4014 * AdminActions::parse_outputspecialdirs()
4015 * Parse skinvar outputspecialdirs
4017 * @param string $type type of setting for directory
4020 public function parse_outputspecialdirs($type)
4022 global $DIR_MEDIA, $DIR_NUCLEUS;
4027 echo Entity::hsc($DIR_NUCLEUS);
4030 echo Entity::hsc($DIR_MEDIA);
4037 * AdminActions::parse_passrequestvars()
4038 * Parse skinvar passrequestvars
4043 public function parse_passrequestvars()
4045 $passvar = Admin::getAdminpassvar();
4046 $oldaction = postVar('oldaction');
4048 if ( ($oldaction != 'logout')
4049 && ($oldaction != 'login')
4051 && !postVar('customaction') )
4059 * AdminActions::parse_pluginextras()
4060 * Parse skinvar pluginextras
4062 * @param string $type type of plugin context
4065 public function parse_pluginextras($type = 'global')
4072 $id = intRequestVar('memberid');
4073 $mem =& $manager->getMember($id);
4074 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4077 $id = intRequestVar('blogid');
4078 $blg =& $manager->getBlog($id);
4079 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4081 case 'createaccount':
4083 'type' => 'createaccount.php',
4085 'postlabel' => '<br />',
4087 'postfield' => '<br /><br />'
4089 $manager->notify('RegistrationFormExtraFields', $data);
4092 $manager->notify('GeneralSettingsFormExtras', array());
4099 * AdminActions::parse_pluginhelp()
4100 * Parse skinvar pluginhelp
4105 public function parse_pluginhelp()
4107 global $manager, $DIR_PLUGINS;
4109 $plugid = intGetVar('plugid');
4110 $plugName = $manager->getPluginNameFromPid($plugid);
4111 $plug =& $manager->getPlugin($plugName);
4113 if ( $plug->supportsFeature('HelpPage') > 0 )
4115 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4116 if ( @file_exists($helpfile . 'php') )
4118 @include($helpfile . 'php');
4121 elseif ( @file_exists($helpfile . 'html') )
4123 @include($helpfile . 'html');
4127 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4128 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4133 * AdminActions::parse_pluginlistlist()
4134 * Parse skinvar pluginlistlist
4136 * @param string $templateName name of template to use
4139 public function parse_pluginlistlist($templateName = '')
4141 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4142 $query = sprintf($query, sql_table('plugin'));
4144 $template['content'] = 'pluginlist';
4145 $template['tabindex'] = 10;
4147 Showlist($query, 'table', $template, $templateName);
4153 * AdminActions::parse_pluginoptions()
4154 * Parse skinvar pluginoptions
4156 * @param string $type type of plugin option
4159 public function parse_pluginoptions($context='global', $templateName='')
4161 global $itemid, $manager;
4166 $contextid = intRequestVar('memberid');
4169 $contextid = intRequestVar('blogid');
4172 $contextid = intRequestVar('catid');
4175 $contextid = $itemid;
4179 /* Actually registererd plugin options */
4180 $aIdToValue = array();
4181 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4182 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4183 $res = DB::getResult($query);
4184 foreach ( $res as $row )
4186 $aIdToValue[$row['oid']] = $row['ovalue'];
4189 /* Currently available plugin options */
4190 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4191 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4192 $res = DB::getResult($query);
4195 foreach ($res as $row )
4197 if ( !array_key_exists($row['oid'], $aIdToValue) )
4199 $value = $row['odef'];
4203 $value = $aIdToValue[$row['oid']];
4207 'pid' => $row['pid'],
4208 'pfile' => $row['pfile'],
4209 'oid' => $row['oid'],
4211 'name' => $row['oname'],
4212 'description' => $row['odesc'],
4213 'type' => $row['otype'],
4214 'typeinfo' => $row['oextra'],
4215 'contextid' => $contextid,
4221 'context' => $context,
4222 'contextid' => $contextid,
4223 'options' => &$options
4225 $manager->notify('PrePluginOptionsEdit', $data);
4227 $template = array();
4228 if ( $templateName )
4230 $templates =& $manager->getTemplate($templateName);
4231 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
4233 $template['title'] = "<tr>"
4234 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
4239 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
4242 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
4244 $template['body'] = "<tr>"
4245 . "<%listplugplugoptionrow%>"
4250 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
4256 include_libs('ACTIONS.php');
4257 $handler = new Actions($this->skintype);
4258 $parser = new PARSER($handler);
4260 foreach ( $options as $option )
4263 if ( $prevPid != $option['pid'] )
4265 $prevPid = $option['pid'];
4266 $parser->parse($template['title']);
4269 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
4271 if ( @$meta['access'] != 'hidden' )
4273 $parsed = $parser->parse($template['body']);
4281 * AdminActions::parse_qmenuaddselect()
4282 * Parse skinvar qmanuaddselect
4284 * @param string $templateName name of template to use
4287 public function parse_qmenuaddselect($templateName = '')
4290 $showAll = requestVar('showall');
4291 if ( $member->isAdmin() && ($showAll == 'yes') )
4293 // Super-Admins have access to all blogs! (no add item support though)
4294 $query = 'SELECT bnumber as value, bname as text'
4295 . ' FROM ' . sql_table('blog')
4296 . ' ORDER BY bname';
4300 $query = 'SELECT bnumber as value, bname as text'
4301 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4302 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4303 . ' ORDER BY bname';
4306 $template['name'] = 'blogid';
4307 $template['tabindex'] = 15000;
4308 $template['extra'] = _QMENU_ADD_SELECT;
4309 $template['selected'] = -1;
4310 $template['shorten'] = 10;
4311 $template['shortenel'] = '';
4312 $template['javascript'] = 'onchange="return form.submit()"';
4314 Showlist($query, 'select', $template, $templateName);
4320 * AdminActions::parse_quickmenu()
4321 * Parse skinvar quickmenu
4323 * @param string $templateName name of template to use
4326 public function parse_quickmenu($templateName = '')
4329 $templates = array();
4330 $template = array();
4331 if ( !empty($templateName) )
4333 $templates = & $manager->getTemplate($templateName);
4335 $pluginExtras = array();
4339 'options' => &$pluginExtras
4342 if ( count($pluginExtras) > 0 )
4344 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4346 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4350 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4352 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4354 $template['head'] = "<ul>\n";
4358 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4360 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4362 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4366 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4368 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4370 $template['foot'] = "</ul>\n";
4374 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4377 $handler = new Actions($this->skintype);
4378 $parser = new PARSER($handler);
4380 $parser->parse($template['title']);
4381 echo $template['head'];
4382 foreach ( $pluginExtras as $aInfo )
4385 'plugadminurl' => Entity::hsc($aInfo['url']),
4386 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4387 'plugadmintitle' => Entity::hsc($aInfo['title']),
4389 echo Template::fill($template['body'], $data);
4391 echo $template['foot'];
4397 * AdminActions::parse_requestblogid()
4398 * Parse skinvar requestblogid
4403 public function parse_requestblogid()
4405 echo intRequestVar('blogid');
4410 * AdminActions::parse_requestiprange()
4411 * Parse skinvar requestiprange
4416 public function parse_requestiprange()
4418 if ( requestVar('iprange') )
4420 echo Entity::hsc(requestVar('iprange'));
4422 elseif ( requestVar('ip') )
4424 echo Entity::hsc(requestVar('ip'));
4430 * AdminActions::parse_selectlocaladminskinfiles()
4431 * Parse skinvar selectlocaladminskinfiles
4436 public function parse_selectlocaladminskinfiles()
4438 global $DIR_SKINS, $manager, $DIR_LIBS;
4440 if ( !class_exists('SkinImport', FALSE) )
4442 include_once("{$DIR_LIBS}skinie.php");
4444 $adminskindir = $DIR_SKINS . 'admin/';
4445 $candidates = SkinImport::searchForCandidates($adminskindir);
4447 foreach ( $candidates as $skinname => $skinfile )
4449 $html = Entity::hsc($skinfile);
4450 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4457 * AdminActions::parse_selectlocalskinfiles()
4458 * Parse skinvar selectlocalskinfiles
4463 public function parse_selectlocalskinfiles()
4467 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4469 foreach ( $candidates as $skinname => $skinfile )
4471 $html = Entity::hsc($skinfile);
4472 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4479 * AdminActions::parse_skineditallowedlist()
4480 * Parse skinvar skineditallowedlist
4482 * @param string $type type of skin
4483 * @param string $templateName name of template
4486 public function parse_skineditallowedlist($type, $templateName = '')
4491 $query = "SELECT bshortname, bname FROM %s;";
4493 'content' => 'shortblognames'
4495 $query = sprintf($query, sql_table('blog'));
4496 Showlist($query, 'table', $show, $templateName);
4499 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4501 'content' => 'shortnames'
4503 $query = sprintf($query, sql_table('template_desc'));
4504 Showlist($query, 'table', $show, $templateName);
4511 * AdminActions::parse_skinielist()
4512 * Parse skinvar skinielist
4514 * @param string $type type of skin
4515 * @param string $templateName name of template to use
4518 public function parse_skinielist($type, $templateName = '')
4522 $templates = array();
4523 if ( $templateName )
4525 $templates =& $manager->getTemplate($templateName);
4527 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4529 $template = $templates['SKINIE_EXPORT_LIST'];
4534 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4535 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4537 . "<td><%expdesc%></td>\n"
4544 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4545 foreach ( $res as $row )
4548 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4549 'expid' => 'skinexp' . $row['sdnumber'],
4550 'expname' => Entity::hsc($row['sdname']),
4551 'expdesc' => Entity::hsc($row['sddesc'])
4553 echo Template::fill($template, $data);
4557 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4558 foreach ( $res as $row )
4561 'typeid' => 'template[' . $row['tdnumber'] . ']',
4562 'expid' => 'templateexp' . $row['tdnumber'],
4563 'expname' => Entity::hsc($row['tdname']),
4564 'expdesc' => Entity::hsc($row['tddesc'])
4566 echo Template::fill($template, $data);
4574 * AdminActions::parse_skinoverview()
4575 * Parse skinvar skinoverview
4577 * @param string $templateName name of template to use
4580 public function parse_skinoverview($templateName = '')
4583 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4584 $query = sprintf($query, sql_table('skin_desc'));
4586 $template['content'] = 'skinlist';
4587 $template['tabindex'] = 10;
4589 Showlist($query, 'table', $template, $templateName);
4594 * AdminActions::parse_skintypehelp()
4595 * Check editing skintypehelp
4600 public function parse_skintypehelp()
4602 $nowSkinType = strtolower(trim(requestVar('type')));
4604 /* TODO: use Skin class */
4605 $regularType = array(
4616 if ( in_array($nowSkinType, $regularType) )
4618 help('skinpart' . $nowSkinType);
4622 help('skinpartspecial');
4628 * AdminActions::parse_specialskinlist()
4629 * Parse skinvar specialskinlist
4631 * @param string $templateName name of template to use
4634 public function parse_specialskinlist($templateName = '')
4638 $templates = array();
4639 if ( $templateName )
4641 $templates =& $manager->getTemplate($templateName);
4644 /* TODO: use Skin class */
4655 $skinid = intRequestVar('skinid');
4656 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4657 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4659 $res = DB::getResult($query);
4660 if ( $res && $res->rowCount() > 0 )
4663 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4665 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4669 $template['head'] = "<ul>\n";
4671 echo Template::fill($template['head'], $data);
4672 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4674 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4675 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4676 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4680 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4684 foreach ( $res as $row )
4687 'tabindex' => $tabstart++,
4688 'skinid' => $skinid,
4689 'skintype' => Entity::hsc(strtolower($row['stype']))
4691 echo Template::fill($template['body'], $data);
4694 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4696 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4700 $template['foot'] = "</ul>\n";
4702 echo Template::fill($template['foot'], $data);
4708 * AdminActions::parse_sprinttext()
4711 * @param string $which
4712 * @param string $val
4715 public function parse_sprinttext($which, $val)
4717 if ( !defined($which) )
4723 $base = constant($which);
4726 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4728 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4730 $met = 'parse_' . $matchies[0];
4734 $arg = trim($args[0], '()');
4735 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4738 if ( method_exists($this, $met) )
4740 $value = call_user_func(array(&$this, $met), $arg);
4744 if ( !isset($value) || empty($value) )
4748 echo sprintf($base, $value);
4753 * AdminActions::parse_systemsettings()
4754 * Parse skinvar systemsettings
4756 * @param string $type type of settings for system
4757 * @param string $templateName name of template to use
4760 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4762 global $manager, $member, $CONF, $nucleus;
4764 $member->isAdmin() or Admin::disallow();
4766 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4767 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4774 case 'sqlserverinfo':
4775 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4777 case 'sqlclientinfo':
4778 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4780 case 'magicquotesgpc':
4781 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4783 case 'magicquotesruntime':
4784 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4786 case 'registerglobals':
4787 echo ini_get('register_globals') ? 'On' : 'Off';
4790 $templates = array();
4791 if ( $templateName )
4793 $templates =& $manager->getTemplate($templateName);
4795 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4797 $template = "<tr>\n"
4798 . "<td><%key%></td>\n"
4799 . "<td><%value%></td>\n"
4804 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4807 $gdinfo = gd_info();
4809 foreach ( $gdinfo as $key => $value )
4811 if ( is_bool($value) )
4813 $value = $value ? $enable : $disable;
4817 $value = Entity::hsc($value);
4823 echo Template::fill($template, $data);
4828 phpinfo(INFO_MODULES);
4829 $im = ob_get_contents();
4831 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4833 case 'nucleusversion':
4834 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4836 case 'nucleuspatchlevel':
4837 echo getNucleusPatchLevel();
4843 echo $CONF['ItemURL'];
4845 case 'alertonheaderssent':
4846 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4848 case 'nucleuscodename':
4849 if ( $nucleus['codename'] != '' )
4851 echo ' "' . $nucleus['codename'] . '"';
4854 case 'versioncheckurl':
4855 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4862 * AdminActions::parse_templateoverview()
4863 * Parse skinvar templateoverview
4865 * @param string $templateName name of template to use
4868 public function parse_templateoverview($templateName = '')
4870 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4871 $query = sprintf($query, sql_table('template_desc'));
4873 $template['content'] = 'templatelist';
4874 $template['tabindex'] = 10;
4876 Showlist($query, 'table', $template, $templateName);
4882 * AdminActions::parse_ticket()
4888 public function parse_ticket()
4891 $manager->addTicketHidden();
4896 * AdminActions::parse_versioncheckurl()
4897 * Parse skinvar versioncheckurl
4902 public function parse_versioncheckurl()
4904 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4909 * AdminActions::parse_yrbloglist()
4910 * Parse skinvar yrbloglist
4912 * @param string $templateName name of template to use
4915 public function parse_yrbloglist($templateName = '')
4918 $showAll = requestVar('showall');
4920 if ( $member->isAdmin() && ($showAll == 'yes') )
4922 // Super-Admins have access to all blogs! (no add item support though)
4923 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4925 . " ORDER BY bnumber;";
4926 $query = sprintf($query, sql_table('blog'));
4930 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4932 . " WHERE tblog=bnumber and tmember=%d"
4933 . " ORDER BY bnumber;";
4934 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4937 $template['content'] = 'bloglist';
4938 $template['superadmin'] = $member->isAdmin();
4940 $amount = Showlist($query, 'table', $template, $templateName);
4942 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4944 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4946 $total = DB::getValue($query);
4947 if ( $total > $amount )
4949 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4955 echo _OVERVIEW_NOBLOGS;
4957 elseif( $amount != 0 )
4959 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4961 $query = "SELECT ititle, inumber, bshortname"
4963 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4964 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4966 $template['content'] = 'draftlist';
4968 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4969 if ( $amountdrafts == 0 )
4971 echo _OVERVIEW_NODRAFTS;
4978 * AdminActions::checkCondition()
4979 * Checks conditions for if statements
4981 * @param string $field type of <%if%>
4982 * @param string $name property of field
4983 * @param string $value value of property
4984 * @return boolean condition
4986 protected function checkCondition($field, $name='', $value = '')
4988 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4998 $blog =& $manager->getBlog($blogid);
5002 $blogid = getBlogIDFromCatID($catid);
5003 $blog =& $manager->getBlog($blogid);
5005 elseif ( intRequestVar('catid') )
5007 $catid = intRequestVar('catid');
5008 $blogid = getBlogIDFromCatID($catid);
5009 $blog =& $manager->getBlog($blogid);
5016 $condition = ($blog && $this->ifCategory($name, $value));
5019 $condition = $member->isLoggedIn();
5022 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5025 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5028 $condition = $member->isLoggedIn() && $member->isAdmin();
5030 case 'allowloginedit':
5031 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5034 $condition = ($itemidnext != '');
5037 $condition = ($itemidprev != '');
5039 case 'archiveprevexists':
5040 $condition = ($archiveprevexists == true);
5042 case 'archivenextexists':
5043 $condition = ($archivenextexists == true);
5046 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5049 $condition = $this->ifHasPlugin($name, $value);
5052 $condition = (Admin::getAdminAction() == $name);
5054 case 'adminoldaction':
5055 $condition = (Admin::getAdminAction() == $name);
5057 case 'addresschange':
5058 $condition = ($this->ifAddresscange());
5060 case 'bechangepass':
5061 $condition = ($this->beChangePassword());
5063 case 'skincandidates':
5064 $condition = ($this->ifSkincandidates());
5067 $condition = requestVar('nameclashes');
5069 case 'existsnewplugin':
5070 $condition = ($this->existsNewPlugin());
5077 $condition = (boolean) ($member->getAutosave() == $value);
5084 $condition = (Admin::$blog->getSetting($name) == $value);
5086 case 'itemproperty':
5091 if ( array_key_exists($name, Admin::$contents) )
5093 $condition = (boolean) (Admin::$contents[$name] == $value);
5097 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5104 * AdminActions::_ifHasPlugin()
5105 * hasplugin,PlugName
5106 * -> checks if plugin exists
5107 * hasplugin,PlugName,OptionName
5108 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5109 * hasplugin,PlugName,OptionName=value
5110 * -> checks if the option OptionName from plugin PlugName is set to value
5112 * @param string $name name of plugin
5113 * @param string $value
5116 private function ifHasPlugin($name, $value)
5120 // (pluginInstalled method won't write a message in the actionlog on failure)
5121 if ( $manager->pluginInstalled("NP_{$name}") )
5123 $plugin =& $manager->getPlugin("NP_{$name}");
5124 if ( $plugin != NULL )
5132 list($name2, $value2) = preg_split('#=#', $value, 2);
5133 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5137 else if ( $plugin->getOption($name2) == $value2 )
5148 * AdminActions::beChangePassword()
5153 private function beChangePassword()
5155 return intRequestVar('bNeedsPasswordChange');
5159 * AdminActions::ifSkincandidates()
5160 * Checks if a plugin exists and call its doIf function
5166 private function ifSkincandidates()
5169 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5170 return (count($candidates) > 0);
5174 * AdminActions::ifPlugin()
5175 * Checks if a plugin exists and call its doIf function
5177 * @param string $name name of plugin
5178 * @param string $key
5179 * @param string $value
5182 private function ifPlugin($name, $key = '', $value = '')
5186 $plugin =& $manager->getPlugin("NP_{$name}");
5192 $params = func_get_args();
5193 array_shift($params);
5195 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5199 * AdminActions::ifCategory()
5200 * Different checks for a category
5202 * @param string $key key for information of category
5203 * @param string $value value for information of category
5206 private function ifCategory($key = '', $value='')
5208 global $blog, $catid;
5210 // when no parameter is defined, just check if a category is selected
5211 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5213 return $blog->isValidCategory($catid);
5216 // check category name
5217 if ( $key == 'catname' )
5219 $value = $blog->getCategoryIdFromName($value);
5220 if ($value == $catid)
5222 return $blog->isValidCategory($catid);
5226 // check category id
5227 if (($key == 'catid') && ($value == $catid))
5229 return $blog->isValidCategory($catid);
5236 * AdminActions::ifOnTeam()
5237 * Checks if a member is on the team of a blog and return his rights
5239 * @param string $blogName name of weblog
5242 private function ifOnTeam($blogName = '')
5244 global $blog, $member, $manager;
5246 // when no blog found
5247 if ( ($blogName == '') && !is_object($blog) )
5252 // explicit blog selection
5253 if ($blogName != '')
5255 $blogid = getBlogIDFromName($blogName);
5258 if (($blogName == '') || !$manager->existsBlogID($blogid))
5261 $blogid = $blog->getID();
5263 return $member->teamRights($blogid);
5267 * AdminActions::ifAdmin()
5268 * Checks if a member is admin of a blog
5270 * @param string $blogName name of weblog
5273 private function ifAdmin($blogName = '')
5275 global $blog, $member, $manager;
5277 // when no blog found
5278 if (($blogName == '') && (!is_object($blog)))
5283 // explicit blog selection
5284 if ($blogName != '')
5286 $blogid = getBlogIDFromName($blogName);
5289 if (($blogName == '') || !$manager->existsBlogID($blogid))
5292 $blogid = $blog->getID();
5295 return $member->isBlogAdmin($blogid);
5299 * AdminActions::ifAddresscange()
5300 * Check e-Mail address is changed
5305 private function ifAddresscange()
5309 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5314 $info = MEMBER::getActivationInfo($key);
5319 $mem =& $manager->getMember($info->vmember);
5324 if ( $info->vtype == 'addresschange' )
5332 * AdminActions::templateEditRow()
5335 * @param array $template
5336 * @param string $desc
5337 * @param string $name
5338 * @param string $help
5339 * @param integer $tabindex
5340 * @param boolean $big
5341 * @param array $tmplt
5344 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5350 if ( !array_key_exists($name, $template) )
5352 $template[$name] = '';
5360 $tmplt =& $manager->getTemplate($tplt);
5364 'description' => $desc,
5365 'help' => empty($help) ? '' : helpHtml('template' . $help),
5368 'tabindex' => $tabindex,
5369 'rows' => $big ? 10 : 5,
5372 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5374 $base['head'] = "</tr>"
5376 . "<td><%description%><%help%></td>\n"
5377 . "<td id=\"td<%count%>\">\n"
5378 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5382 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5385 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5387 $base['tail'] = "</textarea>\n"
5392 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5395 echo TEMPLATE::fill($base['head'], $data);
5396 echo ENTITY::hsc($template[$name]);
5397 echo TEMPLATE::fill($base['tail'], $data);
5405 * AdminActions::customHelp()
5406 * shows a link to custom help file
5409 * @param string $tplName
5410 * @param string $url
5411 * @param string $iconURL
5412 * @param string $alt
5413 * @param string $title
5417 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5419 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5423 * AdminActions::customHelp()
5424 * shows a link to custom help file
5427 * @param string $tplName
5428 * @param string $url
5429 * @param string $iconURL
5430 * @param string $alt
5431 * @param string $title
5435 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5437 global $CONF, $manager;
5439 $templates = array();
5443 $templates =& $manager->getTemplate($tplName);
5446 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5448 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5452 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5457 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5460 if ( empty($onclick) )
5462 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5464 elseif ( preg_match('#^onclick#', $onclick) )
5466 $onclick = $onclick;
5470 $onclick = 'onclick="' . $onclick . '"';
5475 'helptarget' => $id,
5476 'onclick' => $onclick,
5477 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5479 return Template::fill($template, $data);
5483 * AdminActions::customHelpHtml()
5486 * @param string $tplName
5487 * @param string $url
5488 * @param string $iconURL
5489 * @param string $alt
5490 * @param string $title
5491 * @param string $onclick
5492 * @return string anchor element with help uri
5494 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5496 global $CONF, $manager;
5498 $templates = array();
5502 $templates =& $manager->getTemplate($tplName);
5504 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5506 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5510 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5513 if ( empty($iconURL) )
5515 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5518 if ( function_exists('getimagesize') )
5520 $size = getimagesize($iconURL);
5521 $width = 'width="' . $size[0] . '" ';
5522 $height = 'height="' . $size[1] . '" ';
5526 'iconurl' => $iconURL,
5528 'height' => $height,
5529 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5530 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5533 $icon = Template::fill($template, $data);
5534 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5536 return $help . $icon;
5540 * AdminActions::input_yesno
5543 * @param $checkedval
5550 * @param $templateName
5553 public function input_yesno($name,
5566 $templates = array();
5567 if ( $templateName )
5569 $templates =& $manager->getTemplate($templateName);
5572 if ( $name == 'admin' )
5574 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5576 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5577 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5578 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5579 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5583 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5588 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5590 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5594 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5596 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5599 if ( !isset($template) )
5601 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5602 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5603 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5604 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5609 $id = Entity::hsc($name);
5610 $id = str_replace('[', '-', $id);
5611 $id = str_replace(']', '-', $id);
5612 $id1 = $id . Entity::hsc($value1);
5613 $id2 = $id . Entity::hsc($value2);
5615 'name' => Entity::hsc($name),
5616 'yesval' => Entity::hsc($value1),
5617 'noval' => Entity::hsc($value2),
5620 'yesvaltext' => $yesval,
5621 'novaltext' => $noval,
5622 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5623 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5624 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5629 return Template::fill($template, $dat);
5633 echo Template::fill($template, $dat);
5639 * AdminActions::existsNewPlugin()
5640 * Check exists new plugin
5643 * @return boolean exists or not
5645 private function existsNewPlugin()
5647 global $DIR_PLUGINS;
5649 $query = "SELECT * FROM %s;";
5650 $query = sprintf($query, sql_table('plugin'));
5651 $res = DB::getResult($query);
5653 $installed = array();
5654 foreach( $res as $row )
5656 $installed[] = $row['pfile'];
5659 $files = scandir($DIR_PLUGINS);
5661 $candidates = array();
5662 foreach ( $files as $file )
5664 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5666 if ( !in_array($matches[1], $installed) )
5668 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5672 $this->newPlugCandidates = $candidates;
5673 return (count($candidates) > 0);
5677 * AdminActions::pagehead()
5678 * Output admin page head
5683 public function parse_pagehead()
5685 global $member, $nucleus, $CONF, $manager;
5687 $extrahead = Admin::getAdminextrahead();
5689 'extrahead' => &$extrahead,
5690 'action' => Admin::getAdminAction()
5692 $manager->notify('AdminPrePageHead', $data);
5694 $content = $this->parser->skin->getContentFromDB('pagehead');
5697 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5701 if ( !array_key_exists('AdminCSS', $CONF) )
5703 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5704 $CONF['AdminCSS'] = 'original';
5708 /* HTTP 1.1 application for no caching */
5709 header("Cache-Control: no-cache, must-revalidate");
5710 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5712 $root_element = 'html';
5713 $charset = i18n::get_current_charset();
5714 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5715 $xml_version_info = self::$xml_version_info;
5716 $formal_public_identifier = self::$formal_public_identifier;
5717 $system_identifier = self::$system_identifier;
5718 $xhtml_namespace = self::$xhtml_namespace;
5720 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5721 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5722 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5724 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5727 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5729 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5730 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5731 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5732 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5733 echo "{$extrahead}\n";
5736 echo "<div id=\"adminwrapper\">\n";
5737 echo "<div class=\"header\">\n";
5738 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5740 echo "<div id=\"container\">\n";
5741 echo "<div id=\"content\">\n";
5742 echo "<div class=\"loginname\">\n";
5744 if ( !$member->isLoggedIn() )
5746 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5750 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5751 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5754 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5757 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5759 $codenamestring = '';
5763 $codenamestring = ' "' . $nucleus['codename'].'"';
5766 if ( $member->isLoggedIn() && $member->isAdmin() )
5768 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5769 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5771 $newestVersion = getLatestVersion();
5772 $newestCompare = str_replace('/', '.', $newestVersion);
5773 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5775 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5778 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5779 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5785 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5792 $this->parser->parse($content);
5799 * AdminActionss::pagefoot()
5800 * Output admin page foot include quickmenu
5805 public function parse_pagefoot()
5807 global $action, $member, $manager;
5810 'action' => Admin::getAdminAction()
5812 $manager->notify('AdminPrePageFoot', $data);
5814 $content = $this->parser->skin->getContentFromDB('pagefoot');
5817 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5819 echo '<h2>' . _LOGOUT . "</h2>\n";
5821 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5822 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5826 echo "<div class=\"foot\">\n";
5827 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5829 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5832 echo "<div id=\"quickmenu\">\n";
5834 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5837 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5840 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5841 echo "<form method=\"get\" action=\"index.php\">\n";
5843 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5845 $showAll = requestVar('showall');
5847 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5849 // Super-Admins have access to all blogs! (no add item support though)
5850 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5851 $query = sprintf($query, sql_table('blog'));
5855 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5856 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5858 $template['name'] = 'blogid';
5859 $template['tabindex'] = 15000;
5860 $template['extra'] = _QMENU_ADD_SELECT;
5861 $template['selected'] = -1;
5862 $template['shorten'] = 10;
5863 $template['shortenel'] = '';
5864 $template['javascript'] = 'onchange="return form.submit()"';
5865 showlist($query, 'select', $template);
5870 echo "<h2>{$member->getDisplayName()}</h2>\n";
5872 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5873 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5874 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5877 if ( $member->isAdmin() )
5879 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5881 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5882 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5883 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5884 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5885 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5886 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5887 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5890 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5892 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5893 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5894 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5898 $data = array('options' => array());
5900 $manager->notify('QuickMenu', $data);
5902 if ( count($data['options']) > 0 )
5904 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5906 foreach ( $data['options'] as $option )
5908 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5913 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5916 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5920 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5923 echo "<!-- quickmenu -->\n";
5926 echo "<!-- content -->\n";
5929 echo "<!-- container -->\n";
5932 echo "<!-- adminwrapper -->\n";
5940 $this->parser->parse($content);
5947 * AdminActions::selectBlog()
5948 * Inserts a HTML select element with choices for all blogs to which the user has access
5949 * mode = 'blog' => shows blognames and values are blogids
5950 * mode = 'category' => show category names and values are catids
5952 * @param string $name
5953 * @param string $mode
5954 * @param integer $selected
5955 * @param integer $tabindex
5956 * @param integer $showNewCat
5957 * @param integer $iForcedBlogInclude ID for weblog always included
5958 * @param $iForcedBlogInclude
5959 * ID of a blog that always needs to be included, without checking if the
5960 * member is on the blog team (-1 = none)
5963 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5965 global $member, $CONF;
5967 // 0. get IDs of blogs to which member can post items (+ forced blog)
5968 $aBlogIds = array();
5969 if ( $iForcedBlogInclude != -1 )
5971 $aBlogIds[] = intval($iForcedBlogInclude);
5974 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5976 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5977 $query = sprintf($query, sql_table('blog'));
5981 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5982 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5985 $rblogids = DB::getResult($query);
5986 foreach ( $rblogids as $row )
5988 if ( $row['bnumber'] != $iForcedBlogInclude )
5990 $aBlogIds[] = intval($row['bnumber']);
5994 if ( count($aBlogIds) == 0 )
5999 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
6001 // 1. select blogs (we'll create optiongroups)
6002 // (only select those blogs that have the user on the team)
6003 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
6004 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
6005 $blogs = DB::getResult($queryBlogs);
6007 if ( $mode == 'category' )
6009 if ( $blogs->rowCount() > 1 )
6013 foreach ( $blogs as $rBlog )
6015 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
6017 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
6020 // show selection to create new category when allowed/wanted
6023 // check if allowed to do so
6024 if ( $member->blogAdminRights($rBlog['bnumber']) )
6026 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
6030 // 2. for each category in that blog
6031 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
6032 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
6033 $categories = DB::getResult($catQuery);
6034 foreach ( $categories as $rCat )
6036 if ( $rCat['catid'] == $selected )
6038 $selectText = ' selected="selected" ';
6044 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
6047 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
6055 foreach ( $blogs as $rBlog )
6057 echo '<option value="' . $rBlog['bnumber'] . '"';
6058 if ( $rBlog['bnumber'] == $selected )
6060 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
6064 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";