X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=nucleus%2Flibs%2FAdminActions.php;h=be713d3d9715c189044308c6c3b758294b9bc1af;hb=01a93791a8780cae38125785dbee8f94b528323b;hp=ec9b6263608f442d606ce8413a531eb120b55cd3;hpb=2e3e66a2d59ddfebac59b7a54428304b2f0f91b0;p=nucleus-jp%2Fnucleus-next.git diff --git a/nucleus/libs/AdminActions.php b/nucleus/libs/AdminActions.php index ec9b626..be713d3 100644 --- a/nucleus/libs/AdminActions.php +++ b/nucleus/libs/AdminActions.php @@ -1,101 +1,105 @@ _ADM_SKPRT_ACTIONLOG, 'activate' => _ADM_SKPRT_ACTIVATE, 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD, @@ -185,7 +169,7 @@ class AdminActions extends BaseActions 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE, 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE, 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT, - 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW, + 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW, 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW, 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE, 'banlist' => _ADM_SKPRT_BANLIST, @@ -198,6 +182,7 @@ class AdminActions extends BaseActions 'batchitem' => _ADM_SKPRT_BATCHITEM, 'batchmember' => _ADM_SKPRT_BATCHMEMBER, 'batchmove' => _ADM_SKPRT_BATCHMOVE, + 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT, 'batchteam' => _ADM_SKPRT_BATCHTEAM, 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST, 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX, @@ -219,9 +204,11 @@ class AdminActions extends BaseActions 'itemedit' => _ADM_SKPRT_ITEMEDIT, 'itemlist' => _ADM_SKPRT_ITEMLIST, 'itemmove' => _ADM_SKPRT_ITEMMOVE, + 'login' => FALSE, //missing 'manage' => _ADM_SKPRT_MANAGE, 'manageteam' => _ADM_SKPRT_MANAGETEAM, 'memberdelete' => _ADM_SKPRT_MEMBERDELETE, + 'memberedit' => FALSE, //missing 'overview' => _ADM_SKPRT_OVERVIEW, 'pagefoot' => _ADM_SKPRT_PAGEFOOT, 'pagehead' => _ADM_SKPRT_PAGEHEAD, @@ -248,17 +235,60 @@ class AdminActions extends BaseActions ); /** - * AdminActions::getDefinedActions() + * AdminActions::getAvailableSkinTypes() * * @static - * @param string $type page type + * @param void + * @return array list of friendly names for page actions + */ + static public function getAvailableSkinTypes() + { + return self::$default_skin_types; + } + + /** + * AdminActions::getDefaultTypes() + * + * @static + * @param void + * @return array list of friendly names for page actions + */ + static public function getDefaultTypes() + { + return self::$default_skin_types; + } + + /** + * AdminActions::__construct() + * Constructor for a new Actions object + * + * @param string $type + * @return void + */ + public function __construct($type) + { + // call constructor of superclass first + parent::__construct(); + $this->skintype = $type; + if ( !class_exists('Navlist') || !class_exists('Batch') ) + { + global $DIR_LIBS; + include $DIR_LIBS . 'ENCAPSULATE.php'; + } + return; + } + + /** + * AdminActions::getAvailableActions() + * + * @param void * @return array allowed actions for the page type */ - static public function getDefinedActions($type) + public function getAvailableActions() { $extra_actions = array(); - switch ($type) + switch ( $this->skintype ) { case 'actionlog': $extra_actions = array( @@ -332,12 +362,16 @@ class AdminActions extends BaseActions 'editadminskintype', ); break; + case 'admintemplatedelete': + $extra_actions = array( + 'editadmintemplateinfo', + ); case 'admintemplateedit': $extra_actions = array( 'editadmintemplateinfo', ); break; - case 'admintemplateoverview': + case 'admntemplateoverview': $extra_actions = array( 'admintemplateoverview', ); @@ -446,16 +480,17 @@ class AdminActions extends BaseActions case 'blogsettings': $extra_actions = array( 'adminbloglink', - 'blogteammembers', - 'requestblogid', - 'blogsetting', + 'blogcatlist', 'blognotifysetting', - 'defcatselect', - 'blogtime', + 'blogsetting', 'blogsettingyesno', - 'pluginoptions', - 'blogcatlist', + 'blogteammembers', + 'blogtime', + 'defcatselect', + 'defskinselect', 'pluginextras', + 'pluginoptions', + 'requestblogid', ); break; case 'bookmarklet': @@ -484,6 +519,7 @@ class AdminActions extends BaseActions 'requestblogid', 'categorysetting', 'editdesturl', + 'pluginoptions' ); break; case 'commentdelete': @@ -499,16 +535,13 @@ class AdminActions extends BaseActions case 'createitem': $extra_actions = array( 'adminbloglink', - 'ifautosave', 'blogid', - 'jsinput', - 'jsbuttonbar', 'contents', - 'ifblogsetting', 'categories', 'currenttime', - 'pluginextras', - 'itemoptions', + 'init', + 'pluginoptions', + 'pluginextras' ); break; case 'createnewlog': @@ -525,9 +558,9 @@ class AdminActions extends BaseActions break; case 'editmembersettings': $extra_actions = array( - 'editmember', - 'languageselectoptions', 'adminskinselectoptions', + 'editmember', + 'localeselectoptions', 'pluginoptions', ); break; @@ -552,18 +585,13 @@ class AdminActions extends BaseActions case 'itemedit': $extra_actions = array( 'init', - 'ifautosave', 'contents', - 'jsinput', - 'jsbuttonbar', - 'ifblogsetting', 'checkedonval', 'categories', - 'ifitemproperty', 'currenttime', 'itemtime', - 'pluginextras', - 'itemoptions', + 'pluginoptions', + 'pluginextras' ); break; case 'itemlist': @@ -602,28 +630,6 @@ class AdminActions extends BaseActions 'yrbloglist', ); break; - case 'pagefoot': - $extra_actions = array( - 'date', - 'qmenuaddselect', - 'member', - 'quickmenu', - ); - break; - case 'pagehead': - $extra_actions = array( - 'charset', - 'sitevar', - 'adminstyleseets', - 'adminurl', - 'extrahead', - 'member', - 'versioncheckurl', - 'version', - 'codename', - 'newestcompare', - ); - break; case 'plugindelete': $extra_actions = array( 'editpluginfo', @@ -652,11 +658,10 @@ class AdminActions extends BaseActions 'defblogselect', 'defskinselect', 'configsettingsedit', - 'languageselectoptions', 'configsettingsyesno', 'outputspecialdirs', 'jstoolbaroptions', - 'adminstyleselectoptions', + 'localeselectoptions', 'mediadirwarning', 'pluginextras', ); @@ -664,7 +669,6 @@ class AdminActions extends BaseActions case 'showlogin': $extra_actions = array( 'passrequestvars', - 'adminstyleseets', ); break; case 'skindelete': @@ -750,7 +754,6 @@ class AdminActions extends BaseActions $extra_actions = array( 'charset', 'sitevar', - 'adminstyleseets', 'adminurl', 'extrahead', 'member', @@ -765,58 +768,10 @@ class AdminActions extends BaseActions default: break; } - return array_merge(self::$default_actions, $extra_actions); - } - - /** - * AdminActions::getSkinTypeFriendlyNames() - * - * @static - * @param void - * @return array list of friendly names for page actions - */ - static public function getSkinTypeFriendlyNames() - { - return self::$skin_type_friendly_names; - } - - /** - * Actions::__construct() - * Constructor for a new Actions object - * - * @param string $type - * @return void - */ - public function __construct($type) - { - $this->BaseActions(); - $this->skintype = $type; - return; - } - - /** - * Actions::setSkin() - * Set the skin - * @param object $skin an instance of Skin class - * @return void - */ - public function setSkin(&$skin) - { - $this->skin =& $skin; - return; - } - - /** - * Actions::setParser() - * Set the parser - * - * @param object $parser an instance of Parser class - * @return void - */ - public function setParser(&$parser) - { - $this->parser =& $parser; - return; + + $defined_actions = array_merge(self::$default_actions, $extra_actions); + + return array_merge($defined_actions, parent::getAvailableActions()); } /** @@ -832,7 +787,7 @@ class AdminActions extends BaseActions $query = sprintf($query, sql_table('actionlog')); $template['content'] = 'actionlist'; - $amount = skinableShowlist($query, 'table', $template, $templateName); + $amount = showlist($query, 'table', $template, $templateName); return; } @@ -853,25 +808,25 @@ class AdminActions extends BaseActions if ( !empty($templateName)) { - $template = skinableTEMPLATE::read($templateName); + $template = Template::read($templateName); } $key = postVar('ackey'); if ( !$key ) { - $this->objAdmin->error(_ERROR_ACTIVATE); + Admin::error(_ERROR_ACTIVATE); } $info = MEMBER::getActivationInfo($key); if ( !$info ) { - $this->objAdmin->error(_ERROR_ACTIVATE); + Admin::error(_ERROR_ACTIVATE); } $mem = MEMBER::createFromId($info->vmember); if ( !$mem ) { - $this->objAdmin->error(_ERROR_ACTIVATE); + Admin::error(_ERROR_ACTIVATE); } switch ( $info->vtype ) { @@ -937,10 +892,10 @@ class AdminActions extends BaseActions switch ( $type ) { case 'title': - echo TEMPLATE::fill($title, $aVars); + echo Template::fill($title, $aVars); break; case 'text': - echo TEMPLATE::fill($text, $aVars); + echo Template::fill($text, $aVars); break; case 'ackey': echo Entity::hsc($key); @@ -950,7 +905,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_addtickettourl() + * AdminActions::parse_addtickettourl() * Parse skinvar addtickettourl * * @param string $url URI for ticket @@ -965,7 +920,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_adminbanlist() + * AdminActions::parse_adminbanlist() * Parse skinvar adminbanlist * * @param string $templateName name of template to use @@ -990,7 +945,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_adminbatchaction() + * AdminActions::parse_adminbatchaction() * Parse skinvar adminbatchaction * * @param void @@ -1003,7 +958,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_adminbatchlist() + * AdminActions::parse_adminbatchlist() * Parse skinvar adminbatchlist * * @param string $templateName name of template to use @@ -1013,24 +968,29 @@ class AdminActions extends BaseActions { global $manager; $templates = array(); + if ( !empty($templateName) ) { $templates = Template::read($templateName); } - if ( isset($templates['ADMIN_BATCHLIST']) || !empty($templates['ADMIN_BATCHLIST']) ) + + if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) ) { - $template = $templates['ADMIN_BATCHLIST']; + $template = '
  • <%text(_BATCH_EXECUTING)%> ' + . '<%adminbatchaction%> ' + . '<%batchlisttype%> ' + . '<%batchid%>... ' + . '<%batchlistmsg%>' + . '
  • ' . "\n"; } else { - $template = '
  • <%text(_BATCH_EXECUTING)%><%adminbatchaction%>' - . '<%batchlisttype%> <%batchid%>...' - . '<%batchlistmsg%>
  • ' . "\n"; + $template = $templates['ADMIN_BATCHLIST']; } $selected = requestIntArray('batch'); $action = requestVar('batchaction'); - + switch ( $this->skintype ) { case 'batchitem': @@ -1071,64 +1031,66 @@ class AdminActions extends BaseActions // walk over all selectedids and perform action foreach ( $selected as $selectedid ) { - $error = ''; + $error = ''; $selectedid = intval($selectedid); switch ( $action ) { case 'delete': if ( $this->skintype != 'batchteam' ) { - $error = $this->objAdmin->$deleteaction($selectedid); + $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid)); } else { - $error = $this->objAdmin->deleteOneTeamMember($blogid, $selectedid); + $error = Admin::deleteOneTeamMember($blogid, $selectedid); } break; case 'move': - $error = $this->objAdmin->$moveaction($selectedid, $destid); + $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid)); break; case 'setadmin': // always succeeds - sql_query('UPDATE ' . $setadminsql . $selectedid); + DB::execute("UPDATE {$setadminsql} {$selectedid};"); $error = ''; break; case 'unsetadmin': // there should always remain at least one super-admin - $r = sql_query($unsetchksql); - if ( sql_num_rows($r) < 2 ) + $r = DB::getResult($unsetchksql); + if ( $r->rowCount() < 2 ) { $error = $unseterrmsg; } else { - sql_query('UPDATE ' . $unsetupsql . $selectedid); + DB::execute("UPDATE {$unsetupsql} {$selectedid};"); } break; default: $error = _BATCH_UNKNOWN . Entity::hsc($action); } + $data = array( 'batchid' => $selectedid, 'batchlisttype' => Entity::hsc($batchlisttype), 'adminbatchaction' => Entity::hsc($action), 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS, ); - $handler = new Actions('template', $template, new ADMIN); - $parser = new Parser($handler); + $handler = new AdminActions('template'); + $parser = new Parser($handler); + + $output = Template::fill($template, $data); ob_start(); - $parser->parse($template); - $template = ob_get_contents(); + $parser->parse($output); + $output = ob_get_contents(); ob_end_clean(); - - echo TEMPLATE::fill($template, $data); - return; + echo "{$output}
    "; } + return; } /** - * Actions::parse_adminbloglink() + * AdminActions::parse_adminbloglink() * Parse skinvar adminbloglink * * @param string $templateName name of template to use @@ -1146,13 +1108,13 @@ class AdminActions extends BaseActions $templates = Template::read($templateName); } - if ( isset($templates['ADMIN_BLOGLINK']) || !empty($templates['ADMIN_BLOGLINK']) ) + if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) ) { - $template = $templates['ADMIN_BLOGLINK']; + $template = '<%blogname%>'; } else { - $template = '<%blogname%>'; + $template = $templates['ADMIN_BLOGLINK']; } $data = array( @@ -1161,12 +1123,12 @@ class AdminActions extends BaseActions 'blogname' => Entity::hsc($blog->getName()) ); - echo TEMPLATE::fill($template, $data); + echo Template::fill($template, $data); return; } /** - * Actions::parse_adminerrormesg() + * AdminActions::parse_adminerrormesg() * Parse skinvar adminerrormesg * * @param void @@ -1185,61 +1147,16 @@ class AdminActions extends BaseActions { $message = cookieVar($CONF['CookiePrefix'] . 'errormessage'); } - elseif ( $this->objAdmin->sessionVar($CONF['CookiePrefix'] . 'errormessage') ) + elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') ) { - $message = $this->objAdmin->sessionVar($CONF['CookiePrefix'] . 'errormessage'); + $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage'); } echo Entity::hsc($message); return; } /** - * Actions::parse_adminparsedinclude() - * Parse skinvar adminparsedinclude - * - * @param string $filename name of file - * @return void - */ - public function parse_adminparsedinclude($filename) - { - // check current level - if ( $this->level > 3) - { - // max. depth reached (avoid endless loop) - return; - } - $skin = new Skin($this->skintype->id); - $file = $this->getIncludeFileName($filename); - - if ( !$skin->isValid && !file_exists($file) ) - { - return; - } - - $contents = $skin->getContent($filename); - - if ( !$contents ) - { - if ( !file_exists($file) ) - { - return; - } - $contents = file_get_contents($file); - if ( empty($contents) ) - { - return; - } - } - $this->level = $this->level + 1; - // parse file contents - $this->parser->parse($contents); - - $this->level = $this->level - 1; - return; - } - - /** - * Actions::parse_adminskineditallowedlist() + * AdminActions::parse_adminskineditallowedlist() * Parse skinvar adminskineditallowedlist * * @param string $type template/blog @@ -1257,21 +1174,22 @@ class AdminActions extends BaseActions $show = array( 'content' => 'shortblognames' ); + Showlist($query, 'table', $show, $templateName); break; case 'template': - $query = "SELECT tdname as name, tddesc as description FROM %s;"; - $query = sprintf($query, sql_table('admintemplate_desc')); + $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'"; + $query = sprintf($query, sql_table('template_desc')); $show = array( 'content' => 'shortnames' ); + Showlist($query, 'table', $show, $templateName); break; } - Showlist($query, 'table', $show, $templateName); return; } /** - * Actions::parse_adminskinielist() + * AdminActions::parse_adminskinielist() * Parse skinvar adminskinielist * * @param string $type skin/template @@ -1285,47 +1203,53 @@ class AdminActions extends BaseActions { $templates = Template::read($templateName); } - if ( isset($templates['SKINIE_EXPORT_LIST']) && !empty($templates['SKINIE_EXPORT_LIST']) ) + + if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) ) { - $template = $templates['SKINIE_EXPORT_LIST']; + $template = "" + . "\" id=\"<%expid%>\" />\n" + . "" + . "\n" + . "<%expdesc%>\n" + . "\n" + . "\n"; } else { - $template = '' . "\n" - . "<%expdesc%>\n" - . "\n"; + $template = $templates['SKINIE_EXPORT_LIST']; } + switch ( $type ) { case 'skin': - $query = "SELECT * FROM %s;"; - $query = sprintf($query, sql_table('adminskin_desc')); - $res = sql_query($query); + $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';"; + $query = sprintf($query, sql_table('skin_desc')); + $res = DB::getResult($query); - while ( $skinObj = sql_fetch_object($res) ) + foreach ( $res as $row ) { $data = array( - 'typeid' => 'skin[' . $skinObj->sdnumber . ']', - 'expid' => 'skinexp' . $skinObj->sdnumber, - 'expname' => Entity::hsc($skinObj->sdname), - 'expdesc' => Entity::hsc($skinObj->sddesc), + 'typeid' => 'skin[' . $row['sdnumber'] . ']', + 'expid' => 'skinexp' . $row['sdnumber'], + 'expname' => Entity::hsc($row['sdname']), + 'expdesc' => Entity::hsc($row['sddesc']), ); - echo TEMPLATE::fill($template, $data); + echo Template::fill($template, $data); } break; case 'template': - $query = "SELECT * FROM %s;"; - $query = sprintf($query, sql_table('admintemplate_desc')); - $res = sql_query($query); - while ( $templateObj = sql_fetch_object($res) ) + $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';"; + $query = sprintf($query, sql_table('template_desc')); + $res = DB::getResult($query); + foreach ( $res as $row ) { $data = array( - 'typeid' => 'template[' . $templateObj->tdnumber . ']', - 'expid' => 'templateexp' . $templateObj->tdnumber, - 'expname' => Entity::hsc($templateObj->tdname), - 'expdesc' => Entity::hsc($templateObj->tddesc), + 'typeid' => 'template[' . $row['tdnumber'] . ']', + 'expid' => 'templateexp' . $row['tdnumber'], + 'expname' => Entity::hsc($row['tdname']), + 'expdesc' => Entity::hsc($row['tddesc']), ); - echo TEMPLATE::fill($template, $data); + echo Template::fill($template, $data); } break; } @@ -1333,7 +1257,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_adminskinoverview() + * AdminActions::parse_adminskinoverview() * Parse skinvar adminskinoverview * * @param string $templateName name of template to use @@ -1341,38 +1265,38 @@ class AdminActions extends BaseActions */ public function parse_adminskinoverview($templateName = '') { - $query = "SELECT * FROM %s ORDER BY sdname;"; - $query = sprintf($query, sql_table('adminskin_desc')); + $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;"; + $query = sprintf($query, sql_table('skin_desc')); - $template['content'] = 'adminskinlist'; - $template['tabindex'] = 10; - $template['friendly_names'] = Skin::getFriendlyNames('AdminActions'); + $template['content'] = 'adminskinlist'; + $template['tabindex'] = 10; + $template['friendly_names'] = $this->parser->skin->getAvailableTypes(); Showlist($query, 'table', $template, $templateName); return; } /** - * Actions::parse_adminskinselectoptions() + * AdminActions::parse_adminskinselectoptions() * Parse skinvar adminskinselectoptions * * @param void * @return void - */ - public function parse_adminskinselectoptions() + */ + public function parse_adminskinselectoptions($templateName = '') { global $CONF; - $query = "SELECT sdname as text, sdnumber as value FROM %s;"; - $query = sprintf($query, sql_table('adminskin_desc')); + $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';"; + $query = sprintf($query, sql_table('skin_desc')); - $template['name'] = 'adminskin'; - $template['selected'] = $CONF['DefaultAdminSkin']; + $template['name'] = 'adminskin'; + $template['selected'] = $CONF['AdminSkin']; $template['tabindex'] = 110; - Showlist($query, 'select', $template, ''); + Showlist($query, 'select', $template, $templateName); return; } /** - * Actions::parse_adminspecialskinlist() + * AdminActions::parse_adminspecialskinlist() * Parse skinvar adminspecialskinlist * * @param string $templateName name of template to use @@ -1385,31 +1309,25 @@ class AdminActions extends BaseActions $templates = Template::read($templateName); } - $nType = Skin::getFriendlyNames('AdminActions'); + $nType = $this->parser->skin->getAvailableTypes(); $skinid = intRequestVar('skinid'); $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;"; - $query = sprintf($query, sql_table('adminskin'), "'" . implode("', '", $nType) . "'", (integer) $skinid); + $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid); - $res = sql_query($query); - if ( $res && sql_num_rows($res) > 0 ) + $res = DB::getResult($query); + if ( $res && $res->rowCount() > 0 ) { - $data = array(); - if ( array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) ) - { - $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD']; - } - else + /* NOTE: set templates for HEAD/BODY/FOOT */ + if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) ) { $template['head'] = "\n"; + } + else + { + $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT']; + } + $tabstart = 120; - while ( $row = sql_fetch_assoc($res) ) + + /* NOTE: do echo */ + $data = array(); + echo $template['head']; + foreach ( $res as $row ) { $data = array( 'tabindex' => $tabstart++, 'skinid' => $skinid, 'skintype' => Entity::hsc(strtolower($row['stype'])) ); - echo TEMPLATE::fill($template['body'], $data); + echo Template::fill($template['body'], $data); } - $data = array(); - if ( array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) ) - { - $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT']; - } - else - { - $template['foot'] = "\n"; - } - echo TEMPLATE::fill($template['foot'], $data); + echo $template['foot']; } return; } /** - * Actions::parse_adminstylesheets() - * Parse skinvar adminstylesheets - * - * @param void - * @return void - */ - public function parse_adminstylesheets() - { - global $CONF; - $includePrefix = $this->skintype->includePrefix; - - if ( strlen($includePrefix) > 0 ) - { - $styleURL = Entity::hsc($CONF['AdminURL']) . 'adminskins/' . $includePrefix . 'admin_' . $CONF['AdminCSS'] . '.css'; - } - else - { - $styleURL = Entity::hsc($CONF['AdminURL']) . 'styles/admin_' . $CONF['AdminCSS'] . '.css'; - } - echo $styleURL; - return; - } - - /** - * Actions::parse_adminstyleselectoptions() - * Parse skinvar adminstyleselectoptions - * - * @param void - * @return void - */ - public function parse_adminstyleselectoptions() - { - global $CONF, $manager, $DIR_NUCLEUS; - if ( strlen($this->skintype->includePrefix) > 0 ) - { - $scndir = $DIR_NUCLEUS . 'adminskins/' . $this->skintype->includePrefix; - } - else - { - $scndir = $DIR_NUCLEUS . 'styles/'; - } - $files = scandir($scndir); - - foreach ( $files as $file ) - { - if ( !preg_match("#^admin_(.*)\.css$#", $file, $matches) ) - { - continue; - } - - $name = $matches[1]; - $opts = '\n"; - } - else - { - $opts .= "\n"; - } - echo $opts; - } - return; - } - - /** - * Actions::parse_admintemplateoverview() + * AdminActions::parse_admintemplateoverview() * Parse skinvar admintemplateoverview * * @param string $templateName name of template to use @@ -1520,10 +1380,10 @@ class AdminActions extends BaseActions */ public function parse_admintemplateoverview($templateName = '') { - $query = "SELECT * FROM %s ORDER BY tdname;"; - $query = sprintf($query, sql_table('admintemplate_desc')); + $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;"; + $query = sprintf($query, sql_table('template_desc')); - $template['content'] = 'admintemplatelist'; + $template['content'] = 'admintemplatelist'; $template['tabindex'] = 10; Showlist($query, 'table', $template, $templateName); @@ -1531,7 +1391,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_allowedadminskinactions() + * AdminActions::parse_allowedadminskinactions() * Parse skinvar allowedadminskinactions * * @param void @@ -1541,11 +1401,12 @@ class AdminActions extends BaseActions { global $DIR_ADMINSKINS; $skinType = strtolower(trim(requestVar('type'))); - $actions = Skin::getAllowedActionsForType($skinType); + $actions = $this->parser->skin->getAllowedActionsForType($skinType); sort($actions); while ( $current = array_shift($actions) ) { + // TODO: remove this // skip deprecated vars if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars') { @@ -1553,7 +1414,6 @@ class AdminActions extends BaseActions } echo helplink("adminskinvar-{$current}") . "$current\n"; -// echo "{$current}\n"; if ( count($actions) != 0 ) { @@ -1564,7 +1424,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_allowedskinactions() + * AdminActions::parse_allowedskinactions() * Parse skinvar allowedskinactions * * @param void @@ -1573,11 +1433,15 @@ class AdminActions extends BaseActions public function parse_allowedskinactions() { $skinType = strtolower(trim(requestVar('type'))); - $actions = SKIN::getAllowedActionsForType($skinType); + $skinid = intRequestVar('skinid'); + + $skin = new Skin($skinid); + $actions = $skin->getAllowedActionsForType($skinType); sort($actions); while ( $current = array_shift($actions) ) { + // TODO: remove this // skip deprecated vars if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' ) { @@ -1596,7 +1460,7 @@ class AdminActions extends BaseActions } /** - * Action::parse_banlistdeletedlist() + * AdminActions::parse_banlistdeletedlist() * Parse skinvar banlistdeletedlist * * @param string $templateName name of template to use @@ -1605,34 +1469,37 @@ class AdminActions extends BaseActions public function parse_banlistdeletedlist($templateName = '') { global $manager; - $templates = array(); + $templates = array(); if ( $templateName ) { $templates = Template::read($templateName); } - if ( isset($templates['BANLIST_DELETED_LIST']) && !empty($templates['BANLIST_DELETED_LIST']) ) + + if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) ) { - $template = $templates['BANLIST_DELETED_LIST']; + $template = "
  • <%blogname%>
  • \n"; } else { - $template = "
  • <%blogname%>
  • \n"; + $template = $templates['BANLIST_DELETED_LIST']; } + $deleted = requestArray('delblogs'); foreach ( $deleted as $delblog ) { $blog =& $manager->getBlog($delblog); $data = array( - Entity::hsc($blog->getName()) + 'blogname' => Entity::hsc($blog->getName()) ); - TEMPLATE::fill($template, $data); + echo Template::fill($template, $data); } + return; } /** - * Actions::parse_batchdeletelist() + * AdminActions::parse_batchdeletelist() * Parse skinvar batchdeletelist * * @param void @@ -1660,7 +1527,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_batchdeletetype() + * AdminActions::parse_batchdeletetype() * Parse skinvar batchdeletetype * * @param void @@ -1673,7 +1540,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_batchmovebtn() + * AdminActions::parse_batchmovebtn() * Parse skinvar batchmovebtn * * @param void @@ -1695,7 +1562,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_batchmovelist() + * AdminActions::parse_batchmovelist() * Parse skinvar batchmovelist * * @param void @@ -1704,15 +1571,17 @@ class AdminActions extends BaseActions public function parse_batchmovelist() { $selected = requestIntArray('batch'); + $count = 0; foreach ( $selected as $select ) { - echo '\n"; + echo '\n"; + $count++; } return; } /** - * Actions::parse_batchmovetitle() + * AdminActions::parse_batchmovetitle() * Parse skinvar batchmovetitle * * @param void @@ -1734,7 +1603,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_batchmovetype() + * AdminActions::parse_batchmovetype() * Parse skinvar batchmovetype * * @param void @@ -1747,13 +1616,13 @@ class AdminActions extends BaseActions } /** - * Actions::parse_blogcatlist() + * AdminActions::parse_blogcatlist() * Parse skinvar blogcatlist * * @param void * @return void */ - public function parse_blogcatlist() + public function parse_blogcatlist($templateName = '') { global $manager; $blogid = intRequestVar('blogid'); @@ -1763,13 +1632,26 @@ class AdminActions extends BaseActions $template['content'] = 'categorylist'; $template['tabindex'] = 200; - $batch = new Batch('member'); - $batch->showlist($query, 'table', $template); + $batch = new Batch('category'); + $batch->showlist($query, 'table', $template, $templateName); + return; + } + + /** + * AdminActions::parse_blogid() + * Parse skinvar blogid + * + * @param void + * @return void + */ + public function parse_blogid() + { + echo intRequestVar('blogid'); return; } /** - * Actions::parse_blognotifysetting() + * AdminActions::parse_blognotifysetting() * Parse skinvar blognotifysetting * * @param void @@ -1807,7 +1689,7 @@ class AdminActions extends BaseActions } /** - * AdminAction::parse_blogselectbox() + * AdminActions::parse_blogselectbox() * Parse skinvar blogselectbox * * @param void @@ -1831,38 +1713,38 @@ class AdminActions extends BaseActions // (only select those blogs that have the user on the team) $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;"; $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds)); - $blogs = sql_query($queryBlogs); + $blogs = DB::getResult($queryBlogs); if ( $mode == 'category' ) { - if ( sql_num_rows($blogs) > 1 ) + if ( $blogs->rowCount() > 1 ) { $multipleBlogs = 1; } - while ( $oBlog = sql_fetch_object($blogs) ) + foreach ( $blogs as $rBlog ) { if ( isset($multipleBlogs) && !empty($multipleBlogs) ) { - echo '\n"; + echo '\n"; } // show selection to create new category when allowed/wanted if ( $showNewCat ) { // check if allowed to do so - if ( $member->blogAdminRights($oBlog->bnumber) ) + if ( $member->blogAdminRights($rBlog['bnumber']) ) { - echo '\n"; + echo '\n"; } } // 2. for each category in that blog - $catQueriy = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;"; - $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber); - $categories = sql_query(sprintf($catQueriy)); - while ( $oCat = sql_fetch_object($categories) ) + $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;"; + $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']); + $categories = DB::getResult($catQuery); + foreach ( $categories as $rCat ) { - if ( $oCat->catid == $selected ) + if ( $rCat['catid'] == $selected ) { $selectText = ' selected="selected" '; } @@ -1870,7 +1752,7 @@ class AdminActions extends BaseActions { $selectText = ''; } - echo '\n"; + echo '\n"; } if ( isset($multipleBlogs) && !empty($multipleBlogs) ) @@ -1882,16 +1764,16 @@ class AdminActions extends BaseActions else { // blog mode - while ( $oBlog = sql_fetch_object($blogs) ) + foreach ( $blogs as $rBlog ) { - echo '\n"; + echo '\n"; } else { - echo '\n"; + echo '\n"; } } } @@ -1900,7 +1782,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_blogsetting() + * AdminActions::parse_blogsetting() * Parse skinvar blogsetting * * @param string $which name of weblog setting @@ -1913,7 +1795,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_blogsettingyesno() + * AdminActions::parse_blogsettingyesno() * Parse skinvar blogsettingyesno * * @param string $type type of weblog setting @@ -1959,7 +1841,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_blogteamlist() + * AdminActions::parse_blogteamlist() * Parse skinvar blogteamlist * * @param string $templateName name of template to use @@ -1978,12 +1860,12 @@ class AdminActions extends BaseActions $template['tabindex'] = 10; $batch = new Batch('team'); - $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName); + $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE); return; } /** - * Actions::parse_blogteammembers() + * AdminActions::parse_blogteammembers() * Parse skinvar blogteammembers * * @param void @@ -1996,16 +1878,17 @@ class AdminActions extends BaseActions . "FROM %s, %s " . "WHERE mnumber=tmember AND tblog=%d;"; $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid); - $res = sql_query($query); + $res = DB::getResult($query); $memberNames = array(); - while ($o = sql_fetch_object($res)) { - $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')'; + foreach ( $res as $row ) + { + $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')'; } echo implode(',', $memberNames); } /** - * Actions::parse_blogtime() + * AdminActions::parse_blogtime() * Parse skinvar blogtime * * @param string $type type of time @@ -2024,9 +1907,9 @@ class AdminActions extends BaseActions } else { - $bid = intRequestVar('blogid'); - $b = $manager->getBlog($bid); - $timestamp = $b->getCorrectTime() + $offset; + $bid = intRequestVar('blogid'); + $b = $manager->getBlog($bid); + $timestamp = $b->getCorrectTime() + $offset; } echo i18n::formatted_datetime($format, $timestamp); @@ -2034,34 +1917,80 @@ class AdminActions extends BaseActions } /** - * Actions::parse_bookmarkletadmin() + * AdminActions::parse_bookmarkletadmin() * Parse skinvar bookmarkletadmin * - * @param string $type type of anchor element for bookmarklet + * @param void * @return void */ - public function parse_bookmarkletadmin($type) + public function parse_bookmarkletadmin() { global $manager; $blogid = intRequestVar('blogid'); - if ( $type != 'regfile' ) + echo Entity::hsc('javascript:' . getBookmarklet($blogid)); + return; + } + + /** + * AdminActions::parse_categories() + * Parse skinvar categories + * + * create category dropdown box + * + * @param string $type name of setting for category + * @return void + */ + public function parse_categories($startidx = 0) + { + global $manager; + + $item = FALSE; + $itemid = intRequestVar('itemid'); + $item = &$manager->getItem($itemid, 1, 1); + + $blog = FALSE; + if ( !$item ) + { + $blogid = intRequestVar('blogid'); + } + else + { + $blogid = $item['blogid']; + } + $blog = &$manager->getBlog($blogid); + + if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' ) + { + $item['body'] = removeBreaks($item['body']); + $item['more'] = removeBreaks($item['more']); + } + + $contents = array(); + if ( requestVar('action') == 'itemedit' ) { - echo Entity::hsc(getBookmarklet($blogid)); + $contents = $item; + } + + if ( !array_key_exists('catid', $contents) || empty($contents['catid']) ) + { + // on add item + $catid = $blog->getDefaultCategory(); } else { - $url = 'index.php?action=regfile&blogid=' . intval($blogid); - $url = $manager->addTicketToUrl($url); - /* TODO: Shift-JIS is not always correct, I think... */ - echo Entity::hsc($url, 'SJIS'); + // on edit item + $catid = $contents['catid']; } + + Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID()); + return; } /** - * Actions::parse_category() + * AdminActions::parse_category() * Parse skinvar category * * @param string $type name of setting for category @@ -2074,7 +2003,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_categorysetting() + * AdminActions::parse_categorysetting() * Parse skinvar categorysetting * * @param string $type type in category setting @@ -2091,23 +2020,62 @@ class AdminActions extends BaseActions $blogid = intRequestVar('blogid'); $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;"; $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid); - $res = sql_query($query); - $obj = sql_fetch_object($res); + $row = DB::getRow($query); - if ( $type != desc ) + if ( $type != 'name' ) { - echo Entity::hsc($obj->cdesc); + echo Entity::hsc($row['cdesc']); } else { - echo Entity::hsc($obj->cname); + echo Entity::hsc($row['cname']); + } + + return; + } + + /** + * AdminActions::parse_codename() + * Parse templatevar codename + * + * @param $value + * @param $name + * + */ + public function parse_checkedonval($value, $name) + { + global $manager; + + $item = false; + $itemid = intRequestVar('itemid'); + $item =& $manager->getItem($itemid, 1, 1); + + $blog =& $manager->getBlog(getBlogIDFromItemID($itemid)); + + if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' ) + { + $item['body'] = removeBreaks($item['body']); + $item['more'] = removeBreaks($item['more']); } + $contents = array(); + if ( requestVar('action') == 'itemedit' ) + { + $contents = $item; + } + if ( !isset($contents[$name]) ) + { + $contents[$name] = ''; + } + if ($contents[$name] == $value) + { + echo 'checked="checked"'; + } return; } /** - * Actions::parse_codename() + * AdminActions::parse_codename() * Parse templatevar codename * * @param void @@ -2123,7 +2091,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_commentnavlist() + * AdminActions::parse_commentnavlist() * Parse skinvar commentnavlist * * @param void @@ -2190,7 +2158,7 @@ class AdminActions extends BaseActions $search = postVar('search'); if ( !empty($search) ) { - $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"'; + $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%'); } $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}"; @@ -2203,7 +2171,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_configsettingsedit() + * AdminActions::parse_configsettingsedit() * Parse skinvar configsettingsedit * * @param string $type type of global configuration @@ -2219,7 +2187,7 @@ class AdminActions extends BaseActions { $query = "INSERT INTO %s VALUES (DefaultListSize, 10);"; $query = sprintf($query, sql_table('config')); - sql_query($query); + DB::execute($query); $CONF['DefaultListSize'] = 10; } elseif ( intval($CONF['DefaultListSize']) < 1 ) @@ -2251,7 +2219,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_configsettingsyesno() + * AdminActions::parse_configsettingsyesno() * Parse skinvar configsettingsyesno * * @param string $type type of global setting @@ -2269,7 +2237,78 @@ class AdminActions extends BaseActions } /** - * Actions::parse_customhelplink() + * AdminActions::parse_contents() + * Parse skinvar contents + * + * @param string $which part for item + * @return void + */ + public function parse_contents($which) + { + global $manager; + + $item = false; + $contents = array(); + + if ( requestVar('action') == 'itemedit' ) + { + $itemid = intRequestVar('itemid'); + $item =& $manager->getItem($itemid, 1, 1); + + $blog =& $manager->getBlog(getBlogIDFromItemID($itemid)); + + if ( $item && $blog->convertBreaks() ) + { + $item['body'] = removeBreaks($item['body']); + $item['more'] = removeBreaks($item['more']); + } + $contents = $item; + } + elseif ( requestVar('action') == 'createitem' ) + { + $blogid = intRequestVar('blogid'); + $blog =& $manager->getBlog($blogid); + $manager->notify( + 'PreAddItemForm', + array( + 'contents' => &$contents, + 'blog' => &$blog + ) + ); + } + + if ( !array_key_exists($which, $contents) ) + { + $contents[$which] = ''; + } + echo Entity::hsc($contents[$which],ENT_QUOTES); + } + + /** + * AdminActions::parse_currenttime() + * Parse skinvar currenttime + * + * @param string $what + */ + // for future items + public function parse_currenttime($what) + { + global $manager; + if ( requestVar('action') == 'itemedit' ) + { + $itemid = intRequestVar('itemid'); + $blog =& $manager->getBlog(getBlogIDFromItemID($itemid)); + } + elseif ( requestVar('action') == 'createitem' ) + { + $blog =& $manager->getBlog(intRequestVar('blogid')); + } + $nu = getdate($blog->getCorrectTime()); + echo $nu[$what]; + } + + /** + * AdminActions::parse_customhelplink() * Parse skinvar customhelplink * * @param string $topic name of topic @@ -2287,7 +2326,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_date() + * AdminActions::parse_date() * Parse skinvar date */ public function parse_date($format = 'c') @@ -2298,7 +2337,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_defaultadminskintypes() + * AdminActions::parse_defaultadminskintypes() * Parse skinvar defaultadminskintypes * * @param string $tabindex index number for tabindex attribute of input element @@ -2308,40 +2347,51 @@ class AdminActions extends BaseActions public function parse_defaultadminskintypes($tabindex, $templateName = '') { $templates = array(); + if ( $templateName ) { $templates = Template::read($templateName); } - $types = Skin::getFriendlyNames('AdminActions'); + $types = $this->parser->skin->getAvailableTypes(); ksort($types); - if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) ) + /* NOTE: set templates for HEAD/BODY/FOOT */ + if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) ) { - $template['head'] = $templates['ADMINSKINTYPELIST_HEAD']; + $template['head'] = "\n"; - } echo $template['foot']; + return; } /** - * Actions::parse_defblogselect() + * AdminActions::parse_defblogselect() * Parse skinvar defblogselect * * @param string $templateName name of template @@ -2375,17 +2417,21 @@ class AdminActions extends BaseActions public function parse_defblogselect($templateName = '') { global $CONF; - $query = "SELECT bname as text, bnumber as value FROM %s;"; + + $query = "SELECT bname as text, bnumber as value FROM %s;"; $query = sprintf($query, sql_table('blog')); - $template['name'] = 'DefaultBlog'; + + $template['name'] = 'DefaultBlog'; $template['selected'] = $CONF['DefaultBlog']; $template['tabindex'] = 10; + Showlist($query, 'select', $template, $templateName); + return; } /** - * Actions::parse_defcatselect() + * AdminActions::parse_defcatselect() * Parse skinvar defcatselect * * @param string $templateName name of template @@ -2394,19 +2440,24 @@ class AdminActions extends BaseActions public function parse_defcatselect($templateName = '') { global $manager; + $blogid = intRequestVar('blogid'); - $blog = $manager->getBlog($blogid); - $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;"; + $blog = $manager->getBlog($blogid); + + $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;"; $query = sprintf($query, sql_table('category'), (integer) $blog->getID()); + $template['name'] = 'defcat'; $template['selected'] = $blog->getDefaultCategory(); $template['tabindex'] = 110; + Showlist($query, 'select', $template, $templateName); + return; } /** - * Actions::parse_defskinselect() + * AdminActions::parse_defskinselect() * Parse skinvar defskinselect * * @param string $type type of skin @@ -2415,20 +2466,20 @@ class AdminActions extends BaseActions */ public function parse_defskinselect($type = 'blog', $templateName = '') { - global $manager; - $query = "SELECT sdname as text, sdnumber as value FROM %s;"; + global $CONF, $manager; + + $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';"; $query = sprintf($query, sql_table('skin_desc')); $blogid = intRequestVar('blogid'); if ( !$blogid ) { - global $CONF; $template['selected'] = $CONF['BaseSkin']; } else { - $blog = $manager->getBlog($blogid); + $blog = $manager->getBlog($blogid); $template['selected'] = $blog->getDefaultSkin(); } @@ -2443,7 +2494,9 @@ class AdminActions extends BaseActions $template['name'] = $nname; $template['tabindex'] = 50; + Showlist($query, 'select', $template, $templateName); + return; } @@ -2482,7 +2535,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_deleteitembody() + * AdminActions::parse_deleteitembody() * Parse skinvar deleteitembody * * @param void @@ -2491,15 +2544,19 @@ class AdminActions extends BaseActions public function parse_deleteitembody() { global $manager; + $itemid = intRequestVar('itemid'); - $item =& $manager->getItem($itemid, 1, 1); - $body = strip_tags($item['body']); + $item =& $manager->getItem($itemid, 1, 1); + + $body = strip_tags($item['body']); + echo Entity::hsc(shorten($body, 300, '...')); + return; } /** - * Actions::parse_deleteitemid() + * AdminActions::parse_deleteitemid() * Parse skinvar deleteitemid * * @param void @@ -2512,7 +2569,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_deleteitemtitle() + * AdminActions::parse_deleteitemtitle() * Parse skinvar deleteitemtitle * * @param void @@ -2521,14 +2578,17 @@ class AdminActions extends BaseActions public function parse_deleteitemtitle() { global $manager; + $itemid = intRequestVar('itemid'); - $item =& $manager->getItem($itemid, 1, 1); + $item =& $manager->getItem($itemid, 1, 1); + echo Entity::hsc(strip_tags($item['title'])); + return; } /** - * Actions::parse_editadminskin() + * AdminActions::parse_editadminskin() * Parse skinvar editadminskin * * @param string $type type of skin setting @@ -2564,7 +2624,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_editadminskintype() + * AdminActions::parse_editadminskintype() * Parse skinvar editadminskintype * * @param string $type name of skin type @@ -2573,9 +2633,8 @@ class AdminActions extends BaseActions public function parse_editadminskintype($type = 'id') { global $CONF, $manager, $member; - $skinid = intRequestVar('skinid'); - $skin = new Skin($skinid); - $fNames = Skin::getFriendlyNames(); + + $fNames = $this->parser->skin->getAvailableTypes(); $sType = strtolower(trim(requestVar('type'))); switch ( $type ) @@ -2584,16 +2643,16 @@ class AdminActions extends BaseActions echo intRequestVar('skinid'); break; case 'name': - echo Entity::hsc($skin->getName()); + echo Entity::hsc($this->parser->skin->getName()); break; case 'desc': - echo Entity::hsc($skin->getDescription()); + echo Entity::hsc($this->parser->skin->getDescription()); break; case 'type': - echo Entity::hsc($skin->getContentType()); + echo Entity::hsc($this->parser->skin->getContentType()); break; case 'content': - echo Entity::hsc($skin->getContent($sType)); + echo Entity::hsc($this->parser->skin->getContentFromDB($sType)); break; case 'skintype': $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType]; @@ -2603,7 +2662,7 @@ class AdminActions extends BaseActions echo Entity::hsc($sType); break; case 'prefix': - echo Entity::hsc($skin->getIncludePrefix()); + echo Entity::hsc($this->parser->skin->getIncludePrefix()); break; case 'mode': $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL; @@ -2616,81 +2675,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_editadmintemplateinfo() - * Parse skinvar editadmintemplateinfo - * - * @param string $type type of skin template - * @param string $description description of template - * @param string $name name of stemplate - * @param string $tabindex index number for tabindex attribute of input element - * @param string $big - * @param string $tplt - */ - public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '') - { - global $manager; - $templateid = intRequestVar('templateid'); - $templatename = Template::getNameFromId($templateid); - $templatedescription = Template::getDesc($templateid); - $template =& Template::read($templatename); - switch ( $type ) - { - case 'id': - echo intval($templateid); - break; - case 'name': - echo Entity::hsc($templatename); - break; - case 'desc': - echo Entity::hsc($templatedescription); - break; - case 'extratemplate': - $tabidx = 600; - $pluginfields = array(); - $manager->notify( - 'AdminTemplateExtraFields', - array( - 'fields' => &$pluginfields - ) - ); - $tmplt = array(); - if ( $description ) - { - $tmplt = Template::read($description); - } - if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) ) - { - $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME']; - } - else - { - $base = "\n" - . "\n" - . "\t" . '<%explugtplname%>' . "\n"; - } - foreach ( $pluginfields as $pfkey => $pfvalue ) - { - $data = array( - 'explugtplname' => Entity::hsc($pfkey) - ); - echo TEMPLATE::fill($base, $data); - foreach ( $pfvalue as $pffield => $pfdesc ) - { - $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name); - } - } - break; - default: - $desc = defined($description) ? constant($description) : $description; - $name = defined($name) ? constant($name) : $name; - $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt); - break; - } - return; - } - - /** - * Actions::parse_editcomment() + * AdminActions::parse_editcomment() * Parse skinvar editcomment * * @param string $type type of comment setting @@ -2699,6 +2684,7 @@ class AdminActions extends BaseActions public function parse_editcomment($type = 'id') { global $manager; + $commentid = intRequestVar('commentid'); $comment = COMMENT::getComment($commentid); @@ -2710,13 +2696,13 @@ class AdminActions extends BaseActions echo intRequestVar('commentid'); break; case 'user': - if (array_key_exists('member', $comment) && !empty($comment['member']) ) + if ( !array_key_exists('member', $comment) || empty($comment['member']) ) { - echo $comment['member'] . " (" . _EDITC_MEMBER . ")"; + echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")"; } else { - echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")"; + echo $comment['member'] . " (" . _EDITC_MEMBER . ")"; } break; case 'date': @@ -2726,6 +2712,13 @@ class AdminActions extends BaseActions $comment['body'] = str_replace('
    ', '', $comment['body']); $comment['body'] = preg_replace("#[^<]*#", "\\1", $comment['body']); echo $comment['body']; + break; + case 'cmail': + echo $comment['userid']; + break; + case 'url': + echo $comment['userid']; + break; default: echo $comment[$type]; break; @@ -2734,7 +2727,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_editdesturl() + * AdminActions::parse_editdesturl() * Parse skinvar editdesturl */ public function parse_editdesturl() @@ -2747,7 +2740,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_editmemberlist() + * AdminActions::parse_editmemberlist() * Parse skinvar editmemberlist * * @param string $templateName name of template @@ -2758,11 +2751,11 @@ class AdminActions extends BaseActions global $manager; // show list of members with actions $query = 'SELECT * FROM '.sql_table('member'); - $template['content'] = 'memberlist'; + $template['content'] = 'memberlist'; $template['tabindex'] = 10; $batch = new Batch('member'); - $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName); + $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE); return; } @@ -2777,8 +2770,9 @@ class AdminActions extends BaseActions public function parse_editmember($type = 'id', $templateName = '') { global $CONF, $manager, $member; - $memberid = intRequestVar('memberid'); - $mem = MEMBER::createFromID($memberid); + + $memberid = intRequestVar('memberid'); + $mem = MEMBER::createFromID($memberid); switch ( $type ) { @@ -2831,7 +2825,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_editpluginfo() + * AdminActions::parse_editpluginfo() * Parse skinvar editpluginfo * * @param string $type type of plugin info @@ -2839,6 +2833,8 @@ class AdminActions extends BaseActions */ public function parse_editpluginfo($type) { + global $manager; + $pid = intRequestVar('plugid'); switch ( $type ) { @@ -2846,14 +2842,14 @@ class AdminActions extends BaseActions echo $pid; break; case 'name': - echo Entity::hsc(getPluginNameFromPid($pid)); + echo Entity::hsc($manager->getPluginNameFromPid($pid)); break; } return; } /** - * Actions::parse_editplugoptionslist() + * AdminActions::parse_editplugoptionslist() * Parse skinvar editplugoptionslist * * @param string $templateName name of template @@ -2867,21 +2863,20 @@ class AdminActions extends BaseActions $aOptions = array(); $aOIDs = array(); - $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC"; + $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;"; $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid); - $resource = sql_query($query); + $resource = DB::getResult($query); - while ( $o = sql_fetch_object($resource) ) - { - array_push($aOIDs, $o->oid); - $aOptions[$o->oid] = array( - - 'oid' => $o->oid, - 'value' => $o->odef, - 'name' => $o->oname, - 'description' => $o->odesc, - 'type' => $o->otype, - 'typeinfo' => $o->oextra, + foreach ( $resource as $row ) + { + array_push($aOIDs, $row['oid']); + $aOptions[$row['oid']] = array( + 'oid' => $row['oid'], + 'value' => $row['odef'], + 'name' => $row['oname'], + 'description' => $row['odesc'], + 'type' => $row['otype'], + 'typeinfo' => $row['oextra'], 'contextid' => 0 ); } @@ -2892,26 +2887,26 @@ class AdminActions extends BaseActions $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)'; $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs)); - $result = sql_query($query); + $result = DB::getResult($query); - while ( $o = sql_fetch_object($result) ) + foreach ( $result as $row ) { - $aOptions[$o->oid]['value'] = $o->ovalue; + $aOptions[$row['oid']]['value'] = $row['ovalue']; } } // call plugins - $manager->notify( - 'PrePluginOptionsEdit', - array( - 'context' => 'global', - 'plugid' => $pid, - 'options' => &$aOptions - ) + $data = array( + 'context' => 'global', + 'plugid' => $pid, + 'options' => &$aOptions ); + $manager->notify('PrePluginOptionsEdit', $data); $template['content'] = 'plugoptionlist'; - $amount = Showlist($aOptions, 'table', $template, $templateName); + + $amount = Showlist($aOptions, 'table', $template, $templateName); + if ( $amount == 0 ) { echo '

    ' . _ERROR_NOPLUGOPTIONS . "

    \n"; @@ -2920,7 +2915,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_editskin() + * AdminActions::parse_editskin() * Parse skinvar editskin * * @param string $type type of skin @@ -2956,7 +2951,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_editskintype() + * AdminActions::parse_editskintype() * Parse skinvar editskintype * * @param string $type name of type for skin type @@ -2965,10 +2960,10 @@ class AdminActions extends BaseActions public function parse_editskintype($type = 'id') { global $CONF, $manager, $member; - $skinid = intRequestVar('skinid'); - $skin = new SKIN($skinid); - $fNames = SKIN::getFriendlyNames('Actions'); - $sType = strtolower(trim(requestVar('type'))); + $skinid = intRequestVar('skinid'); + $skin = new SKIN($skinid); + $fNames = $skin->getAvailableTypes(); + $sType = strtolower(trim(requestVar('type'))); switch ( $type ) { @@ -2985,7 +2980,7 @@ class AdminActions extends BaseActions echo Entity::hsc($skin->getContentType()); break; case 'content': - echo Entity::hsc($skin->getContent($sType)); + echo Entity::hsc($skin->getContentFromDB($sType)); break; case 'skintype': $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType]; @@ -3008,7 +3003,21 @@ class AdminActions extends BaseActions } /** - * Actions::parse_edittemplateinfo() + * AdminActions::parse_adminurl() + * Parse skinvar adminurl + * (shortcut for admin url) + * + * @param void + * @return void + */ + public function parse_adminurl() + { + $this->parse_sitevar('adminurl'); + return; + } + + /** + * AdminActions::parse_edittemplateinfo() * Parse skinvar edittemplateinfo * * @param string $type name of type for skin @@ -3018,71 +3027,146 @@ class AdminActions extends BaseActions * @param string $tabindex index value for tabindex attribute of input element * @param string $big * @param string $tplt name of template + * @return boolean */ - public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '') + public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '') { global $manager; - $templateid = intRequestVar('templateid'); - $templatename = TEMPLATE::getNameFromId($templateid); - $templatedescription = TEMPLATE::getDesc($templateid); - $template =& $manager->getTemplate($templatename); + + $t_id = intRequestVar('templateid'); + $t_name = Template::getNameFromId($t_id); + $t_desc = Template::getDesc($t_id); + $template = &Template::read($t_name); + switch ( $type ) { case 'id': - echo intval($templateid); + echo intval($t_id); break; case 'name': - echo Entity::hsc($templatename); + echo Entity::hsc($t_name); break; case 'desc': - echo Entity::hsc($templatedescription); + echo Entity::hsc($t_desc); break; case 'extratemplate': - $tabidx = 600; + $tabidx = 600; $pluginfields = array(); - $manager->notify( - 'TemplateExtraFields', - array( - 'fields' => &$pluginfields - ) - ); + $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields)); + $tmplt = array(); - if ( $description ) + if ( $desc ) + { + $tmplt = Template::read($desc); + } + if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) ) { - $tmplt = Template::read($description); + $base = "\n" + . "\n" + . '<%explugtplname%>' . "\n"; } - if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) ) + else { $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME']; } + + foreach ( $pluginfields as $pfkey => $pfvalue ) + { + $data = array('explugtplname' => Entity::hsc($pfkey)); + + echo Template::fill($base, $data); + + foreach ( $pfvalue as $pffield => $pfdesc ) + { + $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name); + } + } + break; + default: + $desc = defined($desc) ? constant($desc) : $desc; + $name = defined($name) ? constant($name) : $name; + $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt); + break; + } + + return; + } + + /** + * AdminActions::parse_editadmintemplateinfo() + * Parse skinvar editadmintemplateinfo + * + * @param string $type type of skin template + * @param string $description description of template + * @param string $name name of stemplate + * @param string $tabindex index number for tabindex attribute of input element + * @param string $big + * @param string $tplt + */ + public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '') + { + global $manager; + + $t_id = intRequestVar('templateid'); + $t_name = Template::getNameFromId($t_id); + $t_desc = Template::getDesc($t_id); + $template = &Template::read($t_name); + + switch ( $type ) + { + case 'id': + echo intval($t_id); + break; + case 'name': + echo Entity::hsc($t_name); + break; + case 'desc': + echo Entity::hsc($t_desc); + break; + case 'extratemplate': + $tabidx = 600; + $pluginfields = array(); + $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields)); + + $tmplt = array(); + if ( $desc ) + { + $tmplt = Template::read($desc); + } + if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) ) + { + $base = "\n" + . "\n" + . '<%explugtplname%>' . "\n"; + } else { - $base = "\n" - . "\t" . '<%explugtplname%>' . "\n"; + $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME']; } + foreach ( $pluginfields as $pfkey => $pfvalue ) { - $data = array( - 'explugtplname' => Entity::hsc($pfkey) - ); - echo TEMPLATE::fill($base, $data); + $data = array('explugtplname' => Entity::hsc($pfkey)); + + echo Template::fill($base, $data); + foreach ( $pfvalue as $pffield => $pfdesc ) { - $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name); + $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name); } } break; default: - $desc = defined($description) ? constant($description) : $description; + $desc = defined($desc) ? constant($desc) : $desc; $name = defined($name) ? constant($name) : $name; - $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt); + $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt); break; } return; } /** - * Actions::parse_eventformextra() + * AdminActions::parse_eventformextra() * Parse skinvar eventformextra * * @param string $type name of type for event form extra @@ -3091,33 +3175,34 @@ class AdminActions extends BaseActions public function parse_eventformextra($type = 'activation') { global $manager; + + $data = array(); + switch ( $type ) { case 'activation': $key = requestVar('ackey'); if ( !$key ) { - $this->objAdmin->error(_ERROR_ACTIVATE); + Admin::error(_ERROR_ACTIVATE); } $info = MEMBER::getActivationInfo($key); if ( !$info ) { - $this->objAdmin->error(_ERROR_ACTIVATE); + Admin::error(_ERROR_ACTIVATE); } $mem = MEMBER::createFromId($info->vmember); if ( !$mem ) { - $this->objAdmin->error(_ERROR_ACTIVATE); + Admin::error(_ERROR_ACTIVATE); } $data = array( - 'type' => 'activation', - 'member' => $mem + 'type' => 'activation', + 'member' => $mem ); break; case 'membermailform-notloggedin': - $data = array( - 'type' => 'membermailform-notloggedin', - ); + $data = array('type' => 'membermailform-notloggedin',); break; } $manager->notify('FormExtra', $data); @@ -3125,31 +3210,164 @@ class AdminActions extends BaseActions } /** - * Actions::parse_extrahead() + * AdminActions::parse_extrahead() * Parse skinvar extrahead */ public function parse_extrahead() { global $manager; - $extrahead = $this->objAdmin->extrahead; - $manager->notify( - 'AdminPrePageHead', - array( - 'extrahead' => &$extrahead, - 'action' => $this->objAdmin->action - ) + + $extrahead = Admin::getAdminextrahead(); + + $data = array( + 'extrahead' => &$extrahead, + 'action' => Admin::getAdminAction() ); + + $manager->notify('AdminPrePageHead', $data); echo $extrahead; return; } /** + * AdminActions::parse_member() + * Parse skinvar member + * (includes a member info thingie) + * + * @param string $what which memberdata is needed + * @return void + */ + public function parse_member($what) + { + global $memberinfo, $member, $CONF; + + // 1. only allow the member-details-page specific variables on member pages + if ( $this->skintype == 'member' ) + { + switch( $what ) + { + case 'name': + echo Entity::hsc($memberinfo->getDisplayName()); + break; + case 'realname': + echo Entity::hsc($memberinfo->getRealName()); + break; + case 'notes': + echo Entity::hsc($memberinfo->getNotes()); + break; + case 'url': + echo Entity::hsc($memberinfo->getURL()); + break; + case 'email': + echo Entity::hsc($memberinfo->getEmail()); + break; + case 'id': + echo Entity::hsc($memberinfo->getID()); + break; + } + } + + // 2. the next bunch of options is available everywhere, as long as the user is logged in + if ( $member->isLoggedIn() ) + { + switch( $what ) + { + case 'yourname': + echo $member->getDisplayName(); + break; + case 'yourrealname': + echo $member->getRealName(); + break; + case 'yournotes': + echo $member->getNotes(); + break; + case 'yoururl': + echo $member->getURL(); + break; + case 'youremail': + echo $member->getEmail(); + break; + case 'yourid': + echo $member->getID(); + break; + case 'yourprofileurl': + if ( $CONF['URLMode'] == 'pathinfo' ) + { + echo Link::create_member_link($member->getID()); + } + else + { + echo $CONF['IndexURL'] . Link::create_member_link($member->getID()); + } + break; + } + } + return; + } + + /** + * AdminActions::parse_version() + * Parse skinvar version + * (include nucleus versionnumber) + * + * @param void + * @return void + */ + public function parse_version() + { + global $nucleus; + echo 'Nucleus CMS ' . $nucleus['version']; + return; + } + + /** + * AdminActions::parse_sitevar() + * Parse skinvar sitevar + * (include a sitevar) + * + * @param string $which + * @return void + */ + public function parse_sitevar($which) + { + global $CONF; + switch ( $which ) + { + case 'url': + echo $CONF['IndexURL']; + break; + case 'name': + echo $CONF['SiteName']; + break; + case 'admin': + echo $CONF['AdminEmail']; + break; + case 'adminurl': + echo $CONF['AdminURL']; + } + return; + } + + /** + * AdminActions::parse_charset() + * Parse skinvar charset + * + * @param void + * @return void + */ + public function parse_charset() + { + echo i18n::get_current_charset(); + return; + } + + /** * AdminActions::parse_getblogsetting() * Parse skinvar getblogsetting */ public function parse_getblogsetting($which) { - global $blog; + global $blog, $manager; if ( $blog ) { @@ -3157,7 +3375,6 @@ class AdminActions extends BaseActions } elseif ( $bid = intRequestVar('blogid') ) { - global $manager; $b = $manager->getBlog($bid); } else @@ -3199,7 +3416,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_geteditpluginfo() + * AdminActions::parse_geteditpluginfo() * Parse skinvar geteditpluginfo * * @param string $type name of setting for edit plugin info @@ -3214,14 +3431,14 @@ class AdminActions extends BaseActions return $pid; break; case 'name': - return Entity::hsc(getPluginNameFromPid($pid)); + return Entity::hsc($manager->getPluginNameFromPid($pid)); break; } return; } /** - * Actions::parse_getmember() + * AdminActions::parse_getmember() * Parse skinvar getmember * (includes a member info thingie) * @@ -3285,7 +3502,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_headmessage() + * AdminActions::parse_headmessage() * Parse skinvar headmessage * * @param void @@ -3293,15 +3510,15 @@ class AdminActions extends BaseActions */ public function parse_headmessage() { - if ( !empty($this->objAdmin->headMess) ) + if ( !empty(Admin::$headMess) ) { - echo '

    ' . _MESSAGE . ': ' . Entity::hsc($this->objAdmin->headMess) . "

    \n"; + echo '

    ' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "

    \n"; } return; } /** - * Actions::parse_helplink() + * AdminActions::parse_helplink() * Parse skinvar helplink * * @param string $topic name of topic for help @@ -3309,16 +3526,15 @@ class AdminActions extends BaseActions */ public function parse_helplink($topic = '') { - if ( empty($topic) ) + if ( !empty($topic) ) { - return; + help($topic); } - help($topic); return; } /** - * Actions::parse_helpplugname() + * AdminActions::parse_helpplugname() * Parse skinvar helpplugname * * @param void @@ -3327,12 +3543,12 @@ class AdminActions extends BaseActions public function parse_helpplugname() { $plugid = intGetVar('plugid'); - Entity::hsc(getPluginNameFromPid($plugid)); + Entity::hsc($manager->getPluginNameFromPid($plugid)); return; } /** - * Actions::parse_ilistaddnew() + * AdminActions::parse_ilistaddnew() * Parse skinvar ilistaddnew * * @param void @@ -3349,7 +3565,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_importskininfo() + * AdminActions::parse_importskininfo() * Parse skinvar importskininfo * * @param string $type name of information for imported skin @@ -3389,7 +3605,45 @@ class AdminActions extends BaseActions } /** - * Actions::parse_inputyesno() + * AdminActions::parse_inputyesno() + * Parse skinvar inputyesno + * + * some init stuff for all forms + * + * @param void + * @return void + */ + public function parse_init() + { + global $manager; + + $item = false; + if ( requestVar('action') == 'itemedit' ) + { + $itemid = intRequestVar('itemid'); + $item =& $manager->getItem($itemid, 1, 1); + + $blog =& $manager->getBlog(getBlogIDFromItemID($itemid)); + if ( $item && $blog->convertBreaks() ) + { + $item['body'] = removeBreaks($item['body']); + $item['more'] = removeBreaks($item['more']); + } + $contents = $item; + $authorid = $contents['authorid']; + } + elseif ( requestVar('action') == 'createitem' ) + { + $blogid = intRequestVar('blogid'); + $blog =& $manager->getBlog($blogid); + $authorid = ''; + } + $blog->insertJavaScriptInfo($authorid); + return; + } + + /** + * AdminActions::parse_inputyesno() * Parse skinvar inputyesno * * @param string $name @@ -3410,12 +3664,12 @@ class AdminActions extends BaseActions } /** - * Actions::parse_insertpluginfo() + * AdminActions::parse_insertpluginfo() * Parse templatevar insertpluginfo */ public function parse_insertpluginfo($type) { - $option = $this->objAdmin; + $option = Admin::getAdminaOption(); switch ( $type ) { case 'id': @@ -3429,7 +3683,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_insertpluginoptions() + * AdminActions::parse_insertpluginoptions() * Parse skinvar insertpluginoptions * * @param string $templateName name of template @@ -3437,7 +3691,7 @@ class AdminActions extends BaseActions */ public function parse_insertpluginoptions($templateName = '') { - $options = $this->objAdmin->aOptions; + $options = Admin::getAdminaOption(); $template = array(); $templats = array(); @@ -3445,36 +3699,47 @@ class AdminActions extends BaseActions { $templates = Template::read($templateName); } - if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) ) + + if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) ) { - $template['title'] = $templates['INSERT_PLUGOPTION_TITLE']; + $template['title'] = "" + . "<%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%>" + . "\n"; } else { - $template['title'] = '<%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%>' . "\n"; + $template['title'] = $templates['INSERT_PLUGOPTION_TITLE']; } - if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) ) + + if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) ) { - $template['body'] = $templates['INSERT_PLUGOPTION_BODY']; + $template['body'] = "" + . "<%listplugplugoptionrow%>" + . "\n"; } else { - $template['body'] = '<%listplugplugoptionrow%>' . "\n"; + $template['body'] = $templates['INSERT_PLUGOPTION_BODY']; } $prevPid = -1; + include_libs('ACTIONS.php'); + $handler = new Actions($this->skintype); + $parser = new PARSER($handler); + foreach ( $options as $option ) { - $handler = new Actions($this->skintype, $template, $option); - $parser = new PARSER(Actions::getDefinedActions(), $handler); + // new plugin? if ( $prevPid != $option['pid'] ) { $prevPid = $option['pid']; $parser->parse($template['title']); } + $meta = NucleusPlugin::getOptionMeta($option['typeinfo']); + if ( @$meta['access'] != 'hidden' ) { $parsed = $parser->parse($template['body']); @@ -3484,7 +3749,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_insplugoptcontent() + * AdminActions::parse_insplugoptcontent() * Parse skinvar insplugoptcontent * * @param void @@ -3492,10 +3757,10 @@ class AdminActions extends BaseActions */ public function parse_insplugoptcontent() { - $option = $this->objAdmin->aOption; + $option = Admin::getAdminaOption(); - $meta = NucleusPlugin::getOptionMeta($option['typeinfo']); - if (array_key_exists('access', $meta) && $meta['access'] != 'hidden') + $meta = NucleusPlugin::getOptionMeta($option['typeinfo']); + if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' ) { echo ''; listplug_plugOptionRow($option); @@ -3505,7 +3770,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_iprangeinput() + * AdminActions::parse_iprangeinput() * Parse skinvar iprangeinput * * @param void @@ -3516,11 +3781,11 @@ class AdminActions extends BaseActions if ( requestVar('ip') ) { $iprangeVal = Entity::hsc(requestVar('ip')); - echo '' . "\n"; - echo '
    \n"; + echo "\n"; + echo "
    \n"; echo '' . "\n"; echo '' . "\n"; - echo '' . "\n"; + echo "\n"; } else { @@ -3531,62 +3796,49 @@ class AdminActions extends BaseActions } /** - * Actions::parse_itemnavlist() + * AdminActions::parse_itemnavlist() * Parse skinvar itemnavlist * * @param void * @return void */ - public function parse_itemnavlist() + public function parse_itemnavlist($templateName) { global $CONF, $manager, $member; - if ( $this->skintype == 'itemlist' ) - { - $blogid = intRequestVar('blogid'); - $blog =& $manager->getBlog($blogid); - } - if ( postVar('start') ) - { - $start = intPostVar('start'); - } - else - { - $start = 0; - } - // amount of items to show - if ( postVar('amount') ) - { - $amount = intPostVar('amount'); - } - else - { - $amount = intval($CONF['DefaultListSize']); - if ( $amount < 1 ) - { - $amount = 10; - } - } $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime" - . " FROM %s, %s, %s" - . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid;"; + . " FROM %s, %s, %s, %s" + . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid"; $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category')); if ( $this->skintype == 'itemlist' ) { - $query .= 'and iblog = ' . $blogid; + $blog = FALSE; + if ( array_key_exists('blogid', $_REQUEST) ) + { + $blogid = intRequestVar('blogid'); + } + else if ( array_key_exists('itemid', $_REQUEST) ) + { + $itemid = intRequestVar('itemid'); + $item = &$manager->getItem($itemid, 1, 1); + $blogid = (integer) $item['blogid']; + } + $blog =& $manager->getBlog($blogid); + + $query .= " AND iblog={$blogid}"; $template['now'] = $blog->getCorrectTime(time()); // non-blog-admins can only edit/delete their own items if ( !$member->blogAdminRights($blogid) ) { - $query .= ' and iauthor = ' . $member->getID(); + $query .= ' AND iauthor = ' . $member->getID(); } } elseif ( $this->skintype == 'browseownitems' ) { - $query .= 'and iauthor = ' . $member->getID(); + $query .= ' AND iauthor = ' . $member->getID(); $blogid = 0; $template['now'] = time(); } @@ -3596,22 +3848,87 @@ class AdminActions extends BaseActions if ( !empty($search) ) { - $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") ' - . ' OR (ibody LIKE "%' . sql_real_escape_string($search) . '%") ' - . ' OR (imore LIKE "%' . sql_real_escape_string($search) . '%"))'; + $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') ' + . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') ' + . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))'; } - $query .= ' ORDER BY itime DESC' + + if ( postVar('start') ) + { + $start = intPostVar('start'); + } + else + { + $start = 0; + } + + // amount of items to show + if ( postVar('amount') ) + { + $amount = intPostVar('amount'); + } + else + { + $amount = (integer) $CONF['DefaultListSize']; + if ( $amount < 1 ) + { + $amount = 10; + } + } + + $query .= ' ORDER BY itime DESC' . " LIMIT {$start},{$amount}"; $template['content'] = 'itemlist'; - + $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0); - $navList->showBatchList('item', $query, 'table', $template); + $navList->showBatchList('item', $query, 'table', $template, '', $templateName); + return; + } + + /** + * AdminActions::parse_itemtime() + * date change on edit item + * + * @param string $key key of PHP's getDate() + * @return void + */ + public function parse_itemtime($key) + { + global $manager; + + $item = false; + $itemid = intRequestVar('itemid'); + $item =& $manager->getItem($itemid, 1, 1); + + $blog =& $manager->getBlog(getBlogIDFromItemID($itemid)); + + if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' ) + { + $item['body'] = removeBreaks($item['body']); + $item['more'] = removeBreaks($item['more']); + } + + $contents = array(); + if ( requestVar('action') == 'itemedit' ) + { + $contents = $item; + } + elseif ( requestVar('action') == 'createitem' ) + { + $data = array( + 'contents' => &$contents, + 'blog' => &$this->blog + ); + $manager->notify('PreAddItemForm', $data); + } + $itemtime = getdate($contents['timestamp']); + echo $itemtime[$key]; return; } /** - * Actions::parse_jstoolbaroptions() + * AdminActions::parse_jstoolbaroptions() * Parse skinvar jstoolbaroptions * * @param void @@ -3625,6 +3942,7 @@ class AdminActions extends BaseActions _SETTINGS_JSTOOLBAR_SIMPLE, _SETTINGS_JSTOOLBAR_FULL ); + $i = 1; foreach ( $options as $option ) { @@ -3635,9 +3953,8 @@ class AdminActions extends BaseActions } return; } - /** - * Actions::parse_localeselectoptions() + * AdminActions::parse_localeselectoptions() * Parse skinvar localeselectoptions * * @param void @@ -3646,7 +3963,8 @@ class AdminActions extends BaseActions public function parse_localeselectoptions() { $locales = i18n::get_available_locale_list(); - $memid = intRequestVar('memberid'); + + $memid = intRequestVar('memberid'); if ( $memid ) { $mem = MEMBER::createFromID($memid); @@ -3665,10 +3983,18 @@ class AdminActions extends BaseActions { echo "\n"; } + else + { + echo "\n"; + } } foreach ( $locales as $locale ) { - if ($memid) + if ( $locale == 'en_Latn_US' ) + { + continue; + } + else if ($memid) { if ( $locale == $mem->getLocale() ) { @@ -3695,7 +4021,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_listplugplugoptionrow() + * AdminActions::parse_listplugplugoptionrow() * Parse templatevar listplugplugoptionrow * * @param string $templateName name of template @@ -3703,13 +4029,12 @@ class AdminActions extends BaseActions */ public function parse_listplugplugoptionrow($templateName = '') { - $option = $this->objAdmin; - echo listplug_plugOptionRow($option, $templateName); + echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName); return; } /** - * Actions::parse_mediadirwarning() + * AdminActions::parse_mediadirwarning() * Parse skinvar mediadirwarning * * @param void @@ -3734,7 +4059,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_movedistselect() + * AdminActions::parse_movedistselect() * Parse skinvar movedistselect */ public function parse_movedistselect() @@ -3743,18 +4068,18 @@ class AdminActions extends BaseActions switch ( $actionType ) { case 'batchitem': - $this->objAdmin->selectBlogCategory('destcatid'); + Admin::selectBlogCategory('destcatid'); break; case 'batchcategory': - $this->objAdmin->selectBlog('destblogid'); + Admin::selectBlog('destblogid'); break; default: if ( $this->skintype == 'itemmove' ) { $query = "SELECT icat as result FROM %s WHERE inumber=%d;"; - $query = spriintf($query, sql_table('item'), intRequestVar('itemid')); - $catid = quickQuery(sprintf($query, intRequestVar('itemid'))); - $this->objAdmin->selectBlogCategory('catid', $catid, 10, 1); + $query = sprintf($query, sql_table('item'), intRequestVar('itemid')); + $catid = DB::getValue(sprintf($query, intRequestVar('itemid'))); + Admin::selectBlogCategory('catid', $catid, 10, 1); } break; } @@ -3762,7 +4087,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_moveitemid() + * AdminActions::parse_moveitemid() * Parse skinvar moveitemid * * @param void @@ -3775,7 +4100,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_newestcompare() + * AdminActions::parse_newestcompare() * Parse skinvar newestcompare * * @param void @@ -3784,9 +4109,11 @@ class AdminActions extends BaseActions public function parse_newestcompare() { global $nucleus; + $newestVersion = getLatestVersion(); $newestCompare = str_replace('/', '.', $newestVersion); $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']); + if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') ) { echo '
    '; @@ -3796,7 +4123,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_newmemberselect() + * AdminActions::parse_newmemberselect() * Parse skinvar newmemberselect * * @param string $templateName name of template to use @@ -3806,27 +4133,30 @@ class AdminActions extends BaseActions { $blogid = intRequestVar('blogid'); - $query = "SELECT tmember FROM %s WHERE tblog=%d;"; + $query = "SELECT tmember FROM %s WHERE tblog=%d;"; $query = sprintf($query, sql_table('team'), (integer) $blogid); - $res = sql_query($query); + $res = DB::getResult($query); $tmem = array(); - while ( $tmember = sql_fetch_object($res) ) + foreach ( $res as $row ) { - $tmem[] = intval($tmember->tmember); + $tmem[] = intval($row['tmember']); } $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);"; $query = sprintf($query, sql_table('member'), implode(', ', $tmem)); - $template['name'] = 'memberid'; - $template['tabindex'] = 10000; + $template = array( + 'name' => 'memberid', + 'tabindex' => 10000, + 'selected' => 0 + ); Showlist($query, 'select', $template, $templateName); return; } /** - * Actions::parse_newpluginlist() + * AdminActions::parse_newpluginlist() * Parse skinvar newpluginlist * * @param void @@ -3843,7 +4173,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_outputspecialdirs() + * AdminActions::parse_outputspecialdirs() * Parse skinvar outputspecialdirs * * @param string $type type of setting for directory @@ -3851,14 +4181,14 @@ class AdminActions extends BaseActions */ public function parse_outputspecialdirs($type) { + global $DIR_MEDIA, $DIR_NUCLEUS; + switch ( $type ) { case 'nucleusdir': - global $DIR_NUCLEUS; echo Entity::hsc($DIR_NUCLEUS); break; case 'mediadir': - global $DIR_MEDIA; echo Entity::hsc($DIR_MEDIA); break; } @@ -3866,7 +4196,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_passrequestvars() + * AdminActions::parse_passrequestvars() * Parse skinvar passrequestvars * * @param void @@ -3874,10 +4204,12 @@ class AdminActions extends BaseActions */ public function parse_passrequestvars() { + $passvar = Admin::getAdminpassvar(); $oldaction = postVar('oldaction'); + if ( ($oldaction != 'logout') && ($oldaction != 'login') - && $this->objAdmin->passvar + && $passvar && !postVar('customaction') ) { passRequestVars(); @@ -3886,7 +4218,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_pluginextras() + * AdminActions::parse_pluginextras() * Parse skinvar pluginextras * * @param string $type type of plugin context @@ -3900,22 +4232,12 @@ class AdminActions extends BaseActions case 'member': $id = intRequestVar('memberid'); $mem = MEMBER::createFromID($id); - $manager->notify( - 'MemberSettingsFormExtras', - array( - 'member' => &$mem - ) - ); + $manager->notify('MemberSettingsFormExtras', array('member' => &$mem)); break; case 'blog': $id = intRequestVar('blogid'); $blg = $manager->getBlog($id); - $manager->notify( - 'BlogSettingsFormExtras', - array( - 'member' => &$blg - ) - ); + $manager->notify('BlogSettingsFormExtras', array('member' => &$blg)); break; default: $manager->notify( @@ -3929,7 +4251,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_pluginhelp() + * AdminActions::parse_pluginhelp() * Parse skinvar pluginhelp * * @param void @@ -3938,8 +4260,9 @@ class AdminActions extends BaseActions public function parse_pluginhelp() { global $manager, $DIR_PLUGINS; + $plugid = intGetVar('plugid'); - $plugName = getPluginNameFromPid($plugid); + $plugName = $manager->getPluginNameFromPid($plugid); $plug =& $manager->getPlugin($plugName); if ( $plug->supportsFeature('HelpPage') > 0 ) @@ -3962,7 +4285,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_pluginlistlist() + * AdminActions::parse_pluginlistlist() * Parse skinvar pluginlistlist * * @param string $templateName name of template to use @@ -3970,41 +4293,100 @@ class AdminActions extends BaseActions */ public function parse_pluginlistlist($templateName = '') { - $query = "SELECT * FROM %s ORDER BY porder ASC;"; + $query = "SELECT * FROM %s ORDER BY porder ASC;"; $query = sprintf($query, sql_table('plugin')); + $template['content'] = 'pluginlist'; $template['tabindex'] = 10; + Showlist($query, 'table', $template, $templateName); + return; } /** - * Actions::parse_pluginoptions() + * AdminActions::parse_pluginoptions() * Parse skinvar pluginoptions * * @param string $type type of plugin option * @return void */ - public function parse_pluginoptions($type = 'global') + public function parse_pluginoptions($context='global') { - switch ( $type ) + global $itemid, $manager; + + switch ( $context ) { case 'member': - $id = intRequestVar('memberid'); + $contextid = intRequestVar('memberid'); break; case 'blog': - $id = intRequestVar('blogid'); + $contextid = intRequestVar('blogid'); break; case 'category': - $id = intRequestVar('catid'); + $contextid = intRequestVar('catid'); break; + case 'item': + $contextid = $itemid; + break; + } + + /* Actually registererd plugin options */ + $aIdToValue = array(); + $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;"; + $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid); + $res = DB::getResult($query); + foreach ( $res as $row ) + { + $aIdToValue[$row['oid']] = $row['ovalue']; } - $this->objAdmin->_insertPluginOptions($type, $id); + + /* Currently available plugin options */ + $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;"; + $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context)); + $res = DB::getResult($query); + + $options = array(); + foreach ($res as $row ) + { + if ( !array_key_exists($row['oid'], $aIdToValue) ) + { + $value = $row['odef']; + } + else + { + $value = $aIdToValue[$row['oid']]; + } + + $options[] = array( + 'pid' => $row['pid'], + 'pfile' => $row['pfile'], + 'oid' => $row['oid'], + 'value' => $value, + 'name' => $row['oname'], + 'description' => $row['odesc'], + 'type' => $row['otype'], + 'typeinfo' => $row['oextra'], + 'contextid' => $contextid, + 'extra' => '' + ); + } + + $data = array( + 'context' => $context, + 'contextid' => $contextid, + 'options' => &$opt4ions + ); + $manager->notify('PrePluginOptionsEdit', $data); + + $content = $this->parser->skin->getContentFromDB('insertpluginoptions'); + $this->parser->parse($content); + return; } /** - * Actions::parse_qmenuaddselect() + * AdminActions::parse_qmenuaddselect() * Parse skinvar qmanuaddselect * * @param string $templateName name of template to use @@ -4028,19 +4410,22 @@ class AdminActions extends BaseActions . ' WHERE tblog=bnumber and tmember=' . $member->getID() . ' ORDER BY bname'; } - $template['name'] = 'blogid'; - $template['tabindex'] = 15000; - $template['extra'] = _QMENU_ADD_SELECT; - $template['selected'] = -1; + + $template['name'] = 'blogid'; + $template['tabindex'] = 15000; + $template['extra'] = _QMENU_ADD_SELECT; + $template['selected'] = -1; $template['shorten'] = 10; - $template['shortenel'] = ''; - $template['javascript'] = 'onchange="return form.submit()"'; + $template['shortenel'] = ''; + $template['javascript'] = 'onchange="return form.submit()"'; + Showlist($query, 'select', $template, $templateName); + return; } /** - * Actions::parse_quickmenu() + * AdminActions::parse_quickmenu() * Parse skinvar quickmenu * * @param string $templateName name of template to use @@ -4064,38 +4449,44 @@ class AdminActions extends BaseActions ); if ( count($pluginExtras) > 0 ) { - if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) ) + if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) ) { - $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE']; + $template['title'] = "

    <%text(_QMENU_PLUGINS)%>

    \n"; } else { - $template['title'] = '

    <%text(_QMENU_PLUGINS)%>

    '; + $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE']; } - $handler = new Actions($this->skintype, $template, $this->objAdmin); - $parser = new PARSER(Actions::getDefinedActions(), $handler); - $parser->parse($template['title']); - - if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) ) + if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) ) { - $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD']; + $template['head'] = "
    '; + echo Template::fill($template['body'], $data); } echo $template['foot']; } @@ -4119,7 +4502,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_requestblogid() + * AdminActions::parse_requestblogid() * Parse skinvar requestblogid * * @param void @@ -4132,7 +4515,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_requestiprange() + * AdminActions::parse_requestiprange() * Parse skinvar requestiprange * * @param void @@ -4152,7 +4535,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_selectlocaladminskinfiles() + * AdminActions::parse_selectlocaladminskinfiles() * Parse skinvar selectlocaladminskinfiles * * @param void @@ -4160,18 +4543,22 @@ class AdminActions extends BaseActions */ public function parse_selectlocaladminskinfiles() { - global $DIR_ADMINSKINS, $manager; - $candidates = SkinImport::searchForCandidates($DIR_ADMINSKINS); + global $DIR_SKINS, $manager; + + $adminskindir = $DIR_SKINS . 'admin/'; + $candidates = SkinImport::searchForCandidates($adminskindir); + foreach ( $candidates as $skinname => $skinfile ) { - $html = Entit::hsc($skinfile); + $html = Entity::hsc($skinfile); echo '\n"; } + return; } /** - * Actions::parse_selectlocalskinfiles() + * AdminActions::parse_selectlocalskinfiles() * Parse skinvar selectlocalskinfiles * * @param void @@ -4180,17 +4567,20 @@ class AdminActions extends BaseActions public function parse_selectlocalskinfiles() { global $DIR_SKINS; + $candidates = SkinImport::searchForCandidates($DIR_SKINS); + foreach ( $candidates as $skinname => $skinfile ) { $html = Entity::hsc($skinfile); echo '\n"; } + return; } /** - * Actions::parse_skineditallowedlist() + * AdminActions::parse_skineditallowedlist() * Parse skinvar skineditallowedlist * * @param string $type type of skin @@ -4202,7 +4592,7 @@ class AdminActions extends BaseActions switch ( $type ) { case 'blog': - $query = "SELECT bshortname, bname FROM %s"; + $query = "SELECT bshortname, bname FROM %s;"; $show = array( 'content' => 'shortblognames' ); @@ -4210,7 +4600,7 @@ class AdminActions extends BaseActions Showlist($query, 'table', $show, $templateName); break; case 'template': - $query = "SELECT tdname as name, tddesc as description FROM %s"; + $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';"; $show = array( 'content' => 'shortnames' ); @@ -4222,29 +4612,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_skinfile() - * Inserts an url relative to the skindir (useful when doing import/export) - * - * e.g. - * - * @param string $filename file name for skin - * @return void - */ - public function parse_skinfile($filename) - { - /* - * TODO: we should decide to use different directory or default $DIR_SKINS - $base = NP_SkinableAdmin::getAdminSkinURL(); - $pref = PARSER::getProperty('IncludePrefix'); - echo $base . $pref . $filename; - */ - $pref = PARSER::getProperty('IncludePrefix'); - echo $pref . $filename; - return; - } - - /** - * Actions::parse_skinielist() + * AdminActions::parse_skinielist() * Parse skinvar skinielist * * @param string $type type of skin @@ -4264,35 +4632,40 @@ class AdminActions extends BaseActions } else { - $template = '' . "\n" - . "<%expdesc%>\n" - . "\n"; + $template = "" + . "\" id=\"<%expid%>\" />\n" + . "\n" + . "\n" + . "<%expdesc%>\n" + . "\n" + . "\n"; } switch ( $type ) { case 'skin': - $res = sql_query('SELECT * FROM ' . sql_table('skin_desc')); - while ( $skinObj = sql_fetch_object($res) ) + $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc')); + foreach ( $res as $row ) { $data = array( - 'typeid' => 'skin[' . $skinObj->sdnumber . ']', - 'expid' => 'skinexp' . $skinObj->sdnumber, - 'expname' => Entity::hsc($skinObj->sdname), - 'expdesc' => Entity::hsc($skinObj->sddesc), + 'typeid' => 'skin[' . $row['sdnumber'] . ']', + 'expid' => 'skinexp' . $row['sdnumber'], + 'expname' => Entity::hsc($row['sdname']), + 'expdesc' => Entity::hsc($row['sddesc']) ); - echo TEMPLATE::fill($template, $data); + echo Template::fill($template, $data); } break; case 'template': - $res = sql_query('SELECT * FROM '.sql_table('template_desc')); - while ($templateObj = sql_fetch_object($res)) { + $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';"); + foreach ( $res as $row ) + { $data = array( - 'typeid' => 'template[' . $templateObj->tdnumber . ']', - 'expid' => 'templateexp' . $templateObj->tdnumber, - 'expname' => Entity::hsc($templateObj->tdname), - 'expdesc' => Entity::hsc($templateObj->tddesc), + 'typeid' => 'template[' . $row['tdnumber'] . ']', + 'expid' => 'templateexp' . $row['tdnumber'], + 'expname' => Entity::hsc($row['tdname']), + 'expdesc' => Entity::hsc($row['tddesc']) ); - echo TEMPLATE::fill($template, $data); + echo Template::fill($template, $data); } break; } @@ -4300,7 +4673,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_skinoverview() + * AdminActions::parse_skinoverview() * Parse skinvar skinoverview * * @param string $templateName name of template to use @@ -4308,19 +4681,19 @@ class AdminActions extends BaseActions */ public function parse_skinoverview($templateName = '') { - $query = "SELECT * FROM %s ORDER BY sdname"; + global $CONF; + $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';"; $query = sprintf($query, sql_table('skin_desc')); $template['content'] = 'skinlist'; $template['tabindex'] = 10; - $template['friendly_names'] = Skin::getFriendlyNames('Actions'); Showlist($query, 'table', $template, $templateName); return; } /** - * Actions::parse_skintypehelp() + * AdminActions::parse_skintypehelp() * Check editing skintypehelp * * @param void @@ -4329,6 +4702,8 @@ class AdminActions extends BaseActions public function parse_skintypehelp() { $nowSkinType = strtolower(trim(requestVar('type'))); + + /* TODO: use Skin class */ $regularType = array( 'index', 'item', @@ -4352,7 +4727,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_specialskinlist() + * AdminActions::parse_specialskinlist() * Parse skinvar specialskinlist * * @param string $templateName name of template to use @@ -4365,6 +4740,8 @@ class AdminActions extends BaseActions { $templates = Template::read($templateName); } + + /* TODO: use Skin class */ $nType = array( 'index', 'item', @@ -4379,8 +4756,8 @@ class AdminActions extends BaseActions $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;"; $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid); - $res = sql_query($query); - if ( $res && sql_num_rows($res) > 0 ) + $res = DB::getResult($query); + if ( $res && $res->rowCount() > 0 ) { $data = array(); if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) ) @@ -4391,26 +4768,27 @@ class AdminActions extends BaseActions { $template['head'] = "
      \n"; } - echo TEMPLATE::fill($template['head'], $data); - if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) ) - { - $template['body'] = $templates['SPECIALSKINLIST_BODY']; - } - else + echo Template::fill($template['head'], $data); + if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) ) { $template['body'] = '
    • <%skintype%> (remove)
    • '; } + else + { + $template['body'] = $templates['SPECIALSKINLIST_BODY']; + } + $tabstart = 75; - while ( $row = sql_fetch_assoc($res) ) + foreach ( $res as $row ) { $data = array( - 'tabindex' => $tabstart++, - 'skinid' => $skinid, - 'skintype' => Entity::hsc(strtolower($row['stype'])) + 'tabindex' => $tabstart++, + 'skinid' => $skinid, + 'skintype' => Entity::hsc(strtolower($row['stype'])) ); - echo TEMPLATE::fill($template['body'], $data); + echo Template::fill($template['body'], $data); } $data = array(); if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) ) @@ -4421,13 +4799,13 @@ class AdminActions extends BaseActions { $template['foot'] = "
    \n"; } - echo TEMPLATE::fill($template['foot'], $data); + echo Template::fill($template['foot'], $data); return; } } /** - * Actions::parse_sprinttext() + * AdminActions::parse_sprinttext() * Parse sprinttext * * @param string $which @@ -4472,7 +4850,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_systemsettings() + * AdminActions::parse_systemsettings() * Parse skinvar systemsettings * * @param string $type type of settings for system @@ -4483,7 +4861,7 @@ class AdminActions extends BaseActions { global $member, $CONF, $nucleus; - $member->isAdmin() or $this->objAdmin->disallow(); + $member->isAdmin() or Admin::disallow(); $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE; $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE; @@ -4494,10 +4872,10 @@ class AdminActions extends BaseActions echo phpversion(); break; case 'sqlserverinfo': - echo sql_get_server_info(); + echo DB::getAttribute(PDO::ATTR_SERVER_VERSION); break; case 'sqlclientinfo': - echo sql_get_client_info(); + echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION); break; case 'magicquotesgpc': echo ini_get('magic_quotes_gpc') ? 'On' : 'Off'; @@ -4514,13 +4892,16 @@ class AdminActions extends BaseActions { $templates = Template::read($templateName); } - if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) ) + if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) ) { - $template = $templates['SYSTEMINFO_GDSETTINGS']; + $template = "\n" + . "<%key%>\n" + . "<%value%>\n" + . "\n"; } else { - $template = "\n\t\t" . '' . "<%key%><%value%>\n\n"; + $template = $templates['SYSTEMINFO_GDSETTINGS']; } $gdinfo = gd_info(); @@ -4539,7 +4920,7 @@ class AdminActions extends BaseActions 'key' => $key, 'value' => $value, ); - echo TEMPLATE::fill($template, $data); + echo Template::fill($template, $data); } break; case 'modrewrite': @@ -4547,7 +4928,7 @@ class AdminActions extends BaseActions phpinfo(INFO_MODULES); $im = ob_get_contents(); ob_end_clean(); - echo (strstr($im, 'mod_rewrite') != '') ? $enable : $disable; + echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable; break; case 'nucleusversion': echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')'; @@ -4578,7 +4959,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_templateoverview() + * AdminActions::parse_templateoverview() * Parse skinvar templateoverview * * @param string $templateName name of template to use @@ -4586,11 +4967,14 @@ class AdminActions extends BaseActions */ public function parse_templateoverview($templateName = '') { - $query = "SELECT * FROM %s ORDER BY tdname"; + $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname"; $query = sprintf($query, sql_table('template_desc')); + $template['content'] = 'templatelist'; $template['tabindex'] = 10; + Showlist($query, 'table', $template, $templateName); + return; } @@ -4609,7 +4993,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_versioncheckurl() + * AdminActions::parse_versioncheckurl() * Parse skinvar versioncheckurl * * @param void @@ -4622,7 +5006,7 @@ class AdminActions extends BaseActions } /** - * Actions::parse_yrbloglist() + * AdminActions::parse_yrbloglist() * Parse skinvar yrbloglist * * @param string $templateName name of template to use @@ -4638,7 +5022,7 @@ class AdminActions extends BaseActions // Super-Admins have access to all blogs! (no add item support though) $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname" . " FROM %s" - . " ORDER BY bnumber"; + . " ORDER BY bnumber;"; $query = sprintf($query, sql_table('blog')); } else @@ -4646,7 +5030,7 @@ class AdminActions extends BaseActions $query = "SELECT bnumber, bname, tadmin, burl, bshortname" . " FROM %s,%s" . " WHERE tblog=bnumber and tmember=%d" - . " ORDER BY bnumber"; + . " ORDER BY bnumber;"; $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID()); } @@ -4659,7 +5043,7 @@ class AdminActions extends BaseActions { $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog'); - $total = quickQuery($query); + $total = DB::getValue($query); if ( $total > $amount ) { echo '

    ' . _OVERVIEW_SHOWALL . '

    '; @@ -4676,8 +5060,8 @@ class AdminActions extends BaseActions $query = "SELECT ititle, inumber, bshortname" . " FROM %s,%s" - . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1'; - $query = sprintf($query. sql_table('item'), sql_table('blog'), (integer) $member->getID()); + . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;'; + $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID()); $template['content'] = 'draftlist'; @@ -4691,62 +5075,534 @@ class AdminActions extends BaseActions } /** - * Actions::customHelp() - * shows a link to custom help file - * - * @param integer $id - * @param string $tplName - * @param string $url - * @param string $iconURL - * @param string $alt - * @param string $title - * @param $onclick - * + * AdminActions::checkCondition() + * Checks conditions for if statements + * + * @param string $field type of <%if%> + * @param string $name property of field + * @param string $value value of property + * @return boolean condition */ - private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '') + protected function checkCondition($field, $name='', $value = '') { - echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick); + global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists; + + $condition = 0; + switch ( $field ) + { + case 'category': + if ( !$blog ) + { + if ( $blogid ) + { + global $manager; + $blog =& $manager->getBlog($blogid); + } + elseif ( $catid ) + { + $blogid = getBlogIDFromCatID($catid); + global $manager; + $blog =& $manager->getBlog($blogid); + } + elseif ( intRequestVar('catid') ) + { + $catid = intRequestVar('catid'); + $blogid = getBlogIDFromCatID($catid); + global $manager; + $blog =& $manager->getBlog($blogid); + } + else + { + return; + } + } + $condition = ($blog && $this->ifCategory($name, $value)); + break; + case 'blogsetting': + $condition = ($blog && ($blog->getSetting($name) == $value)); + break; + case 'loggedin': + $condition = $member->isLoggedIn(); + break; + case 'onteam': + $condition = $member->isLoggedIn() && $this->ifOnTeam($name); + break; + case 'admin': + $condition = $member->isLoggedIn() && $this->ifAdmin($name); + break; + case 'superadmin': + $condition = $member->isLoggedIn() && $member->isAdmin(); + break; + case 'allowloginedit': + $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin()); + break; + case 'nextitem': + $condition = ($itemidnext != ''); + break; + case 'previtem': + $condition = ($itemidprev != ''); + break; + case 'archiveprevexists': + $condition = ($archiveprevexists == true); + break; + case 'archivenextexists': + $condition = ($archivenextexists == true); + break; + case 'skintype': + $condition = (($name == $this->skintype) || ($name == requestVar('action'))); + break; + case 'hasplugin': + $condition = $this->ifHasPlugin($name, $value); + break; + case 'adminaction': + $condition = (Admin::getAdminAction() == $name); + break; + case 'adminoldaction': + $condition = (Admin::getAdminAction() == $name); + break; + case 'addresschange': + $condition = ($this->ifAddresscange()); + break; + case 'bechangepass': + $condition = ($this->beChangePassword()); + break; + case 'skincandidates': + $condition = ($this->ifSkincandidates()); + break; + case 'nameclashes': + $condition = requestVar('nameclashes'); + break; + case 'existsnewplugin': + $condition = ($this->existsNewPlugin()); + break; + case 'autosave': + $condition = (boolean) ($member->getAutosave() == $value); + break; + default: + $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value); + break; + } + return $condition; } /** - * Actions::customHelpHtml() - * - * @param integer $id - * @param string $tplName - * @param string $url - * @param string $iconURL - * @param string $alt - * @param string $title - * @param string $onclick - * @return string anchor element with help uri + * Actions::_ifHasPlugin() + * hasplugin,PlugName + * -> checks if plugin exists + * hasplugin,PlugName,OptionName + * -> checks if the option OptionName from plugin PlugName is not set to 'no' + * hasplugin,PlugName,OptionName=value + * -> checks if the option OptionName from plugin PlugName is set to value + * + * @param string $name name of plugin + * @param string $value + * @return */ - private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '') + private function ifHasPlugin($name, $value) { - $templates = array(); - if ( $tplName ) - { - $templates = Template::read($tplName); - } - if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) ) - { - $template = $templates['ADMIN_CUSTOMHELPLINK_ICON']; - } - else - { - $template = '<%height%>alt="<%alt%>" title="<%title%>" />'; - } - - if ( empty($iconURL) ) + global $manager; + $condition = false; + // (pluginInstalled method won't write a message in the actionlog on failure) + if ( $manager->pluginInstalled("NP_{$name}") ) { - global $CONF; - $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif'; + $plugin =& $manager->getPlugin("NP_{$name}"); + if ( $plugin != NULL ) + { + if ( $value == "" ) + { + $condition = true; + } + else + { + list($name2, $value2) = preg_split('#=#', $value, 2); + if ( $value2 == "" && $plugin->getOption($name2) != 'no' ) + { + $condition = true; + } + else if ( $plugin->getOption($name2) == $value2 ) + { + $condition = true; + } + } + } } - if ( function_exists('getimagesize') ) - { - $size = getimagesize($iconURL); + return $condition; + } + + /** + * Actions::beChangePassword() + * + * @param void + * @return void + */ + private function beChangePassword() + { + return intRequestVar('bNeedsPasswordChange'); + } + + /** + * Actions::ifSkincandidates() + * Checks if a plugin exists and call its doIf function + * + * @param void + * @return void + * @return boolean + */ + private function ifSkincandidates() + { + global $DIR_SKINS; + $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS); + return (count($candidates) > 0); + } + + /** + * Actions::ifPlugin() + * Checks if a plugin exists and call its doIf function + * + * @param string $name name of plugin + * @param string $key + * @param string $value + * @return callback + */ + private function ifPlugin($name, $key = '', $value = '') + { + global $manager; + + $plugin =& $manager->getPlugin("NP_{$name}"); + if ( !$plugin ) + { + return; + } + + $params = func_get_args(); + array_shift($params); + + return call_user_func_array(array(&$plugin, 'doIf'), $params); + } + + /** + * AdminActions::ifCategory() + * Different checks for a category + * + * @param string $key key for information of category + * @param string $value value for information of category + * @return boolean + */ + private function ifCategory($key = '', $value='') + { + global $blog, $catid; + + // when no parameter is defined, just check if a category is selected + if (($key != 'catname' && $key != 'catid') || ($value == '')) + { + return $blog->isValidCategory($catid); + } + + // check category name + if ( $key == 'catname' ) + { + $value = $blog->getCategoryIdFromName($value); + if ($value == $catid) + { + return $blog->isValidCategory($catid); + } + } + + // check category id + if (($key == 'catid') && ($value == $catid)) + { + return $blog->isValidCategory($catid); + } + + return FALSE; + } + + /** + * AdminActions::ifOnTeam() + * Checks if a member is on the team of a blog and return his rights + * + * @param string $blogName name of weblog + * @return boolean + */ + private function ifOnTeam($blogName = '') + { + global $blog, $member, $manager; + + // when no blog found + if ( ($blogName == '') && !is_object($blog) ) + { + return 0; + } + + // explicit blog selection + if ($blogName != '') + { + $blogid = getBlogIDFromName($blogName); + } + + if (($blogName == '') || !$manager->existsBlogID($blogid)) + { + // use current blog + $blogid = $blog->getID(); + } + return $member->teamRights($blogid); + } + + /** + * AdminActions::ifAdmin() + * Checks if a member is admin of a blog + * + * @param string $blogName name of weblog + * @return boolean + */ + private function ifAdmin($blogName = '') + { + global $blog, $member, $manager; + + // when no blog found + if (($blogName == '') && (!is_object($blog))) + { + return 0; + } + + // explicit blog selection + if ($blogName != '') + { + $blogid = getBlogIDFromName($blogName); + } + + if (($blogName == '') || !$manager->existsBlogID($blogid)) + { + // use current blog + $blogid = $blog->getID(); + } + + return $member->isBlogAdmin($blogid); + } + + /** + * AdminActions::ifAddresscange() + * Check e-Mail address is changed + * + * @param void + * @return boolean + */ + private function ifAddresscange() + { + $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey"); + if ( !$key ) + { + return FALSE; + } + $info = MEMBER::getActivationInfo($key); + if ( !$info ) + { + return FALSE; + } + $mem = MEMBER::createFromId($info->vmember); + if ( !$mem ) + { + return FALSE; + } + if ( $info->vtype == 'addresschange' ) + { + return TRUE; + } + return FALSE; + } + + /** + * AdminActions::templateEditRow() + * Template edit box + * + * @param array $template + * @param string $desc + * @param string $name + * @param string $help + * @param integer $tabindex + * @param boolean $big + * @param array $tmplt + * @return void + */ + private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '') + { + static $count = 1; + + if ( !array_key_exists($name, $template) ) + { + $template[$name] = ''; + } + + $tmplt = array(); + $base = array(); + + if ( $tplt ) + { + $tmplt = skinableTEMPLATE::read($tplt); + } + + $data = array( + 'description' => $desc, + 'help' => empty($help) ? '' : helpHtml('template' . $help), + 'count' => $count, + 'name' => $name, + 'tabindex' => $tabindex, + 'rows' => $big ? 10 : 5, + ); + + if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) ) + { + $base['head'] = "" + . "\n" + . "<%description%><%help%>\n" + . "\">\n" + . "\n" + . "\n"; + } + else + { + $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL']; + } + + echo TEMPLATE::fill($base['head'], $data); + echo ENTITY::hsc($template[$name]); + echo TEMPLATE::fill($base['tail'], $data); + + $count++; + + return; + } + + /** + * AdminActions::customHelp() + * shows a link to custom help file + * + * @param string $id + * @param string $tplName + * @param string $url + * @param string $iconURL + * @param string $alt + * @param string $title + * @param $onclick + * + */ + private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '') + { + echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick); + } + + /** + * AdminActions::customHelp() + * shows a link to custom help file + * + * @param string $id + * @param string $tplName + * @param string $url + * @param string $iconURL + * @param string $alt + * @param string $title + * @param $onclick + * + */ + static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '') + { + global $CONF; + + $templates = array(); + + if ( $tplName ) + { + $templates = Template::read($tplName); + } + + if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) ) + { + $template = "#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n"; + } + else + { + $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR']; + } + + if ( empty($url) ) + { + $url = $CONF['AdminURL'] . 'documentation/customHelp.html'; + } + + if ( empty($onclick) ) + { + $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"'; + } + elseif ( preg_match('#^onclick#', $onclick) ) + { + $onclick = $onclick; + } + else + { + $onclick = 'onclick="' . $onclick . '"'; + } + + $data = array( + 'helpurl' => $url, + 'helptarget' => $id, + 'onclick' => $onclick, + 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT, + ); + return Template::fill($template, $data); + } + + /** + * AdminActions::customHelpHtml() + * + * @param string $id + * @param string $tplName + * @param string $url + * @param string $iconURL + * @param string $alt + * @param string $title + * @param string $onclick + * @return string anchor element with help uri + */ + private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '') + { + global $CONF; + + $templates = array(); + + if ( $tplName ) + { + $templates = Template::read($tplName); + } + if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) ) + { + $template = "\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" />\n"; + } + else + { + $template = $templates['ADMIN_CUSTOMHELPLINK_ICON']; + } + + if ( empty($iconURL) ) + { + $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif'; + } + + if ( function_exists('getimagesize') ) + { + $size = getimagesize($iconURL); $width = 'width="' . $size[0] . '" '; $height = 'height="' . $size[1] . '" '; } + $data = array( 'iconurl' => $iconURL, 'width' => $width, @@ -4754,13 +5610,15 @@ class AdminActions extends BaseActions 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT, 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT, ); - $icon = TEMPLATE::fill($template, $data); + + $icon = Template::fill($template, $data); $help = self::customHelplink($id, $tplName, $url, $title, $onclick); + return $help . $icon; } /** - * Actions::input_yesno + * AdminActions::input_yesno * * @param $name * @param $checkedval @@ -4773,7 +5631,7 @@ class AdminActions extends BaseActions * @param $templateName * @param $showlist */ - private function input_yesno($name, + public function input_yesno($name, $checkedval, $tabindex = 0, $value1 = 1, @@ -4792,17 +5650,17 @@ class AdminActions extends BaseActions if ( $name == 'admin' ) { - if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) ) - { - $template = $templates['INPUTYESNO_TEMPLATE_ADMIN']; - } - else + if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) ) { $template = ' id="<%yesid%>" />' . "\n" . '' . "\n" . ' id="<%noid%>"<%disabled%> />' . "\n" . '' . "\n"; } + else + { + $template = $templates['INPUTYESNO_TEMPLATE_ADMIN']; + } } else { @@ -4851,26 +5709,317 @@ class AdminActions extends BaseActions } else { - echo TEMPLATE::fill($template, $dat); + echo Template::fill($template, $dat); } return; } /** - * AdminActions::parse_text() - * Parse text + * AdminActions::existsNewPlugin() + * Check exists new plugin * - * FIXME: is this really needed? + * @param void + * @return boolean exists or not + */ + private function existsNewPlugin() + { + global $DIR_PLUGINS; + + $query = "SELECT * FROM %s;"; + $query = sprintf($query, sql_table('plugin')); + $res = DB::getResult($query); + + $installed = array(); + foreach( $res as $row ) + { + $installed[] = $row['pfile']; + } + + $files = scandir($DIR_PLUGINS); + + $candidates = array(); + foreach ( $files as $file ) + { + if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) ) + { + if ( !in_array($matches[1], $installed) ) + { + $candidates[] = $matches[1]; + } + } + } + $this->newPlugCandidates = $candidates; + return (count($candidates) > 0); + } + + /** + * AdminActions::pagehead() + * Output admin page head * - * @param string $which constant vallue + * @param void * @return void */ - public function parse_text($which) + public function parse_pagehead() { - if ( defined($which) ) + global $member, $nucleus, $CONF, $manager; + + $content = $this->parser->skin->getContentFromDB('pagehead'); + if ( !$content ) { - echo constant($which); + $extrahead = Admin::$extrahead; + $data = array( + 'extrahead' => &$extrahead, + 'action' => Admin::$action + ); + $manager->notify('AdminPrePageHead', $data); + + $baseUrl = Entity::hsc($CONF['SkinsURL']); + + /* + * TODO: obsoleted + if ( !array_key_exists('AdminCSS', $CONF) ) + { + DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')"); + $CONF['AdminCSS'] = 'original'; + } + */ + + /* HTTP 1.1 application for no caching */ + header("Cache-Control: no-cache, must-revalidate"); + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); + + $root_element = 'html'; + $charset = i18n::get_current_charset(); + $locale = preg_replace('#_#', '-', i18n::get_current_locale()); + $xml_version_info = self::$xml_version_info; + $formal_public_identifier = self::$formal_public_identifier; + $system_identifier = self::$system_identifier; + $xhtml_namespace = self::$xhtml_namespace; + + echo "\n"; + echo "\n"; + echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n"; + echo "\n"; + echo '' . Entity::hsc($CONF['SiteName']) . " - Admin\n"; + /* + * TODO: obsoleted + echo "\n"; + */ + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "{$extrahead}\n"; + echo "\n\n"; + echo "\n"; + echo "
    \n"; + echo "
    \n"; + echo '

    ' . Entity::hsc($CONF['SiteName']) . "

    \n"; + echo "
    \n"; + echo "
    \n"; + echo "
    \n"; + echo "
    \n"; + + if ( !$member->isLoggedIn() ) + { + echo '' . _NOTLOGGEDIN . "
    \n"; + } + else + { + echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - " . _LOGOUT. "
    \n"; + echo "" . _ADMINHOME . " - "; + } + + echo ""._YOURSITE."
    \n"; + echo '('; + + if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) ) + { + $codenamestring = ''; + } + else + { + $codenamestring = ' "' . $nucleus['codename'].'"'; + } + + if ( $member->isLoggedIn() && $member->isAdmin() ) + { + $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel()); + echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring . ''; + + $newestVersion = getLatestVersion(); + $newestCompare = str_replace('/', '.', $newestVersion); + $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']); + + if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 ) + { + echo "
    \n"; + echo ''; + echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion; + echo ""; + } + } + else + { + echo "Nucleus CMS {$nucleus['version']}{$codenamestring}"; + } + echo ')'; + echo '
    '; + } + else + { + $this->parser->parse($content); + } + + return; + } + + /** + * AdminActionss::pagefoot() + * Output admin page foot include quickmenu + * + * @param void + * @return void + */ + public function parse_pagefoot() + { + global $action, $member, $manager; + + $content = $this->parser->skin->getContentFromDB('pagefoot'); + if ( !$content ) + { + $data = array( + 'action' => self::$action + ); + $manager->notify('AdminPrePageFoot', $data); + + if ( $member->isLoggedIn() && ($action != 'showlogin') ) + { + echo '

    ' . _LOGOUT . "

    \n"; + echo "\n"; + } + + echo "
    \n"; + echo 'Nucleus CMS © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT; + echo '-'; + echo '' . _ADMINPAGEFOOT_DONATE . "\n"; + echo "
    \n"; + + echo "
    \n"; + + if ( ($action != 'showlogin') && ($member->isLoggedIn()) ) + { + echo "\n"; + + echo '

    ' . _QMENU_ADD . "

    \n"; + echo "
    \n"; + echo "

    \n"; + echo "\n"; + + $showAll = requestVar('showall'); + + if ( ($member->isAdmin()) && ($showAll == 'yes') ) + { + // Super-Admins have access to all blogs! (no add item support though) + $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;"; + $query = sprintf($query, sql_table('blog')); + } + else + { + $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;"; + $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID()); + } + $template['name'] = 'blogid'; + $template['tabindex'] = 15000; + $template['extra'] = _QMENU_ADD_SELECT; + $template['selected'] = -1; + $template['shorten'] = 10; + $template['shortenel'] = ''; + $template['javascript'] = 'onchange="return form.submit()"'; + showlist($query, 'select', $template); + + echo "

    \n"; + echo "
    \n"; + + echo "

    {$member->getDisplayName()}

    \n"; + echo "\n"; + + if ( $member->isAdmin() ) + { + echo '

    ' . _QMENU_MANAGE . "

    \n"; + echo "\n"; + + echo "

    " . _QMENU_LAYOUT . "

    \n"; + echo "\n"; + } + + $data = array('options' => array()); + + $manager->notify('QuickMenu', $data); + + if ( count($data['options']) > 0 ) + { + echo "

    " . _QMENU_PLUGINS . "

    \n"; + echo "\n"; + } + } + else if ( ($action == 'activate') || ($action == 'activatesetpwd') ) + { + + echo '

    ' . _QMENU_ACTIVATE . '

    ' . _QMENU_ACTIVATE_TEXT; + } + else + { + echo '

    ' . _QMENU_INTRO . '

    ' . _QMENU_INTRO_TEXT; + } + + echo "\n"; + echo "
    \n"; + + echo "\n"; + echo "
    \n"; + + echo "\n"; + echo "
    \n"; + + echo "\n"; + echo "
    \n"; + + echo "\n"; + echo "\n"; } + else + { + $this->parser->skin->parse('pagefoot'); + exit; + } + return; } }