From 94c2a44af7bd521844bc7255757918fe3bde9261 Mon Sep 17 00:00:00 2001 From: oldperl Date: Tue, 15 Nov 2011 23:36:35 +0000 Subject: [PATCH] enhancing dashboard widget part I --- trunk/semmelstatzR.css | 12 +++++++++ trunk/semmelstatzR.php | 55 +++++++++++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/trunk/semmelstatzR.css b/trunk/semmelstatzR.css index 631875c..9573951 100644 --- a/trunk/semmelstatzR.css +++ b/trunk/semmelstatzR.css @@ -129,4 +129,16 @@ table.chartelement { input.regular-text { font-size: 11px; width: 28em; +} + +span.rahmen { + font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; + font-size:12px; + font-weight: bold; + color: #1172B9; + background-color: #E5E5E5; + padding: 0 4px 0 4px; + border-radius: 1em; + -moz-border-radius:4px; + -khtml-border-radius:4px; } \ No newline at end of file diff --git a/trunk/semmelstatzR.php b/trunk/semmelstatzR.php index dab6e33..d1fbeda 100644 --- a/trunk/semmelstatzR.php +++ b/trunk/semmelstatzR.php @@ -62,11 +62,15 @@ if(is_admin() == true) { /** * add CSS + * + * @uses wp add_action() * * @return void */ function semmelstatzR_css() { - print "\n"; + print "\n"; } add_action('admin_head', 'semmelstatzR_css'); ### End add CSS @@ -74,13 +78,15 @@ if(is_admin() == true) { /** * add toplevel menu into admin * - * @todo localization + * @uses wp add_action() admin_menu * * @return void */ function semmelstatzR_menu() { if (function_exists('add_menu_page')) { - add_menu_page('SemmelstatzR','SemmelstatzR', 'manage_statz', 'semmelstatzR/semmelstatzR-statz.php', '', plugins_url('semmelstatzR/img/statz_small.png')); + add_menu_page('SemmelstatzR','SemmelstatzR', + 'manage_statz', 'semmelstatzR/semmelstatzR-statz.php', '', + plugins_url('semmelstatzR/img/statz_small.png')); } if (function_exists('add_submenu_page')) { @@ -107,10 +113,10 @@ if(is_admin() == true) { } } add_action('admin_menu', 'semmelstatzR_menu'); + ### end add toplevel adminmenu + // include context help system include SEMMELSTATZR_SRVPATH."includes/help/start.php"; - ### end add toplevel adminmenu - /** @@ -162,7 +168,6 @@ if(is_admin() == true) { ### Anlegen der Tabellen, Optionen schreiben -add_action('activate_semmelstatzR/semmelstatzR.php', 'sem_statzsetup'); function sem_statzsetup() { global $wpdb; if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) { @@ -211,6 +216,7 @@ function sem_statzsetup() { $role->add_cap('manage_statz'); } } +add_action('activate_semmelstatzR/semmelstatzR.php', 'sem_statzsetup'); ### Zugriff analysieren und in statz-Tabelle schreiben add_action('wp_footer', 'sem_writeStatz'); @@ -275,33 +281,48 @@ $wpdb->query("INSERT INTO $wpdb->statz (ip, time, referer, page, username) ### Rendert eine Mini-STATZ. Idee: René Tauchnitz function sem_dashboardStatz_show() { - $widgets = get_option( 'dashboard_widget_options' ); + $widget_options = get_option( 'dashboard_widget_options' ); + echo '

'; - printf(_n("%d Visitor online", "%d Visitors online", sem_showNumUsersOnline(), "semmelstatzR"), sem_showNumUsersOnline()); + printf(semr_i18np("%d Visitor online", "%d Visitors online", sem_showNumUsersOnline()), sem_showNumUsersOnline()); echo ' - '; - printf(__("Today: %s", "semmelstatzR"),sem_showTodayStatz()); - echo ' »»'; + printf(semr_i18n("Today: %s"),sem_showTodayStatz()); + echo ' »»'; + echo '

'; + echo '

'; + printf(semr_i18n("This blog is online since %s that are %s days.
"), + ''.sem_showFirstPostDate()."", + ''.sem_showPostDays().""); + printf(semr_i18n("SemmelstatzR collects the statistics since %s."), + ''.sem_showStatzStartDate().""); echo '

'; } function sem_dashboardStatz_control() { - if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) + if (!$widget_options = get_option('dashboard_widget_options')) $widget_options = array(); - if ( !isset($widget_options['dashboard_sem_dashboardStatz']) ) + if (!isset($widget_options['dashboard_sem_dashboardStatz'])) $widget_options['dashboard_sem_dashboardStatz'] = array(); - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['dashboard-sem-dashboardStatz']) ) { + if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['dashboard-sem-dashboardStatz'])) { $number = absint( $_POST['dashboard-sem-dashboardStatz']['items'] ); $number = ($number > 20)?20:$number; $widget_options['dashboard_sem_dashboardStatz']['items'] = $number; + $widget_options['dashboard_sem_dashboardStatz']['showinfo'] = + ($_POST['dashboard-sem-dashboardStatz']['showinfo'] == true)?true:false; update_option( 'dashboard_widget_options', $widget_options ); } - $number = isset( $widget_options['dashboard_sem_dashboardStatz']['items'] ) ? (int) $widget_options['dashboard_sem_dashboardStatz']['items'] : ''; - - echo '

'; - echo '

'; + $number = isset( $widget_options['dashboard_sem_dashboardStatz']['items'] )? + (int) $widget_options['dashboard_sem_dashboardStatz']['items'] : ''; + $checked = isset($widget_options['dashboard_sem_dashboardStatz']['showinfo'])?'checked="checked"':''; + + echo '

'; + echo '

'; + echo '

'; + echo '

'; //print_r($widget_options['dashboard_sem_dashboardStatz']); }