miniflux-legacy/vendor/PicoFeed/Parser.php

63 lines
1.1 KiB
PHP
Raw Normal View History

2013-02-18 03:48:21 +01:00
<?php
namespace PicoFeed;
require_once __DIR__.'/Filter.php';
abstract class Parser
{
protected $content = '';
public $id = '';
public $url = '';
public $title = '';
public $updated = '';
public $items = array();
2013-04-05 05:34:07 +02:00
public $debug = false;
2013-02-18 03:48:21 +01:00
abstract public function execute();
public function __construct($content)
{
$this->content = $content;
}
public function filterHtml($str, $item_url)
{
$content = '';
if ($str) {
$filter = new Filter($str, $item_url);
$content = $filter->execute();
}
return $content;
}
2013-04-05 05:34:07 +02:00
public function displayXmlErrors()
2013-02-18 03:48:21 +01:00
{
2013-04-05 05:34:07 +02:00
foreach(\libxml_get_errors() as $error) {
2013-02-18 03:48:21 +01:00
2013-04-05 05:34:07 +02:00
printf("Message: %s\nLine: %d\nColumn: %d\nCode: %d\n",
$error->message,
$error->line,
$error->column,
$error->code
);
2013-02-18 03:48:21 +01:00
}
}
2013-04-05 05:34:07 +02:00
// Dirty quickfix before XML parsing
public function normalizeData($data)
2013-02-18 03:48:21 +01:00
{
2013-04-05 05:34:07 +02:00
return str_replace("\xc3\x20", '', $data);
2013-02-18 03:48:21 +01:00
}
}