Пример #1
0
 function createFeed()
 {
     $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
     $feed .= $this->_createStylesheetReferences();
     $feed .= "<feed version=\"0.1\" xmlns=\"http://www.tbray.org/ongoing/pie/0.1/pie.rnc\">\n";
     $feed .= "    <title>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars($this->title), 100) . "</title>\n";
     $this->truncSize = 500;
     $feed .= "    <subtitle>" . $this->getDescription() . "</subtitle>\n";
     $feed .= "    <link>" . $this->link . "</link>\n";
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= "    <entry>\n";
         $feed .= "        <title>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n";
         $feed .= "        <link>" . FeedCreator::htmlspecialchars($this->items[$i]->link) . "</link>\n";
         $itemDate = new FeedDate($this->items[$i]->date);
         $feed .= "        <created>" . FeedCreator::htmlspecialchars($itemDate->iso8601()) . "</created>\n";
         $feed .= "        <issued>" . FeedCreator::htmlspecialchars($itemDate->iso8601()) . "</issued>\n";
         $feed .= "        <modified>" . FeedCreator::htmlspecialchars($itemDate->iso8601()) . "</modified>\n";
         $feed .= "        <id>" . FeedCreator::htmlspecialchars($this->items[$i]->guid) . "</id>\n";
         if ($this->items[$i]->author != "") {
             $feed .= "        <author>\n";
             $feed .= "            <name>" . FeedCreator::htmlspecialchars($this->items[$i]->author) . "</name>\n";
             if ($this->items[$i]->authorEmail != "") {
                 $feed .= "            <email>" . $this->items[$i]->authorEmail . "</email>\n";
             }
             $feed .= "        </author>\n";
         }
         $feed .= "        <content type=\"text/html\" xml:lang=\"en-us\">\n";
         $feed .= "            <div xmlns=\"http://www.w3.org/1999/xhtml\">" . $this->items[$i]->getDescription() . "</div>\n";
         $feed .= "        </content>\n";
         $feed .= "    </entry>\n";
     }
     $feed .= "</feed>\n";
     return $feed;
 }
Пример #2
0
 /**
  * Builds the MBOX contents.
  * @return    string    the feed's complete text 
  */
 function createFeed()
 {
     $feed = '';
     for ($i = 0; $i < count($this->items); $i++) {
         if ($this->items[$i]->author != "") {
             $from = $this->items[$i]->author;
         } else {
             $from = $this->title;
         }
         $itemDate = new FeedDate($this->items[$i]->date);
         $feed .= "From " . strtr(MBOX::qp_enc($from), " ", "_") . " " . $itemDate->v0002() . "\n";
         $feed .= "Content-Type: text/plain;\n";
         $feed .= "\tcharset=\"" . $this->encoding . "\"\n";
         $feed .= "Content-Transfer-Encoding: quoted-printable\n";
         $feed .= "Content-Type: text/plain\n";
         $feed .= "From: \"" . MBOX::qp_enc($from) . "\"\n";
         $feed .= "Date: " . $itemDate->rfc822() . "\n";
         $feed .= "Subject: " . MBOX::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "\n";
         $feed .= "\n";
         $body = chunk_split(MBOX::qp_enc($this->items[$i]->description));
         $feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From \$1\$2\n", $body);
         $feed .= "\n";
         $feed .= "\n";
     }
     return $feed;
 }
