• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getDateFormatDataForQID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getDateFormatDataForQID函数的典型用法代码示例。如果您正苦于以下问题:PHP getDateFormatDataForQID函数的具体用法?PHP getDateFormatDataForQID怎么用?PHP getDateFormatDataForQID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getDateFormatDataForQID函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: insert


//.........这里部分代码省略.........
                     $fieldname = $irow['fieldname'];
                     if (isset($_POST[$fieldname])) {
                         if ($_POST[$fieldname] == "" && ($irow['type'] == 'D' || $irow['type'] == 'N' || $irow['type'] == 'K')) {
                             // can't add '' in Date column
                             // Do nothing
                         } else {
                             if ($irow['type'] == '|') {
                                 if (!strpos($irow['fieldname'], "_filecount")) {
                                     $json = $_POST[$fieldname];
                                     $phparray = json_decode(stripslashes($json));
                                     $filecount = 0;
                                     for ($i = 0; $filecount < count($phparray); $i++) {
                                         if ($_FILES[$fieldname . "_file_" . $i]['error'] != 4) {
                                             $target = Yii::app()->getConfig('uploaddir') . "/surveys/" . $thissurvey['sid'] . "/files/" . randomChars(20);
                                             $size = 0.001 * $_FILES[$fieldname . "_file_" . $i]['size'];
                                             $name = rawurlencode($_FILES[$fieldname . "_file_" . $i]['name']);
                                             if (move_uploaded_file($_FILES[$fieldname . "_file_" . $i]['tmp_name'], $target)) {
                                                 $phparray[$filecount]->filename = basename($target);
                                                 $phparray[$filecount]->name = $name;
                                                 $phparray[$filecount]->size = $size;
                                                 $pathinfo = pathinfo($_FILES[$fieldname . "_file_" . $i]['name']);
                                                 $phparray[$filecount]->ext = $pathinfo['extension'];
                                                 $filecount++;
                                             }
                                         }
                                     }
                                     $insert_data[$fieldname] = ls_json_encode($phparray);
                                 } else {
                                     $insert_data[$fieldname] = count($phparray);
                                 }
                             } elseif ($irow['type'] == 'D') {
                                 Yii::app()->loadLibrary('Date_Time_Converter');
                                 $qidattributes = getQuestionAttributeValues($irow['qid'], $irow['type']);
                                 $dateformatdetails = getDateFormatDataForQID($qidattributes, $thissurvey);
                                 $datetimeobj = new Date_Time_Converter($_POST[$fieldname], $dateformatdetails['phpdate']);
                                 $insert_data[$fieldname] = $datetimeobj->convert("Y-m-d H:i:s");
                             } else {
                                 $insert_data[$fieldname] = $_POST[$fieldname];
                             }
                         }
                     }
                 }
                 Survey_dynamic::sid($surveyid);
                 $new_response = new Survey_dynamic();
                 foreach ($insert_data as $column => $value) {
                     $new_response->{$column} = $value;
                 }
                 $new_response->save();
                 $last_db_id = $new_response->getPrimaryKey();
                 if (isset($_POST['closerecord']) && isset($_POST['token']) && $_POST['token'] != '') {
                     // get submit date
                     if (isset($_POST['closedate'])) {
                         $submitdate = $_POST['closedate'];
                     } else {
                         $submitdate = dateShift(date("Y-m-d H:i:s"), "Y-m-d", $timeadjust);
                     }
                     // check how many uses the token has left
                     $usesquery = "SELECT usesleft FROM {{tokens_}}{$surveyid} WHERE token='" . $_POST['token'] . "'";
                     $usesresult = dbExecuteAssoc($usesquery);
                     $usesrow = $usesresult->readAll();
                     //$usesresult->row_array()
                     if (isset($usesrow)) {
                         $usesleft = $usesrow[0]['usesleft'];
                     }
                     // query for updating tokens
                     $utquery = "UPDATE {{tokens_{$surveyid}}}\n";
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:67,代码来源:dataentry.php


示例2: getExtendedAnswer

/**
* @param integer $iSurveyID The Survey ID
* @param string $sFieldCode Field code of the particular field
* @param string $sValue The stored response value
* @param string $sLanguage Initialized limesurvey_lang object for the resulting response data
* @return string
*/
function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $sLanguage)
{
    if ($sValue == null || $sValue == '') {
        return '';
    }
    //Fieldcode used to determine question, $sValue used to match against answer code
    //Returns NULL if question type does not suit
    if (strpos($sFieldCode, "{$iSurveyID}X") === 0) {
        $fieldmap = createFieldMap($iSurveyID, 'short', false, false, $sLanguage);
        if (isset($fieldmap[$sFieldCode])) {
            $fields = $fieldmap[$sFieldCode];
        } else {
            return false;
        }
        // If it is a comment field there is nothing to convert here
        if ($fields['aid'] == 'comment') {
            return $sValue;
        }
        //Find out the question type
        $this_type = $fields['type'];
        switch ($this_type) {
            case 'D':
                if (trim($sValue) != '') {
                    $qidattributes = getQuestionAttributeValues($fields['qid']);
                    $dateformatdetails = getDateFormatDataForQID($qidattributes, $iSurveyID);
                    $sValue = convertDateTimeFormat($sValue, "Y-m-d H:i:s", $dateformatdetails['phpdate']);
                }
                break;
            case 'N':
                if (trim($sValue) != '') {
                    if (strpos($sValue, ".") !== false) {
                        $sValue = rtrim(rtrim($sValue, "0"), ".");
                    }
                    $qidattributes = getQuestionAttributeValues($fields['qid']);
                    if ($qidattributes['num_value_int_only']) {
                        $sValue = number_format($sValue, 0, '', '');
                    }
                }
                break;
            case "L":
            case "!":
            case "O":
            case "^":
            case "I":
            case "R":
                $result = Answer::model()->getAnswerFromCode($fields['qid'], $sValue, $sLanguage);
                foreach ($result as $row) {
                    $this_answer = $row['answer'];
                }
                // while
                if ($sValue == "-oth-") {
                    $this_answer = gT("Other", null, $sLanguage);
                }
                break;
            case "M":
            case "J":
            case "P":
                switch ($sValue) {
                    case "Y":
                        $this_answer = gT("Yes", null, $sLanguage);
                        break;
                }
                break;
            case "Y":
                switch ($sValue) {
                    case "Y":
                        $this_answer = gT("Yes", null, $sLanguage);
                        break;
                    case "N":
                        $this_answer = gT("No", null, $sLanguage);
                        break;
                    default:
                        $this_answer = gT("No answer", null, $sLanguage);
                }
                break;
            case "G":
                switch ($sValue) {
                    case "M":
                        $this_answer = gT("Male", null, $sLanguage);
                        break;
                    case "F":
                        $this_answer = gT("Female", null, $sLanguage);
                        break;
                    default:
                        $this_answer = gT("No answer", null, $sLanguage);
                }
                break;
            case "C":
                switch ($sValue) {
                    case "Y":
                        $this_answer = gT("Yes", null, $sLanguage);
                        break;
                    case "N":
//.........这里部分代码省略.........
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:101,代码来源:common_helper.php


示例3: do_date

function do_date($ia)
{
    global $thissurvey;
    $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]);
    $sDateLangvarJS = " translt = {\n         alertInvalidDate: '" . gT('Date entered is invalid!', 'js') . "',\n         infoCompleteAll: '" . gT('Please complete all parts of the date!', 'js') . "'\n        };";
    App()->getClientScript()->registerScript("sDateLangvarJS", $sDateLangvarJS, CClientScript::POS_HEAD);
    App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("generalscripts") . 'date.js');
    App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("third_party") . 'jstoolbox/date.js');
    $checkconditionFunction = "checkconditions";
    $dateformatdetails = getDateFormatDataForQID($aQuestionAttributes, $thissurvey);
    $numberformatdatat = getRadixPointData($thissurvey['surveyls_numberformat']);
    $sMindatetailor = '';
    $sMaxdatetailor = '';
    // date_min: Determine whether we have an expression, a full date (YYYY-MM-DD) or only a year(YYYY)
    if (trim($aQuestionAttributes['date_min']) != '') {
        $date_min = $aQuestionAttributes['date_min'];
        if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/", $date_min)) {
            $mindate = $date_min;
        } elseif (strlen($date_min) == 4 && $date_min >= 1900 && $date_min <= 2099) {
            // backward compatibility: if only a year is given, add month and day
            $mindate = $date_min . '-01-01';
        } else {
            $mindate = '{' . $aQuestionAttributes['date_min'] . '}';
            // get the LEMtailor ID, remove the span tags
            $sMindatespan = LimeExpressionManager::ProcessString($mindate, $ia[0], NULL, false, 1, 1);
            preg_match("/LEMtailor_Q_[0-9]{1,7}_[0-9]{1,3}/", $sMindatespan, $matches);
            if (isset($matches[0])) {
                $sMindatetailor = $matches[0];
            }
        }
    } else {
        $mindate = '1900-01-01';
    }
    // date_max: Determine whether we have an expression, a full date (YYYY-MM-DD) or only a year(YYYY)
    if (trim($aQuestionAttributes['date_max']) != '') {
        $date_max = $aQuestionAttributes['date_max'];
        if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/", $date_max)) {
            $maxdate = $date_max;
        } elseif (strlen($date_max) == 4 && $date_max >= 1900 && $date_max <= 2099) {
            // backward compatibility: if only a year is given, add month and day
            $maxdate = $date_max . '-12-31';
        } else {
            $maxdate = '{' . $aQuestionAttributes['date_max'] . '}';
            // get the LEMtailor ID, remove the span tags
            $sMaxdatespan = LimeExpressionManager::ProcessString($maxdate, $ia[0], NULL, false, 1, 1);
            preg_match("/LEMtailor_Q_[0-9]{1,7}_[0-9]{1,3}/", $sMaxdatespan, $matches);
            if (isset($matches[0])) {
                $sMaxdatetailor = $matches[0];
            }
        }
    } else {
        $maxdate = '2037-12-31';
    }
    if (trim($aQuestionAttributes['dropdown_dates']) == 1) {
        if (!empty($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]]) & $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]] != 'INVALID') {
            $datetimeobj = new Date_Time_Converter($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]], "Y-m-d H:i:s");
            $currentyear = $datetimeobj->years;
            $currentmonth = $datetimeobj->months;
            $currentdate = $datetimeobj->days;
            $currenthour = $datetimeobj->hours;
            $currentminute = $datetimeobj->minutes;
        } else {
            $currentdate = '';
            $currentmonth = '';
            $currentyear = '';
            $currenthour = '';
            $currentminute = '';
        }
        $dateorder = preg_split('/([-\\.\\/ :])/', $dateformatdetails['phpdate'], -1, PREG_SPLIT_DELIM_CAPTURE);
        $answer = '<p class="question answer-item dropdown-item date-item">';
        foreach ($dateorder as $datepart) {
            switch ($datepart) {
                // Show day select box
                case 'j':
                case 'd':
                    $answer .= '<label for="day' . $ia[1] . '" class="hide">' . gT('Day') . '</label><select id="day' . $ia[1] . '" name="day' . $ia[1] . '" class="day">
                    <option value="">' . gT('Day') . "</option>\n";
                    for ($i = 1; $i <= 31; $i++) {
                        if ($i == $currentdate) {
                            $i_date_selected = SELECTED;
                        } else {
                            $i_date_selected = '';
                        }
                        $answer .= '<option value="' . sprintf('%02d', $i) . '"' . $i_date_selected . '>' . sprintf('%02d', $i) . "</option>\n";
                    }
                    $answer .= '</select>';
                    break;
                    // Show month select box
                // Show month select box
                case 'n':
                case 'm':
                    $answer .= '<label for="month' . $ia[1] . '" class="hide">' . gT('Month') . '</label><select id="month' . $ia[1] . '" name="month' . $ia[1] . '" class="month">
                    <option value="">' . gT('Month') . "</option>\n";
                    switch ((int) trim($aQuestionAttributes['dropdown_dates_month_style'])) {
                        case 0:
                            $montharray = array(gT('Jan'), gT('Feb'), gT('Mar'), gT('Apr'), gT('May'), gT('Jun'), gT('Jul'), gT('Aug'), gT('Sep'), gT('Oct'), gT('Nov'), gT('Dec'));
                            break;
                        case 1:
                            $montharray = array(gT('January'), gT('February'), gT('March'), gT('April'), gT('May'), gT('June'), gT('July'), gT('August'), gT('September'), gT('October'), gT('November'), gT('December'));
                            break;
//.........这里部分代码省略.........
开发者ID:segfault,项目名称:LimeSurvey,代码行数:101,代码来源:qanda_helper.php


示例4: do_date

function do_date($ia)
{
    global $thissurvey;
    $aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]);
    $checkconditionFunction = "checkconditions";
    $dateformatdetails = getDateFormatDataForQID($aQuestionAttributes, $thissurvey);
    $numberformatdatat = getRadixPointData($thissurvey['surveyls_numberformat']);
    $inputnames = array();
    $sDateLangvarJS = " translt = {\n         alertInvalidDate: '" . gT('Date entered is invalid!', 'js') . "',\n        };";
    App()->getClientScript()->registerScript("sDateLangvarJS", $sDateLangvarJS, CClientScript::POS_HEAD);
    App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("generalscripts") . 'date.js');
    App()->getClientScript()->registerPackage('moment');
    // date_min: Determine whether we have an expression, a full date (YYYY-MM-DD) or only a year(YYYY)
    if (trim($aQuestionAttributes['date_min']) != '') {
        $date_min = trim($aQuestionAttributes['date_min']);
        $date_time_em = strtotime(LimeExpressionManager::ProcessString("{" . $date_min . "}", $ia[0]));
        if (ctype_digit($date_min) && strlen($date_min) == 4 && $date_min >= 1900 && $date_min <= 2099) {
            $mindate = $date_min . '-01-01';
            // backward compatibility: if only a year is given, add month and day
        } elseif (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/", $date_min)) {
            $mindate = $date_min;
        } elseif ($date_time_em) {
            $mindate = date("Y-m-d", $date_time_em);
        } else {
            $mindate = '{' . $aQuestionAttributes['date_min'] . '}';
        }
    } else {
        $mindate = '1900-01-01';
        // Why 1900 ?
    }
    // date_max: Determine whether we have an expression, a full date (YYYY-MM-DD) or only a year(YYYY)
    if (trim($aQuestionAttributes['date_max']) != '') {
        $date_max = trim($aQuestionAttributes['date_max']);
        $date_time_em = strtotime(LimeExpressionManager::ProcessString("{" . $date_max . "}", $ia[0]));
        if (ctype_digit($date_max) && strlen($date_max) == 4 && $date_max >= 1900 && $date_max <= 2099) {
            $maxdate = $date_max . '-12-31';
            // backward compatibility: if only a year is given, add month and day
        } elseif (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/", $date_max)) {
            $maxdate = $date_max;
        } elseif ($date_time_em) {
            $maxdate = date("Y-m-d", $date_time_em);
        } else {
            $maxdate = '{' . $aQuestionAttributes['date_max'] . '}';
        }
    } else {
        $maxdate = '2037-12-31';
        // Why 2037 ?
    }
    if (trim($aQuestionAttributes['dropdown_dates']) == 1) {
        if (!empty($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]]) && $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]] != 'INVALID') {
            $datetimeobj = new Date_Time_Converter($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]], "Y-m-d H:i:s");
            $currentyear = $datetimeobj->years;
            $currentmonth = $datetimeobj->months;
            $currentdate = $datetimeobj->days;
            $currenthour = $datetimeobj->hours;
            $currentminute = $datetimeobj->minutes;
        } else {
            // If date is invalid get the POSTED value
            $currentdate = App()->request->getPost("day{$ia[1]}", '');
            $currentmonth = App()->request->getPost("month{$ia[1]}", '');
            $currentyear = App()->request->getPost("year{$ia[1]}", '');
            $currenthour = App()->request->getPost("hour{$ia[1]}", '');
            $currentminute = App()->request->getPost("minute{$ia[1]}", '');
        }
        $dateorder = preg_split('/([-\\.\\/ :])/', $dateformatdetails['phpdate'], -1, PREG_SPLIT_DELIM_CAPTURE);
        $sRows = '';
        $montharray = array();
        foreach ($dateorder as $datepart) {
            switch ($datepart) {
                // Show day select box
                case 'j':
                case 'd':
                    $sRows .= doRender('/survey/questions/date/dropdown/rows/day', array('dayId' => $ia[1], 'currentdate' => $currentdate), true);
                    break;
                    // Show month select box
                // Show month select box
                case 'n':
                case 'm':
                    switch ((int) trim($aQuestionAttributes['dropdown_dates_month_style'])) {
                        case 0:
                            $montharray = array(gT('Jan'), gT('Feb'), gT('Mar'), gT('Apr'), gT('May'), gT('Jun'), gT('Jul'), gT('Aug'), gT('Sep'), gT('Oct'), gT('Nov'), gT('Dec'));
                            break;
                        case 1:
                            $montharray = array(gT('January'), gT('February'), gT('March'), gT('April'), gT('May'), gT('June'), gT('July'), gT('August'), gT('September'), gT('October'), gT('November'), gT('December'));
                            break;
                        case 2:
                            $montharray = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
                            break;
                    }
                    $sRows .= doRender('/survey/questions/date/dropdown/rows/month', array('monthId' => $ia[1], 'currentmonth' => $currentmonth, 'montharray' => $montharray), true);
                    break;
                    // Show year select box
                // Show year select box
                case 'y':
                case 'Y':
                    /*
                     * yearmin = Minimum year value for dropdown list, if not set default is 1900
                     * yearmax = Maximum year value for dropdown list, if not set default is 2037
                     * if full dates (format: YYYY-MM-DD) are given, only the year is used
                     * expressions are not supported because contents of dropbox cannot be easily updated dynamically
//.........这里部分代码省略.........
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:qanda_helper.php


示例5: _GetVarAttribute


//.........这里部分代码省略.........
                                 $ansArray = $var['ansArray'];
                                 if (is_null($ansArray)) {
                                     $shown = $code;
                                 } else {
                                     if (isset($ansArray[$which_ans])) {
                                         $answerInfo = explode('|', $ansArray[$which_ans]);
                                         array_shift($answerInfo);
                                         $answer = join('|', $answerInfo);
                                     } else {
                                         $answer = $code;
                                     }
                                     $shown = $answer;
                                 }
                             }
                         }
                         break;
                     case 'A':
                         //ARRAY (5 POINT CHOICE) radio-buttons
                     //ARRAY (5 POINT CHOICE) radio-buttons
                     case 'B':
                         //ARRAY (10 POINT CHOICE) radio-buttons
                     //ARRAY (10 POINT CHOICE) radio-buttons
                     case ':':
                         //ARRAY (Multi Flexi) 1 to 10
                     //ARRAY (Multi Flexi) 1 to 10
                     case '5':
                         //5 POINT CHOICE radio-buttons
                         $shown = $code;
                         break;
                     case 'D':
                         //DATE
                         $LEM =& LimeExpressionManager::singleton();
                         $aAttributes = $LEM->getQuestionAttributesForEM($LEM->sid, $var['qid'], $_SESSION['LEMlang']);
                         $aDateFormatData = getDateFormatDataForQID($aAttributes[$var['qid']], $LEM->surveyOptions);
                         $shown = '';
                         if (strtotime($code)) {
                             $shown = date($aDateFormatData['phpdate'], strtotime($code));
                         }
                         break;
                     case 'N':
                         //NUMERICAL QUESTION TYPE
                     //NUMERICAL QUESTION TYPE
                     case 'K':
                         //MULTIPLE NUMERICAL QUESTION
                     //MULTIPLE NUMERICAL QUESTION
                     case 'Q':
                         //MULTIPLE SHORT TEXT
                     //MULTIPLE SHORT TEXT
                     case ';':
                         //ARRAY (Multi Flexi) Text
                     //ARRAY (Multi Flexi) Text
                     case 'S':
                         //SHORT FREE TEXT
                     //SHORT FREE TEXT
                     case 'T':
                         //LONG FREE TEXT
                     //LONG FREE TEXT
                     case 'U':
                         //HUGE FREE TEXT
                     //HUGE FREE TEXT
                     case '*':
                         //Equation
                     //Equation
                     case 'I':
                         //Language Question
                     //Language Question
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:67,代码来源:em_manager_helper.php


示例6: getExtendedAnswer

/**
*
* @param type $iSurveyID The Survey ID
* @param type $sFieldCode Field code of the particular field
* @param type $sValue The stored response value
* @param object $oLanguage Initialized limesurvey_lang object for the resulting response data
* @return string
*/
function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $oLanguage)
{
    if (is_null($sValue) || $sValue == '') {
        return '';
    }
    $sLanguage = $oLanguage->langcode;
    //Fieldcode used to determine question, $sValue used to match against answer code
    //Returns NULL if question type does not suit
    if (strpos($sFieldCode, "{$iSurveyID}X") === 0) {
        $fieldmap = createFieldMap($iSurveyID, 'short', false, false, $sLanguage);
        if (isset($fieldmap[$sFieldCode])) {
            $fields = $fieldmap[$sFieldCode];
        } else {
            return false;
        }
        //Find out the question type
        $this_type = $fields['type'];
        switch ($this_type) {
            case 'D':
                if (trim($sValue) != '') {
                    $qidattributes = getQuestionAttributeValues($fields['qid']);
                    $dateformatdetails = getDateFormatDataForQID($qidattributes, $iSurveyID);
                    $sValue = convertDateTimeFormat($sValue, "Y-m-d H:i:s", $dateformatdetails['phpdate']);
                }
                break;
            case "L":
            case "!":
            case "O":
            case "^":
            case "I":
            case "R":
                $result = Answers::model()->getAnswerFromCode($fields['qid'], $sValue, $sLanguage) or die("Couldn't get answer type L - getAnswerCode()");
                //Checked
                foreach ($result as $row) {
                    $this_answer = $row['answer'];
                }
                // while
                if ($sValue == "-oth-") {
                    $this_answer = $oLanguage->gT("Other");
                }
                break;
            case "M":
            case "J":
            case "P":
                switch ($sValue) {
                    case "Y":
                        $this_answer = $oLanguage->gT("Yes");
                        break;
                }
                break;
            case "Y":
                switch ($sValue) {
                    case "Y":
                        $this_answer = $oLanguage->gT("Yes");
                        break;
                    case "N":
                        $this_answer = $oLanguage->gT("No");
                        break;
                    default:
                        $this_answer = $oLanguage->gT("No answer");
                }
                break;
            case "G":
                switch ($sValue) {
                    case "M":
                        $this_answer = $oLanguage->gT("Male");
                        break;
                    case "F":
                        $this_answer = $oLanguage->gT("Female");
                        break;
                    default:
                        $this_answer = $oLanguage->gT("No answer");
                }
                break;
            case "C":
                switch ($sValue) {
                    case "Y":
                        $this_answer = $oLanguage->gT("Yes");
                        break;
                    case "N":
                        $this_answer = $oLanguage->gT("No");
                        break;
                    case "U":
                        $this_answer = $oLanguage->gT("Uncertain");
                        break;
                }
                break;
            case "E":
                switch ($sValue) {
                    case "I":
                        $this_answer = $oLanguage->gT("Increase");
                        break;
//.........这里部分代码省略.........
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:101,代码来源:common_helper.php


示例7: ProcessCurrentResponses

 /**
  * Cleanse the $_POSTed data and update $_SESSION variables accordingly
  */
 static function ProcessCurrentResponses()
 {
     $LEM =& LimeExpressionManager::singleton();
     if (!isset($LEM->currentQset)) {
         return array();
     }
     $updatedValues = array();
     $radixchange = $LEM->surveyOptions['radix'] == ',' ? true : false;
     foreach ($LEM->currentQset as $qinfo) {
         $relevant = false;
         $qid = $qinfo['info']['qid'];
         $gseq = $qinfo['info']['gseq'];
         $relevant = isset($_POST['relevance' . $qid]) ? $_POST['relevance' . $qid] == 1 : false;
         $grelevant = isset($_POST['relevanceG' . $gseq]) ? $_POST['relevanceG' . $gseq] == 1 : false;
         $_SESSION[$LEM->sessid]['relevanceStatus'][$qid] = $relevant;
         $_SESSION[$LEM->sessid]['relevanceStatus']['G' . $gseq] = $grelevant;
         foreach (explode('|', $qinfo['sgqa']) as $sq) {
             $sqrelevant = true;
             if (isset($LEM->subQrelInfo[$qid][$sq]['rowdivid'])) {
                 $rowdivid = $LEM->subQrelInfo[$qid][$sq]['rowdivid'];
                 if ($rowdivid != '' && isset($_POST['relevance' . $rowdivid])) {
                     $sqrelevant = $_POST['relevance' . $rowdivid] == 1;
                     $_SESSION[$LEM->sessid]['relevanceStatus'][$rowdivid] = $sqrelevant;
                 }
             }
             $type = $qinfo['info']['type'];
             if ($relevant && $grelevant && $sqrelevant || !$LEM->surveyOptions['deletenonvalues']) {
                 if ($qinfo['info']['hidden'] && !isset($_POST[$sq])) {
                     $value = isset($_SESSION[$LEM->sessid][$sq]) ? $_SESSION[$LEM->sessid][$sq] : '';
                     // if always hidden, use the default value, if any
                 } else {
                     $value = isset($_POST[$sq]) ? $_POST[$sq] : '';
                 }
                 if ($radixchange && isset($LEM->knownVars[$sq]['onlynum']) && $LEM->knownVars[$sq]['onlynum'] == '1') {
                     // convert from comma back to decimal
                     $value = implode('.', explode(',', $value));
                 }
                 switch ($type) {
                     case 'D':
                         //DATE
                         if (trim($value) == "") {
                             $value = "";
                         } else {
                             $aAttributes = $LEM->getQuestionAttributesForEM($LEM->sid, $qid, $_SESSION['LEMlang']);
                             if (!isset($aAttributes[$qid])) {
                                 $aAttributes[$qid] = array();
                             }
                             $aDateFormatData = getDateFormatDataForQID($aAttributes[$qid], $LEM->surveyOptions);
                             $oDateTimeConverter = new Date_Time_Converter($value, $aDateFormatData['phpdate']);
                             $value = $oDateTimeConverter->convert("Y-m-d H:i");
                         }
                         break;
                     case 'N':
                         //NUMERICAL QUESTION TYPE
                     //NUMERICAL QUESTION TYPE
                     case 'K':
                         //MULTIPLE NUMERICAL QUESTION
                         if (trim($value) == "") {
                             $value = "";
                         } else {
                             $value = sanitize_float($value);
                         }
                         break;
                     case '|':
                         //File Upload
                         if (!preg_match('/_filecount$/', $sq)) {
                             $json = $value;
                             $phparray = json_decode(stripslashes($json));
                             // if the files have not been saved already,
                             // move the files from tmp to the files folder
                             $tmp = $LEM->surveyOptions['tempdir'] . 'upload' . DIRECTORY_SEPARATOR;
                             if (!is_null($phparray) && count($phparray) > 0) {
                                 // Move the (unmoved, temp) files from temp to files directory.
                                 // Check all possible file uploads
                                 for ($i = 0; $i < count($phparray); $i++) {
                                     if (file_exists($tmp . $phparray[$i]->filename)) {
                                         $sDestinationFileName = 'fu_' . randomChars(15);
                                         if (!is_dir($LEM->surveyOptions['target'])) {
                                             mkdir($LEM->surveyOptions['target'], 0777, true);
                                         }
                                         if (!rename($tmp . $phparray[$i]->filename, $LEM->surveyOptions['target'] . $sDestinationFileName)) {
                                             echo "Error moving file to target destination";
                                         }
                                         $phparray[$i]->filename = $sDestinationFileName;
                                     }
                                 }
                                 $value = ls_json_encode($phparray);
                                 // so that EM doesn't try to parse it.
                             }
                         }
                         break;
                 }
                 $_SESSION[$LEM->sessid][$sq] = $value;
                 $_update = array('type' => $type, 'value' => $value);
                 $updatedValues[$sq] = $_update;
                 $LEM->updatedValues[$sq] = $_update;
             } else {
//.........这里部分代码省略.........
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:101,代码来源:em_manager_helper.php


示例8: getDateFormatDataForQID

            echo $x;
            ?>
'><?php 
            echo $x;
            ?>
</option>
                    <?php 
        }
        ?>
            </select>
            <?php 
        break;
    case "D":
        //DATE
        //                            $qidattributes = getQuestionAttributeValues($deqrow['qid'], $deqrow['type']);
        $dateformatdetails = getDateFormatDataForQID($qidattributes, $thissurvey);
        if (canShowDatePicker($dateformatdetails)) {
            $goodchars = str_replace(array("m", "d", "y", "H", "M"), "", $dateformatdetails['dateformat']);
            $goodchars = "0123456789" . $goodchars[0];
            ?>
                <input type='text' class='popupdate' size='12' name='<?php 
            echo $fieldname;
            ?>
' onkeypress="return goodchars(event,'<?php 
            echo $goodchars;
            ?>
')"/>
                <input type='hidden' name='dateformat<?php 
            echo $fieldname;
            ?>
' id='dateformat<?php 
开发者ID:withhope,项目名称:HIT-Survey,代码行数:31,代码来源:content_view.php


示例9: aCheckInput

function aCheckInput($surveyid, $move, $backok = null)
{
    global $thisstep, $thissurvey;
    if (!isset($backok) || $backok != "Y") {
        $fieldmap = createFieldMap($surveyid, 'full', false, false, $_SESSION['survey_' . $surveyid]['s_lang']);
        if (isset($_POST['fieldnames'])) {
            $fields = explode("|", $_POST['fieldnames']);
            foreach ($fields as $field) {
                //Get question information
                if (isset($_POST[$field]) && isset($_SESSION['survey_' . $surveyid]['s_lang']) && ($_POST[$field] == "0" || $_POST[$field])) {
                    $fieldinfo = $fieldmap[$field];
                    $pregquery = "SELECT preg\n" . "FROM {{questions}}\n" . "WHERE qid=" . $fieldinfo['qid'] . " " . "AND language='" . $_SESSION['survey_' . $surveyid]['s_lang'] . "'";
                    $pregresult = dbExecuteAssoc($pregquery) or safeDie("ERROR: {$pregquery}<br />");
                    //Checked
                    foreach ($pregresult->readAll() as $pregrow) {
                        $preg = trim($pregrow['preg']);
                    }
                    // while
                    if (isset($preg) && $preg) {
                        if (!@preg_match($preg, $_POST[$field])) {
                            $notvalidated[] = $field;
                            continue;
                        }
                    }
                    // check for other question attributes
                    $qidattributes = getQuestionAttributeValues($fieldinfo['qid'], $fieldinfo['type']);
                    if ($fieldinfo['type'] == 'N') {
                        $neg = true;
                        if (trim($qidattributes['max_num_value_n']) != '' && $qidattributes['max_num_value_n'] >= 0) {
                            $neg = false;
                        }
                        if (trim($qidattributes['num_value_int_only']) == 1 && !preg_match("/^" . ($neg ? "-?" : "") . "[0-9]+\$/", $_POST[$field])) {
                            $notvalidated[] = $field;
                            continue;
                        }
                        if (trim($qidattributes['max_num_value_n']) != '' && $_POST[$field] > $qidattributes['max_num_value_n']) {
                            $notvalidated[] = $field;
                            continue;
                        }
                        if (trim($qidattributes['min_num_value_n']) != '' && $_POST[$field] < $qidattributes['min_num_value_n']) {
                            $notvalidated[] = $field;
                            continue;
                        }
                    } elseif ($fieldinfo['type'] == 'D') {
                        // $_SESSION['survey_'.$surveyid][$fieldinfo['fieldname']] now contains the crappy value parsed by
                        // Date_Time_Converter in save.php. We can leave it there. We just do validation here.
                        $dateformatdetails = getDateFormatDataForQID($qidattributes, $thissurvey);
                        $datetimeobj = DateTime::createFromFormat($dateformatdetails['phpdate'], $_POST[$field]);
                        if (!$datetimeobj) {
                            $notvalidated[] = $field;
                            continue;
                        }
                    }
                }
            }
        }
        //The following section checks for question attribute validation, looking for values in a particular field
        if (isset($_POST['qattribute_answer'])) {
            foreach ($_POST['qattribute_answer'] as $maxvalueanswer) {
                //$maxvalue_answername="maxvalue_answer".$maxvalueanswer;
                if (!empty($_POST['qattribute_answer' . $maxvalueanswer]) && $_POST['display' . $maxvalueanswer] == "on") {
                    $_SESSION['survey_' . $surveyid]['step'] = $thisstep;
                    $notvalidated[] = $maxvalueanswer;
                    return $notvalidated;
                }
            }
        }
        if (isset($notvalidated) && is_array($notvalidated)) {
            if (isset($move) && $move == "moveprev") {
                $_SESSION['survey_' . $surveyid]['step'] = $thisstep;
            }
            if (isset($move) && $move == "movenext") {
                $_SESSION['survey_' . $surveyid]['step'] = $thisstep;
            }
            return $notvalidated;
        }
    }
}
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:78,代码来源:frontend_helper.php


示例10: do_date

function do_date($ia)
{
    global $thissurvey;
    header_includes(Yii::app()->getConfig("generalscripts") . 'date.js', 'js');
    $clang = Yii::app()->lang;
    $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]);
    $checkconditionFunction = "checkconditions";
    $dateformatdetails = getDateFormatDataForQID($aQuestionAttributes, $thissurvey);
    $numberformatdatat = getRadixPointData($thissurvey['surveyls_numberformat']);
    if (trim($aQuestionAttributes['dropdown_dates']) == 1) {
        if (!empty($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]])) {
            $datetimeobj = getdate(DateTime::createFromFormat("Y-m-d H:i:s", $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]])->getTimeStamp());
            $currentyear = $datetimeobj['year'];
            $currentmonth = $datetimeobj['mon'];
            $currentdate = $datetimeobj['mday'];
            $currenthour = $datetimeobj['hours'];
            $currentminute = $datetimeobj['minutes'];
        } else {
            $currentdate = '';
            $currentmonth = '';
            $currentyear = '';
            $currenthour = '';
            $currentminute = '';
        }
        $dateorder = preg_split('/([-\\.\\/ :])/', $dateformatdetails['phpdate'], -1, PREG_SPLIT_DELIM_CAPTURE);
        $answer = '<p class="question answer-item dropdown-item date-item">';
        foreach ($dateorder as $datepart) {
            switch ($datepart) {
                // Show day select box
                case 'j':
                case 'd':
                    $answer .= '<label for="day' . $ia[1] . '" class="hide">' . $clang->gT('Day') . '</label><select id="day' . $ia[1] . '" name="day' . $ia[1] . '" class="day">
                    <option value="">' . $clang->gT('Day') . "</option>\n";
                    for ($i = 1; $i <= 31; $i++) {
                        if ($i == $currentdate) {
                            $i_date_selected = SELECTED;
                        } else {
                            $i_date_selected = '';
                        }
                        $answer .= '<option value="' . sprintf('%02d', $i) . '"' . $i_date_selected . '>' . sprintf('%02d', $i) . "</option>\n";
                    }
                    $answer .= '</select>';
                    break;
                    // Show month select box
                // Show month select box
                case 'n':
                case 'm':
                    $answer .= '<label for="month' . $ia[1] . '" class="hide">' . $clang->gT('Month') . '</label><select id="month' . $ia[1] . '" name="month' . $ia[1] . '" class="month">
                    <option value="">' . $clang->gT('Month') . "</option>\n";
                    $montharray = array($clang->gT('Jan'), $clang->gT('Feb'), $clang->gT('Mar'), $clang->gT('Apr'), $clang->gT('May'), $clang->gT('Jun'), $clang->gT('Jul'), $clang->gT('Aug'), $clang->gT('Sep'), $clang->gT('Oct'), $clang->gT('Nov'), $clang->gT('Dec'));
                    for ($i = 1; $i <= 12; $i++) {
                        if ($i == $currentmonth) {
                            $i_date_selected = SELECTED;
                        } else {
                            $i_date_selected = '';
                        }
                        $answer .= '<option value="' . sprintf('%02d', $i) . '"' . $i_date_selected . '>' . $montharray[$i - 1] . '</option>';
                    }
                    $answer .= '</select>';
                    break;
                    // Show year select box
                // Show year select box
                case 'Y':
                    $answer .= '<label for="year' . $ia[1] . '" class="hide">' . $clang->gT('Year') . '</label><select id="year' . $ia[1] . '" name="year' . $ia[1] . '" class="year">
                    <option value="">' . $clang->gT('Year') . '</option>';
                    /*
                     *  New question attributes used only if question attribute
                     * "dropdown_dates" is used (see IF(...) above).
                     *
                     * yearmin = Minimum year value for dropdown list, if not set default is 1900
                     * yearmax = Maximum year value for dropdown list, if not set default is 2020
                     */
                    if (trim($aQuestionAttributes['dropdown_dates_year_min']) != '') {
                        $yearmin = $aQuestionAttributes['dropdown_dates_year_min'];
                    } else {
                        $yearmin = 1900;
                    }
                    if (trim($aQuestionAttributes['dropdown_dates_year_max']) != '') {
                        $yearmax = $aQuestionAttributes['dropdown_dates_year_max'];
                    } else {
                        $yearmax = 2020;
                    }
                    if ($yearmin > $yearmax) {
                        $yearmin = 1900;
                        $yearmax = 2020;
                    }
                    if ($aQuestionAttributes['reverse'] == 1) {
                        $tmp = $yearmin;
                        $yearmin = $yearmax;
                        $yearmax = $tmp;
                        $step = 1;
                        $reverse = true;
                    } else {
                        $step = -1;
                        $reverse = false;
                    }
                    for ($i = $yearmax; $reverse ? $i <= $yearmin : $i >= $yearmin; $i += $step) {
                        if ($i == $currentyear) {
                            $i_date_selected = SELECTED;
                        } else {
//.........这里部分代码省略.........
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:101,代码来源:qanda_helper.php



注:本文中的getDateFormatDataForQID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getDateFormate函数代码示例发布时间:2022-05-15
下一篇:
PHP getDateFormatData函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap