public function actionPublicList($lang = null)
 {
     if (!empty($lang)) {
         App()->setLanguage($lang);
     } else {
         App()->setLanguage(App()->getConfig('defaultlang'));
     }
     $oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
     if ($oTemplate->cssFramework == 'bootstrap') {
         // We now use the bootstrap package isntead of the Yiistrap TbApi::register() method
         // Then instead of using the composer dependency system for templates
         // We can use the package dependency system
         Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport');
         App()->bootstrap->registerAllScripts();
     }
     $aData = array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll());
     $htmlOut = $this->render('publicSurveyList', $aData, true);
     $event = new PluginEvent('beforeSurveysStartpageRender', $this);
     $event->set('aData', $aData);
     App()->getPluginManager()->dispatchEvent($event);
     if ($event->get('result')) {
         $htmlFromEvent = $event->get('result');
         $htmlOut = $htmlFromEvent['html'];
     }
     echo $htmlOut;
 }
Example #2
0
 function showsaveform()
 {
     //Show 'SAVE FORM' only when click the 'Save so far' button the first time, or when duplicate is found on SAVE FORM.
     global $errormsg, $thissurvey, $surveyid, $clienttoken, $thisstep;
     $redata = compact(array_keys(get_defined_vars()));
     $sTemplatePath = $_SESSION['survey_' . $surveyid]['templatepath'];
     sendCacheHeaders();
     doHeader();
     $oTemplate = Template::model()->getInstance(null, $surveyid);
     echo templatereplace(file_get_contents($oTemplate->viewPath . "startpage.pstpl"), array(), $redata);
     echo "\n\n<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->\n" . "\t<script type='text/javascript'>\n" . "\t<!--\n" . "function checkconditions(value, name, type, evt_type)\n" . "\t{\n" . "\t}\n" . "\t//-->\n" . "\t</script>\n\n";
     echo CHtml::form(array("/survey/index", "sid" => $surveyid), 'post') . "\n";
     //PRESENT OPTIONS SCREEN
     if (isset($errormsg) && $errormsg != "") {
         $errormsg .= "<p>" . gT("Please try again.") . "</p>";
     }
     echo templatereplace(file_get_contents($oTemplate->viewPath . "save.pstpl"), array(), $redata);
     //END
     echo "<input type='hidden' name='thisstep' value='{$thisstep}' />\n";
     echo CHtml::hiddenField('token', $clienttoken) . "\n";
     echo "<input type='hidden' name='saveprompt' value='Y' />\n";
     echo "</form>";
     echo templatereplace(file_get_contents($oTemplate->viewPath . "endpage.pstpl"), array(), $redata);
     echo "</html>\n";
     exit;
 }
Example #3
0
 function viewAction()
 {
     $clearArray = array('flags');
     $this->filter($clearArray);
     if (empty($this->params)) {
         $today = date("d.m.Y");
         $this->params['dates'] = $today . '-' . $today;
     }
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     $models = AFActiveDataProvider::models('ProspectEmail', $this->params, $pagination);
     $dataProvider = $models->getAll();
     $filterFields = $models->getoutFilterFields($clearArray, array('dates'));
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_table', array('application', 'views', 'emails'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields));
         die;
     }
     $campaigns = Campaign::model()->cache()->findAllInArray();
     $templates = Template::model()->cache()->findAllInArray();
     $flags = ProspectEmail::getEmailFlags();
     /*
     $campaignsFilter = $models->getFilterCampaigns();
     $templatesFilter = $models->getFilterTemplates();
     $flagsFilter = $models->getFilterFlags();
     */
     Assets::css('jquery-ui');
     Assets::js('jquery-ui');
     Assets::js('dateRange/jquery.daterange');
     Assets::js('ajax_table');
     Assets::js('af_input_field');
     $this->addToPageTitle(__('prospect_emails'));
     $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields, 'campaigns' => $campaigns, 'templates' => $templates, 'flags' => $flags));
 }
Example #4
0
 function updateAction()
 {
     $model = new Event();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['model']) && $_POST['model'] == 'Event') {
         if (isset($_POST['ajax'])) {
             $model->fillFromArray($_POST, FALSE);
             $model->user_id_updated = $this->user->user_id;
             $model->updated = 'NOW():sql';
             $model->model_uset_id = $this->user->user_id;
             if ($model->save()) {
                 Message::echoJsonSuccess(__('events_updated'));
             } else {
                 Message::echoJsonError(__('events_not_updated') . ' ' . $model->errors2string);
             }
             die;
         }
         $model->save();
         $this->redirect();
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $templates = Template::model()->cache()->findAllInArray();
     $smtps = Smtp::model()->cache()->findAllInArray();
     Assets::js('jquery.form');
     $this->addToPageTitle('Update event');
     $this->render('update', array('model' => $model, 'smtps' => $smtps, 'templates' => $templates));
 }
 protected function defaultAttributes()
 {
     $attr = parent::defaultAttributes();
     $findParams = \GO\Base\Db\FindParams::newInstance()->limit(1);
     $stmt = Template::model()->find($findParams);
     if ($template = $stmt->fetch()) {
         $attr['template_id'] = $template->id;
     }
     return $attr;
 }
 public function actionPublicList($lang = null)
 {
     if (!empty($lang)) {
         App()->setLanguage($lang);
     } else {
         App()->setLanguage(App()->getConfig('defaultlang'));
     }
     $oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
     if ($oTemplate->cssFramework == 'bootstrap') {
         App()->bootstrap->register();
     }
     $this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
 }
 private function _renderHtml($html, $thistpl, $aSurveyInfo)
 {
     sendCacheHeaders();
     doHeader();
     $aSupportData = array('thissurvey' => $aSurveyInfo);
     $oTemplate = Template::model()->getInstance();
     $sTemplatePath = $oTemplate->path;
     $thistpl = $oTemplate->viewPath;
     echo templatereplace(file_get_contents($thistpl . 'startpage.pstpl'), array(), $aSupportData);
     $aData['html'] = $html;
     $aData['thistpl'] = $thistpl;
     $this->render('/opt_view', $aData);
     echo templatereplace(file_get_contents($thistpl . 'endpage.pstpl'), array(), $aSupportData);
     doFooter();
 }
 /**
  * Initialises this controller, does some basic checks and setups
  *
  * @access protected
  * @return void
  */
 protected function _init()
 {
     parent::_init();
     App()->getComponent('bootstrap');
     $this->_sessioncontrol();
     define('ADMIN_SCRIPT_PATH', realpath(Yii::app()->basePath . '/../scripts/admin/') . '/');
     define('SCRIPT_PATH', realpath(Yii::app()->basePath . '/../scripts/') . '/');
     App()->getClientScript()->registerScriptFile(App()->getAssetManager()->publish(ADMIN_SCRIPT_PATH . '/admin_core.js'));
     $this->user_id = Yii::app()->user->getId();
     if (!Yii::app()->getConfig("surveyid")) {
         Yii::app()->setConfig("surveyid", returnGlobal('sid'));
     }
     //SurveyID
     if (!Yii::app()->getConfig("ugid")) {
         Yii::app()->setConfig("ugid", returnGlobal('ugid'));
     }
     //Usergroup-ID
     if (!Yii::app()->getConfig("gid")) {
         Yii::app()->setConfig("gid", returnGlobal('gid'));
     }
     //GroupID
     if (!Yii::app()->getConfig("qid")) {
         Yii::app()->setConfig("qid", returnGlobal('qid'));
     }
     //QuestionID
     if (!Yii::app()->getConfig("lid")) {
         Yii::app()->setConfig("lid", returnGlobal('lid'));
     }
     //LabelID
     if (!Yii::app()->getConfig("code")) {
         Yii::app()->setConfig("code", returnGlobal('code'));
     }
     // ??
     if (!Yii::app()->getConfig("action")) {
         Yii::app()->setConfig("action", returnGlobal('action'));
     }
     //Desired action
     if (!Yii::app()->getConfig("subaction")) {
         Yii::app()->setConfig("subaction", returnGlobal('subaction'));
     }
     //Desired subaction
     if (!Yii::app()->getConfig("editedaction")) {
         Yii::app()->setConfig("editedaction", returnGlobal('editedaction'));
     }
     // for html editor integration
     // Variable not used, but keep it here so the object is initialized at the right place.
     $oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
 }