Пример #3
0
function getRss2String($content, $pattern)
{
    $Feed = new FeedCreator();
    $Feed->setBase($pattern->baseurl, $pattern->feed_title, $pattern->baseurl);
    $matchies = getMatchies($pattern->pattern, $content);
    foreach ($matchies as $m) {
        $id = $pattern->baseurl . time();
        $title = itemReplace($pattern->item_title, $m);
        $link = itemReplace($pattern->item_link, $m);
        $summary = itemReplace($pattern->item_content, $m);
        $Feed->addEntry($id, $title, $link, $summary);
    }
    $rss2 = $Feed->getRss2String();
    unset($Feed);
    return $rss2;
}
Пример #4
0
 function createFeed()
 {
     $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
     $feed .= $this->_createGeneratorComment();
     $feed .= $this->_createStylesheetReferences();
     $feed .= "<feed xmlns=\"http://www.w3.org/2005/Atom\"";
     if (!empty($this->language)) {
         $feed .= " xml:lang=\"" . $this->language . "\"";
     }
     $feed .= ">\n";
     $feed .= "    <title>" . FeedCreator::htmlspecialchars($this->title) . "</title>\n";
     $feed .= "    <subtitle>" . FeedCreator::htmlspecialchars($this->description) . "</subtitle>\n";
     $feed .= "    <link rel=\"alternate\" type=\"text/html\" href=\"" . FeedCreator::htmlspecialchars($this->link) . "\"/>\n";
     $feed .= "    <id>" . FeedCreator::htmlspecialchars($this->link) . "</id>\n";
     $now = new FeedDate();
     $feed .= "    <updated>" . FeedCreator::htmlspecialchars($now->iso8601()) . "</updated>\n";
     if (!empty($this->editor)) {
         $feed .= "    <author>\n";
         $feed .= "        <name>" . $this->editor . "</name>\n";
         if (!empty($this->editorEmail)) {
             $feed .= "        <email>" . $this->editorEmail . "</email>\n";
         }
         $feed .= "    </author>\n";
     }
     $feed .= "    <generator>" . FEEDCREATOR_VERSION . "</generator>\n";
     $feed .= "<link rel=\"self\" type=\"application/atom+xml\" href=\"" . $this->syndicationURL . "\" />\n";
     $feed .= $this->_createAdditionalElements($this->additionalElements, "    ");
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= "    <entry>\n";
         $feed .= "        <title>" . FeedCreator::htmlspecialchars(strip_tags($this->items[$i]->title)) . "</title>\n";
         $feed .= "        <link rel=\"alternate\" type=\"text/html\" href=\"" . FeedCreator::htmlspecialchars($this->items[$i]->link) . "\"/>\n";
         if ($this->items[$i]->date == "") {
             $this->items[$i]->date = time();
         }
         $itemDate = new FeedDate($this->items[$i]->date);
         $feed .= "        <published>" . FeedCreator::htmlspecialchars($itemDate->iso8601()) . "</published>\n";
         $feed .= "        <updated>" . FeedCreator::htmlspecialchars($itemDate->iso8601()) . "</updated>\n";
         $feed .= "        <id>" . FeedCreator::htmlspecialchars($this->items[$i]->link) . "</id>\n";
         $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, "        ");
         if (!empty($this->items[$i]->author)) {
             $feed .= "        <author>\n";
             $feed .= "            <name>" . FeedCreator::htmlspecialchars($this->items[$i]->author) . "</name>\n";
             $feed .= "        </author>\n";
         }
         if (!empty($this->items[$i]->description)) {
             $feed .= "        <summary type=\"html\">" . FeedCreator::htmlspecialchars($this->items[$i]->description) . "</summary>\n";
         }
         if (!empty($this->items[$i]->enclosure)) {
             $feed .= "        <link rel=\"enclosure\" href=\"" . $this->items[$i]->enclosure->url . "\" type=\"" . $this->items[$i]->enclosure->type . "\"  length=\"" . $this->items[$i]->enclosure->length . "\" />\n";
         }
         $feed .= "    </entry>\n";
     }
     $feed .= "</feed>\n";
     return $feed;
 }
	function createFeed() {
		global $config;
		$now = new FeedDate();
		$this->descriptionTruncSize = 500;

		$feed = '<?xml version="1.0" encoding="'.$this->encoding.'"?>'."\n";
		$feed .= $this->_createGeneratorComment();
		$feed .= '<klip>'."\n";

		$feed .= '	<owner>'."\n";
		$feed .= '		<author>'.$this->htmlspecialchars(FeedCreator::iTrunc($this->editor,100)).'</author>'."\n";
		$feed .= '		<copyright>'.$this->htmlspecialchars(FeedCreator::iTrunc($this->copyright,100)).'</copyright>'."\n";
		if (!empty($this->editorEmail)) {
			$feed .= '		<email>'.$this->htmlspecialchars($this->editorEmail).'</email>'."\n";
		}
		$feed .= '		<web>'.$this->link.'</web>'."\n";
		$feed .= '	</owner>'."\n";

		$feed .= '	<identity>'."\n";
		$feed .= '		<title>'.$this->htmlspecialchars(FeedCreator::iTrunc($this->title,100)).'</title>'."\n";
		$feed .= '		<uniqueid>'.md5($config['cryptkey']).'</uniqueid>'."\n";
		$feed .= '		<version>1.0</version>'."\n";
		$feed .= '		<lastmodified>'.$this->htmlspecialchars($now->v0001()).'</lastmodified>'."\n";
		$feed .= '		<description>'.$this->getDescription($this->encoding).'</description>'."\n";
		$feed .= '		<keywords>Viscacha '.$this->htmlspecialchars($this->title).'</keywords>'."\n";
		$feed .= '	</identity>'."\n";

		$feed .= '	<locations>'."\n";
		$feed .= '		<defaultlink>'.$this->link.'</defaultlink>'."\n";
		$feed .= '		<contentsource>'.$config['furl'].'/external.php?action=KLIPFOOD</contentsource>'."\n";
		$feed .= '		<kliplocation>'.$config['furl'].'/external.php?action=KLIPFOLIO</kliplocation>'."\n";
		$feed .= '	</locations>'."\n";

		$feed .= '	<setup>'."\n";
		$feed .= '		<refresh>'.$this->htmlspecialchars($this->ttl).'</refresh>'."\n";
		if (!check_hp($_SERVER['HTTP_REFERER'])) {
			$_SERVER['HTTP_REFERER'] = $this->link;
		}
		$feed .= '		<referer>'.$this->htmlspecialchars($_SERVER['HTTP_REFERER']).'</referer>'."\n";
		$feed .= '		<country>'.$this->language.'</country>'."\n";
		$feed .= '		<language>'.$this->language.'</language>'."\n";
		$feed .= '	</setup>'."\n";

		$feed .= '	<messages>'."\n";
		$feed .= '		<loading>Getting data...</loading>'."\n";
		$feed .= '		<nodata>No items to display.</nodata>'."\n";
		$feed .= '	</messages>'."\n";

		$feed .= "</klip>\n";
		return $feed;
	}
Пример #6
0
 function output()
 {
     if (!$this->rawFieldContent) {
         $result = "";
     } elseif ($this->syndicateHtml) {
         $result = "<![CDATA[" . $this->rawFieldContent . "]]>";
     } else {
         if ($this->truncSize and is_int($this->truncSize)) {
             $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize);
         } else {
             $result = htmlspecialchars($this->rawFieldContent);
         }
     }
     return $result;
 }
 function createFeed()
 {
     $now = new FeedDate();
     $this->descriptionTruncSize = 500;
     $feed = '<?xml version="1.0" encoding="' . $this->encoding . '"?>' . "\n";
     $feed .= $this->_createGeneratorComment();
     $feed .= '<klipfood>' . "\n";
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= '	<item>' . "\n";
         $feed .= '		<title>' . $this->htmlspecialchars(FeedCreator::iTrunc($this->items[$i]->title, 100)) . '</title>' . "\n";
         $feed .= '		<link>' . $this->htmlspecialchars($this->items[$i]->link) . '</link>' . "\n";
         $feed .= '		<note>' . $this->items[$i]->getDescription($this->encoding) . '</note>' . "\n";
         $feed .= '	</item>' . "\n";
     }
     $feed .= '</klipfood>' . "\n";
     return $feed;
 }
 function createFeed()
 {
     global $config, $lang;
     $now = new FeedDate();
     $this->descriptionTruncSize = 500;
     $feed = $this->_createGeneratorComment();
     $feed .= '<?xml version="1.0"?>' . "\n";
     $feed .= '<klipfood>' . "\n";
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= '	<item>' . "\n";
         $feed .= '		<title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . '</title>' . "\n";
         $feed .= '		<link>' . htmlspecialchars($this->items[$i]->link) . '</link>' . "\n";
         $feed .= '		<note>' . $this->items[$i]->getDescription() . '</note>' . "\n";
         $feed .= '	</item>' . "\n";
     }
     $feed .= '</klipfood>' . "\n";
     return $feed;
 }
Пример #9
0
 function createFeed()
 {
     $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
     $feed .= $this->_createGeneratorComment();
     $feed .= $this->_createStylesheetReferences();
     $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
     $feed .= "    <head>\n";
     $feed .= "        <title>" . FeedCreator::htmlspecialchars($this->title) . "</title>\n";
     if ($this->pubDate != "") {
         $date = new FeedDate($this->pubDate);
         $feed .= "         <dateCreated>" . $date->rfc822() . "</dateCreated>\n";
     }
     if ($this->lastBuildDate != "") {
         $date = new FeedDate($this->lastBuildDate);
         $feed .= "         <dateModified>" . $date->rfc822() . "</dateModified>\n";
     }
     if ($this->editor != "") {
         $feed .= "         <ownerName>" . $this->editor . "</ownerName>\n";
     }
     if ($this->editorEmail != "") {
         $feed .= "         <ownerEmail>" . $this->editorEmail . "</ownerEmail>\n";
     }
     $feed .= "    </head>\n";
     $feed .= "    <body>\n";
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= "    <outline type=\"rss\" ";
         $title = FeedCreator::htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", "  ")));
         $feed .= " title=\"" . $title . "\"";
         $feed .= " text=\"" . $title . "\"";
         //$feed.= " description=\"".FeedCreator::htmlspecialchars($this->items[$i]->description)."\"";
         $feed .= " url=\"" . FeedCreator::htmlspecialchars($this->items[$i]->link) . "\"";
         $feed .= "/>\n";
     }
     $feed .= "    </body>\n";
     $feed .= "</opml>\n";
     return $feed;
 }
