Esempio n. 1
0
function download_consultation_times()
{
    global $config_url_consultation_times;
    $doc = new DomDocument('1.0');
    $root = $doc->createElement('mitglieder');
    $root->setAttribute("von", "Fachbereich 3");
    $doc->appendChild($root);
    @($dom = loadNprepare($config_url_consultation_times, 'UTF-8'));
    $dom->preserveWhiteSpace = false;
    $employee_table_wrapper = $dom->getElementById('c13016');
    $table_rows = $employee_table_wrapper->getElementsByTagName('tr');
    $table_rows->item(0);
    $current_person_function = "";
    foreach ($table_rows as $table_row) {
        $person_node = $doc->createElement('person');
        $headlines = $table_row->getElementsByTagName('h3');
        if ($headlines->length > 0) {
            $current_person_function = $headlines->item(0)->textContent;
            continue;
        }
        $current_entry = trim($table_row->getElementsByTagName('td')->item(0)->textContent);
        if (strpos($current_entry, "\n") > -1) {
            $text_parts_array = explode("\n", $current_entry);
            $person_node->appendChild($doc->createElement("titel", trim($text_parts_array[1])));
            $person_node->appendChild($doc->createElement("name", $text_parts_array[0]));
        } else {
            $person_node->appendChild($doc->createElement("name", $current_entry));
        }
        $person_node->appendChild($doc->createElement("funktion", $current_person_function));
        if ($table_row->getElementsByTagName('span')->length >= 1) {
            $person_node->appendChild($doc->createElement("sprechzeiten", $table_row->getElementsByTagName('span')->item(0)->textContent));
            if ($table_row->getElementsByTagName('span')->length == 2) {
                $person_node->appendChild($doc->createElement("raum", $table_row->getElementsByTagName('span')->item(1)->textContent));
            }
        }
        $root->appendChild($person_node);
    }
    $xml = combine_person_entries($doc);
    $xml = $doc->saveXML();
    $file_handle = fopen('data/sprechzeiten.xml', 'w');
    fwrite($file_handle, formatXmlString($xml));
    fclose($file_handle);
}
Esempio n. 2
0
function create_xml_for_room($room_url)
{
    $doc = lsf_xml_create();
    $root = $doc->documentElement;
    $root->setAttribute("datum", date("d.m.y"));
    $root->setAttribute("zeit", date("H:i"));
    $root->setAttribute("url", $room_url);
    @($dom = loadNprepare($room_url, "UTF-8"));
    $title_node = $dom->getElementsByTagName('h4')->item(0);
    $title = $title_node->getElementsByTagName('a')->item(0)->textContent;
    $title = strip_tags($title);
    $title = trim($title);
    $title = str_replace(chr(9), "", $title);
    $title = str_replace(chr(10), "", $title);
    $title = trim($title, chr(0xc2) . chr(0xa0));
    //$title = str_replace(chr(160), "", $title);
    $root->setAttribute("raum", $title);
    //echo trim(strip_tags(str_replace(" ", "", $title_node->textContent)));
    /*
    $dom->attributes;
    foreach ($all_links as $link) {
    	if($link->hasAttributes()) {
    		foreach ($link->attributes as $attr) {
    			if($attr->nodeName == "href") {
    				echo $attr->nodeValue . "\n";
    				if($attr->nodeValue == $room_url) {
    					echo "GOT YA'";						
    				}
    			}
    		}
    	}
    }
    */
    $table_links = lsf_get_timetable_node($dom)->getElementsByTagName('a');
    foreach ($table_links as $link) {
        $table_col = $link->parentNode->parentNode->parentNode->parentNode;
        $table_row = $link->parentNode->parentNode->parentNode->parentNode->parentNode;
        $event_name = $link->attributes->getNamedItem('title')->nodeValue;
        $time = correct_time(convert_row_siblings_to_time(count_previous_siblings($table_row)));
        $day = convert_col_siblings_to_day(count_previous_siblings($table_row), count_previous_siblings($table_col));
        $event_node = $doc->createElement("veranstaltung");
        $event_node->appendChild($doc->createElement("name", $event_name));
        $event_node->appendChild($doc->createElement("tag", $day));
        $event_node->appendChild($doc->createElement("zeit", $time));
        $root->appendChild($event_node);
    }
    lsf_xml_save($doc);
}