Exemple #1
0
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     App()->setLanguage($sLanguageCode);
     if ($oOptions->output == 'display') {
         header("Content-Disposition: attachment; filename=results-survey" . $survey->id . ".doc");
         header("Content-type: application/vnd.ms-word");
     }
     $sOutput = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <style>
     table {
     border-collapse:collapse;
     }
     td, th {
     border:solid black 1.0pt;
     }
     th {
     background: #c0c0c0;
     }
     </style>';
     if ($oOptions->output == 'display') {
         echo $sOutput;
     } elseif ($oOptions->output == 'file') {
         $this->file = fopen($this->filename, 'w');
         $this->output = $sOutput;
     }
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $this->survey = $survey;
     if ($oOptions->output == 'display') {
         //header("Content-Disposition: attachment; filename=results-survey".$survey->id.".html");
         header("Content-type: text/html; charset=UTF-8");
         $this->handle = fopen('php://output', 'w');
     } elseif ($oOptions->output == 'file') {
         $this->handle = fopen($this->filename, 'w');
     }
     $this->groupMap = array();
     $index = 0;
     foreach ($oOptions->selectedColumns as $column) {
         if (isset($survey->fieldMap[$column])) {
             $question = $survey->fieldMap[$column];
         } else {
             // Token field
             $question = array('gid' => 0, 'qid' => '');
         }
         $question['index'] = $index;
         $this->groupMap[intval($question['gid'])][] = $question;
         $index++;
     }
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     if ($oOptions->output == 'display') {
         header("Content-Disposition: attachment; filename=survey_" . $survey->id . "_R_syntax_file.R");
         header("Content-type: application/download; charset=UTF-8");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Pragma: public");
         $this->handle = fopen('php://output', 'w');
     } elseif ($oOptions->output == 'file') {
         $this->handle = fopen($this->filename, 'w');
     }
     $this->out('data <- read.csv("survey_' . $survey->id . '_R_data_file.csv", quote = "\'\\"", na.strings=c("", "\\"\\""), stringsAsFactors=FALSE)');
     $this->out("");
     $this->out("");
     $oOptions->headingFormat = 'code';
     // Always use fieldcodes
     // R specific stuff
     Yii::app()->loadHelper("export");
     $tmpFieldmap = SPSSFieldMap($survey->id);
     foreach ($tmpFieldmap as $field => $values) {
         $fieldmap[$values['title']] = $values;
         if (array_key_exists('sql_name', $values)) {
             $fieldmap[$values['sql_name']] = $values;
         }
     }
     $this->customFieldmap = $fieldmap;
 }
Exemple #4
0
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $this->csvFilename = "results-survey" . $survey->id . ".csv";
     if ($oOptions->output == 'file') {
         $this->file = fopen($this->filename, 'w');
     }
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $sStartOutput = '{' . json_encode("responses") . ': [';
     if ($oOptions->output == 'display') {
         header("Content-type: application/json");
         echo $sStartOutput;
     } elseif ($oOptions->output == 'file') {
         $this->file = fopen($this->filename, 'w');
         fwrite($this->file, $sStartOutput);
     }
 }
Exemple #6
0
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $this->survey = $survey;
     if ($oOptions->output == 'display') {
         //header("Content-Disposition: attachment; filename=results-survey".$survey->id.".html");
         header("Content-type: text/html; charset=UTF-8");
         $this->handle = fopen('php://output', 'w');
     } elseif ($oOptions->output == 'file') {
         $this->handle = fopen($this->filename, 'w');
     }
     $this->groupMap = $this->setGroupMap($survey, $oOptions);
 }