Пример #10
0
 } else {
     $row->email = $row->gmail;
     $row->name = $row->gname;
 }
 $bbcode->setSmileys(0);
 if ($config['wordstatus'] == 0) {
     $row->dowords = 0;
 }
 $bbcode->setReplace($row->dowords);
 if ($row->status == 2) {
     $row->comment = $bbcode->ReplaceTextOnce($row->comment, 'moved');
 }
 $row->comment = $bbcode->parse($row->comment, 'plain');
 $row->comment = str_replace("\n", ' ', $row->comment);
 if (strxlen($row->comment) > $config['rsschars']) {
     $row->comment = FeedCreator::iTrunc($row->comment, $config['rsschars']);
 }
 $item = new FeedItem();
 $item->title = $row->topic;
 $item->link = $config['furl'] . "/showtopic.php?id=" . $row->id;
 $item->source = $config['furl'] . "/showforum.php?id=" . $row->board;
 $item->description = $row->comment;
 $item->date = $row->date;
 $item->author = $row->name;
 if ($config['syndication_insert_email'] == 1) {
     $item->authorEmail = $row->email;
 } else {
     $item->authorEmail = '';
 }
 $item->pubDate = $row->date;
 $item->category = $row->forum;
Пример #11
0
/**
 * Add recent changed pages to a feed object
 *
 * @author Andreas Gohr <*****@*****.**>
 * @param  FeedCreator $rss the FeedCreator Object
 * @param  array       $data the items to add
 * @param  array       $opt  the feed options
 */
