function output_list($type, $list, $fields, $idstr) { switch ($type) { case 'xml': xml_header($fields); xml_data($list, $fields); xml_footer(); break; case 'dom': dom_header($fields); dom_data($list, $fields); dom_footer(); break; case 'img': img_header($fields); img_data($list, $fields, $idstr); img_footer(); break; case 'csv': default: csv_header($fields); csv_data($list, $fields); csv_footer(); break; } }
function write_major_file($code, $data, $type) { $pointer = new XMLWriter(); $time = strftime("%Y-%m-%d %H:%m:%S"); foreach (array_keys($data) as $group) { echo "writing major xml files for: {$group}\n"; $dir = realpath(dirname(dirname(__FILE__)) . "/modules") . "/isco_{$code}/modules/" . "isco_{$code}_major_{$group}"; if (!is_dir($dir)) { if (!mkdir($dir, 0777, TRUE)) { echo "Couldn't make {$dir}!"; exit(1); } } $pointer->openURI("file://{$dir}/majorgroup" . $group . ".xml"); xml_header($pointer, $code, $group); foreach ($type as $i => $level) { write_group($pointer, $i, $level, $code, $group, $data[$group], $time, $type); } xml_footer($pointer); $pointer->flush(); } }
/** * Exports data of the given range. * * This function calls the functions that export the data sepcified by the given $export_range. * It calls the function output_data afterwards. * * @access public * @param string $range_id Stud.IP-range_id for export */ function export_range($range_id) { global $o_mode, $range_name, $ex_person_details, $persons, $ex_sem; // Ist die Range-ID eine Einrichtungs-ID? $query = "SELECT Name FROM Institute WHERE Institut_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($range_id)); $name = $statement->fetchColumn(); if ($name) { $range_name = $name; output_data(xml_header(), $o_mode); $output_startet = true; export_inst($range_id); } // Ist die Range-ID eine Fakultaets-ID? Dann auch untergeordnete Institute exportieren! $query = "SELECT Name, Institut_id\n FROM Institute\n WHERE fakultaets_id = ? AND Institut_id != fakultaets_id"; $statement = DBManager::get()->prepare($query); $statement->execute(array($range_id)); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { if ($row['Name'] != '') { // output_data ( xml_header(), $o_mode); export_inst($row['Institut_id']); } } // Ist die Range-ID eine Seminar-ID? $query = "SELECT Name, Seminar_id, Institut_id\n FROM seminare\n WHERE Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($range_id)); $row = $statement->fetch(PDO::FETCH_ASSOC); if ($row && $row['Name'] != '') { $range_name = $row['Name']; if (!$output_startet) { output_data(xml_header(), $o_mode); $output_startet = true; } export_inst($row['Institut_id'], $row['Seminar_id']); } // Ist die Range-ID ein Range-Tree-Item? if ($range_id != 'root') { $tree_object = new RangeTreeObject($range_id); $range_name = $tree_object->item_data["name"]; // Tree-Item ist ein Institut: if ($tree_object->item_data['studip_object'] == 'inst') { if (!$output_startet) { output_data(xml_header(), $o_mode); $output_startet = true; } export_inst($tree_object->item_data['studip_object_id']); } // Tree-Item hat Institute als Kinder: $inst_array = $tree_object->GetInstKids(); if (count($inst_array) > 0) { if (!$output_startet) { output_data(xml_header(), $o_mode); $output_startet = true; } while (list($key, $inst_ids) = each($inst_array)) { export_inst($inst_ids); } } } $query = "SELECT 1 FROM sem_tree WHERE sem_tree_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($range_id)); if ($statement->fetchColumn() || $range_id == 'root') { if (!$output_startet) { output_data(xml_header(), $o_mode); $output_startet = true; } if (isset($ex_sem) && ($semester = Semester::find($ex_sem))) { $args = array('sem_number' => array(SemesterData::GetSemesterIndexById($ex_sem))); } else { $args = array(); } if ($range_id != 'root') { $the_tree = TreeAbstract::GetInstance('StudipSemTree', $args); $sem_ids = array_unique($the_tree->getSemIds($range_id, true)); } if (is_array($sem_ids) || $range_id == 'root') { if (is_array($sem_ids)) { $query = "SELECT DISTINCT Institut_id\n FROM seminare\n WHERE Seminar_id IN (?)"; $statement = DBManager::get()->prepare($query); $statement->execute(array($sem_ids)); $to_export = $statement->fetchAll(PDO::FETCH_COLUMN); } else { $sem_ids = 'root'; $query = "SELECT DISTINCT Institut_id\n FROM seminare\n INNER JOIN seminar_sem_tree USING (seminar_id)"; if ($semester) { $query .= " WHERE seminare.start_time <= :begin\n AND (:begin <= (seminare.start_time + seminare.duration_time) OR\n seminare.duration_time = -1)"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':begin', $semester->beginn); $statement->execute(); } else { $statement = DBManager::get()->query($query); } $to_export = $statement->fetchAll(PDO::FETCH_COLUMN); } foreach ($to_export as $inst) { export_inst($inst, $sem_ids); } } } if ($ex_person_details && is_array($persons)) { export_persons(array_keys($persons)); } output_data(xml_footer(), $o_mode, $flush = true); }