本文整理汇总了PHP中fixLanguageConsistency函数的典型用法代码示例。如果您正苦于以下问题:PHP fixLanguageConsistency函数的具体用法?PHP fixLanguageConsistency怎么用?PHP fixLanguageConsistency使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fixLanguageConsistency函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
/**
* questiongroup::import()
* Function responsible to import a question group.
*
* @access public
* @return void
*/
function import()
{
$action = $_POST['action'];
$iSurveyID = $surveyid = $aData['surveyid'] = (int) $_POST['sid'];
if (!Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'import')) {
Yii::app()->user->setFlash('error', gT("Access denied"));
$this->getController()->redirect(array('admin/survey/sa/listquestiongroups/surveyid/' . $surveyid));
}
if ($action == 'importgroup') {
$importgroup = "\n";
$importgroup .= "\n";
$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
$aPathInfo = pathinfo($_FILES['the_file']['name']);
$sExtension = $aPathInfo['extension'];
if ($_FILES['the_file']['error'] == 1 || $_FILES['the_file']['error'] == 2) {
$fatalerror = sprintf(gT("Sorry, this file is too large. Only files up to %01.2f MB are allowed."), getMaximumFileUploadSize() / 1024 / 1024) . '<br>';
} elseif (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $sFullFilepath)) {
$fatalerror = gT("An error occurred uploading your file. This may be caused by incorrect permissions for the application /tmp folder.");
}
// validate that we have a SID
if (!returnGlobal('sid')) {
$fatalerror .= gT("No SID (Survey) has been provided. Cannot import question.");
}
if (isset($fatalerror)) {
@unlink($sFullFilepath);
Yii::app()->user->setFlash('error', $fatalerror);
$this->getController()->redirect(array('admin/questiongroups/sa/importview/surveyid/' . $surveyid));
}
Yii::app()->loadHelper('admin/import');
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
if (strtolower($sExtension) == 'lsg') {
$aImportResults = XMLImportGroup($sFullFilepath, $iSurveyID);
} else {
Yii::app()->user->setFlash('error', gT("Unknown file extension"));
$this->getController()->redirect(array('admin/questiongroups/sa/importview/surveyid/' . $surveyid));
}
LimeExpressionManager::SetDirtyFlag();
// so refreshes syntax highlighting
fixLanguageConsistency($iSurveyID);
if (isset($aImportResults['fatalerror'])) {
unlink($sFullFilepath);
Yii::app()->user->setFlash('error', $aImportResults['fatalerror']);
$this->getController()->redirect(array('admin/questiongroups/sa/importview/surveyid/' . $surveyid));
}
unlink($sFullFilepath);
$aData['display'] = $importgroup;
$aData['surveyid'] = $iSurveyID;
$aData['aImportResults'] = $aImportResults;
$aData['sExtension'] = $sExtension;
//$aData['display']['menu_bars']['surveysummary'] = 'importgroup';
$aData['sidemenu']['state'] = false;
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$this->_renderWrappedTemplate('survey/QuestionGroups', 'import_view', $aData);
}
}
示例2: import
/**
* Function responsible to import a question.
*
* @access public
* @return void
*/
public function import()
{
$action = returnGlobal('action');
$surveyid = returnGlobal('sid');
$gid = returnGlobal('gid');
$clang = $this->getController()->lang;
$aViewUrls = array();
$aData['display']['menu_bars']['surveysummary'] = 'viewquestion';
$aData['display']['menu_bars']['gid_action'] = 'viewgroup';
if ($action == 'importquestion') {
$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $_FILES['the_file']['name'];
$aPathInfo = pathinfo($sFullFilepath);
$sExtension = $aPathInfo['extension'];
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $sFullFilepath)) {
$fatalerror = sprintf($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), Yii::app()->getConfig('tempdir'));
}
// validate that we have a SID and GID
if (!$surveyid) {
$fatalerror .= $clang->gT("No SID (Survey) has been provided. Cannot import question.");
}
if (!$gid) {
$fatalerror .= $clang->gT("No GID (Group) has been provided. Cannot import question");
}
if (isset($fatalerror)) {
unlink($sFullFilepath);
$this->getController()->error($fatalerror);
}
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
Yii::app()->loadHelper('admin/import');
if (strtolower($sExtension) == 'csv') {
$aImportResults = CSVImportQuestion($sFullFilepath, $surveyid, $gid);
} elseif (strtolower($sExtension) == 'lsq') {
$aImportResults = XMLImportQuestion($sFullFilepath, $surveyid, $gid);
} else {
$this->getController()->error($clang->gT('Unknown file extension'));
}
fixLanguageConsistency($surveyid);
if (isset($aImportResults['fatalerror'])) {
unlink($sFullFilepath);
$this->getController()->error($aImportResults['fatalerror']);
}
unlink($sFullFilepath);
$aData['aImportResults'] = $aImportResults;
$aData['surveyid'] = $surveyid;
$aData['gid'] = $gid;
$aData['sExtension'] = $sExtension;
$aViewUrls[] = 'import_view';
}
$this->_renderWrappedTemplate('survey/Question', $aViewUrls, $aData);
}
示例3: import
/**
* questiongroup::import()
* Function responsible to import a question group.
*
* @access public
* @return void
*/
function import()
{
$action = $_POST['action'];
$surveyid = $_POST['sid'];
$clang = $this->getController()->lang;
if ($action == 'importgroup') {
$importgroup = "\n";
$importgroup .= "\n";
$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
$aPathInfo = pathinfo($_FILES['the_file']['name']);
$sExtension = $aPathInfo['extension'];
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $sFullFilepath)) {
$fatalerror = sprintf($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), $this->config->item('tempdir'));
}
// validate that we have a SID
if (!returnGlobal('sid')) {
$fatalerror .= $clang->gT("No SID (Survey) has been provided. Cannot import question.");
}
if (isset($fatalerror)) {
@unlink($sFullFilepath);
$this->getController()->error($fatalerror);
}
Yii::app()->loadHelper('admin/import');
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
if (strtolower($sExtension) == 'csv') {
$aImportResults = CSVImportGroup($sFullFilepath, $surveyid);
} elseif (strtolower($sExtension) == 'lsg') {
$aImportResults = XMLImportGroup($sFullFilepath, $surveyid);
} else {
$this->getController()->error('Unknown file extension');
}
LimeExpressionManager::SetDirtyFlag();
// so refreshes syntax highlighting
fixLanguageConsistency($surveyid);
if (isset($aImportResults['fatalerror'])) {
unlink($sFullFilepath);
$this->getController()->error($aImportResults['fatalerror']);
}
unlink($sFullFilepath);
$aData['display'] = $importgroup;
$aData['surveyid'] = $surveyid;
$aData['aImportResults'] = $aImportResults;
$aData['sExtension'] = $sExtension;
//$aData['display']['menu_bars']['surveysummary'] = 'importgroup';
$this->_renderWrappedTemplate('survey/QuestionGroups', 'import_view', $aData);
// TMSW Condition->Relevance: call LEM->ConvertConditionsToRelevance() after import
}
}
示例4: update
//.........这里部分代码省略.........
$oSurvey->refurl = App()->request->getPost('refurl');
}
$oSurvey->publicgraphs = App()->request->getPost('publicgraphs');
$oSurvey->usecookie = App()->request->getPost('usecookie');
$oSurvey->allowregister = App()->request->getPost('allowregister');
$oSurvey->allowsave = App()->request->getPost('allowsave');
$oSurvey->navigationdelay = App()->request->getPost('navigationdelay');
$oSurvey->printanswers = App()->request->getPost('printanswers');
$oSurvey->publicstatistics = App()->request->getPost('publicstatistics');
$oSurvey->autoredirect = App()->request->getPost('autoredirect');
$oSurvey->showxquestions = App()->request->getPost('showxquestions');
$oSurvey->showgroupinfo = App()->request->getPost('showgroupinfo');
$oSurvey->showqnumcode = App()->request->getPost('showqnumcode');
$oSurvey->shownoanswer = App()->request->getPost('shownoanswer');
$oSurvey->showwelcome = App()->request->getPost('showwelcome');
$oSurvey->allowprev = App()->request->getPost('allowprev');
$oSurvey->questionindex = App()->request->getPost('questionindex');
$oSurvey->nokeyboard = App()->request->getPost('nokeyboard');
$oSurvey->showprogress = App()->request->getPost('showprogress');
$oSurvey->listpublic = App()->request->getPost('public');
$oSurvey->htmlemail = App()->request->getPost('htmlemail');
$oSurvey->sendconfirmation = App()->request->getPost('sendconfirmation');
$oSurvey->tokenanswerspersistence = App()->request->getPost('tokenanswerspersistence');
$oSurvey->alloweditaftercompletion = App()->request->getPost('alloweditaftercompletion');
$oSurvey->usecaptcha = App()->request->getPost('usecaptcha');
$oSurvey->emailresponseto = App()->request->getPost('emailresponseto');
$oSurvey->emailnotificationto = App()->request->getPost('emailnotificationto');
$oSurvey->googleanalyticsapikey = App()->request->getPost('googleanalyticsapikey');
$oSurvey->googleanalyticsstyle = App()->request->getPost('googleanalyticsstyle');
$oSurvey->tokenlength = App()->request->getPost('tokenlength');
$oSurvey->adminemail = App()->request->getPost('adminemail');
$oSurvey->bounce_email = App()->request->getPost('bounce_email');
if ($oSurvey->save()) {
Yii::app()->setFlashMessage(gT("Survey settings were successfully saved."));
} else {
Yii::app()->setFlashMessage(gT("Survey could not be updated."), "error");
tracevar($oSurvey->getErrors());
}
/* Reload $oSurvey (language are fixed : need it ?) */
$oSurvey = Survey::model()->findByPk($iSurveyId);
/* Delete removed language cleanLanguagesFromSurvey do it already why redo it (cleanLanguagesFromSurvey must be moved to model) ?*/
$aAvailableLanguage = $oSurvey->getAllLanguages();
$oCriteria = new CDbCriteria();
$oCriteria->compare('surveyls_survey_id', $iSurveyId);
$oCriteria->addNotInCondition('surveyls_language', $aAvailableLanguage);
SurveyLanguageSetting::model()->deleteAll($oCriteria);
/* Add new language fixLanguageConsistency do it ?*/
foreach ($oSurvey->additionalLanguages as $sLang) {
if ($sLang) {
$oLanguageSettings = SurveyLanguageSetting::model()->find('surveyls_survey_id=:surveyid AND surveyls_language=:langname', array(':surveyid' => $iSurveyId, ':langname' => $sLang));
if (!$oLanguageSettings) {
$oLanguageSettings = new SurveyLanguageSetting();
$languagedetails = getLanguageDetails($sLang);
$oLanguageSettings->surveyls_survey_id = $iSurveyId;
$oLanguageSettings->surveyls_language = $sLang;
$oLanguageSettings->surveyls_title = '';
// Not in default model ?
$oLanguageSettings->surveyls_dateformat = $languagedetails['dateformat'];
if (!$oLanguageSettings->save()) {
Yii::app()->setFlashMessage(gT("Survey language could not be created."), "error");
tracevar($oLanguageSettings->getErrors());
}
}
}
}
/* Language fix : remove and add question/group */
cleanLanguagesFromSurvey($iSurveyId, implode(" ", $oSurvey->additionalLanguages));
fixLanguageConsistency($iSurveyId, implode(" ", $oSurvey->additionalLanguages));
// Url params in json
$aURLParams = json_decode(Yii::app()->request->getPost('allurlparams'), true);
SurveyURLParameter::model()->deleteAllByAttributes(array('sid' => $iSurveyId));
if (isset($aURLParams)) {
foreach ($aURLParams as $aURLParam) {
$aURLParam['parameter'] = trim($aURLParam['parameter']);
if ($aURLParam['parameter'] == '' || !preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $aURLParam['parameter']) || $aURLParam['parameter'] == 'sid' || $aURLParam['parameter'] == 'newtest' || $aURLParam['parameter'] == 'token' || $aURLParam['parameter'] == 'lang') {
continue;
// this parameter name seems to be invalid - just ignore it
}
unset($aURLParam['act']);
unset($aURLParam['title']);
unset($aURLParam['id']);
if ($aURLParam['targetqid'] == '') {
$aURLParam['targetqid'] = NULL;
}
if ($aURLParam['targetsqid'] == '') {
$aURLParam['targetsqid'] = NULL;
}
$aURLParam['sid'] = $iSurveyId;
$param = new SurveyURLParameter();
foreach ($aURLParam as $k => $v) {
$param->{$k} = $v;
}
$param->save();
}
}
if (Yii::app()->request->getPost('redirect')) {
$this->getController()->redirect(Yii::app()->request->getPost('redirect'));
App()->end();
}
}
示例5: import_question
/**
* RPC Routine to import a question - imports lsq,csv.
*
* @access public
* @param string $sSessionKey
* @param int $iSurveyID The id of the survey that the question will belong
* @param int $iGroupID The id of the group that the question will belong
* @param string $sImportData String containing the BASE 64 encoded data of a lsg,csv
* @param string $sImportDataType lsq,csv
* @param string $sMandatory Optional Mandatory question option (default to No)
* @param string $sNewQuestionTitle Optional new title for the question
* @param string $sNewqQuestion An optional new question
* @param string $sNewQuestionHelp An optional new question help text
* @return array|integer iQuestionID - ID of the new question - Or status
*/
public function import_question($sSessionKey, $iSurveyID, $iGroupID, $sImportData, $sImportDataType, $sMandatory = 'N', $sNewQuestionTitle = NULL, $sNewqQuestion = NULL, $sNewQuestionHelp = NULL)
{
if ($this->_checkSessionKey($sSessionKey)) {
$oSurvey = Survey::model()->findByPk($iSurveyID);
if (!isset($oSurvey)) {
return array('status' => 'Error: Invalid survey ID');
}
if (Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'update')) {
if ($oSurvey->getAttribute('active') == 'Y') {
return array('status' => 'Error:Survey is Active and not editable');
}
$oGroup = QuestionGroup::model()->findByAttributes(array('gid' => $iGroupID));
if (!isset($oGroup)) {
return array('status' => 'Error: Invalid group ID');
}
$sGroupSurveyID = $oGroup['sid'];
if ($sGroupSurveyID != $iSurveyID) {
return array('status' => 'Error: Missmatch in surveyid and groupid');
}
if (!in_array($sImportDataType, array('csv', 'lsq'))) {
return array('status' => 'Invalid extension');
}
libxml_use_internal_errors(true);
Yii::app()->loadHelper('admin/import');
// First save the data to a temporary file
$sFullFilePath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(40) . '.' . $sImportDataType;
file_put_contents($sFullFilePath, base64_decode(chunk_split($sImportData)));
if (strtolower($sImportDataType) == 'lsq') {
$sXMLdata = file_get_contents($sFullFilePath);
$xml = @simplexml_load_string($sXMLdata, 'SimpleXMLElement', LIBXML_NONET);
if (!$xml) {
unlink($sFullFilePath);
return array('status' => 'Error: Invalid LimeSurvey question structure XML ');
}
$aImportResults = XMLImportQuestion($sFullFilePath, $iSurveyID, $iGroupID);
} else {
return array('status' => 'Really Invalid extension');
}
//just for symmetry!
unlink($sFullFilePath);
if (isset($aImportResults['fatalerror'])) {
return array('status' => 'Error: ' . $aImportResults['fatalerror']);
} else {
fixLanguageConsistency($iSurveyID);
$iNewqid = $aImportResults['newqid'];
$oQuestion = Question::model()->findByAttributes(array('sid' => $iSurveyID, 'gid' => $iGroupID, 'qid' => $iNewqid));
if ($sNewQuestionTitle != NULL) {
$oQuestion->setAttribute('title', $sNewQuestionTitle);
}
if ($sNewqQuestion != '') {
$oQuestion->setAttribute('question', $sNewqQuestion);
}
if ($sNewQuestionHelp != '') {
$oQuestion->setAttribute('help', $sNewQuestionHelp);
}
if (in_array($sMandatory, array('Y', 'N'))) {
$oQuestion->setAttribute('mandatory', $sMandatory);
} else {
$oQuestion->setAttribute('mandatory', 'N');
}
try {
$oQuestion->save();
} catch (Exception $e) {
// no need to throw exception
}
return (int) $aImportResults['newqid'];
}
} else {
return array('status' => 'No permission');
}
} else {
return array('status' => 'Invalid session key');
}
}
示例6: fixLanguageConsistencyAllSurveys
function fixLanguageConsistencyAllSurveys()
{
$surveyidquery = "SELECT sid,additional_languages FROM " . dbQuoteID('{{surveys}}');
$surveyidresult = Yii::app()->db->createCommand($surveyidquery)->queryAll();
foreach ($surveyidresult as $sv) {
fixLanguageConsistency($sv['sid'], $sv['additional_languages']);
}
}
示例7: index
//.........这里部分代码省略.........
$oSurvey->printanswers = App()->request->getPost('printanswers');
$oSurvey->publicstatistics = App()->request->getPost('publicstatistics');
$oSurvey->autoredirect = App()->request->getPost('autoredirect');
$oSurvey->showxquestions = App()->request->getPost('showxquestions');
$oSurvey->showgroupinfo = App()->request->getPost('showgroupinfo');
$oSurvey->showqnumcode = App()->request->getPost('showqnumcode');
$oSurvey->shownoanswer = App()->request->getPost('shownoanswer');
$oSurvey->showwelcome = App()->request->getPost('showwelcome');
$oSurvey->allowprev = App()->request->getPost('allowprev');
$oSurvey->questionindex = App()->request->getPost('questionindex');
$oSurvey->nokeyboard = App()->request->getPost('nokeyboard');
$oSurvey->showprogress = App()->request->getPost('showprogress');
$oSurvey->listpublic = App()->request->getPost('public');
$oSurvey->htmlemail = App()->request->getPost('htmlemail');
$oSurvey->sendconfirmation = App()->request->getPost('sendconfirmation');
$oSurvey->tokenanswerspersistence = App()->request->getPost('tokenanswerspersistence');
$oSurvey->alloweditaftercompletion = App()->request->getPost('alloweditaftercompletion');
$oSurvey->usecaptcha = Survey::transcribeCaptchaOptions();
$oSurvey->emailresponseto = App()->request->getPost('emailresponseto');
$oSurvey->emailnotificationto = App()->request->getPost('emailnotificationto');
$oSurvey->googleanalyticsapikey = App()->request->getPost('googleanalyticsapikey');
$oSurvey->googleanalyticsstyle = App()->request->getPost('googleanalyticsstyle');
$oSurvey->tokenlength = App()->request->getPost('tokenlength');
$oSurvey->adminemail = App()->request->getPost('adminemail');
$oSurvey->bounce_email = App()->request->getPost('bounce_email');
if ($oSurvey->save()) {
Yii::app()->setFlashMessage(gT("Survey settings were successfully saved."));
} else {
Yii::app()->setFlashMessage(gT("Survey could not be updated."), "error");
tracevar($oSurvey->getErrors());
}
/* Reload $oSurvey (language are fixed : need it ?) */
$oSurvey = Survey::model()->findByPk($iSurveyID);
/* Delete removed language cleanLanguagesFromSurvey do it already why redo it (cleanLanguagesFromSurvey must be moved to model) ?*/
$aAvailableLanguage = $oSurvey->getAllLanguages();
$oCriteria = new CDbCriteria();
$oCriteria->compare('surveyls_survey_id', $iSurveyID);
$oCriteria->addNotInCondition('surveyls_language', $aAvailableLanguage);
SurveyLanguageSetting::model()->deleteAll($oCriteria);
/* Add new language fixLanguageConsistency do it ?*/
foreach ($oSurvey->additionalLanguages as $sLang) {
if ($sLang) {
$oLanguageSettings = SurveyLanguageSetting::model()->find('surveyls_survey_id=:surveyid AND surveyls_language=:langname', array(':surveyid' => $iSurveyID, ':langname' => $sLang));
if (!$oLanguageSettings) {
$oLanguageSettings = new SurveyLanguageSetting();
$languagedetails = getLanguageDetails($sLang);
$oLanguageSettings->surveyls_survey_id = $iSurveyID;
$oLanguageSettings->surveyls_language = $sLang;
$oLanguageSettings->surveyls_title = '';
// Not in default model ?
$oLanguageSettings->surveyls_dateformat = $languagedetails['dateformat'];
if (!$oLanguageSettings->save()) {
Yii::app()->setFlashMessage(gT("Survey language could not be created."), "error");
tracevar($oLanguageSettings->getErrors());
}
}
}
}
/* Language fix : remove and add question/group */
cleanLanguagesFromSurvey($iSurveyID, implode(" ", $oSurvey->additionalLanguages));
fixLanguageConsistency($iSurveyID, implode(" ", $oSurvey->additionalLanguages));
// Url params in json
$aURLParams = json_decode(Yii::app()->request->getPost('allurlparams'), true);
SurveyURLParameter::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
if (isset($aURLParams)) {
foreach ($aURLParams as $aURLParam) {
$aURLParam['parameter'] = trim($aURLParam['parameter']);
if ($aURLParam['parameter'] == '' || !preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $aURLParam['parameter']) || $aURLParam['parameter'] == 'sid' || $aURLParam['parameter'] == 'newtest' || $aURLParam['parameter'] == 'token' || $aURLParam['parameter'] == 'lang') {
continue;
// this parameter name seems to be invalid - just ignore it
}
unset($aURLParam['act']);
unset($aURLParam['title']);
unset($aURLParam['id']);
if ($aURLParam['targetqid'] == '') {
$aURLParam['targetqid'] = NULL;
}
if ($aURLParam['targetsqid'] == '') {
$aURLParam['targetsqid'] = NULL;
}
$aURLParam['sid'] = $iSurveyID;
$param = new SurveyURLParameter();
foreach ($aURLParam as $k => $v) {
$param->{$k} = $v;
}
$param->save();
}
}
////////////////////////////////////////
if ($sDBOutput != '') {
echo $sDBOutput;
} else {
if (Yii::app()->request->getPost('close-after-save') === 'true') {
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyID));
}
$this->getController()->redirect(array('/admin/survey/sa/editlocalsettings/surveyid/' . $iSurveyID));
}
}
$this->getController()->redirect(array("/admin"), "refresh");
}
示例8: import
/**
* Function responsible to import a question.
*
* @access public
* @return void
*/
public function import()
{
$action = returnGlobal('action');
$surveyid = $iSurveyID = returnGlobal('sid');
$gid = returnGlobal('gid');
$aViewUrls = array();
$aData['display']['menu_bars']['surveysummary'] = 'viewquestion';
$aData['display']['menu_bars']['gid_action'] = 'viewgroup';
if ($action == 'importquestion') {
$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
$sExtension = pathinfo($_FILES['the_file']['name'], PATHINFO_EXTENSION);
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $sFullFilepath)) {
$fatalerror = sprintf(gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), Yii::app()->getConfig('tempdir'));
}
// validate that we have a SID and GID
if (!$surveyid) {
$fatalerror .= gT("No SID (Survey) has been provided. Cannot import question.");
}
if (!$gid) {
$fatalerror .= gT("No GID (Group) has been provided. Cannot import question");
}
if (isset($fatalerror)) {
unlink($sFullFilepath);
$message = $fatalerror;
$message .= '<p>
<a class="btn btn-default btn-lg"
href="' . $this->getController()->createUrl('admin/survey/sa/listquestions/surveyid/') . '/' . $surveyid . '">' . gT("Return to question list") . '</a></p>';
$this->_renderWrappedTemplate('super', 'messagebox', array('title' => gT('Error'), 'message' => $message));
die;
}
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
Yii::app()->loadHelper('admin/import');
if (strtolower($sExtension) == 'lsq') {
$aImportResults = XMLImportQuestion($sFullFilepath, $surveyid, $gid);
} else {
$this->getController()->error(gT('Unknown file extension'));
}
fixLanguageConsistency($surveyid);
if (isset($aImportResults['fatalerror'])) {
//echo htmlentities($aImportResults['fatalerror']); die();
$message = $aImportResults['fatalerror'];
$message .= '<p>
<a class="btn btn-default btn-lg"
href="' . $this->getController()->createUrl('admin/survey/sa/listquestions/surveyid/') . '/' . $surveyid . '">' . gT("Return to question list") . '</a></p>';
$this->_renderWrappedTemplate('super', 'messagebox', array('title' => gT('Error'), 'message' => $message));
die;
}
unlink($sFullFilepath);
$aData['aImportResults'] = $aImportResults;
$aData['surveyid'] = $surveyid;
$aData['gid'] = $gid;
$aData['sExtension'] = $sExtension;
$aViewUrls[] = 'import_view';
}
/////
$aData['sidemenu']['state'] = false;
$aData['surveyid'] = $iSurveyID;
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$this->_renderWrappedTemplate('survey/Question', $aViewUrls, $aData);
}
示例9: index
//.........这里部分代码省略.........
} else {
$this->getController()->redirect($this->getController()->createUrl('admin/survey/sa/view/surveyid/' . $surveyid));
}
}
if (($action == "updatesurveysettingsandeditlocalesettings" || $action == "updatesurveysettings") && hasSurveyPermission($surveyid, 'surveysettings', 'update')) {
Yii::app()->loadHelper('surveytranslator');
Yii::app()->loadHelper('database');
$formatdata = getDateFormatData(Yii::app()->session['dateformat']);
$expires = $_POST['expires'];
if (trim($expires) == "") {
$expires = null;
} else {
Yii::app()->loadLibrary('Date_Time_Converter');
$datetimeobj = new date_time_converter($expires, $formatdata['phpdate'] . ' H:i');
//new Date_Time_Converter($expires, $formatdata['phpdate'].' H:i');
$expires = $datetimeobj->convert("Y-m-d H:i:s");
}
$startdate = $_POST['startdate'];
if (trim($startdate) == "") {
$startdate = null;
} else {
Yii::app()->loadLibrary('Date_Time_Converter');
$datetimeobj = new date_time_converter($startdate, $formatdata['phpdate'] . ' H:i');
//new Date_Time_Converter($startdate,$formatdata['phpdate'].' H:i');
$startdate = $datetimeobj->convert("Y-m-d H:i:s");
}
//make sure only numbers are passed within the $_POST variable
$tokenlength = (int) $_POST['tokenlength'];
//token length has to be at least 5, otherwise set it to default (15)
if ($tokenlength < 5) {
$tokenlength = 15;
}
cleanLanguagesFromSurvey($surveyid, Yii::app()->request->getPost('languageids'));
fixLanguageConsistency($surveyid, Yii::app()->request->getPost('languageids'));
$template = Yii::app()->request->getPost('template');
if (Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1 && Yii::app()->session['USER_RIGHT_MANAGE_TEMPLATE'] != 1 && !hasTemplateManageRights(Yii::app()->session['loginID'], $template)) {
$template = "default";
}
$aURLParams = json_decode(Yii::app()->request->getPost('allurlparams'), true);
Survey_url_parameters::model()->deleteAllByAttributes(array('sid' => $surveyid));
foreach ($aURLParams as $aURLParam) {
$aURLParam['parameter'] = trim($aURLParam['parameter']);
if ($aURLParam['parameter'] == '' || !preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $aURLParam['parameter']) || $aURLParam['parameter'] == 'sid' || $aURLParam['parameter'] == 'newtest' || $aURLParam['parameter'] == 'token' || $aURLParam['parameter'] == 'lang') {
continue;
// this parameter name seems to be invalid - just ignore it
}
unset($aURLParam['act']);
unset($aURLParam['title']);
unset($aURLParam['id']);
if ($aURLParam['targetqid'] == '') {
$aURLParam['targetqid'] = NULL;
}
if ($aURLParam['targetsqid'] == '') {
$aURLParam['targetsqid'] = NULL;
}
$aURLParam['sid'] = $surveyid;
$param = new Survey_url_parameters();
foreach ($aURLParam as $k => $v) {
$param->{$k} = $v;
}
$param->save();
}
$updatearray = array('admin' => Yii::app()->request->getPost('admin'), 'expires' => $expires, 'adminemail' => Yii::app()->request->getPost('adminemail'), 'startdate' => $startdate, 'bounce_email' => Yii::app()->request->getPost('bounce_email'), 'anonymized' => Yii::app()->request->getPost('anonymized'), 'faxto' => Yii::app()->request->getPost('faxto'), 'format' => Yii::app()->request->getPost('format'), 'savetimings' => Yii::app()->request->getPost('savetimings'), 'template' => $template, 'assessments' => Yii::app()->request->getPost('assessments'), 'language' => Yii::app()->request->getPost('language'), 'additional_languages' => Yii::app()->request->getPost('languageids'), 'datestamp' => Yii::app()->request->getPost('datestamp'), 'ipaddr' => Yii::app()->request->getPost('ipaddr'), 'refurl' => Yii::app()->request->getPost('refurl'), 'publicgraphs' => Yii::app()->request->getPost('publicgraphs'), 'usecookie' => Yii::app()->request->getPost('usecookie'), 'allowregister' => Yii::app()->request->getPost('allowregister'), 'allowsave' => Yii::app()->request->getPost('allowsave'), 'navigationdelay' => Yii::app()->request->getPost('navigationdelay'), 'printanswers' => Yii::app()->request->getPost('printanswers'), 'publicstatistics' => Yii::app()->request->getPost('publicstatistics'), 'autoredirect' => Yii::app()->request->getPost('autoredirect'), 'showxquestions' => Yii::app()->request->getPost('showxquestions'), 'showgroupinfo' => Yii::app()->request->getPost('showgroupinfo'), 'showqnumcode' => Yii::app()->request->getPost('showqnumcode'), 'shownoanswer' => Yii::app()->request->getPost('shownoanswer'), 'showwelcome' => Yii::app()->request->getPost('showwelcome'), 'allowprev' => Yii::app()->request->getPost('allowprev'), 'allowjumps' => Yii::app()->request->getPost('allowjumps'), 'nokeyboard' => Yii::app()->request->getPost('nokeyboard'), 'showprogress' => Yii::app()->request->getPost('showprogress'), 'listpublic' => Yii::app()->request->getPost('public'), 'htmlemail' => Yii::app()->request->getPost('htmlemail'), 'sendconfirmation' => Yii::app()->request->getPost('sendconfirmation'), 'tokenanswerspersistence' => Yii::app()->request->getPost('tokenanswerspersistence'), 'alloweditaftercompletion' => Yii::app()->request->getPost('alloweditaftercompletion'), 'usecaptcha' => Yii::app()->request->getPost('usecaptcha'), 'emailresponseto' => trim(Yii::app()->request->getPost('emailresponseto')), 'emailnotificationto' => trim(Yii::app()->request->getPost('emailnotificationto')), 'googleanalyticsapikey' => trim(Yii::app()->request->getPost('googleanalyticsapikey')), 'googleanalyticsstyle' => trim(Yii::app()->request->getPost('googleanalyticsstyle')), 'tokenlength' => $tokenlength);
// use model
$Survey = Survey::model()->findByPk($surveyid);
foreach ($updatearray as $k => $v) {
示例10: index
//.........这里部分代码省略.........
App()->getPluginManager()->dispatchEvent($settingsEvent, $plugin);
}
Yii::app()->loadHelper('surveytranslator');
Yii::app()->loadHelper('database');
$formatdata = getDateFormatData(Yii::app()->session['dateformat']);
$expires = $_POST['expires'];
if (trim($expires) == "") {
$expires = null;
} else {
Yii::app()->loadLibrary('Date_Time_Converter');
$datetimeobj = new date_time_converter($expires, $formatdata['phpdate'] . ' H:i');
//new Date_Time_Converter($expires, $formatdata['phpdate'].' H:i');
$expires = $datetimeobj->convert("Y-m-d H:i:s");
}
$startdate = $_POST['startdate'];
if (trim($startdate) == "") {
$startdate = null;
} else {
Yii::app()->loadLibrary('Date_Time_Converter');
$datetimeobj = new date_time_converter($startdate, $formatdata['phpdate'] . ' H:i');
//new Date_Time_Converter($startdate,$formatdata['phpdate'].' H:i');
$startdate = $datetimeobj->convert("Y-m-d H:i:s");
}
//make sure only numbers are passed within the $_POST variable
$tokenlength = (int) $_POST['tokenlength'];
//token length has to be at least 5, otherwise set it to default (15)
if ($tokenlength < 5) {
$tokenlength = 15;
}
if ($tokenlength > 36) {
$tokenlength = 36;
}
cleanLanguagesFromSurvey($iSurveyID, Yii::app()->request->getPost('languageids'));
fixLanguageConsistency($iSurveyID, Yii::app()->request->getPost('languageids'));
$template = Yii::app()->request->getPost('template');
if (!Permission::model()->hasGlobalPermission('superadmin', 'read') && !Permission::model()->hasGlobalPermission('templates', 'read') && !hasTemplateManageRights(Yii::app()->session['loginID'], $template)) {
$template = "default";
}
$aURLParams = json_decode(Yii::app()->request->getPost('allurlparams'), true);
SurveyURLParameter::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
if (isset($aURLParams)) {
foreach ($aURLParams as $aURLParam) {
$aURLParam['parameter'] = trim($aURLParam['parameter']);
if ($aURLParam['parameter'] == '' || !preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $aURLParam['parameter']) || $aURLParam['parameter'] == 'sid' || $aURLParam['parameter'] == 'newtest' || $aURLParam['parameter'] == 'token' || $aURLParam['parameter'] == 'lang') {
continue;
// this parameter name seems to be invalid - just ignore it
}
unset($aURLParam['act']);
unset($aURLParam['title']);
unset($aURLParam['id']);
if ($aURLParam['targetqid'] == '') {
$aURLParam['targetqid'] = NULL;
}
if ($aURLParam['targetsqid'] == '') {
$aURLParam['targetsqid'] = NULL;
}
$aURLParam['sid'] = $iSurveyID;
$param = new SurveyURLParameter();
foreach ($aURLParam as $k => $v) {
$param->{$k} = $v;
}
$param->save();
}
}
$updatearray = array('admin' => Yii::app()->request->getPost('admin'), 'expires' => $expires, 'startdate' => $startdate, 'anonymized' => Yii::app()->request->getPost('anonymized'), 'faxto' => Yii::app()->request->getPost('faxto'), 'format' => Yii::app()->request->getPost('format'), 'savetimings' => Yii::app()->request->getPost('savetimings'), 'template' => $template, 'assessments' => Yii::app()->request->getPost('assessments'), 'language' => Yii::app()->request->getPost('language'), 'additional_languages' => Yii::app()->request->getPost('languageids'), 'datestamp' => Yii::app()->request->getPost('datestamp'), 'ipaddr' => Yii::app()->request->getPost('ipaddr'), 'refurl' => Yii::app()->request->getPost('refurl'), 'publicgraphs' => Yii::app()->request->getPost('publicgraphs'), 'usecookie' => Yii::app()->request->getPost('usecookie'), 'allowregister' => Yii::app()->request->getPost('allowregister'), 'allowsave' => Yii::app()->request->getPost('allowsave'), 'navigationdelay' => Yii::app()->request->getPost('navigationdelay'), 'printanswers' => Yii::app()->request->getPost('printanswers'), 'publicstatistics' => Yii::app()->request->getPost('publicstatistics'), 'autoredirect' => Yii::app()->request->getPost('autoredirect'), 'showxquestions' => Yii::app()->request->getPost('showxquestions'), 'showgroupinfo' => Yii::app()->request->getPost('showgroupinfo'), 'showqnumcode' => Yii::app()->request->getPost('showqnumcode'), 'shownoanswer' => Yii::app()->request->getPost('shownoanswer'), 'showwelcome' => Yii::app()->request->getPost('showwelcome'), 'allowprev' => Yii::app()->request->getPost('allowprev'), 'questionindex' => Yii::app()->request->getPost('questionindex'), 'nokeyboard' => Yii::app()->request->getPost('nokeyboard'), 'showprogress' => Yii::app()->request->getPost('showprogress'), 'listpublic' => Yii::app()->request->getPost('public'), 'htmlemail' => Yii::app()->request->getPost('htmlemail'), 'sendconfirmation' => Yii::app()->request->getPost('sendconfirmation'), 'tokenanswerspersistence' => Yii::app()->request->getPost('tokenanswerspersistence'), 'alloweditaftercompletion' => Yii::app()->request->getPost('alloweditaftercompletion'), 'usecaptcha' => Yii::app()->request->getPost('usecaptcha'), 'emailresponseto' => trim(Yii::app()->request->getPost('emailresponseto')), 'emailnotificationto' => trim(Yii::app()->request->getPost('emailnotificationto')), 'googleanalyticsapikey' => trim(Yii::app()->request->getPost('googleanalyticsapikey')), 'googleanalyticsstyle' => trim(Yii::app()->request->getPost('googleanalyticsstyle')), 'tokenlength' => $tokenlength);
$warning = '';