コード例 #1
1
ファイル: responses.php プロジェクト: mfavetti/LimeSurvey
 /**
  * View a single response in detail
  *
  * @param mixed $iSurveyID
  * @param mixed $iId
  * @param mixed $sBrowseLang
  */
 public function view($iSurveyID, $iId, $sBrowseLang = '')
 {
     if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
         $aData = $this->_getData(array('iId' => $iId, 'iSurveyId' => $iSurveyID, 'browselang' => $sBrowseLang));
         $sBrowseLanguage = $aData['language'];
         extract($aData);
         $aViewUrls = array();
         $fieldmap = createFieldMap($iSurveyID, 'full', false, false, $aData['language']);
         $bHaveToken = $aData['surveyinfo']['anonymized'] == "N" && tableExists('tokens_' . $iSurveyID);
         // Boolean : show (or not) the token
         if (!Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read')) {
             unset($fieldmap['token']);
             $bHaveToken = false;
         }
         //add token to top of list if survey is not private
         if ($bHaveToken) {
             $fnames[] = array("token", gT("Token ID"), 'code' => 'token');
             $fnames[] = array("firstname", gT("First name"), 'code' => 'firstname');
             // or token:firstname ?
             $fnames[] = array("lastname", gT("Last name"), 'code' => 'lastname');
             $fnames[] = array("email", gT("Email"), 'code' => 'email');
         }
         $fnames[] = array("submitdate", gT("Submission date"), gT("Completed"), "0", 'D', 'code' => 'submitdate');
         $fnames[] = array("completed", gT("Completed"), "0");
         foreach ($fieldmap as $field) {
             if ($field['fieldname'] == 'lastpage' || $field['fieldname'] == 'submitdate') {
                 continue;
             }
             if ($field['type'] == 'interview_time') {
                 continue;
             }
             if ($field['type'] == 'page_time') {
                 continue;
             }
             if ($field['type'] == 'answer_time') {
                 continue;
             }
             //$question = $field['question'];
             $question = viewHelper::getFieldText($field);
             if ($field['type'] != "|") {
                 $fnames[] = array($field['fieldname'], viewHelper::getFieldText($field), 'code' => viewHelper::getFieldCode($field, array('LEMcompat' => true)));
             } elseif ($field['aid'] !== 'filecount') {
                 $qidattributes = getQuestionAttributeValues($field['qid']);
                 for ($i = 0; $i < $qidattributes['max_num_of_files']; $i++) {
                     $filenum = sprintf(gT("File %s"), $i + 1);
                     if ($qidattributes['show_title'] == 1) {
                         $fnames[] = array($field['fieldname'], "{$filenum} - {$question} (" . gT('Title') . ")", 'code' => viewHelper::getFieldCode($field) . '(title)', "type" => "|", "metadata" => "title", "index" => $i);
                     }
                     if ($qidattributes['show_comment'] == 1) {
                         $fnames[] = array($field['fieldname'], "{$filenum} - {$question} (" . gT('Comment') . ")", 'code' => viewHelper::getFieldCode($field) . '(comment)', "type" => "|", "metadata" => "comment", "index" => $i);
                     }
                     $fnames[] = array($field['fieldname'], "{$filenum} - {$question} (" . gT('File name') . ")", 'code' => viewHelper::getFieldCode($field) . '(name)', "type" => "|", "metadata" => "name", "index" => $i);
                     $fnames[] = array($field['fieldname'], "{$filenum} - {$question} (" . gT('File size') . ")", 'code' => viewHelper::getFieldCode($field) . '(size)', "type" => "|", "metadata" => "size", "index" => $i);
                     //$fnames[] = array($field['fieldname'], "File ".($i+1)." - ".$field['question']." (extension)", "type"=>"|", "metadata"=>"ext",     "index"=>$i);
                 }
             } else {
                 $fnames[] = array($field['fieldname'], gT("File count"));
             }
         }
         $nfncount = count($fnames) - 1;
         if ($iId < 1) {
             $iId = 1;
         }
         $exist = SurveyDynamic::model($iSurveyID)->exist($iId);
         $next = SurveyDynamic::model($iSurveyID)->next($iId, true);
         $previous = SurveyDynamic::model($iSurveyID)->previous($iId, true);
         $aData['exist'] = $exist;
         $aData['next'] = $next;
         $aData['previous'] = $previous;
         $aData['id'] = $iId;
         $aViewUrls[] = 'browseidheader_view';
         if ($exist) {
             $oPurifier = new CHtmlPurifier();
             //SHOW INDIVIDUAL RECORD
             $oCriteria = new CDbCriteria();
             if ($bHaveToken) {
                 $oCriteria = SurveyDynamic::model($iSurveyID)->addTokenCriteria($oCriteria);
             }
             $oCriteria->addCondition("id = {$iId}");
             $iIdresult = SurveyDynamic::model($iSurveyID)->findAllAsArray($oCriteria);
             foreach ($iIdresult as $iIdrow) {
                 $iId = $iIdrow['id'];
                 $rlanguage = $iIdrow['startlanguage'];
             }
             $aData['bHasFile'] = false;
             if (isset($rlanguage)) {
                 $aData['rlanguage'] = $rlanguage;
             }
             foreach ($iIdresult as $iIdrow) {
                 $highlight = false;
                 for ($i = 0; $i < $nfncount + 1; $i++) {
                     if ($fnames[$i][0] != 'completed' && is_null($iIdrow[$fnames[$i][0]])) {
                         continue;
                         // irrelevant, so don't show
                     }
                     $inserthighlight = '';
                     if ($highlight) {
                         $inserthighlight = "class='highlight'";
                     }
                     if ($fnames[$i][0] == 'completed') {
                         if ($iIdrow['submitdate'] == NULL || $iIdrow['submitdate'] == "N") {
                             $answervalue = "N";
                         } else {
                             $answervalue = "Y";
                         }
                     } else {
                         if (isset($fnames[$i]['type']) && $fnames[$i]['type'] == "|") {
                             $index = $fnames[$i]['index'];
                             $metadata = $fnames[$i]['metadata'];
                             $phparray = json_decode_ls($iIdrow[$fnames[$i][0]]);
                             if (isset($phparray[$index])) {
                                 switch ($metadata) {
                                     case "size":
                                         $answervalue = sprintf(gT("%s KB"), intval($phparray[$index][$metadata]));
                                         break;
                                     case "name":
                                         $answervalue = CHtml::link($oPurifier->purify(rawurldecode($phparray[$index][$metadata])), $this->getController()->createUrl("/admin/responses", array("sa" => "actionDownloadfile", "surveyid" => $surveyid, "iResponseId" => $iId, "sFileName" => $phparray[$index][$metadata])));
                                         break;
                                     default:
                                         $answervalue = htmlspecialchars(strip_tags(stripJavaScript($phparray[$index][$metadata])));
                                 }
                                 $aData['bHasFile'] = true;
                             } else {
                                 $answervalue = "";
                             }
                         } else {
                             $answervalue = htmlspecialchars(strip_tags(stripJavaScript(getExtendedAnswer($iSurveyID, $fnames[$i][0], $iIdrow[$fnames[$i][0]], $sBrowseLanguage))), ENT_QUOTES);
                         }
                     }
                     $aData['answervalue'] = $answervalue;
                     $aData['inserthighlight'] = $inserthighlight;
                     $aData['fnames'] = $fnames;
                     $aData['i'] = $i;
                     $aViewUrls['browseidrow_view'][] = $aData;
                 }
             }
         } else {
             Yii::app()->session['flashmessage'] = gT("This response ID is invalid.");
         }
         $aViewUrls[] = 'browseidfooter_view';
         $aData['sidemenu']['state'] = false;
         $aData['menu']['edition'] = true;
         $aData['menu']['view'] = true;
         $aData['menu']['close'] = true;
         // This resets the url on the close button to go to the upper view
         $aData['menu']['closeurl'] = $this->getController()->createUrl("admin/responses/sa/browse/surveyid/" . $iSurveyId);
         $this->_renderWrappedTemplate('', $aViewUrls, $aData);
     } else {
         $aData = array();
         $aData['surveyid'] = $iSurveyID;
         $message = array();
         $message['title'] = gT('Access denied!');
         $message['message'] = gT('You do not have permission to access this page.');
         $message['class'] = "error";
         $this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
     }
 }
