[ Index ]

MailPress 7.2

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

title

Body

[close]

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

   1  <?php
   2  abstract class MP_tracking_xml_
   3  {
   4  	function __construct( $title )
   5      {
   6          $this->title = $title;
   7          $this->img_path = site_url() . '/' . MP_PATH . "mp-admin/images/{$this->id}";
   8      
   9          $xml = new SimpleXMLElement( file_get_contents( MP_ABSPATH . "mp-admin/xml/{$this->id}s.xml" ) );
  10          $this->xml = $xml->{$this->id};
  11  
  12          add_filter( "MailPress_tracking_{$this->folder}_register",        array( $this, 'register' ),    8, 1 );
  13          add_filter( "MailPress_tracking_{$this->folder}_{$this->id}_get",array( $this, 'get' ),     8, 1 );
  14      }
  15  
  16  	function register( $items )
  17      {
  18          $items[$this->id] = $this->title;
  19          return $items;
  20      }
  21  
  22  	function get( $string )
  23      {
  24          $item = new stdClass();
  25          $count = 0;
  26  
  27          foreach ( $this->xml as $i )
  28          {
  29              unset( $icon );
  30              $count++;
  31  
  32              if ( !@preg_match( $i->pattern, $string, $matches ) ) continue;
  33              if ( isset( $i->icon ) ) $icon = $i->icon;
  34              if ( !isset( $i->versions ) ) break;
  35  
  36              foreach( $i->versions as $attrs ) $vp = ( int ) $attrs['pattern'];
  37  
  38              switch ( true ) 
  39              {
  40                  case ( isset( $i->versions->id ) ) :
  41                      foreach( $i->versions->id as $ver )
  42                      {
  43                          if ( @preg_match( $ver->pattern, $matches[$vp] ) )
  44                          {
  45                              $version = ( string ) $ver->name;
  46                              if ( isset( $ver->icon ) ) $icon = ( string ) $ver->icon;
  47                              break;
  48                          }
  49                      }
  50                  break;
  51                  case ( !empty( $i->versions ) ) :
  52                      @preg_match( $i->versions, $string, $matches );
  53                      if ( isset( $matches[$vp] ) ) $version = $matches[$vp];
  54                  break;
  55                  default :
  56                      $version = ( string ) $matches[$vp];
  57                  break;
  58              }
  59              break;
  60          }
  61  
  62          $item->string = $string;
  63          if ( isset( $i->name ) ) { $item->name = ( string ) $i->name; }
  64          if ( isset( $version ) ) { $item->version = ( string ) $version; }
  65          if ( isset( $i->link ) ) { $item->link = ( string ) $i->link; }
  66          if ( isset( $icon ) )    { $item->icon = ( string ) $icon; $item->icon_path = "{$this->img_path}/{$item->icon}"; }
  67          if ( isset( $icon ) )    { $item->classes = ( string ) 'mp_' . $this->id . ' mp_' . $this->id . '_' . substr( $item->icon, 0, -4 ); }
  68  
  69          if ( isset( $item->name ) )    $item->full_name = ( isset( $item->version ) ) ? "{$item->name} {$item->version}" : $item->name;
  70          else                    $item->name = $item->full_name = '';
  71          $item->count = $count;
  72  
  73          return $item;
  74      }
  75  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1