Ejemplo n.º 1
0
function xhtml_hcalendar_render($view)
{
    $xhtml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
    $xhtml .= '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"' . ">\r\n";
    $xhtml .= '<head>' . "\r\n";
    $xhtml .= '  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\r\n";
    $xhtml .= '  <meta name="KEYWORDS" content="hCalendars" />' . "\r\n";
    $xhtml .= '  <title>hCards</title>' . "\r\n";
    $xhtml .= '</head>' . "\r\n";
    $xhtml .= '<body>' . "\r\n";
    foreach ($view->result as $node) {
        $hcalendar = array();
        foreach ($node as $field_label => $field_value) {
            $label = views_rdf_strip_illegal_chars($field_label);
            $value = views_xml_strip_illegal_chars(views_xhtml_is_date($field_value));
            $label = str_replace('_value', '', str_replace("profile_values_profile_", '', $label));
            //strip out Profile: from profile fields
            if (is_null($value) || $value === '') {
                continue;
            }
            if (stripos($label, 'class') !== FALSE) {
                $hcalendar['class'] = $value;
            }
            if (stripos($label, 'category') !== FALSE) {
                $hcalendar['category'][] = $value;
            }
            if (stripos($label, 'description') !== FALSE) {
                $hcalendar['description'] = $value;
            }
            if (stripos($label, 'summary') !== FALSE) {
                $hcalendar['summary'] = $value;
            }
            if (stripos($label, 'dtstart') !== FALSE || stripos($label, 'event_start') !== FALSE || stripos($label, 'eventstarttime') !== FALSE) {
                if (preg_match('/\\d/', $value)) {
                    if (strtotime($value)) {
                        $value = date(EXHIBIT_DATE_FORMAT, strtotime($value));
                    }
                }
                $hcalendar['dtstart'] = $value;
            }
            if (stripos($label, 'dtend') !== FALSE || stripos($label, 'event_end') !== FALSE || stripos($label, 'eventendtime') !== FALSE) {
                if (preg_match('/\\d/', $value)) {
                    if (strtotime($value)) {
                        $value = date(EXHIBIT_DATE_FORMAT, strtotime($value));
                    }
                }
                $hcalendar['dtend'] = $value;
            }
            if (stripos($label, 'duration') !== FALSE) {
                $hcalendar['duration'] = $value;
            }
            if (stripos($label, 'geo_latitude') !== FALSE) {
                $hcalendar['geo']['latitude'] = $value;
            }
            if (stripos($label, 'geo_longitude') !== FALSE) {
                $hcalendar['geo']['longitude'] = $value;
            }
            if (stripos($label, 'location') !== FALSE) {
                $hcalendar['location'] = $value;
            }
            if (stripos($label, 'status') !== FALSE) {
                $hcalendar['status'] = $value;
            }
            if (stripos($label, 'uid') !== FALSE) {
                $hcalendar['uid'] = $value;
            }
            if (stripos($label, 'url') !== FALSE) {
                $hcalendar['url'] = $value;
            }
            if (stripos($label, 'last_modified') !== FALSE) {
                if (preg_match('/\\d/', $value)) {
                    if (strtotime($value)) {
                        $value = date(EXHIBIT_DATE_FORMAT, strtotime($value));
                    }
                }
                $hcalendar['last-modified'] = $value;
            }
            if (stripos($label, 'address_type') !== FALSE) {
                $hcalendar['adr']['type'] = $value;
            }
            if (stripos($label, 'post_office_box') !== FALSE) {
                $hcalendar['adr']['post-office-box'] = $value;
            }
            if (stripos($label, 'street_address') !== FALSE) {
                $hcalendar['adr']['street-address'][] = $value;
            }
            if (stripos($label, 'extended_address') !== FALSE) {
                $hcalendar['adr']['extended-address'] = $value;
            }
            if (stripos($label, 'region') !== FALSE) {
                $hcalendar['adr']['region'] = $value;
            }
            if (stripos($label, 'locality') !== FALSE) {
                $hcalendar['adr']['locality'] = $value;
            }
            if (stripos($label, 'postal_code') !== FALSE) {
                $hcalendar['adr']['postal-code'] = $value;
            }
            if (stripos($label, 'country_name') !== FALSE) {
                $hcalendar['adr']['country-name'] = $value;
            }
        }
        $xhtml .= '<div class = "vevent">' . "\r\n";
        $class = $hcalendar['class'];
        if ($class) {
            $xhtml .= '  <span class="class">' . $class . '</span>' . "<br/>\r\n";
        }
        $categories = $hcalendar['category'];
        if ($categories) {
            foreach ($categories as $category) {
                $xhtml .= '  <span class="category">' . $category . '</span>' . "<br/>\r\n";
            }
        }
        $dtstart = $hcalendar['dtstart'];
        if ($dtstart) {
            $xhtml .= '  <span class="dtstart">' . $dtstart . '</span>' . "<br/>\r\n";
        }
        $summary = $hcalendar['summary'];
        if ($summary) {
            $xhtml .= '  <span class="summary">' . $summary . '</span>' . "<br/>\r\n";
        }
        $dtend = $hcalendar['dtend'];
        if ($dtend) {
            $xhtml .= '  <span class="dtend">' . $dtend . '</span>' . "<br/>\r\n";
        }
        $location = $hcalendar['location'];
        if ($location) {
            $xhtml .= '  <span class="location">' . $location . '</span>' . "<br/>\r\n";
        }
        $geo_latitude = $hcalendar['geo-latitude'];
        $geo_longitude = $hcalendar['geo-longitude'];
        if ($geo_latitude || $geo_longitude) {
            $xhtml .= "  <div class=\"geo\">\n";
            if ($location) {
                $xhtml .= "    {$location}: ";
            }
            if ($geo_latitude) {
                $xhtml .= "    <span class=\"latitude\">{$geo_latitude}</span>; ";
            }
            if ($geo_longitude) {
                $xhtml .= "    <span class=\"longitude\">{$geo_longitude}</span>";
            }
            $xhtml .= "  </div>\n";
        }
        $status = $hcalendar['status'];
        if ($status) {
            $xhtml .= '  <span class="status">' . $status . '</span>' . "<br/>\r\n";
        }
        $duration = $hcalendar['duration'];
        if ($duration) {
            $xhtml .= '  <span class="duration">' . $duration . '</span>' . "<br/>\r\n";
        }
        $uid = $hcalendar['uid'];
        if ($uid) {
            $xhtml .= '  <span class="uid">' . $uid . '</span>' . "<br/>\r\n";
        }
        $url = $hcalendar['url'];
        if ($url) {
            $xhtml .= '  <span class="url">' . $url . '</span>' . "<br/>\r\n";
        }
        $last_modified = $hcalendar['last-modified'];
        if ($last_modified) {
            $xhtml .= '  <span class="last-modified">' . $last_modified . '</span>' . "<br/>\r\n";
        }
        $description = $hcalendar['description'];
        if ($description) {
            $xhtml .= '  <span class="description">' . $description . '</span>' . "<br/>\r\n";
        }
        $adr = $hcalendar['adr'];
        if ($adr) {
            $xhtml .= "  <div class=\"adr\">\n";
            $adr_type = $adr['address-type'];
            if ($adr_type) {
                $xhtml .= '    <span class="address-type">' . $adr_type . '</span>' . "<br/>\r\n";
            }
            $xhtml .= "  </div>";
        }
        $xhtml .= '</div>' . "\r\n";
    }
    $xhtml .= '</body>' . "\r\n";
    $xhtml .= '</html>' . "\r\n";
    drupal_set_header('Content-Type: text/html');
    //var_dump($view);
    print $xhtml;
    module_invoke_all('exit');
    exit;
}
Ejemplo n.º 2
0
function rdf_sioc_xml_node_render($node, &$users = null, &$nodes = null)
{
    global $base_url;
    //i
    foreach ($node as $field_label => $field_value) {
        $label = views_rdf_strip_illegal_chars($field_label);
        $value = views_rdf_strip_illegal_chars(views_rdf_is_date($field_value));
        if (is_null($value) || $value === '') {
            continue;
        }
        //    if (strtotime($value))
        //      $value = date(DATE_ISO8601, strtotime($value));
        if (strtolower($label) == 'id' || strtolower($label) == 'nid') {
            $nid = $value;
        }
        if (strtolower($label) == 'title' || strtolower($label) == 'node_title') {
            $title = $value;
        }
        if (strtolower($label) == 'body' || strtolower($label) == 'node_revisions_body') {
            $body = $value;
        }
        if (strtolower($label) == 'type' || strtolower($label) == 'node_type') {
            $type = $value;
        }
        if (strtolower($label) == 'created' || strtolower($label) == 'node_created') {
            $created = $value;
        }
        if (strtolower($label) == 'changed' || strtolower($label) == 'node_changed') {
            $changed = $value;
        }
        if (strtolower($label) == 'last_updated' || strtolower($label) == 'node_comment_statistics_last_updated') {
            $last_updated = $value;
        }
        if (strtolower($label) == 'uid' || strtolower($label) == 'users_uid') {
            $uid = $value;
        }
    }
    $user = user_load($uid);
    if (!array_key_exists($uid, $users)) {
        $users[$uid] = rdf_sioc_xml_user_render(null, $uid, $user->name, $user->mail);
    }
    if (!array_key_exists($nid, $nodes)) {
        if ($type == 'page' || $type == 'story' || $type == 'forum' || $type == 'blog') {
            $nodes[$nid] = rdf_sioc_xml_story_render($xml, $nid, $title, $type, $created, $changed, $last_updated, $uid, $body);
        }
    }
    //$xml = '';
    //var_dump($nodes);
    //var_dump($users);
    //module_invoke_all('exit');
    return;
}