function rss_buildItems(&$rss, &$data, $opt)
{
    global $conf;
    global $lang;
    /* @var auth_basic $auth */
    global $auth;
    $eventData = array('rss' => &$rss, 'data' => &$data, 'opt' => &$opt);
    $event = new Doku_Event('FEED_DATA_PROCESS', $eventData);
    if ($event->advise_before(false)) {
        foreach ($data as $ditem) {
            if (!is_array($ditem)) {
                // not an array? then only a list of IDs was given
                $ditem = array('id' => $ditem);
            }
            $item = new FeedItem();
            $id = $ditem['id'];
            if (!$ditem['media']) {
                $meta = p_get_metadata($id);
            } else {
                $meta = array();
            }
            // add date
            if ($ditem['date']) {
                $date = $ditem['date'];
            } elseif ($ditem['media']) {
                $date = @filemtime(mediaFN($id));
            } elseif (@file_exists(wikiFN($id))) {
                $date = @filemtime(wikiFN($id));
            } elseif ($meta['date']['modified']) {
                $date = $meta['date']['modified'];
            } else {
                $date = 0;
            }
            if ($date) {
                $item->date = date('r', $date);
            }
            // add title
            if ($conf['useheading'] && $meta['title']) {
                $item->title = $meta['title'];
            } else {
                $item->title = $ditem['id'];
            }
            if ($conf['rss_show_summary'] && !empty($ditem['sum'])) {
                $item->title .= ' - ' . strip_tags($ditem['sum']);
            }
            // add item link
            switch ($opt['link_to']) {
                case 'page':
                    if ($ditem['media']) {
                        $item->link = media_managerURL(array('image' => $id, 'ns' => getNS($id), 'rev' => $date), '&', true);
                    } else {
                        $item->link = wl($id, 'rev=' . $date, true, '&');
                    }
                    break;
                case 'rev':
                    if ($ditem['media']) {
                        $item->link = media_managerURL(array('image' => $id, 'ns' => getNS($id), 'rev' => $date, 'tab_details' => 'history'), '&', true);
                    } else {
                        $item->link = wl($id, 'do=revisions&rev=' . $date, true, '&');
                    }
                    break;
                case 'current':
                    if ($ditem['media']) {
                        $item->link = media_managerURL(array('image' => $id, 'ns' => getNS($id)), '&', true);
                    } else {
                        $item->link = wl($id, '', true, '&');
                    }
                    break;
                case 'diff':
                default:
                    if ($ditem['media']) {
                        $item->link = media_managerURL(array('image' => $id, 'ns' => getNS($id), 'rev' => $date, 'tab_details' => 'history', 'mediado' => 'diff'), '&', true);
                    } else {
                        $item->link = wl($id, 'rev=' . $date . '&do=diff', true, '&');
                    }
            }
            // add item content
            switch ($opt['item_content']) {
                case 'diff':
                case 'htmldiff':
                    if ($ditem['media']) {
                        $revs = getRevisions($id, 0, 1, 8192, true);
                        $rev = $revs[0];
                        $src_r = '';
                        $src_l = '';
                        if ($size = media_image_preview_size($id, false, new JpegMeta(mediaFN($id)), 300)) {
                            $more = 'w=' . $size[0] . '&h=' . $size[1] . 't=' . @filemtime(mediaFN($id));
                            $src_r = ml($id, $more);
                        }
                        if ($rev && ($size = media_image_preview_size($id, $rev, new JpegMeta(mediaFN($id, $rev)), 300))) {
                            $more = 'rev=' . $rev . '&w=' . $size[0] . '&h=' . $size[1];
                            $src_l = ml($id, $more);
                        }
                        $content = '';
                        if ($src_r) {
                            $content = '<table>';
                            $content .= '<tr><th width="50%">' . $rev . '</th>';
                            $content .= '<th width="50%">' . $lang['current'] . '</th></tr>';
                            $content .= '<tr align="center"><td><img src="' . $src_l . '" alt="" /></td><td>';
                            $content .= '<img src="' . $src_r . '" alt="' . $id . '" /></td></tr>';
                            $content .= '</table>';
                        }
                    } else {
                        require_once DOKU_INC . 'inc/DifferenceEngine.php';
                        $revs = getRevisions($id, 0, 1);
                        $rev = $revs[0];
                        if ($rev) {
                            $df = new Diff(explode("\n", rawWiki($id, $rev)), explode("\n", rawWiki($id, '')));
                        } else {
                            $df = new Diff(array(''), explode("\n", rawWiki($id, '')));
                        }
                        if ($opt['item_content'] == 'htmldiff') {
                            // note: no need to escape diff output, TableDiffFormatter provides 'safe' html
                            $tdf = new TableDiffFormatter();
                            $content = '<table>';
                            $content .= '<tr><th colspan="2" width="50%">' . $rev . '</th>';
                            $content .= '<th colspan="2" width="50%">' . $lang['current'] . '</th></tr>';
                            $content .= $tdf->format($df);
                            $content .= '</table>';
                        } else {
                            // note: diff output must be escaped, UnifiedDiffFormatter provides plain text
                            $udf = new UnifiedDiffFormatter();
                            $content = "<pre>\n" . hsc($udf->format($df)) . "\n</pre>";
                        }
                    }
                    break;
                case 'html':
                    if ($ditem['media']) {
                        if ($size = media_image_preview_size($id, false, new JpegMeta(mediaFN($id)))) {
                            $more = 'w=' . $size[0] . '&h=' . $size[1] . 't=' . @filemtime(mediaFN($id));
                            $src = ml($id, $more);
                            $content = '<img src="' . $src . '" alt="' . $id . '" />';
                        } else {
                            $content = '';
                        }
                    } else {
                        if (@filemtime(wikiFN($id)) === $date) {
                            $content = p_wiki_xhtml($id, '', false);
                        } else {
                            $content = p_wiki_xhtml($id, $date, false);
                        }
                        // no TOC in feeds
                        $content = preg_replace('/(<!-- TOC START -->).*(<!-- TOC END -->)/s', '', $content);
                        // add alignment for images
                        $content = preg_replace('/(<img .*?class="medialeft")/s', '\\1 align="left"', $content);
                        $content = preg_replace('/(<img .*?class="mediaright")/s', '\\1 align="right"', $content);
                        // make URLs work when canonical is not set, regexp instead of rerendering!
                        if (!$conf['canonical']) {
                            $base = preg_quote(DOKU_REL, '/');
                            $content = preg_replace('/(<a href|<img src)="(' . $base . ')/s', '$1="' . DOKU_URL, $content);
                        }
                    }
                    break;
                case 'abstract':
                default:
                    if ($ditem['media']) {
                        if ($size = media_image_preview_size($id, false, new JpegMeta(mediaFN($id)))) {
                            $more = 'w=' . $size[0] . '&h=' . $size[1] . 't=' . @filemtime(mediaFN($id));
                            $src = ml($id, $more);
                            $content = '<img src="' . $src . '" alt="' . $id . '" />';
                        } else {
                            $content = '';
                        }
                    } else {
                        $content = $meta['description']['abstract'];
                    }
            }
            $item->description = $content;
            //FIXME a plugin hook here could be senseful
            // add user
            # FIXME should the user be pulled from metadata as well?
            $user = @$ditem['user'];
            // the @ spares time repeating lookup
            $item->author = '';
            if ($user && $conf['useacl'] && $auth) {
                $userInfo = $auth->getUserData($user);
                if ($userInfo) {
                    switch ($conf['showuseras']) {
                        case 'username':
                            $item->author = $userInfo['name'];
                            break;
                        default:
                            $item->author = $user;
                            break;
                    }
                } else {
                    $item->author = $user;
                }
                if ($userInfo && !$opt['guardmail']) {
                    $item->authorEmail = $userInfo['mail'];
                } else {
                    //cannot obfuscate because some RSS readers may check validity
                    $item->authorEmail = $user . '@' . $ditem['ip'];
                }
            } elseif ($user) {
                // this happens when no ACL but some Apache auth is used
                $item->author = $user;
                $item->authorEmail = $user . '@' . $ditem['ip'];
            } else {
                $item->authorEmail = 'anonymous@' . $ditem['ip'];
            }
            // add category
            if (isset($meta['subject'])) {
                $item->category = $meta['subject'];
            } else {
                $cat = getNS($id);
                if ($cat) {
                    $item->category = $cat;
                }
            }
            // finally add the item to the feed object, after handing it to registered plugins
            $evdata = array('item' => &$item, 'opt' => &$opt, 'ditem' => &$ditem, 'rss' => &$rss);
            $evt = new Doku_Event('FEED_ITEM_ADD', $evdata);
            if ($evt->advise_before()) {
                $rss->addItem($item);
            }
            $evt->advise_after();
            // for completeness
        }
    }
    $event->advise_after();
}
Пример #12
0
 function createFeed()
 {
     $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
     $feed .= $this->_createStylesheetReferences();
     $feed .= "<rss version=\"" . $this->RSSVersion . "\" xmlns:mtree=\"http://www.mosets.com/tree/rss/\">\n";
     $feed .= "<channel>\n";
     $feed .= "<title>" . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n";
     $this->descriptionTruncSize = 500;
     $feed .= "<description>" . $this->getDescription() . "</description>\n";
     $feed .= "<link>" . $this->link . "</link>\n";
     $now = new FeedDate();
     $feed .= "<lastBuildDate>" . htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n";
     $feed .= "<generator>" . FEEDCREATOR_VERSION . "</generator>\n";
     if ($this->image != null) {
         $feed .= "<image>\n";
         $feed .= "\t<url>" . $this->image->url . "</url>\n";
         $feed .= "\t<title>" . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100) . "</title>\n";
         $feed .= "\t<link>" . $this->image->link . "</link>\n";
         if ($this->image->width != "") {
             $feed .= "\t<width>" . $this->image->width . "</width>\n";
         }
         if ($this->image->height != "") {
             $feed .= "\t<height>" . $this->image->height . "</height>\n";
         }
         if ($this->image->description != "") {
             $feed .= "\t<description>" . $this->image->getDescription() . "</description>\n";
         }
         $feed .= "</image>\n";
     }
     if ($this->language != "") {
         $feed .= "<language>" . $this->language . "</language>\n";
     }
     if ($this->copyright != "") {
         $feed .= "<copyright>" . FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100) . "</copyright>\n";
     }
     if ($this->editor != "") {
         $feed .= "<managingEditor>" . FeedCreator::iTrunc(htmlspecialchars($this->editor), 100) . "</managingEditor>\n";
     }
     if ($this->webmaster != "") {
         $feed .= "<webMaster>" . FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100) . "</webMaster>\n";
     }
     if ($this->pubDate != "") {
         $pubDate = new FeedDate($this->pubDate);
         $feed .= "<pubDate>" . htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n";
     }
     if ($this->category != "") {
         $feed .= "<category>" . htmlspecialchars($this->category) . "</category>\n";
     }
     if ($this->docs != "") {
         $feed .= "<docs>" . FeedCreator::iTrunc(htmlspecialchars($this->docs), 500) . "</docs>\n";
     }
     if ($this->ttl != "") {
         $feed .= "<ttl>" . htmlspecialchars($this->ttl) . "</ttl>\n";
     }
     if (isset($this->rating_count) && $this->rating_count > 0) {
         $rating = round($this->rating_sum / $this->rating_count);
         $feed .= "<rating>" . FeedCreator::iTrunc(htmlspecialchars($rating), 500) . "</rating>\n";
     }
     if ($this->skipHours != "") {
         $feed .= "<skipHours>" . htmlspecialchars($this->skipHours) . "</skipHours>\n";
     }
     if ($this->skipDays != "") {
         $feed .= "<skipDays>" . htmlspecialchars($this->skipDays) . "</skipDays>\n";
     }
     $feed .= $this->_createAdditionalElements($this->additionalElements, "\t");
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= "<item>\n";
         $feed .= "\t<title>" . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n";
         $feed .= "\t<link>" . htmlspecialchars($this->items[$i]->link) . "</link>\n";
         $feed .= "\t<description>" . $this->items[$i]->getDescription() . "</description>\n";
         if ($this->items[$i]->author != "") {
             $feed .= "\t<author>" . htmlspecialchars($this->items[$i]->author) . "</author>\n";
         }
         if ($this->items[$i]->category != "") {
             $feed .= "\t<category>" . htmlspecialchars($this->items[$i]->category) . "</category>\n";
         }
         if ($this->items[$i]->comments != "") {
             $feed .= "\t<comments>" . htmlspecialchars($this->items[$i]->comments) . "</comments>\n";
         }
         if ($this->items[$i]->date != "") {
             $itemDate = new FeedDate($this->items[$i]->date);
             $feed .= "\t<pubDate>" . htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n";
         }
         if ($this->items[$i]->guid != "") {
             $feed .= "\t<guid>" . htmlspecialchars($this->items[$i]->guid) . "</guid>\n";
         }
         $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, "\t");
         $feed .= "</item>\n";
     }
     $feed .= "</channel>\n";
     $feed .= "</rss>\n";
     return $feed;
 }