コード例 #2
0
ファイル: responses.php プロジェクト: BertHankes/LimeSurvey
 /**
  * @deprecated
  * */
 function oldbrowse($iSurveyID)
 {
     $aData = $this->_getData($iSurveyID);
     extract($aData);
     $aViewUrls = array();
     $sBrowseLanguage = $aData['language'];
     $tokenRequest = Yii::app()->request->getParam('token', null);
     /**
      * fnames is used as informational array
      * it containts
      *             $fnames[] = array(<dbfieldname>, <some strange title>, <questiontext>, <group_id>, <questiontype>);
      */
     if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
         if (Yii::app()->request->getPost('sql')) {
             $aViewUrls[] = 'browseallfiltered_view';
         }
         //add token to top of list if survey is not private
         if ($aData['surveyinfo']['anonymized'] == "N" && tableExists('tokens_' . $iSurveyID)) {
             if (Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read')) {
                 $fnames[] = array("token", gT("Token ID"), 'code' => 'token');
                 $fnames[] = array("firstname", gT("First name"), 'code' => 'firstname');
                 // or token:firstname ?
                 $fnames[] = array("lastname", gT("Last name"), 'code' => 'lastname');
                 $fnames[] = array("email", gT("Email"), 'code' => 'email');
             }
         }
         $fnames[] = array("submitdate", gT("Completed"), gT("Completed"), "0", 'D');
         $fields = createFieldMap($iSurveyID, 'full', false, false, $aData['language']);
         foreach ($fields as $fielddetails) {
             if ($fielddetails['fieldname'] == 'lastpage' || $fielddetails['fieldname'] == 'submitdate') {
                 continue;
             }
             $question = $fielddetails['question'];
             if ($fielddetails['type'] != "|") {
                 if ($fielddetails['fieldname'] == 'lastpage' || $fielddetails['fieldname'] == 'submitdate' || $fielddetails['fieldname'] == 'token') {
                     continue;
                 }
                 // no headers for time data
                 if ($fielddetails['type'] == 'interview_time') {
                     continue;
                 }
                 if ($fielddetails['type'] == 'page_time') {
                     continue;
                 }
                 if ($fielddetails['type'] == 'answer_time') {
                     continue;
                 }
                 $fnames[] = array($fielddetails['fieldname'], viewHelper::getFieldText($fielddetails), 'code' => viewHelper::getFieldCode($fielddetails, array('LEMcompat' => true)));
             } elseif ($fielddetails['aid'] !== 'filecount') {
                 $qidattributes = getQuestionAttributeValues($fielddetails['qid']);
                 for ($i = 0; $i < $qidattributes['max_num_of_files']; $i++) {
                     $filenum = sprintf(gT("File %s"), $i + 1);
                     if ($qidattributes['show_title'] == 1) {
                         $fnames[] = array($fielddetails['fieldname'], "{$filenum} - {$question} (" . gT('Title') . ")", 'code' => viewHelper::getFieldCode($fielddetails) . '(title)', "type" => "|", "metadata" => "title", "index" => $i);
                     }
                     if ($qidattributes['show_comment'] == 1) {
                         $fnames[] = array($fielddetails['fieldname'], "{$filenum} - {$question} (" . gT('Comment') . ")", 'code' => viewHelper::getFieldCode($fielddetails) . '(comment)', "type" => "|", "metadata" => "comment", "index" => $i);
                     }
                     $fnames[] = array($fielddetails['fieldname'], "{$filenum} - {$question} (" . gT('File name') . ")", 'code' => viewHelper::getFieldCode($fielddetails) . '(name)', "type" => "|", "metadata" => "name", "index" => $i);
                     $fnames[] = array($fielddetails['fieldname'], "{$filenum} - {$question} (" . gT('File size') . ")", 'code' => viewHelper::getFieldCode($fielddetails) . '(size)', "type" => "|", "metadata" => "size", "index" => $i);
                     //$fnames[] = array($fielddetails['fieldname'], "File ".($i+1)." - ".$fielddetails['question']."(extension)", "type"=>"|", "metadata"=>"ext",     "index"=>$i);
                 }
             } else {
                 $fnames[] = array($fielddetails['fieldname'], gT("File count"), 'code' => viewHelper::getFieldCode($fielddetails));
             }
         }
         $fncount = count($fnames);
         $start = (int) Yii::app()->request->getParam('start', 0);
         $limit = (int) Yii::app()->request->getParam('limit', 50);
         $order = Yii::app()->request->getParam('order', 'asc');
         if (!$limit) {
             $limit = 50;
         }
         $oCriteria = new CDbCriteria();
         //Create the query
         if ($aData['surveyinfo']['anonymized'] == "N" && tableExists("{{tokens_{$iSurveyID}}}") && Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read')) {
             $oCriteria = SurveyDynamic::model($iSurveyID)->addTokenCriteria($oCriteria);
         }
         if (incompleteAnsFilterState() == "incomplete") {
             $oCriteria->addCondition("submitdate IS NULL");
         } elseif (incompleteAnsFilterState() == "complete") {
             $oCriteria->addCondition("submitdate IS NOT NULL");
         }
         $dtcount = SurveyDynamic::model($iSurveyID)->count($oCriteria);
         // or die("Couldn't get response data<br />");
         if ($limit > $dtcount) {
             $limit = $dtcount;
         }
         //NOW LETS SHOW THE DATA
         if (Yii::app()->request->getPost('sql') && stripcslashes(Yii::app()->request->getPost('sql')) !== "" && Yii::app()->request->getPost('sql') != "NULL") {
             $oCriteria->addCondition(stripcslashes(Yii::app()->request->getPost('sql')));
         }
         if (!is_null($tokenRequest)) {
             $oCriteria->addCondition('t.token = ' . Yii::app()->db->quoteValue($tokenRequest));
         }
         $oCriteria->order = 'id ' . ($order == 'desc' ? 'desc' : 'asc');
         $oCriteria->offset = $start;
         $oCriteria->limit = $limit;
         $dtresult = SurveyDynamic::model($iSurveyID)->findAllAsArray($oCriteria);
         $dtcount2 = count($dtresult);
         $cells = $fncount + 1;
         // Fix start if order is desc, only if actual start is 0
         if ($order == 'desc' && $start == 0) {
             $start = $dtcount - count($dtresult);
         }
         //CONTROL MENUBAR
         $last = $start - $limit;
         $next = $start + $limit;
         $end = $dtcount - $limit;
         if ($end < 0) {
             $end = 0;
         }
         if ($last < 0) {
             $last = 0;
         }
         if ($next >= $dtcount) {
             $next = $dtcount - $limit;
         }
         if ($end < 0) {
             $end = 0;
         }
         $aData['dtcount2'] = $dtcount2;
         $aData['sCompletionStateValue'] = incompleteAnsFilterState();
         $aData['start'] = $start;
         $aData['limit'] = $limit;
         $aData['last'] = $last;
         $aData['next'] = $next;
         $aData['end'] = $end;
         $aData['fncount'] = $fncount;
         $aData['fnames'] = $fnames;
         $aData['bHasFileUploadQuestion'] = hasFileUploadQuestion($iSurveyID);
         $aViewUrls[] = 'browseallheader_view';
         $bgcc = 'even';
         foreach ($dtresult as $dtrow) {
             if ($bgcc == "even") {
                 $bgcc = "odd";
             } else {
                 $bgcc = "even";
             }
             $aData['dtrow'] = $dtrow;
             $aData['bgcc'] = $bgcc;
             $aData['sBrowseLanguage'] = $sBrowseLanguage;
             $aViewUrls['browseallrow_view'][] = $aData;
         }
         $aViewUrls[] = 'browseallfooter_view';
         $this->_renderWrappedTemplate('', $aViewUrls, $aData);
     } else {
         $aData['surveyid'] = $iSurveyID;
         $message['title'] = gT('Access denied!');
         $message['message'] = gT('You do not have sufficient rights to access this page.');
         $message['class'] = "error";
         $this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
     }
 }
