예제 #1
0
파일: dates.php 프로젝트: ratbird/hope
 public function export_action()
 {
     $course = new Course($_SESSION['SessionSeminar']);
     $sem = new Seminar($_SESSION['SessionSeminar']);
     $themen =& $sem->getIssues();
     $termine = getAllSortedSingleDates($sem);
     $dates = array();
     if (is_array($termine) && sizeof($termine) > 0) {
         foreach ($termine as $singledate_id => $singledate) {
             if (!$singledate->isExTermin()) {
                 $tmp_ids = $singledate->getIssueIDs();
                 $title = $description = '';
                 if (is_array($tmp_ids)) {
                     $title = trim(join("\n", array_map(function ($tid) use($themen) {
                         return $themen[$tid]->getTitle();
                     }, $tmp_ids)));
                     $description = trim(join("\n\n", array_map(function ($tid) use($themen) {
                         return $themen[$tid]->getDescription();
                     }, $tmp_ids)));
                 }
                 $dates[] = array('date' => $singledate->toString(), 'title' => $title, 'description' => $description, 'start' => $singledate->getStartTime(), 'related_persons' => $singledate->getRelatedPersons());
             } elseif ($singledate->getComment()) {
                 $dates[] = array('date' => $singledate->toString(), 'title' => _('fällt aus') . ' (' . _('Kommentar:') . ' ' . $singledate->getComment() . ')', 'description' => '', 'start' => $singledate->getStartTime(), 'related_persons' => array());
             }
         }
     }
     $factory = $this->get_template_factory();
     $template = $factory->open($this->get_default_template("export"));
     $template->set_attribute('dates', $dates);
     $content = $template->render();
     $content = mb_encode_numericentity($content, array(0x80, 0xffff, 0, 0xffff), 'cp1252');
     $filename = prepareFilename($course['name'] . '-' . _("Ablaufplan")) . '.doc';
     $this->set_content_type(get_mime_type($filename));
     $this->response->add_header('Content-Disposition', 'attachment;filename="' . $filename . '"');
     $this->response->add_header('Expires', 0);
     $this->response->add_header('Cache-Control', 'private');
     $this->response->add_header('Pragma', 'cache');
     $this->render_text($content);
 }