Пример #13
0
 /**
  * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0.
  * The feed will contain all items previously added in the same order.
  * @return    string    the feed's complete text
  */
 function createFeed()
 {
     $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
     $feed .= $this->_createGeneratorComment();
     if ($this->cssStyleSheet == "") {
         $cssStyleSheet = "http://www.w3.org/2000/08/w3c-synd/style.css";
     }
     $feed .= $this->_createStylesheetReferences();
     $feed .= "<rdf:RDF\n";
     $feed .= "    xmlns=\"http://purl.org/rss/1.0/\"\n";
     $feed .= "    xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
     $feed .= "    xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n";
     $feed .= "    xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
     $feed .= "    <channel rdf:about=\"" . $this->syndicationURL . "\">\n";
     $feed .= "        <title>" . FeedCreator::htmlspecialchars($this->title) . "</title>\n";
     $feed .= "        <description>" . FeedCreator::htmlspecialchars($this->description) . "</description>\n";
     $feed .= "        <link>" . $this->link . "</link>\n";
     if ($this->image != null) {
         $feed .= "        <image rdf:resource=\"" . $this->image->url . "\" />\n";
     }
     $now = new FeedDate();
     $feed .= "       <dc:date>" . FeedCreator::htmlspecialchars($now->iso8601()) . "</dc:date>\n";
     $feed .= "        <items>\n";
     $feed .= "            <rdf:Seq>\n";
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= "                <rdf:li rdf:resource=\"" . FeedCreator::htmlspecialchars($this->items[$i]->link) . "\"/>\n";
     }
     $feed .= "            </rdf:Seq>\n";
     $feed .= "        </items>\n";
     $feed .= "    </channel>\n";
     if ($this->image != null) {
         $feed .= "    <image rdf:about=\"" . $this->image->url . "\">\n";
         $feed .= "        <title>" . $this->image->title . "</title>\n";
         $feed .= "        <link>" . $this->image->link . "</link>\n";
         $feed .= "        <url>" . $this->image->url . "</url>\n";
         $feed .= "    </image>\n";
     }
     $feed .= $this->_createAdditionalElements($this->additionalElements, "    ");
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= "    <item rdf:about=\"" . FeedCreator::htmlspecialchars($this->items[$i]->link) . "\">\n";
         //$feed.= "        <dc:type>Posting</dc:type>\n";
         $feed .= "        <dc:format>text/html</dc:format>\n";
         if ($this->items[$i]->date != null) {
             $itemDate = new FeedDate($this->items[$i]->date);
             $feed .= "        <dc:date>" . FeedCreator::htmlspecialchars($itemDate->iso8601()) . "</dc:date>\n";
         }
         if ($this->items[$i]->source != "") {
             $feed .= "        <dc:source>" . FeedCreator::htmlspecialchars($this->items[$i]->source) . "</dc:source>\n";
         }
         if ($this->items[$i]->author != "") {
             $feed .= "        <dc:creator>" . FeedCreator::htmlspecialchars($this->items[$i]->author) . "</dc:creator>\n";
         }
         $feed .= "        <title>" . FeedCreator::htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", "  "))) . "</title>\n";
         $feed .= "        <link>" . FeedCreator::htmlspecialchars($this->items[$i]->link) . "</link>\n";
         $feed .= "        <description>" . FeedCreator::htmlspecialchars($this->items[$i]->description) . "</description>\n";
         $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, "        ");
         // added by Joseph LeBlanc, contact@jlleblanc.com
         if (count($this->items[$i]->enclosures)) {
             foreach ($this->items[$i]->enclosures as $enc) {
                 $feed .= "            <enclosure url=\"" . $enc['url'] . "\" length=\"" . $enc['length'] . "\" type=\"" . $enc['type'] . "\" />";
             }
         }
         // end add, Joseph LeBlanc
         $feed .= "    </item>\n";
     }
     $feed .= "</rdf:RDF>\n";
     return $feed;
 }
 /**
  * Writes the HTML.
  * @return	string	the scripts's complete text
  */
 function createFeed()
 {
     // if there is styleless output, use the content of this variable and ignore the rest
     if ($this->stylelessOutput != "") {
         return $this->stylelessOutput;
     }
     //set an openInNewWindow_token_to be inserted or not
     if ($this->openInNewWindow) {
         $targetInsert = " target='_blank'";
     }
     // use this array to put the lines in and implode later with "document.write" javascript
     $feedArray = array();
     if ($this->image != null) {
         $imageStr = "<a href='" . $this->image->link . "'" . $targetInsert . ">" . "<img src='" . $this->image->url . "' border='0' alt='" . $this->htmlspecialchars(FeedCreator::iTrunc($this->image->title, 100)) . "' align='" . $this->imageAlign . "' ";
         if ($this->image->width) {
             $imageStr .= " width='" . $this->image->width . "' ";
         }
         if ($this->image->height) {
             $imageStr .= " height='" . $this->image->height . "' ";
         }
         $imageStr .= "/></a>";
         $feedArray[] = $imageStr;
     }
     if ($this->title) {
         $feedArray[] = "<div class='" . $this->stylePrefix . "title'><a href='" . $this->link . "' " . $targetInsert . " class='" . $this->stylePrefix . "title'>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->title, 100)) . "</a></div>";
     }
     $description = $this->getDescription($this->encoding);
     if ($description) {
         $feedArray[] = "<div class='" . $this->stylePrefix . "description'>" . str_replace("]]>", "", str_replace("<![CDATA[", "", $description)) . "</div>";
     }
     if ($this->header) {
         $feedArray[] = "<div class='" . $this->stylePrefix . "header'>" . $this->htmlspecialchars($this->header) . "</div>";
     }
     for ($i = 0; $i < count($this->items); $i++) {
         if ($this->separator and $i > 0) {
             $feedArray[] = "<div class='" . $this->stylePrefix . "separator'>" . $this->htmlspecialchars($this->separator) . "</div>";
         }
         if ($this->items[$i]->title) {
             if ($this->items[$i]->link) {
                 $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'><a href='" . $this->items[$i]->link . "' class='" . $this->stylePrefix . "item_title'" . $targetInsert . ">" . $this->htmlspecialchars(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "</a></div>";
             } else {
                 $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "</div>";
             }
         }
         $description = $this->items[$i]->getDescription($this->encoding);
         if ($description) {
             $feedArray[] = "<div class='" . $this->stylePrefix . "item_description'>" . str_replace("]]>", "", str_replace("<![CDATA[", "", $description)) . "</div>";
         }
     }
     if ($this->footer) {
         $feedArray[] = "<div class='" . $this->stylePrefix . "footer'>" . $this->htmlspecialchars($this->footer) . "</div>";
     }
     $jsFeed = "";
     foreach ($feedArray as $indexval => $value) {
         $jsFeed .= "document.write('" . trim(addslashes($value)) . "');\n";
     }
     return $jsFeed;
 }
