BUG 0000 "Safe upgrade for JavaScript files" SOLVED
- New feature
- Safe upgrade for JavaScript files
- Added new feature,
- This new feature is activated when you run one of the following commands:
$ ./processmaker upgrade
$ ./processmaker build-js
$ ./processmaker browser-cache-files-upgrade
- The new feature creates an attribute in the file "processmaker/workflow/engine/config/env.ini"
Example:
browser_cache_files_uid = "xxxxxxxxxxyyyyyyyyyyzzzzzzzzzzaa"
- After running the command, the browser should automatically cache the new files
* Available from version ProcessMaker-2.5
This commit is contained in:
@@ -579,8 +579,13 @@ 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);
|
||||
$output = Bootstrap::streamJSTranslationFile($filename, $typearray[count($typearray)-2]);
|
||||
|
||||
$filename = str_replace(implode(".", $typearray), $typearray[0] . "." . $typearray[1] . "." . $typearray[count($typearray) - 1], $filename);
|
||||
|
||||
$output = Bootstrap::streamJSTranslationFile($filename, $typearray[1]);
|
||||
|
||||
echo $output;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4899,6 +4899,28 @@ class G
|
||||
{
|
||||
$arrayLibrary = array();
|
||||
|
||||
//Translations /js/ext/translation.en.js
|
||||
$arrayLibrary["translation"] = ""; //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;
|
||||
|
||||
foreach ($arrayData as $index1 => $value1) {
|
||||
foreach ($value1 as $index2 => $value2) {
|
||||
$record = $value2;
|
||||
|
||||
if (file_exists($path . $record["LOCALE"] . ".js")) {
|
||||
$arrayLibrary[$record["LOCALE"]] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Libraries
|
||||
$library = G::json_decode(file_get_contents(PATH_HOME . "engine" . PATH_SEP . "bin" . PATH_SEP . "tasks" . PATH_SEP . "libraries.json"));
|
||||
|
||||
foreach ($library as $index => $value) {
|
||||
@@ -4933,13 +4955,17 @@ class G
|
||||
$name = $index;
|
||||
$path = $value;
|
||||
|
||||
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 (!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
|
||||
}
|
||||
}
|
||||
|
||||
@copy($path . $name . ".js", $path . $name . "." . $uid . ".js"); //Create new file
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4959,15 +4985,28 @@ class G
|
||||
$n = count($arrayAux);
|
||||
|
||||
if ($n > 0 && !empty($arrayAux[$n - 1])) {
|
||||
$name = $arrayAux[$n - 1];
|
||||
$arrayAux = explode("?", $arrayAux[$n - 1]);
|
||||
$name = $arrayAux[0];
|
||||
|
||||
if (preg_match("/^(.*)\.js$/i", $name, $arrayMatch)) {
|
||||
$index = $arrayMatch[1];
|
||||
$index = (preg_match("/^translation\..*$/", $index))? "translation" : $index;
|
||||
|
||||
$arrayLibrary = G::browserCacheFilesGetLibraryJs();
|
||||
|
||||
if (isset($arrayLibrary[$arrayMatch[1]])) {
|
||||
$path = $arrayLibrary[$arrayMatch[1]];
|
||||
if (isset($arrayLibrary[$index])) {
|
||||
$path = $arrayLibrary[$index];
|
||||
$sw = 0;
|
||||
|
||||
if (file_exists($path . $arrayMatch[1] . "." . $browserCacheFilesUid . ".js")) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ class headPublisher
|
||||
}
|
||||
|
||||
if (!in_array($this->translationsFile, $this->scriptFiles)) {
|
||||
$head .= "<script type='text/javascript' src='" . $this->translationsFile . "'></script>\n";
|
||||
$head = $head . "<script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl($this->translationsFile) . "\"></script>\n";
|
||||
}
|
||||
|
||||
$head .= "<script type='text/javascript'>\n";
|
||||
@@ -321,7 +321,7 @@ class headPublisher
|
||||
$head .= $this->getExtJsLibraries();
|
||||
|
||||
// $head .= " <script type='text/javascript' src='/js/ext/draw2d.js'></script>\n";
|
||||
// $head .= " <script type='text/javascript' src='/js/ext/translation." . SYS_LANG . ".js'></script>\n";
|
||||
// $head .= " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/translation." . SYS_LANG . ".js") . "\"></script>\n";
|
||||
|
||||
if (!isset($this->extJsSkin) || $this->extJsSkin == '') {
|
||||
$this->extJsSkin = 'xtheme-gray';
|
||||
@@ -341,7 +341,7 @@ class headPublisher
|
||||
public function getExtJsStylesheets($skinName)
|
||||
{
|
||||
$script = " <link rel='stylesheet' type='text/css' href='/css/$skinName.css' />\n";
|
||||
//$script .= " <script type='text/javascript' src='/js/ext/translation." . SYS_LANG . ".js'></script>\n";
|
||||
//$script .= " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/translation." . SYS_LANG . ".js") . "\"></script>\n";
|
||||
/*
|
||||
$script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/ext-all-notheme.css' />\n";
|
||||
$script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/" . $this->extJsSkin.".css' />\n";
|
||||
@@ -413,7 +413,7 @@ class headPublisher
|
||||
}
|
||||
}
|
||||
if (!in_array($this->translationsFile, $this->extJsLibrary)) {
|
||||
$script .= " <script type='text/javascript' src='" . $this->translationsFile . "'></script>\n";
|
||||
$script = $script . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl($this->translationsFile) . "\"></script>\n";
|
||||
}
|
||||
return $script;
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ class Installer extends Controller
|
||||
{
|
||||
$pathSharedPartner = trim( $_REQUEST['pathShared'] );
|
||||
if (file_exists($pathSharedPartner.'partner.info')) {
|
||||
$_REQUEST['PARTNER_FLAG'] = true;
|
||||
$_REQUEST["PARTNER_FLAG"] = true;
|
||||
}
|
||||
$this->setResponseType( 'json' );
|
||||
if ($_REQUEST['db_engine'] == 'mysql') {
|
||||
@@ -382,13 +382,13 @@ class Installer extends Controller
|
||||
public function forceTogenerateTranslationsFiles ($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, (isset( $_SERVER['HTTPS'] ) ? ($_SERVER['HTTPS'] != '' ? 'https://' : 'http://') : 'http://') . $_SERVER['HTTP_HOST'] . '/js/ext/translation.en.js?r=' . rand( 1, 10000 ) );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_FRESH_CONNECT, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 20 );
|
||||
curl_exec( $ch );
|
||||
curl_close( $ch );
|
||||
curl_setopt($ch, CURLOPT_URL, G::browserCacheFilesUrl((isset($_SERVER["HTTPS"])? (($_SERVER["HTTPS"] != "")? "https://" : "http://") : "http://") . $_SERVER["HTTP_HOST"] . "/js/ext/translation.en.js?r=" . rand(1, 10000)));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -277,10 +277,11 @@ class Main extends Controller
|
||||
$this->setVar( 'advise_text', $adviseText );
|
||||
$loginScript = $this->getHeadPublisher()->getExtJsLibraries();
|
||||
$loginScript .= $this->getHeadPublisher()->getExtJsScripts();
|
||||
$this->setVar( 'login_script', $loginScript );
|
||||
$this->setVar( 'login_vars', $this->getHeadPublisher()->getExtJsVariablesScript() );
|
||||
$this->setVar("login_script", $loginScript);
|
||||
$this->setVar("login_vars", $this->getHeadPublisher()->getExtJsVariablesScript());
|
||||
$this->setVar("URL_TRANSLATION_JS", G::browserCacheFilesUrl("/js/ext/translation.en.js"));
|
||||
|
||||
$this->setLayout( 'pm-modern-login' );
|
||||
$this->setLayout("pm-modern-login");
|
||||
|
||||
$this->render();
|
||||
}
|
||||
@@ -342,10 +343,11 @@ class Main extends Controller
|
||||
|
||||
$loginScript = $this->getHeadPublisher()->getExtJsLibraries();
|
||||
$loginScript .= $this->getHeadPublisher()->getExtJsScripts();
|
||||
$this->setVar( 'login_script', $loginScript );
|
||||
$this->setVar( 'login_vars', $this->getHeadPublisher()->getExtJsVariablesScript() );
|
||||
$this->setVar("login_script", $loginScript);
|
||||
$this->setVar("login_vars", $this->getHeadPublisher()->getExtJsVariablesScript());
|
||||
$this->setVar("URL_TRANSLATION_JS", G::browserCacheFilesUrl("/js/ext/translation.en.js"));
|
||||
|
||||
$this->setLayout( 'pm-modern-login' );
|
||||
$this->setLayout("pm-modern-login");
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
@@ -141,6 +141,7 @@ try {
|
||||
$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"]);
|
||||
$template->assign("sysSys", SYS_SYS);
|
||||
$template->assign("sysLang", SYS_LANG);
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<script type="text/javascript">document.getElementById('loading-message').innerHTML = 'Loading Components...';</script>
|
||||
<script type='text/javascript' src='/js/ext/ext-all.js'></script>
|
||||
<script type="text/javascript">document.getElementById('loading-message').innerHTML = 'Initializing...';</script>
|
||||
<script type='text/javascript' src='/js/ext/translation.en.js'></script>
|
||||
<script type="text/javascript" src="{$URL_TRANSLATION_JS}"></script>
|
||||
{$login_script}
|
||||
{$login_vars}
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="{siteUrl}/jscore/labels/{sysLang}.js"></script>
|
||||
<script type="text/javascript" src="{siteUrl}{URL_TRANSLATION_ENV_JS}"></script>
|
||||
<script type="text/javascript" src="{siteUrl}{URL_MABORAK_JS}"></script>
|
||||
<script type="text/javascript" src="{siteUrl}/js/jscalendar/lang/calendar-{sysLang}.js"></script>
|
||||
<script type="text/javascript" src="{siteUrl}/jsform/gulliver/dynaforms_Options.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user