コード例 #1
0
 function getTopicsEmails($topics_ids)
 {
     global $application;
     loadCoreFile('csv_parser.php');
     $temp_file = $application->getAppIni('PATH_CACHE_DIR') . '__emails_temp';
     $topics_emails = modApiFunc('Subscriptions', 'getTopicsEmailsByTopicsIds', $topics_ids);
     $topics_names = modApiFunc('Subscriptions', 'getTopicsNamesByIds', $topics_ids);
     $csv_worker = new CSV_Writer(session_id());
     $csv_worker->setOutFile($temp_file);
     $csv_worker->setLayout(array('Topic Name', 'E-mail'));
     $csv_worker->setDelimetr(';');
     $csv_worker->setNewLineType('win');
     $csv_worker->writeLayout();
     foreach (array_keys($topics_emails) as $i) {
         $csv_worker->writeArray(array('Topic Name' => $topics_names[$topics_emails[$i]['topic_id']], 'E-mail' => $topics_emails[$i]['email']));
     }
     #$this->_csv_worker->flush();
     $csv_worker->closeOutFile();
     header("Content-Length: " . @filesize($temp_file));
     @readfile($temp_file);
 }
コード例 #2
0
 function flush()
 {
     if ($this->__out_file_path == null) {
         return false;
     }
     $csv_writer = new CSV_Writer();
     $csv_writer->setOutFile($this->__out_file_path);
     $csv_writer->setLayout($this->__csv_headers);
     $csv_writer->setDelimetr($this->csv_delimetr);
     $csv_writer->writeLayout();
     for ($i = 1; $i <= $this->__counter; $i++) {
         if (null === ($data = $this->__cache->read('data_' . $i))) {
             continue;
         }
         $this->__fillMap($data);
         $csv_writer->writeData($data);
         $this->__cache->erase('data_' . $i);
     }
     $this->__cache->erase('headers');
     $this->__cache->erase('counter');
     $csv_writer->closeOutFile();
     return true;
 }