diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index faf3f4a2f24..50e818108a8 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -6548,33 +6548,17 @@ function getLabelInputWidth($labelAttributeWidth,$inputAttributeWidth){ * If the Survey template is configured to overwrite the question views, then the function will check if the required view exist in the template directory * and then will use this one to render the question. * + * Rem: all the logic has been moved to LSETwigViewRenderer::renderFile() + * We keep the function doRender here, to add the first parameter Yii::app()->getController() + * It can't be done in LSETwigViewRenderer because it implements IViewRenderer which force the signature of renderFile + * + * TODO: replace the 162 occurences of doRender([sView], $aData, [bReturn]) by App()->twigRenderer->renderFile( Yii::app()->getController(), [sView], $aData, [bReturn]); + * * @param string $sView name of the view to be rendered. * @param array $aData data to be extracted into PHP variables and made available to the view script * @param boolean $bReturn whether the rendering result should be returned instead of being displayed to end users (should be always true) */ function doRender($sView, $aData, $bReturn=true) { - global $thissurvey; - $requiredView = Yii::getPathOfAlias('application.views').$sView; - if(isset($thissurvey['template'])) - { - $sTemplate = $thissurvey['template']; - $oTemplate = Template::model()->getInstance($sTemplate); // we get the template configuration - if($oTemplate->overwrite_question_views===true && Yii::app()->getConfig('allow_templates_to_overwrite_views')) // If it's configured to overwrite the views - { - $requiredView = $oTemplate->viewPath.ltrim($sView, '/'); // Then we check if it has its own version of the required view - if( file_exists($requiredView.'.php') ) // If it the case, the function will render this view - { - Yii::setPathOfAlias('survey.template.view', $requiredView); // to render a view from an absolute path outside of application/, path alias must be used. - $sView = 'survey.template.view'; // See : http://www.yiiframework.com/doc/api/1.1/CController#getViewFile-detail - } - } - } - - // Twig or not twig? - if( file_exists($requiredView.'.twig') ){ - return Yii::app()->twigRenderer->renderFile( Yii::app()->getController(), $requiredView.'.twig', $aData, $bReturn); - }else{ - return Yii::app()->getController()->renderPartial($sView, $aData, $bReturn); - } + return Yii::app()->twigRenderer->renderFile( Yii::app()->getController(), $sView, $aData, $bReturn); }