# Id$
#
include "include/init.php";
$sheet_url = "";
# if incoming owner id & sheet id
if ($_GET['oid'] && $_GET['sid']) {
    $sheet = array('user_id' => (int) $_GET['oid'], 'id' => (int) $_GET['sid']);
    $sheet_url = urls_url_for_sheet($sheet);
} else {
    # pass random URL to seed example
    $recent_sheets = sheets_recently_created($GLOBALS['cfg']['user_id']);
    if ($recent_sheets) {
        $len = count($recent_sheets) - 1;
        if ($len > 0) {
            $rdm = rand(0, $len);
            $sheet_url = urls_url_for_sheet($recent_sheets['sheets'][$rdm]);
        }
    }
}
$chosen_theme = "default";
if ($_GET['type'] == "crime") {
    $chosen_theme = "crime";
} else {
    if ($_GET['type'] == "photo") {
        $chosen_theme = "photo";
    } else {
        if ($_GET['type'] == "bucket") {
            $chosen_theme = "bucket";
        } else {
            if ($_GET['type'] == "bubbles") {
                $chosen_theme = "bubbles";
Example #2
0
function rss_export_dots(&$dots, &$more)
{
    $_dot = dots_get_dot($dots[0]['id']);
    $channel_data = array('title' => "Dots from sheet ID {$_dot['sheet']['id']}", 'link' => urls_url_for_sheet($_dot['sheet']), 'description' => "Dots from sheet ID {$_dot['sheet']['id']}", 'pubDate' => gmdate("c", time()), 'lastBuildDate' => gmdate("c", time()), 'generator' => 'Dotspotting');
    $ns_map = array('geo' => 'http://www.georss.org/georss', 'dotspotting' => 'x-urn:dotspotting#internal', 'sheet' => 'x-urn:dotspotting#sheet');
    $skip = array('latitude', 'longitude', 'altitude', 'title', 'description');
    $doc = new DomDocument('1.0', 'UTF-8');
    $rss = $doc->createElement('rss');
    $rss = $doc->appendChild($rss);
    foreach ($ns_map as $prefix => $uri) {
        $xmlns = $prefix ? "xmlns:{$prefix}" : "xmlns";
        $attr = $doc->createAttribute($xmlns);
        $uri = $doc->createTextNode($uri);
        $attr->appendChild($uri);
        $rss->appendChild($attr);
    }
    $channel = $doc->createElement('channel');
    $channel = $rss->appendChild($channel);
    foreach ($channel_data as $key => $value) {
        $text = $doc->createTextNode($value);
        $el = $doc->createElement($key);
        $el->appendChild($text);
        $channel->appendChild($el);
    }
    foreach ($dots as $dot) {
        $properties = array();
        $item = $doc->createElement('item');
        foreach ($dot as $key => $value) {
            if (in_array($key, $skip)) {
                continue;
            }
            $properties[] = implode("\t", array(htmlspecialchars($key), htmlspecialchars($value)));
            # maybe do OSM-style k= v= pairs? (20110114/straup)
            if (0) {
                if (!preg_match("/^dotspotting:/", $key)) {
                    $key = "sheet:{$key}";
                }
                $el = $doc->createElement($key);
                $text = $doc->createTextNode($value);
                $el->appendChild($text);
                $item->appendChild($el);
            }
        }
        $coords = array($dot['latitude'], $dot['longitude']);
        $_geo = $doc->createTextNode(implode(",", $coords));
        $geo = $doc->createElement('geo:point');
        $geo->appendChild($_geo);
        $_title = $doc->createTextNode("Dot #{$dot['id']}");
        if (isset($dot['title'])) {
            $_title = $doc->createTextNode($dot['title']);
        }
        $title = $doc->createElement('title');
        $title->appendChild($_title);
        $_dot = dots_get_dot($dot['id']);
        $_link = $doc->createTextNode(urls_url_for_dot($_dot));
        $link = $doc->createElement('link');
        $link->appendChild($_link);
        # see above inre: osm style tags
        $_description = $doc->createTextNode(implode("<br />", $properties));
        $description = $doc->createElement('description');
        $description->appendChild($_description);
        $item->appendChild($title);
        $item->appendChild($link);
        $item->appendChild($description);
        $item->appendChild($geo);
        $channel->appendChild($item);
    }
    $doc->save($more['path']);
    return $more['path'];
}