Example #9
0
 public function run()
 {
     /*
      * Instead of manually rendering scripts after this function returns we
      * use the callback. This ensures that scripts are always rendered, even
      * if we call exit at some point in the code. (Which we shouldn't, but
      * it happens.)
      */
     // Ensure to set some var, but script are replaced in SurveyRuntimeHelper
     $aLSJavascriptVar = array();
     $aLSJavascriptVar['bFixNumAuto'] = (int) (bool) Yii::app()->getConfig('bFixNumAuto', 1);
     $aLSJavascriptVar['bNumRealValue'] = (int) (bool) Yii::app()->getConfig('bNumRealValue', 0);
     $aLangData = getLanguageData();
     $aRadix = getRadixPointData($aLangData[Yii::app()->getConfig('defaultlang')]['radixpoint']);
     $aLSJavascriptVar['sLEMradix'] = $aRadix['separator'];
     $sLSJavascriptVar = "LSvar=" . json_encode($aLSJavascriptVar) . ';';
     // Template configuration
     $param = $this->_getParameters(func_get_args(), $_POST);
     $surveyid = $param['sid'];
     // Font awesome
     if (!YII_DEBUG) {
         App()->getClientScript()->registerCssFile(App()->getAssetManager()->publish(dirname(Yii::app()->request->scriptFile) . '/styles-public/font-awesome-43.min.css'));
     } else {
         App()->getClientScript()->registerCssFile(Yii::app()->getBaseUrl(true) . '/styles-public/font-awesome-43-debugmode.min.css');
     }
     global $oTemplate;
     $oTemplate = Template::model()->getTemplateConfiguration('', $surveyid);
     $this->oTemplate = $oTemplate;
     App()->clientScript->registerScript('sLSJavascriptVar', $sLSJavascriptVar, CClientScript::POS_HEAD);
     App()->clientScript->registerScript('setJsVar', "setJsVar();", CClientScript::POS_BEGIN);
     // Ensure all js var is set before rendering the page (User can click before $.ready)
     foreach ($oTemplate->packages as $package) {
         App()->getClientScript()->registerPackage($package);
     }
     App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
     if ($oTemplate->cssFramework == 'bootstrap') {
         App()->bootstrap->register();
     }
     useFirebug();
     ob_start(function ($buffer, $phase) {
         App()->getClientScript()->render($buffer);
         App()->getClientScript()->reset();
         return $buffer;
     });
     ob_implicit_flush(false);
     $this->action();
     ob_flush();
 }
Example #10
0
 /**
  * ๆจกๆฟๅˆ—่กจ
  * @author yongze
  */
 public function actionIndex($id)
 {
     $dsModel = $this->loadModel((int) $id, 'ds');
     $dbModel = $this->loadModel((int) $dsModel->database_id, 'db');
     $model = Template::model();
     $attr = $model->attributeLabels();
     $model->dataset_id = (int) $id;
     $data['attr'] = $attr;
     //ๆจกๅž‹ๅฑžๆ€ง
     $data['model'] = $model;
     $data['dbModel'] = $dbModel;
     $data['dsModel'] = $dsModel;
     $data['datasetId'] = $dsModel->id;
     $data['info'] = $this->promptInfo();
     $this->render('index', $data);
 }
 public function eventDelete($event)
 {
     switch ($event->objectUsed) {
         case 'Account':
             Template::model()->dbConnection->createCommand("DELETE FROM TemplateRowAccount WHERE accountId={$event->id}")->execute();
             break;
         case 'Company':
             $templateList = Template::model()->findAll('companyId=:companyId', array(':companyId' => $event->id));
             if ($templateList != null) {
                 foreach ($templateList as $model) {
                     $model->delete();
                 }
             }
             break;
     }
 }
Example #12
0
 /**
  * Render stuff
  *
  * @param string $html
  * @param array $aSurveyInfo
  * @param int $iSurveyID
  * @return void
  */
 private function _renderHtml($html, $aSurveyInfo, $iSurveyID)
 {
     sendCacheHeaders();
     doHeader();
     $aSupportData = array('thissurvey' => $aSurveyInfo);
     $oTemplate = Template::model()->getInstance(null, $iSurveyID);
     if ($oTemplate->cssFramework == 'bootstrap') {
         App()->bootstrap->register();
     }
     $thistpl = $oTemplate->viewPath;
     echo templatereplace(file_get_contents($thistpl . 'startpage.pstpl'), array(), $aSupportData);
     $aData['html'] = $html;
     $aData['thistpl'] = $thistpl;
     $this->render('/opt_view', $aData);
     echo templatereplace(file_get_contents($thistpl . 'endpage.pstpl'), array(), $aSupportData);
     doFooter();
 }
Example #13
0
 public function actionPublicList($lang = null)
 {
     if (!empty($lang)) {
         App()->setLanguage($lang);
     } else {
         App()->setLanguage(App()->getConfig('defaultlang'));
     }
     $oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
     if ($oTemplate->cssFramework == 'bootstrap') {
         // We now use the bootstrap package isntead of the Yiistrap TbApi::register() method
         // Then instead of using the composer dependency system for templates
         // We can use the package dependency system
         Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport');
         App()->bootstrap->registerAllScripts();
     }
     $this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
 }
Example #14
0
 function viewAction()
 {
     $clearArray = array();
     $this->filter($clearArray);
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     $models = AFActiveDataProvider::models('Template', $this->params, $pagination, '`template_id` DESC');
     $dataProvider = $models->getAll();
     $filterFields = $models->getoutFilterFields($clearArray);
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_table', array('application', 'views', 'templates'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields));
         die;
     }
     $templates = Template::model()->cache()->findAllInArray();
     Assets::js('ajax_table');
     Assets::js('af_input_field');
     $this->addToPageTitle('Templates');
     $this->render('view', array('dataProvider' => $dataProvider, 'templates' => $templates, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields));
 }
Example #15
0
 public function actionForm($id = null, $template_type_id = null)
 {
     if (Yii::app()->session["username"] != null) {
         $this->layout = "main";
     } else {
         $this->layout = "front";
     }
     $model = new Template();
     if (!empty($_POST["Template"])) {
         // 1.step new user
         $model = new Template();
         // 2.step edit template
         if (!empty($id)) {
             $model = Template::model()->findByPk($id);
         }
         // 3. step merge data
         $model->_attributes = $_POST["Template"];
         $model->template_type_id = $template_type_id;
         $model->created = new CDbExpression('NOW()');
         $model->image = CUploadedFile::getInstance($model, 'image');
         $fecha = date('YmdHms');
         if ($model->image) {
             $attach_src = Yii::app()->basePath . '/../docs/' . $fecha . '.' . $model->image->getExtensionName();
             //. '_' . $model->$imageAttrName;
             $model->image->saveAs($attach_src);
             $model->image = $fecha . '.' . $model->image->getExtensionName();
             // . '_' . $model->$imageAttrName;
         }
         // 5. step save/update
         if ($model->save()) {
             $this->redirect("index.php?r=template&template_type_id={$template_type_id}");
         }
     }
     if (!empty($id)) {
         $model = Template::model()->findByPk($id);
     }
     $this->render("//template/form", array("model" => $model, "template_type_id" => $template_type_id));
 }
