コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
    /**
     * rpc_get_metrics function.
     * 
     * @access public
     * @param mixed $args
     * @return array
     */
    function rpc_get_metrics($args)
    {
        if (null == $args) {
            return -1;
        }
        $key = $args['key'];
        if (!$this->verifyKey($key)) {
            return -1;
        }
        $dao = new WPSDTrendsDao();
        $factory = new WPSDStatsFactory();
        $types = array('alexa' => array('title' => 'Alexa', 'description' => __('The traffic rank is based on three months of aggregated historical traffic data from millions 
					of Alexa Toolbar users and data obtained from other, diverse traffic data sources, and is a combined measure of 
					page views and users (reach).', 'wpsd'), 'id' => $factory->alexa), 'pagerank' => array('title' => 'Pagerank', 'description' => __('PageRank is a numeric value that represents how important a page is on the web. 
					Google figures that when one page links to another page, it is effectively casting a vote for the other page. 
					The more votes that are cast for a page, the more important the page must be.', 'wpsd'), 'id' => $factory->pagerank), 'engagement' => array('title' => __('Engagement', 'wpsd'), 'description' => __('The number of comments added to your blog.', 'wpsd'), 'id' => $factory->engagement), 'bing' => array('title' => 'Bing', 'description' => __('Number of search results in the Microsoft Bing search engine.', 'wpsd'), 'id' => $factory->bing), 'google' => array('title' => 'Google Backlinks', 'description' => __('The number of google backlinks. A backlink is any link received by a web page from another web page. The number of backlinks is one indication of the popularity or importance of that website or page in search engines.', 'wpsd'), 'id' => $factory->google_backlinks), 'twitter' => array('title' => 'Twitter Followers', 'description' => __('The number of Twitter followers. Twitter is a real-time information network that connects you to the latest stories, ideas, opinions and news about what you find interesting', 'wpsd'), 'id' => $factory->twitter_followers), 'facebook' => array('title' => 'Facebook Likes', 'description' => __('The number of Facebook likes. Facebook is a social networking service.', 'wpsd'), 'id' => $factory->facebook), 'linkedin' => array('title' => 'LinkedIn Connections', 'description' => __('The number of LinkedIn connections', 'wpsd'), 'id' => $factory->linkedin_connections), 'klout' => array('title' => 'Klout Rank', 'description' => __('The Klout Score measures influence based on your ability to drive action. 
					Every time you create content or engage you influence others.', 'wpsd'), 'id' => $factory->klout), 'youtube' => array('title' => 'Youtube Views', 'description' => __('The number of video views on Youtube. YouTube allows billions of people to discover, watch and share originally-created videos.', 'wpsd'), 'id' => $factory->youtube), 'pinterest' => array('title' => 'Pinterest Followers', 'description' => __('The number followers on Pinterest. Pinterest is a virtual pinboard. Pinterest allows you to organize and share all the beautiful things you find on the web. You can browse pinboards created by other people to discover new things and get inspiration from people who share your interests.', 'wpsd'), 'id' => $factory->pinterest_followers), 'googleplus' => array('title' => 'Google Plus Followers', 'description' => __('The number followers on Google Plus. Google Plus aims to make sharing on the web more like sharing in real life. ', 'wpsd'), 'id' => $factory->googleplus));
        $ret = array();
        foreach ($types as $type => $arr) {
            $title = $arr['title'];
            $desc = $arr['description'];
            $id = $arr['id'];
            $ret[$type] = $dao->getStats($id);
            $ret[$type][] = $title;
            $ret[$type][] = $desc;
        }
        //$ret['total_views'] = get_option('wpsd_alltime_hits');
        //$this->writeCache('metrics', $ret);
        return $ret;
    }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
// 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;
            }
        }
        if (null != $set) {
            foreach ($set as $date => $value) {
                $dataSet[$date] = number_format($value, 0, '.', '');
            }
        }
        $dataSet = array_reverse($dataSet, true);
        $count = count($dataSet);
        $labels = '';
        $values = '';