コード例 #3
0
ファイル: Writer.php プロジェクト: krsandesh/LimeSurvey
 /**
  * Return the question code according to options
  *
  * @param Survey $oSurvey
  * @param FormattingOptions $oOptions
  * @param string $fieldName
  * @return string
  */
 public function getHeadingCode(SurveyObj $oSurvey, FormattingOptions $oOptions, $fieldName)
 {
     if (isset($oSurvey->fieldMap[$fieldName])) {
         return viewHelper::getFieldCode($oSurvey->fieldMap[$fieldName], array('separator' => array('[', ']'), 'LEMcompat' => $oOptions->useEMCode));
     } else {
         return $fieldName;
     }
 }
コード例 #4
0
 function browse($iSurveyID)
 {
     $aData = $this->_getData($iSurveyID);
     extract($aData);
     $aViewUrls = array();
     $oBrowseLanguage = new Limesurvey_lang($aData['language']);
     $tokenRequest = Yii::app()->request->getParam('token', null);
     //Delete Individual answer using inrow delete buttons/links - checked
     if (Yii::app()->request->getPost('deleteanswer') && Yii::app()->request->getPost('deleteanswer') != '' && Yii::app()->request->getPost('deleteanswer') != 'marked') {
         if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'delete')) {
             $iResponseID = (int) Yii::app()->request->getPost('deleteanswer');
             // sanitize the value
             Response::model($iSurveyID)->findByPk($iResponseID)->delete(true);
             // delete timings if savetimings is set
             if ($aData['surveyinfo']['savetimings'] == "Y") {
                 SurveyTimingDynamic::model($iSurveyID)->deleteByPk($iResponseID);
             }
             Yii::app()->session['flashmessage'] = sprintf(gT("Response ID %s was successfully deleted."), $iResponseID);
         } else {
             Yii::app()->session['flashmessage'] = gT("Access denied!", 'js');
         }
     }
     // Marked responses -> deal with the whole batch of marked responses
     if (Yii::app()->request->getPost('markedresponses') && count(Yii::app()->request->getPost('markedresponses')) > 0) {
         // Delete the marked responses - checked
         if (Yii::app()->request->getPost('deleteanswer') && Yii::app()->request->getPost('deleteanswer') === 'marked') {
             if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'delete')) {
                 foreach (Response::model($iSurveyID)->findAllByPk(Yii::app()->request->getPost('markedresponses')) as $response) {
                     $response->deleteFiles();
                     // delete timings if savetimings is set
                     /**
                      * @todo Move this to the Response model.
                      */
                     if ($aData['surveyinfo']['savetimings'] == "Y") {
                         SurveyTimingDynamic::model($iSurveyID)->deleteByPk($iResponseID);
                     }
                 }
                 Response::model($iSurveyID)->deleteByPk(Yii::app()->request->getPost('markedresponses'));
                 Yii::app()->session['flashmessage'] = sprintf(ngT("%s response was successfully deleted.", "%s responses were successfully deleted.", count(Yii::app()->request->getPost('markedresponses'))), count(Yii::app()->request->getPost('markedresponses')), 'js');
             } else {
                 Yii::app()->session['flashmessage'] = $clang->gT("Access denied!", 'js');
             }
         } elseif (Yii::app()->request->getPost('downloadfile') && Yii::app()->request->getPost('downloadfile') === 'marked') {
             if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
                 // Now, zip all the files in the filelist
                 $zipfilename = "Responses_for_survey_{$iSurveyID}.zip";
                 $this->_zipFiles($iSurveyID, Yii::app()->request->getPost('markedresponses'), $zipfilename);
             }
         }
     } elseif (Yii::app()->request->getPost('downloadfile') && Yii::app()->request->getPost('downloadfile') != '' && Yii::app()->request->getPost('downloadfile') !== true) {
         if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
             // Now, zip all the files in the filelist
             $zipfilename = "Files_for_responses_" . Yii::app()->request->getPost('downloadfile') . ".zip";
             $this->_zipFiles($iSurveyID, Yii::app()->request->getPost('downloadfile'), $zipfilename);
         }
     } elseif (Yii::app()->request->getParam('downloadindividualfile') != '') {
         if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
             $iId = (int) Yii::app()->request->getParam('id');
             $downloadindividualfile = Yii::app()->request->getParam('downloadindividualfile');
             $fieldname = Yii::app()->request->getParam('fieldname');
             $oRow = SurveyDynamic::model($iSurveyID)->findByAttributes(array('id' => $iId));
             $phparray = json_decode_ls($oRow->{$fieldname});
             for ($i = 0; $i < count($phparray); $i++) {
                 if (rawurldecode($phparray[$i]['name']) == rawurldecode($downloadindividualfile)) {
                     $file = Yii::app()->getConfig('uploaddir') . "/surveys/" . $iSurveyID . "/files/" . $phparray[$i]['filename'];
                     if (file_exists($file)) {
                         @ob_clean();
                         header('Content-Description: File Transfer');
                         header('Content-Type: application/octet-stream');
                         header('Content-Disposition: attachment; filename="' . rawurldecode($phparray[$i]['name']) . '"');
                         header('Content-Transfer-Encoding: binary');
                         header('Expires: 0');
                         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                         header('Pragma: public');
                         header('Content-Length: ' . filesize($file));
                         readfile($file);
                         exit;
                     } else {
                         Yii::app()->session['flashmessage'] = gT("The requested file does not exist on the server.");
                     }
                     break;
                 }
             }
         }
     }
     /**
      * fnames is used as informational array
      * it containts
      *             $fnames[] = array(<dbfieldname>, <some strange title>, <questiontext>, <group_id>, <questiontype>);
      */
     if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
         if (Yii::app()->request->getPost('sql')) {
             $aViewUrls[] = 'browseallfiltered_view';
         }
         //add token to top of list if survey is not private
         if ($aData['surveyinfo']['anonymized'] == "N" && tableExists('tokens_' . $iSurveyID)) {
             if (Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read')) {
                 $fnames[] = array("token", $clang->gT("Token ID"), 'code' => 'token');
                 $fnames[] = array("firstname", $clang->gT("First name"), 'code' => 'firstname');
                 // or token:firstname ?
                 $fnames[] = array("lastname", $clang->gT("Last name"), 'code' => 'lastname');
                 $fnames[] = array("email", $clang->gT("Email"), 'code' => 'email');
             }
         }
         $fnames[] = array("submitdate", $clang->gT("Completed"), $clang->gT("Completed"), "0", 'D');
         $fields = createFieldMap($iSurveyID, 'full', false, false, $aData['language']);
         foreach ($fields as $fielddetails) {
             if ($fielddetails['fieldname'] == 'lastpage' || $fielddetails['fieldname'] == 'submitdate') {
                 continue;
             }
             $question = $fielddetails['question'];
             if ($fielddetails['type'] != "|") {
                 if ($fielddetails['fieldname'] == 'lastpage' || $fielddetails['fieldname'] == 'submitdate' || $fielddetails['fieldname'] == 'token') {
                     continue;
                 }
                 // no headers for time data
                 if ($fielddetails['type'] == 'interview_time') {
                     continue;
                 }
                 if ($fielddetails['type'] == 'page_time') {
                     continue;
                 }
                 if ($fielddetails['type'] == 'answer_time') {
                     continue;
                 }
                 $fnames[] = array($fielddetails['fieldname'], viewHelper::getFieldText($fielddetails), 'code' => viewHelper::getFieldCode($fielddetails, array('LEMcompat' => true)));
             } elseif ($fielddetails['aid'] !== 'filecount') {
                 $qidattributes = getQuestionAttributeValues($fielddetails['qid']);
                 for ($i = 0; $i < $qidattributes['max_num_of_files']; $i++) {
                     $filenum = sprintf($clang->gT("File %s"), $i + 1);
                     if ($qidattributes['show_title'] == 1) {
                         $fnames[] = array($fielddetails['fieldname'], "{$filenum} - {$question} (" . $clang->gT('Title') . ")", 'code' => viewHelper::getFieldCode($fielddetails) . '(title)', "type" => "|", "metadata" => "title", "index" => $i);
                     }
                     if ($qidattributes['show_comment'] == 1) {
                         $fnames[] = array($fielddetails['fieldname'], "{$filenum} - {$question} (" . $clang->gT('Comment') . ")", 'code' => viewHelper::getFieldCode($fielddetails) . '(comment)', "type" => "|", "metadata" => "comment", "index" => $i);
                     }
                     $fnames[] = array($fielddetails['fieldname'], "{$filenum} - {$question} (" . $clang->gT('File name') . ")", 'code' => viewHelper::getFieldCode($fielddetails) . '(name)', "type" => "|", "metadata" => "name", "index" => $i);
                     $fnames[] = array($fielddetails['fieldname'], "{$filenum} - {$question} (" . $clang->gT('File size') . ")", 'code' => viewHelper::getFieldCode($fielddetails) . '(size)', "type" => "|", "metadata" => "size", "index" => $i);
                     //$fnames[] = array($fielddetails['fieldname'], "File ".($i+1)." - ".$fielddetails['question']."(extension)", "type"=>"|", "metadata"=>"ext",     "index"=>$i);
                 }
             } else {
                 $fnames[] = array($fielddetails['fieldname'], $clang->gT("File count"), 'code' => viewHelper::getFieldCode($fielddetails));
             }
         }
         $fncount = count($fnames);
         $start = (int) Yii::app()->request->getParam('start', 0);
         $limit = (int) Yii::app()->request->getParam('limit', 50);
         $order = Yii::app()->request->getParam('order', 'asc');
         if (!$limit) {
             $limit = 50;
         }
         $oCriteria = new CDbCriteria();
         //Create the query
         if ($aData['surveyinfo']['anonymized'] == "N" && tableExists("{{tokens_{$iSurveyID}}}") && Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read')) {
             $oCriteria = SurveyDynamic::model($iSurveyID)->addTokenCriteria($oCriteria);
         }
         if (incompleteAnsFilterState() == "incomplete") {
             $oCriteria->addCondition("submitdate IS NULL");
         } elseif (incompleteAnsFilterState() == "complete") {
             $oCriteria->addCondition("submitdate IS NOT NULL");
         }
         $dtcount = SurveyDynamic::model($iSurveyID)->count($oCriteria);
         // or die("Couldn't get response data<br />");
         if ($limit > $dtcount) {
             $limit = $dtcount;
         }
         //NOW LETS SHOW THE DATA
         if (Yii::app()->request->getPost('sql') && stripcslashes(Yii::app()->request->getPost('sql')) !== "" && Yii::app()->request->getPost('sql') != "NULL") {
             $oCriteria->addCondition(stripcslashes(Yii::app()->request->getPost('sql')));
         }
         if (!is_null($tokenRequest)) {
             $oCriteria->addCondition('t.token = ' . Yii::app()->db->quoteValue($tokenRequest));
         }
         $oCriteria->order = 'id ' . ($order == 'desc' ? 'desc' : 'asc');
         $oCriteria->offset = $start;
         $oCriteria->limit = $limit;
         $dtresult = SurveyDynamic::model($iSurveyID)->findAllAsArray($oCriteria);
         $dtcount2 = count($dtresult);
         $cells = $fncount + 1;
         // Fix start if order is desc, only if actual start is 0
         if ($order == 'desc' && $start == 0) {
             $start = $dtcount - count($dtresult);
         }
         //CONTROL MENUBAR
         $last = $start - $limit;
         $next = $start + $limit;
         $end = $dtcount - $limit;
         if ($end < 0) {
             $end = 0;
         }
         if ($last < 0) {
             $last = 0;
         }
         if ($next >= $dtcount) {
             $next = $dtcount - $limit;
         }
         if ($end < 0) {
             $end = 0;
         }
         $aData['dtcount2'] = $dtcount2;
         $aData['sCompletionStateValue'] = incompleteAnsFilterState();
         $aData['start'] = $start;
         $aData['limit'] = $limit;
         $aData['last'] = $last;
         $aData['next'] = $next;
         $aData['end'] = $end;
         $aData['fncount'] = $fncount;
         $aData['fnames'] = $fnames;
         $aData['bHasFileUploadQuestion'] = hasFileUploadQuestion($iSurveyID);
         $aViewUrls[] = 'browseallheader_view';
         $bgcc = 'even';
         foreach ($dtresult as $dtrow) {
             if ($bgcc == "even") {
                 $bgcc = "odd";
             } else {
                 $bgcc = "even";
             }
             $aData['dtrow'] = $dtrow;
             $aData['bgcc'] = $bgcc;
             $aData['oBrowseLanguage'] = $oBrowseLanguage;
             $aViewUrls['browseallrow_view'][] = $aData;
         }
         $aViewUrls[] = 'browseallfooter_view';
         $this->_renderWrappedTemplate('', $aViewUrls, $aData);
     } else {
         $clang = $this->getController()->lang;
         $aData['surveyid'] = $iSurveyID;
         App()->getClientScript()->registerPackage('jquery-superfish');
         $message['title'] = $clang->gT('Access denied!');
         $message['message'] = $clang->gT('You do not have sufficient rights to access this page.');
         $message['class'] = "error";
         $this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
     }
 }