Пример #15
0
 /**
  * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0.
  * The feed will contain all items previously added in the same order.
  * @return    string    the feed's complete text
  */
 function createFeed()
 {
     $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
     $feed .= $this->_createGeneratorComment();
     $feed .= $this->_createStylesheetReferences();
     $feed .= "<rss version=\"" . $this->RSSVersion . "\">\n";
     $feed .= "    <channel>\n";
     $feed .= "        <title>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars($this->title), 100) . "</title>\n";
     $this->descriptionTruncSize = 500;
     $feed .= "        <description>" . $this->getDescription() . "</description>\n";
     $feed .= "        <link>" . $this->link . "</link>\n";
     $now = new FeedDate();
     $feed .= "        <lastBuildDate>" . FeedCreator::htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n";
     $feed .= "        <generator>" . FEEDCREATOR_VERSION . "</generator>\n";
     if ($this->image != null) {
         $feed .= "        <image>\n";
         $feed .= "            <url>" . $this->image->url . "</url>\n";
         $feed .= "            <title>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars($this->image->title), 100) . "</title>\n";
         $feed .= "            <link>" . $this->image->link . "</link>\n";
         if ($this->image->width != "") {
             $feed .= "            <width>" . $this->image->width . "</width>\n";
         }
         if ($this->image->height != "") {
             $feed .= "            <height>" . $this->image->height . "</height>\n";
         }
         if ($this->image->description != "") {
             $feed .= "            <description>" . $this->image->getDescription() . "</description>\n";
         }
         $feed .= "        </image>\n";
     }
     if ($this->language != "") {
         $feed .= "        <language>" . $this->language . "</language>\n";
     }
     if ($this->copyright != "") {
         $feed .= "        <copyright>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars($this->copyright), 100) . "</copyright>\n";
     }
     if (!empty($this->editor) && !empty($this->editorEmail)) {
         $feed .= "        <managingEditor>" . FeedCreator::htmlspecialchars($this->editorEmail) . " (" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars($this->editor), 100) . ")</managingEditor>\n";
     }
     if ($this->webmaster != "") {
         $feed .= "        <webMaster>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars($this->webmaster), 100) . "</webMaster>\n";
     }
     if ($this->pubDate != "") {
         $pubDate = new FeedDate($this->pubDate);
         $feed .= "        <pubDate>" . FeedCreator::htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n";
     }
     if ($this->category != "") {
         $feed .= "        <category>" . FeedCreator::htmlspecialchars($this->category) . "</category>\n";
     }
     if ($this->docs != "") {
         $feed .= "        <docs>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars($this->docs), 500) . "</docs>\n";
     }
     if ($this->ttl != "") {
         $feed .= "        <ttl>" . FeedCreator::htmlspecialchars($this->ttl) . "</ttl>\n";
     }
     if ($this->rating != "") {
         $feed .= "        <rating>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars($this->rating), 500) . "</rating>\n";
     }
     if ($this->skipHours != "") {
         $feed .= "        <skipHours>" . FeedCreator::htmlspecialchars($this->skipHours) . "</skipHours>\n";
     }
     if ($this->skipDays != "") {
         $feed .= "        <skipDays>" . FeedCreator::htmlspecialchars($this->skipDays) . "</skipDays>\n";
     }
     $feed .= $this->_createAdditionalElements($this->additionalElements, "    ");
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= "        <item>\n";
         $feed .= "            <title>" . FeedCreator::iTrunc(FeedCreator::htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n";
         $feed .= "            <link>" . FeedCreator::htmlspecialchars($this->items[$i]->link) . "</link>\n";
         $feed .= "            <description>" . $this->items[$i]->getDescription() . "</description>\n";
         if (!empty($this->items[$i]->author) && !empty($this->items[$i]->authorEmail)) {
             $feed .= "            <author>" . FeedCreator::htmlspecialchars($this->items[$i]->author) . " &lt;" . $this->items[$i]->authorEmail . "&gt;</author>\n";
         }
         /*
         // on hold
         if ($this->items[$i]->source!="") {
         		$feed.= "            <source>".FeedCreator::htmlspecialchars($this->items[$i]->source)."</source>\n";
         }
         */
         if ($this->items[$i]->category != "") {
             $feed .= "            <category>" . FeedCreator::htmlspecialchars($this->items[$i]->category) . "</category>\n";
         }
         if ($this->items[$i]->comments != "") {
             $feed .= "            <comments>" . FeedCreator::htmlspecialchars($this->items[$i]->comments) . "</comments>\n";
         }
         if ($this->items[$i]->date != "") {
             $itemDate = new FeedDate($this->items[$i]->date);
             $feed .= "            <pubDate>" . FeedCreator::htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n";
         }
         if ($this->items[$i]->guid != "") {
             $feed .= "            <guid>" . FeedCreator::htmlspecialchars($this->items[$i]->guid) . "</guid>\n";
         }
         $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, "        ");
         $feed .= "        </item>\n";
     }
     $feed .= "    </channel>\n";
     $feed .= "</rss>\n";
     return $feed;
 }
