本文整理汇总了PHP中xajaxCompressJavascript函数的典型用法代码示例。如果您正苦于以下问题:PHP xajaxCompressJavascript函数的具体用法?PHP xajaxCompressJavascript怎么用?PHP xajaxCompressJavascript使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xajaxCompressJavascript函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autoCompressJavascript
/**
* This method can be used to create a new xajax.js file out of the
* xajax_uncompressed.js file (which will only happen if xajax.js doesn't
* already exist on the filesystem).
*
* @param string an optional argument containing the full server file path
* of xajax.js.
*/
function autoCompressJavascript($sJsFullFilename = NULL)
{
$sJsFile = "xajax_js/xajax.js";
if ($sJsFullFilename) {
$realJsFile = $sJsFullFilename;
} else {
$realPath = realpath(dirname(__FILE__));
$realJsFile = $realPath . "/" . $sJsFile;
}
// Create a compressed file if necessary
if (!file_exists($realJsFile)) {
$srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
if (!file_exists($srcFile)) {
trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
}
require dirname(__FILE__) . "/xajaxCompress.php";
$javaScript = implode('', file($srcFile));
$compressedScript = xajaxCompressJavascript($javaScript);
$fH = @fopen($realJsFile, "w");
if (!$fH) {
trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
} else {
fwrite($fH, $compressedScript);
fclose($fH);
}
}
}
示例2: getJavascript
function getJavascript($sJsURI = "", $sJsFile = NULL, $sJsFullFilename = NULL)
{
if ($sJsFile == NULL) {
$sJsFile = "xajax_js/xajax.js";
}
if ($sJsURI != "" && substr($sJsURI, -1) != "/") {
$sJsURI .= "/";
}
$html = "\t<script type=\"text/javascript\">\n";
$html .= "var xajaxRequestUri=\"" . $this->sRequestURI . "\";\n";
$html .= "var xajaxDebug=" . ($this->bDebug ? "true" : "false") . ";\n";
$html .= "var xajaxStatusMessages=" . ($this->bStatusMessages ? "true" : "false") . ";\n";
$html .= "var xajaxWaitCursor=" . ($this->bWaitCursor ? "true" : "false") . ";\n";
$html .= "var xajaxDefinedGet=" . XAJAX_GET . ";\n";
$html .= "var xajaxDefinedPost=" . XAJAX_POST . ";\n";
foreach ($this->aFunctions as $sFunction => $bExists) {
$html .= $this->_wrap($sFunction, $this->aFunctionRequestTypes[$sFunction]);
}
$html .= "</script>\n";
// Create a compressed file if necessary
if ($sJsFullFilename) {
$realJsFile = $sJsFullFilename;
} else {
$realPath = realpath(dirname(__FILE__));
$realJsFile = $realPath . "/" . $sJsFile;
}
$srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
if (!file_exists($srcFile)) {
trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
}
if ($this->bDebug) {
if (!@copy($srcFile, $realJsFile)) {
trigger_error("The xajax uncompressed javascript file could not be copied to the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
}
} else {
if (!file_exists($realJsFile)) {
require dirname($realJsFile) . "/xajaxCompress.php";
$javaScript = implode('', file($srcFile));
$compressedScript = xajaxCompressJavascript($javaScript);
$fH = @fopen($realJsFile, "w");
if (!$fH) {
trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
} else {
fwrite($fH, $compressedScript);
fclose($fH);
}
}
}
$html .= "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
return $html;
}