public function rssObservations() { global $objObservation, $objInstrument, $objLocation, $objPresentations, $objObserver, $baseURL, $objUtil; $dom = new DomDocument('1.0', 'US-ASCII'); // add root fcga -> The header $rssInfo = $dom->createElement('rss'); $rssDom = $dom->appendChild($rssInfo); $attr = $dom->createAttribute("version"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("2.0"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:content"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://purl.org/rss/1.0/modules/content/"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:dc"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://purl.org/dc/elements/1.1/"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:atom"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://www.w3.org/2005/Atom"); $attr->appendChild($attrText); // add root - <channel> $channelDom = $rssDom->appendChild($dom->createElement('channel')); // add root - <channel> - <title> $titleDom = $channelDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode("DeepskyLog")); // add root - <channel> - <description> $descDom = $channelDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createTextNode("DeepskyLog - visual deepsky and comets observations")); // add root - <channel> - <atom> $atomDom = $channelDom->appendChild($dom->createElement('atom:link')); $attr = $dom->createAttribute("href"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode($baseURL . "observations.rss"); $attr->appendChild($attrText); $attr = $dom->createAttribute("rel"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode("self"); $attr->appendChild($attrText); $attr = $dom->createAttribute("type"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode("application/rss+xml"); $attr->appendChild($attrText); // add root - <channel> - <link> $linkDom = $channelDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createTextNode("http://www.deepskylog.org/")); $theDate = date('r'); // add root - <channel> - <link> $lbdDom = $channelDom->appendChild($dom->createElement('lastBuildDate')); $lbdDom->appendChild($dom->createTextNode($theDate)); // Get the new deepsky observations of the last month $theDate = date('Ymd', strtotime('-1 month')); $_GET['minyear'] = substr($theDate, 0, 4); $_GET['minmonth'] = substr($theDate, 4, 2); $_GET['minday'] = substr($theDate, 6, 2); $query = array("catalog" => '%', "mindate" => $objUtil->checkGetDate('minyear', 'minmonth', 'minday')); $result = $objObservation->getObservationFromQuery($query, 'A'); while (list($key, $value) = each($result)) { // add root - <channel> - <item> $itemDom = $channelDom->appendChild($dom->createElement('item')); $titleDom = $itemDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode($value['observername'] . " : " . $value['objectname'] . " with " . htmlspecialchars_decode($objInstrument->getInstrumentPropertyFromId($value['instrumentid'], 'name')) . " from " . $objLocation->getLocationPropertyFromId($objObservation->getDsObservationProperty($value['observationid'], 'locationid'), 'name'))); $linkDom = $itemDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createCDATASection($baseURL . "index.php?indexAction=detail_observation&observation=" . $value['observationid'] . "&QobsKey=0&dalm=D")); $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection($objPresentations->br2nl(utf8_encode($value['observationdescription'])))); $authorDom = $itemDom->appendChild($dom->createElement('dc:creator')); $authorDom->appendChild($dom->createCDATASection($value['observername'])); $guidDom = $itemDom->appendChild($dom->createElement('guid')); $guidDom->appendChild($dom->createTextNode("deepsky" . $value['observationid'])); $attr = $dom->createAttribute("isPermaLink"); $guidDom->appendChild($attr); $attrText = $dom->createTextNode("false"); $attr->appendChild($attrText); $pubDateDom = $itemDom->appendChild($dom->createElement('pubDate')); date_default_timezone_set('UTC'); $time = -999; $obs = $objObservation->getAllInfoDsObservation($value['observationid']); $time = $obs['time']; if ($time >= "0") { $hour = (int) ($time / 100); $minute = $time - 100 * $hour; } else { $hour = 0; $minute = 0; } $date = $value['observationdate']; $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $pubDateDom->appendChild($dom->createTextNode(date("r", mktime($hour, $minute, 0, $month, $day, $year)))); } include_once "cometobjects.php"; include_once "observers.php"; include_once "instruments.php"; include_once "locations.php"; include_once "cometobservations.php"; include_once "icqmethod.php"; include_once "icqreferencekey.php"; global $instDir, $objCometObject; $objects = new CometObjects(); $observer = new Observers(); $instrument = new Instruments(); $observation = new CometObservations(); $location = new Locations(); $util = $this; $ICQMETHODS = new ICQMETHOD(); $ICQREFERENCEKEYS = new ICQREFERENCEKEY(); $cometsResult = $observation->getObservationFromQuery($query); while (list($key, $value) = each($cometsResult)) { $objectname = $objCometObject->getName($observation->getObjectId($value)); // add root - <channel> - <item> $itemDom = $channelDom->appendChild($dom->createElement('item')); $title = htmlspecialchars_decode($objectname); // Location and instrument if ($observation->getLocationId($value) != 0 && $observation->getLocationId($value) != 1) { $title = $title . " from " . htmlspecialchars_decode($location->getLocationPropertyFromId($observation->getLocationId($value), 'name')); } if ($observation->getInstrumentId($value) != 0) { $title = $title . " with " . htmlspecialchars_decode($instrument->getInstrumentPropertyFromId($observation->getInstrumentId($value), 'name')); } $titleDom = $itemDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode($title)); $linkDom = $itemDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createCDATASection($baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $value)); // Description $description = $observation->getDescription($value); if (strcmp($description, "") != 0) { $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection($objPresentations->br2nl(utf8_encode($description)))); } else { $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection("")); } $observerid = $observation->getObserverId($value); $observername = $observer->getObserverProperty($observerid, 'firstname') . " " . $observer->getObserverProperty($observerid, 'name'); $authorDom = $itemDom->appendChild($dom->createElement('dc:creator')); $authorDom->appendChild($dom->createCDATASection($observername)); $guidDom = $itemDom->appendChild($dom->createElement('guid')); $guidDom->appendChild($dom->createTextNode("comet" . $value)); $attr = $dom->createAttribute("isPermaLink"); $guidDom->appendChild($attr); $attrText = $dom->createTextNode("false"); $attr->appendChild($attrText); $pubDateDom = $itemDom->appendChild($dom->createElement('pubDate')); date_default_timezone_set('UTC'); $date = sscanf($observation->getLocalDate($value), "%4d%2d%2d"); $time = $observation->getLocalTime($value); $hour = (int) ($time / 100); $minute = $time - $hour * 100; $pubDateDom->appendChild($dom->createTextNode(date("r", mktime($hour, $minute, 0, $date[1], $date[2], $date[0])))); } // generate xml $dom->formatOutput = true; // set the formatOutput attribute of // domDocument to true // save XML as string or file $test1 = $dom->saveXML(); // put string in test1 print $test1; }