Пример #16
0
 function createFeed()
 {
     $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
     $feed .= "<!DOCTYPE xbel PUBLIC\n";
     $feed .= '    "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML"' . "\n";
     $feed .= '    "http://www.python.org/topics/xml/dtds/xbel-1.0.dtd">' . "\n";
     $feed .= $this->_createGeneratorComment();
     $feed .= '<xbel version="1.0"';
     $now = new FeedDate();
     $feed .= ' added="' . FeedCreator::htmlspecialchars($now->iso8601()) . '"';
     if ($this->language != "") {
         $feed .= " xml:lang=\"" . $this->language . "\"";
     }
     $feed .= ">\n";
     if ($this->title != "") {
         $feed .= "  <folder>\n";
         $feed .= "    <title>" . FeedCreator::htmlspecialchars($this->title) . "</title>\n";
         $feed .= "    <desc>" . FeedCreator::htmlspecialchars($this->description) . "</desc>\n";
     }
     $feed .= $this->_createAdditionalElements($this->additionalElements, "    ");
     $ocat = '';
     for ($i = 0; $i < count($this->items); $i++) {
         if ($this->items[$i]->category != $ocat) {
             if ($ocat != '') {
                 $feed .= "    </folder>\n";
             }
             $ocat = $this->items[$i]->category;
             if ($ocat != '') {
                 $feed .= "    <folder>\n";
                 $feed .= "      <title>" . FeedCreator::htmlspecialchars(strip_tags($ocat)) . "</title>\n";
             }
         }
         if (preg_match('/^-+$/', $this->items[$i]->title)) {
             $feed .= "    <separator/>\n";
             continue;
         }
         $feed .= '      <bookmark';
         $feed .= ' href="' . FeedCreator::htmlspecialchars($this->items[$i]->link) . '"';
         if ($this->items[$i]->date == "") {
             $itemDate = $now;
         } else {
             $itemDate = new FeedDate($this->items[$i]->date);
         }
         $feed .= ' added="' . FeedCreator::htmlspecialchars($itemDate->iso8601()) . '"';
         $feed .= ">\n";
         $feed .= "        <title>" . FeedCreator::htmlspecialchars(strip_tags($this->items[$i]->title)) . "</title>\n";
         if ($this->items[$i]->description != "") {
             $feed .= "        <desc>" . FeedCreator::htmlspecialchars($this->items[$i]->description) . "</desc>\n";
         }
         $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, "        ");
         $feed .= "      </bookmark>\n";
     }
     if ($ocat != '') {
         $feed .= "    </folder>\n";
     }
     if ($this->title != "") {
         $feed .= "  </folder>\n";
     }
     $feed .= "</xbel>\n";
     return $feed;
 }
