From b3f57c2fd86bbce241112e123ff17d096ce28026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20Cesar=20Laura=20Avenda=C3=B1o?= Date: Thu, 2 Jun 2022 20:27:42 +0000 Subject: [PATCH] PMCORE-3846 --- gulliver/system/class.headPublisher.php | 45 +++------------ .../admin/settings/customCasesList.blade.php | 2 +- .../engine/methods/cases/casesListSetup.php | 26 +++++---- workflow/engine/methods/cases/viena_init.php | 57 +++++++------------ workflow/engine/skinEngine/skinEngine.php | 22 ++++--- 5 files changed, 52 insertions(+), 100 deletions(-) diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php index 152b278c4..03520af98 100644 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -1,29 +1,4 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Core\System; @@ -31,8 +6,6 @@ use ProcessMaker\Core\System; /** * Class headPublisher * - * @author David S. Callizaya S. - * @package gulliver.system * @access public */ class headPublisher @@ -417,7 +390,13 @@ class headPublisher return $script; } - public function getExtJsVariablesScript() + /** + * Build javascript section with declaration of variables + * + * @param string $declarationKeyword + * @return string + */ + public function getExtJsVariablesScript($declarationKeyword = 'var') { $script = ''; if (count($this->extVariable) > 0) { @@ -427,15 +406,7 @@ class headPublisher $value = $val['value']; $variablesValues = G::json_encode($value); $variablesValues = $this->stripCodeQuotes($variablesValues); - // var_dump($variablesValues); - // echo "
"; - $script .= " var $name = " . $variablesValues . ";\n"; - /* - if ($val ['type'] == 'number') - $script .= " var $name = $value;\n"; - else - $script .= " var $name = '$value';\n"; - */ + $script .= " $declarationKeyword $name = " . $variablesValues . ";\n"; } $script .= "\n"; } diff --git a/resources/views/admin/settings/customCasesList.blade.php b/resources/views/admin/settings/customCasesList.blade.php index 8865ba9d3..457097066 100644 --- a/resources/views/admin/settings/customCasesList.blade.php +++ b/resources/views/admin/settings/customCasesList.blade.php @@ -10,7 +10,7 @@ - {{ ScriptVariables::render() }} + {!! $oHeadPublisher->getExtJsVariablesScript('') !!}
diff --git a/workflow/engine/methods/cases/casesListSetup.php b/workflow/engine/methods/cases/casesListSetup.php index a87523cee..5753392f7 100644 --- a/workflow/engine/methods/cases/casesListSetup.php +++ b/workflow/engine/methods/cases/casesListSetup.php @@ -1,5 +1,5 @@ assignNumber("pageSize", 20); //sending the page size $oHeadPublisher->assignNumber("availableFields", G::json_encode($availableFields)); $userCanAccess = 1; - $pmDynaform = new PmDynaform(); -ScriptVariables::add('SYS_CREDENTIALS', base64_encode(G::json_encode($pmDynaform->getCredentials()))); -ScriptVariables::add('SYS_SERVER_API', System::getHttpServerHostnameRequestsFrontEnd()); -ScriptVariables::add('SYS_SERVER_AJAX', System::getServerProtocolHost()); -ScriptVariables::add('SYS_WORKSPACE', config("system.workspace")); -ScriptVariables::add('SYS_URI', SYS_URI); -ScriptVariables::add('SYS_LANG', SYS_LANG); -ScriptVariables::add('TRANSLATIONS', $translation); -ScriptVariables::add('FORMATS', $conf->getFormats()); -ScriptVariables::add('userId', User::getId($_SESSION['USER_LOGGED'])); -echo View::make('Views::admin.settings.customCasesList', compact("userCanAccess"))->render(); \ No newline at end of file + +$oHeadPublisher->assign('window.config', []); +$oHeadPublisher->assign('window.config.SYS_CREDENTIALS', base64_encode(G::json_encode($pmDynaform->getCredentials()))); +$oHeadPublisher->assign('window.config.SYS_SERVER_API', System::getHttpServerHostnameRequestsFrontEnd()); +$oHeadPublisher->assign('window.config.SYS_SERVER_AJAX', System::getServerProtocolHost()); +$oHeadPublisher->assign('window.config.SYS_WORKSPACE', config('system.workspace')); +$oHeadPublisher->assign('window.config.SYS_URI', SYS_URI); +$oHeadPublisher->assign('window.config.SYS_LANG', SYS_LANG); +$oHeadPublisher->assign('window.config.TRANSLATIONS', $translation); +$oHeadPublisher->assign('window.config.FORMATS', $conf->getFormats()); +$oHeadPublisher->assign('window.config.userId', User::getId($_SESSION['USER_LOGGED'])); + +echo View::make('Views::admin.settings.customCasesList', compact('userCanAccess', 'oHeadPublisher'))->render(); \ No newline at end of file diff --git a/workflow/engine/methods/cases/viena_init.php b/workflow/engine/methods/cases/viena_init.php index 202c6f918..65defd065 100644 --- a/workflow/engine/methods/cases/viena_init.php +++ b/workflow/engine/methods/cases/viena_init.php @@ -1,7 +1,5 @@ isRtl(SYS_LANG)) { - $regionTreePanel = 'east'; - $regionDebug = 'west'; -} else { - $regionTreePanel = 'west'; - $regionDebug = 'east'; -} - -$urlProxy = 'casesMenuLoader?action=getAllCounters&r='; -$oHeadPublisher->assign('regionTreePanel', $regionTreePanel); -$oHeadPublisher->assign('regionDebug', $regionDebug); -$oHeadPublisher->assign('openCaseIE', $openCaseIE); -$oHeadPublisher->assign("defaultOption", $defaultOption); //User menu permissions -$oHeadPublisher->assign('urlProxy', $urlProxy); //sending the urlProxy to make -$oHeadPublisher->assign("_nodeId", isset($confDefaultOption) ? $confDefaultOption : "PM_USERS"); //User menu permissions -$oHeadPublisher->assign("FORMATS", $conf->getFormats()); - -$userCanAccess = 1; global $translation; $pmDynaform = new PmDynaform(); -ScriptVariables::add('defaultOption', $defaultOption); -ScriptVariables::add('_nodeId', isset($confDefaultOption) ? $confDefaultOption : "PM_USERS"); -ScriptVariables::add('SYS_CREDENTIALS', base64_encode(G::json_encode($pmDynaform->getCredentials()))); -ScriptVariables::add('SYS_SERVER_API', System::getHttpServerHostnameRequestsFrontEnd()); -ScriptVariables::add('SYS_SERVER_AJAX', System::getServerProtocolHost()); -ScriptVariables::add('SYS_WORKSPACE', config("system.workspace")); -ScriptVariables::add('SYS_URI', SYS_URI); -ScriptVariables::add('SYS_LANG', SYS_LANG); -ScriptVariables::add('TRANSLATIONS', $translation); -ScriptVariables::add('FORMATS', $conf->getFormats()); -ScriptVariables::add('userId', User::getId($_SESSION['USER_LOGGED'])); -ScriptVariables::add('userConfig', array( - "usr_uid" => $_SESSION['USER_LOGGED'] -)); -G::RenderPage("publish", "viena"); \ No newline at end of file + +$oHeadPublisher = headPublisher::getSingleton(); +$oHeadPublisher->assign('window.config', []); +$oHeadPublisher->assign('window.config.defaultOption', $defaultOption); +$oHeadPublisher->assign('window.config._nodeId', isset($confDefaultOption) ? $confDefaultOption : 'PM_USERS'); +$oHeadPublisher->assign('window.config.SYS_CREDENTIALS', base64_encode(G::json_encode($pmDynaform->getCredentials()))); +$oHeadPublisher->assign('window.config.SYS_SERVER_API', System::getHttpServerHostnameRequestsFrontEnd()); +$oHeadPublisher->assign('window.config.SYS_SERVER_AJAX', System::getServerProtocolHost()); +$oHeadPublisher->assign('window.config.SYS_WORKSPACE', config('system.workspace')); +$oHeadPublisher->assign('window.config.SYS_URI', SYS_URI); +$oHeadPublisher->assign('window.config.SYS_LANG', SYS_LANG); +$oHeadPublisher->assign('window.config.TRANSLATIONS', $translation); +$oHeadPublisher->assign('window.config.FORMATS', $conf->getFormats()); +$oHeadPublisher->assign('window.config.userId', User::getId($_SESSION['USER_LOGGED'])); +$oHeadPublisher->assign('window.config.userConfig', [ + 'usr_uid' => $_SESSION['USER_LOGGED'] +]); + +G::RenderPage('publish', 'viena'); \ No newline at end of file diff --git a/workflow/engine/skinEngine/skinEngine.php b/workflow/engine/skinEngine/skinEngine.php index 986cfb2ed..1da6a140f 100644 --- a/workflow/engine/skinEngine/skinEngine.php +++ b/workflow/engine/skinEngine/skinEngine.php @@ -3,9 +3,6 @@ * Class SkinEngine * * This class load and dispatch the main systems layouts - * - * @author Erik Amaru Ortiz - * @author Hugo Loza */ use ProcessMaker\Core\System; @@ -334,16 +331,18 @@ class SkinEngine echo $template->getOutputContent(); } - - private function _viena() + + /** + * Render "viena" view + */ + private function _viena() { - $oHeadPublisher = headPublisher::getSingleton(); - $styles = ""; - $header = $oHeadPublisher->getExtJsVariablesScript(); - $header = $oHeadPublisher->getExtJsStylesheets($this->cssFileName . "-viena"); $templateFile = $this->layoutFile['dirname'] . PATH_SEP . $this->layoutFileViena['basename']; if (file_exists($templateFile)) { - $body = ScriptVariables::render(); + $oHeadPublisher = headPublisher::getSingleton(); + $header = $oHeadPublisher->getExtJsStylesheets($this->cssFileName . '-viena'); + $body = $oHeadPublisher->getExtJsVariablesScript(''); + $template = new TemplatePower($templateFile); $template->prepare(); $template->assign('header', $header); @@ -351,7 +350,7 @@ class SkinEngine echo $template->getOutputContent(); } else { $userCanAccess = 1; - echo View::make('Views::home.home', compact("userCanAccess"))->render(); + echo View::make('Views::home.home', compact('userCanAccess'))->render(); } } @@ -472,7 +471,6 @@ class SkinEngine if (!defined('NO_DISPLAY_USERNAME')) { define('NO_DISPLAY_USERNAME', 0); } - if (NO_DISPLAY_USERNAME == 0) { $smarty->assign('userfullname', isset($_SESSION['USR_FULLNAME']) ? $_SESSION['USR_FULLNAME'] : ''); $smarty->assign('user', isset($_SESSION['USR_USERNAME']) ? '(' . $_SESSION['USR_USERNAME'] . ')' : '');