1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: if ( ! defined( 'ABSPATH' ) ) {
14: exit;
15: }
16:
17: 18: 19:
20: class WxRobot_Admin_Menu_Statistics{
21:
22: 23: 24: 25: 26:
27: public function init(){
28: add_action('init', array($this, 'statistics_ajax'), 10);
29: add_action('admin_head', array(&$this, 'weixin_robot_menu_js'), 10);
30: }
31:
32: 33: 34: 35: 36:
37: public function menu(){
38: add_submenu_page('weixin-robot',
39: 'weixin-robot',
40: '微信机器人统计',
41: 'manage_options',
42: 'weixin-robot-statistics',
43: array($this, 'weixin_robot_statistics'));
44: }
45:
46: 47: 48: 49: 50:
51: public function statistics_ajax(){
52: if(!empty($_POST['page']) && $_POST['page'] == 'weixin-robot-statistics'){
53: echo($this->weixin_robot_count_ajax());
54: }
55: }
56:
57: 58: 59: 60: 61:
62: public function weixin_robot_count_ajax(){
63: $text = WxRobot_Table_Records::instance()->weixin_get_msgtype_count('text');
64: $voice = WxRobot_Table_Records::instance()->weixin_get_msgtype_count('voice');
65: $video = WxRobot_Table_Records::instance()->weixin_get_msgtype_count('video');
66: $link = WxRobot_Table_Records::instance()->weixin_get_msgtype_count('link');
67: $event = WxRobot_Table_Records::instance()->weixin_get_msgtype_count('event');
68: $image = WxRobot_Table_Records::instance()->weixin_get_msgtype_count('image');
69: $location = WxRobot_Table_Records::instance()->weixin_get_msgtype_count('location');
70:
71: $list['text'] = $text;
72: $list['voice'] = $voice;
73: $list['video'] = $video;
74: $list['link'] = $link;
75: $list['event'] = $event;
76: $list['image'] = $image;
77: $list['location'] = $location;
78: return json_encode($list);
79: }
80:
81: 82: 83: 84: 85:
86: public function weixin_robot_menu_js(){
87: $url = WEIXIN_ROBOT_URL;
88: if(!empty($_GET['page']) && 'weixin-robot-statistics' == $_GET['page']){
89: echo '<script type="text/javascript" src="'.$url.'/assets/js/ichart.min.js"></script>';
90: echo '<script type="text/javascript" src="'.$url.'/assets/js/ichart.count.js"></script>';
91: }
92:
93: }
94:
95: 96: 97:
98: public function weixin_robot_statistics(){
99: echo '<div class="wrap"><div class="metabox-holder">',
100: '<div class="postbox"><h3>微信通信记录统计分析</h3><div id="canvasDiv1"></div></div></div></div>';
101: do_action('weixin_midoks_push');
102: }
103: }
104:
105: ?>
106: