diff options
Diffstat (limited to 'it_html.class')
-rw-r--r-- | it_html.class | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/it_html.class b/it_html.class index 1f705fb..7437aed 100644 --- a/it_html.class +++ b/it_html.class @@ -65,7 +65,7 @@ class it_html * @param $p Configuration settings. Can be set/overridden in constructor, configure(), html() or head(). * See source code for a list of supported values */ -function it_html($p = array()) +function __construct($p = array()) { # Default configuration of html class $this->p = $p + array( @@ -74,7 +74,6 @@ function it_html($p = array()) 'head' => '', # Code to put into head() section 'htmltype' => 'html5', # 'html5', '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,label,span,noscript', # tags that do not like newlines after them @@ -85,7 +84,7 @@ function it_html($p = array()) 'show_favicon' => true, # If true, add <link> tag to /favicon.ico if it exists 'favicon' => '', # If set, add favicon <link> tag to this url '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,pre,span,style,table,tbody,td,textarea,tfoot,th,thead,tr,ul,ol,article,section", + 'tags' => "a,b,br,button,div,em,fieldset,form,h1,h2,h3,h4,h5,h6,hr,img,input,label,legend,li,meta,noscript,p,pre,span,style,table,tbody,td,textarea,tfoot,th,thead,tr,ul,ol,article,section", 'title' => '', # HTML title (default: no title added) 'use_it_state' => false, # If true, generate code needed by state.js (aka 'history iframe') 'srclines' => $GLOBALS['debug_srclines'], # append stackdump to each tag @@ -107,7 +106,7 @@ function it_html($p = array()) $notexported = array_flip(explode(',', "dummy," . $this->p['notexported'])); # dummy keeps values > 0 # Create global functions for _tags - foreach (array_merge(explode(',', $this->p['tags']), explode(',', $this->p['moretags'])) as $func) + foreach (array_keys($this->alltags) as $func) { if (!function_exists($func) && $func) $code[$func] = "function $func() { \$args = func_get_args(); return \$GLOBALS['{$this->p['name']}']->_tag('$func', \$args); }"; @@ -140,6 +139,7 @@ static function configure($p) { $ithtml = $GLOBALS[$p['name'] ? $p['name'] : "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'])); $ithtml->alwaysclose = array_flip(explode(',', $ithtml->p['alwaysclosetags'])); } @@ -344,33 +344,6 @@ function tag($args) } /** - * Special img() function patches png transparency for IE 5.5-6 if ie_png_fix is set - * @param ... any number optional data or array of key => value arguments - * @return <img ... /> - */ -function img($args) -{ - if ($this->p['ie_png_fix'] && preg_match('/MSIE [56]/', $_SERVER['HTTP_USER_AGENT'])) - { - foreach($args as $id => $arg) - if (preg_match('/\.png(\?.*)?$/', $arg['src'])) - { - $args[$id]['style'] = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$arg['src']}',sizingMethod='crop');" . $arg['style']; - $args[$id]['src'] = $this->p['ie_png_fix']; - } - } - - foreach ($args as $arg) - $havealt += isset($arg['alt']); - - if (!$havealt) - it::error('img() needs alt'); - - return $this->_tag("img", $args); -} - - -/** * Create a dropdown menu object. Warning: encodes html code within options! * @param $tags key => value pairs of <select> tag * @param $options array (value => text) of available options or @@ -628,5 +601,16 @@ function _itjs($files, $mode) return $result; } + +/** + * Permit calling it_html::div() or parent::div() in a derived class. + */ +function __call($name, $args) +{ + if (isset($this->alltags[$name])) + return $this->_tag($name, $args[0]); + else + it::error("unknown method '$name' called."); +} + } -?> |