Example #16
0
 function run($args)
 {
     extract($args);
     $redata = compact(array_keys(get_defined_vars()));
     $sTemplatePath = $_SESSION['survey_' . $surveyid]['templatepath'];
     sendCacheHeaders();
     doHeader();
     $oTemplate = Template::model()->getInstance(null, $surveyid);
     echo templatereplace(file_get_contents($oTemplate->viewPath . "startpage.pstpl"), array(), $redata);
     echo "\n\n<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->\n" . "\t<script type='text/javascript'>\n" . "function checkconditions(value, name, type, evt_type)\n" . "\t{\n" . "\t}\n" . "\t</script>\n\n";
     echo CHtml::form(array("/survey/index", "sid" => $surveyid), 'post') . "\n";
     echo templatereplace(file_get_contents($oTemplate->viewPath . "load.pstpl"), array(), $redata);
     //PRESENT OPTIONS SCREEN (Replace with Template Later)
     //END
     echo "<input type='hidden' name='loadall' value='reload' />\n";
     if (isset($clienttoken) && $clienttoken != "") {
         echo "<input type='hidden' name='token' value='{$clienttoken}' />\n";
     }
     echo "</form>";
     echo templatereplace(file_get_contents($oTemplate->viewPath . "endpage.pstpl"), array(), $redata);
     doFooter();
     exit;
 }
