1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 04:32:01 +02:00

e107::getFile()->send() now accepts optional type, encoding and disposition values.

HTMLTAG fallback for THEME_LAYOUT added.
This commit is contained in:
Cameron 2021-02-16 13:32:34 -08:00
parent 766b50338f
commit e371da1785
2 changed files with 29 additions and 17 deletions

View File

@ -117,7 +117,7 @@ if(!defined("XHTML4"))
{
echo "<!doctype html>\n";
$htmlTag = "<html".(defined("TEXTDIRECTION") ? " dir='".TEXTDIRECTION."'" : "").(defined("CORE_LC") ? " lang=\"".CORE_LC."\"" : "").">";
echo deftrue('HTMLTAG', $htmlTag)."\n";
echo (defined('HTMLTAG') ? str_replace('THEME_LAYOUT', THEME_LAYOUT, HTMLTAG) : $htmlTag)."\n";
echo "<head>\n";
echo "<meta charset='utf-8' />\n";
}
@ -139,6 +139,18 @@ if(!defined('e_PAGETITLE') && ($_PAGE_TITLE = e107::getSingleton('eResponse')->g
unset($_PAGE_TITLE);
}
if (deftrue('e_FRONTPAGE'))
{
// Ignore any additional title when current page is the frontpage
echo "<title>".SITENAME."</title>\n\n";
}
else
{
echo "<title>".(deftrue('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME') ? PAGE_NAME.' - ' : "")).SITENAME."</title>\n\n";
unset($_PAGE_TITLE);
}
//
// C: Send start of HTML
@ -179,18 +191,7 @@ unset($e_headers);
echo e107::getSingleton('eResponse')->renderMeta()."\n"; // render all the e107::meta() entries.
if (deftrue('e_FRONTPAGE'))
{
// Ignore any additional title when current page is the frontpage
echo "<title>".SITENAME."</title>\n\n";
}
else
{
echo "<title>".(deftrue('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME') ? PAGE_NAME.' - ' : "")).SITENAME."</title>\n\n";
unset($_PAGE_TITLE);
}
//

View File

@ -1078,10 +1078,11 @@
/**
* File retrieval function. by Cam.
*
* @param $file string actual path or {e_xxxx} path to file.
* @param string $file actual path or {e_xxxx} path to file.
* @param string $opts (optional) type | disposition | encoding values.
*
*/
function send($file)
function send($file, $opts = array())
{
global $e107;
@ -1159,12 +1160,22 @@
fseek($res, $seek);
}
$data_len -= $seek;
header("Expires: 0");
$contentType = vartrue($opts['type'], 'application/force-download');
$contentDisp = vartrue($opts['disposition'], 'attachment');
header('Expires: 0');
header("Cache-Control: max-age=30");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"{$file}\"");
header('Content-Type: '.$contentType);
header('Content-Disposition: '.$contentDisp.'; filename="'.$file.'"');
header("Content-Length: {$data_len}");
header("Pragma: public");
if(!empty($opts['encoding']))
{
header('Content-Transfer-Encoding: '.$opts['encoding']);
}
if($seek)
{
header("Accept-Ranges: bytes");