[ Index ]

MailPress 7.1

[ 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          echo '<table id ="tracking_mp_010"><tr>';
  53          foreach( $items as $item => $desc )
  54          {
  55              echo '<th class="border b-$count">' . $desc . '</th>';
  56              if ( ++$z != $count ) echo '<th class="i-' . $count . '"></th>';
  57          }
  58          echo '</tr><tr>';
  59  
  60          $z = 0;
  61          foreach( $items as $item => $desc )
  62          {
  63              $x = array();
  64              foreach( $agent as $k => $v )
  65              {
  66                  $ug = apply_filters( "MailPress_tracking_useragents_{$item}_get",      $k );
  67                  $key = $ug->name;
  68                  if ( isset( $x[$key]['count'] ) )     $x[$key]['count'] += $v;
  69                  else                         $x[$key]['count']  = $v;
  70                  if ( isset( $ug->icon_path ) && !isset( $x[$key]['img'] ) ) 
  71                  {
  72                      $x[$key]['img'] = $ug->icon_path;
  73                      $x[$key]['class'] = $ug->classes;
  74                  }
  75              }
  76  
  77              if ( isset( $x[''] ) ) { $w = $x['']; unset( $x[''] ); } else unset( $w );
  78              uasort( $x, array( 'self', 'sort_tracks' ) );
  79              if ( isset( $w ) ) $x[''] = $w;
  80  
  81              echo '<td class="border"><table>';
  82              foreach( $x as $k => $v )
  83              {
  84                  echo '<tr><td>';
  85  //                if ( isset( $v['img'] ) ) echo '<img class="' . $v['class']  . '" src="' . $v['img'] . '" alt="" /> ';
  86                  if ( isset( $v['img'] ) ) echo '<div class="' . $v['class']  . '"></div>';
  87                  echo ( empty( $k ) ) ? __( 'others', 'MailPress' ) : $k;
  88                  echo ' </td><td class="num">' . sprintf( "%01.2f %%",100 * $v['count']/$total );
  89                  echo '</td></tr>';
  90              }
  91              echo '</table></td>';
  92              if ( ++$z != $count ) echo '<td></td>';
  93          }
  94          echo '</tr></table>';
  95      }
  96  
  97  	public static function sort_tracks( $a, $b ) 
  98      {
  99          return $b['count'] - $a['count'];
 100      }
 101  
 102  }


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1