/**
* This function replaces keywords in a text and is mainly intended for templates
* If you use this functions put your replacement strings into the $replacements variable
* instead of using global variables
* NOTE - Don't do any embedded replacements in this function.  Create the array of replacement values and
* they will be done in batch at the end
*
* @param mixed $line Text to search in
* @param mixed $replacements Array of replacements:  Array( <stringtosearch>=><stringtoreplacewith>
* @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 <SPAN> 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, $oTemplate = '')
{
    /*
    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', 'saved_id', 'usertemplaterootdir',
    'languagechanger', 'printoutput', 'captchapath', 'loadname');
    */
    $allowedvars = array('assessments', 'captchapath', 'clienttoken', 'completed', 'errormsg', 'groupdescription', 'groupname', 'imageurl', 'languagechanger', 'loadname', 'move', 'navigator', 'moveprevbutton', 'movenextbutton', 'percentcomplete', 'privacy', 's_lang', 'saved_id', 'showgroupinfo', 'showqnumcode', 'showxquestions', 'sitename', 'sitelogo', 'surveylist', 'templatedir', 'thissurvey', 'token', 'totalBoilerplatequestions', 'totalquestions', 'questionindex', 'questionindexmenu');
    $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'];
    }
    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 = "";
    $_templatejs = "";
    /**
     * Template css/js files from the template config files are loaded.
     * It use the asset manager (so user never need to empty the cache, even if template is updated)
     * If debug mode is on, no asset manager is used.
     *
     * oTemplate is defined in controller/survey/index
     *
     * If templatereplace is called from the template editor, a $oTemplate is provided.
     */
    $oTemplate = Template::model()->getInstance($templatename);
    $aCssFiles = $oTemplate->config->files->css->filename;
    $aJsFiles = $oTemplate->config->files->js->filename;
    $aOtherFiles = $oTemplate->otherFiles;
    //var_dump($aOtherFiles); die();
    if (stripos($line, "{TEMPLATECSS}")) {
        // If the template has files for css, we can't publish the files one by one, but we must publish them as a whole directory
        // TODO : extend asset manager so it check for file modification even in directory mode
        if (!YII_DEBUG || count($aOtherFiles) < 0) {
            foreach ($aCssFiles as $sCssFile) {
                if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile)) {
                    Yii::app()->getClientScript()->registerCssFile(App()->getAssetManager()->publish($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile), $sCssFile['media']);
                }
            }
        } else {
            foreach ($aCssFiles as $sCssFile) {
                if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile)) {
                    Yii::app()->getClientScript()->registerCssFile("{$templateurl}{$sCssFile}", $sCssFile['media']);
                }
            }
        }
        /* RTL CSS */
        if (getLanguageRTL(App()->language)) {
            $aCssFiles = (array) $oTemplate->config->files->rtl->css->filename;
            if (!YII_DEBUG) {
                foreach ($aCssFiles as $sCssFile) {
                    if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile)) {
                        Yii::app()->getClientScript()->registerCssFile(App()->getAssetManager()->publish($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile), $sCssFile['media']);
                    }
                }
            } else {
                foreach ($aCssFiles as $sCssFile) {
                    if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile)) {
                        Yii::app()->getClientScript()->registerCssFile("{$templateurl}{$sCssFile}", $sCssFile['media']);
                    }
                }
            }
        }
    }
    if (stripos($line, "{TEMPLATEJS}")) {
        if (!YII_DEBUG) {
            foreach ($aJsFiles as $sJsFile) {
                if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sJsFile)) {
                    App()->getClientScript()->registerScriptFile(App()->getAssetManager()->publish($oTemplate->path . DIRECTORY_SEPARATOR . $sJsFile));
                }
            }
        } else {
            foreach ($aJsFiles as $sJsFile) {
                if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sJsFile)) {
                    Yii::app()->getClientScript()->registerScriptFile("{$templateurl}{$sJsFile}");
                }
            }
        }
        /* RTL JS */
        if (getLanguageRTL(App()->language)) {
            $aJsFiles = (array) $oTemplate->config->files->rtl->js->filename;
            if (!YII_DEBUG) {
                foreach ($aJsFiles as $aJsFile) {
                    if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $aJsFile)) {
                        App()->getClientScript()->registerScriptFile(App()->getAssetManager()->publish($oTemplate->path . DIRECTORY_SEPARATOR . $aJsFile));
                    }
                }
            } else {
                foreach ($aJsFiles as $sJsFile) {
                    if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sJsFile)) {
                        Yii::app()->getClientScript()->registerScriptFile("{$templateurl}{$sJsFile}");
                    }
                }
            }
        }
    }
    // surveyformat
    if (isset($thissurvey['format'])) {
        $surveyformat = str_replace(array("A", "S", "G"), array("allinone", "questionbyquestion", "groupbygroup"), $thissurvey['format']);
    } else {
        $surveyformat = "";
    }
    if ($oTemplate->config->engine->cssframework) {
        $surveyformat .= " " . $oTemplate->config->engine->cssframework . "-engine ";
    }
    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(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($totalquestions)) {
        $totalquestions = 0;
    }
    $_totalquestionsAsked = $totalquestions;
    if ($showxquestions == 'show' || $showxquestions == 'choose' && !isset($thissurvey['showxquestions']) || $showxquestions == 'choose' && $thissurvey['showxquestions'] == 'Y') {
        if ($_totalquestionsAsked < 1) {
            $_therearexquestions = gT("There are no questions in this survey");
            // Singular
        } elseif ($_totalquestionsAsked == 1) {
            $_therearexquestions = gT("There is 1 question in this survey");
            //Singular
        } else {
            $_therearexquestions = 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 = "<input class='submit btn btn-default' type='submit' value=' " . gT("Submit") . " ' name='move2' onclick=\"javascript:document.limesurvey.move.value = 'movesubmit';\" />";
    if (isset($thissurvey['surveyls_url']) and $thissurvey['surveyls_url'] != "") {
        if (trim($thissurvey['surveyls_urldescription']) != '') {
            $_linkreplace = "<a href='{$thissurvey['surveyls_url']}'>{$thissurvey['surveyls_urldescription']}</a>";
        } else {
            $_linkreplace = "<a href='{$thissurvey['surveyls_url']}'>{$thissurvey['surveyls_url']}</a>";
        }
    } 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(gT("Exit and clear survey"), array('type' => 'submit', 'id' => "clearall", 'value' => 'clearall', 'name' => 'clearall', 'class' => 'clearall button  btn btn-default btn-lg  col-xs-4 hidden', 'data-confirmedby' => 'confirm-clearall', 'title' => gT("This action need confirmation.")));
        $_clearall .= CHtml::checkBox("confirm-clearall", false, array('id' => 'confirm-clearall', 'value' => 'confirm', 'class' => 'hide jshide  btn btn-default btn-lg  col-xs-4'));
        $_clearall .= CHtml::label(gT("Are you sure you want to clear all your responses?"), 'confirm-clearall', array('class' => 'hide jshide  btn btn-default btn-lg  col-xs-4'));
        $_clearalllinks = '<li><a href="#" id="clearallbtnlink">' . gT("Exit and clear survey") . '</a></li>';
    } else {
        $_clearall = "";
        $_clearalllinks = '';
    }
    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);
        $_savelinks = doHtmlSaveLinks(isset($move) ? $move : NULL);
    } else {
        $_saveall = "";
        $_savelinks = "";
    }
    if (isset($thissurvey['allowprev']) && $thissurvey['allowprev'] == "N") {
        $_strreview = "";
    } else {
        $_strreview = 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 = "<a href='{$restarturl}'>" . gT("Restart this Survey") . "</a>";
    } else {
        $_restart = "";
    }
    if (isset($thissurvey['anonymized']) && $thissurvey['anonymized'] == 'Y') {
        $_savealert = 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' => Token::sanitizeToken($_token)));
        } else {
            $returnlink = Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}");
        }
        $_return_to_survey = "<a href='{$returnlink}'>" . gT("Return to survey") . "</a>";
    } else {
        $_return_to_survey = "";
    }
    // Save Form
    $_saveform = "<table class='save-survey-form'><tr class='save-survey-row save-survey-name'><td class='save-survey-label label-cell' align='right'><label for='savename'>" . gT("Name") . "</label>:</td><td class='save-survey-input input-cell'><input type='text' name='savename' id='savename' value='";
    if (isset($_POST['savename'])) {
        $_saveform .= HTMLEscape(autoUnescape($_POST['savename']));
    }
    $_saveform .= "' /></td></tr>\n" . "<tr class='save-survey-row save-survey-password-1'><td class='save-survey-label label-cell' align='right'><label for='savepass'>" . gT("Password") . "</label>:</td><td class='save-survey-input input-cell'><input type='password' id='savepass' name='savepass' value='";
    if (isset($_POST['savepass'])) {
        $_saveform .= HTMLEscape(autoUnescape($_POST['savepass']));
    }
    $_saveform .= "' /></td></tr>\n" . "<tr class='save-survey-row save-survey-password-2'><td class='save-survey-label label-cell' align='right'><label for='savepass2'>" . gT("Repeat password") . "</label>:</td><td class='save-survey-input input-cell'><input type='password' id='savepass2' name='savepass2' value='";
    if (isset($_POST['savepass2'])) {
        $_saveform .= HTMLEscape(autoUnescape($_POST['savepass2']));
    }
    $_saveform .= "' /></td></tr>\n" . "<tr class='save-survey-row save-survey-email'><td class='save-survey-label label-cell' align='right'><label for='saveemail'>" . gT("Your email address") . "</label>:</td><td class='save-survey-input input-cell'><input type='text' id='saveemail' name='saveemail' value='";
    if (isset($_POST['saveemail'])) {
        $_saveform .= HTMLEscape(autoUnescape($_POST['saveemail']));
    }
    $_saveform .= "' /></td></tr>\n";
    if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && isCaptchaEnabled('saveandloadscreen', $thissurvey['usecaptcha'])) {
        $_saveform .= "<tr class='save-survey-row save-survey-captcha'><td class='save-survey-label label-cell' align='right'><label for='loadsecurity'>" . gT("Security question") . "</label>:</td><td class='save-survey-input input-cell'><table class='captcha-table'><tr><td class='captcha-image' valign='middle'><img alt='' src='" . Yii::app()->getController()->createUrl('/verification/image/sid/' . (isset($surveyid) ? $surveyid : '')) . "' /></td><td class='captcha-input' valign='middle' style='text-align:left'><input type='text' size='5' maxlength='3' id='loadsecurity' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
    }
    $_saveform .= "<tr><td align='right'></td><td></td></tr>\n" . "<tr class='save-survey-row save-survey-submit'><td class='save-survey-label label-cell'><label class='hide jshide' for='savebutton'>" . gT("Save Now") . "</label></td><td class='save-survey-input input-cell'><input type='submit' id='savebutton' name='savesubmit' class='button' value='" . gT("Save Now") . "' /></td></tr>\n" . "</table>";
    // Load Form
    $_loadform = "<table class='load-survey-form'><tr class='load-survey-row load-survey-name'><td class='load-survey-label label-cell' align='right'><label for='loadname'>" . gT("Saved name") . "</label>:</td><td class='load-survey-input input-cell'><input type='text' id='loadname' name='loadname' value='";
    if (isset($loadname)) {
        $_loadform .= HTMLEscape(autoUnescape($loadname));
    }
    $_loadform .= "' /></td></tr>\n" . "<tr class='load-survey-row load-survey-password'><td class='load-survey-label label-cell' align='right'><label for='loadpass'>" . gT("Password") . "</label>:</td><td class='load-survey-input input-cell'><input type='password' id='loadpass' name='loadpass' value='";
    if (isset($loadpass)) {
        $_loadform .= HTMLEscape(autoUnescape($loadpass));
    }
    $_loadform .= "' /></td></tr>\n";
    if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && isCaptchaEnabled('saveandloadscreen', $thissurvey['usecaptcha'])) {
        $_loadform .= "<tr class='load-survey-row load-survey-captcha'><td class='load-survey-label label-cell' align='right'><label for='loadsecurity'>" . gT("Security question") . "</label>:</td><td class='load-survey-input input-cell'><table class='captcha-table'><tr><td class='captcha-image' valign='middle'><img src='" . Yii::app()->getController()->createUrl('/verification/image/sid/' . (isset($surveyid) ? $surveyid : '')) . "' alt='' /></td><td class='captcha-input' valign='middle'><input type='text' size='5' maxlength='3' id='loadsecurity' name='loadsecurity' value='' alt=''/></td></tr></table></td></tr>\n";
    }
    $_loadform .= "<tr class='load-survey-row load-survey-submit'><td class='load-survey-label label-cell'><label class='hide jshide' for='loadbutton'>" . gT("Load now") . "</label></td><td class='load-survey-input input-cell'><input type='submit' id='loadbutton' class='button' value='" . gT("Load now") . "' /></td></tr></table>\n";
    // 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 = <<<EOD
<script>
(function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments) },i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{$_googleAnalyticsAPIKey}', 'auto');  // Replace with your property ID.
ga('send', 'pageview');

</script>

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 = <<<EOD
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{$_googleAnalyticsAPIKey}', 'auto');  // Replace with your property ID.
ga('send', 'pageview');
ga('send', 'pageview', '{$_trackURL}');