Exemple #7
0
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $this->workbook = new XLSXWriter();
     $this->workbook->setTempDir(Yii::app()->getConfig('tempdir'));
     $worksheetName = $survey->languageSettings['surveyls_title'];
     $worksheetName = substr(str_replace(array('*', ':', '/', '\\', '?', '[', ']'), array(' '), $worksheetName), 0, 31);
     // Remove invalid characters
     if ($worksheetName == '') {
         $worksheetName = 'survey_' . $survey->id;
     }
     $this->currentSheet = $worksheetName;
     $this->forceDownload = !($oOptions->output == 'file');
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     if ($oOptions->output == 'display') {
         header("Content-Disposition: attachment; filename=survey_" . $survey->id . "_STATA.xml");
         header("Content-type: application/download; charset=US-ASCII");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Pragma: public");
         $this->handle = fopen('php://output', 'w');
     } elseif ($oOptions->output == 'file') {
         $this->handle = fopen($this->filename, 'w');
     }
     $this->headersSGQA = $oOptions->selectedColumns;
     $oOptions->headingFormat = 'code';
     // Always use fieldcodes
     $this->customFieldmap = $this->createStataFieldmap($survey, $sLanguageCode, $oOptions);
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $pdforientation = Yii::app()->getConfig('pdforientation');
     if ($oOptions->output == 'file') {
         $this->pdfDestination = 'F';
     } else {
         $this->pdfDestination = 'D';
     }
     Yii::import('application.libraries.admin.pdf', true);
     Yii::import('application.helpers.pdfHelper');
     $aPdfLanguageSettings = pdfHelper::getPdfLanguageSettings($sLanguageCode);
     // create PDF document
     $this->pdf = new pdf();
     $this->surveyName = $survey->info['surveyls_title'];
     $this->pdf->initAnswerPDF($survey->info, $aPdfLanguageSettings, Yii::app()->getConfig('sitename'), $this->surveyName);
     $this->separator = "\t";
     $this->rowCounter = 0;
     $this->aGroupMap = $this->setGroupMap($survey, $oOptions);
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     if ($oOptions->output == 'file') {
         $this->workbook = new xlswriter($this->filename);
         $this->outputToFile = true;
     } else {
         $this->workbook = new xlswriter();
     }
     $this->workbook->setTempDir(Yii::app()->getConfig("tempdir"));
     if ($oOptions->output == 'display') {
         $this->workbook->send('results-survey' . $survey->id . '.xls');
     }
     $worksheetName = $survey->languageSettings['surveyls_title'];
     $worksheetName = substr(str_replace(array('*', ':', '/', '\\', '?', '[', ']'), array(' '), $worksheetName), 0, 31);
     // Remove invalid characters
     $this->workbook->setVersion(8);
     $sheet = $this->workbook->addWorksheet($worksheetName);
     // do not translate/change this - the library does not support any special chars in sheet name
     $sheet->setInputEncoding('utf-8');
     $this->currentSheet = $sheet;
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $pdforientation = Yii::app()->getConfig('pdforientation');
     $this->clang = new limesurvey_lang($sLanguageCode);
     if ($oOptions->output == 'file') {
         $this->pdfDestination = 'F';
     } else {
         $this->pdfDestination = 'D';
     }
     Yii::import('application.libraries.admin.pdf', true);
     Yii::import('application.helpers.pdfHelper');
     $aPdfLanguageSettings = pdfHelper::getPdfLanguageSettings($sLanguageCode);
     // create new PDF document
     $this->pdf = new pdf();
     $this->pdf->SetFont($aPdfLanguageSettings['pdffont'], '', $aPdfLanguageSettings['pdffontsize']);
     $this->pdf->AddPage();
     $this->pdf->intopdf("PDF export " . date("Y.m.d-H:i", time()));
     $this->pdf->setLanguageArray($aPdfLanguageSettings['lg']);
     $this->separator = "\t";
     $this->rowCounter = 0;
     $this->surveyName = $survey->languageSettings['surveyls_title'];
     $this->pdf->titleintopdf($this->surveyName, $survey->languageSettings['surveyls_description']);
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     if ($oOptions->output == 'file') {
         $this->pdfDestination = 'F';
     } else {
         $this->pdfDestination = 'D';
     }
     //The $pdforientation, $pdfDefaultFont, and $pdfFontSize values
     //come from the Lime Survey config files.
     global $pdforientation, $pdfdefaultfont, $pdffontsize;
     Yii::import('application.libraries.admin.pdf', true);
     $this->pdf = new pdf();
     $this->pdf->SetFont(Yii::app()->getConfig('pdfdefaultfont'), '', Yii::app()->getConfig('pdffontsize'));
     $this->pdf->AddPage();
     $this->pdf->intopdf("PDF export " . date("Y.m.d-H:i", time()));
     $this->separator = "\t";
     $this->rowCounter = 0;
     $this->surveyName = $survey->languageSettings[0]['surveyls_title'];
     $this->pdf->titleintopdf($this->surveyName, $survey->languageSettings[0]['surveyls_description']);
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $this->surveyName = $survey->languageSettings[0]['surveyls_title'];
     $this->pdf->titleintopdf($this->surveyName, $survey->languageSettings[0]['surveyls_description']);
 }
 public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
 {
     parent::init($survey, $sLanguageCode, $oOptions);
     $pdfdefaultfont = Yii::app()->getConfig('pdfdefaultfont');
     $pdffontsize = Yii::app()->getConfig('pdffontsize');
     $pdforientation = Yii::app()->getConfig('pdforientation');
     $clang = new limesurvey_lang($sLanguageCode);
     if ($oOptions->output == 'file') {
         $this->pdfDestination = 'F';
     } else {
         $this->pdfDestination = 'D';
     }
     Yii::import('application.libraries.admin.pdf', true);
     if ($pdfdefaultfont == 'auto') {
         $pdfdefaultfont = PDF_FONT_NAME_DATA;
     }
     // Array of PDF core fonts: are replaced by according fonts according to the alternatepdffontfile array.Maybe just courier,helvetica and times but if a user want symbol: why not ....
     $pdfcorefont = array("courier", "helvetica", "symbol", "times", "zapfdingbats");
     $pdffontsize = Yii::app()->getConfig('pdffontsize');
     // create new PDF document
     $this->pdf = new pdf();
     if (in_array($pdfdefaultfont, $pdfcorefont)) {
         $alternatepdffontfile = Yii::app()->getConfig('alternatepdffontfile');
         if (array_key_exists($sLanguageCode, $alternatepdffontfile)) {
             $pdfdefaultfont = $alternatepdffontfile[$sLanguageCode];
             // Actually use only core font
         }
     }
     if ($pdffontsize == 'auto') {
         $pdffontsize = PDF_FONT_SIZE_MAIN;
     }
     $this->pdf = new pdf();
     $this->pdf->SetFont($pdfdefaultfont, '', $pdffontsize);
     $this->pdf->AddPage();
     $this->pdf->intopdf("PDF export " . date("Y.m.d-H:i", time()));
     //Set some pdf metadata
     Yii::app()->loadHelper('surveytranslator');
     $lg = array();
     $lg['a_meta_charset'] = 'UTF-8';
     if (getLanguageRTL($sLanguageCode)) {
         $lg['a_meta_dir'] = 'rtl';
     } else {
         $lg['a_meta_dir'] = 'ltr';
     }
     $lg['a_meta_language'] = $sLanguageCode;
     $lg['w_page'] = $clang->gT("page");
     $this->pdf->setLanguageArray($lg);
     $this->separator = "\t";
     $this->rowCounter = 0;
     $this->surveyName = $survey->languageSettings[0]['surveyls_title'];
     $this->pdf->titleintopdf($this->surveyName, $survey->languageSettings[0]['surveyls_description']);
 }