diff options
-rw-r--r-- | it_html.class | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/it_html.class b/it_html.class index 56918e1..4167356 100644 --- a/it_html.class +++ b/it_html.class @@ -39,23 +39,23 @@ function it_html($p = array()) # Default configuration of html class $this->p = $p + array( 'charset' => 'iso-8859-1', - 'doctype' => null, # Custom doctype (will usually be calculated from htmltype) - 'head' => '', # Code to put into head() section - 'htmltype' => 'xhtml', # 'html' (=old-style), 'xhtml' or 'xhtml-mobile' - 'lang' => 'de', # Language code to use in <html lang="..."> tag - 'ie_png_fix' => false, # To enable, supply URL of a transparent gif (like /images/0.gif) - '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 - 'nonewlinetags' => 'a,b,em,img,input,span', # tags that do not like newlines after them - 'notexported' => 'configure,sanitize', # Those methods are not exported - 'prettyprint' => false, # Should output be prettily indented? - 'show_boot_dom' => false, # If true, append invisible <div id="it_boot_dom"> at the end of body - 'show_content_type' => true, # If true, add <meta http-equiv="Content-Type" ...> header - 'show_favicon' => true, # If true, add <link> tag to /favicon.ico if it exists - 'staticallycallable' => 'q,u,select', # Those methods are statically callable (have same arguments as global stubs) but are a bit slower - 'use_it_state' => false, # If true, generate code needed by state.js (aka 'history iframe') - 'tags' => 'a,b,br,button,div,em,fieldset,form,h1,h2,h3,h4,h5,h6,hr,input,label,legend,li,meta,noscript,p,span,table,td,textarea,th,tr,ul', - 'title' => '', # HTML title (default: empty title) + 'doctype' => null, # Custom doctype (will usually be calculated from htmltype) + 'head' => '', # Code to put into head() section + 'htmltype' => 'xhtml', # 'html' (=old-style), 'xhtml' or 'xhtml-mobile' + 'lang' => 'de', # Language code to use in <html lang="..."> tag + 'ie_png_fix' => false, # To enable, supply URL of a transparent gif (like /images/0.gif) + '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 + 'nonewlinetags' => 'a,b,em,img,input,span', # tags that do not like newlines after them + 'notexported' => 'configure,sanitize',# Those methods are not exported + 'prettyprint' => false, # Should output be prettily indented? + 'show_boot_dom' => false, # If true, append invisible <div id="it_boot_dom"> at the end of body + 'show_content_type' => true, # If true, add <meta http-equiv="Content-Type" ...> header + 'show_favicon' => true, # If true, add <link> tag to /favicon.ico if it exists + 'staticallycallable' => 'q,u,select', # Those methods are statically callable (have same arguments as global stubs) but are a bit slower + 'tags' => 'a,b,br,button,div,em,fieldset,form,h1,h2,h3,h4,h5,h6,hr,input,label,legend,li,meta,noscript,p,span,style,table,td,textarea,th,tr,ul', + 'title' => '', # HTML title (default: no title added) + 'use_it_state' => false, # If true, generate code needed by state.js (aka 'history iframe') ); # We know these doctypes. If you need something else, supply 'doctype' in p @@ -112,15 +112,19 @@ function configure($p) * Example application code to render page: * echo html(head(...), body(...)); * - * @param any number of text args or array of key => value for $p (see constructor for list) + * @param any number of text args or array of key => value for $p. + * @param named parameter doctype can override <!DOCTYPE line + * @param named parameter lang contains language */ function html($args) { list($data, $p) = $this->_parse_args($args); $p += $this->p; - return ($p['doctype'] ? $p['doctype'] : $this->doctypes[$p['htmltype']]) . "\n" . + $html = ($p['doctype'] ? $p['doctype'] : $this->doctypes[$p['htmltype']]) . "\n" . '<html ' . ($p['htmltype'] == "xhtml-mobile" ? 'xml:lang' : 'lang') . "=\"{$p['lang']}\">\n" . $data . ($p['omit_endhtml'] ? '' : "</html>\n"); + + return EDC('re') ? it::replace(array('<!DOCTYPE.*<head>' => ''), $html, array('singleline' => true)) : $html; } @@ -159,7 +163,7 @@ function head($args = array()) if (!empty($p['cssinline'])) $header .= tag('style', array('type' => "text/css", "\n" . preg_replace(array('/\s*\/\*[^\*]+\*\//Um', '/\s*\{\s*/', '/;\s+/'), array('', '{', ';'), $p['cssinline']))); - $header .= $p['head'] . tag('title', Q($p['title'])); + $header .= $p['head'] . ($p['title'] ? tag('title', Q($p['title'])) : ""); if($this->p['htmltype'] == "xhtml-mobile" && strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) header("Content-Type: application/xhtml+xml; charset={$this->p['charset']}"); # for validation @@ -275,7 +279,7 @@ function _tag($name, $args) /** * Return a <tag> containing optional data. - * @param $name tag name ('h1', 'div' etc.) + * @param $name tag name ('style', etc.) * @param ... any number optional data or array of key => value arguments * @return string containing XML/HTML tag */ @@ -285,6 +289,14 @@ function tag($args) return $this->_tag($name, $args); } +/** + * function div($args...) + * creates a <div>...</div> element with any strings from $args as content. + * any associative arrays among the arguments will create attributes for <div>. + * attributes with values false or null will be omitted completely. + * attributes with value true can be used for boolean attributes like 'checked' + * attributes values are html encoded, content values are not so you may need to use Q(). + */ /** * Special img() function patches png transparency for IE 5.5-6 if ie_png_fix is set |