本文整理汇总了PHP中Date_Time_Converter类的典型用法代码示例。如果您正苦于以下问题:PHP Date_Time_Converter类的具体用法?PHP Date_Time_Converter怎么用?PHP Date_Time_Converter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Date_Time_Converter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templatereplace
//.........这里部分代码省略.........
}
if (isset($_SESSION['therearexquestions'])) {
$_totalquestionsAsked = $_SESSION['therearexquestions'] - $totalBoilerplatequestions;
} else {
$_totalquestionsAsked = 0;
}
if ($showxquestions == 'show' || $showxquestions == 'choose' && !isset($thissurvey['showxquestions']) || $showxquestions == 'choose' && $thissurvey['showxquestions'] == 'Y') {
if ($_totalquestionsAsked < 1) {
$_therearexquestions = $clang->gT("There are no questions in this survey");
// Singular
} elseif ($_totalquestionsAsked == 1) {
$_therearexquestions = $clang->gT("There is 1 question in this survey");
//Singular
} else {
$_therearexquestions = $clang->gT("There are {NUMBEROFQUESTIONS} questions in this survey.");
//Note this line MUST be before {NUMBEROFQUESTIONS}
}
} else {
$_therearexquestions = '';
}
if (isset($token)) {
$_token = $token;
} elseif (isset($clienttoken)) {
$_token = htmlentities($clienttoken, ENT_QUOTES, 'UTF-8');
} else {
$_token = '';
}
if (isset($thissurvey['surveyls_dateformat'])) {
$dateformatdetails = getDateFormatData($thissurvey['surveyls_dateformat']);
} else {
$dateformatdetails = getDateFormatData();
}
if (isset($thissurvey['expiry'])) {
$_datetimeobj = new Date_Time_Converter($thissurvey['expiry'], "Y-m-d");
$_dateoutput = $_datetimeobj->convert($dateformatdetails['phpdate']);
} else {
$_dateoutput = '-';
}
$_submitbutton = "<input class='submit' type='submit' value=' " . $clang->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($clienttoken)) {
$token = $clienttoken;
} else {
$token = '';
}
if (!isset($_SESSION['s_lang'])) {
$_s_lang = 'en';
} else {
$_s_lang = $_SESSION['s_lang'];
}
// CLEARALL
if ($surveyid && !isCompleted($surveyid, $saved_id)) {
$_clearall = "<input type='button' name='clearallbtn' value='" . $clang->gT("Exit and Clear Survey") . "' class='clearall' " . "onclick=\"if (confirm('" . $clang->gT("Are you sure you want to clear all your responses?", 'js') . "')) {\nwindow.open('{$publicurl}/index.php?sid={$surveyid}&move=clearall&lang=" . $_s_lang;
if (returnglobal('token')) {
$_clearall .= "&token={$_token}";
}
$_clearall .= "', '_self')}\" />";
} else {
示例2: 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;
//.........这里部分代码省略.........
示例3: templatereplace
//.........这里部分代码省略.........
}
if (!($showqnumcode == 'both' || $showqnumcode == 'code' || $showqnumcode == 'choose' && !isset($thissurvey['showqnumcode']) || $showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B' || $showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'C')) {
$_question_code = '';
}
if (!isset($totalquestions)) {
$totalquestions = 0;
}
$_totalquestionsAsked = $totalquestions;
if ($showxquestions == 'show' || $showxquestions == 'choose' && !isset($thissurvey['showxquestions']) || $showxquestions == 'choose' && $thissurvey['showxquestions'] == 'Y') {
if ($_totalquestionsAsked < 1) {
$_therearexquestions = $clang->gT("There are no questions in this survey");
// Singular
} elseif ($_totalquestionsAsked == 1) {
$_therearexquestions = $clang->gT("There is 1 question in this survey");
//Singular
} else {
$_therearexquestions = $clang->gT("There are {NUMBEROFQUESTIONS} questions in this survey.");
//Note this line MUST be before {NUMBEROFQUESTIONS}
}
} else {
$_therearexquestions = '';
}
if (isset($token)) {
$_token = $token;
} elseif (isset($clienttoken)) {
$_token = htmlentities($clienttoken, ENT_QUOTES, 'UTF-8');
// or should it be URL-encoded?
} else {
$_token = '';
}
// Expiry
if (isset($thissurvey['expiry'])) {
$dateformatdetails = getDateFormatData($thissurvey['surveyls_dateformat']);
Yii::import('application.libraries.Date_Time_Converter', true);
$datetimeobj = new Date_Time_Converter($thissurvey['expiry'], "Y-m-d");
$_dateoutput = $datetimeobj->convert($dateformatdetails['phpdate']);
} else {
$_dateoutput = '-';
}
$_submitbutton = "<input class='submit' type='submit' value=' " . $clang->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 = Survey_dynamic::model($surveyid)->isCompleted($_SESSION['survey_' . $thissurvey['sid']]['srid']);
} else {
$iscompleted = false;
}
if (isset($surveyid) && !$iscompleted) {
$_clearall = "<input type='button' name='clearallbtn' value='" . $clang->gT("Exit and clear survey") . "' class='clearall' " . "onclick=\"if (confirm('" . $clang->gT("Are you sure you want to clear all your responses?", 'js') . "')) {\nwindow.open('" . Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}", array('move' => 'clearall', 'lang' => $s_lang), '&');
if (returnGlobal('token')) {
$_clearall .= "&token=" . urlencode(trim(sanitize_token(strip_tags(returnGlobal('token')))));
}
$_clearall .= "', '_self')}\" />";
} else {
$_clearall = "";
}
if (isset(Yii::app()->session['datestamp'])) {
$_datestamp = Yii::app()->session['datestamp'];
} else {
示例4: generate_statistics
//.........这里部分代码省略.........
}
//D - Date
elseif ($firstletter == "D" && $_POST[$pv] != "")
{
//Date equals
if (substr($pv, -1, 1) == "=")
{
$selects[]=db_quote_id(substr($pv, 1, strlen($pv)-2))." = '".$_POST[$pv]."'";
}
else
{
//date less than
if (substr($pv, -1, 1) == "<")
{
$selects[]= db_quote_id(substr($pv, 1, strlen($pv)-2)) . " >= '".$_POST[$pv]."'";
}
//date greater than
if (substr($pv, -1, 1) == ">")
{
$selects[]= db_quote_id(substr($pv, 1, strlen($pv)-2)) . " <= '".$_POST[$pv]."'";
}
}
}
//check for datestamp of given answer
elseif (substr($pv, 0, 9) == "datestamp")
{
//timestamp equals
$formatdata=getDateFormatData($_SESSION['dateformat']);
if (substr($pv, -1, 1) == "E" && !empty($_POST[$pv]))
{
$datetimeobj = new Date_Time_Converter($_POST[$pv], $formatdata['phpdate'].' H:i');
$_POST[$pv]=$datetimeobj->convert("Y-m-d");
$selects[] = db_quote_id('datestamp')." >= '".$_POST[$pv]." 00:00:00' and ".db_quote_id('datestamp')." <= '".$_POST[$pv]." 23:59:59'";
}
else
{
//timestamp less than
if (substr($pv, -1, 1) == "L" && !empty($_POST[$pv]))
{
$datetimeobj = new Date_Time_Converter($_POST[$pv], $formatdata['phpdate'].' H:i');
$_POST[$pv]=$datetimeobj->convert("Y-m-d H:i:s");
$selects[]= db_quote_id('datestamp')." < '".$_POST[$pv]."'";
}
//timestamp greater than
if (substr($pv, -1, 1) == "G" && !empty($_POST[$pv]))
{
$datetimeobj = new Date_Time_Converter($_POST[$pv], $formatdata['phpdate'].' H:i');
$_POST[$pv]=$datetimeobj->convert("Y-m-d H:i:s");
$selects[]= db_quote_id('datestamp')." > '".$_POST[$pv]."'";
}
}
}
}
else
{
$statisticsoutput .= "<!-- $pv DOES NOT EXIST IN ARRAY -->";
}
} //end foreach -> loop through filter options to create SQL
//count number of answers
示例5: addDummies
/**
* Add dummy tokens form
*/
function addDummies($iSurveyId, $subaction = '')
{
$iSurveyId = sanitize_int($iSurveyId);
$clang = $this->getController()->lang;
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'create')) {
Yii::app()->session['flashmessage'] = $clang->gT("You do not have sufficient rights to access this page.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
$bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
if (!$bTokenExists) {
self::_newtokentable($iSurveyId);
}
$this->getController()->loadHelper("surveytranslator");
if (!empty($subaction) && $subaction == 'add') {
$this->getController()->loadLibrary('Date_Time_Converter');
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
//Fix up dates and match to database format
if (trim(Yii::app()->request->getPost('validfrom')) == '') {
$_POST['validfrom'] = null;
} else {
$datetimeobj = new Date_Time_Converter(trim(Yii::app()->request->getPost('validfrom')), $dateformatdetails['phpdate'] . ' H:i');
$_POST['validfrom'] = $datetimeobj->convert('Y-m-d H:i:s');
}
if (trim(Yii::app()->request->getPost('validuntil')) == '') {
$_POST['validuntil'] = null;
} else {
$datetimeobj = new Date_Time_Converter(trim(Yii::app()->request->getPost('validuntil')), $dateformatdetails['phpdate'] . ' H:i');
$_POST['validuntil'] = $datetimeobj->convert('Y-m-d H:i:s');
}
$santitizedtoken = '';
$aData = array('firstname' => Yii::app()->request->getPost('firstname'), 'lastname' => Yii::app()->request->getPost('lastname'), 'email' => Yii::app()->request->getPost('email'), 'emailstatus' => 'OK', 'token' => $santitizedtoken, 'language' => sanitize_languagecode(Yii::app()->request->getPost('language')), 'sent' => 'N', 'remindersent' => 'N', 'completed' => 'N', 'usesleft' => Yii::app()->request->getPost('usesleft'), 'validfrom' => Yii::app()->request->getPost('validfrom'), 'validuntil' => Yii::app()->request->getPost('validuntil'));
// add attributes
$attrfieldnames = getTokenFieldsAndNames($iSurveyId, true);
foreach ($attrfieldnames as $attr_name => $desc) {
$value = Yii::app()->request->getPost($attr_name);
if ($desc['mandatory'] == 'Y' && trim($value) == '') {
$this->getController()->error(sprintf($clang->gT('%s cannot be left empty'), $desc['description']));
}
$aData[$attr_name] = Yii::app()->request->getPost($attr_name);
}
$amount = sanitize_int(Yii::app()->request->getPost('amount'));
$tokenlength = sanitize_int(Yii::app()->request->getPost('tokenlen'));
// Fill an array with all existing tokens
$existingtokens = array();
$tokenModel = Token::model($iSurveyId);
$criteria = $tokenModel->getDbCriteria();
$criteria->select = 'token';
$criteria->distinct = true;
$command = $tokenModel->getCommandBuilder()->createFindCommand($tokenModel->getTableSchema(), $criteria);
$result = $command->query();
while ($tokenRow = $result->read()) {
$existingtokens[$tokenRow['token']] = true;
}
$result->close();
$invalidtokencount = 0;
$newDummyToken = 0;
while ($newDummyToken < $amount && $invalidtokencount < 50) {
$token = Token::create($iSurveyId);
$token->setAttributes($aData, false);
$token->firstname = str_replace('{TOKEN_COUNTER}', $newDummyToken, $token->firstname);
$token->lastname = str_replace('{TOKEN_COUNTER}', $newDummyToken, $token->lastname);
$token->email = str_replace('{TOKEN_COUNTER}', $newDummyToken, $token->email);
$attempts = 0;
do {
$token->token = randomChars($tokenlength);
$attempts++;
} while (isset($existingtokens[$token->token]) && $attempts < 50);
if ($attempts == 50) {
throw new Exception('Something is wrong with your random generator.');
}
$existingtokens[$token->token] = true;
$token->save();
$newDummyToken++;
}
$aData['thissurvey'] = getSurveyInfo($iSurveyId);
$aData['surveyid'] = $iSurveyId;
if (!$invalidtokencount) {
$aData['success'] = false;
$message = array('title' => $clang->gT("Success"), 'message' => $clang->gT("New dummy tokens were added.") . "<br /><br />\n<input type='button' value='" . $clang->gT("Display tokens") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/browse/surveyid/{$iSurveyId}") . "', '_top')\" />\n");
} else {
$aData['success'] = true;
$message = array('title' => $clang->gT("Failed"), 'message' => "<p>" . sprintf($clang->gT("Only %s new dummy tokens were added after %s trials."), $newDummyToken, $invalidtokencount) . $clang->gT("Try with a bigger token length.") . "</p>" . "\n<input type='button' value='" . $clang->gT("Display tokens") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/browse/surveyid/{$iSurveyId}") . "', '_top')\" />\n");
}
$this->_renderWrappedTemplate('token', array('tokenbar', 'message' => $message), $aData);
} else {
$tokenlength = !empty(Token::model($iSurveyId)->survey->tokenlength) ? Token::model($iSurveyId)->survey->tokenlength : 15;
$thissurvey = getSurveyInfo($iSurveyId);
$aData['thissurvey'] = $thissurvey;
$aData['surveyid'] = $iSurveyId;
$aData['tokenlength'] = $tokenlength;
$aData['dateformatdetails'] = getDateFormatData(Yii::app()->session['dateformat'], $clang->langcode);
$aData['aAttributeFields'] = GetParticipantAttributes($iSurveyId);
$this->_renderWrappedTemplate('token', array('tokenbar', 'dummytokenform'), $aData);
}
}
示例6: htmlspecialchars
$hh = htmlspecialchars($hh, ENT_QUOTES);
//Change & " ' < > to HTML entities to make HTML happy.
$dataentryoutput .= "\t<img src='{$imageurl}/help.gif' alt='" . $blang->gT("Help about this question") . "' align='right' onclick=\"javascript:alert('Question {$deqrow['title']} Help: {$hh}')\" />\n";
}
switch ($deqrow['type']) {
case "5":
//5 POINT CHOICE radio-buttons
$dataentryoutput .= "\t<select name='{$fieldname}'>\n" . "<option value=''>" . $blang->gT("No answer") . "</option>\n";
for ($x = 1; $x <= 5; $x++) {
$dataentryoutput .= "<option value='{$x}'>{$x}</option>\n";
}
$dataentryoutput .= "\t</select>\n";
break;
case "D":
//DATE
$datetimeobj = new Date_Time_Converter('', "Y-m-d H:i:s");
$thisdate = $datetimeobj->convert($dateformatdetails['phpdate']);
$dataentryoutput .= "\t<input type='text' class='popupdate' size='12' name='{$fieldname}'/>\n";
break;
case "G":
//GENDER drop-down list
$dataentryoutput .= "\t<select name='{$fieldname}'>\n" . "<option selected='selected' value=''>" . $blang->gT("Please choose") . "..</option>\n" . "<option value='F'>" . $blang->gT("Female") . "</option>\n" . "<option value='M'>" . $blang->gT("Male") . "</option>\n" . "\t</select>\n";
break;
case "Q":
//MULTIPLE SHORT TEXT
//MULTIPLE SHORT TEXT
case "K":
$deaquery = "SELECT question,title FROM " . db_table_name("questions") . " WHERE parent_qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}' ORDER BY question_order";
$dearesult = db_execute_assoc($deaquery);
$dataentryoutput .= "\t<table>\n";
while ($dearow = $dearesult->FetchRow()) {
示例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) {
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 {
$dateformatdatat = getDateFormatData($LEM->surveyOptions['surveyls_dateformat']);
$datetimeobj = new Date_Time_Converter($value, $dateformatdatat['phpdate']);
$value = $datetimeobj->convert("Y-m-d");
}
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 {
// irrelevant, so database will be NULLed separately
// Must unset the value, rather than setting to '', so that EM can re-use the default value as needed.
unset($_SESSION[$LEM->sessid][$sq]);
$_update = array('type' => $type, 'value' => NULL);
//.........这里部分代码省略.........
示例8: convertDateTimeFormat
/**
* This is a convenience function for the coversion of datetime values
*
* @param mixed $value
* @param mixed $fromdateformat
* @param mixed $todateformat
* @return string
*/
function convertDateTimeFormat($value, $fromdateformat, $todateformat)
{
$datetimeobj = new Date_Time_Converter($value, $fromdateformat);
return $datetimeobj->convert($todateformat);
}
示例9: eT
<label class="col-sm-2 control-label" for='usesleft'><?php eT("Uses left:"); ?></label>
<div class="col-sm-10">
<input type='text' size='20' id='usesleft' name='usesleft' value="1" />
</div>
</div>
<!-- Validity -->
<div class="form-group">
<label class="col-sm-2 control-label" for='validfrom'><?php eT("Valid from"); ?>:</label>
<div class="col-sm-3">
<input type='text' class='popupdatetime' size='20' id='validfrom' name='validfrom' value="<?php if (isset($validfrom)){$datetimeobj = new Date_Time_Converter($validfrom, "Y-m-d H:i:s");echo $datetimeobj->convert($dateformatdetails['phpdate'] . ' H:i');}?>" />
</div>
<label class="col-sm-2 control-label" for='validuntil'><?php eT('until'); ?></label>
<div class="col-sm-3">
<input type='text' size='20' id='validuntil' name='validuntil' class='popupdatetime' value="<?php if (isset($validuntil)){$datetimeobj = new Date_Time_Converter($validuntil, "Y-m-d H:i:s");echo $datetimeobj->convert($dateformatdetails['phpdate'] . ' H:i');}?>" />
<span class="help-block"><?php printf(gT('Format: %s'), $dateformatdetails['dateformat'] . ' ' . gT('hh:mm')); ?></span>
</div>
</div>
<!-- Attribute fields -->
<?php foreach ($aAttributeFields as $attr_name => $attr_description): ?>
<div class="form-group">
<label class="col-sm-2 control-label" for='<?php echo $attr_name; ?>'><?php echo $attr_description['description'] . ($attr_description['mandatory'] == 'Y' ? '*' : '') ?>:</label>
<div class="col-sm-10">
<input type='text' size='55' id='<?php echo $attr_name; ?>' name='<?php echo $attr_name; ?>' value='<?php if (isset($$attr_name)){echo htmlspecialchars($$attr_name, ENT_QUOTES, 'UTF-8');}?>' />
</div>
</div>
<?php endforeach; ?>
<!-- Buttons -->
示例10: do_date
//.........这里部分代码省略.........
}
if ($yearmin > $yearmax)
{
$yearmin = 1900;
$yearmax = 2020;
}
if ($qidattributes['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
{
$i_date_selected = '';
}
$answer .= ' <option value="'.$i.'"'.$i_date_selected.'>'.$i.'</option>';
}
$answer .= '</select>';
break;
}
}
$answer .= '<input class="text" type="text" size="10" name="'.$ia[1].'" style="display: none" id="answer'.$ia[1].'" value="'.$_SESSION[$ia[1]].'" maxlength="10" alt="'.$clang->gT('Answer').'" onchange="'.$checkconditionFunction.'(this.value, this.name, this.type)" />
</p>';
$answer .= '<input type="hidden" name="qattribute_answer[]" value="'.$ia[1].'" />
<input type="hidden" id="qattribute_answer'.$ia[1].'" name="qattribute_answer'.$ia[1].'" />
<input type="hidden" id="dateformat'.$ia[1].'" value="'.$dateformatdetails['jsdate'].'"/>';
}
else
{
if ($clang->langcode !== 'en')
{
$js_header_includes[] = '/scripts/jquery/locale/jquery.ui.datepicker-'.$clang->langcode.'.js';
}
$css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css';
// Format the date for output
if (trim($_SESSION[$ia[1]])!='')
{
$datetimeobj = new Date_Time_Converter($_SESSION[$ia[1]] , "Y-m-d");
$dateoutput=$datetimeobj->convert($dateformatdetails['phpdate']);
}
else
{
$dateoutput='';
}
if (trim($qidattributes['dropdown_dates_year_min'])!='') {
$minyear=$qidattributes['dropdown_dates_year_min'];
}
else
{
$minyear='1980';
}
if (trim($qidattributes['dropdown_dates_year_max'])!='') {
$maxyear=$qidattributes['dropdown_dates_year_max'];
}
else
{
$maxyear='2020';
}
$goodchars = str_replace( array("m","d","y"), "", $dateformatdetails['jsdate']);
$goodchars = "0123456789".$goodchars[0];
$answer ="<p class=\"question\">
<input class='popupdate' type=\"text\" alt=\"".$clang->gT('Date picker')."\" size=\"10\" name=\"{$ia[1]}\" id=\"answer{$ia[1]}\" value=\"$dateoutput\" maxlength=\"10\" onkeypress=\"return goodchars(event,'".$goodchars."')\" onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" />
<input type='hidden' name='dateformat{$ia[1]}' id='dateformat{$ia[1]}' value='{$dateformatdetails['jsdate']}' />
<input type='hidden' name='datelanguage{$ia[1]}' id='datelanguage{$ia[1]}' value='{$clang->langcode}' />
<input type='hidden' name='dateyearrange{$ia[1]}' id='dateyearrange{$ia[1]}' value='{$minyear}:{$maxyear}' />
</p>
<p class=\"tip\">
".sprintf($clang->gT('Format: %s'),$dateformatdetails['dateformat'])."
</p>";
}
$inputnames[]=$ia[1];
return array($answer, $inputnames);
}
示例11: addDummies
/**
* Add dummy tokens form
*/
function addDummies($iSurveyId, $subaction = '')
{
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
$bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
if (!$bTokenExists) {
self::_newtokentable($iSurveyId);
}
$iSurveyId = sanitize_int($iSurveyId);
$clang = $this->getController()->lang;
if (!hasSurveyPermission($iSurveyId, 'tokens', 'create')) {
die("No permissions.");
// TODO Replace
}
$this->getController()->loadHelper("surveytranslator");
if (!empty($subaction) && $subaction == 'add') {
$this->getController()->loadLibrary('Date_Time_Converter');
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
//Fix up dates and match to database format
if (trim(Yii::app()->request->getPost('validfrom')) == '') {
$_POST['validfrom'] = null;
} else {
$datetimeobj = new Date_Time_Converter(trim(Yii::app()->request->getPost('validfrom')), $dateformatdetails['phpdate'] . ' H:i');
$_POST['validfrom'] = $datetimeobj->convert('Y-m-d H:i:s');
}
if (trim(Yii::app()->request->getPost('validuntil')) == '') {
$_POST['validuntil'] = null;
} else {
$datetimeobj = new Date_Time_Converter(trim(Yii::app()->request->getPost('validuntil')), $dateformatdetails['phpdate'] . ' H:i');
$_POST['validuntil'] = $datetimeobj->convert('Y-m-d H:i:s');
}
$santitizedtoken = '';
$aData = array('firstname' => Yii::app()->request->getPost('firstname'), 'lastname' => Yii::app()->request->getPost('lastname'), 'email' => sanitize_email(Yii::app()->request->getPost('email')), 'emailstatus' => 'OK', 'token' => $santitizedtoken, 'language' => sanitize_languagecode(Yii::app()->request->getPost('language')), 'sent' => 'N', 'remindersent' => 'N', 'completed' => 'N', 'usesleft' => Yii::app()->request->getPost('usesleft'), 'validfrom' => Yii::app()->request->getPost('validfrom'), 'validuntil' => Yii::app()->request->getPost('validuntil'));
// add attributes
$attrfieldnames = Survey::model()->findByPk($iSurveyId)->tokenAttributes;
foreach ($attrfieldnames as $attr_name => $desc) {
$value = Yii::app()->request->getPost($attr_name);
if ($desc['mandatory'] == 'Y' && trim($value) == '') {
$this->getController()->error(sprintf($clang->gT('%s cannot be empty'), $desc['description']));
}
$aData[$attr_name] = Yii::app()->request->getPost($attr_name);
}
$amount = sanitize_int(Yii::app()->request->getPost('amount'));
$tokenlength = sanitize_int(Yii::app()->request->getPost('tokenlen'));
// Fill an array with all existing tokens
$criteria = Tokens_dynamic::model($iSurveyId)->getDbCriteria();
$criteria->select = 'token';
$ntresult = Tokens_dynamic::model($iSurveyId)->findAllAsArray($criteria);
//Use AsArray to skip active record creation
$existingtokens = array();
foreach ($ntresult as $tkrow) {
$existingtokens[$tkrow['token']] = true;
}
$invalidtokencount = 0;
$newDummyToken = 0;
while ($newDummyToken < $amount && $invalidtokencount < 50) {
$aDataToInsert = $aData;
$aDataToInsert['firstname'] = str_replace('{TOKEN_COUNTER}', $newDummyToken, $aDataToInsert['firstname']);
$aDataToInsert['lastname'] = str_replace('{TOKEN_COUNTER}', $newDummyToken, $aDataToInsert['lastname']);
$aDataToInsert['email'] = str_replace('{TOKEN_COUNTER}', $newDummyToken, $aDataToInsert['email']);
$isvalidtoken = false;
while ($isvalidtoken == false && $invalidtokencount < 50) {
$newtoken = randomChars($tokenlength);
if (!isset($existingtokens[$newtoken])) {
$isvalidtoken = true;
$existingtokens[$newtoken] = true;
$invalidtokencount = 0;
} else {
$invalidtokencount++;
}
}
if ($isvalidtoken) {
$aDataToInsert['token'] = $newtoken;
Tokens_dynamic::model()->insertToken($iSurveyId, $aDataToInsert);
$newDummyToken++;
}
}
$aData['thissurvey'] = getSurveyInfo($iSurveyId);
$aData['surveyid'] = $iSurveyId;
if (!$invalidtokencount) {
$aData['success'] = false;
$message = array('title' => $clang->gT("Success"), 'message' => $clang->gT("New dummy tokens were added.") . "<br /><br />\n<input type='button' value='" . $clang->gT("Display tokens") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/browse/surveyid/{$iSurveyId}") . "', '_top')\" />\n");
} else {
$aData['success'] = true;
$message = array('title' => $clang->gT("Failed"), 'message' => "<p>" . sprintf($clang->gT("Only %s new dummy tokens were added after %s trials."), $newDummyToken, $invalidtokencount) . $clang->gT("Try with a bigger token length.") . "</p>" . "\n<input type='button' value='" . $clang->gT("Display tokens") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/browse/surveyid/{$iSurveyId}") . "', '_top')\" />\n");
}
$this->_renderWrappedTemplate('token', array('tokenbar', 'message' => $message), $aData);
} else {
$tkcount = Tokens_dynamic::model($iSurveyId)->count();
$tokenlength = Yii::app()->db->createCommand()->select('tokenlength')->from('{{surveys}}')->where('sid=:sid')->bindParam(":sid", $iSurveyId, PDO::PARAM_INT)->query()->readColumn(0);
if (empty($tokenlength)) {
$tokenlength = 15;
}
$thissurvey = getSurveyInfo($iSurveyId);
$aData['thissurvey'] = $thissurvey;
$aData['surveyid'] = $iSurveyId;
$aData['tokenlength'] = $tokenlength;
$aData['dateformatdetails'] = getDateFormatData(Yii::app()->session['dateformat'], $clang->langcode);
//.........这里部分代码省略.........
示例12: do_date
//.........这里部分代码省略.........
$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 {
$i_date_selected = '';
}
$answer .= '<option value="' . $i . '"' . $i_date_selected . '>' . $i . '</option>';
}
$answer .= '</select>';
break;
case 'H':
case 'h':
case 'g':
case 'G':
$answer .= '<label for="hour' . $ia[1] . '" class="hide">' . $clang->gT('Hour') . '</label><select id="hour' . $ia[1] . '" name="hour' . $ia[1] . '" class="hour"><option value="">' . $clang->gT('Hour') . '</option>';
for ($i = 0; $i < 24; $i++) {
if ($i === $currenthour) {
$i_date_selected = SELECTED;
} else {
$i_date_selected = '';
}
if ($datepart == 'H') {
$answer .= '<option value="' . $i . '"' . $i_date_selected . '>' . sprintf('%02d', $i) . '</option>';
} else {
$answer .= '<option value="' . $i . '"' . $i_date_selected . '>' . $i . '</option>';
}
}
$answer .= '</select>';
break;
case 'i':
$answer .= '<label for="minute' . $ia[1] . '" class="hide">' . $clang->gT('Minute') . '</label><select id="minute' . $ia[1] . '" name="minute' . $ia[1] . '" class="minute">
<option value="">' . $clang->gT('Minute') . '</option>';
for ($i = 0; $i < 60; $i += $aQuestionAttributes['dropdown_dates_minute_step']) {
if ($i === $currentminute) {
$i_date_selected = SELECTED;
} else {
$i_date_selected = '';
}
if ($datepart == 'i') {
$answer .= '<option value="' . $i . '"' . $i_date_selected . '>' . sprintf('%02d', $i) . '</option>';
} else {
$answer .= '<option value="' . $i . '"' . $i_date_selected . '>' . $i . '</option>';
}
}
$answer .= '</select>';
break;
default:
$answer .= $datepart;
}
}
$answer .= '<input class="text" type="text" size="10" name="' . $ia[1] . '" style="display: none" id="answer' . $ia[1] . '" value="' . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]] . '" maxlength="10" alt="' . $clang->gT('Answer') . '" onchange="' . $checkconditionFunction . '(this.value, this.name, this.type)" />
</p>';
$answer .= '<input type="hidden" name="qattribute_answer[]" value="' . $ia[1] . '" />
<input type="hidden" id="qattribute_answer' . $ia[1] . '" name="qattribute_answer' . $ia[1] . '" />
<input type="hidden" id="dateformat' . $ia[1] . '" value="' . $dateformatdetails['jsdate'] . '"/>';
} else {
header_includes(Yii::app()->getConfig("generalscripts") . 'jquery/lime-calendar.js');
if ($clang->langcode !== 'en') {
header_includes(Yii::app()->getConfig("generalscripts") . 'jquery/locale/jquery.ui.datepicker-' . $clang->langcode . '.js');
}
// Format the date for output
if (trim($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]]) != '') {
$datetimeobj = new Date_Time_Converter($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]], "Y-m-d");
$dateoutput = $datetimeobj->convert($dateformatdetails['phpdate']);
} else {
$dateoutput = '';
}
if (trim($aQuestionAttributes['dropdown_dates_year_min']) != '') {
$minyear = $aQuestionAttributes['dropdown_dates_year_min'];
} else {
$minyear = '1980';
}
if (trim($aQuestionAttributes['dropdown_dates_year_max']) != '') {
$maxyear = $aQuestionAttributes['dropdown_dates_year_max'];
} else {
$maxyear = '2020';
}
$goodchars = str_replace(array("m", "d", "y"), "", $dateformatdetails['jsdate']);
$goodchars = "0123456789" . $goodchars[0];
$answer = "<p class='question answer-item text-item date-item'><label for='answer{$ia[1]}' class='hide label'>{$clang->gT('Date picker')}</label>\n <input class='popupdate' type=\"text\" size=\"10\" name=\"{$ia[1]}\" title='" . sprintf($clang->gT('Format: %s'), $dateformatdetails['dateformat']) . "' id=\"answer{$ia[1]}\" value=\"{$dateoutput}\" maxlength=\"10\" onkeypress=\"return goodchars(event,'" . $goodchars . "')\" onchange=\"{$checkconditionFunction}(this.value, this.name, this.type)\" />\n <input type='hidden' name='dateformat{$ia[1]}' id='dateformat{$ia[1]}' value='{$dateformatdetails['jsdate']}' />\n <input type='hidden' name='datelanguage{$ia[1]}' id='datelanguage{$ia[1]}' value='{$clang->langcode}' />\n <input type='hidden' name='dateyearrange{$ia[1]}' id='dateyearrange{$ia[1]}' value='{$minyear}:{$maxyear}' />\n\n </p>";
if (trim($aQuestionAttributes['hide_tip']) == 1) {
$answer .= "<p class=\"tip\">" . sprintf($clang->gT('Format: %s'), $dateformatdetails['dateformat']) . "</p>";
}
}
$inputnames[] = $ia[1];
return array($answer, $inputnames);
}
示例13: getStartDate
/**
* Get the date if survey is future
* @param $iSurveyId
* @return localized date
*/
public function getStartDate($iSurveyId)
{
$aSurveyInfo = getSurveyInfo($iSurveyId, Yii::app()->language);
if (empty($aSurveyInfo['startdate']) || dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig("timeadjust")) >= $aSurveyInfo['startdate']) {
return;
}
Yii::app()->loadHelper("surveytranslator");
$aDateFormat = getDateFormatData(getDateFormatForSID($iSurveyId, Yii::app()->language), Yii::app()->language);
$datetimeobj = new Date_Time_Converter($aSurveyInfo['startdate'], 'Y-m-d H:i:s');
return $datetimeobj->convert($aDateFormat['phpdate']);
}
示例14: _surveysummary
/**
* Show survey summary
* @param int Survey id
* @param string Action to be performed
*/
function _surveysummary($iSurveyID, $action = null, $gid = null)
{
$clang = $this->getController()->lang;
$baselang = Survey::model()->findByPk($iSurveyID)->language;
$condition = array('sid' => $iSurveyID, 'language' => $baselang);
$sumresult1 = Survey::model()->with(array('languagesettings' => array('condition' => 'surveyls_language=language')))->findByPk($iSurveyID);
//$sumquery1, 1) ; //Checked
if (is_null($sumresult1)) {
Yii::app()->session['flashmessage'] = $clang->gT("Invalid survey ID");
$this->getController()->redirect($this->getController()->createUrl("admin/index"));
}
// if surveyid is invalid then die to prevent errors at a later time
$surveyinfo = $sumresult1->attributes;
$surveyinfo = array_merge($surveyinfo, $sumresult1->languagesettings[0]->attributes);
$surveyinfo = array_map('flattenText', $surveyinfo);
//$surveyinfo = array_map('htmlspecialchars', $surveyinfo);
$activated = $surveyinfo['active'];
$condition = array('sid' => $iSurveyID, 'parent_qid' => 0, 'language' => $baselang);
$sumresult3 = Questions::model()->findAllByAttributes($condition);
//Checked
$sumcount3 = count($sumresult3);
$condition = array('sid' => $iSurveyID, 'language' => $baselang);
//$sumquery2 = "SELECT * FROM ".db_table_name('groups')." WHERE sid={$iSurveyID} AND language='".$baselang."'"; //Getting a count of groups for this survey
$sumresult2 = Groups::model()->findAllByAttributes($condition);
//Checked
$sumcount2 = count($sumresult2);
//SURVEY SUMMARY
$aAdditionalLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$surveysummary2 = "";
if ($surveyinfo['anonymized'] != "N") {
$surveysummary2 .= $clang->gT("Responses to this survey are anonymized.") . "<br />";
} else {
$surveysummary2 .= $clang->gT("Responses to this survey are NOT anonymized.") . "<br />";
}
if ($surveyinfo['format'] == "S") {
$surveysummary2 .= $clang->gT("It is presented question by question.") . "<br />";
} elseif ($surveyinfo['format'] == "G") {
$surveysummary2 .= $clang->gT("It is presented group by group.") . "<br />";
} else {
$surveysummary2 .= $clang->gT("It is presented on one single page.") . "<br />";
}
if ($surveyinfo['allowjumps'] == "Y") {
if ($surveyinfo['format'] == 'A') {
$surveysummary2 .= $clang->gT("No question index will be shown with this format.") . "<br />";
} else {
$surveysummary2 .= $clang->gT("A question index will be shown; participants will be able to jump between viewed questions.") . "<br />";
}
}
if ($surveyinfo['datestamp'] == "Y") {
$surveysummary2 .= $clang->gT("Responses will be date stamped.") . "<br />";
}
if ($surveyinfo['ipaddr'] == "Y") {
$surveysummary2 .= $clang->gT("IP Addresses will be logged") . "<br />";
}
if ($surveyinfo['refurl'] == "Y") {
$surveysummary2 .= $clang->gT("Referrer URL will be saved.") . "<br />";
}
if ($surveyinfo['usecookie'] == "Y") {
$surveysummary2 .= $clang->gT("It uses cookies for access control.") . "<br />";
}
if ($surveyinfo['allowregister'] == "Y") {
$surveysummary2 .= $clang->gT("If tokens are used, the public may register for this survey") . "<br />";
}
if ($surveyinfo['allowsave'] == "Y" && $surveyinfo['tokenanswerspersistence'] == 'N') {
$surveysummary2 .= $clang->gT("Participants can save partially finished surveys") . "<br />\n";
}
if ($surveyinfo['emailnotificationto'] != '') {
$surveysummary2 .= $clang->gT("Basic email notification is sent to:") . " {$surveyinfo['emailnotificationto']}<br />\n";
}
if ($surveyinfo['emailresponseto'] != '') {
$surveysummary2 .= $clang->gT("Detailed email notification with response data is sent to:") . " {$surveyinfo['emailresponseto']}<br />\n";
}
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
if (trim($surveyinfo['startdate']) != '') {
Yii::import('application.libraries.Date_Time_Converter');
$datetimeobj = new Date_Time_Converter($surveyinfo['startdate'], 'Y-m-d H:i:s');
$aData['startdate'] = $datetimeobj->convert($dateformatdetails['phpdate'] . ' H:i');
} else {
$aData['startdate'] = "-";
}
if (trim($surveyinfo['expires']) != '') {
//$constructoritems = array($surveyinfo['expires'] , "Y-m-d H:i:s");
Yii::import('application.libraries.Date_Time_Converter');
$datetimeobj = new Date_Time_Converter($surveyinfo['expires'], 'Y-m-d H:i:s');
//$datetimeobj = new Date_Time_Converter($surveyinfo['expires'] , "Y-m-d H:i:s");
$aData['expdate'] = $datetimeobj->convert($dateformatdetails['phpdate'] . ' H:i');
} else {
$aData['expdate'] = "-";
}
if (!$surveyinfo['language']) {
$aData['language'] = getLanguageNameFromCode($currentadminlang, false);
} else {
$aData['language'] = getLanguageNameFromCode($surveyinfo['language'], false);
}
// get the rowspan of the Additionnal languages row
//.........这里部分代码省略.........
示例15: insert
/**
* Saves the new survey after the creation screen is submitted
*
* @param $iSurveyID The survey id to be used for the new survey. If already taken a new random one will be used.
*/
function insert($iSurveyID = null)
{
if (Yii::app()->session['USER_RIGHT_CREATE_SURVEY']) {
// Check if survey title was set
if (!$_POST['surveyls_title']) {
Yii::app()->session['flashmessage'] = $clang->gT("Survey could not be created because it did not have a title");
redirect($this->getController()->createUrl('admin'));
return;
}
// Check if template may be used
$sTemplate = $_POST['template'];
if (!$sTemplate || Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1 && Yii::app()->session['USER_RIGHT_MANAGE_TEMPLATE'] != 1 && !hasTemplateManageRights(Yii::app()->session['loginID'], $_POST['template'])) {
$sTemplate = "default";
}
Yii::app()->loadHelper("surveytranslator");
// If start date supplied convert it to the right format
$aDateFormatData = getDateFormatData(Yii::app()->session['dateformat']);
$sStartDate = $_POST['startdate'];
if (trim($sStartDate) != '') {
Yii::import('application.libraries.Date_Time_Converter');
$converter = new Date_Time_Converter($sStartDate, $aDateFormatData['phpdate'] . ' H:i:s');
$sStartDate = $converter->convert("Y-m-d H:i:s");
}
// If expiry date supplied convert it to the right format
$sExpiryDate = $_POST['expires'];
if (trim($sExpiryDate) != '') {
Yii::import('application.libraries.Date_Time_Converter');
$converter = new Date_Time_Converter($sExpiryDate, $aDateFormatData['phpdate'] . ' H:i:s');
$sExpiryDate = $converter->convert("Y-m-d H:i:s");
}
// Insert base settings into surveys table
$aInsertData = array('expires' => $sExpiryDate, 'startdate' => $sStartDate, 'template' => $sTemplate, 'owner_id' => Yii::app()->session['loginID'], 'admin' => $_POST['admin'], 'active' => 'N', 'adminemail' => $_POST['adminemail'], 'bounce_email' => $_POST['bounce_email'], 'anonymized' => $_POST['anonymized'], 'faxto' => $_POST['faxto'], 'format' => $_POST['format'], 'savetimings' => $_POST['savetimings'], 'language' => $_POST['language'], 'datestamp' => $_POST['datestamp'], 'ipaddr' => $_POST['ipaddr'], 'refurl' => $_POST['refurl'], 'usecookie' => $_POST['usecookie'], 'emailnotificationto' => $_POST['emailnotificationto'], 'allowregister' => $_POST['allowregister'], 'allowsave' => $_POST['allowsave'], 'navigationdelay' => $_POST['navigationdelay'], 'autoredirect' => $_POST['autoredirect'], 'showxquestions' => $_POST['showxquestions'], 'showgroupinfo' => $_POST['showgroupinfo'], 'showqnumcode' => $_POST['showqnumcode'], 'shownoanswer' => $_POST['shownoanswer'], 'showwelcome' => $_POST['showwelcome'], 'allowprev' => $_POST['allowprev'], 'allowjumps' => $_POST['allowjumps'], 'nokeyboard' => $_POST['nokeyboard'], 'showprogress' => $_POST['showprogress'], 'printanswers' => $_POST['printanswers'], 'listpublic' => $_POST['public'], 'htmlemail' => $_POST['htmlemail'], 'sendconfirmation' => $_POST['sendconfirmation'], 'tokenanswerspersistence' => $_POST['tokenanswerspersistence'], 'alloweditaftercompletion' => $_POST['alloweditaftercompletion'], 'usecaptcha' => $_POST['usecaptcha'], 'publicstatistics' => $_POST['publicstatistics'], 'publicgraphs' => $_POST['publicgraphs'], 'assessments' => $_POST['assessments'], 'emailresponseto' => $_POST['emailresponseto'], 'tokenlength' => $_POST['tokenlength']);
if (!is_null($iSurveyID)) {
$aInsertData['wishSID'] = $iSurveyID;
}
$iNewSurveyid = Survey::model()->insertNewSurvey($aInsertData);
if (!$iNewSurveyid) {
die('Survey could not be created.');
}
// Prepare locale data for surveys_language_settings table
$sTitle = $_POST['surveyls_title'];
$sDescription = $_POST['description'];
$sWelcome = $_POST['welcome'];
$sURLDescription = $_POST['urldescrip'];
if (Yii::app()->getConfig('filterxsshtml')) {
//$p = new CHtmlPurifier();
//$p->options = array('URI.AllowedSchemes'=>array('http' => true, 'https' => true));
//$sTitle=$p->purify($sTitle);
//$sDescription=$p->purify($sDescription);
//$sWelcome=$p->purify($sWelcome);
//$sURLDescription=$p->purify($sURLDescription);
}
$sTitle = html_entity_decode($sTitle, ENT_QUOTES, "UTF-8");
$sDescription = html_entity_decode($sDescription, ENT_QUOTES, "UTF-8");
$sWelcome = html_entity_decode($sWelcome, ENT_QUOTES, "UTF-8");
$sURLDescription = html_entity_decode($sURLDescription, ENT_QUOTES, "UTF-8");
// Fix bug with FCKEditor saving strange BR types
$sTitle = fixCKeditorText($sTitle);
$sDescription = fixCKeditorText($sDescription);
$sWelcome = fixCKeditorText($sWelcome);
// Insert base language into surveys_language_settings table
$aInsertData = array('surveyls_survey_id' => $iNewSurveyid, 'surveyls_title' => $sTitle, 'surveyls_description' => $sDescription, 'surveyls_welcometext' => $sWelcome, 'surveyls_language' => $_POST['language'], 'surveyls_urldescription' => $_POST['urldescrip'], 'surveyls_endtext' => $_POST['endtext'], 'surveyls_url' => $_POST['url'], 'surveyls_dateformat' => (int) $_POST['dateformat'], 'surveyls_numberformat' => (int) $_POST['numberformat']);
$langsettings = new Surveys_languagesettings();
$langsettings->insertNewSurvey($aInsertData);
Yii::app()->session['flashmessage'] = $this->getController()->lang->gT("Survey was successfully added.");
// Update survey permissions
Survey_permissions::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'], $iNewSurveyid);
$this->getController()->redirect($this->getController()->createUrl('admin/survey/sa/view/surveyid/' . $iNewSurveyid));
}
}