This commit is contained in:
Frederic Guillot 2013-02-19 22:09:32 -05:00
parent e957fe1665
commit f943bdddf2
4 changed files with 19 additions and 13 deletions

View File

@ -318,6 +318,7 @@ nav .active a {
display: block;
margin-top: 15px;
margin-bottom: 15px;
max-width: 100%;
}
.item code {

View File

@ -67,10 +67,10 @@ class Filter
public function __construct($data, $url)
{
$this->url = $url;
$data = iconv("UTF-8", "ISO-8859-15//IGNORE", $data);
$dom = new \DOMDocument();
$dom->loadHTML($data);
// Convert bad formatted documents to XML
$dom = new \DOMDocument;
$dom->loadHTML('<?xml encoding="UTF-8">'.$data);
$this->input = $dom->saveXML($dom->getElementsByTagName('body')->item(0));
}

View File

@ -140,24 +140,29 @@ class Rss20 extends Parser
$author = '';
$content = '';
$pubdate = '';
$link = '';
if (isset($ns['feedburner'])) {
$ns_fb = $entry->children($ns['feedburner']);
$link = $ns_fb->origLink;
}
if (isset($ns['dc'])) {
$ns_dc = $entry->children($ns['dc']);
$author = (string) $ns_dc->creator;
$pubdate = (string) $ns_dc->date;
}
if (isset($ns['content'])) {
$ns_content = $entry->children($ns['content']);
if (! empty($entry->content)) {
$content = (string) $ns_content->encoded;
}
$content = (string) $ns_content->encoded;
}
if (! $content) {
if ($content === '' && isset($entry->description)) {
$content = (string) $entry->description;
}
@ -165,8 +170,8 @@ class Rss20 extends Parser
$item = new \StdClass;
$item->id = (string) $entry->guid;
$item->title = (string) $entry->title;
$item->url = (string) $entry->link;
$item->updated = strtotime((string) $entry->pubDate);
$item->url = $link ?: (string) $entry->link;
$item->updated = strtotime($pubdate ?: (string) $entry->pubDate) ?: $this->updated;
$item->content = $this->filterHtml($content, $item->url);
$item->author = $author ?: (string) $xml->channel->webMaster;

View File

@ -44,13 +44,13 @@ class Reader
public function getParser()
{
$first_lines = substr($this->content, 0, 512);
$first_lines = substr($this->content, 0, 1024);
if (stripos($first_lines, 'html') !== false) {
if ($this->discover()) {
$first_lines = substr($this->content, 0, 512);
$first_lines = substr($this->content, 0, 1024);
}
else {