1
0
Fork 0

enhancing dashboard widget part I

Dieser Commit ist enthalten in:
Oldperl 2011-11-15 23:36:35 +00:00
Ursprung 69af1567f5
Commit 97f9004713
2 geänderte Dateien mit 50 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -129,4 +129,16 @@ table.chartelement {
input.regular-text { input.regular-text {
font-size: 11px; font-size: 11px;
width: 28em; 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;
} }

Datei anzeigen

@ -62,11 +62,15 @@ if(is_admin() == true) {
/** /**
* add CSS * add CSS
*
* @uses wp add_action()
* *
* @return void * @return void
*/ */
function semmelstatzR_css() { function semmelstatzR_css() {
print "<link rel='stylesheet' href='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/semmelstatzR.css' type='text/css' media='screen' />\n"; print "<link rel='stylesheet' href='".
get_option('siteurl').
"/wp-content/plugins/semmelstatzR/semmelstatzR.css' type='text/css' media='screen' />\n";
} }
add_action('admin_head', 'semmelstatzR_css'); add_action('admin_head', 'semmelstatzR_css');
### End add CSS ### End add CSS
@ -74,13 +78,15 @@ if(is_admin() == true) {
/** /**
* add toplevel menu into admin * add toplevel menu into admin
* *
* @todo localization * @uses wp add_action() admin_menu
* *
* @return void * @return void
*/ */
function semmelstatzR_menu() { function semmelstatzR_menu() {
if (function_exists('add_menu_page')) { 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')) { if (function_exists('add_submenu_page')) {
@ -107,10 +113,10 @@ if(is_admin() == true) {
} }
} }
add_action('admin_menu', 'semmelstatzR_menu'); add_action('admin_menu', 'semmelstatzR_menu');
### end add toplevel adminmenu
// include context help system // include context help system
include SEMMELSTATZR_SRVPATH."includes/help/start.php"; include SEMMELSTATZR_SRVPATH."includes/help/start.php";
### end add toplevel adminmenu
/** /**
@ -162,7 +168,6 @@ if(is_admin() == true) {
### Anlegen der Tabellen, Optionen schreiben ### Anlegen der Tabellen, Optionen schreiben
add_action('activate_semmelstatzR/semmelstatzR.php', 'sem_statzsetup');
function sem_statzsetup() { function sem_statzsetup() {
global $wpdb; global $wpdb;
if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) { if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
@ -211,6 +216,7 @@ function sem_statzsetup() {
$role->add_cap('manage_statz'); $role->add_cap('manage_statz');
} }
} }
add_action('activate_semmelstatzR/semmelstatzR.php', 'sem_statzsetup');
### Zugriff analysieren und in statz-Tabelle schreiben ### Zugriff analysieren und in statz-Tabelle schreiben
add_action('wp_footer', 'sem_writeStatz'); 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 ### Rendert eine Mini-STATZ. Idee: René Tauchnitz
function sem_dashboardStatz_show() { function sem_dashboardStatz_show() {
$widgets = get_option( 'dashboard_widget_options' ); $widget_options = get_option( 'dashboard_widget_options' );
echo '<p>'; echo '<p>';
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 ' - '; echo ' - ';
printf(__("Today: %s", "semmelstatzR"),sem_showTodayStatz()); printf(semr_i18n("Today: %s"),sem_showTodayStatz());
echo ' <a title="'.__("more...", "semmelstatzR").'" href="'.get_option('siteurl').'/wp-admin/admin.php?page=semmelstatzR/semmelstatzR-statz.php">&raquo;&raquo;</a>'; echo ' <a title="'.semr_i18n("more...").'" href="'.get_option('siteurl')
.'/wp-admin/admin.php?page=semmelstatzR/semmelstatzR-statz.php">&raquo;&raquo;</a>';
echo '</p>';
echo '<p style="line-height: 2.0em;">';
printf(semr_i18n("This blog is online since %s that are %s days.<br>"),
'<span class="rahmen">'.sem_showFirstPostDate()."</span>",
'<span class="rahmen">'.sem_showPostDays()."</span>");
printf(semr_i18n("SemmelstatzR collects the statistics since %s."),
'<span class="rahmen">'.sem_showStatzStartDate()."</span>");
echo '</p>'; echo '</p>';
} }
function sem_dashboardStatz_control() { function sem_dashboardStatz_control() {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) if (!$widget_options = get_option('dashboard_widget_options'))
$widget_options = array(); $widget_options = array();
if ( !isset($widget_options['dashboard_sem_dashboardStatz']) ) if (!isset($widget_options['dashboard_sem_dashboardStatz']))
$widget_options['dashboard_sem_dashboardStatz'] = array(); $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 = absint( $_POST['dashboard-sem-dashboardStatz']['items'] );
$number = ($number > 20)?20:$number; $number = ($number > 20)?20:$number;
$widget_options['dashboard_sem_dashboardStatz']['items'] = $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 ); update_option( 'dashboard_widget_options', $widget_options );
} }
$number = isset( $widget_options['dashboard_sem_dashboardStatz']['items'] ) ? (int) $widget_options['dashboard_sem_dashboardStatz']['items'] : ''; $number = isset( $widget_options['dashboard_sem_dashboardStatz']['items'] )?
(int) $widget_options['dashboard_sem_dashboardStatz']['items'] : '';
echo '<p><label for="sem-number">' . semr_i18n('Number of Items (max. 10):') . '</label>'; $checked = isset($widget_options['dashboard_sem_dashboardStatz']['showinfo'])?'checked="checked"':'';
echo '<input id="sem-number" name="dashboard-sem-dashboardStatz[items]" type="text" value="' . $number . '" size="3" /></p>';
echo '<p><label for="sem-info">' . semr_i18n('Show semR Info:').'</label>';
echo '<input id="sem-ninfo" name="dashboard-sem-dashboardStatz[showinfo]" type="checkbox" value="true"'.$checked.' /></p>';
echo '<p><label for="sem-number">' . semr_i18n('Number of Items (max. 10):') . '</label>';
echo '<input id="sem-number" name="dashboard-sem-dashboardStatz[items]" type="text" value="'.$number.'" size="3" /></p>';
//print_r($widget_options['dashboard_sem_dashboardStatz']); //print_r($widget_options['dashboard_sem_dashboardStatz']);
} }