示例#1
0
 function createClient($dom)
 {
     $client = "";
     // see if there is any "loose" source in the client
     if (!empty($GLOBALS['client']["_src"])) {
         $client = $GLOBALS['client']["_src"];
         unset($GLOBALS['client']["_src"]);
     }
     // if in debug, remove any scripts in the require.js paths
     $scripts = !empty($this->client['require']['paths']);
     if ((DEBUG || !$this->useRequire()) && $scripts) {
         // add the scripts in the require list as script tags
         $head = $dom->getElementsByTagName("head")->item(0);
         foreach ($this->client['require']['paths'] as $name => $script) {
             $src = is_array($script) ? array_shift($script) : $script;
             // check if there's a js extension
             if (substr($src, -3) != ".js") {
                 $src .= ".js";
             }
             // add straight in the head section
             $script = $dom->createElement('script');
             $script->setAttribute("type", "text/javascript");
             $script->setAttribute("src", $src);
             $head->appendChild($script);
             unset($this->client['require']['paths'][$name]);
         }
     }
     // render the global client vars
     $client .= 'Object.extend(KISSCMS, ' . json_encode_escaped($GLOBALS['client']) . ');';
     if ($this->useRequire()) {
         $client .= 'if(typeof require != "undefined") require.config( KISSCMS["require"] );';
     }
     $client = $this->trimWhitespace($client);
     // #87 not caching client vars as a file
     /*
     $client_file = "client_". $this->hash .".js";
     $cache = $this->getCache( $client_file );
     
     // write config file
     $client_sign = md5($client);
     $cache_sign = ($cache) ? md5($cache) : NULL;
     
     // the client file should not be cached by the cdn
     $client_src= WEB_FOLDER. $client_file;
     
     // check md5 signature
     if($client_sign == $cache_sign){
     	// do nothing
     } else {
     	// set the cache for later use
     	self::setCache( $client_file , $client);
     }
     */
     /*
     $client_file = "client";
     $client_src= WEB_FOLDER. $client_file;
     
     // Always render the client.js
     // render a standard script tag
     $script = $dom->createElement('script');
     $script->setAttribute("type", "text/javascript");
     $script->setAttribute("src", $client_src);
     //$script->setAttribute("defer", "defer");
     // include the script
     $dom = $this->updateDom($script, $dom);
     */
     // set the client as a session var
     if (!array_key_exists("_client", $_SESSION)) {
         $_SESSION["_client"] = array();
     }
     $_SESSION["_client"][$_SERVER["REQUEST_URI"]] = $client;
 }
示例#2
0
Object.extend = function(destination, source) {
	for (var property in source) {
		if (source[property] && source[property].constructor && source[property].constructor === Object) {
			destination[property] = destination[property] || {};
			arguments.callee(destination[property], source[property]);
		} else {
			destination[property] = source[property];
		}
	}
	return destination;
};

<?php 
if (DEBUG) {
    ?>

	var DEBUG = true;

	// raw out put of the client side vars
	Object.extend(KISSCMS, <?php 
    echo json_encode_escaped($GLOBALS['client']);
    ?>
);

<?php 
}
?>

</script>

示例#3
0
<?php

//echo json_encode( $this->stream, "JSON_UNESCAPED_SLASHES" );
echo json_encode_escaped($vars);