</script>
EOD;
                break;
        }
    }
    $_endtext = '';
    if (isset($thissurvey['surveyls_endtext']) && trim($thissurvey['surveyls_endtext']) != '') {
        $_endtext = $thissurvey['surveyls_endtext'];
    }
    $sitelogo = !empty($oTemplate->siteLogo) ? '<img src="' . App()->getAssetManager()->publish($oTemplate->path . '/' . $oTemplate->siteLogo) . '"/>' : '';
    // Set the array of replacement variables here - don't include curly braces
    $coreReplacements = array();
    $coreReplacements['ACTIVE'] = isset($thissurvey['active']) && !($thissurvey['active'] != "Y");
    $coreReplacements['ANSWERSCLEARED'] = gT("Answers cleared");
    $coreReplacements['ASSESSMENTS'] = $assessmenthtml;
    $coreReplacements['ASSESSMENT_CURRENT_TOTAL'] = $_assessment_current_total;
    $coreReplacements['ASSESSMENT_HEADING'] = gT("Your assessment");
    $coreReplacements['CHECKJAVASCRIPT'] = "<noscript><span class='warningjs'>" . gT("Caution: JavaScript execution is disabled in your browser. You may not be able to answer all questions in this survey. Please, verify your browser parameters.") . "</span></noscript>";
    $coreReplacements['CLEARALL'] = $_clearall;
    $coreReplacements['CLEARALL_LINKS'] = $_clearalllinks;
    $coreReplacements['CLOSEWINDOW'] = '';
    // Obsolete tag - keep this line for compatibility reaons
    $coreReplacements['COMPLETED'] = isset($redata['completed']) ? $redata['completed'] : '';
    // global
    $coreReplacements['DATESTAMP'] = $_datestamp;
    $coreReplacements['ENDTEXT'] = $_endtext;
    $coreReplacements['EXPIRY'] = $_dateoutput;
    $coreReplacements['ADMINNAME'] = isset($thissurvey['admin']) ? $thissurvey['admin'] : '';
    $coreReplacements['ADMINEMAIL'] = isset($thissurvey['adminemail']) ? $thissurvey['adminemail'] : '';
    $coreReplacements['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'] = App()->language;
    $coreReplacements['LANGUAGECHANGER'] = isset($languagechanger) ? $languagechanger : '';
    // global
    $coreReplacements['LOADERROR'] = isset($errormsg) ? $errormsg : '';
    // global
    $coreReplacements['LOADFORM'] = $_loadform;
    $coreReplacements['LOADHEADING'] = gT("Load a previously saved survey");
    $coreReplacements['LOADMESSAGE'] = gT("You can load a survey that you have previously saved from this screen.") . "<br />" . gT("Type in the 'name' you used to save the survey, and the password.") . "<br />";
    $coreReplacements['NAVIGATOR'] = isset($navigator) ? $navigator : '';
    // global
    $coreReplacements['MOVEPREVBUTTON'] = isset($moveprevbutton) ? $moveprevbutton : '';
    // global
    $coreReplacements['MOVENEXTBUTTON'] = isset($movenextbutton) ? $movenextbutton : '';
    // global
    $coreReplacements['NOSURVEYID'] = isset($surveylist) ? $surveylist['nosid'] : '';
    $coreReplacements['NUMBEROFQUESTIONS'] = $_totalquestionsAsked;
    $coreReplacements['PERCENTCOMPLETE'] = isset($percentcomplete) ? $percentcomplete : '';
    // global
    $coreReplacements['PRIVACY'] = isset($privacy) ? $privacy : '';
    // global
    $coreReplacements['PRIVACYMESSAGE'] = "<span style='font-weight:bold; font-style: italic;'>" . gT("A Note On Privacy") . "</span><br />" . gT("This survey is anonymous.") . "<br />" . gT("The record of your survey responses does not contain any identifying information about you, unless a specific survey question explicitly asked for it.") . ' ' . 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['QUESTION_INDEX'] = isset($questionindex) ? $questionindex : '';
    $coreReplacements['QUESTION_INDEX_MENU'] = isset($questionindexmenu) ? $questionindexmenu : '';
    $coreReplacements['RESTART'] = $_restart;
    $coreReplacements['RETURNTOSURVEY'] = $_return_to_survey;
    $coreReplacements['SAVE_LINKS'] = $_savelinks;
    $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'] = gT("Save your unfinished survey");
    $coreReplacements['SAVEMESSAGE'] = gT("Enter a name and password for this survey and click save below.") . "<br />\n" . 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.") . "<br /><br />\n<span class='emailoptional'>" . gT("If you give an email address, an email containing the details will be sent to you.") . "</span><br /><br />\n" . gT("After having clicked the save button you can either close this browser window or continue filling out the survey.");
    $coreReplacements['SID'] = Yii::app()->getConfig('surveyID', '');
    // Allways use surveyID from config
    $coreReplacements['SITENAME'] = isset($sitename) ? $sitename : '';
    // global
    $coreReplacements['SITELOGO'] = $sitelogo;
    $coreReplacements['SUBMITBUTTON'] = $_submitbutton;
    $coreReplacements['SUBMITCOMPLETE'] = "<strong>" . gT("Thank you!") . "<br /><br />" . gT("You have completed answering the questions in this survey.") . "</strong><br /><br />" . 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['SURVEYLANGUAGE'] = App()->language;
    $coreReplacements['SURVEYLIST'] = isset($surveylist) ? $surveylist['list'] : '';
    $coreReplacements['SURVEYLISTHEADING'] = isset($surveylist) ? $surveylist['listheading'] : '';
    $coreReplacements['SURVEYNAME'] = isset($thissurvey['name']) ? $thissurvey['name'] : '';
    $coreReplacements['SURVEYRESOURCESURL'] = isset($thissurvey['sid']) ? Yii::app()->getConfig("uploadurl") . '/surveys/' . $thissurvey['sid'] . '/' : '';
    $coreReplacements['TEMPLATECSS'] = $_templatecss;
    $coreReplacements['TEMPLATEJS'] = $_templatejs;
    $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 (!isset($replacements['QID'])) {
        Yii::import('application.helpers.SurveyRuntimeHelper');
        $coreReplacements = array_merge($coreReplacements, SurveyRuntimeHelper::getQuestionReplacement(null));
        // so $replacements overrides core values
    }
    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;
}
Example #18
0
 function emailAction()
 {
     $model = new CampaignEmail();
     if (isset($_POST['ajax'])) {
         if (isset($_POST['model']) && $_POST['model'] == 'prospects') {
             // Uncomment the following line if AJAX validation is needed
             $this->performAjaxValidation($model);
             $model->fillFromArray($_POST);
             /*
             $model->user_id_created = $this->user->user_id;
             $model->user_id_updated = $this->user->user_id;
             $model->updated = 'NOW():sql';
             $model->created = 'NOW():sql';
             $model->model_uset_id = $this->user->user_id;
             */
             if ($model->save()) {
                 Message::echoJsonSuccess();
             } else {
                 Message::echoJsonError(__('prospects_email_not_created') . ' ' . $model->errors2string);
             }
             die;
         }
         if (isset($_POST['model']) && $_POST['model'] == 'campaigns') {
             $campaignModel = new Campaign();
             $campaignModel->setIsNewRecord(false);
             $campaignID = AF::get($_POST, 'campaign_id');
             $campaignModel->fillFromDbPk($campaignID);
             $campaignModel->smtp_id = AF::get($_POST, 'smtp_id');
             $campaignModel->user_id_updated = $this->user->user_id;
             $campaignModel->updated = 'NOW():sql';
             if ($campaignModel->save(false)) {
                 Message::echoJsonSuccess(__('campaign_updated'));
             } else {
                 Message::echoJsonError(__('campaign_no_updated'));
             }
             die;
         }
     }
     $clearArray = array();
     $this->filter($clearArray);
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     $models = AFActiveDataProvider::models('CampaignEmail', $this->params, $pagination);
     $dataProvider = $models->getAll();
     $filterFields = $models->getoutFilterFields($clearArray);
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_email_table', array('application', 'views', 'prospects'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields));
         die;
     }
     $templates = Template::model()->cache()->findAllInArray();
     $smtps = Smtp::model()->cache()->findAllInArray();
     $campaignID = AF::get($this->params, 'campaign_id');
     $campaignModel = new Campaign();
     $campaignModel->fillFromDbPk($campaignID);
     Assets::js('jquery.form');
     $this->addToPageTitle(__('prospect_email'));
     $this->render('email', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'campaignModel' => $campaignModel, 'templates' => $templates, 'smtps' => $smtps, 'filterFields' => $filterFields));
 }
 /**
  * Construction of replacement array, actually doing it with redata
  *
  * @param $aQuestionQanda : array from qanda helper
  * @return aray of replacement for question.psptl
  **/
 public static function getQuestionReplacement($aQuestionQanda)
 {
     // Get the default replacement and set empty value by default
     $aReplacement = array("QID" => "", "SGQ" => "", "AID" => "", "QUESTION_CODE" => "", "QUESTION_NUMBER" => "", "QUESTION" => "", "QUESTION_TEXT" => "", "QUESTIONHELP" => "", "QUESTIONHELPPLAINTEXT" => "", "QUESTION_CLASS" => "", "QUESTION_MAN_CLASS" => "", "QUESTION_INPUT_ERROR_CLASS" => "", "ANSWER" => "", "QUESTION_HELP" => "", "QUESTION_VALID_MESSAGE" => "", "QUESTION_FILE_VALID_MESSAGE" => "", "QUESTION_MAN_MESSAGE" => "", "QUESTION_MANDATORY" => "", "QUESTION_ESSENTIALS" => "");
     if (!is_array($aQuestionQanda) || empty($aQuestionQanda[0])) {
         return $aReplacement;
     }
     $iQid = $aQuestionQanda[4];
     $lemQuestionInfo = LimeExpressionManager::GetQuestionStatus($iQid);
     $iSurveyId = Yii::app()->getConfig('surveyID');
     // Or : by SGQA of question ? by Question::model($iQid)->sid;
     $oSurveyId = Survey::model()->findByPk($iSurveyId);
     $sType = $lemQuestionInfo['info']['type'];
     // Core value : not replaced
     $aReplacement['QID'] = $iQid;
     $aReplacement['GID'] = $aQuestionQanda[6];
     // Not sure for aleatory : it's the real gid or the updated gid ? We need original gid or updated gid ?
     $aReplacement['SGQ'] = $aQuestionQanda[7];
     $aReplacement['AID'] = isset($aQuestionQanda[0]['aid']) ? $aQuestionQanda[0]['aid'] : "";
     $aReplacement['QUESTION_CODE'] = $aReplacement['QUESTION_NUMBER'] = "";
     $sCode = $aQuestionQanda[5];
     $iNumber = $aQuestionQanda[0]['number'];
     switch (Yii::app()->getConfig('showqnumcode')) {
         case 'both':
             $aReplacement['QUESTION_CODE'] = $sCode;
             $aReplacement['QUESTION_NUMBER'] = $iNumber;
             break;
         case 'number':
             $aReplacement['QUESTION_NUMBER'] = $iNumber;
             break;
         case 'number':
             $aReplacement['QUESTION_CODE'] = $sCode;
             break;
         case 'choose':
         default:
             switch ($oSurveyId->showqnumcode) {
                 case 'B':
                     // Both
                     $aReplacement['QUESTION_CODE'] = $sCode;
                     $aReplacement['QUESTION_NUMBER'] = $iNumber;
                     break;
                 case 'N':
                     $aReplacement['QUESTION_NUMBER'] = $iNumber;
                     break;
                 case 'C':
                     $aReplacement['QUESTION_CODE'] = $sCode;
                     break;
                 case 'X':
                 default:
                     break;
             }
             break;
     }
     $aReplacement['QUESTION'] = $aQuestionQanda[0]['all'];
     // Deprecated : only used in old template (very old)
     // Core value : user text
     $aReplacement['QUESTION_TEXT'] = $aQuestionQanda[0]['text'];
     $aReplacement['QUESTIONHELP'] = $lemQuestionInfo['info']['help'];
     // User help
     // To be moved in a extra plugin : QUESTIONHELP img adding
     $sTemplateDir = Template::model()->getTemplatePath($oSurveyId->template);
     $sTemplateUrl = Template::model()->getTemplateURL($oSurveyId->template);
     if (flattenText($aReplacement['QUESTIONHELP'], true, true) != '') {
         $aReplacement['QUESTIONHELP'] = Yii::app()->getController()->renderPartial('/survey/system/questionhelp/questionhelp', array('questionHelp' => $aReplacement['QUESTIONHELP']), true);
     }
     // Core value :the classes
     $aReplacement['QUESTION_CLASS'] = Question::getQuestionClass($sType);
     //get additional question classes from question attribute
     $aQuestionAttributes = getQuestionAttributeValues($aQuestionQanda[4]);
     //add additional classes
     if (isset($aQuestionAttributes['cssclass'])) {
         $aReplacement['QUESTION_CLASS'] .= " " . $aQuestionAttributes['cssclass'];
     }
     $aMandatoryClass = array();
     if ($lemQuestionInfo['info']['mandatory'] == 'Y') {
         $aMandatoryClass[] = 'mandatory';
     }
     if ($lemQuestionInfo['anyUnanswered'] && $_SESSION['survey_' . $iSurveyId]['maxstep'] != $_SESSION['survey_' . $iSurveyId]['step']) {
         $aMandatoryClass[] = 'missing';
     }
     $aReplacement['QUESTION_MAN_CLASS'] = !empty($aMandatoryClass) ? " " . implode(" ", $aMandatoryClass) : "";
     $aReplacement['QUESTION_INPUT_ERROR_CLASS'] = $aQuestionQanda[0]['input_error_class'];
     // Core value : LS text : EM and not
     $aReplacement['ANSWER'] = $aQuestionQanda[1];
     $aReplacement['QUESTION_HELP'] = $aQuestionQanda[0]['help'];
     // Core help only, not EM
     $aReplacement['QUESTION_VALID_MESSAGE'] = $aQuestionQanda[0]['valid_message'];
     // $lemQuestionInfo['validTip']
     $aReplacement['QUESTION_FILE_VALID_MESSAGE'] = $aQuestionQanda[0]['file_valid_message'];
     // $lemQuestionInfo['??']
     $aReplacement['QUESTION_MAN_MESSAGE'] = $aQuestionQanda[0]['man_message'];
     $aReplacement['QUESTION_MANDATORY'] = $aQuestionQanda[0]['mandatory'];
     // For QUESTION_ESSENTIALS
     $aHtmlOptions = array();
     if (!$lemQuestionInfo['relevant'] || $lemQuestionInfo['hidden']) {
         $aHtmlOptions['style'] = 'display: none;';
     }
     // Launch the event
     $event = new PluginEvent('beforeQuestionRender');
     // Some helper
     $event->set('surveyId', $iSurveyId);
     $event->set('type', $sType);
     $event->set('code', $sCode);
     $event->set('qid', $iQid);
     $event->set('gid', $aReplacement['GID']);
     // User text
     $event->set('text', $aReplacement['QUESTION_TEXT']);
     $event->set('questionhelp', $aReplacement['QUESTIONHELP']);
     // The classes
     $event->set('class', $aReplacement['QUESTION_CLASS']);
     $event->set('man_class', $aReplacement['QUESTION_MAN_CLASS']);
     $event->set('input_error_class', $aReplacement['QUESTION_INPUT_ERROR_CLASS']);
     // LS core text
     $event->set('answers', $aReplacement['ANSWER']);
     $event->set('help', $aReplacement['QUESTION_HELP']);
     $event->set('man_message', $aReplacement['QUESTION_MAN_MESSAGE']);
     $event->set('valid_message', $aReplacement['QUESTION_VALID_MESSAGE']);
     $event->set('file_valid_message', $aReplacement['QUESTION_FILE_VALID_MESSAGE']);
     // htmlOptions for container
     $event->set('aHtmlOptions', $aHtmlOptions);
     App()->getPluginManager()->dispatchEvent($event);
     // User text
     $aReplacement['QUESTION_TEXT'] = $event->get('text');
     $aReplacement['QUESTIONHELP'] = $event->get('questionhelp');
     $aReplacement['QUESTIONHELPPLAINTEXT'] = strip_tags(addslashes($aReplacement['QUESTIONHELP']));
     // The classes
     $aReplacement['QUESTION_CLASS'] = $event->get('class');
     $aReplacement['QUESTION_MAN_CLASS'] = $event->get('man_class');
     $aReplacement['QUESTION_INPUT_ERROR_CLASS'] = $event->get('input_error_class');
     // LS core text
     $aReplacement['ANSWER'] = $event->get('answers');
     $aReplacement['QUESTION_HELP'] = $event->get('help');
     $aReplacement['QUESTION_MAN_MESSAGE'] = $event->get('man_message');
     $aReplacement['QUESTION_VALID_MESSAGE'] = $event->get('valid_message');
     $aReplacement['QUESTION_FILE_VALID_MESSAGE'] = $event->get('file_valid_message');
     $aReplacement['QUESTION_MANDATORY'] = $event->get('mandatory', $aReplacement['QUESTION_MANDATORY']);
     // Always add id for QUESTION_ESSENTIALS
     $aHtmlOptions['id'] = "question{$iQid}";
     $aReplacement['QUESTION_ESSENTIALS'] = CHtml::renderAttributes($aHtmlOptions);
     return $aReplacement;
 }
