Skip to content

Commit

Permalink
#107 setting client container if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Aug 21, 2013
1 parent 1f251f8 commit 66cc7f1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/helpers/mvc.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,19 @@ function __construct($controller_path,$web_folder,$default_controller,$default_f
parent::__construct($controller_path,$web_folder,$default_controller,$default_function);
}

// display the client vars
function client_js() {
// set the right header
header('Content-Type: application/javascript');
// display the client vars
// container
if( !array_key_exists("_client", $_SESSION) || !is_array($_SESSION["_client"]) )
$_SESSION["_client"] = array();
//
$path = null;
if( !empty( $_SERVER["HTTP_REFERER"] ) ){
$url = parse_url ( $_SERVER["HTTP_REFERER"] );
$path = ( array_key_exists('path', $url) ) ? $url['path'] : "/";
}
// set the right header
header('Content-Type: application/javascript');
echo ( !empty( $_SESSION["_client"][$path] ) ) ? $_SESSION["_client"][$path] : "";
}

Expand Down

0 comments on commit 66cc7f1

Please sign in to comment.