[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/dashboard/widgets/ -> users_map.php (source)

   1  <?php
   2  class MP_Dashboard_users_map extends MP_dashboard_widget_
   3  {
   4      const option_name = 'MailPress_dashboard_mp_map';
   5  
   6      var $id = 'mp_users_map';
   7  
   8  	function widget()
   9      {
  10          global $wpdb, $wp_locale;
  11  
  12          if ( !$options = get_option( self::option_name ) )
  13          {
  14              $options['code'] = 'world';
  15              $options['title'] = __( 'Subscribers - World', MP_TXTDOM );
  16          }
  17  
  18          $chd = $chld = array();
  19  
  20          $where = "status='active'";
  21          $where .= ('usa' == $options['code']) ? " AND created_country = 'US' AND created_US_state <> 'ZZ'" : " AND created_country <> 'ZZ'";
  22  
  23          $countalls = $wpdb->get_var("SELECT count(*) FROM $wpdb->mp_users WHERE $where ;");
  24          $users = $wpdb->get_results("SELECT created_US_state as toto, count(*) as count FROM $wpdb->mp_users WHERE $where GROUP BY created_US_state;");
  25  
  26          foreach($users as $user)
  27          {
  28              $chld[] = ('UK' == $user->toto) ? 'GB' : $user->toto;
  29              $chd[]  = round(100 * $user->count/$countalls);
  30          }
  31  
  32          $args = array();
  33          $args['cht']  = 't';
  34          $args['chs']  = $this->widget_size('440x200');
  35          $args['chtm'] = $options['code'];
  36          $args['chf']  = 'bg,s,EAF7FE';
  37          if (!empty($chld)) $args['chld'] = join('', $chld);
  38          $args['chco'] = 'ffffff,B5F8C2,294D30';
  39          $args['chd']  = (empty($chd)) ? 's:_' : 't:' . join(',', $chd);
  40          $url = esc_url(add_query_arg($args, $this->url));
  41  
  42  ?>
  43  <div style='text-align:center;'>
  44  <img style='width:100%;' src="<?php echo $url; ?>" alt="<?php echo $options['title']; ?>" />
  45  </div>
  46  <?php
  47      }
  48  
  49  	function control()
  50      {
  51          $c= array (    'africa'         => __('Africa', MP_TXTDOM),
  52                  'asia'        => __('Asia', MP_TXTDOM),
  53                  'europe'        => __('Europe', MP_TXTDOM),
  54                  'middle_east'    => __('Middle East', MP_TXTDOM),
  55                  'south_america'    => __('South America', MP_TXTDOM),
  56                  'usa'            => __('USA', MP_TXTDOM),
  57                  'world'        => __('World', MP_TXTDOM));
  58  
  59          if ( !$options = get_option( self::option_name ) )
  60          {
  61              $options['code'] = 'world';
  62              $options['title'] = $c[$options['code']];
  63          }
  64          if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['code']) ) 
  65          {    
  66              update_option( self::option_name, array('code' => $_POST['code'] , 'title' => $c[$_POST['code']]) );
  67              return;
  68          }
  69  ?>
  70              <select id='code' name='code'>
  71  <?php
  72              MP_::select_option($c, $options['code']);
  73  ?>
  74              </select>
  75  <?php
  76      }
  77  }
  78  new MP_Dashboard_users_map(__( 'MailPress - Subscribers Map', MP_TXTDOM ));


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1