Пример #1
0
function getDefaultSurveyLanguage()
{
    global $defaultlanguage;
    if ($defaultlanguage != "") {
        return $defaultlanguage;
    }
    global $survey;
    $defaultlanguage = $survey->getSettingDirectly(USCIC_SURVEY, OBJECT_SURVEY, SETTING_DEFAULT_LANGUAGE, getSurveyMode())->getValue();
    // if empty, then try with default mode
    if ($defaultlanguage == "") {
        $defaultlanguage = $survey->getSettingDirectly(USCIC_SURVEY, OBJECT_SURVEY, SETTING_DEFAULT_LANGUAGE, getDefaultSurveyMode())->getValue();
    }
    return $defaultlanguage;
}
Пример #2
0
 function getAllowedLanguages($mode, $default = true)
 {
     $allowed = $this->getSettingDirectly(USCIC_SURVEY, OBJECT_SURVEY, SETTING_ALLOWED_LANGUAGES, $mode)->getValue();
     if ($default && $allowed == "") {
         $allowed = $this->getSettingDirectly(USCIC_SURVEY, OBJECT_SURVEY, SETTING_ALLOWED_LANGUAGES, getDefaultSurveyMode())->getValue();
     }
     if (trim($allowed) == "") {
         $allowed = 1;
         // default of english allowed
     }
     return $allowed;
 }
Пример #3
0
    function displayParadataScripts($paradata)
    {
        //only for surveys
        if ($_SESSION['SYSTEM_ENTRY'] != USCIC_SURVEY) {
            return;
        }
        // check config
        if ($paradata == false) {
            return;
        }
        // http://greensock.com/forums/topic/9059-cross-browser-to-detect-tab-or-window-is-active-so-animations-stay-in-sync-using-html5-visibility-api/
        if (!isRegisteredScript("js/TabWindowVisibilityManager.min.js")) {
            registerScript('js/TabWindowVisibilityManager.min.js');
            $returnStr = getScript('js/TabWindowVisibilityManager.min.js');
        }
        if (!isRegisteredScript("js/datetimepicker/moment-min.js")) {
            registerScript('js/datetimepicker/moment-min.js');
            $returnStr .= getScript("js/datetimepicker/moment-min.js");
        }
        //if (!isRegisteredScript("js/zip/lzstring.js")) {
        //    registerScript('js/zip/lzstring.js');
        //    $returnStr .= '<script type=text/javascript src="js/zip/lzstring.js"></script>';
        //}
        $params = array(POST_PARAM_DEFAULT_LANGUAGE => getDefaultSurveyLanguage(), POST_PARAM_DEFAULT_MODE => getDefaultSurveyMode(), POST_PARAM_RGID => $this->engine->getRgid(), POST_PARAM_LANGUAGE => getSurveyLanguage(), POST_PARAM_MODE => getSurveyMode(), SESSION_PARAM_TEMPLATE => getSurveyTemplate(), POST_PARAM_VERSION => getSurveyVersion(), POST_PARAM_STATEID => $this->engine->getStateId(), POST_PARAM_DISPLAYED => urlencode(serialize($this->engine->getDisplayNumbers())), POST_PARAM_PRIMKEY => $this->engine->getPrimaryKey(), POST_PARAM_SUID => $this->engine->getSuid());
        $r = setSessionsParamString($params);
        $returnStr .= '<script type="text/javascript">';
        $str = '
            // bind listeners
            $(document).ready(function(){  ';
        if (Config::logParadataMouseMovement()) {
            $str .= '$("html").mousemove(function(event) {
                    window.mousex = event.pageX;
                    window.mousey = event.pageY;
                });';
        }
        $str .= '
                $("html").click(function(event){
                    var name = "";
                    if (event.target.name) {
                        name = event.target.name;
                    }
                    logParadata("MC:"+event.pageX+":"+event.pageY+":"+event.which+":"+name);
                });
                $("html").keyup(function(event){
                    var name = "";
                    if (event.target.name) {
                        name = event.target.name;
                    }
                    logParadata("KE:"+event.keyCode+":"+name);
                });
            });';
        if (Config::logParadataMouseMovement()) {
            $str .= '
                window.mousex = 0;
                window.mousey = 0;
                window.lastx = window.mousex;
                window.lasty = window.mousey;
                function mousemov() {
                    if (window.lastx != window.mousex || window.lasty != window.mousey) {
                        logParadata("MM:"+window.mousex+":"+window.mousey);
                        window.lastx = window.mousex;
                        window.lasty = window.mousey;
                    }

                }
                window.onload=setInterval(mousemov, ' . Config::logParadataMouseMovementInterval() . '); // capture mouse movement every 5 seconds
                ';
        }
        $str .= '
            // compress function
            function compress(string) {
                return string;
                //return LZString.compressToUTF16(string);
            }
            
            // function to log paradata
            function logParadata(para) {
                $("#pid").val($("#pid").val() + "||" + compress(para + "=" + moment()));
                //alert($("#pid").val().length);
                // if length exceeds limit
                //if ($("#pid").val().length > 1024) {
                    //alert($("#pid").val().length);
                    //sendParadata($("#pid").val()); // send to server
                    //$("#pid").val(""); // reset
                //}
            }

            // function to send paradata to the server
            function sendParadata(paradata) {
                $.ajax({
                    type: "POST",
                    url: "ajax/index.php",
                    data: {ajaxr: "' . $r . '", p: "storeparadata", ' . POST_PARAM_PARADATA . ': paradata},
                    async: true
                });
            }
                 
            var firedin = false;                
            var firedout = false; 
            $(window).TabWindowVisibilityManager({
                onFocusCallback: function(){
                        if (firedin == false) {
                            //document.title="visible";
                            logParadata("FI:");	                
                        }
                        firedin = true;
                        firedout = false;
                },
                onBlurCallback: function(){
                    if (firedout == false) {
                        //document.title="invisible";
                        logParadata("FO:");
                    }
                    firedout = true;    
                    firedin = false;
                }
            });';
        $returnStr .= minifyScript($str);
        $returnStr .= '</script>';
        return $returnStr;
    }
