Skip to content

Commit

Permalink
Fixed issue #13748: PHP Warning in register form
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Jun 11, 2018
1 parent dbfede2 commit 6a66606
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
3 changes: 2 additions & 1 deletion application/core/LSETwigViewRenderer.php
Expand Up @@ -40,7 +40,8 @@ public function renderTemplateFromFile($sLayout, $aDatas, $bReturn)
if ($oLayoutTemplate) {
$line = file_get_contents($oLayoutTemplate->viewPath.$sLayout);
$sHtml = $this->convertTwigToHtml($line, $aDatas, $oTemplate);
$sEmHiddenInputs = LimeExpressionManager::FinishProcessPublicPage();
LimeExpressionManager::ApplyEMJavaScriptToPage();
$sEmHiddenInputs = LimeExpressionManager::FinishProcessPublicPage(false);
if($sEmHiddenInputs) {
$sHtml = str_replace("<!-- emScriptsAndHiddenInputs -->","<!-- emScriptsAndHiddenInputs updated -->\n".$sEmHiddenInputs,$sHtml);
}
Expand Down
38 changes: 24 additions & 14 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -7230,28 +7230,38 @@ public static function FinishProcessingPage()
* @return string|null : hidden inputs needed for relevance
* @todo : add directly hidden input in page without return it.
*/
public static function FinishProcessPublicPage()
public static function FinishProcessPublicPage($applyJavaScript=false)
{
if(!self::isInitialized()) {
$oldLEM = unserialize($_SESSION['LEMsingleton']);
if($oldLEM){
self::StartProcessingPage($oldLEM->allOnOnePage, false);
if(self::isInitialized()) {
$LEM =& LimeExpressionManager::singleton();
/* Replace FinishProcessingGroup directly : always needed (in all in one too, and needed at end only (after all html are processed for Expression)) */
$LEM->pageTailorInfo[] = $LEM->em->GetCurrentSubstitutionInfo();
$LEM->pageRelevanceInfo[] = $LEM->groupRelevanceInfo;

if($applyJavaScript) {
self::ApplyEMJavaScriptToPage();
}

$aScriptsAndHiddenInputs = self::GetRelevanceAndTailoringJavaScript(true);
$sHiddenInputs = implode('', $aScriptsAndHiddenInputs['inputs']);
$LEM->FinishProcessingPage();
return $sHiddenInputs;
}
}

$LEM =& LimeExpressionManager::singleton();
/* Replace FinishProcessingGroup directly : always needed (in all in one too, and needed at end only (after all html are processed for Expression)) */
$LEM->pageTailorInfo[] = $LEM->em->GetCurrentSubstitutionInfo();
$LEM->pageRelevanceInfo[] = $LEM->groupRelevanceInfo;
$aScriptsAndHiddenInputs = self::GetRelevanceAndTailoringJavaScript(true);
/*
* Applies the EM relevance equations directly to the page
* @return void
*/
public static function ApplyEMJavaScriptToPage()
{
$aScriptsAndHiddenInputs = @self::GetRelevanceAndTailoringJavaScript(true);
$sScripts = implode('', $aScriptsAndHiddenInputs['scripts']);
Yii::app()->clientScript->registerScript('lemscripts', $sScripts, LSYii_ClientScript::POS_BEGIN);
$sHiddenInputs = implode('', $aScriptsAndHiddenInputs['inputs']);
Yii::app()->clientScript->registerScript('triggerEmRelevance', "triggerEmRelevance();", LSYii_ClientScript::POS_POSTSCRIPT);
Yii::app()->clientScript->registerScript('updateMandatoryErrorClass', "updateMandatoryErrorClass();", LSYii_ClientScript::POS_POSTSCRIPT); /* Maybe only if we have mandatory error ?*/
$LEM->FinishProcessingPage();
return $sHiddenInputs;
Yii::app()->clientScript->registerScript('updateMandatoryErrorClass', "updateMandatoryErrorClass();", LSYii_ClientScript::POS_POSTSCRIPT); /* Maybe only if we have mandatory error ?*/
}

/*
* Generate JavaScript needed to do dynamic relevance and tailoring
* Also create list of variables that need to be declared
Expand Down

1 comment on commit 6a66606

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if EM is not initialized : it means there are no question inside page : then no need javascript, then can send an empty EM function ?

Please sign in to comment.