Example #20
0
 /**
  * Relations.
  *
  * @return array Relations.
  */
 public function relations()
 {
     return array('user' => array(self::BELONGS_TO, User::model()->tableName(), 'user_id'), 'template' => array(self::BELONGS_TO, Template::model()->tableName(), 'template_id'));
 }
Example #21
0
 /**
  * Function responsible to delete a template.
  *
  * @access public
  * @param string $templatename
  * @return void
  */
 public function delete($templatename)
 {
     if (!Permission::model()->hasGlobalPermission('templates', 'delete')) {
         die('No permission');
     }
     Yii::app()->loadHelper("admin/template");
     if (is_template_editable($templatename) == true) {
         $clang = $this->getController()->lang;
         if (rmdirr(Yii::app()->getConfig('usertemplaterootdir') . "/" . $templatename) == true) {
             $surveys = Survey::model()->findAllByAttributes(array('template' => $templatename));
             foreach ($surveys as $s) {
                 $s->template = Yii::app()->getConfig('defaulttemplate');
                 $s->save();
             }
             Template::model()->deleteAllByAttributes(array('folder' => $templatename));
             Permission::model()->deleteAllByAttributes(array('permission' => $templatename, 'entity' => 'template'));
             Yii::app()->setFlashMessage(sprintf($clang->gT("Template '%s' was successfully deleted."), $templatename));
         } else {
             Yii::app()->setFlashMessage(sprintf($clang->gT("There was a problem deleting the template '%s'. Please check your directory/file permissions."), $templatename), 'error');
         }
     }
     // Redirect with default templatename, editfile and screenname
     $this->getController()->redirect(array("admin/templates/sa/view"));
 }
    }
    if(empty($list))
    {
        $list=CHtml::openTag('li',array('class'=>'surveytitle')).gT("No available surveys").CHtml::closeTag('li');
    }
    $data['surveylist'] = array(
        "nosid"=> "",
        "contact"=> sprintf(gT("Please contact %s ( %s ) for further assistance."),
            Yii::app()->getConfig("siteadminname"),
            encodeEmail(Yii::app()->getConfig("siteadminemail"))
        ),
        "listheading"=> gT("The following surveys are available:"),
        "list"=> $list,
    );

    $oTemplate = Template::model()->getTemplateConfiguration(Yii::app()->getConfig("defaulttemplate"));

    $data['templatedir'] = Template::getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
    $data['templateurl'] = Template::getTemplateURL(Yii::app()->getConfig("defaulttemplate"))."/";
    $data['templatename'] = $oTemplate->name;
    $data['sitename'] = Yii::app()->getConfig("sitename");
    $data['languagechanger'] = makeLanguageChanger(App()->language);

    //A nice exit
    sendCacheHeaders();
    doHeader();
    // Javascript Var
    $aLSJavascriptVar=array();
    $aLSJavascriptVar['bFixNumAuto']=(int)(bool)Yii::app()->getConfig('bFixNumAuto',1);
    $aLSJavascriptVar['bNumRealValue']=(int)(bool)Yii::app()->getConfig('bNumRealValue',0);
    if(isset($thissurvey['surveyls_numberformat']))
