BUG 0000 "Safe upgrade for JavaScript files of the plugins" SOLVED
- Safe upgrade for JavaScript files of the plugins's translations - Improved programming logic for this issue - Problem solved, has been added the code necessary for the plugins's translations * Available from version ProcessMaker-2.5.2-testing.1
This commit is contained in:
@@ -571,6 +571,14 @@ class Bootstrap
|
||||
*/
|
||||
public function streamFile($file, $download = false, $downloadFileName = '')
|
||||
{
|
||||
$fileNameIni = $file;
|
||||
|
||||
$browserCacheFilesUid = G::browserCacheFilesGetUid();
|
||||
|
||||
if ($browserCacheFilesUid != null) {
|
||||
$file = str_replace(".$browserCacheFilesUid", null, $file);
|
||||
}
|
||||
|
||||
$folderarray = explode('/', $file);
|
||||
$typearray = explode('.', basename($file));
|
||||
$typefile = $typearray[count($typearray) - 1];
|
||||
@@ -578,14 +586,7 @@ class Bootstrap
|
||||
|
||||
//trick to generate the translation.language.js file , merging two files
|
||||
if (strtolower($typefile) == 'js' && $typearray[0] == 'translation') {
|
||||
Bootstrap::sendHeaders($filename, 'text/javascript', $download, $downloadFileName);
|
||||
if ($typearray[1] != "enterprise" && $typearray[1] != "pmCaseArchive") {
|
||||
$arrayAux = array($typearray[0], $typearray[1], $typearray[count($typearray) - 1]);
|
||||
|
||||
$filename = str_replace(implode(".", $typearray), implode(".", $arrayAux), $filename);
|
||||
|
||||
$typearray = $arrayAux;
|
||||
}
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/javascript", $download, $downloadFileName);
|
||||
|
||||
$output = Bootstrap::streamJSTranslationFile($filename, $typearray[count($typearray) - 2]);
|
||||
|
||||
@@ -596,7 +597,7 @@ class Bootstrap
|
||||
|
||||
//trick to generate the big css file for ext style .
|
||||
if (strtolower($typefile) == 'css' && $folderarray[count($folderarray) - 2] == 'css') {
|
||||
Bootstrap::sendHeaders($filename, 'text/css', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/css", $download, $downloadFileName);
|
||||
$output = Bootstrap::streamCSSBigFile($typearray[0]);
|
||||
echo $output;
|
||||
return;
|
||||
@@ -605,59 +606,59 @@ class Bootstrap
|
||||
if (file_exists($filename)) {
|
||||
switch (strtolower($typefile)) {
|
||||
case 'swf':
|
||||
Bootstrap::sendHeaders($filename, 'application/x-shockwave-flash', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "application/x-shockwave-flash", $download, $downloadFileName);
|
||||
break;
|
||||
case 'js':
|
||||
Bootstrap::sendHeaders($filename, 'text/javascript', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/javascript", $download, $downloadFileName);
|
||||
break;
|
||||
case 'htm':
|
||||
case 'html':
|
||||
Bootstrap::sendHeaders($filename, 'text/html', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/html", $download, $downloadFileName);
|
||||
break;
|
||||
case 'htc':
|
||||
Bootstrap::sendHeaders($filename, 'text/plain', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/plain", $download, $downloadFileName);
|
||||
break;
|
||||
case 'json':
|
||||
Bootstrap::sendHeaders($filename, 'text/plain', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/plain", $download, $downloadFileName);
|
||||
break;
|
||||
case 'gif':
|
||||
Bootstrap::sendHeaders($filename, 'image/gif', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "image/gif", $download, $downloadFileName);
|
||||
break;
|
||||
case 'png':
|
||||
Bootstrap::sendHeaders($filename, 'image/png', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "image/png", $download, $downloadFileName);
|
||||
break;
|
||||
case 'jpg':
|
||||
Bootstrap::sendHeaders($filename, 'image/jpg', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "image/jpg", $download, $downloadFileName);
|
||||
break;
|
||||
case 'css':
|
||||
Bootstrap::sendHeaders($filename, 'text/css', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/css", $download, $downloadFileName);
|
||||
break;
|
||||
case 'xml':
|
||||
Bootstrap::sendHeaders($filename, 'text/xml', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/xml", $download, $downloadFileName);
|
||||
break;
|
||||
case 'txt':
|
||||
Bootstrap::sendHeaders($filename, 'text/html', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/html", $download, $downloadFileName);
|
||||
break;
|
||||
case 'doc':
|
||||
case 'pdf':
|
||||
case 'pm':
|
||||
case 'po':
|
||||
Bootstrap::sendHeaders($filename, 'application/octet-stream', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "application/octet-stream", $download, $downloadFileName);
|
||||
break;
|
||||
case 'php':
|
||||
if ($download) {
|
||||
Bootstrap::sendHeaders($filename, 'text/plain', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/plain", $download, $downloadFileName);
|
||||
} else {
|
||||
require_once ($filename);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 'tar':
|
||||
Bootstrap::sendHeaders($filename, 'application/x-tar', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "application/x-tar", $download, $downloadFileName);
|
||||
break;
|
||||
default:
|
||||
//throw new Exception ( "Unknown type of file '$file'. " );
|
||||
Bootstrap::sendHeaders($filename, 'application/octet-stream', $download, $downloadFileName);
|
||||
Bootstrap::sendHeaders($fileNameIni, "application/octet-stream", $download, $downloadFileName);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -672,6 +673,7 @@ class Bootstrap
|
||||
if (substr($filename, -10) == "ext-all.js") {
|
||||
$filename = PATH_GULLIVER_HOME . 'js/ext/min/ext-all.js';
|
||||
}
|
||||
|
||||
@readfile($filename);
|
||||
}
|
||||
|
||||
|
||||
@@ -5080,21 +5080,19 @@ class G
|
||||
$arrayLibrary = array();
|
||||
|
||||
//Translations /js/ext/translation.en.js
|
||||
$arrayLibrary["translation"] = ""; //Not use null
|
||||
//Translations /js/ext/translation.xxx.en.js //xxx is an plugin
|
||||
$arrayLibrary["translation"] = 1; //Not use null
|
||||
|
||||
//Translation environment /jscore/labels/en.js
|
||||
$translationEnvFilePath = PATH_DATA . "META-INF" . PATH_SEP . "translations.env";
|
||||
|
||||
if (file_exists($translationEnvFilePath)) {
|
||||
$arrayData = unserialize(file_get_contents($translationEnvFilePath));
|
||||
$path = PATH_CORE . "js" . PATH_SEP . "labels" . PATH_SEP;
|
||||
if (file_exists(PATH_DATA . "META-INF" . PATH_SEP . "translations.env")) {
|
||||
$arrayData = unserialize(file_get_contents(PATH_DATA . "META-INF" . PATH_SEP . "translations.env"));
|
||||
|
||||
foreach ($arrayData as $index1 => $value1) {
|
||||
foreach ($value1 as $index2 => $value2) {
|
||||
$record = $value2;
|
||||
|
||||
if (file_exists($path . $record["LOCALE"] . ".js")) {
|
||||
$arrayLibrary[$record["LOCALE"]] = $path;
|
||||
if (file_exists(PATH_CORE . "js" . PATH_SEP . "labels" . PATH_SEP . $record["LOCALE"] . ".js")) {
|
||||
$arrayLibrary[$record["LOCALE"]] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5111,7 +5109,7 @@ class G
|
||||
$lib->build_js_to = $lib->build_js_to . "/";
|
||||
}
|
||||
|
||||
$arrayLibrary[$lib->name] = PATH_TRUNK . $lib->build_js_to;
|
||||
$arrayLibrary[$lib->name] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5120,33 +5118,12 @@ class G
|
||||
|
||||
public static function browserCacheFilesSetUid()
|
||||
{
|
||||
//Set UID
|
||||
$uid = G::generateUniqueID();
|
||||
|
||||
$arrayData = array();
|
||||
$arrayData["browser_cache_files_uid"] = $uid;
|
||||
|
||||
G::update_php_ini(PATH_CONFIG . "env.ini", $arrayData);
|
||||
|
||||
//Set file JavaScript
|
||||
$arrayLibrary = G::browserCacheFilesGetLibraryJs();
|
||||
|
||||
foreach ($arrayLibrary as $index => $value) {
|
||||
$name = $index;
|
||||
$path = $value;
|
||||
|
||||
if (!empty($path)) {
|
||||
foreach (glob($path . $name . "*") as $file) {
|
||||
if (preg_match("/^\.\w{32}\.js$/i", str_replace($path . $name, null, $file))) {
|
||||
@unlink($file); //Delete old file
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($path . $name . ".js")) {
|
||||
@copy($path . $name . ".js", $path . $name . "." . $uid . ".js"); //Create new file
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function browserCacheFilesGetUid()
|
||||
@@ -5175,20 +5152,7 @@ class G
|
||||
$arrayLibrary = G::browserCacheFilesGetLibraryJs();
|
||||
|
||||
if (isset($arrayLibrary[$index])) {
|
||||
$path = $arrayLibrary[$index];
|
||||
$sw = 0;
|
||||
|
||||
if (!empty($path)) {
|
||||
if (file_exists($path . $arrayMatch[1] . "." . $browserCacheFilesUid . ".js")) {
|
||||
$sw = 1;
|
||||
}
|
||||
} else {
|
||||
$sw = 1;
|
||||
}
|
||||
|
||||
if ($sw == 1) {
|
||||
$url = str_replace($name, $arrayMatch[1] . "." . $browserCacheFilesUid . ".js", $url);
|
||||
}
|
||||
$url = str_replace($name, $arrayMatch[1] . "." . $browserCacheFilesUid . ".js", $url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,11 +214,9 @@ class headPublisher
|
||||
$head = '';
|
||||
$head .= '<TITLE>' . $this->title . "</TITLE>\n";
|
||||
|
||||
$browserCacheFilesUid = G::browserCacheFilesGetUid();
|
||||
|
||||
$head = $head . "
|
||||
<script type=\"text/javascript\">
|
||||
var BROWSER_CACHE_FILES_UID = \"" . (($browserCacheFilesUid != null && file_exists(PATH_TRUNK . "gulliver" . PATH_SEP . "js" . PATH_SEP . "maborak" . PATH_SEP . "core" . PATH_SEP . "maborak.$browserCacheFilesUid.js"))? $browserCacheFilesUid : null) . "\";
|
||||
var BROWSER_CACHE_FILES_UID = \"" . G::browserCacheFilesGetUid() . "\";
|
||||
</script>
|
||||
";
|
||||
|
||||
@@ -310,12 +308,14 @@ class headPublisher
|
||||
public function includeExtJs()
|
||||
{
|
||||
$this->clearScripts();
|
||||
$head = '';
|
||||
$head .= " <script type='text/javascript' src='/js/ext/ext-base.js'></script>\n";
|
||||
$head .= " <script type='text/javascript' src='/js/ext/ext-all.js'></script>\n";
|
||||
|
||||
$head = "";
|
||||
$head = $head . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/ext-base.js") . "\"></script>\n";
|
||||
$head = $head . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/ext-all.js") . "\"></script>\n";
|
||||
|
||||
$aux = explode('-', strtolower(SYS_LANG));
|
||||
if (($aux[0] != 'en') && file_exists(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'ext' . PATH_SEP . 'locale' . PATH_SEP . 'ext-lang-' . $aux[0] . '.js')) {
|
||||
$head .= " <script type='text/javascript' src='/js/ext/locale/ext-lang-" . $aux[0] . ".js'></script>\n";
|
||||
$head = $head . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/locale/ext-lang-" . $aux[0] . ".js") . "\"></script>\n";
|
||||
}
|
||||
|
||||
// enabled for particular use
|
||||
@@ -333,7 +333,7 @@ class headPublisher
|
||||
$head .= $this->getExtJsVariablesScript();
|
||||
$oServerConf = & serverConf::getSingleton();
|
||||
if ($oServerConf->isRtl(SYS_LANG)) {
|
||||
$head .= " <script type='text/javascript' src='/js/ext/extjs_rtl.js'></script>\n";
|
||||
$head = $head . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/extjs_rtl.js") . "\"></script>\n";
|
||||
}
|
||||
|
||||
return $head;
|
||||
@@ -374,7 +374,7 @@ class headPublisher
|
||||
$script = '';
|
||||
if (isset($this->extJsScript) && is_array($this->extJsScript)) {
|
||||
foreach ($this->extJsScript as $key => $file) {
|
||||
$script .= " <script type='text/javascript' src='" . $file . ".js'></script>\n";
|
||||
$script = $script . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl($file . ".js") . "\"></script>\n";
|
||||
}
|
||||
}
|
||||
return $script;
|
||||
@@ -410,7 +410,7 @@ class headPublisher
|
||||
$script = '';
|
||||
if (isset($this->extJsLibrary) && is_array($this->extJsLibrary)) {
|
||||
foreach ($this->extJsLibrary as $file) {
|
||||
$script .= " <script type='text/javascript' src='/js/ext/" . $file . ".js'></script>\n";
|
||||
$script = $script . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/" . $file . ".js") . "\"></script>\n";
|
||||
}
|
||||
}
|
||||
if (!in_array($this->translationsFile, $this->extJsLibrary)) {
|
||||
|
||||
@@ -138,8 +138,6 @@ try {
|
||||
$oStep = new Step();
|
||||
$sUidGrids = $oStep->lookingforUidGrids( $sPRO_UID, $sDYNAFORM );
|
||||
|
||||
$browserCacheFilesUid = G::browserCacheFilesGetUid();
|
||||
|
||||
$template->assign("URL_MABORAK_JS", G::browserCacheFilesUrl("/js/maborak/core/maborak.js"));
|
||||
$template->assign("URL_TRANSLATION_ENV_JS", G::browserCacheFilesUrl("/jscore/labels/" . SYS_LANG . ".js"));
|
||||
$template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]);
|
||||
|
||||
@@ -72,6 +72,7 @@ function transactionLog($transactionName){
|
||||
newrelic_name_transaction ($transactionName);
|
||||
}
|
||||
}
|
||||
|
||||
// Defining the PATH_SEP constant, he we are defining if the the path separator symbol will be '\\' or '/'
|
||||
define( 'PATH_SEP', '/' );
|
||||
|
||||
@@ -316,6 +317,15 @@ if (! defined( 'PATH_C' )) {
|
||||
define( 'PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/' );
|
||||
}
|
||||
|
||||
//Call Gulliver Classes
|
||||
Bootstrap::LoadThirdParty("smarty/libs", "Smarty.class");
|
||||
|
||||
//Loading the autoloader libraries feature
|
||||
spl_autoload_register(array("Bootstrap", "autoloadClass"));
|
||||
|
||||
Bootstrap::registerClass("G", PATH_GULLIVER . "class.g.php");
|
||||
Bootstrap::registerClass("System", PATH_HOME . "engine/classes/class.system.php");
|
||||
|
||||
// defining Virtual URLs
|
||||
$virtualURITable = array ();
|
||||
$virtualURITable['/plugin/(*)'] = 'plugin';
|
||||
@@ -405,6 +415,7 @@ if (Bootstrap::virtualURI( $_SERVER['REQUEST_URI'], $virtualURITable, $realPath
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
switch ($realPath) {
|
||||
case 'jsMethod':
|
||||
Bootstrap::parseURI( getenv( "REQUEST_URI" ) );
|
||||
@@ -421,6 +432,7 @@ if (Bootstrap::virtualURI( $_SERVER['REQUEST_URI'], $virtualURITable, $realPath
|
||||
die();
|
||||
break;
|
||||
default:
|
||||
//Process files loaded with tag head in HTML
|
||||
if (substr( $realPath, 0, 12 ) == 'rest-service') {
|
||||
$isRestRequest = true;
|
||||
} else {
|
||||
@@ -435,13 +447,6 @@ if (Bootstrap::virtualURI( $_SERVER['REQUEST_URI'], $virtualURITable, $realPath
|
||||
}
|
||||
} //virtual URI parser
|
||||
|
||||
// Call Gulliver Classes
|
||||
Bootstrap::LoadThirdParty( 'smarty/libs', 'Smarty.class' );
|
||||
//loading the autoloader libraries feature
|
||||
spl_autoload_register(array('Bootstrap', 'autoloadClass'));
|
||||
Bootstrap::registerClass('G', PATH_GULLIVER . "class.g.php");
|
||||
Bootstrap::registerClass('System', PATH_HOME . "engine/classes/class.system.php");
|
||||
|
||||
// the request correspond to valid php page, now parse the URI
|
||||
Bootstrap::parseURI( getenv( "REQUEST_URI" ), $isRestRequest );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user