diff --git a/application/controllers/admin/printablesurvey.php b/application/controllers/admin/printablesurvey.php index 56b362014ef..badad2f9dea 100644 --- a/application/controllers/admin/printablesurvey.php +++ b/application/controllers/admin/printablesurvey.php @@ -39,6 +39,8 @@ function index($surveyid, $lang = null) } else { + /* Remove admin css and js */ + Yii::app()->clientScript->reset(); $aSurveyInfo=getSurveyInfo($surveyid,$lang); if (!($aSurveyInfo)) $this->getController()->error('Invalid survey ID'); @@ -95,11 +97,24 @@ function index($surveyid, $lang = null) } $sFullTemplatePath = $oTemplate->path . DIRECTORY_SEPARATOR; $sFullTemplateUrl = Template::model()->getTemplateURL($templatename)."/"; + define('PRINT_TEMPLATE_DIR' , $sFullTemplatePath , true); define('PRINT_TEMPLATE_URL' , $sFullTemplateUrl , true); LimeExpressionManager::StartSurvey($surveyid, 'survey',NULL,false,LEM_PRETTY_PRINT_ALL_SYNTAX); $moveResult = LimeExpressionManager::NavigateForwards(); + Yii::app()->clientScript->reset();// Remove all scripts + /* Add css */ + Yii::app()->getClientScript()->registerCssFile(App()->getConfig('publicstyleurl')."/printable.css"); + if(getLanguageRTL(App()->language)){ + $aCssFiles=isset($oTemplate->config->files->rtl->print_css->filename) ? (array) $oTemplate->config->files->rtl->print_css->filename : array(); + }else{ + $aCssFiles=isset($oTemplate->config->files->print_css->filename) ? (array) $oTemplate->config->files->print_css->filename : array(); + } + + foreach($aCssFiles as $cssFile){ + Yii::app()->getClientScript()->registerCssFile("{$sFullTemplateUrl}{$cssFile}"); + } $condition = "sid = '{$surveyid}' AND language = '{$sLanguageCode}'"; $degresult = QuestionGroup::model()->getAllGroups($condition, array('group_order')); //xiao, @@ -198,7 +213,7 @@ function index($surveyid, $lang = null) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // START doing questions - $qidattributes=getQuestionAttributeValues($deqrow['qid'],$deqrow['type']); + $qidattributes=QuestionAttribute::model()->getQuestionAttributes($deqrow['qid']); if ($qidattributes['hidden'] == 1 && $deqrow['type'] != '*') { continue; @@ -220,11 +235,11 @@ function index($surveyid, $lang = null) { if( $s == 0 && count($scenarioresult) > 1) { - $sExplanation .= '

'." -------- Scenario {$scenariorow['scenario']} --------

\n\n"; + $sExplanation .= '
'." -------- Scenario {$scenariorow['scenario']} --------
\n\n"; } if($s > 0) { - $sExplanation .= '

'.' -------- '.gT("or")." Scenario {$scenariorow['scenario']} --------

\n\n"; + $sExplanation .= '
'.' -------- '.gT("or")." Scenario {$scenariorow['scenario']} --------
\n\n"; } $x=0; @@ -551,10 +566,10 @@ function index($surveyid, $lang = null) $sExplanation=$sEquation; $sEquation=' '; // No need to show it twice } - $sExplanation = "".gT('Only answer this question if the following conditions are met:')."
".$sExplanation; + $sExplanation = "
".gT('Only answer this question if the following conditions are met:')."
".$sExplanation; if (Yii::app()->getConfig('showrelevance')) { - $sExplanation.="
".$sEquation."
"; + $sExplanation.="
".$sEquation."
"; } } else @@ -584,7 +599,7 @@ function index($surveyid, $lang = null) ,'QUESTION_SCENARIO' => $sExplanation // if there are conditions on a question, list the conditions. ,'QUESTION_MANDATORY' => '' // translated 'mandatory' identifier ,'QUESTION_ID' => $deqrow['qid'] // id to be added to wrapping question div - ,'QUESTION_CLASS' => getQuestionClass( $deqrow['type']) // classes to be added to wrapping question div + ,'QUESTION_CLASS' => Question::getQuestionClass( $deqrow['type']) // classes to be added to wrapping question div ,'QUESTION_TYPE_HELP' => $qinfo['validTip'] // '' // instructions on how to complete the question // prettyValidTip is too verbose; assuming printable surveys will use static values ,'QUESTION_MAN_MESSAGE' => '' // (not sure if this is used) mandatory error ,'QUESTION_VALID_MESSAGE' => '' // (not sure if this is used) validation error @@ -592,7 +607,14 @@ function index($surveyid, $lang = null) ,'QUESTIONHELP' => '' // content of the question help field. ,'ANSWER' => '' // contains formatted HTML answer ); - + if(trim($question['QUESTION_TYPE_HELP'])!=""){ + $question['QUESTION_TYPE_HELP']=CHtml::tag("div",array("class"=>"tip-help"),$question['QUESTION_TYPE_HELP']); + } + if(isset($aQuestionAttributes['cssclass']) && $aQuestionAttributes['cssclass']!=""){ + $attributeClass=trim(LimeExpressionManager::ProcessString($aQuestionAttributes['cssclass'], null, array(), false, 1, 1, false, false, true)); + $question['QUESTION_CLASS'].=" ".Chtml::encode($attributeClass); + } + /* This must have some option specific for print : think we need to always send QUESTION_CODE */ $showqnumcode = Yii::app()->getConfig('showqnumcode'); if(($showqnumcode=='choose' && ($aSurveyInfo['showqnumcode']=='N' || $aSurveyInfo['showqnumcode']=='X')) || $showqnumcode=='number' || $showqnumcode=='none') { @@ -603,13 +625,9 @@ function index($surveyid, $lang = null) $question['QUESTION_NUMBER']=''; } - if($question['QUESTION_TYPE_HELP'] != "") { - $question['QUESTION_TYPE_HELP'] .= "
\n"; - } - if ($deqrow['mandatory'] == 'Y') { - $question['QUESTION_MANDATORY'] = gT('*'); + $question['QUESTION_MANDATORY'] = gT('*'); // Must add a real string here ! $question['QUESTION_CLASS'] .= ' mandatory'; } @@ -635,8 +653,8 @@ function index($surveyid, $lang = null) { // ================================================================== case "5": //5 POINT CHOICE - $question['QUESTION_TYPE_HELP'] .= gT('Please choose *only one* of the following:'); - $question['ANSWER'] .= "\n\t