From 1b0b4504db097502699e4a8b051eecc6cb6806d8 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 3 Mar 2013 03:49:17 -0800 Subject: [PATCH] e-latest and e-status GUI fixes. --- .../shortcodes/batch/admin_shortcodes.php | 218 +++++++++++++----- e107_plugins/chatbox_menu/e_status.php | 9 +- e107_themes/bootstrap/admin_style.css | 12 + e107_themes/bootstrap/admin_template.php | 6 +- 4 files changed, 174 insertions(+), 71 deletions(-) diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index b5dacd565..73dd1ca9d 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -312,55 +312,30 @@ class admin_shortcodes if (ADMIN) { - if (!function_exists('admin_latest')) + if (!function_exists('admin_latest')) //XXX Is this still necessary? { function admin_latest($parm='') { - $sql = e107::getDb(); - $ns = e107::getRender(); - $pref = e107::getPref(); - $mes = e107::getMessage(); + $sql = e107::getDb(); + $ns = e107::getRender(); + $pref = e107::getPref(); + $mes = e107::getMessage(); - $active_uploads = $sql -> db_Count('upload', '(*)', 'WHERE upload_active = 0'); - $submitted_news = $sql -> db_Count('submitnews', '(*)', 'WHERE submitnews_auth = 0'); - $comments_pending = $sql -> db_Count("comments", "(*)", "WHERE comment_blocked = 2 "); + $active_uploads = $sql->count('upload', '(*)', 'WHERE upload_active = 0'); + $submitted_news = $sql->count('submitnews', '(*)', 'WHERE submitnews_auth = 0'); + $comments_pending = $sql->count("comments", "(*)", "WHERE comment_blocked = 2 "); - $text = "
".E_16_NEWS.($submitted_news ? " ".ADLAN_LAT_2.": $submitted_news" : ' '.ADLAN_LAT_2.': 0').'
'; - $text .= "
".E_16_COMMENT. " ".ADLAN_LAT_9.": $comments_pending
"; + // $text = "
".E_16_NEWS.($submitted_news ? " ".ADLAN_LAT_2.": $submitted_news" : ' '.ADLAN_LAT_2.': 0').'
'; + // $text .= "
".E_16_COMMENT. " ".ADLAN_LAT_9.": $comments_pending
"; - $text .= "
".E_16_UPLOADS." ".ADLAN_LAT_7.": $active_uploads
"; - - - // for BC only. - if(vartrue($pref['e_latest_list'])) - { - foreach($pref['e_latest_list'] as $val) - { - if (is_readable(e_PLUGIN.$val.'/e_latest.php')) - { - include_once(e_PLUGIN.$val.'/e_latest.php'); - if(!class_exists($val."_latest")) - { - $mes->addDebug("".$val ." using deprecated e_latest method"); - } - } - } - } - - - - $configs = e107::getAddonConfig('e_latest'); - foreach($configs as $k=>$v) - { - foreach($v as $val) - { - $link = "".$val['title'].": ".$val['total'].""; - $text .= "
".$val['icon']." ".$link."
\n"; - } - } - + // $text .= "
".E_16_UPLOADS." ".ADLAN_LAT_7.": $active_uploads
"; + $oldconfigs = array(); + $oldconfigs['e-news'][0] = array('icon'=>E_16_NEWS, 'title'=>ADLAN_LAT_2, 'url'=> e_ADMIN."newspost.php?mode=sub&action=list", 'total'=>$submitted_news); + $oldconfigs['e-comment'][0] = array('icon'=>E_16_COMMENT, 'title'=>ADLAN_LAT_9, 'url'=> e_ADMIN_ABS."comment.php?searchquery=&filter_options=comment_blocked__2", 'total'=>$comments_pending); + $oldconfigs['e-upload'][0] = array('icon'=>E_16_UPLOADS, 'title'=>ADLAN_LAT_7, 'url'=> e_ADMIN."upload.php", 'total'=>$active_uploads); + $messageTypes = array('Broken Download', 'Dev Team Message'); $queryString = ''; foreach($messageTypes as $types) @@ -369,11 +344,51 @@ class admin_shortcodes } $queryString = substr($queryString, 0, -3); - if($amount = $sql -> db_Select('generic', '*', $queryString)) + if($amount = $sql->select('generic', '*', $queryString)) { - $text .= "
".ADLAN_LAT_8." [".$amount."]"; + // $text .= "
".ADLAN_LAT_8." [".$amount."]"; + + $oldconfigs['e-generic'][0] = array('icon'=>E_16_NOTIFY, 'title'=>ADLAN_LAT_8, 'url'=> e_ADMIN_ABS."message.php", 'total'=>$amount); } - $text .= "
"; + + + if(vartrue($pref['e_latest_list'])) + { + foreach($pref['e_latest_list'] as $val) + { + $text = ""; + if (is_readable(e_PLUGIN.$val.'/e_latest.php')) + { + include_once(e_PLUGIN.$val.'/e_latest.php'); + if(!class_exists($val."_latest")) + { + $mes->addDebug("".$val ." using deprecated e_latest method"); + $oldconfigs[$val] = admin_shortcodes::legacyToConfig($text); + } + } + } + } + + $configs = e107::getAddonConfig('e_latest'); + $allconfigs = array_merge($oldconfigs,$configs); + + $allconfigs = multiarray_sort($allconfigs,'title'); //XXX FIXME - not sorting correctly. + + $text = ""; + + + + // $text .= "
"; return ($parm != 'norender') ? $ns -> tablerender(ADLAN_LAT_1, $text, '', TRUE) : $text; @@ -946,7 +961,7 @@ class admin_shortcodes if (getperms('0') || getperms('4')) { - if (!function_exists('admin_status')) + if (!function_exists('admin_status')) //XXX Discuss.. do we still need to embed this function within the shortcode? { function admin_status($parm='') { @@ -956,11 +971,12 @@ class admin_shortcodes $pref = e107::getPref(); - $members = $sql -> db_Count('user'); - $unverified = $sql -> db_Count('user', '(*)', 'WHERE user_ban=2'); - $banned = $sql -> db_Count('user', '(*)', 'WHERE user_ban=1'); - $comments = $sql -> db_Count('comments'); + $members = $sql->count('user'); + $unverified = $sql->count('user', '(*)', 'WHERE user_ban=2'); + $banned = $sql->count('user', '(*)', 'WHERE user_ban=1'); + $comments = $sql->count('comments'); + /* $unver = ($unverified ? " ".ADLAN_111.": {$unverified}" : ADLAN_111); $lban = ($banned) ? "".ADLAN_112. ": ".$banned."" : ADLAN_112.":"; $lcomment = ($comments) ? "".ADLAN_114.": ".$comments."" : ADLAN_114; @@ -972,47 +988,72 @@ class admin_shortcodes
".E_16_BANLIST." ".$lban."
".E_16_COMMENT." ".$lcomment."
\n\n"; - + */ // for BC only. + + + $oldconfigs['e-user'][0] = array('icon'=>E_16_USER, 'title'=>ADLAN_110, 'url'=> e_ADMIN_ABS."users.php?filter=0", 'total'=>$members); + $oldconfigs['e-user'][1] = array('icon'=>E_16_USER, 'title'=>ADLAN_111, 'url'=> e_ADMIN."users.php?searchquery=&filter_options=user_ban__2&filter=unverified", 'total'=>$unverified); + $oldconfigs['e-user'][2] = array('icon'=>E_16_BANLIST, 'title'=>ADLAN_112, 'url'=> e_ADMIN."users.phpsearchquery=&filter_options=user_ban__1&filter=banned", 'total'=>$banned); + $oldconfigs['e-comments'][0] = array('icon'=>E_16_COMMENT, 'title'=>ADLAN_114, 'url'=> e_ADMIN_ABS."comment.php", 'total'=>$comments); + + if($flo = $sql->count('generic', '(*)', "WHERE gen_type='failed_login'")) + { + //$text .= "\n\t\t\t\t\t
".E_16_FAILEDLOGIN." ".ADLAN_146.": $flo
"; + $oldconfigs['e-failed'][0] = array('icon'=>E_16_FAILEDLOGIN, 'title'=>ADLAN_146, 'url'=>e_ADMIN_ABS."fla.php", 'total'=>$flo); + } + + + if(vartrue($pref['e_status_list'])) { foreach($pref['e_status_list'] as $val) { - $text .= "\n\t\t\t\t\t"; + $text = ""; if (is_readable(e_PLUGIN.$val.'/e_status.php')) { + include_once(e_PLUGIN.$val.'/e_status.php'); if(!class_exists($val."_status")) { - $mes->addDebug("".$val ." using deprecated e_status method"); + $mes->addDebug("".$val ." using deprecated e_status method. See the chatbox plugin folder for a working example of the new one. "); } + + $oldconfigs[$val] = admin_shortcodes::legacyToConfig($text); } } } - + // New in v2.x $configs = e107::getAddonConfig('e_status'); - foreach($configs as $k=>$v) + + if(!is_array($configs)) + { + $configs = array(); + } + + $allconfigs = array_merge($oldconfigs,$configs); + + $allconfigs = multiarray_sort($allconfigs,'title'); //XXX FIXME - not sorting correctly. + + $text = ""; - - if($flo = $sql->db_Count('generic', '(*)', "WHERE gen_type='failed_login'")) - { - $text .= "\n\t\t\t\t\t
".E_16_FAILEDLOGIN." ".ADLAN_146.": $flo
"; - } - if($parm == 'list') { // $text = str_replace("
","
  • ",$text);; } - $text .= "\n\t\t\t\t\t
  • "; + // $text .= "\n\t\t\t\t\t"; return ($parm != 'norender') ? $ns -> tablerender(LAN_STATUS, $text, '', TRUE) : $text; @@ -1036,6 +1077,57 @@ class admin_shortcodes } } + function getBadge($total, $type = 'latest') + { + + /* + * 1 +Success 2 2 +Warning 4 4 +Important 6 6 +Info 8 8 +Inverse 10 10 + */ + + $class = 'badge '; + if($total > 100 && $type == 'latest') + { + $class .= 'badge-important'; + } + elseif($total > 50 && $type == 'latest') + { + $class .= 'badge-warning'; + } + elseif($total > 0) + { + $class .= 'badge-info'; + } + + + return $class; + } + + + /** + * Attempt to Convert Old $text string into new array format (e_status and e_latest) + */ + function legacyToConfig($text) + { + $var = array(); + preg_match_all('/(]*>)[\s]*]href=(\'|")([^\'"]*)(\'|")>([^<]*)<\/a>[: ]*([\d]*)/is',$text, $match); + foreach($match[5] as $k=>$m) + { + $var[$k]['icon'] = $match[1][$k]; + $var[$k]['title'] = $match[5][$k]; + $var[$k]['url'] = $match[3][$k]; + $var[$k]['total'] = $match[6][$k]; + } + return $var; + + } + + + function sc_admin_update() { if (!ADMIN) { return ''; } diff --git a/e107_plugins/chatbox_menu/e_status.php b/e107_plugins/chatbox_menu/e_status.php index 112e8d967..b1b8c6e18 100644 --- a/e107_plugins/chatbox_menu/e_status.php +++ b/e107_plugins/chatbox_menu/e_status.php @@ -2,17 +2,12 @@ /* * e107 website system * - * Copyright (C) 2008-2010 e107 Inc (e107.org) + * Copyright (C) 2008-2013 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * Chatbox plugin - Status * - * $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/e_status.php,v $ - * $Revision$ - * $Date$ - * $Author$ - * */ /** @@ -30,7 +25,7 @@ class chatbox_menu_status // include plugin-folder in the name. function config() { $sql = e107::getDb(); - $chatbox_posts = $sql -> db_Count('chatbox'); + $chatbox_posts = $sql->count('chatbox'); $var[0]['icon'] = " "; $var[0]['title'] = ADLAN_115; diff --git a/e107_themes/bootstrap/admin_style.css b/e107_themes/bootstrap/admin_style.css index 9bd533968..08b208680 100644 --- a/e107_themes/bootstrap/admin_style.css +++ b/e107_themes/bootstrap/admin_style.css @@ -736,9 +736,21 @@ i.searchquery { .table .options { white-space:nowrap } + + /****************************************************************/ +ul#e-status { list-style: none;; margin:0px} +ul#e-status li { padding-bottom:6px; } +ul#e-status { line-height:20px } +ul#e-status li a span.badge { float:right; } +ul#e-status li a:hover { text-decoration: none; } +ul#e-latest { list-style: none; margin:0px} +ul#e-latest li { padding-bottom:6px; } +ul#e-latest { line-height:20px } +ul#e-latest li a span.badge { float:right; } +ul#e-latest li a:hover { text-decoration: none; } /* diff --git a/e107_themes/bootstrap/admin_template.php b/e107_themes/bootstrap/admin_template.php index 4c01e783a..83cfb4b65 100644 --- a/e107_themes/bootstrap/admin_template.php +++ b/e107_themes/bootstrap/admin_template.php @@ -220,8 +220,12 @@ $ADMIN_HEADER .= '
    {ADMIN_HELP} {ADMIN_SITEINFO=creditsonly} {SETSTYLE=default} - {ADMIN_STATUS=infopanel} +
    {ADMIN_LATEST=infopanel} +
    +
    + {ADMIN_STATUS=infopanel} +
    {ADMIN_LOG=request} {ADMIN_MSG=request} {ADMIN_PLUGINS}