示例#1
0
 /**
  * @param Request            $request
  * @param null|Redirect|Page $page
  *
  * @return array
  */
 public function getHitQuery(Request $request, $page = null)
 {
     if ($page instanceof Redirect) {
         //use the configured redirect URL
         $pageURL = $page->getUrl();
     } else {
         //use current URL
         // Tracking pixel is used
         if (strpos($request->server->get('REQUEST_URI'), '/mtracking.gif') !== false) {
             $pageURL = $request->server->get('HTTP_REFERER');
             // if additional data were sent with the tracking pixel
             if ($request->server->get('QUERY_STRING')) {
                 parse_str($request->server->get('QUERY_STRING'), $query);
                 // URL attr 'd' is encoded so let's decode it first.
                 $decoded = false;
                 if (isset($query['d'])) {
                     // parse_str auto urldecodes
                     $query = $this->decodeArrayFromUrl($query['d'], false);
                     $decoded = true;
                 }
                 if (is_array($query) && !empty($query)) {
                     if (isset($query['page_url'])) {
                         $pageURL = $query['page_url'];
                         if (!$decoded) {
                             $pageURL = urldecode($pageURL);
                         }
                     }
                     if (isset($query['page_referrer'])) {
                         if (!$decoded) {
                             $query['page_referrer'] = urldecode($query['page_referrer']);
                         }
                     }
                     if (isset($query['page_language'])) {
                         if (!$decoded) {
                             $query['page_language'] = urldecode($query['page_language']);
                         }
                     }
                     if (isset($query['page_title'])) {
                         if (!$decoded) {
                             $query['page_title'] = urldecode($query['page_title']);
                         }
                     }
                     if (isset($query['tags'])) {
                         if (!$decoded) {
                             $query['tags'] = urldecode($query['tags']);
                         }
                     }
                 }
             }
         } else {
             $pageURL = 'http';
             if ($request->server->get('HTTPS') == 'on') {
                 $pageURL .= 's';
             }
             $pageURL .= '://';
             if ($request->server->get('SERVER_PORT') != '80') {
                 $pageURL .= $request->server->get('SERVER_NAME') . ':' . $request->server->get('SERVER_PORT') . $request->server->get('REQUEST_URI');
             } else {
                 $pageURL .= $request->server->get('SERVER_NAME') . $request->server->get('REQUEST_URI');
             }
         }
     }
     if (!isset($query)) {
         $query = $request->query->all();
     }
     // Set generated page url
     $query['page_url'] = $pageURL;
     // Process clickthrough if applicable
     if (!empty($query['ct'])) {
         $query['ct'] = $this->decodeArrayFromUrl($query['ct']);
     }
     return $query;
 }
 /**
  * {@inheritDoc}
  */
 public function getUrl()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUrl', array());
     return parent::getUrl();
 }