/** * Widget. */ function widget($args = array()) { if (is_array($args)) { extract($args, EXTR_SKIP); } echo $before_widget . $before_title . $widget_name . $after_title; $form = new WPSDAdminConfigForm(); if ($form->getWpsdWidgetTrends()) { $dao = new WPSDTrendsDao(); $factory = new WPSDStatsFactory(); $trends_type = $form->getWpsdTrendsType(); if (null == $trends_type) { $trends_type = $factory->pagerank; } $rows = $dao->getStats($trends_type); $data = array(); if (is_array($rows)) { foreach ($rows as $row) { $data[$row->wpsd_trends_date] = $row->wpsd_trends_stats; } } // Default is pagerank. $this->render_admin('admin_trend', array('set' => $data, 'label' => 'days', 'form' => $form)); } else { _e('Widget disabled check', 'wpsd'); echo ' <a href="' . wpsd_get_settings_url() . '" title="wp-stats-dashboard settings" target="_self">' . __('settings', 'wpsd') . '</a>'; } echo $after_widget; }
<td><?php echo '<img src="' . WPSD_PLUGIN_URL . '/resources/images/icons/' . $icon . '.png" alt="' . $icon . ' icon" />'; ?> </td> <td<?php echo $alt_count % 2 == 0 ? ' class="alternate"' : ''; ?> ><?php echo $html1; ?> </td> <td<?php echo $alt_count % 2 == 0 ? ' class="alternate"' : ''; ?> ><?php echo $html2; ?> </td> </tr> <?php $alt_count++; } // Start loading. wpsd_load_stats(); $dao = new WPSDTrendsDao(); $factory = new WPSDStatsFactory(); // Update stats. for ($i = 1; $i <= $factory->last; $i++) { $dao->update($i, $factory->getStats($i)); } die;
/** * updateStats function. * * @access public * @return void */ function updateStats() { global $wpsd_update_cache; $wpsd_update_cache = true; $dao = new WPSDTrendsDao(); $factory = new WPSDStatsFactory(); for ($i = 1; $i <= $factory->last; $i++) { // Update stats. $dao->update($i, $factory->getStats($i)); } }
/** * wp_ajax_wpsd_load_trend function. * * @access public * @return void */ function wp_ajax_wpsd_load_trend() { $type = $_REQUEST['type']; $dao = new WPSDTrendsDao(); $rows = $dao->getStats($type); $data = array(); if (is_array($rows)) { foreach ($rows as $row) { $data[$row->wpsd_trends_date] = $row->wpsd_trends_stats; } } // Default is pagerank. $this->render_admin('admin_ajax_trend_visualize', array('set' => $data, 'label' => 'days', 'title' => '')); exit; }
* Trend graph data. * * @author dligthart <*****@*****.**> * @version 0.2 * @package wp-stats-dashboard * @subpackage view */ include_once realpath(dirname(__FILE__) . '/../../../../..') . '/wp-load.php'; // load wordpress context. // Check user. $user = wp_get_current_user(); // Only for admin. if ($user->caps['administrator'] || wpsd_has_access()) { $form = new WPSDAdminConfigForm(); if ($form->getWpsdWidgetTrends()) { $dao = new WPSDTrendsDao(); $factory = new WPSDStatsFactory(); $trends_type = $form->getWpsdTrendsType(); if (null == $trends_type) { $trends_type = $factory->pagerank; } if (isset($_REQUEST['type'])) { $trends_type = $_REQUEST['type']; } $rows = $dao->getStats($trends_type); $set = array(); if (is_array($rows)) { foreach ($rows as $row) { $set[$row->wpsd_trends_date] = $row->wpsd_trends_stats; } }