/**
* Shows the welcome page, used in group by group and question by question mode
*/
function display_first_page()
{
    global $token, $surveyid, $thissurvey, $navigator;
    $totalquestions = $_SESSION['survey_' . $surveyid]['totalquestions'];
    // Fill some necessary var for template
    $aNavigator = surveymover();
    $moveprevbutton = $aNavigator['sMovePrevButton'];
    $movenextbutton = $aNavigator['sMoveNextButton'];
    $navigator = $moveprevbutton . ' ' . $movenextbutton;
    $sitename = Yii::app()->getConfig('sitename');
    $languagechanger = makeLanguageChangerSurvey(App()->language);
    sendCacheHeaders();
    doHeader();
    LimeExpressionManager::StartProcessingPage();
    LimeExpressionManager::StartProcessingGroup(-1, false, $surveyid);
    // start on welcome page
    $redata = compact(array_keys(get_defined_vars()));
    $oTemplate = Template::model()->getInstance('', $surveyid);
    $sTemplatePath = $oTemplate->path;
    $sTemplateViewPath = $oTemplate->viewPath;
    echo templatereplace(file_get_contents($sTemplateViewPath . "startpage.pstpl"), array(), $redata, 'frontend_helper[2757]');
    echo CHtml::form(array("/survey/index", "sid" => $surveyid), 'post', array('id' => 'limesurvey', 'name' => 'limesurvey', 'autocomplete' => 'off', 'class' => 'frontend_helper'));
    echo templatereplace(file_get_contents($sTemplateViewPath . "welcome.pstpl"), array(), $redata, 'frontend_helper[2762]') . "\n";
    if ($thissurvey['anonymized'] == "Y") {
        echo templatereplace(file_get_contents($sTemplateViewPath . "/privacy.pstpl"), array(), $redata, 'frontend_helper[2765]') . "\n";
    }
    echo templatereplace(file_get_contents($sTemplateViewPath . "navigator.pstpl"), array(), $redata, 'frontend_helper[2767]');
    echo "\n<input type='hidden' name='sid' value='{$surveyid}' id='sid' />\n";
    if (isset($token) && !empty($token)) {
        echo "\n<input type='hidden' name='token' value='{$token}' id='token' />\n";
    }
    echo "\n<input type='hidden' name='lastgroupname' value='_WELCOME_SCREEN_' id='lastgroupname' />\n";
    //This is to ensure consistency with mandatory checks, and new group test
    $loadsecurity = returnGlobal('loadsecurity', true);
    if (isset($loadsecurity)) {
        echo "\n<input type='hidden' name='loadsecurity' value='{$loadsecurity}' id='loadsecurity' />\n";
    }
    $_SESSION['survey_' . $surveyid]['LEMpostKey'] = mt_rand();
    echo "<input type='hidden' name='LEMpostKey' value='{$_SESSION['survey_' . $surveyid]['LEMpostKey']}' id='LEMpostKey' />\n";
    echo "<input type='hidden' name='thisstep' id='thisstep' value='0' />\n";
    echo "<!--frontendhelper --></form>";
    echo templatereplace(file_get_contents($sTemplateViewPath . "endpage.pstpl"), array(), $redata, 'frontend_helper[2782]');
    echo LimeExpressionManager::GetRelevanceAndTailoringJavaScript();
    LimeExpressionManager::FinishProcessingPage();
    doFooter();
    echo "<!-- end of frontend_helper /  display_first_page -->";
}
Example #24
0
 function _niceExit(&$redata, $iDebugLine, $sTemplateDir = null, $asMessage = array())
 {
     $oTemplate = Template::model()->getInstance('', $redata['surveyid']);
     $asMessage[] = "<input type='hidden' class='hidemenubutton'/>";
     if (isset($redata['surveyid']) && $redata['surveyid'] && !isset($thisurvey)) {
         $thissurvey = getSurveyInfo($redata['surveyid']);
         $sTemplateDir = $oTemplate->viewPath;
     } else {
         $sTemplateDir = $oTemplate->viewPath;
     }
     sendCacheHeaders();
     doHeader();
     $oTemplate = $this->oTemplate;
     //$oTemplate->viewPath;
     echo "<!-- survey/index/_niceExit -->";
     $this->_printTemplateContent($oTemplate->viewPath . '/startpage.pstpl', $redata, $iDebugLine);
     $this->_printMessage($asMessage);
     $this->_printTemplateContent($oTemplate->viewPath . '/endpage.pstpl', $redata, $iDebugLine);
     doFooter();
     exit;
 }
