diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-10-28 11:15:58 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-10-28 11:15:58 +0100 |
commit | 510d0b2cf3c108447f42fcb119560175134fb0f6 (patch) | |
tree | e5fa478087f35655f5857ebefb5c4ba576503697 /lib/private/template.php | |
parent | 7466ff09bb1b02de45b62a622ce51e4f680f2658 (diff) | |
download | nextcloud-server-510d0b2cf3c108447f42fcb119560175134fb0f6.tar.gz nextcloud-server-510d0b2cf3c108447f42fcb119560175134fb0f6.zip |
Fix the "addHeader($tag, $attributes, $text)" methods to not ignore the $text parameter
Also support closing tags with no text content given
Conflicts:
lib/private/template.php
Diffstat (limited to 'lib/private/template.php')
-rw-r--r-- | lib/private/template.php | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/private/template.php b/lib/private/template.php index fe0cde53ff1..9ad9d5466db 100644 --- a/lib/private/template.php +++ b/lib/private/template.php @@ -158,10 +158,15 @@ class OC_Template extends \OC\Template\Base { * Add a custom element to the header * @param string $tag tag name of the element * @param array $attributes array of attributes for the element - * @param string $text the text content for the element + * @param string $text the text content for the element. If $text is null then the + * element will be written as empty element. So use "" to get a closing tag. */ - public function addHeader( $tag, $attributes, $text='') { - $this->headers[]=array('tag'=>$tag,'attributes'=>$attributes, 'text'=>$text); + public function addHeader($tag, $attributes, $text=null) { + $this->headers[]= array( + 'tag' => $tag, + 'attributes' => $attributes, + 'text' => $text + ); } /** @@ -178,12 +183,22 @@ class OC_Template extends \OC\Template\Base { $page = new OC_TemplateLayout($this->renderas, $this->app); // Add custom headers - $page->assign('headers', $this->headers, false); + $headers = ''; foreach(OC_Util::$headers as $header) { - $page->append('headers', $header); + $headers .= '<'.OC_Util::sanitizeHTML($header['tag']); + foreach($header['attributes'] as $name=>$value) { + $headers .= ' "'.OC_Util::sanitizeHTML($name).'"="'.OC_Util::sanitizeHTML($value).'"'; + } + if ($header['text'] !== null) { + $headers .= '>'.OC_Util::sanitizeHTML($header['text']).'</'.OC_Util::sanitizeHTML($header['tag']).'>'; + } else { + $headers .= '/>'; + } } - $page->assign( "content", $data, false ); + $page->assign('headers', $headers, false); + + $page->assign('content', $data, false ); return $page->fetchPage(); } else{ |