ZF-4397: getLastRequest() when _request is AJAXed`

Description

Hi,

It would be very useful to have a possibility of having this while using with AJAX requests, i.e. when AJAX request is invoked then two fields are set in $_SERVER: HTTP_REFERER and [HTTP_X_REQUESTED_WITH] => XMLHttpRequest

and HTTP_REFERER contains the original page URI that is in browser. This is useful when I am having tabs that are being fed with HTML AJAX output and I want to render the proper viewscript basing on the page that I am really on (and not on the request itself where I don't have the information about the controller/action that is requesting by AJAX)

A sample implementation in the Controller's init():

if (isset($_SERVER["HTTP_REFERER"])){
  preg_match('#<a rel="nofollow" href="http://[^/]+/">http://[^/]+/</a>([^/]+)/([^/]+)/(.+)#',$_SERVER["HTTP_REFERER"],$matches);
  $params = array();
  foreach ((array)split("/",$matches[3]) as $val){
    if (isset($param)) {
      $param[key($param)] = $val;
      $params[] = $param;
      unset($param);
    }else {
      $param = array($val=>null);
    }  
  }
  $this->origRequest["controller"] = $matches[1];
  $this->origRequest["action"] = $matches[2];
  $this->origRequest["params"] = $params;
}

Comments

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.