Пример #4
0
    function showRemarkModal($queryobject, $qa, $current)
    {
        $params = array(POST_PARAM_DEFAULT_LANGUAGE => getDefaultSurveyLanguage(), POST_PARAM_DEFAULT_MODE => getDefaultSurveyMode(), POST_PARAM_LANGUAGE => getSurveyLanguage(), POST_PARAM_MODE => getSurveyMode(), POST_PARAM_GROUP => $this->engine->getTemplate(), POST_PARAM_TEMPLATE => getSurveyTemplate(), POST_PARAM_VERSION => getSurveyVersion(), POST_PARAM_STATEID => $this->engine->getStateId(), POST_PARAM_RGID => $this->engine->getRgid(), POST_PARAM_DISPLAYED => $this->engine->getDisplayed(), POST_PARAM_PRIMKEY => $this->engine->getPrimaryKey(), POST_PARAM_SUID => $this->engine->getSuid());
        $r = setSessionsParamString($params);
        $returnStr = minifyScript("<script type='text/javascript'>\n                            function storeRemark() { \n                                var val=\$('#remarkfield').val();\n                                if (val == '') {\n                                    if (\$('#uscic-remarkbutton').hasClass('uscic-remarkbutton-active') == true) {\n                                        \$('#uscic-remarkbutton').removeClass('uscic-remarkbutton-active');\n                                        \$('#" . POST_PARAM_REMARK_INDICATOR . "').val('');\n                                        \$.ajax({\n                                            type: 'POST',\n                                            url: 'ajax/index.php',\n                                            data: {p: 'removeremark', ajaxr: '" . $r . "'},\n                                            async: true\n                                          });\n                                     }\n                                }\n                                else {\n                                    \$('#uscic-remarkbutton').addClass('uscic-remarkbutton-active');\n                                    \$('#" . POST_PARAM_REMARK_INDICATOR . "').val(1);\n                                    \$.ajax({\n                                        type: 'POST',\n                                        url: 'ajax/index.php',\n                                        data: {p: 'storeremark', ajaxr: '" . $r . "', " . POST_PARAM_REMARK . ": encodeURIComponent(val)},\n                                        async: true\n                                      });\n                                }\n                            }</script>");
        $inlineclass = '';
        $returnStr .= '<div class="modal fade" id="remarkmodal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header uscic-modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
            <h4 class="modal-title" id="remarktitle">' . Language::remarkTitle() . '</h4>
            </div>
            <div class="modal-body">
                <h3>
                <div class="form-group uscic-formgroup' . $inlineclass . '">
                        <label>
                            <div class="uscic-remarkarea">
                                <textarea class="form-control uscic-form-control" id="remarkfield" name="remarkfield">' . $current . '</textarea>
                            </div>            
                        </label>
                </div>
                </h3>
            </div>';
        if ($queryobject->getShowCloseButton() == BUTTON_YES || $queryobject->getShowRemarkSaveButton() == BUTTON_YES) {
            $returnStr .= '<div class="panel-footer ' . $qa . ' uscic-buttonpanel">';
            if ($queryobject->getShowCloseButton() == BUTTON_YES) {
                $returnStr .= '<button type="button" class="btn btn-default" data-dismiss="modal">' . $queryobject->getLabelCloseButton() . '</button>';
            }
            if ($queryobject->getShowRemarkSaveButton() == BUTTON_YES) {
                $returnStr .= '<button type="button" class="btn btn-default" onclick=\'storeRemark(); $("#remarkmodal").modal("hide"); return false;\'>' . $queryobject->getLabelRemarkSaveButton() . '</button>';
            }
            $returnStr .= '</div>';
        }
        $returnStr .= '</div>
  </div>
</div>';
        return $returnStr;
    }
Пример #5
0
         }
     }
     $setting = new Setting();
     $this->addRuntimeSetting($index, $setting);
     return $setting;
     // db failed
 }
 function getSettingValueDirect($name, $mode, $language)
 {
     $index = strtoupper($name . $mode . $language . $this->getObjectType());
     if (isset($this->settings[$index])) {
         return $this->settings[$index]->getValue();
     }
     // check for current mode/default language
     $index = strtoupper($name . $mode . getDefaultSurveyLanguage() . $this->getObjectType());
     if (isset($this->settings[$index])) {
         return $this->settings[$index]->getValue();
     }
     // should we break mode below to find a setting value???
     // check for default mode/current language
     $index = strtoupper($name . getDefaultSurveyMode() . $language . $this->getObjectType());
     if (isset($this->settings[$index])) {
         return $this->settings[$index]->getValue();
     }