prepare mp refactor home and rss

This commit is contained in:
quenousimporte 2024-08-26 18:10:14 +02:00
parent cb59059a2b
commit b97f730205
1 changed files with 14 additions and 10 deletions

View File

@ -17,6 +17,11 @@
require 'settings.php'; require 'settings.php';
require 'TPEpubCreator.php'; require 'TPEpubCreator.php';
function add_mp_article($url, $context, $epub)
{
}
function get_mp_cookie() function get_mp_cookie()
{ {
global $mp_user; global $mp_user;
@ -325,17 +330,18 @@
foreach ($items as $item) foreach ($items as $item)
{ {
$title = $item->title; $url = $item->link;
$category = $item->xpath('dc:subject')[0]; $article = file_get_contents($url, false, $context);
$author = $item->xpath('dc:creator')[0];
$summary = $item->description;
$article = file_get_contents($item->link, false, $context);
$doc = new DOMDocument(); $doc = new DOMDocument();
$doc->loadHTML($article); $doc->loadHTML($article);
$finder = new DomXPath($doc); $finder = new DomXPath($doc);
$title = $item->title;
$author = $item->xpath('dc:creator')[0];
$date = $item->pubDate;
$summary = $item->description;
// strip images // strip images
$toremove = $finder->query('//svg'); $toremove = $finder->query('//svg');
foreach ($toremove as $elt) foreach ($toremove as $elt)
@ -355,7 +361,7 @@
$result = '<h1>' . $title . '</h1>'; $result = '<h1>' . $title . '</h1>';
$result .= '<p>' . $author . '</p>'; $result .= '<p>' . $author . '</p>';
$result .= '<p>' . $item->pubDate . '</p>'; $result .= '<p>' . $date . '</p>';
$result .= '<p><b>' . $summary . '</b></p>'; $result .= '<p><b>' . $summary . '</b></p>';
$nodes = $finder->query('//div[contains(@class, "paywall-restricted-content")]'); $nodes = $finder->query('//div[contains(@class, "paywall-restricted-content")]');
@ -501,8 +507,6 @@
foreach ($items as $item) foreach ($items as $item)
{ {
$title = $item->title; $title = $item->title;
$category = $item->xpath('dc:subject')[0];
$author = $item->xpath('dc:creator')[0]; $author = $item->xpath('dc:creator')[0];
$summary = $item->description; $summary = $item->description;