[ Index ]

MailPress 544

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

title

Body

[close]

/mp-includes/class/ -> MP_tracking_metabox_sysinfo_.class.php (source)

   1  <?php
   2  abstract class MP_tracking_metabox_sysinfo_ extends MP_tracking_metabox_
   3  {
   4      var $query = true;
   5  
   6  	function __construct($title)
   7      {
   8          if (!class_exists('MP_Tracking_useragents', false)) new MP_Tracking_useragents();
   9          parent::__construct($title);
  10      }
  11  
  12  	function meta_box($item)
  13      {
  14          global $wpdb;
  15  
  16          $tracks = $wpdb->get_results( $wpdb->prepare( "SELECT context, count(*) as count FROM $wpdb->mp_tracks WHERE $this->item_id = %d AND mail_id <> 0 GROUP BY context ORDER BY context;", $item->id) );
  17  
  18          if ($tracks)
  19          {
  20              $total = 0;
  21              foreach($tracks as $track)
  22              {
  23                  $context[$track->context] = $track->count;
  24                  $total += $track->count;
  25              }
  26              foreach($context as $k => $v)
  27              {
  28                  echo '<b>' . $k . '</b> : &#160;' . sprintf("%01.2f %%",100 * $v/$total ) . '&#160;&#160;&#160;&#160;';
  29              }
  30              echo '<br />';
  31          }
  32  
  33          if (!$this->query) return $this->extended_meta_box($item);
  34  
  35          $tracks = $wpdb->get_results( $wpdb->prepare( "SELECT agent, count(*) as count FROM $wpdb->mp_tracks WHERE $this->item_id = %d GROUP BY agent ORDER BY count DESC;", $item->id) );
  36          if ($tracks) $this->extended_meta_box($tracks);
  37      }
  38  
  39  	function _010($tracks)
  40      {
  41          echo '<br />';
  42          $total = $z = 0;
  43          foreach($tracks as $track)
  44          {
  45              $agent[$track->agent] = $track->count;
  46              $total += $track->count;
  47          }
  48  
  49          $items = MP_Tracking_useragents::get_all();
  50          $count = count($items);
  51  
  52          $int_width = 3;
  53          $width = (100 - ($int_width * ($count - 1)))/$count;
  54  
  55          echo '<table id ="tracking_mp_010"><tr>';
  56          foreach($items as $item => $desc)
  57          {
  58              echo "<th class='border' width='{$width}%'>$desc</th>";
  59              if (++$z != $count) echo "<th width='{$int_width}%'></th>";
  60          }
  61          echo '</tr><tr>';
  62  
  63          $z = 0;
  64          foreach($items as $item => $desc)
  65          {
  66              $x = array();
  67              foreach($agent as $k => $v)
  68              {
  69                  $ug = apply_filters('MailPress_tracking_useragents_' . $item . '_get',      $k);
  70                  $key = $ug->name;
  71                  if (isset($x[$key]['count']))     $x[$key]['count'] += $v;
  72                  else                         $x[$key]['count']  = $v;
  73                  if (isset($ug->icon_path) && !isset($x[$key]['img'])) $x[$key]['img'] = $ug->icon_path;
  74              }
  75  
  76              if (isset($x[''])) { $w = $x['']; unset($x['']); } else unset($w);
  77              uasort($x, create_function('$a, $b', 'return $b["count"] - $a["count"];'));
  78              if (isset($w)) $x[''] = $w;
  79  
  80              echo '<td class="border"><table>';
  81              foreach($x as $k => $v)
  82              {
  83                  echo '<tr><td>';
  84                  if (isset($v['img'])) echo '<img src="' . $v['img'] . '" alt="" /> ';
  85                  echo (empty($k)) ? __('others', MP_TXTDOM) : $k;
  86                  echo ' </td><td class="num">' . sprintf("%01.2f %%",100 * $v['count']/$total );
  87                  echo '</td></tr>';
  88              }
  89              echo '</table></td>';
  90              if (++$z != $count) echo '<td></td>';
  91          }
  92          echo '</tr></table>';
  93      }
  94  }


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