Compare commits
3 Commits
254d1fff48
...
9a53ed1da3
Author | SHA1 | Date |
---|---|---|
quenousimporte | 9a53ed1da3 | |
quenousimporte | 74ad25f7e3 | |
quenousimporte | 2c7c35cb09 |
30
epub.php
30
epub.php
|
@ -53,6 +53,16 @@
|
||||||
return $temp_img_path;
|
return $temp_img_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function inner_html($node)
|
||||||
|
{
|
||||||
|
$innerHTML = '';
|
||||||
|
foreach ($node->childNodes as $childNode)
|
||||||
|
{
|
||||||
|
$innerHTML .= $childNode->ownerDocument->saveHTML($childNode);
|
||||||
|
}
|
||||||
|
return $innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Paris');
|
date_default_timezone_set('Europe/Paris');
|
||||||
$date = (new DateTime('today'))->format('Ymd');
|
$date = (new DateTime('today'))->format('Ymd');
|
||||||
|
|
||||||
|
@ -62,6 +72,8 @@
|
||||||
// parameters hardcoded for now
|
// parameters hardcoded for now
|
||||||
$includeimages = false;
|
$includeimages = false;
|
||||||
$includepages = true;
|
$includepages = true;
|
||||||
|
$imagesonly = false;
|
||||||
|
$imagesize = $imagesonly ? "XLARGE" : "MEDIUM";
|
||||||
|
|
||||||
$url = $_POST['lmurl'];
|
$url = $_POST['lmurl'];
|
||||||
|
|
||||||
|
@ -112,14 +124,17 @@
|
||||||
}))[0];
|
}))[0];
|
||||||
$pageid = $pageobj->PublicationPageID;
|
$pageid = $pageobj->PublicationPageID;
|
||||||
|
|
||||||
$path = lm_download_image($url, 'Preview-MEDIUM-', $pageid);
|
$path = lm_download_image($url, 'Preview-' . $imagesize . '-', $pageid);
|
||||||
$epub->AddPage('<img style="width: 100%" src="' . $path . '">', false, 'Page ' . $page, true);
|
|
||||||
|
|
||||||
// Add page 1 as cover
|
|
||||||
if ($page == 1)
|
if ($page == 1)
|
||||||
{
|
{
|
||||||
|
// cover
|
||||||
$epub->AddImage($path, 'image/jpeg', true);
|
$epub->AddImage($path, 'image/jpeg', true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$epub->AddPage('<img style="width: 100%" src="' . $path . '">', false, 'Page ' . $page, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$articlebody = array_filter($article->ContentItem, function($item) { return $item->ContentType == 'text/xml'; });
|
$articlebody = array_filter($article->ContentItem, function($item) { return $item->ContentType == 'text/xml'; });
|
||||||
|
@ -151,13 +166,12 @@
|
||||||
$pagecontent .= '<p><img style="width: 100%" src="' . $path . '"></p>';
|
$pagecontent .= '<p><img style="width: 100%" src="' . $path . '"></p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pagecontent .= $articlebody->HtmlText;
|
$pagecontent .= $articlebody->HtmlText;
|
||||||
|
|
||||||
// debug
|
if (!$imagesonly)
|
||||||
// echo '<pre style="white-space: pre-wrap;">' . $pagecontent . '<br>----------------------</pre>';
|
{
|
||||||
|
$epub->AddPage($pagecontent, false, strip_tags($articlebody->Title), true);
|
||||||
$epub->AddPage($pagecontent, false, strip_tags($articlebody->Title), true);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write_epub($epub);
|
write_epub($epub);
|
||||||
|
|
Loading…
Reference in New Issue