当前位置: 首页>>代码示例>>PHP>>正文


PHP viewHelper::getFieldCode方法代码示例

本文整理汇总了PHP中viewHelper::getFieldCode方法的典型用法代码示例。如果您正苦于以下问题:PHP viewHelper::getFieldCode方法的具体用法?PHP viewHelper::getFieldCode怎么用?PHP viewHelper::getFieldCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在viewHelper的用法示例。


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

示例1: view

 /**
  * 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;
//.........这里部分代码省略.........
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:responses.php

示例2: oldbrowse

 /**
  * @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;
//.........这里部分代码省略.........
开发者ID:BertHankes,项目名称:LimeSurvey,代码行数:101,代码来源:responses.php

示例3: getHeadingCode

 /**
  * 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;
     }
 }
开发者ID:krsandesh,项目名称:LimeSurvey,代码行数:16,代码来源:Writer.php

示例4: browse


//.........这里部分代码省略.........
             $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");
开发者ID:Narasimman,项目名称:UrbanExpansion,代码行数:67,代码来源:responses.php

示例5: array

$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() }});
                    });
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:31,代码来源:listResponses_view.php

示例6: write

 /**
  * 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;
 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:76,代码来源:Writer.php

示例7: vvexport

 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;
//.........这里部分代码省略.........
开发者ID:ambientelivre,项目名称:LimeSurvey,代码行数:101,代码来源:export.php

示例8: createStataFieldmap

 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'));
//.........这里部分代码省略.........
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:101,代码来源:STATAxmlWriter.php

示例9: getFullHeading

 /**
  * 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;
 }
开发者ID:BelgianHealthCareKnowledgeCentre,项目名称:LS-exportCompleteAnswers,代码行数:54,代码来源:exportCompleteAnswersWriter.php

示例10: foreach

?>
:

                <?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 
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:31,代码来源:exportresults_view.php


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