Example #25
0
 public function actionTemplateData($id)
 {
     $id = intval($id);
     $this->render('templatedata', array('data' => Template::model()->getDataTemplate($id)));
 }
Example #26
0
 private function _refreshtemplates()
 {
     $template_a = getTemplateList();
     foreach ($template_a as $tp => $fullpath) {
         // check for each folder if there is already an entry in the database
         // if not create it with current user as creator (user with rights "create user" can assign template rights)
         $result = Template::model()->findByPk($tp);
         if (count($result) == 0) {
             $post = new Template();
             $post->folder = $tp;
             $post->creator = Yii::app()->session['loginID'];
             $post->save();
         }
     }
     return true;
 }
Example #27
0
$list .= "</ul>";
if (!empty($futureSurveys)) {
    $list .= "<div class=\"survey-list-heading\">" . gT("Following survey(s) are not yet active but you can register for them.") . "</div>";
    $list .= '<ul class="surveys-list future-surveys-list">';
    foreach ($futureSurveys as $survey) {
        $list .= CHtml::openTag('li');
        $list .= CHtml::link($survey->localizedTitle, array('survey/index', 'sid' => $survey->sid, 'lang' => App()->language), array('class' => 'surveytitle'));
        $list .= CHtml::closeTag('li');
        $list .= CHtml::tag('div', array('data-regformsurvey' => $survey->sid));
    }
}
if (empty($list)) {
    $list = CHtml::openTag('li', array('class' => 'surveytitle')) . gT("No available surveys") . CHtml::closeTag('li');
}
$data['surveylist'] = array("nosid" => "", "contact" => sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), encodeEmail(Yii::app()->getConfig("siteadminemail"))), "listheading" => gT("The following surveys are available:"), "list" => $list);
$oTemplate = Template::model()->getInstance("default");
$data['templatedir'] = Template::getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
$data['templateurl'] = Template::getTemplateURL(Yii::app()->getConfig("defaulttemplate")) . "/";
$data['templatename'] = $oTemplate->name;
$data['sitename'] = Yii::app()->getConfig("sitename");
$data['languagechanger'] = makeLanguageChanger(App()->language);
//A nice exit
sendCacheHeaders();
doHeader();
// Javascript Var
$aLSJavascriptVar = array();
$aLSJavascriptVar['bFixNumAuto'] = (int) (bool) Yii::app()->getConfig('bFixNumAuto', 1);
$aLSJavascriptVar['bNumRealValue'] = (int) (bool) Yii::app()->getConfig('bNumRealValue', 0);
if (isset($thissurvey['surveyls_numberformat'])) {
    $radix = getRadixPointData($thissurvey['surveyls_numberformat']);
} else {
Example #28
0
 /**
  * Function responsible to delete a template.
  *
  * @access public
  * @param string $templatename
  * @return void
  */
 public function delete($templatename)
 {
     Yii::app()->loadHelper("admin/template");
     if (is_template_editable($templatename) == true) {
         $clang = $this->getController()->lang;
         if (rmdirr(Yii::app()->getConfig('usertemplaterootdir') . "/" . $templatename) == true) {
             $surveys = Survey::model()->findAllByAttributes(array('template' => $templatename));
             foreach ($surveys as $s) {
                 $s->template = Yii::app()->getConfig('defaulttemplate');
                 $s->save();
             }
             Template::model()->deleteAllByAttributes(array('folder' => $templatename));
             Templates_rights::model()->deleteAllByAttributes(array('folder' => $templatename));
             Yii::app()->session['flashmessage'] = sprintf($clang->gT("Template '%s' was successfully deleted."), $templatename);
         } else {
             Yii::app()->session['flashmessage'] = sprintf($clang->gT("There was a problem deleting the template '%s'. Please check your directory/file permissions."), $templatename);
         }
     }
     // Redirect with default templatename, editfile and screenname
     $this->getController()->redirect($this->getController()->createUrl("admin/templates/view"));
 }
Example #29
0
 public static function sendMail($to, $subject, $view, $params)
 {
     if ($view != "empty") {
         $template = Template::model()->findByName($view);
         if ($template != null) {
             self::sendMailWithContent($to, $subject, $template->applyParams($params));
             return;
         }
     }
     $mail = new YiiMailer($view, $params);
     //set properties
     $setting = Yii::app()->params["accounts"]["mail"];
     $mail->setFrom($setting["adminEmail"], $setting["admin"]);
     $mail->setSubject($subject);
     $mail->setTo($to);
     $mail->IsSMTP();
     $mail->Host = $setting["host"];
     $mail->SMTPDebug = 0;
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = $setting["smtp"]["secure"];
     $mail->Host = $setting["smtp"]["host"];
     $mail->Port = $setting["smtp"]["port"];
     $mail->Username = $setting["smtp"]["username"];
     $mail->Password = $setting["smtp"]["password"];
     //send
     if ($mail->send()) {
         return;
     } else {
         echo "Error while sending email: " . $mail->getError();
         return false;
     }
 }
Example #30
0
/**
 * Render the question view.
 *
 * By default, it just renders the required core view from application/views/survey/...
 * 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.
 *
 * @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;
    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')) {
            $requiredView = $oTemplate->viewPath . ltrim($sView, '/');
            // Then we check if it has its own version of the required view
            if (file_exists($requiredView . '.php')) {
                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
            }
        }
    }
    return Yii::app()->getController()->renderPartial($sView, $aData, $bReturn);
}