summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2018-04-26 18:32:07 +0200
committerChristian Schneider2018-04-26 18:32:07 +0200
commite649b1a12fe4b43063753e482a47fcda0cbeb9d7 (patch)
treea144113cd74f558c874910d543a62335a13837e7
parent1a671e962786da343919b4ce6a33efc3077962c0 (diff)
downloaditools-e649b1a12fe4b43063753e482a47fcda0cbeb9d7.tar.gz
itools-e649b1a12fe4b43063753e482a47fcda0cbeb9d7.tar.bz2
itools-e649b1a12fe4b43063753e482a47fcda0cbeb9d7.zip
Use different global object for htmltype xml to allow mixing xml/html5 generation
-rw-r--r--it_html.class4
-rwxr-xr-xtests/it_html.t2
2 files changed, 3 insertions, 3 deletions
diff --git a/it_html.class b/it_html.class
index 58e0b84..e410816 100644
--- a/it_html.class
+++ b/it_html.class
@@ -76,7 +76,7 @@ function __construct($p = array())
'htmltype' => 'html5', # 'html5', 'html' (=old-style), 'xhtml' or 'xhtml-mobile' for xhtml, or 'xml' for plain xml without magic
'lang' => 'de', # Language code to use in <html lang="..."> tag
'moretags' => '', # Comma-separated list of tag-functions to generate additionally to 'tags'
- 'name' => 'it_html', # Name of global variable $this is assigned to (string), XXX Copy and paste in configure() to keep PHP4 compatibility
+ 'name' => $p['htmltype'] == 'xml' ? 'it_html_xml' : 'it_html', # Name of global variable $this is assigned to (string), XXX Copy and paste in configure()
'nonewlinetags' => 'a,b,em,img,input,label,span,noscript', # tags that do not like newlines after them
'prettyprint' => it::is_devel(), # Should output be prettily indented?
'show_boot_dom' => false, # If true, append invisible <div id="it_boot_dom"> at the end of body
@@ -138,7 +138,7 @@ function __construct($p = array())
*/
static function configure($p)
{
- $ithtml = $GLOBALS[$p['name'] ? $p['name'] : "it_html"];
+ $ithtml = $GLOBALS[$p['name'] ?: ($p['htmltype'] == 'xml' ? 'it_html_xml' : 'it_html')];
$ithtml->p = $p + (array)$ithtml->p;
$ithtml->alltags = array_flip(explode(',', trim($ithtml->p['tags'] . ',' . $ithtml->p['moretags'], ',')));
$ithtml->hasnonewline = array_flip(explode(',', $ithtml->p['nonewlinetags']));
diff --git a/tests/it_html.t b/tests/it_html.t
index 8e529e0..6d55319 100755
--- a/tests/it_html.t
+++ b/tests/it_html.t
@@ -139,7 +139,7 @@ is(
# XML generation
unset($GLOBALS['it_html']);
-new it_html(array('htmltype' => "xml", 'tags' => "xmltest"));
+new it_html(array('htmltype' => "xml", 'name' => 'it_html', 'tags' => "xmltest"));
is(
xmltest(),