b2evolution PHP Cross Reference Blogging Systems

Source: /inc/sessions/views/_stats_goalhits.view.php - 187 lines - 5972 bytes - Summary - Text - Print

Description: This file implements the UI view for the Goal Hit list. b2evolution - {@link http://b2evolution.net/} Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   1  <?php
   2  /**
   3   * This file implements the UI view for the Goal Hit list.
   4   *
   5   * b2evolution - {@link http://b2evolution.net/}
   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * @package admin
  11   *
  12   * @version $Id: _stats_goalhits.view.php 6136 2014-03-08 07:59:48Z manuel $
  13   */
  14  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  15  
  16  global $blog, $admin_url, $rsc_url;
  17  global $Session, $UserSettings;
  18  
  19  /**
  20   * View funcs
  21   */
  22  require_once dirname(__FILE__).'/_stats_view.funcs.php';
  23  
  24  global $datestartinput, $datestart, $datestopinput, $datestop;
  25  
  26  if( param_date( 'datestartinput', T_('Invalid date'), false,  NULL ) !== NULL )
  27  {    // We have a user provided localized date:
  28      memorize_param( 'datestart', 'string', NULL, trim(form_date($datestartinput)) );
  29  }
  30  else
  31  {    // We may have an automated param transmission date:
  32      param( 'datestart', 'string', '', true );
  33  }
  34  if( param_date( 'datestopinput', T_('Invalid date'), false, NULL ) !== NULL )
  35  {    // We have a user provided localized date:
  36      memorize_param( 'datestop', 'string', NULL, trim(form_date($datestopinput)) );
  37  }
  38  else
  39  {    // We may have an automated param transmission date:
  40      param( 'datestop', 'string', '', true );
  41  }
  42  //pre_dump( $datestart, $datestop );
  43  
  44  $exclude = param( 'exclude', 'integer', 0, true );
  45  $sess_ID = param( 'sess_ID', 'integer', NULL, true );
  46  $goal_name = param( 'goal_name', 'string', NULL, true );
  47  
  48  if( param_errors_detected() )
  49  {
  50      $sql = 'SELECT 0 AS count';
  51      $sql_count = 0;
  52  }
  53  else
  54  {
  55      // Create result set:
  56      $SQL = new SQL();
  57      $SQL->SELECT( 'hit_ID, sess_ID, hit_datetime, hit_referer_type, hit_uri, hit_blog_ID, hit_referer, hit_remote_addr,
  58                                      user_login, hit_agent_type, dom_name, goal_name, keyp_phrase' );
  59      $SQL->FROM( 'T_track__goalhit LEFT JOIN T_hitlog ON ghit_hit_ID = hit_ID
  60                                      LEFT JOIN T_basedomains ON dom_ID = hit_referer_dom_ID
  61                                    LEFT JOIN T_track__keyphrase ON hit_keyphrase_keyp_ID = keyp_ID
  62                                      LEFT JOIN T_sessions ON hit_sess_ID = sess_ID
  63                                      LEFT JOIN T_users ON sess_user_ID = user_ID
  64                                      LEFT JOIN T_track__goal ON ghit_goal_ID = goal_ID' );
  65  
  66      $SQL_count = new SQL();
  67      $SQL_count->SELECT( 'COUNT(ghit_ID)' );
  68      $SQL_count->FROM( 'T_track__goalhit LEFT JOIN T_hitlog ON ghit_hit_ID = hit_ID' );
  69  
  70      if( !empty($datestart) )
  71      {
  72          $SQL->WHERE_and( 'hit_datetime >= '.$DB->quote($datestart.' 00:00:00') );
  73          $SQL_count->WHERE_and( 'hit_datetime >= '.$DB->quote($datestart.' 00:00:00') );
  74      }
  75      if( !empty($datestop) )
  76      {
  77          $SQL->WHERE_and( 'hit_datetime <= '.$DB->quote($datestop.' 23:59:59') );
  78          $SQL_count->WHERE_and( 'hit_datetime <= '.$DB->quote($datestop.' 23:59:59') );
  79      }
  80  
  81      if( !empty($sess_ID) )
  82      {    // We want to filter on the session ID:
  83          $operator = ($exclude ? ' <> ' : ' = ' );
  84          $SQL->WHERE_and( 'hit_sess_ID'.$operator.$sess_ID );
  85          $SQL_count->FROM_add( 'LEFT JOIN T_sessions ON hit_sess_ID = sess_ID' );
  86          $SQL_count->WHERE_and( 'hit_sess_ID'.$operator.$sess_ID );
  87      }
  88  
  89      if( !empty($goal_name) ) // TODO: allow combine
  90      { // We want to filter on the goal name:
  91          $operator = ($exclude ? ' NOT LIKE ' : ' LIKE ' );
  92          $SQL->WHERE_and( 'goal_name'.$operator.$DB->quote($goal_name.'%') );
  93          $SQL_count->FROM_add( 'LEFT JOIN T_track__goal ON ghit_goal_ID = goal_ID' );
  94          $SQL_count->WHERE_and( 'goal_name'.$operator.$DB->quote($goal_name.'%') );
  95      }
  96  
  97      $sql = $SQL->get();
  98      $sql_count = $SQL_count->get();
  99  }
 100  
 101  $Results = new Results( $sql, 'ghits_', '--D', $UserSettings->get( 'results_per_page' ), $sql_count );
 102  
 103  $Results->title = T_('Recent goal hits').get_manual_link( 'goal-hits' );
 104  
 105  /**
 106   * Callback to add filters on top of the result set
 107   *
 108   * @param Form
 109   */
 110  function filter_goal_hits( & $Form )
 111  {
 112      global $datestart, $datestop;
 113  
 114      $Form->date_input( 'datestartinput', $datestart, T_('From') );
 115      $Form->date_input( 'datestopinput', $datestop, T_('to') );
 116  
 117      $Form->checkbox_basic_input( 'exclude', get_param('exclude'), T_('Exclude').' &rarr; ' );
 118      $Form->text_input( 'sess_ID', get_param('sess_ID'), 15, T_('Session ID'), '', array( 'maxlength'=>20 ) );
 119      $Form->text_input( 'goal_name', get_param('goal_name'), 20, T_('Goal names starting with'), '', array( 'maxlength'=>50 ) );
 120  }
 121  $Results->filter_area = array(
 122      'callback' => 'filter_goal_hits',
 123      'url_ignore' => 'results_hits_page,exclude,sess_ID,goal_name,datestartinput,datestart,datestopinput,datestop',
 124      'presets' => array(
 125          'all' => array( T_('All'), '?ctrl=stats&amp;tab=goals&amp;tab3=hits&amp;blog=0' ),
 126          'all_but_curr' => array( T_('All but current session'), '?ctrl=stats&amp;tab=goals&amp;tab3=hits&amp;blog=0&amp;sess_ID='.$Session->ID.'&amp;exclude=1' ),
 127          )
 128      );
 129  
 130  $Results->cols[] = array(
 131          'th' => T_('Session'),
 132          'order' => 'hit_sess_ID',
 133          'td_class' => 'right',
 134          'td' => '<a href="?ctrl=stats&amp;tab=hits&amp;blog=0&amp;sess_ID=$sess_ID$">$sess_ID$</a>',
 135      );
 136  
 137  $Results->cols[] = array(
 138          'th' => T_('User'),
 139          'order' => 'user_login',
 140          'td' => '%stat_session_login( #user_login# )%',
 141      );
 142  
 143  $Results->cols[] = array(
 144          'th' => T_('Date Time'),
 145          'order' => 'ghit_ID',
 146          'default_dir' => 'D',
 147          'td_class' => 'timestamp',
 148          'td' => '%mysql2localedatetime_spans( #hit_datetime#, "M-d" )%',
 149       );
 150  
 151  $Results->cols[] = array(
 152          'th' => T_('Type'),
 153          'order' => 'hit_referer_type',
 154          'td' => '$hit_referer_type$',
 155      );
 156  
 157  $Results->cols[] = array(
 158          'th' => T_('U.A.'),
 159          'order' => 'hit_agent_type',
 160          'td' => '$hit_agent_type$',
 161      );
 162  
 163  $Results->cols[] = array(
 164          'th' => T_('Referer'),
 165          'order' => 'dom_name',
 166          'td_class' => 'nowrap',
 167          'td' => '<a href="$hit_referer$">$dom_name$</a>',
 168      );
 169  
 170  // Keywords:
 171  $Results->cols[] = array(
 172          'th' => T_('Search keywords'),
 173          'order' => 'keyp_phrase',
 174          'td' => '%stats_search_keywords( #keyp_phrase# )%',
 175      );
 176  
 177  $Results->cols[] = array(
 178          'th' => T_('Goal'),
 179          'order' => 'goal_name',
 180          'default_dir' => 'D',
 181          'td' => '$goal_name$',
 182      );
 183  
 184  // Display results:
 185  $Results->display();
 186  
 187  ?>

title

Description

title

Description

title

Description

title

title

Body