コード例 #5
0
$aColumns[] = array('header' => 'lastpage', 'name' => 'lastpage', 'type' => 'number', 'filter' => TbHtml::textField('SurveyDynamic[lastpage]', $model->lastpage));
$aColumns[] = array('header' => gT("completed"), 'name' => 'completed_filter', 'value' => '$data->completed', 'type' => 'raw', 'filter' => TbHtml::dropDownList('SurveyDynamic[completed_filter]', $model->completed_filter, array('' => gT('All'), 'Y' => gT('Yes'), 'N' => gT('No'))));
//add token to top of list if survey is not private
if ($bHaveToken) {
    $aColumns[] = array('header' => 'token', 'name' => 'token', 'type' => 'raw', 'value' => '$data->tokenForGrid');
    $aColumns[] = array('header' => gT("First name"), 'name' => 'tokens.firstname', 'id' => 'firstname', 'type' => 'raw', 'value' => '$data->firstNameForGrid', 'filter' => TbHtml::textField('SurveyDynamic[firstname_filter]', $model->firstname_filter));
    $aColumns[] = array('header' => gT("Last name"), 'name' => 'tokens.lastname', 'type' => 'raw', 'id' => 'lastname', 'value' => '$data->lastNameForGrid', 'filter' => TbHtml::textField('SurveyDynamic[lastname_filter]', $model->lastname_filter));
    $aColumns[] = array('header' => gT("Email"), 'name' => 'tokens.email', 'id' => 'email', 'filter' => TbHtml::textField('SurveyDynamic[email_filter]', $model->email_filter));
}
$aColumns[] = array('header' => 'startlanguage', 'name' => 'startlanguage');
// The column model must be built dynamically, since the columns will differ from survey to survey, depending on the questions.
// All other columns are based on the questions.
// An array to control unicity of $code (EM code)
foreach ($model->metaData->columns as $column) {
    if (!in_array($column->name, $aDefaultColumns)) {
        $colName = viewHelper::getFieldCode($fieldmap[$column->name], array('LEMcompat' => true));
        // This must be unique ......
        $base64jsonFieldMap = base64_encode(json_encode($fieldmap[$column->name]));
        $aColumns[] = array('header' => '<span data-toggle="tooltip" data-placement="bottom" title="' . quoteText(strip_tags($fieldmap[$column->name]['question'])) . '">' . $colName . ' <br/> ' . ellipsize($fieldmap[$column->name]['question'], $model->ellipsize_header_value) . '</span>', 'headerHtmlOptions' => array('style' => 'min-width: 350px;'), 'name' => $column->name, 'type' => 'raw', 'value' => '$data->getExtendedData("' . $column->name . '", "' . $language . '", "' . $base64jsonFieldMap . '")');
    }
}
$this->widget('bootstrap.widgets.TbGridView', array('dataProvider' => $model->search(), 'filter' => $model, 'columns' => $aColumns, 'itemsCssClass' => 'table-striped', 'id' => 'responses-grid', 'ajaxUpdate' => true, 'ajaxType' => 'POST', 'afterAjaxUpdate' => 'bindScrollWrapper', 'template' => "{items}\n<div id='ListPager'><div class=\"col-sm-4\" id=\"massive-action-container\">{$massiveAction}</div><div class=\"col-sm-4 pager-container \">{pager}</div><div class=\"col-sm-4 summary-container\">{summary}</div></div>", 'summaryText' => gT('Displaying {start}-{end} of {count} result(s).') . ' ' . sprintf(gT('%s rows per page'), CHtml::dropDownList('pageSize', $pageSize, Yii::app()->params['pageSizeOptions'], array('class' => 'changePageSize form-control', 'style' => 'display: inline; width: auto')))));
?>
            </div>

            <!-- To update rows per page via ajax -->
            <script type="text/javascript">
                jQuery(function($) {
                    jQuery(document).on("change", '#pageSize', function(){
                        $.fn.yiiGridView.update('responses-grid',{ data:{ pageSize: $(this).val() }});
                    });
コード例 #6
0
ファイル: Writer.php プロジェクト: jdbaltazar/survey-office
 /**
  * This method is made final to prevent extending code from circumventing the
  * initialization process that must take place prior to any of the translation
  * infrastructure to work.
  *
  * The inialization process is dependent upon the survey being passed into the
  * write function and so must be performed when the method is called and not
  * prior to (such as in a constructor).
  *
  * All extending classes must implement the internalWrite function which is
  * the code that is called after all initialization is completed.
  *
  * @param Survey $survey
  * @param string $sLanguageCode
  * @param FormattingOptions $oOptions
  * @param boolean $bOutputHeaders Set if header should be given back
  */
 public final function write(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions, $bOutputHeaders = true)
 {
     //Output the survey.
     $headers = array();
     if ($bOutputHeaders) {
         foreach ($oOptions->selectedColumns as $column) {
             //Survey question field, $column value is a field name from the getFieldMap function.
             switch ($oOptions->headingFormat) {
                 case 'abbreviated':
                     $value = $this->getAbbreviatedHeading($survey, $column);
                     break;
                 case 'full':
                     $value = $this->getFullHeading($survey, $oOptions, $column);
                     break;
                 default:
                 case 'code':
                     if (isset($survey->fieldMap[$column])) {
                         $value = viewHelper::getFieldCode($survey->fieldMap[$column]);
                     } else {
                         // Token field
                         $value = $column;
                     }
                     break;
             }
             if ($oOptions->headerSpacesToUnderscores) {
                 $value = str_replace(' ', '_', $value);
             }
             //$this->output.=$this->csvEscape($value).$this->separator;
             $headers[] = $value;
         }
     }
     //Output the results.
     $sFile = '';
     foreach ($survey->responses as $response) {
         $elementArray = array();
         foreach ($oOptions->selectedColumns as $column) {
             $value = $response[$column];
             if (isset($survey->fieldMap[$column]) && $survey->fieldMap[$column]['type'] != 'answer_time' && $survey->fieldMap[$column]['type'] != 'page_time' && $survey->fieldMap[$column]['type'] != 'interview_time') {
                 switch ($oOptions->answerFormat) {
                     case 'long':
                         $elementArray[] = $this->transformResponseValue($survey->getFullAnswer($column, $value, $this->translator, $this->languageCode), $survey->fieldMap[$column]['type'], $oOptions);
                         break;
                     default:
                     case 'short':
                         $elementArray[] = $this->transformResponseValue($value, $survey->fieldMap[$column]['type'], $oOptions);
                         break;
                 }
             } else {
                 $elementArray[] = $value;
             }
         }
         if ($oOptions->output == 'display') {
             $this->outputRecord($headers, $elementArray, $oOptions);
         } else {
             $sFile .= $this->outputRecord($headers, $elementArray, $oOptions);
         }
     }
     return $sFile;
 }
コード例 #7
0
ファイル: export.php プロジェクト: ambientelivre/LimeSurvey
 public function vvexport()
 {
     $iSurveyId = sanitize_int(Yii::app()->request->getParam('surveyid'));
     $subaction = Yii::app()->request->getParam('subaction');
     //Exports all responses to a survey in special "Verified Voting" format.
     if (!Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'export')) {
         Yii::app()->session['flashmessage'] = gT("You do not have sufficient rights to access this page.");
         $this->getController()->redirect($this->getController()->createUrl("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
     }
     if ($subaction != "export") {
         $aData['selectincansstate'] = incompleteAnsFilterState();
         $aData['surveyid'] = $iSurveyId;
         $aData['display']['menu_bars']['browse'] = gT("Export VV file");
         $fieldmap = createFieldMap($iSurveyId, 'full', false, false, getBaseLanguageFromSurveyID($iSurveyId));
         Survey::model()->findByPk($iSurveyId)->language;
         $surveytable = "{{survey_{$iSurveyId}}}";
         // Control if fieldcode are unique
         $fieldnames = Yii::app()->db->schema->getTable($surveytable)->getColumnNames();
         foreach ($fieldnames as $field) {
             $fielddata = arraySearchByKey($field, $fieldmap, "fieldname", 1);
             $fieldcode[] = viewHelper::getFieldCode($fielddata, array("LEMcompat" => true));
         }
         $aData['uniquefieldcode'] = count(array_unique($fieldcode)) == count($fieldcode);
         // Did we need more control ?
         $aData['vvversionseleted'] = $aData['uniquefieldcode'] ? 2 : 1;
         $this->_renderWrappedTemplate('export', 'vv_view', $aData);
     } elseif (isset($iSurveyId) && $iSurveyId) {
         //Export is happening
         $extension = sanitize_paranoid_string(returnGlobal('extension'));
         $vvVersion = (int) Yii::app()->request->getPost('vvversion');
         $vvVersion = in_array($vvVersion, array(1, 2)) ? $vvVersion : 2;
         // Only 2 version actually, default to 2
         $fn = "vvexport_{$iSurveyId}." . $extension;
         $this->_addHeaders($fn, "text/comma-separated-values", 0, "cache");
         $s = "\t";
         $fieldmap = createFieldMap($iSurveyId, 'full', false, false, getBaseLanguageFromSurveyID($iSurveyId));
         $surveytable = "{{survey_{$iSurveyId}}}";
         Survey::model()->findByPk($iSurveyId)->language;
         $fieldnames = Yii::app()->db->schema->getTable($surveytable)->getColumnNames();
         //Create the human friendly first line
         $firstline = "";
         $secondline = "";
         foreach ($fieldnames as $field) {
             $fielddata = arraySearchByKey($field, $fieldmap, "fieldname", 1);
             if (count($fielddata) < 1) {
                 $firstline .= $field;
             } else {
                 $firstline .= preg_replace('/\\s+/', ' ', strip_tags($fielddata['question']));
             }
             $firstline .= $s;
             if ($vvVersion == 2) {
                 $fieldcode = viewHelper::getFieldCode($fielddata, array("LEMcompat" => true));
                 $fieldcode = $fieldcode ? $fieldcode : $field;
                 // $fieldcode is empty for token if there are no token table
             } else {
                 $fieldcode = $field;
             }
             $secondline .= $fieldcode . $s;
         }
         $vvoutput = $firstline . "\n";
         $vvoutput .= $secondline . "\n";
         $query = "SELECT * FROM " . Yii::app()->db->quoteTableName($surveytable);
         if (incompleteAnsFilterState() == "incomplete") {
             $query .= " WHERE submitdate IS NULL ";
         } elseif (incompleteAnsFilterState() == "complete") {
             $query .= " WHERE submitdate >= '01/01/1980' ";
         }
         $result = Yii::app()->db->createCommand($query)->query();
         echo $vvoutput;
         foreach ($result as $row) {
             foreach ($fieldnames as $field) {
                 if (is_null($row[$field])) {
                     $value = '{question_not_shown}';
                 } else {
                     $value = trim($row[$field]);
                     // sunscreen for the value. necessary for the beach.
                     // careful about the order of these arrays:
                     // lbrace has to be substituted *first*
                     $value = str_replace(array("{", "\n", "\r", "\t"), array("{lbrace}", "{newline}", "{cr}", "{tab}"), $value);
                 }
                 // one last tweak: excel likes to quote values when it
                 // exports as tab-delimited (esp if value contains a comma,
                 // oddly enough).  So we're going to encode a leading quote,
                 // if it occurs, so that we can tell the difference between
                 // strings that "really are" quoted, and those that excel quotes
                 // for us.
                 $value = preg_replace('/^"/', '{quote}', $value);
                 // yay!  that nasty soab won't hurt us now!
                 if ($field == "submitdate" && !$value) {
                     $value = "NULL";
                 }
                 $sun[] = $value;
             }
             /* it is important here to stream output data, line by line
              * in order to avoid huge memory consumption when exporting large
              * quantities of answers */
             echo implode($s, $sun) . "\n";
             unset($sun);
         }
         exit;
     }
 }
コード例 #8
0
 function createStataFieldmap($survey, $sLanguage, $oOptions)
 {
     App()->setLanguage($sLanguage);
     $yvalue = $oOptions->convertY ? $oOptions->yValue : '1';
     // set value for Y if it is set in export settings (needed for correct value label)
     $nvalue = $oOptions->convertN ? $oOptions->nValue : '2';
     // set value for N if it is set in export settings (needed for correct value label)
     //create fieldmap only with the columns (variables) selected
     $aFieldmap['questions'] = array_intersect_key($survey->fieldMap, array_flip($oOptions->selectedColumns));
     //tokens need to be "smuggled" into the fieldmap as additional questions
     $aFieldmap['tokenFields'] = array_intersect_key($survey->tokenFields, array_flip($oOptions->selectedColumns));
     foreach ($aFieldmap['tokenFields'] as $key => $value) {
         $aFieldmap['questions'][$key] = $value;
         $aFieldmap['questions'][$key]['qid'] = '';
         $aFieldmap['questions'][$key]['question'] = $value['description'];
         $aFieldmap['questions'][$key]['fieldname'] = $key;
         $aFieldmap['questions'][$key]['type'] = 'S';
     }
     // add only questions and answers to the fieldmap that are relevant to the selected columns (variables)
     foreach ($aFieldmap['questions'] as $question) {
         $aUsedQIDs[] = $question['qid'];
     }
     $aFieldmap['answers'] = array_intersect_key($survey->answers, array_flip($aUsedQIDs));
     // add per-survey info
     $aFieldmap['info'] = $survey->info;
     // STATA only uses value labels on numerical variables. If the answer codes are not numerical we later replace them with the text-answer
     // here we go through the answers-array and check whether answer-codes are numerical. If they are not, we save the respective QIDs
     // so responses can later be set to full answer test of Question or SQ'
     foreach ($aFieldmap['answers'] as $qid => $aScale) {
         foreach ($aFieldmap['answers'][$qid] as $iScale => $aAnswers) {
             foreach ($aFieldmap['answers'][$qid][$iScale] as $iAnswercode => $aAnswer) {
                 if (!is_numeric($aAnswer['code'])) {
                     $this->aQIDnonumericalAnswers[$aAnswer['qid']] = true;
                 }
             }
         }
     }
     // go through the questions array and create/modify vars for STATA-output
     foreach ($aFieldmap['questions'] as $sSGQAkey => $aQuestion) {
         // STATA does not support attaching value labels to non-numerical values
         // We therefore set a flag in questions array for non-numerical answer codes.
         // The respective codes are later recoded to contain the full answers
         if (array_key_exists($aQuestion['qid'], $this->aQIDnonumericalAnswers)) {
             $aFieldmap['questions'][$sSGQAkey]['nonnumericanswercodes'] = true;
         } else {
             $aFieldmap['questions'][$sSGQAkey]['nonnumericanswercodes'] = false;
         }
         // create 'varname' from Question/Subquestiontitles
         $aQuestion['varname'] = viewHelper::getFieldCode($aFieldmap['questions'][$sSGQAkey]);
         //set field types for standard vars
         if ($aQuestion['varname'] == 'submitdate' || $aQuestion['varname'] == 'startdate' || $aQuestion['varname'] == 'datestamp') {
             $aFieldmap['questions'][$sSGQAkey]['type'] = 'D';
         } elseif ($aQuestion['varname'] == 'startlanguage') {
             $aFieldmap['questions'][$sSGQAkey]['type'] = 'S';
         } elseif ($aQuestion['varname'] == 'token') {
             $aFieldmap['questions'][$sSGQAkey]['type'] = 'S';
         } elseif ($aQuestion['varname'] == 'id') {
             $aFieldmap['questions'][$sSGQAkey]['type'] = 'N';
         } elseif ($aQuestion['varname'] == 'ipaddr') {
             $aFieldmap['questions'][$sSGQAkey]['type'] = 'S';
         } elseif ($aQuestion['varname'] == 'refurl') {
             $aFieldmap['questions'][$sSGQAkey]['type'] = 'S';
         } elseif ($aQuestion['varname'] == 'lastpage') {
             $aFieldmap['questions'][$sSGQAkey]['type'] = 'N';
         }
         //Rename the variables if original name is not STATA-compatible
         $aQuestion['varname'] = $this->STATAvarname($aQuestion['varname']);
         // create variable labels
         $aQuestion['varlabel'] = $aQuestion['question'];
         if (isset($aQuestion['scale'])) {
             $aQuestion['varlabel'] = "[{$aQuestion['scale']}] " . $aQuestion['varlabel'];
         }
         if (isset($aQuestion['subquestion'])) {
             $aQuestion['varlabel'] = "[{$aQuestion['subquestion']}] " . $aQuestion['varlabel'];
         }
         if (isset($aQuestion['subquestion2'])) {
             $aQuestion['varlabel'] = "[{$aQuestion['subquestion2']}] " . $aQuestion['varlabel'];
         }
         if (isset($aQuestion['subquestion1'])) {
             $aQuestion['varlabel'] = "[{$aQuestion['subquestion1']}] " . $aQuestion['varlabel'];
         }
         //write varlabel back to fieldmap
         $aFieldmap['questions'][$sSGQAkey]['varlabel'] = $aQuestion['varlabel'];
         //create value labels for question types with "fixed" answers (YES/NO etc.)
         if (isset($aQuestion['other']) && $aQuestion['other'] == 'Y' || substr($aQuestion['fieldname'], -7) == 'comment') {
             $aFieldmap['questions'][$sSGQAkey]['commentother'] = true;
             //comment/other fields: create flag, so value labels are not attached (in close())
         } else {
             $aFieldmap['questions'][$sSGQAkey]['commentother'] = false;
             if ($aQuestion['type'] == 'M') {
                 $aFieldmap['answers'][$aQuestion['qid']]['0'][$yvalue] = array('code' => $yvalue, 'answer' => gT('Yes'));
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['0'] = array('code' => 0, 'answer' => gT('Not Selected'));
             } elseif ($aQuestion['type'] == "P") {
                 $aFieldmap['answers'][$aQuestion['qid']]['0'][$yvalue] = array('code' => $yvalue, 'answer' => gT('Yes'));
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['0'] = array('code' => 0, 'answer' => gT('Not Selected'));
             } elseif ($aQuestion['type'] == "G") {
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['0'] = array('code' => 'F', 'answer' => gT('Female'));
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['1'] = array('code' => 'M', 'answer' => gT('Male'));
             } elseif ($aQuestion['type'] == "Y") {
                 $aFieldmap['answers'][$aQuestion['qid']]['0'][$yvalue] = array('code' => $yvalue, 'answer' => gT('Yes'));
                 $aFieldmap['answers'][$aQuestion['qid']]['0'][$nvalue] = array('code' => $nvalue, 'answer' => gT('No'));
             } elseif ($aQuestion['type'] == "C") {
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['1'] = array('code' => 1, 'answer' => gT('Yes'));
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['0'] = array('code' => 2, 'answer' => gT('No'));
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['9'] = array('code' => 3, 'answer' => gT('Uncertain'));
             } elseif ($aQuestion['type'] == "E") {
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['1'] = array('code' => 1, 'answer' => gT('Increase'));
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['0'] = array('code' => 2, 'answer' => gT('Same'));
                 $aFieldmap['answers'][$aQuestion['qid']]['0']['-1'] = array('code' => 3, 'answer' => gT('Decrease'));
             }
         }
         // close: no-other/comment variable
         $aFieldmap['questions'][$sSGQAkey]['varname'] = $aQuestion['varname'];
         //write changes back to array
     }
     // close foreach question
     // clean up fieldmap (remove HTML tags, CR/LS, etc.)
     $aFieldmap = $this->stripArray($aFieldmap);
     return $aFieldmap;
 }
 /**
  * Returns the adapted heading using parent function
  *
  * @param Survey $survey
  * @param FormattingOptions $oOptions
  * @param string $fieldName
  * @return string (or false)
  */
 public function getFullHeading(SurveyObj $survey, FormattingOptions $oOptions, $fieldName)
 {
     $sQuestion = "";
     static $aColumnDone = array();
     switch ($this->oldHeadFormat) {
         case 'abbreviated':
             $sQuestion = parent::getAbbreviatedHeading($survey, $fieldName);
             break;
         case 'full':
             $sQuestion = parent::getFullHeading($survey, $oOptions, $fieldName);
             break;
         default:
         case 'code':
             if (isset($survey->fieldMap[$fieldName])) {
                 $sQuestion = viewHelper::getFieldCode($survey->fieldMap[$fieldName]);
             } else {
                 // Token field
                 $sQuestion = $column;
             }
             break;
     }
     if ($oOptions->headerSpacesToUnderscores) {
         $sQuestion = str_replace(' ', '_', $sQuestion);
     }
     if ($this->exportAnswerPosition == 'aseperatecodetext') {
         if (isset($survey->fieldMap[$fieldName])) {
             $aField = $survey->fieldMap[$fieldName];
             if (!self::sameTextAndCode($aField['type'], $fieldName)) {
                 if (!array_key_exists($fieldName, $aColumnDone)) {
                     // Code export
                     $sQuestion = $this->beforeHeadColumnCode . $sQuestion . $this->afterHeadColumnCode;
                     $aColumnDone[$fieldName] = 1;
                 } else {
                     // Text export
                     $sQuestion = $this->beforeHeadColumnFull . $sQuestion . $this->afterHeadColumnFull;
                     unset($aColumnDone[$fieldName]);
                 }
             } else {
                 $sQuestion = $sQuestion;
             }
         } else {
             $sQuestion = $sQuestion;
         }
     }
     return $sQuestion;
 }
コード例 #10
0
?>
:

                <?php 
if ($afieldcount > 255) {
    echo "\t<img src='{$imageurl}/help.gif' alt='" . $clang->gT("Help") . "' onclick='javascript:alert(\"" . $clang->gT("Your survey contains more than 255 columns of responses. Spreadsheet applications such as Excel are limited to loading no more than 255. Select the columns you wish to export in the list below.", "js") . "\")' />";
} else {
    echo "\t<img src='{$imageurl}/help.gif' alt='" . $clang->gT("Help") . "' onclick='javascript:alert(\"" . $clang->gT("Choose the columns you wish to export.", "js") . "\")' />";
}
?>
                <br /><select name='colselect[]' multiple size='20'>
                    <?php 
$i = 1;
foreach ($excesscols as $sFieldName => $fieldinfo) {
    $questiontext = viewHelper::getFieldText($fieldinfo);
    $questioncode = viewHelper::getFieldCode($fieldinfo);
    echo "<option value='{$sFieldName}'";
    if (isset($_POST['summary'])) {
        if (in_array($ec, $_POST['summary'])) {
            echo "selected";
        }
    } elseif ($i < 256) {
        echo " selected";
    }
    echo " title='{$sFieldName} : " . str_replace("'", "&#39;", $questiontext) . "'>" . ellipsize("{$i} : {$questioncode} - " . str_replace(array("\r\n", "\n", "\r"), " ", $questiontext), 45) . "</option>\n";
    $i++;
}
?>
                </select>
                <br />&nbsp;</fieldset>
            <?php