=> * @param boolean $anonymized Determines if token data is being used or just replaced with blanks * @param questionNum - needed to support dynamic JavaScript-based tailoring within questions * @param bStaticReplacement - Default off, forces non-dynamic replacements without tags (e.g. for the Completed page) * @return string Text with replaced strings */ function templatereplace($line, $replacements = array(), &$redata = array(), $debugSrc = 'Unspecified', $anonymized = false, $questionNum = NULL, $registerdata = array(), $bStaticReplacement = false) { /* global $clienttoken,$token,$sitename,$move,$showxquestions,$showqnumcode,$questioncode; global $s_lang,$errormsg,$saved_id, $languagechanger,$captchapath,$loadname; */ /* $allowedvars = array('surveylist', 'sitename', 'clienttoken', 'rooturl', 'thissurvey', 'imageurl', 'defaulttemplate', 'percentcomplete', 'move', 'groupname', 'groupdescription', 'question', 'showxquestions', 'showgroupinfo', 'showqnumcode', 'questioncode', 'answer', 'navigator', 'help', 'totalquestions', 'surveyformat', 'completed', 'notanswered', 'privacy', 'surveyid', 'publicurl', 'templatedir', 'token', 'assessments', 's_lang', 'errormsg', 'clang', 'saved_id', 'usertemplaterootdir', 'languagechanger', 'printoutput', 'captchapath', 'loadname'); */ $allowedvars = array( 'answer', 'assessments', 'captchapath', 'clienttoken', 'completed', 'errormsg', 'groupdescription', 'groupname', 'help', 'imageurl', 'languagechanger', 'loadname', 'move', 'navigator', 'percentcomplete', 'privacy', 'question', 's_lang', 'saved_id', 'showgroupinfo', 'showqnumcode', 'showxquestions', 'sitename', 'surveylist', 'templatedir', 'thissurvey', 'token', 'totalBoilerplatequestions', 'totalquestions', ); $varsPassed = array(); foreach($allowedvars as $var) { if(isset($redata[$var])) { $$var = $redata[$var]; $varsPassed[] = $var; } } // if (count($varsPassed) > 0) { // log_message('debug', 'templatereplace() called from ' . $debugSrc . ' contains: ' . implode(', ', $varsPassed)); // } // if (isset($redata['question'])) { // LimeExpressionManager::ShowStackTrace('has QID and/or SGA',$allowedvars); // } // extract($redata); // creates variables for each of the keys in the array // Local over-rides in case not set above if (!isset($showgroupinfo)) { $showgroupinfo = Yii::app()->getConfig('showgroupinfo'); } if (!isset($showqnumcode)) { $showqnumcode = Yii::app()->getConfig('showqnumcode'); } $_surveyid = Yii::app()->getConfig('surveyID'); if (!isset($showxquestions)) { $showxquestions = Yii::app()->getConfig('showxquestions'); } if (!isset($s_lang)) { $s_lang = (isset(Yii::app()->session['survey_'.$_surveyid]['s_lang']) ? Yii::app()->session['survey_'.$_surveyid]['s_lang'] : 'en'); } if($_surveyid && !isset($thissurvey)) { $thissurvey=getSurveyInfo($_surveyid,$s_lang); } if (!isset($captchapath)) { $captchapath = ''; } if (!isset($sitename)) { $sitename=Yii::app()->getConfig('sitename'); } if (!isset($saved_id) && isset(Yii::app()->session['survey_'.$_surveyid]['srid'])) { $saved_id=Yii::app()->session['survey_'.$_surveyid]['srid'];} $clang = Yii::app()->lang; Yii::app()->loadHelper('surveytranslator'); if (isset($thissurvey['sid'])) { $surveyid = $thissurvey['sid']; } // lets sanitize the survey template if(isset($thissurvey['templatedir'])) { $templatename=$thissurvey['templatedir']; } else { $templatename=Yii::app()->getConfig('defaulttemplate'); } if(!isset($templatedir)) $templatedir = getTemplatePath($templatename); if(!isset($templateurl)) $templateurl = getTemplateURL($templatename)."/"; if (!$anonymized && isset($thissurvey['anonymized'])) { $anonymized=($thissurvey['anonymized']=="Y"); } // TEMPLATECSS $_templatecss=""; if(stripos ($line,"{TEMPLATECSS}")) { if (file_exists($templatedir .DIRECTORY_SEPARATOR.'jquery-ui-custom.css')) { Yii::app()->getClientScript()->registerCssFile("{$templateurl}jquery-ui-custom.css"); } elseif(file_exists($templatedir.DIRECTORY_SEPARATOR.'jquery-ui.css')) { Yii::app()->getClientScript()->registerCssFile("{$templateurl}jquery-ui.css"); } else { Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl')."jquery-ui.css"); } Yii::app()->getClientScript()->registerCssFile("{$templateurl}template.css"); if (getLanguageRTL($clang->langcode)) { Yii::app()->getClientScript()->registerCssFile("{$templateurl}template-rtl.css"); } } // surveyformat if (isset($thissurvey['format'])) { $surveyformat = str_replace(array("A", "S", "G"), array("allinone", "questionbyquestion", "groupbygroup"), $thissurvey['format']); } else { $surveyformat = ""; } if ((isset(Yii::app()->session['step']) && Yii::app()->session['step'] % 2) && $surveyformat!="allinone") { $surveyformat .= " page-odd"; } if (isset($thissurvey['questionindex']) && $thissurvey['questionindex'] > 0 && $surveyformat!="allinone" && (isset(Yii::app()->session['step']) && Yii::app()->session['step']>0)){ $surveyformat .= " withindex"; } if (isset($thissurvey['showprogress']) && $thissurvey['showprogress']=="Y"){ $surveyformat .= " showprogress"; } if (isset($thissurvey['showqnumcode'])){ $surveyformat .= " showqnumcode-".$thissurvey['showqnumcode']; } // real survey contact if (isset($surveylist) && isset($surveylist['contact'])) { $surveycontact = $surveylist['contact']; } elseif (isset($surveylist) && isset($thissurvey['admin']) && $thissurvey['admin']!="") { $surveycontact=sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$thissurvey['admin'],$thissurvey['adminemail']); } else { $surveycontact=""; } // If there are non-bracketed replacements to be made do so above this line. // Only continue in this routine if there are bracketed items to replace {} if (strpos($line, "{") === false) { // process string anyway so that it can be pretty-printed return LimeExpressionManager::ProcessString($line, $questionNum, NULL, false, 1, 1, true); } if ( $showgroupinfo == 'both' || $showgroupinfo == 'name' || ($showgroupinfo == 'choose' && !isset($thissurvey['showgroupinfo'])) || ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'B') || ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'N') ) { $_groupname = isset($groupname) ? $groupname : ''; } else { $_groupname = ''; }; if ( $showgroupinfo == 'both' || $showgroupinfo == 'description' || ($showgroupinfo == 'choose' && !isset($thissurvey['showgroupinfo'])) || ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'B') || ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'D') ) { $_groupdescription = isset($groupdescription) ? $groupdescription : ''; } else { $_groupdescription = ''; }; if (isset($question) && is_array($question)) { $_question = $question['all']; $_question_text = $question['text']; $_question_help = $question['help']; $_question_mandatory = $question['mandatory']; $_question_man_message = $question['man_message']; $_question_valid_message = $question['valid_message']; $_question_file_valid_message = $question['file_valid_message']; $question['sgq'] = (isset($question['sgq']) ? $question['sgq'] : ''); $_question_essentials = $question['essentials']; $_getQuestionClass = $question['class']; $_question_man_class = $question['man_class']; $_question_input_error_class = $question['input_error_class']; $_question_number = $question['number']; $_question_code = $question['code']; $_question_type = $question['type']; if($question['sgq']) // Not sure it can happen today ? But if set : allways sXgXq list($question['sid'],$question['gid'],$question['qid'])=explode("X",$question['sgq']); else list($question['sid'],$question['gid'],$question['qid'])=array('','',''); $question['aid']= (isset($question['aid']) ? $question['aid'] : ''); } else { $_question = isset($question) ? $question : ''; $_question_text = ''; $_question_help = ''; $_question_mandatory = ''; $_question_man_message = ''; $_question_valid_message = ''; $_question_file_valid_message = ''; $_question_essentials = ''; $_getQuestionClass = ''; $_question_man_class = ''; $_question_input_error_class = ''; $_question_number = ''; $_question_code = ''; $_question_type = ''; $question = array_fill_keys(array('sid','gid','qid','aid','sgq'), ''); }; if ($_question_type == '*') { $_question_text = '
' .$_question_text. '
'; } if (!( $showqnumcode == 'both' || $showqnumcode == 'number' || ($showqnumcode == 'choose' && !isset($thissurvey['showqnumcode'])) || ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B') || ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'N') )) { $_question_number = ''; }; if (!( $showqnumcode == 'both' || $showqnumcode == 'code' || ($showqnumcode == 'choose' && !isset($thissurvey['showqnumcode'])) || ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B') || ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'C') )) { $_question_code = ''; } if(!isset($totalquestions)) $totalquestions = 0; $_totalquestionsAsked = $totalquestions; if ( $showxquestions == 'show' || ($showxquestions == 'choose' && !isset($thissurvey['showxquestions'])) || ($showxquestions == 'choose' && $thissurvey['showxquestions'] == 'Y') ) { if ($_totalquestionsAsked < 1) { $_therearexquestions = $clang->gT("There are no questions in this survey"); // Singular } elseif ($_totalquestionsAsked == 1) { $_therearexquestions = $clang->gT("There is 1 question in this survey"); //Singular } else { $_therearexquestions = $clang->gT("There are {NUMBEROFQUESTIONS} questions in this survey."); //Note this line MUST be before {NUMBEROFQUESTIONS} }; } else { $_therearexquestions = ''; }; if (isset($token)) { $_token = $token; } elseif (isset($clienttoken)) { $_token = htmlentities($clienttoken, ENT_QUOTES, 'UTF-8'); // or should it be URL-encoded? } else { $_token = ''; } // Expiry if (isset($thissurvey['expiry'])) { $dateformatdetails=getDateFormatData($thissurvey['surveyls_dateformat']); Yii::import('application.libraries.Date_Time_Converter', true); $datetimeobj = new Date_Time_Converter($thissurvey['expiry'],"Y-m-d") ; $_dateoutput=$datetimeobj->convert($dateformatdetails['phpdate']); } else { $_dateoutput = '-'; } $_submitbutton = ""; if (isset($thissurvey['surveyls_url']) and $thissurvey['surveyls_url'] != "") { if (trim($thissurvey['surveyls_urldescription']) != '') { $_linkreplace = "{$thissurvey['surveyls_urldescription']}"; } else { $_linkreplace = "{$thissurvey['surveyls_url']}"; } } else { $_linkreplace=''; } if(isset($thissurvey['sid']) && isset($_SESSION['survey_'.$thissurvey['sid']]['srid']) && $thissurvey['active']=='Y') { $iscompleted=SurveyDynamic::model($surveyid)->isCompleted($_SESSION['survey_'.$thissurvey['sid']]['srid']); } else { $iscompleted=false; } if (isset($surveyid) && !$iscompleted) { $_clearall=CHtml::htmlButton($clang->gT("Exit and clear survey"),array('type'=>'submit','id'=>"clearall",'value'=>'clearall','name'=>'clearall','class'=>'clearall button','data-confirmedby'=>'confirm-clearall','title'=>$clang->gT("This action need confirmation."))); $_clearall.=CHtml::checkBox("confirm-clearall",false,array('id'=>'confirm-clearall','value'=>'confirm','class'=>'hide jshide')); $_clearall.=CHtml::label($clang->gT("Are you sure you want to clear all your responses?"),'confirm-clearall',array('class'=>'hide jshide')); } else { $_clearall = ""; } if (isset(Yii::app()->session['datestamp'])) { $_datestamp = Yii::app()->session['datestamp']; } else { $_datestamp = '-'; } if (isset($thissurvey['allowsave']) and $thissurvey['allowsave'] == "Y") { $_saveall = doHtmlSaveAll(isset($move)?$move:NULL); } else { $_saveall = ""; } if(!isset($help)) $help = ""; if (flattenText($help, true,true) != '') { if (!isset($helpicon)) { if (file_exists($templatedir . '/help.gif')) { $helpicon = $templateurl . 'help.gif'; } elseif (file_exists($templatedir . '/help.png')) { $helpicon = $templateurl . 'help.png'; } else { $helpicon=Yii::app()->getConfig('imageurl')."/help.gif"; } } $_questionhelp = "Help".$help; } else { $_questionhelp = $help; } if (isset($thissurvey['allowprev']) && $thissurvey['allowprev'] == "N") { $_strreview = ""; } else { $_strreview = $clang->gT("If you want to check any of the answers you have made, and/or change them, you can do that now by clicking on the [<< prev] button and browsing through your responses."); } if(isset($surveyid)) { $restartparam=array(); if($_token) $restartparam['token']=sanitize_token($_token);// urlencode with needed with sanitize_token if (Yii::app()->request->getQuery('lang')) $restartparam['lang']=sanitize_languagecode(Yii::app()->request->getQuery('lang')); elseif($s_lang) $restartparam['lang']=$s_lang; $restartparam['newtest']="Y"; $restarturl=Yii::app()->getController()->createUrl("survey/index/sid/$surveyid",$restartparam); $_restart = "".$clang->gT("Restart this Survey").""; } else { $_restart = ""; } if (isset($thissurvey['anonymized']) && $thissurvey['anonymized'] == 'Y') { $_savealert = $clang->gT("To remain anonymous please use a pseudonym as your username, also an email address is not required."); } else { $_savealert = ""; } if (isset($surveyid)) { if($_token) { $returnlink=Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}",array('token'=>sanitize_token($_token))); } else { $returnlink=Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}"); } $_return_to_survey = "".$clang->gT("Return to survey").""; } else { $_return_to_survey = ""; } // Save Form $_saveform = "\n"; } $_saveform .= "\n" . "\n" . "
::::gT("Security question") . ":
"; // Load Form $_loadform = "\n" . "\n"; if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && isCaptchaEnabled('saveandloadscreen', $thissurvey['usecaptcha'])) { $_loadform .="\n"; } $_loadform .="
:
:
:
\n"; // Registration Form if (isset($surveyid) || (isset($registerdata) && $debugSrc == 'register.php')) { if (isset($surveyid)) $tokensid = $surveyid; else $tokensid = $registerdata['sid']; $_registerform = CHtml::form(array("/register/index/surveyid/{$tokensid}"), 'post'); if (!isset($_REQUEST['lang'])) { $_reglang = Survey::model()->findByPk($tokensid)->language; } else { $_reglang = returnGlobal('lang'); } $_registerform .= "\n\n"; $_registerform .= "\n"; $_registerform.="\n" . "" . "\n" . "\n" . "'; } if ((count($registerdata) > 1 || isset($thissurvey['usecaptcha'])) && function_exists("ImageCreate") && isCaptchaEnabled('registrationscreen', $thissurvey['usecaptcha'])) { $_registerform .="\n"; } $_registerform .= "\n" . "
::: $attribute) { if (empty($attribute['show_register']) || $attribute['show_register'] != 'Y') continue; $_registerform .= '
:
:
" . "
\n"; if (count($registerdata) > 1 && $registerdata['sid'] != NULL && $debugSrc == 'register.php') { $_registerform .= ""; $_registerform .= ""; } $_registerform .= "\n"; } else { $_registerform = ""; } // Assessments $assessmenthtml=""; if (isset($surveyid) && !is_null($surveyid) && function_exists('doAssessment')) { $assessmentdata = doAssessment($surveyid, true); $_assessment_current_total = $assessmentdata['total']; if(stripos ($line,"{ASSESSMENTS}")){ $assessmenthtml=doAssessment($surveyid, false); } } else { $_assessment_current_total = ''; } if (isset($thissurvey['googleanalyticsapikey']) && trim($thissurvey['googleanalyticsapikey']) != '') { $_googleAnalyticsAPIKey = trim($thissurvey['googleanalyticsapikey']); } else { $_googleAnalyticsAPIKey = trim(getGlobalSetting('googleanalyticsapikey')); } $_googleAnalyticsStyle = (isset($thissurvey['googleanalyticsstyle']) ? $thissurvey['googleanalyticsstyle'] : '0'); $_googleAnalyticsJavaScript = ''; if ($_googleAnalyticsStyle != '' && $_googleAnalyticsStyle != 0 && $_googleAnalyticsAPIKey != '') { switch ($_googleAnalyticsStyle) { case '1': // Default Google Tracking $_googleAnalyticsJavaScript = << var _gaq = _gaq || []; _gaq.push(['_setAccount', '$_googleAnalyticsAPIKey']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); EOD; break; case '2': // SurveyName-[SID]/[GSEQ]-GroupName - create custom GSEQ based upon page step $moveInfo = LimeExpressionManager::GetLastMoveResult(); if (is_null($moveInfo)) { $gseq='welcome'; } else if ($moveInfo['finished']) { $gseq='finished'; } else if (isset($moveInfo['at_start']) && $moveInfo['at_start']) { $gseq='welcome'; } else if (is_null($_groupname)) { $gseq='printanswers'; } else { $gseq=$moveInfo['gseq']+1; } $_trackURL = htmlspecialchars($thissurvey['name'] . '-[' . $surveyid . ']/[' . $gseq . ']-' . $_groupname); $_googleAnalyticsJavaScript = << var _gaq = _gaq || []; _gaq.push(['_setAccount', '$_googleAnalyticsAPIKey']); _gaq.push(['_trackPageview','$_trackURL']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); EOD; break; } } $_endtext = ''; if (isset($thissurvey['surveyls_endtext']) && trim($thissurvey['surveyls_endtext'])!='') { $_endtext = $thissurvey['surveyls_endtext']; } if (isset($surveyid) && isset($_SESSION['survey_'.$surveyid]) && isset($_SESSION['survey_'.$surveyid]['register_errormsg'])) { $register_errormsg=$_SESSION['survey_'.$surveyid]['register_errormsg']; } // Set the array of replacement variables here - don't include curly braces $coreReplacements = array(); $coreReplacements['ACTIVE'] = (isset($thissurvey['active']) && !($thissurvey['active'] != "Y")); $coreReplacements['AID'] = $question['aid']; $coreReplacements['ANSWER'] = isset($answer) ? $answer : ''; // global $coreReplacements['ANSWERSCLEARED'] = $clang->gT("Answers cleared"); $coreReplacements['ASSESSMENTS'] = $assessmenthtml; $coreReplacements['ASSESSMENT_CURRENT_TOTAL'] = $_assessment_current_total; $coreReplacements['ASSESSMENT_HEADING'] = $clang->gT("Your assessment"); $coreReplacements['CHECKJAVASCRIPT'] = ""; $coreReplacements['CLEARALL'] = $_clearall; $coreReplacements['CLOSEWINDOW'] = "".$clang->gT("Close this window").""; $coreReplacements['COMPLETED'] = isset($redata['completed']) ? $redata['completed'] : ''; // global $coreReplacements['DATESTAMP'] = $_datestamp; $coreReplacements['ENDTEXT'] = $_endtext; $coreReplacements['EXPIRY'] = $_dateoutput; $coreReplacements['GID'] = ($question['gid']) ? $question['gid'] : Yii::app()->getConfig('gid','');// Use the gid of the question, except if we are not in question (Randomization group name) $coreReplacements['GOOGLE_ANALYTICS_API_KEY'] = $_googleAnalyticsAPIKey; $coreReplacements['GOOGLE_ANALYTICS_JAVASCRIPT'] = $_googleAnalyticsJavaScript; $coreReplacements['GROUPDESCRIPTION'] = $_groupdescription; $coreReplacements['GROUPNAME'] = $_groupname; $coreReplacements['LANG'] = $clang->getlangcode(); $coreReplacements['LANGUAGECHANGER'] = isset($languagechanger) ? $languagechanger : ''; // global $coreReplacements['LOADERROR'] = isset($errormsg) ? $errormsg : ''; // global $coreReplacements['LOADFORM'] = $_loadform; $coreReplacements['LOADHEADING'] = $clang->gT("Load a previously saved survey"); $coreReplacements['LOADMESSAGE'] = $clang->gT("You can load a survey that you have previously saved from this screen.")."
".$clang->gT("Type in the 'name' you used to save the survey, and the password.")."
"; $coreReplacements['NAVIGATOR'] = isset($navigator) ? $navigator : ''; // global $coreReplacements['NOSURVEYID'] = (isset($surveylist))?$surveylist['nosid']:''; $coreReplacements['NUMBEROFQUESTIONS'] = $_totalquestionsAsked; $coreReplacements['PERCENTCOMPLETE'] = isset($percentcomplete) ? $percentcomplete : ''; // global $coreReplacements['PRIVACY'] = isset($privacy) ? $privacy : ''; // global $coreReplacements['PRIVACYMESSAGE'] = "".$clang->gT("A Note On Privacy")."
".$clang->gT("This survey is anonymous.")."
".$clang->gT("The record of your survey responses does not contain any identifying information about you, unless a specific survey question explicitly asked for it.").' '.$clang->gT("If you used an identifying token to access this survey, please rest assured that this token will not be stored together with your responses. It is managed in a separate database and will only be updated to indicate whether you did (or did not) complete this survey. There is no way of matching identification tokens with survey responses."); $coreReplacements['QID'] = $question['qid']; $coreReplacements['QUESTION'] = $_question; $coreReplacements['QUESTIONHELP'] = $_questionhelp; $coreReplacements['QUESTIONHELPPLAINTEXT'] = strip_tags(addslashes($help)); // global $coreReplacements['QUESTION_CLASS'] = $_getQuestionClass; $coreReplacements['QUESTION_CODE'] = $_question_code; $coreReplacements['QUESTION_ESSENTIALS'] = $_question_essentials; $coreReplacements['QUESTION_FILE_VALID_MESSAGE'] = $_question_file_valid_message; $coreReplacements['QUESTION_HELP'] = $_question_help; $coreReplacements['QUESTION_INPUT_ERROR_CLASS'] = $_question_input_error_class; $coreReplacements['QUESTION_MANDATORY'] = $_question_mandatory; $coreReplacements['QUESTION_MAN_CLASS'] = $_question_man_class; $coreReplacements['QUESTION_MAN_MESSAGE'] = $_question_man_message; $coreReplacements['QUESTION_NUMBER'] = $_question_number; $coreReplacements['QUESTION_TEXT'] = $_question_text; $coreReplacements['QUESTION_VALID_MESSAGE'] = $_question_valid_message; $coreReplacements['REGISTERERROR'] = isset($register_errormsg) ? $register_errormsg : ''; // global $coreReplacements['REGISTERFORM'] = $_registerform; $coreReplacements['REGISTERMESSAGE1'] = $clang->gT("You must be registered to complete this survey"); $coreReplacements['REGISTERMESSAGE2'] = $clang->gT("You may register for this survey if you wish to take part.")."
\n".$clang->gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately."); $coreReplacements['RESTART'] = $_restart; $coreReplacements['RETURNTOSURVEY'] = $_return_to_survey; $coreReplacements['SAVE'] = $_saveall; $coreReplacements['SAVEALERT'] = $_savealert; $coreReplacements['SAVEDID'] = isset($saved_id) ? $saved_id : ''; // global $coreReplacements['SAVEERROR'] = isset($errormsg) ? $errormsg : ''; // global - same as LOADERROR $coreReplacements['SAVEFORM'] = $_saveform; $coreReplacements['SAVEHEADING'] = $clang->gT("Save your unfinished survey"); $coreReplacements['SAVEMESSAGE'] = $clang->gT("Enter a name and password for this survey and click save below.")."
\n".$clang->gT("Your survey will be saved using that name and password, and can be completed later by logging in with the same name and password.")."

\n".$clang->gT("If you give an email address, an email containing the details will be sent to you.")."

\n".$clang->gT("After having clicked the save button you can either close this browser window or continue filling out the survey."); $coreReplacements['SGQ'] = $question['sgq']; $coreReplacements['SID'] = Yii::app()->getConfig('surveyID','');// Allways use surveyID from config $coreReplacements['SITENAME'] = isset($sitename) ? $sitename : ''; // global $coreReplacements['SUBMITBUTTON'] = $_submitbutton; $coreReplacements['SUBMITCOMPLETE'] = "".$clang->gT("Thank you!")."

".$clang->gT("You have completed answering the questions in this survey.")."


".$clang->gT("Click on 'Submit' now to complete the process and save your answers."); $coreReplacements['SUBMITREVIEW'] = $_strreview; $coreReplacements['SURVEYCONTACT'] = $surveycontact; $coreReplacements['SURVEYDESCRIPTION'] = (isset($thissurvey['description']) ? $thissurvey['description'] : ''); $coreReplacements['SURVEYFORMAT'] = isset($surveyformat) ? $surveyformat : ''; // global $coreReplacements['SURVEYLANGAGE'] = $clang->langcode; $coreReplacements['SURVEYLANGUAGE'] = $clang->langcode; $coreReplacements['SURVEYLIST'] = (isset($surveylist))?$surveylist['list']:''; $coreReplacements['SURVEYLISTHEADING'] = (isset($surveylist))?$surveylist['listheading']:''; $coreReplacements['SURVEYNAME'] = (isset($thissurvey['name']) ? $thissurvey['name'] : ''); $coreReplacements['TEMPLATECSS'] = $_templatecss; $coreReplacements['TEMPLATEJS'] = CHtml::tag('script', array('type' => 'text/javascript', 'src' => $templateurl . 'template.js'), ''); $coreReplacements['TEMPLATEURL'] = $templateurl; $coreReplacements['THEREAREXQUESTIONS'] = $_therearexquestions; $coreReplacements['TOKEN'] = (!$anonymized ? $_token : '');// Silently replace TOKEN by empty string $coreReplacements['URL'] = $_linkreplace; $coreReplacements['WELCOME'] = (isset($thissurvey['welcome']) ? $thissurvey['welcome'] : ''); if (!is_null($replacements) && is_array($replacements)) { $doTheseReplacements = array_merge($coreReplacements, $replacements); // so $replacements overrides core values } else { $doTheseReplacements = $coreReplacements; } // Now do all of the replacements - In rare cases, need to do 3 deep recursion, that that is default $line = LimeExpressionManager::ProcessString($line, $questionNum, $doTheseReplacements, false, 3, 1, false, true, $bStaticReplacement); return $line; } // This function replaces field names in a text with the related values // (e.g. for email and template functions) function ReplaceFields ($text,$fieldsarray, $bReplaceInsertans=true, $staticReplace=true) { if ($bReplaceInsertans) { $replacements = array(); foreach ( $fieldsarray as $key => $value ) { $replacements[substr($key,1,-1)] = $value; } $text = LimeExpressionManager::ProcessString($text, NULL, $replacements, false, 2, 1, false, false, $staticReplace); } else { foreach ( $fieldsarray as $key => $value ) { $text=str_replace($key, $value, $text); } } return $text; } /** * passthruReplace() takes a string and looks for {PASSTHRU:myarg} variables * which it then substitutes for parameter data sent in the initial URL and stored * in the session array containing responses * * @param mixed $line string - the string to iterate, and then return * @param mixed $thissurvey string - the string containing the surveyinformation * @return string This string is returned containing the substituted responses * */ function PassthruReplace($line, $thissurvey) { while (strpos($line,"{PASSTHRU:") !== false) { $p1 = strpos($line,"{PASSTHRU:"); // startposition $p2 = $p1 + 10; // position of the first arg char $p3 = strpos($line,"}",$p1); // position of the last arg char $cmd=substr($line,$p1,$p3-$p1+1); // extract the complete passthru like "{PASSTHRU:myarg}" $arg=substr($line,$p2,$p3-$p2); // extract the arg to passthru (like "myarg") // lookup for the fitting arg $sValue=''; if (isset($_SESSION['survey_'.$thissurvey['sid']]['urlparams'][$arg])) { $sValue=urlencode($_SESSION['survey_'.$thissurvey['sid']]['urlparams'][$arg]); } $line=str_replace($cmd, $sValue, $line); // replace } return $line; } /** * doHtmlSaveAll return HTML part of saveall button in survey * @param string $move : * @return string **/ function doHtmlSaveAll($move="") { static $aSaveAllButtons=array(); if(isset($aSaveAllButtons[$move])) return $aSaveAllButtons[$move]; $surveyid=Yii::app()->getConfig('surveyID'); $thissurvey=getsurveyinfo($surveyid); $clang = Yii::app()->lang; $aHtmlOptionsLoadall=array('type'=>'submit','id'=>'loadallbtn','value'=>'loadall','name'=>'loadall','class'=>"saveall submit button"); $aHtmlOptionsSaveall=array('type'=>'submit','id'=>'saveallbtn','value'=>'saveall','name'=>'saveall','class'=>"saveall submit button"); if($thissurvey['active'] != "Y"){ $aHtmlOptionsLoadall['disabled']='disabled'; $aHtmlOptionsSaveall['disabled']='disabled'; } $sLoadButton=CHtml::htmlButton($clang->gT("Load unfinished survey"),$aHtmlOptionsLoadall); $sSaveButton=CHtml::htmlButton($clang->gT("Resume later"),$aHtmlOptionsSaveall); // Fill some test here, more clear .... $bTokenanswerspersistence=$thissurvey['tokenanswerspersistence'] == 'Y' && tableExists('tokens_'.$surveyid); $bAlreadySaved=isset($_SESSION['survey_'.$surveyid]['scid']); $iSessionStep=(isset($_SESSION['survey_'.$surveyid]['step'])? $_SESSION['survey_'.$surveyid]['step'] : false ); $iSessionMaxStep=(isset($_SESSION['survey_'.$surveyid]['maxstep'])? $_SESSION['survey_'.$surveyid]['maxstep'] : false ); $sSaveAllButtons=""; // Find out if the user has any saved data if ($thissurvey['format'] == 'A') { if ( !$bTokenanswerspersistence && !$bAlreadySaved ) { $sSaveAllButtons .= $sLoadButton; } $sSaveAllButtons .= CHtml::htmlButton($clang->gT("Resume later"),$aHtmlOptionsSaveall); } elseif (!$iSessionStep) //Welcome page, show load (but not save) { if (!$bTokenanswerspersistence && !$bAlreadySaved ) { $sSaveAllButtons .= $sLoadButton; } if($thissurvey['showwelcome']=="N") { $sSaveAllButtons .= $sSaveButton; } } elseif ($iSessionMaxStep==1 && $thissurvey['showwelcome']=="N")//First page, show LOAD and SAVE { if (!$bTokenanswerspersistence && !$bAlreadySaved ) { $sSaveAllButtons .= $sLoadButton; } $sSaveAllButtons .= $sSaveButton; } elseif ($move != "movelast") // Not on last page or submited survey { $sSaveAllButtons .= $sSaveButton; } $aSaveAllButtons[$move]=$sSaveAllButtons; return $aSaveAllButtons[$move]; } // Closing PHP tag intentionally omitted - yes, it is okay