| 290 | | } else { |
|---|
| | 290 | } |
|---|
| | 291 | else if ($format == 'WIFI411_CSV') { |
|---|
| | 292 | /* Header("Cache-control: private, no-cache, must-revalidate"); |
|---|
| | 293 | Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
|---|
| | 294 | Header("Pragma: no-cache"); |
|---|
| | 295 | Header("Content-Type: text/xml; charset=UTF-8");*/ |
|---|
| | 296 | |
|---|
| | 297 | $xmldoc = new DOMDocument(); |
|---|
| | 298 | $xmldoc->formatOutput = true; |
|---|
| | 299 | //$xmldoc->encoding="iso-8859-15"; |
|---|
| | 300 | $rss = $xmldoc->createElement("rss"); |
|---|
| | 301 | $xmldoc->appendChild($rss); |
|---|
| | 302 | $rss->setAttribute('version', '2.0'); |
|---|
| | 303 | |
|---|
| | 304 | /* channel */ |
|---|
| | 305 | $channel = $xmldoc->createElement("channel"); |
|---|
| | 306 | $rss->appendChild($channel); |
|---|
| | 307 | |
|---|
| | 308 | /**************** Required channel elements ********************/ |
|---|
| | 309 | /* title */ |
|---|
| | 310 | $title = $xmldoc->createElement("title"); |
|---|
| | 311 | $title = $channel->appendChild($title); |
|---|
| | 312 | |
|---|
| | 313 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots"))); |
|---|
| | 314 | $title->appendChild($textnode); |
|---|
| | 315 | |
|---|
| | 316 | /* link */ |
|---|
| | 317 | $link = $xmldoc->createElement("link"); |
|---|
| | 318 | $channel->appendChild($link); |
|---|
| | 319 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
|---|
| | 320 | $link->appendChild($textnode); |
|---|
| | 321 | |
|---|
| | 322 | /* description */ |
|---|
| | 323 | $description = $xmldoc->createElement("description"); |
|---|
| | 324 | $channel->appendChild($description); |
|---|
| | 325 | $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME)); |
|---|
| | 326 | $description->appendChild($textnode); |
|---|
| | 327 | |
|---|
| | 328 | /****************** Optional channel elements *******************/ |
|---|
| | 329 | /* language */ |
|---|
| | 330 | /**@todo Make language selectable */ |
|---|
| | 331 | $language = $xmldoc->createElement("language"); |
|---|
| | 332 | $channel->appendChild($language); |
|---|
| | 333 | $textnode = $xmldoc->createTextNode("en-CA"); |
|---|
| | 334 | $language->appendChild($textnode); |
|---|
| | 335 | |
|---|
| | 336 | /* copyright */ |
|---|
| | 337 | $copyright = $xmldoc->createElement("copyright"); |
|---|
| | 338 | $channel->appendChild($copyright); |
|---|
| | 339 | $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").HOTSPOT_NETWORK_NAME)); |
|---|
| | 340 | $copyright->appendChild($textnode); |
|---|
| | 341 | |
|---|
| | 342 | /* managingEditor */ |
|---|
| | 343 | |
|---|
| | 344 | /* webMaster */ |
|---|
| | 345 | |
|---|
| | 346 | $webMaster = $xmldoc->createElement("webMaster"); |
|---|
| | 347 | $channel->appendChild($webMaster); |
|---|
| | 348 | $textnode = $xmldoc->createTextNode(utf8_encode(TECH_SUPPORT_EMAIL)); |
|---|
| | 349 | $webMaster->appendChild($textnode); |
|---|
| | 350 | |
|---|
| | 351 | /* pubDate */ |
|---|
| | 352 | $pubDate = $xmldoc->createElement("pubDate"); |
|---|
| | 353 | $channel->appendChild($pubDate); |
|---|
| | 354 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time()))); |
|---|
| | 355 | $pubDate->appendChild($textnode); |
|---|
| | 356 | |
|---|
| | 357 | /* lastBuildDate */ |
|---|
| | 358 | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
|---|
| | 359 | /* Make a request through the database for the latest modification date of an object. |
|---|
| | 360 | * Maybe it should be an object property? */ |
|---|
| | 361 | $db->ExecSqlUniqueRes("SELECT EXTRACT(epoch FROM MAX(creation_date)) as date_last_hotspot_opened FROM nodes WHERE node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE' ", $last_hotspot_row, false); |
|---|
| | 362 | |
|---|
| | 363 | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
|---|
| | 364 | $channel->appendChild($lastBuildDate); |
|---|
| | 365 | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
|---|
| | 366 | $lastBuildDate->appendChild($textnode); |
|---|
| | 367 | |
|---|
| | 368 | /* category */ |
|---|
| | 369 | /* Specify one or more categories that the channel belongs to. |
|---|
| | 370 | * Follows the same rules as the <item>-level category element.*/ |
|---|
| | 371 | |
|---|
| | 372 | /* generator */ |
|---|
| | 373 | $generator = $xmldoc->createElement("generator"); |
|---|
| | 374 | $channel->appendChild($generator); |
|---|
| | 375 | $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME . " " . WIFIDOG_VERSION)); |
|---|
| | 376 | $generator->appendChild($textnode); |
|---|
| | 377 | |
|---|
| | 378 | /* docs */ |
|---|
| | 379 | $docs = $xmldoc->createElement("docs"); |
|---|
| | 380 | $channel->appendChild($docs); |
|---|
| | 381 | $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss")); |
|---|
| | 382 | $docs->appendChild($textnode); |
|---|
| | 383 | |
|---|
| | 384 | /* cloud */ |
|---|
| | 385 | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
|---|
| | 386 | |
|---|
| | 387 | /* ttl */ |
|---|
| | 388 | /* ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source.*/ |
|---|
| | 389 | |
|---|
| | 390 | /* image */ |
|---|
| | 391 | $image = $xmldoc->createElement("image"); |
|---|
| | 392 | $channel->appendChild($image); |
|---|
| | 393 | |
|---|
| | 394 | /* title */ |
|---|
| | 395 | $title = $xmldoc->createElement("title"); |
|---|
| | 396 | $image->appendChild($title); |
|---|
| | 397 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME)); |
|---|
| | 398 | $title->appendChild($textnode); |
|---|
| | 399 | /* url */ |
|---|
| | 400 | $url = $xmldoc->createElement("url"); |
|---|
| | 401 | $image->appendChild($url); |
|---|
| | 402 | $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME)); |
|---|
| | 403 | $url->appendChild($textnode); |
|---|
| | 404 | /* link */ |
|---|
| | 405 | $link = $xmldoc->createElement("link"); |
|---|
| | 406 | $image->appendChild($link); |
|---|
| | 407 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
|---|
| | 408 | $link->appendChild($textnode); |
|---|
| | 409 | /* width */ |
|---|
| | 410 | /* |
|---|
| | 411 | $width = $xmldoc->createElement("width"); |
|---|
| | 412 | $image->appendChild($width); |
|---|
| | 413 | $textnode = $xmldoc->createTextNode('135'); |
|---|
| | 414 | $width->appendChild($textnode); |
|---|
| | 415 | */ |
|---|
| | 416 | /* height */ |
|---|
| | 417 | /* |
|---|
| | 418 | $height = $xmldoc->createElement("height"); |
|---|
| | 419 | $image->appendChild($height); |
|---|
| | 420 | $textnode = $xmldoc->createTextNode('109'); |
|---|
| | 421 | $height->appendChild($textnode); |
|---|
| | 422 | */ |
|---|
| | 423 | /* description */ |
|---|
| | 424 | /* |
|---|
| | 425 | $description = $xmldoc->createElement("description"); |
|---|
| | 426 | $image->appendChild($description); |
|---|
| | 427 | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
|---|
| | 428 | $description->appendChild($textnode); |
|---|
| | 429 | */ |
|---|
| | 430 | |
|---|
| | 431 | /* rating */ |
|---|
| | 432 | /* textInput */ |
|---|
| | 433 | /* skipHours */ |
|---|
| | 434 | /* skipDays */ |
|---|
| | 435 | |
|---|
| | 436 | $i=0; |
|---|
| | 437 | |
|---|
| | 438 | foreach($node_results as $node_row) { |
|---|
| | 439 | |
|---|
| | 440 | $item = $xmldoc->createElement("item"); |
|---|
| | 441 | $item = $channel->appendChild($item); |
|---|
| | 442 | |
|---|
| | 443 | /* title */ |
|---|
| | 444 | /* lom_1_2_title_langstrings_id */ |
|---|
| | 445 | $title = $xmldoc->createElement("title"); |
|---|
| | 446 | $item->appendChild($title); |
|---|
| | 447 | $title_str = $node_row['name']; |
|---|
| | 448 | $textnode = $xmldoc->createTextNode(utf8_encode($title_str)); |
|---|
| | 449 | $title->appendChild($textnode); |
|---|
| | 450 | |
|---|
| | 451 | /* link */ |
|---|
| | 452 | if(!empty($node_row['home_page_url'])) |
|---|
| | 453 | { |
|---|
| | 454 | $link = $xmldoc->createElement("link"); |
|---|
| | 455 | $item->appendChild($link); |
|---|
| | 456 | $textnode = $xmldoc->createTextNode(utf8_encode($node_row['home_page_url'])); |
|---|
| | 457 | $link->appendChild($textnode); |
|---|
| | 458 | } |
|---|
| | 459 | |
|---|
| | 460 | /* description */ |
|---|
| | 461 | $description = $xmldoc->createElement("description"); |
|---|
| | 462 | $item->appendChild($description); |
|---|
| | 463 | $description_text='<p>'; |
|---|
| | 464 | if($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
|---|
| | 465 | { |
|---|
| | 466 | if($node_row['is_up']=='t') |
|---|
| | 467 | { |
|---|
| | 468 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> "; |
|---|
| | 469 | } |
|---|
| | 470 | else |
|---|
| | 471 | { |
|---|
| | 472 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> "; |
|---|
| | 473 | } |
|---|
| | 474 | } |
|---|
| | 475 | |
|---|
| | 476 | if(!empty($node_row['description'])) |
|---|
| | 477 | { |
|---|
| | 478 | $description_text.= $node_row['description']; |
|---|
| | 479 | } |
|---|
| | 480 | $description_text.= "</p>\n"; |
|---|
| | 481 | $description_text.="<p>\n"; |
|---|
| | 482 | if(!empty($node_row['street_address'])) |
|---|
| | 483 | { |
|---|
| | 484 | $description_text.= ""._("Address:")." ".$node_row['street_address']." "; |
|---|
| | 485 | } |
|---|
| | 486 | if(!empty($node_row['map_url'])) |
|---|
| | 487 | { |
|---|
| | 488 | $description_text.=" <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; |
|---|
| | 489 | } |
|---|
| | 490 | $description_text.= "<br/>\n"; |
|---|
| | 491 | if(!empty($node_row['mass_transit_info'])) |
|---|
| | 492 | { |
|---|
| | 493 | $description_text.=""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; |
|---|
| | 494 | } |
|---|
| | 495 | $description_text.= "</p>\n"; |
|---|
| | 496 | if(!empty($node_row['public_email']) || !empty($node_row['public_phone_number'])) |
|---|
| | 497 | { |
|---|
| | 498 | $description_text.="<p>"._("Contact:"); |
|---|
| | 499 | |
|---|
| | 500 | if(!empty($node_row['public_phone_number'])) |
|---|
| | 501 | { |
|---|
| | 502 | $description_text.=" $node_row[public_phone_number] "; |
|---|
| | 503 | } |
|---|
| | 504 | if(!empty($node_row['public_email'])) |
|---|
| | 505 | { |
|---|
| | 506 | $description_text.=" <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; |
|---|
| | 507 | } |
|---|
| | 508 | $description_text.="</p>\n"; |
|---|
| | 509 | } |
|---|
| | 510 | $textnode = $xmldoc->createTextNode(utf8_encode($description_text)); |
|---|
| | 511 | $description->appendChild($textnode); |
|---|
| | 512 | |
|---|
| | 513 | /* author */ |
|---|
| | 514 | /* |
|---|
| | 515 | $author = $xmldoc->createElement("author"); |
|---|
| | 516 | $item->appendChild($author); |
|---|
| | 517 | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
|---|
| | 518 | $author->appendChild($textnode); |
|---|
| | 519 | */ |
|---|
| | 520 | /* category */ |
|---|
| | 521 | |
|---|
| | 522 | /* comments */ |
|---|
| | 523 | /** Link to page once page is available **/ |
|---|
| | 524 | /* enclosure */ |
|---|
| | 525 | /* guid */ |
|---|
| | 526 | |
|---|
| | 527 | $guid = $xmldoc->createElement("guid"); |
|---|
| | 528 | $guid->setAttribute('isPermaLink', 'false'); |
|---|
| | 529 | $item->appendChild($guid); |
|---|
| | 530 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL.$node_row['node_id'])); |
|---|
| | 531 | $guid->appendChild($textnode); |
|---|
| | 532 | |
|---|
| | 533 | /* pubDate */ |
|---|
| | 534 | $pubDate = $xmldoc->createElement("pubDate"); |
|---|
| | 535 | $item->appendChild($pubDate); |
|---|
| | 536 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch']))); |
|---|
| | 537 | $pubDate->appendChild($textnode); |
|---|
| | 538 | |
|---|
| | 539 | /* source */ |
|---|
| | 540 | } |
|---|
| | 541 | ob_clean(); |
|---|
| | 542 | echo $xmldoc->saveXML(); |
|---|
| | 543 | } |
|---|
| | 544 | else { |
|---|