/** * 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; }
/** * 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; }