diff --git a/textpattern/lib/txplib_misc.php b/textpattern/lib/txplib_misc.php index 5f5e284a04..2a2bb8bcaf 100644 --- a/textpattern/lib/txplib_misc.php +++ b/textpattern/lib/txplib_misc.php @@ -4773,19 +4773,29 @@ function get_lastmod($unix_ts = null) /** * Sets headers. * - * @param array $headers 'lower-case-name' => 'value' + * @param array $headers 'name' => 'value' * @param bool $rewrite If TRUE, rewrites existing headers */ -function set_headers($headers = array('content-type' => 'text/html; charset=utf-8'), $rewrite = false) +function set_headers($headers = array('Content-Type' => 'text/html; charset=utf-8'), $rewrite = false) { if (headers_sent()) { return; } - if (!$rewrite) { - foreach (headers_list() as $header) { - unset($headers[strtolower(trim(strtok($header, ':')))]); + if (!$rewrite && $headers_list = headers_list()) { + $headers_low = array(); + + foreach (array_keys($headers) as $name) { + $headres_low[strtolower($name)] = $name; + } + + foreach ($headers_list as $header) { + $name = strtolower(trim(strtok($header, ':'))); + + if (isset($headers_low[$name])) { + unset($headers[$headers_low[$name]]); + } } } diff --git a/textpattern/publish.php b/textpattern/publish.php index ba0e61c7c3..191134f913 100644 --- a/textpattern/publish.php +++ b/textpattern/publish.php @@ -825,7 +825,6 @@ function output_file_download($filename) set_headers(array( 'content-type' => 'application/octet-stream', 'content-disposition' => 'attachment; filename="'.$filename.'"', - 'content-description' => 'File Download', 'content-length' => $filesize, // Fix for IE6 PDF bug on servers configured to send cache headers. 'cache-control' => 'private' diff --git a/textpattern/publish/taghandlers.php b/textpattern/publish/taghandlers.php index ac6bf31f58..56c2959f32 100644 --- a/textpattern/publish/taghandlers.php +++ b/textpattern/publish/taghandlers.php @@ -59,15 +59,15 @@ ->register('section_list') ->register('search_input') ->register('search_term') - ->register('link_to_next') - ->register('link_to_prev') + ->register('link_to', 'link_to_next') + ->register('link_to', 'link_to_prev', 'prev') ->register('next_title') ->register('prev_title') ->register('site_name') ->register('site_slogan') ->register('link_to_home') - ->register('newer') - ->register('older') + ->register('txp_pager', 'newer') + ->register('txp_pager', 'older', false) ->register('text') ->register('article_id') ->register('article_url_title') @@ -101,8 +101,8 @@ ->register('body') ->register('title') ->register('excerpt') - ->register('category1') - ->register('category2') + ->register('article_category', 'category1') + ->register('article_category', 'category2', 2) ->register('category') ->register('section') ->register('keywords') @@ -165,8 +165,8 @@ ->register('file_download') ->register('file_download_link') ->register('file_download_size') - ->register('file_download_created') - ->register('file_download_modified') + ->register('file_download_time', 'file_download_created') + ->register('file_download_time', 'file_download_modified', 'modified') ->register('file_download_id') ->register('file_download_name') ->register('file_download_category') @@ -1647,7 +1647,7 @@ function search_term($atts) // ------------------------------------------------------------- // Link to next/prev article, if it exists. -function link_to($atts, $thing = null, $target = null) +function link_to($atts, $thing = null, $target = 'next') { global $pretext, $thisarticle; @@ -1705,22 +1705,6 @@ function link_to($atts, $thing = null, $target = null) // ------------------------------------------------------------- -// Link to next article, if it exists. -function link_to_next($atts, $thing = null) -{ - return link_to($atts, $thing, 'next'); -} - -// ------------------------------------------------------------- - -// Link to previous article, if it exists. -function link_to_prev($atts, $thing = null) -{ - return link_to($atts, $thing, 'prev'); -} - -// ------------------------------------------------------------- - function next_title() { global $thisarticle, $is_article_list; @@ -1876,20 +1860,6 @@ function txp_pager($atts, $thing = null, $newer = true) // ------------------------------------------------------------- -function newer($atts, $thing = null) -{ - return txp_pager($atts, $thing); -} - -// ------------------------------------------------------------- - -function older($atts, $thing = null) -{ - return txp_pager($atts, $thing, false); -} - -// ------------------------------------------------------------- - function text($atts) { extract(lAtts(array( @@ -2979,28 +2949,14 @@ function excerpt($atts = array(), $thing = null) // ------------------------------------------------------------- -function category1($atts, $thing = null) -{ - return article_category(array('number' => 1) + $atts, $thing); -} - -// ------------------------------------------------------------- - -function category2($atts, $thing = null) -{ - return article_category(array('number' => 2) + $atts, $thing); -} - -// ------------------------------------------------------------- - -function article_category($atts, $thing = null) +function article_category($atts, $thing = null, $number = 1) { global $thisarticle, $s, $permlink_mode; assert_article(); extract(lAtts(array( - 'number' => 1, + 'number' => $number, 'class' => '', 'link' => 0, 'title' => 0, @@ -4365,12 +4321,12 @@ function txp_header($atts) } extract(lAtts(array( - 'name' => 'Content-Type', + 'name' => true, 'replace' => true, - 'value' => 'text/html; charset=utf-8', + 'value' => '200 OK', ), $atts)); - set_headers(array(strtolower($name) => $value), !empty($replace)); + set_headers(array($name => $value), !empty($replace)); } // ------------------------------------------------------------- @@ -4909,25 +4865,7 @@ function file_download_size($atts) // ------------------------------------------------------------- -function file_download_created($atts) -{ - global $thisfile; - - assert_file(); - - extract(lAtts(array('format' => ''), $atts)); - - if ($thisfile['created']) { - return fileDownloadFormatTime(array( - 'ftime' => $thisfile['created'], - 'format' => $format, - )); - } -} - -// ------------------------------------------------------------- - -function file_download_modified($atts) +function file_download_time($atts, $thing = null, $time = 'created') { global $thisfile; @@ -4935,9 +4873,9 @@ function file_download_modified($atts) extract(lAtts(array('format' => ''), $atts)); - if ($thisfile['modified']) { + if (!empty($thisfile[$time])) { return fileDownloadFormatTime(array( - 'ftime' => $thisfile['modified'], + 'ftime' => $thisfile[$time], 'format' => $format, )); } diff --git a/textpattern/vendors/Textpattern/Tag/Registry.php b/textpattern/vendors/Textpattern/Tag/Registry.php index c5de605a9e..a7a448b694 100644 --- a/textpattern/vendors/Textpattern/Tag/Registry.php +++ b/textpattern/vendors/Textpattern/Tag/Registry.php @@ -39,6 +39,7 @@ class Registry implements \Textpattern\Container\ReusableInterface */ private $tags = array(); + private $params = array(); private $atts = array(); /** @@ -63,6 +64,11 @@ public function register($callback, $tag = null) if ($tag) { $this->tags[$tag] = $callback; + $params = array_slice(func_get_args(), 2); + + if (!empty($params)) { + $this->params[$tag] = $params; + } } } @@ -113,7 +119,11 @@ public function registerAttr($callback, $tag = null) public function process($tag, array $atts = null, $thing = null) { if ($this->isRegistered($tag)) { - return (string) call_user_func($this->tags[$tag], (array)$atts, $thing); + //TODO: switch to args unpacking for php 5.6+ + return isset($this->params[$tag]) ? +// (string) call_user_func($this->tags[$tag], (array)$atts, $thing, ...$this->params[$tag]) : + (string) call_user_func_array($this->tags[$tag], array_merge(array((array)$atts, $thing), $this->params[$tag])) : + (string) call_user_func($this->tags[$tag], (array)$atts, $thing); } else { return false; }