Пример #17
0
 /**
  * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0.
  * The feed will contain all items previously added in the same order.
  * @return	string	the feed's complete text
  */
 function createFeed()
 {
     $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
     $feed .= $this->_createGeneratorComment();
     $feed .= $this->_createStylesheetReferences();
     $feed .= "<rss version=\"{$this->RSSVersion}\">\n";
     $feed .= "\t<channel>\n";
     $feed .= "\t\t<title>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->title, 100)) . "</title>\n";
     $feed .= "\t\t<description>" . $this->getDescription($this->encoding) . "</description>\n";
     $feed .= "\t\t<link>{$this->link}</link>\n";
     $now = new FeedDate();
     $feed .= "\t\t<lastBuildDate>" . $this->htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n";
     $feed .= "\t\t<generator>" . FEEDCREATOR_VERSION . "</generator>\n";
     if ($this->image != null) {
         $feed .= "\t\t<image>\n";
         $feed .= "\t\t\t<url>{$this->image->url}</url>\n";
         $feed .= "\t\t\t<title>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->image->title, 100)) . "</title>\n";
         $feed .= "\t\t\t<link>{$this->image->link}</link>\n";
         if (!empty($this->image->width)) {
             $feed .= "\t\t\t<width>{$this->image->width}</width>\n";
         }
         if (!empty($this->image->height)) {
             $feed .= "\t\t\t<height>{$this->image->height}</height>\n";
         }
         if (!empty($this->image->description)) {
             $feed .= "\t\t\t<description>" . $this->image->getDescription($this->encoding) . "</description>\n";
         }
         $feed .= "\t\t</image>\n";
     }
     if ($this->language != "") {
         $feed .= "\t\t<language>{$this->language}</language>\n";
     }
     if ($this->copyright != "") {
         $feed .= "\t\t<copyright>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->copyright, 100)) . "</copyright>\n";
     }
     if (!empty($this->editor) && !empty($this->editorEmail)) {
         $feed .= "\t\t<managingEditor>" . $this->htmlspecialchars($this->editorEmail) . " (" . $this->htmlspecialchars(FeedCreator::iTrunc($this->editor, 100)) . ")</managingEditor>\n";
     }
     if ($this->webmaster != "") {
         $feed .= "\t\t<webMaster>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->webmaster, 100)) . "</webMaster>\n";
     }
     if ($this->pubDate != "") {
         $pubDate = new FeedDate($this->pubDate);
         $feed .= "\t\t<pubDate>" . $this->htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n";
     }
     if ($this->category != "") {
         $feed .= "\t\t<category>" . $this->htmlspecialchars($this->category) . "</category>\n";
     }
     if ($this->docs != "") {
         $feed .= "\t\t<docs>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->docs, 500)) . "</docs>\n";
     }
     if ($this->ttl != "") {
         $feed .= "\t\t<ttl>" . $this->htmlspecialchars($this->ttl) . "</ttl>\n";
     }
     if ($this->rating != "") {
         $feed .= "\t\t<rating>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->rating, 500)) . "</rating>\n";
     }
     if ($this->skipHours != "") {
         $feed .= "\t\t<skipHours>" . $this->htmlspecialchars($this->skipHours) . "</skipHours>\n";
     }
     if ($this->skipDays != "") {
         $feed .= "\t\t<skipDays>" . $this->htmlspecialchars($this->skipDays) . "</skipDays>\n";
     }
     $feed .= $this->_createAdditionalElements($this->additionalElements, "\t");
     for ($i = 0; $i < count($this->items); $i++) {
         $feed .= "\t\t<item>\n";
         $feed .= "\t\t\t<title>" . $this->htmlspecialchars(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "</title>\n";
         $feed .= "\t\t\t<link>" . $this->htmlspecialchars($this->items[$i]->link) . "</link>\n";
         $feed .= "\t\t\t<description>" . $this->items[$i]->getDescription($this->encoding) . "</description>\n";
         if (!empty($this->items[$i]->author) && !empty($this->items[$i]->authorEmail)) {
             $feed .= "\t\t\t<author>" . $this->htmlspecialchars($this->items[$i]->author) . " &lt;" . $this->htmlspecialchars($this->items[$i]->authorEmail) . "&gt;</author>\n";
         }
         if ($this->items[$i]->category != "") {
             $feed .= "\t\t\t<category>" . $this->htmlspecialchars($this->items[$i]->category) . "</category>\n";
         }
         if ($this->items[$i]->comments != "") {
             $feed .= "\t\t\t<comments>" . $this->htmlspecialchars($this->items[$i]->comments) . "</comments>\n";
         }
         if ($this->items[$i]->date != "") {
             $itemDate = new FeedDate($this->items[$i]->date);
             $feed .= "\t\t\t<pubDate>" . $this->htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n";
         }
         if ($this->items[$i]->guid != "") {
             $feed .= "\t\t\t<guid>" . $this->htmlspecialchars($this->items[$i]->guid) . "</guid>\n";
         }
         $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, "\t\t");
         $feed .= "\t\t</item>\n";
     }
     $feed .= "\t</channel>\n";
     $feed .= "</rss>\n";
     return $feed;
 }
 /**
  * Creates the right output, depending on $truncSize, $syndicateHtml properties.
  * @return string    the formatted field
  */
 function output()
 {
     // when field available and syndicated in html we assume
     // - valid html in $rawFieldContent and we enclose in CDATA tags
     // - no truncation (truncating risks producing invalid html)
     if (!$this->rawFieldContent) {
         $result = "";
     } elseif ($this->syndicateHtml) {
         $result = "<![CDATA[" . $this->rawFieldContent . "]]>";
     } else {
         if ($this->truncSize and is_int($this->truncSize)) {
             $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize);
         } else {
             $result = htmlspecialchars($this->rawFieldContent);
         }
     }
     return $result;
 }
 function static_htmlspecialchars($content, $enc)
 {
     return FeedCreator::_htmlspecialchars($content, $enc);
 }
Пример #20
0
 /**
  * Writes the HTML.
  * @return    string    the scripts's complete text 
  */
 function createFeed()
 {
     // if there is styleless output, use the content of this variable and ignore the rest
     if ($this->stylelessOutput != "") {
         return $this->stylelessOutput;
     }
     //if no stylePrefix is set, generate it yourself depending on the script name
     if ($this->stylePrefix == "") {
         $this->stylePrefix = str_replace(".", "_", $this->_generateFilename()) . "_";
     }
     //set an openInNewWindow_token_to be inserted or not
     if ($this->openInNewWindow) {
         $targetInsert = " target='_blank'";
     }
     // use this array to put the lines in and implode later with "document.write" javascript
     $feedArray = array();
     if ($this->image != null) {
         $imageStr = "<a href='" . $this->image->link . "'" . $targetInsert . ">" . "<img src='" . $this->image->url . "' border='0' alt='" . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100) . "' align='" . $this->imageAlign . "' ";
         if ($this->image->width) {
             $imageStr .= " width='" . $this->image->width . "' ";
         }
         if ($this->image->height) {
             $imageStr .= " height='" . $this->image->height . "' ";
         }
         $imageStr .= "/></a>";
         $feedArray[] = $imageStr;
     }
     if ($this->title) {
         $feedArray[] = "<div class='" . $this->stylePrefix . "title'><a href='" . $this->link . "' " . $targetInsert . " class='" . $this->stylePrefix . "title'>" . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</a></div>";
     }
     if ($this->getDescription()) {
         $feedArray[] = "<div class='" . $this->stylePrefix . "description'>" . str_replace("]]>", "", str_replace("<![CDATA[", "", $this->getDescription())) . "</div>";
     }
     if ($this->header) {
         $feedArray[] = "<div class='" . $this->stylePrefix . "header'>" . $this->header . "</div>";
     }
     for ($i = 0; $i < count($this->items); $i++) {
         if ($this->separator and $i > 0) {
             $feedArray[] = "<div class='" . $this->stylePrefix . "separator'>" . $this->separator . "</div>";
         }
         if ($this->items[$i]->title) {
             if ($this->items[$i]->link) {
                 $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'><a href='" . $this->items[$i]->link . "' class='" . $this->stylePrefix . "item_title'" . $targetInsert . ">" . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</a></div>";
             } else {
                 $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'>" . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</div>";
             }
         }
         if ($this->items[$i]->getDescription()) {
             $feedArray[] = "<div class='" . $this->stylePrefix . "item_description'>" . str_replace("]]>", "", str_replace("<![CDATA[", "", $this->items[$i]->getDescription())) . "</div>";
         }
     }
     if ($this->footer) {
         $feedArray[] = "<div class='" . $this->stylePrefix . "footer'>" . $this->footer . "</div>";
     }
     $feed = "" . join($feedArray, "\r\n");
     return $feed;
 }
Пример #21
0
<?php

require "functions.php";
$_POST = file_get_contents("php://input");
$posts = json_decode($_POST);
$Atom = new FeedCreator();
$Atom->setBase($posts->basurl, $posts->feed_title, $posts->baseurl);
$matchies = getMatchies($posts->pattern, $posts->html);
foreach ($matchies as $m) {
    $id = $posts->baseurl . time();
    $title = itemReplace($posts->item_title, $m);
    $link = itemReplace($posts->item_link, $m);
    $summary = itemReplace($posts->item_content, $m);
    $Atom->addEntry($id, $title, $link, $summary);
}
echo $Atom->getRss2String();