Location: PHPKode > projects > Aukyla Document Management System > doc/html/a00241.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>Aukyla PHP Framework</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="StyleSheet" href="auton.css" type="text/css" media="screen">
  </head>

  <body>
    <div id="mainmenu">
      <a href="http://www.auton.nl/" class="home">Home</a>
    </div>
    <div id="submenu">
      <a class="logo" href="http://www.auton.nl/"></a>

      <div class="head">Ads</div>
      <a href="http://sourceforge.net/"><img src="http://sourceforge.net/sflogo.php?group_id=116358&amp;type=1" alt="SourceForge.net Logo" style="padding: 2px 4px; width: 88px; height: 31px; border: 0px"></a>
      <a href="http://getfirefox.com/" title="Get Firefox - The Browser, Reloaded."><img src="http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png" alt="Get Firefox" style="width: 110px; height: 32px; border: 0px"></a>
    </div>
    <div id="main">
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">base</a></div>
<h1>XHTML.php</h1><div class="fragment"><pre class="fragment">00001 &lt;?php
00002 <span class="comment">/*</span>
00003 <span class="comment">     XHTML.php, XHTML utility functions.</span>
00004 <span class="comment">     Copyright (C) 2004-2005 Arend van Beelen, Auton Rijnsburg</span>
00005 <span class="comment"></span>
00006 <span class="comment">     This program is free software; you can redistribute it and/or modify it</span>
00007 <span class="comment">     under the terms of the GNU General Public License as published by the Free</span>
00008 <span class="comment">     Software Foundation; either version 2 of the License, or (at your option)</span>
00009 <span class="comment">     any later version.</span>
00010 <span class="comment"></span>
00011 <span class="comment">     This program is distributed in the hope that it will be useful, but WITHOUT</span>
00012 <span class="comment">     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span>
00013 <span class="comment">     FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for</span>
00014 <span class="comment">     more details.</span>
00015 <span class="comment"></span>
00016 <span class="comment">     You should have received a copy of the GNU General Public License along</span>
00017 <span class="comment">     with this program; if not, write to the Free Software Foundation, Inc.,</span>
00018 <span class="comment">     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
00019 <span class="comment"></span>
00020 <span class="comment">     For any questions, comments or whatever, you may mail me at: hide@address.com</span>
00021 <span class="comment">*/</span>
00022 
00023 require_once('<a class="code" href="a00153.html">String</a>.php');
00024 require_once('Widgets.php');
00025 
00029 <span class="keyword">class </span>XHTMLTag
00030 {
00031         <span class="keyword">public</span> function __construct($name, $single, $visible, $textAllowed, $attributes = array(), $allowedParents = array(), $requiredAttributes = array())
00032         {
00033                 $this-&gt;name = $name;
00034                 $this-&gt;single = $single;
00035                 $this-&gt;visible = $visible;
00036                 $this-&gt;textAllowed = $textAllowed;
00037                 $this-&gt;attributes = $attributes;
00038                 $this-&gt;allowedParents = $allowedParents;
00039                 $this-&gt;requiredAttributes = $requiredAttributes;
00040         }
00041 
00042         <span class="keyword">public</span> $name;
00043         <span class="keyword">public</span> $single;
00044         <span class="keyword">public</span> $visible;
00045         <span class="keyword">public</span> $textAllowed;
00046         <span class="keyword">public</span> $attributes;
00047         <span class="keyword">public</span> $allowedParents;
00048         <span class="keyword">public</span> $requiredAttributes;
00049 }
00050 
<a name="l00054"></a><a class="code" href="a00169.html">00054</a> <span class="keyword">class </span><a class="code" href="a00169.html">XHTML</a>
00055 {
<a name="l00062"></a><a class="code" href="a00169.html#e0">00062</a>         <span class="keyword">public</span> <span class="keyword">static</span> function doctype()
00063         {
00064                 <span class="keywordflow">return</span> '&lt;!DOCTYPE html PUBLIC <span class="stringliteral">"-//W3C//DTD XHTML 1.1//EN"</span> <span class="stringliteral">"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"</span>&gt;';
00065         }
00066 
<a name="l00075"></a><a class="code" href="a00169.html#e1">00075</a>         <span class="keyword">public</span> <span class="keyword">static</span> function html2XhtmlDocument($document, &amp;$root = NULL)
00076         {
00077                 self::initializeTags();
00078 
00079                 $tagStack = '/html';
00080                 $readingTag = <span class="keyword">false</span>;
00081                 $readingComment = <span class="keyword">false</span>;
00082                 $readingEntity = <span class="keyword">false</span>;
00083                 $numberedEntity = <span class="keyword">false</span>;
00084                 $tagOffset = 0;
00085                 $entityOffset = 0;
00086                 $parentNodes = array();
00087                 $currentParent = 0;
00088                 $currentNode = NULL;
00089 
00090                 $xhtmlDocument = <span class="keyword">new</span> DOMDocument(<span class="stringliteral">"1.0"</span>);
00091                 $root = $xhtmlDocument-&gt;createElement('html');
00092                 $root-&gt;setAttribute('xmlns', 'http:<span class="comment">//www.w3.org/1999/xhtml');</span>
00093                 $xhtmlDocument-&gt;appendChild($root);
00094 
00095                 $parentNodes[$currentParent] = $root;
00096 
00097                 <span class="keywordflow">for</span>($i = 0; $i &lt; strlen($document); $i++)
00098                 {
00099                         <span class="comment">// currently reading text</span>
00100                         <span class="keywordflow">if</span>($readingTag == <span class="keyword">false</span>)
00101                         {
00102                                 <span class="comment">// currently reading an entity</span>
00103                                 <span class="keywordflow">if</span>($readingEntity == <span class="keyword">true</span>)
00104                                 {
00105                                         <span class="keywordflow">if</span>($document{$i} == <span class="stringliteral">"#"</span>)
00106                                         {
00107                                                 $numberedEntity = <span class="keyword">true</span>;
00108                                         }
00109                                         elseif($document{$i} == <span class="charliteral">';'</span> || $document{$i} == <span class="charliteral">' '</span> ||
00110                                                $document{$i} == <span class="charliteral">'&lt;'</span> || $document{$i} == <span class="charliteral">'&gt;'</span> ||
00111                                                $document{$i} == <span class="charliteral">'&amp;'</span>)
00112                                         {
00113                                                 <span class="keywordflow">if</span>($currentNode == null)
00114                                                 {
00115                                                         $currentNode = $xhtmlDocument-&gt;createTextNode('');
00116                                                 }
00117 
00118                                                 <span class="keywordflow">if</span>($i - $entityOffset == 1 ||
00119                                                    substr($document, $entityOffset, $i - $entityOffset - 1) == '&amp;amp')
00120                                                 {
00121                                                         $currentNode-&gt;appendData(<span class="charliteral">'&amp;'</span>);
00122                                                 }
00123                                                 elseif($numberedEntity == <span class="keyword">true</span>)
00124                                                 {
00125                                                         $currentNode-&gt;appendData(chr((<span class="keywordtype">int</span>) substr($document, $entityOffset + 2, $i - $entityOffset - 2)));
00126                                                 }
00127                                                 $readingEntity = <span class="keyword">false</span>;
00128                                         }
00129                                 }
00130                                 <span class="keywordflow">else</span>
00131                                 {
00132                                         <span class="comment">// a tag starts</span>
00133                                         <span class="keywordflow">if</span>($document{$i} == <span class="charliteral">'&lt;'</span>)
00134                                         {
00135                                                 <span class="keywordflow">if</span>($currentNode != null)
00136                                                 {
00137                                                         $parentNodes[$currentParent]-&gt;appendChild($currentNode);
00138                                                         $currentNode = null;
00139                                                 }
00140 
00141                                                 $readingTag = <span class="keyword">true</span>;
00142                                                 $tagOffset = $i;
00143                                         }
00144                                         <span class="comment">// an entity starts</span>
00145                                         elseif($document{$i} == <span class="charliteral">'&amp;'</span>)
00146                                         {
00147                                                 $readingEntity = <span class="keyword">true</span>;
00148                                                 $numberedEntity = <span class="keyword">false</span>;
00149                                                 $entityOffset = $i;
00150                                         }
00151                                         <span class="comment">// reading a text node</span>
00152                                         <span class="keywordflow">else</span>
00153                                         {
00154                                                 <span class="keywordflow">if</span>($currentNode == null)
00155                                                 {
00156                                                         $currentNode = $xhtmlDocument-&gt;createTextNode('');
00157                                                 }
00158 
00159                                                 $currentNode-&gt;appendData($document{$i});
00160                                         }
00161                                 }
00162                         }
00163                         <span class="comment">// currently reading comments</span>
00164                         elseif($readingComment == <span class="keyword">true</span>)
00165                         {
00166                                 <span class="keywordflow">if</span>(substr($document, $i - 2, 3) == '--&gt;')
00167                                 {
00168                                         $readingComment = <span class="keyword">false</span>;
00169                                 }
00170                         }
00171                         <span class="comment">// currently reading a tag</span>
00172                         <span class="keywordflow">else</span>
00173                         {
00174                                 <span class="comment">// see if we start reading comments</span>
00175                                 <span class="keywordflow">if</span>($i == $tagOffset + 3 &amp;&amp;
00176                                    substr($document, $tagOffset, 4) == '&lt;!--')
00177                                 {
00178                                         $readingComment = <span class="keyword">true</span>;
00179                                         <span class="keywordflow">continue</span>;
00180                                 }
00181 
00182                                 <span class="comment">// the tag is finished</span>
00183                                 <span class="keywordflow">if</span>($document{$i} == <span class="charliteral">'&gt;'</span>)
00184                                 {
00185                                         $readingTag = <span class="keyword">false</span>;
00186                                         $tag = substr($document, $tagOffset, $i - $tagOffset + 1);
00187                                         preg_match('/^&lt;\s*(\/?\w+).*&gt;$/', $tag, $matches);
00188                                         $tagName = strtolower($matches[1]);
00189 
00190                                         <span class="comment">// ending tag</span>
00191                                         <span class="keywordflow">if</span>(<a class="code" href="a00153.html#e2">String::startsWith</a>($tagName, <span class="charliteral">'/'</span>))
00192                                         {
00193                                                 <span class="keywordflow">if</span>($currentParent &gt; 0 &amp;&amp;
00194                                                    (<a class="code" href="a00153.html#e3">String::endsWith</a>($tagStack, $tagName) || strpos($tagStack, <span class="stringliteral">"$tagName/"</span>) !== <span class="keyword">false</span>))
00195                                                 {
00196                                                         $tagStack = <a class="code" href="a00153.html#e0">String::substringBefore</a>($tagStack, $tagName, <span class="keyword">true</span>);
00197                                                         $currentParent = substr_count($tagStack, <span class="charliteral">'/'</span>) - 1;
00198                                                 }
00199                                                 <span class="keywordflow">if</span>($tagName == '/html')
00200                                                 {
00201                                                         <span class="keywordflow">break</span>;
00202                                                 }
00203                                         }
00204                                         <span class="comment">// starting tag</span>
00205                                         <span class="keywordflow">else</span> <span class="keywordflow">if</span>($tagName != 'html')
00206                                         {
00207                                                 <span class="keywordflow">if</span>(isset(self::$tags[$tagName]) == <span class="keyword">false</span>)
00208                                                 {
00209                                                         <span class="keywordflow">continue</span>;
00210                                                 }
00211 
00212                                                 $tagStruct = self::$tags[$tagName];
00213 
00214                                                 <span class="comment">// check whether the parent tag is valid</span>
00215                                                 <span class="keywordflow">if</span>(in_array(String::substringAfter($tagStack, <span class="charliteral">'/'</span>, <span class="keyword">true</span>),
00216                                                             $tagStruct-&gt;allowedParents) == <span class="keyword">false</span>)
00217                                                 {
00218                                                         $ancestors = array_reverse(explode(<span class="charliteral">'/'</span>, String::substringBefore($tagStack, <span class="charliteral">'/'</span>, <span class="keyword">true</span>)));
00219 
00220                                                         $parentFound = <span class="keyword">false</span>;
00221                                                         $previousAncestor = <a class="code" href="a00153.html#e1">String::substringAfter</a>($tagStack, <span class="charliteral">'/'</span>, <span class="keyword">true</span>);
00222                                                         foreach($ancestors as $ancestor)
00223                                                         {
00224                                                                 <span class="keywordflow">if</span>(in_array($ancestor, $tagStruct-&gt;allowedParents))
00225                                                                 {
00226                                                                         $tagStack = <a class="code" href="a00153.html#e0">String::substringBefore</a>($tagStack, <span class="stringliteral">"/$previousAncestor"</span>, <span class="keyword">true</span>);
00227                                                                         $currentParent = substr_count($tagStack, <span class="charliteral">'/'</span>) - 1;
00228 
00229                                                                         $parentFound = <span class="keyword">true</span>;
00230                                                                 }
00231                                                                 $previousAncestor = $ancestor;
00232                                                         }
00233 
00234                                                         <span class="keywordflow">if</span>($parentFound == <span class="keyword">false</span>)
00235                                                         {
00236                                                                 foreach($tagStruct-&gt;allowedParents as $parent)
00237                                                                 {
00238                                                                         $parentStruct = self::$tags[$parent];
00239                                                                         <span class="keywordflow">if</span>(in_array(String::substringAfter($tagStack, <span class="charliteral">'/'</span>, <span class="keyword">true</span>),
00240                                                                                         $parentStruct-&gt;allowedParents) == <span class="keyword">true</span>)
00241                                                                         {
00242                                                                                 $currentNode = $xhtmlDocument-&gt;createElement($parent);
00243                                                                                 $parentNodes[$currentParent]-&gt;appendChild($currentNode);
00244 
00245                                                                                 $currentParent++;
00246                                                                                 $parentNodes[$currentParent] = $currentNode;
00247                                                                                 $tagStack .= <span class="stringliteral">"/$parent"</span>;
00248 
00249                                                                                 $currentNode = null;
00250                                                                                 $parentFound = <span class="keyword">true</span>;
00251                                                                         }
00252                                                                 }
00253                                                         }
00254 
00255                                                         <span class="keywordflow">if</span>($parentFound == <span class="keyword">false</span>)
00256                                                         {
00257                                                                 <span class="keywordflow">continue</span>;
00258                                                         }
00259                                                 }
00260 
00261                                                 $attributes = array();
00262                                                 <span class="keywordflow">while</span>(preg_match('/^&lt;\s*\/?\w+\s+(\w+=(?:<span class="stringliteral">".*?"</span>|[^<span class="stringliteral">" &gt;]+)).*&gt;$/', $tag, $matches))</span>
00263 <span class="stringliteral">                                                {</span>
00264 <span class="stringliteral">                                                        $attributes[] = $matches[1];</span>
00265 <span class="stringliteral">                                                        $tag = str_replace($matches[1], '', $tag);</span>
00266 <span class="stringliteral">                                                }</span>
00267 <span class="stringliteral"></span>
00268 <span class="stringliteral">                                                $currentNode = $xhtmlDocument-&gt;createElement($tagName);</span>
00269 <span class="stringliteral"></span>
00270 <span class="stringliteral">                                                $attributeKeys = array();</span>
00271 <span class="stringliteral">                                                foreach($attributes as $attribute)</span>
00272 <span class="stringliteral">                                                {</span>
00273 <span class="stringliteral">                                                        $key = strtolower(String::substringBefore($attribute, '='));</span>
00274 <span class="stringliteral">                                                        $value = String::substringAfter($attribute, '=');</span>
00275 <span class="stringliteral">                                                        $attributeKeys[] = $key;</span>
00276 <span class="stringliteral"></span>
00277 <span class="stringliteral">                                                        if(in_array($key, $tagStruct-&gt;attributes) == false &amp;&amp;</span>
00278 <span class="stringliteral">                                                                in_array($key, $tagStruct-&gt;requiredAttributes) == false)</span>
00279 <span class="stringliteral">                                                        {</span>
00280 <span class="stringliteral">                                                                continue;</span>
00281 <span class="stringliteral">                                                        }</span>
00282 <span class="stringliteral"></span>
00283 <span class="stringliteral">                                                        if($value{0} == '"</span>')
00284                                                         {
00285                                                                 $value = substr($value, 1);
00286                                                         }
00287                                                         <span class="keywordflow">if</span>(substr($value, -1) == <span class="charliteral">'"'</span>)
00288                                                         {
00289                                                                 $value = substr($value, 0, strlen($value) - 1);
00290                                                         }
00291 
00292                                                         $currentNode-&gt;setAttribute($key, $value);
00293                                                 }
00294                                                 foreach($tagStruct-&gt;requiredAttributes as $key)
00295                                                 {
00296                                                         <span class="keywordflow">if</span>(in_array($key, $attributeKeys) == <span class="keyword">false</span>)
00297                                                         {
00298                                                                 $currentNode-&gt;setAttribute($key, '');
00299                                                         }
00300                                                 }
00301 
00302                                                 $parentNodes[$currentParent]-&gt;appendChild($currentNode);
00303 
00304                                                 <span class="keywordflow">if</span>($tagStruct-&gt;single == <span class="keyword">false</span>)
00305                                                 {
00306                                                         $currentParent++;
00307                                                         $parentNodes[$currentParent] = $currentNode;
00308                                                         $tagStack .= <span class="stringliteral">"/$tagName"</span>;
00309                                                 }
00310 
00311                                                 $currentNode = null;
00312                                         }
00313                                 }
00314                         }
00315                 }
00316 
00317                 <span class="keywordflow">return</span> $xhtmlDocument;
00318         }
00319 
00326         <span class="keyword">public</span> <span class="keyword">static</span> function html2Xhtml($document)
00327         {
00328                 $xhtmlDocument = self::html2XhtmlDocument($document, $root);
00329 
00330                 <span class="keywordflow">return</span> self::doctype().<span class="stringliteral">"\n"</span>.
00331                        $xhtmlDocument-&gt;saveXML($root).<span class="stringliteral">"\n"</span>;
00332         }
00333 
00334         <span class="keyword">private</span> <span class="keyword">static</span> function initializeTags()
00335         {
00336                 <span class="keywordflow">if</span>(isset(self::$tags))
00337                 {
00338                         <span class="keywordflow">return</span>;
00339                 }
00340 
00341                 self::$tags['html']  = <span class="keyword">new</span> XHTMLTag('html',  <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>);
00342 
00343                 self::$tags['head']  = <span class="keyword">new</span> XHTMLTag('head',  <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">false</span>, array('style'),                       array('html'));
00344                 self::$tags['title'] = <span class="keyword">new</span> XHTMLTag('title', <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('head'));
00345                 self::$tags['link']  = <span class="keyword">new</span> XHTMLTag('link',  <span class="keyword">true</span>,  <span class="keyword">true</span>,  <span class="keyword">false</span>, array('style', 'href', 'rel', 'type'),array('head'));
00346                 self::$tags['meta']  = <span class="keyword">new</span> XHTMLTag('meta',  <span class="keyword">true</span>,  <span class="keyword">true</span>,  <span class="keyword">false</span>, array('style', 'http-equiv', 'name'), array('head'), array('content'));
00347 
00348                 self::$tags['body']  = <span class="keyword">new</span> XHTMLTag('body',  <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'), array('html'));
00349                 self::$tags['h1']    = <span class="keyword">new</span> XHTMLTag('h1',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div'));
00350                 self::$tags['h2']    = <span class="keyword">new</span> XHTMLTag('h2',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div'));
00351                 self::$tags['h3']    = <span class="keyword">new</span> XHTMLTag('h3',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div'));
00352                 self::$tags['h4']    = <span class="keyword">new</span> XHTMLTag('h4',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div'));
00353                 self::$tags['h5']    = <span class="keyword">new</span> XHTMLTag('h5',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div'));
00354                 self::$tags['h6']    = <span class="keyword">new</span> XHTMLTag('h6',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div'));
00355                 self::$tags[<span class="charliteral">'p'</span>]     = <span class="keyword">new</span> XHTMLTag(<span class="charliteral">'p'</span>,     <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div'));
00356                 self::$tags[<span class="charliteral">'a'</span>]     = <span class="keyword">new</span> XHTMLTag(<span class="charliteral">'a'</span>,     <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style', 'href', 'name'),       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>,      'span', 'strong', 'em'));
00357                 self::$tags['div']   = <span class="keyword">new</span> XHTMLTag('div',   <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>, <span class="charliteral">'a'</span>, 'span', 'strong', 'em'));
00358                 self::$tags['span']  = <span class="keyword">new</span> XHTMLTag('span',  <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>, <span class="charliteral">'a'</span>, 'span', 'strong', 'em'));
00359                 self::$tags['strong']= <span class="keyword">new</span> XHTMLTag('strong',<span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>, <span class="charliteral">'a'</span>, 'span', 'strong', 'em'));
00360                 self::$tags['em']    = <span class="keyword">new</span> XHTMLTag('em',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>, <span class="charliteral">'a'</span>, 'span', 'strong', 'em'));
00361                 self::$tags['br']    = <span class="keyword">new</span> XHTMLTag('br',    <span class="keyword">true</span>,  <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>, <span class="charliteral">'a'</span>, 'span', 'strong', 'em'));
00362                 self::$tags['hr']    = <span class="keyword">new</span> XHTMLTag('hr',    <span class="keyword">true</span>,  <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>, <span class="charliteral">'a'</span>, 'span', 'strong', 'em'));
00363                 self::$tags['img']   = <span class="keyword">new</span> XHTMLTag('img',   <span class="keyword">true</span>,  <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>, <span class="charliteral">'a'</span>, 'span', 'strong', 'em'), array('src', 'alt'));
00364                 self::$tags['table'] = <span class="keyword">new</span> XHTMLTag('table', <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>,      'span', 'strong', 'em'));
00365                 self::$tags['thead'] = <span class="keyword">new</span> XHTMLTag('thead', <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('table'));
00366                 self::$tags['tbody'] = <span class="keyword">new</span> XHTMLTag('tbody', <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('table'));
00367                 self::$tags['tfoot'] = <span class="keyword">new</span> XHTMLTag('tfoot', <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('table'));
00368                 self::$tags['tr']    = <span class="keyword">new</span> XHTMLTag('tr',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('table', 'thead', 'tbody', 'tfoot'));
00369                 self::$tags['td']    = <span class="keyword">new</span> XHTMLTag('td',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style', 'colspan', 'rowspan'), array('tr'));
00370                 self::$tags['ol']    = <span class="keyword">new</span> XHTMLTag('ol',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>,      'span', 'strong', 'em'));
00371                 self::$tags['ul']    = <span class="keyword">new</span> XHTMLTag('ul',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('body', 'td', 'li', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', <span class="charliteral">'p'</span>,      'span', 'strong', 'em'));
00372                 self::$tags['li']    = <span class="keyword">new</span> XHTMLTag('li',    <span class="keyword">false</span>, <span class="keyword">true</span>,  <span class="keyword">true</span>,  array('style'),                       array('ul', 'ol'));
00373 
00374                 self::$tags[<span class="charliteral">'b'</span>] = self::$tags['strong'];
00375                 self::$tags[<span class="charliteral">'i'</span>] = self::$tags['em'];
00376 
00377                 <span class="comment">//self::$tags['script']= new XHTMLTag('script',false, false, false, array(), array('head'));</span>
00378                 <span class="comment">//self::$tags['style'] = new XHTMLTag('style', false, false, false, array(), array('head'));</span>
00379         }
00380 
00381         <span class="keyword">private</span> <span class="keyword">static</span> $tags;
00382 }
00383 
<a name="l00392"></a><a class="code" href="a00112.html">00392</a> <span class="keyword">class </span><a class="code" href="a00112.html">HTMLWidget</a> <span class="keyword">extends</span> <a class="code" href="a00142.html">RawWidget</a>
00393 {
<a name="l00400"></a><a class="code" href="a00112.html#a0">00400</a>         <span class="keyword">public</span> function <a class="code" href="a00112.html#a0">__construct</a>(<a class="code" href="a00096.html">Container</a> $parent, $contents)
00401         {
00402                 $domDocument = <a class="code" href="a00169.html#e1">XHTML::html2XhtmlDocument</a>(<span class="stringliteral">"&lt;html&gt;&lt;body&gt;$contents&lt;/body&gt;&lt;/html&gt;"</span>);
00403 
00404                 $xPath = <span class="keyword">new</span> DOMXPath($domDocument);
00405 
00406                 $nodeList = $xPath-&gt;query('/html/body');
00407 
00408                 $html = substr($domDocument-&gt;saveXML($nodeList-&gt;item(0)), 6, -7);
00409 
00410                 parent::__construct($parent, <span class="stringliteral">"&lt;htmlblock xmlns=\"http://www.w3.org/1999/xhtml\"&gt;&lt;span&gt;$html&lt;/span&gt;&lt;/htmlblock&gt;"</span>);
00411         }
00412 }
00413 
00414 ?&gt;
</pre></div>    </div>
  </body>
</html>
Return current item: Aukyla Document Management System