Exemplo n.º 1
0
 public function build(array $items)
 {
     $feed = $this->document->createElement("feed");
     $feed->at("xmlns", "http://www.w3.org/2005/Atom");
     $feed->at("xml:lang", $this->info["language"]);
     $this->document->setDocumentElement($feed);
     $info = $this->info;
     if (array_isset("title", $info)) {
         $feed->addChild("title")->setNodeValue(xmlescape($info["title"]));
     }
     if (array_isset("image[src]", $info)) {
         $feed->addChild("logo")->setNodeValue($info["image"]["src"]);
     }
     $link = $feed->addChild("link");
     $link->at("rel", "alternate")->at("type", "text/html")->at("href", $info["home"]);
     if (array_isset("rss", $info)) {
         $link = $dom->createElement("link");
         $link->at("rel", "self")->at("type", "application/atom-xml")->at("href", $info["rss"]);
     }
     if (array_isset("description", $info)) {
         $feed->addChild("subtitle")->setNodeValue(xmlescape($info["description"]));
     }
     if (array_isset("updated", $info)) {
         $feed->addChild("updated")->setNodeValue(date("c", strtotime($info["updated"])));
     }
     $this->createItems($feed, $items);
     return $this->document->toXML();
 }
Exemplo n.º 2
0
 protected function createItems($rss, $items)
 {
     foreach ($items as $item) {
         $itemElem = $rss->addChild("item");
         if (array_isset("title", $item)) {
             $itemElem->addChild("title")->setNodeValue(xmlescape($item["title"]));
         }
         $itemElem->addChild("link")->setNodeValue(xmlescape($item["link"]));
         $content = "";
         if (array_isset("content", $item)) {
             $content = $item["content"];
         } elseif (array_isset("description", $item)) {
             $content = $item["description"];
         }
         $itemElem->addChild("description")->setNodeValue($content, true);
         if (array_isset("date", $item)) {
             $itemElem->addChild("pubDate")->setNodeValue(date("r", strtotime($item["date"])));
         }
     }
 }
Exemplo n.º 3
0
 protected function createItems($feed, $items)
 {
     foreach ($items as $item) {
         $itemElem = $feed->addChild("entry");
         if (array_isset("title", $item)) {
             $itemElem->addChild("title")->setNodeValue(xmlescape($item["title"]));
         }
         $link = $itemElem->addChild("link");
         $link->at("rel", "alternate")->at("type", "text/html")->at("href", $item["link"]);
         if (array_isset("description", $item)) {
             $summary = $itemElem->addChild("summary");
             $summary->at("type", "text/plain");
             $summary->setNodeValue(xmlescape($item["description"]));
         }
         if (array_isset("content", $item)) {
             $content = $itemElem->addChild("content");
             $content->at("type", "text")->at("mode", "escaped");
             $content->setNodeValue($item["content"], true);
         }
         if (array_isset("date", $item)) {
             $itemElem->addChild("modified")->setNodeValue(date("c", strtotime($item["date"])));
         }
     }
 }
Exemplo n.º 4
0
function xh($string, $charset = APP_ENCODING)
{
    return xmlescape($string, $charset);
}
Exemplo n.º 5
0
/**
 * Display an XML error.
 */
function display_xml_error($e)
{
    xml_header();
    ?>
<error time="<?php 
    echo iso_date();
    ?>
">
<?php 
    echo xmlescape($e->getMessage());
    ?>
</error>
  <?php 
    die;
}
Exemplo n.º 6
0
    include_once "formattext.php";
    $rss->title = 'FOSS Factory projects';
    $rss->description = 'List of newest projects on FOSS Factory.';
    $rss->link = $GLOBALS['SITE_URL'] . 'browse.php';
    list($rc, $projects) = ff_getnewprojects(30);
    if ($rc == 0) {
        foreach ($projects as $p) {
            $item = new FeedItem();
            $item->title = $p['name'];
            $item->link = $GLOBALS['SITE_URL'] . projurl($p['id']);
            $item->guid = $item->link;
            $item->date = (int) $p['created'];
            $item->author = $p['creator'];
            $item->description = '
                <p>
                Creator: ' . xmlescape($p['creator']) . '<br>
                Requirements:<br><br>
                    ' . formattext($p['reqmts']) . '
                </p>
                ';
            $rss->addItem($item);
        }
    }
} else {
    if ($_GET['src'] == 'duties') {
        include_once "getduties.php";
        include_once "formattext.php";
        $user = scrub($_GET['u']);
        $rss->title = '[FF] ' . $user . '\'s duties';
        $rss->description = $user . '\' duties on FOSS Factory.';
        $rss->link = $GLOBALS['SITE_URL'] . 'account.php#tabs';
Exemplo n.º 7
0
 protected function createImage($rdf)
 {
     $info = $this->info;
     if (array_isset("image", $info)) {
         $imgInfo = $info["image"];
         $image = $rdf->addChild("image");
         if (array_isset("title", $imgInfo)) {
             $image->addChild("title")->setNodeValue(xmlescape($imgInfo["title"]));
         } elseif (array_isset("title", $info)) {
             $image->addChild("title")->setNodeValue(xmlescape($info["title"]));
         }
         if (array_isset("src", $imgInfo)) {
             $image->at("rdf:about", xmlescape($imgInfo["src"]));
             $image->addChild("url")->setNodeValue(xmlescape($imgInfo["src"]));
         }
         if (array_isset("link", $imgInfo)) {
             $image->addChild("link")->setNodeValue(xmlescape($imgInfo["link"]));
         } elseif (array_isset("home", $info)) {
             $image->addChild("link")->setNodeValue(xmlescape($info["home"]));
         }
     }
 }