Location: PHPKode > projects > Aukyla Platform > aukyla/doc/html/a00236.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>Tables.php</h1><div class="fragment"><pre class="fragment">00001 &lt;?php
00002 <span class="comment">/*</span>
00003 <span class="comment">     Tables.php, provides functions for building tables</span>
00004 <span class="comment">     Copyright (C) 2004 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('Widgets.php');
00024 
<a name="l00028"></a><a class="code" href="a00155.html">00028</a> <span class="keyword">class </span><a class="code" href="a00155.html">Table</a> <span class="keyword">extends</span> <a class="code" href="a00096.html">Container</a>
00029 {
<a name="l00035"></a><a class="code" href="a00155.html#a0">00035</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a0">__construct</a>(<a class="code" href="a00096.html">Container</a> $parent)
00036         {
00037                 parent::__construct($parent);
00038 
00039                 $this-&gt;<a class="code" href="a00155.html#a7">width</a> = 0;
00040                 $this-&gt;header = <span class="keyword">false</span>;
00041                 $this-&gt;footer = <span class="keyword">false</span>;
00042                 $this-&gt;<a class="code" href="a00155.html#a8">lastRow</a> = <span class="keyword">false</span>;
00043         }
00044 
<a name="l00055"></a><a class="code" href="a00155.html#a1">00055</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a1">setRowsAlternate</a>($rowsAlternate)
00056         {
00057                 $this-&gt;<a class="code" href="a00155.html#a2">rowsAlternate</a> = $rowsAlternate;
00058         }
00059 
<a name="l00067"></a><a class="code" href="a00155.html#a2">00067</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a2">rowsAlternate</a>()
00068         {
00069                 <span class="keywordflow">return</span> $this-&gt;rowsAlternate;
00070         }
00071 
<a name="l00082"></a><a class="code" href="a00155.html#a3">00082</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a3">setColumnsAlternate</a>($columnsAlternate)
00083         {
00084                 $this-&gt;<a class="code" href="a00155.html#a4">columnsAlternate</a> = $columnsAlternate;
00085         }
00086 
<a name="l00094"></a><a class="code" href="a00155.html#a4">00094</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a4">columnsAlternate</a>()
00095         {
00096                 <span class="keywordflow">return</span> $this-&gt;columnsAlternate;
00097         }
00098 
<a name="l00109"></a><a class="code" href="a00155.html#a5">00109</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a5">addWidget</a>(<a class="code" href="a00157.html">TableRow</a> $widget)
00110         {
00111                 parent::addWidget($widget);
00112                 $this-&gt;<a class="code" href="a00155.html#a8">lastRow</a> = $widget;
00113         }
00114 
<a name="l00122"></a><a class="code" href="a00155.html#a6">00122</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a6">setWidth</a>($width)
00123         {
00124                 $this-&gt;<a class="code" href="a00155.html#a7">width</a> = $width;
00125         }
00126 
<a name="l00132"></a><a class="code" href="a00155.html#a7">00132</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a7">width</a>()
00133         {
00134                 <span class="keywordflow">return</span> $this-&gt;width;
00135         }
00136 
<a name="l00143"></a><a class="code" href="a00155.html#a8">00143</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a8">lastRow</a>()
00144         {
00145                 <span class="keywordflow">return</span> $this-&gt;lastRow;
00146         }
00147 
<a name="l00156"></a><a class="code" href="a00155.html#a9">00156</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a9">cell</a>($row, $column)
00157         {
00158                 <span class="keywordflow">return</span> $this-&gt;children[$row]-&gt;cell($column);
00159         }
00160 
<a name="l00164"></a><a class="code" href="a00155.html#a10">00164</a>         <span class="keyword">public</span> function <a class="code" href="a00155.html#a10">show</a>()
00165         {
00166                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;table'.$this-&gt;parentProperties().<span class="charliteral">'&gt;'</span>);
00167 
00168                 foreach($this-&gt;children as $child)
00169                 {
00170                         <span class="keywordflow">if</span>($child-&gt;width() &gt; $this-&gt;width)
00171                         {
00172                                 $this-&gt;<a class="code" href="a00155.html#a7">width</a> = $child-&gt;width();
00173                         }
00174                 }
00175 
00176                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;columns&gt;');
00177                 <span class="keywordflow">for</span>($i = 0; $i &lt; $this-&gt;width; $i++)
00178                 {
00179                         <a class="code" href="a00134.html#e5">Output::write</a>('&lt;column/&gt;');
00180                 }
00181                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;/columns&gt;'.
00182                               '&lt;rows&gt;');
00183                 $i = 0;
00184                 foreach($this-&gt;children as $child)
00185                 {
00186                         <span class="keywordflow">if</span>($this-&gt;rowsAlternate)
00187                         {
00188                                 $alternate = (($i = ($i + 1) % 2) == 0);
00189                         }
00190                         <span class="keywordflow">else</span>
00191                         {
00192                                 $alternate = <span class="keyword">false</span>;
00193                         }
00194 
00195                         $child-&gt;show($alternate, $this-&gt;columnsAlternate);
00196                 }
00197                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;/rows&gt;'.
00198                               '&lt;/table&gt;');
00199         }
00200 
00201         <span class="keyword">private</span> $width;
00202         <span class="keyword">private</span> $rowsAlternate;
00203         <span class="keyword">private</span> $columnsAlternate;
00204         <span class="keyword">private</span> $header;
00205         <span class="keyword">private</span> $footer;
00206         <span class="keyword">private</span> $lastRow;
00207 }
00208 
<a name="l00212"></a><a class="code" href="a00157.html">00212</a> <span class="keyword">class </span><a class="code" href="a00157.html">TableRow</a> <span class="keyword">extends</span> <a class="code" href="a00096.html">Container</a>
00213 {
<a name="l00219"></a><a class="code" href="a00157.html#a0">00219</a>         <span class="keyword">public</span> function <a class="code" href="a00157.html#a0">__construct</a>(<a class="code" href="a00155.html">Table</a> $parent)
00220         {
00221                 $previousRow = <a class="code" href="a00157.html#p2">$parent</a>-&gt;lastRow();
00222 
00223                 parent::__construct($parent);
00224 
00225                 <span class="keywordflow">if</span>($previousRow !== <span class="keyword">false</span>)
00226                 {
00227                         $rowSpans = $previousRow-&gt;rowSpans();
00228                         $this-&gt;<a class="code" href="a00157.html#a2">width</a> = <span class="keyword">sizeof</span>($rowSpans);
00229                         <span class="keywordflow">for</span>($i = 0; $i &lt; $this-&gt;width; $i++)
00230                         {
00231                                 $rowSpans[$i]--;
00232                                 <span class="keywordflow">if</span>($rowSpans[$i] == 0)
00233                                 {
00234                                         unset($rowSpans[$i]);
00235                                 }
00236                         }
00237                         $this-&gt;rowSpans = $rowSpans;
00238                 }
00239                 <span class="keywordflow">else</span>
00240                 {
00241                         $this-&gt;<a class="code" href="a00157.html#a2">width</a> = 0;
00242                         $this-&gt;rowSpans = array();
00243                 }
00244         }
00245 
<a name="l00246"></a><a class="code" href="a00157.html#a1">00246</a>         <span class="keyword">public</span> function <a class="code" href="a00157.html#a1">addWidget</a>(<a class="code" href="a00166.html">Widget</a> $widget)
00247         {
00248                 <span class="keywordflow">if</span>(!is_a($widget, '<a class="code" href="a00156.html">TableCell</a>'))
00249                 {
00250                         die('Can only add <a class="code" href="a00156.html">TableCell</a> to a <a class="code" href="a00157.html">TableRow</a>.');
00251                 }
00252 
00253                 parent::addWidget($widget);
00254                 $this-&gt;<a class="code" href="a00157.html#a2">width</a> += $widget-&gt;columnSpan();
00255                 <span class="keywordflow">if</span>($widget-&gt;rowSpan() &gt; 1)
00256                 {
00257                         $this-&gt;rowSpans[] = $widget-&gt;rowSpan() - 1;
00258                 }
00259         }
00260 
<a name="l00266"></a><a class="code" href="a00157.html#a2">00266</a>         <span class="keyword">public</span> function <a class="code" href="a00157.html#a2">width</a>()
00267         {
00268                 <span class="keywordflow">return</span> $this-&gt;width;
00269         }
00270 
<a name="l00277"></a><a class="code" href="a00157.html#a3">00277</a>         <span class="keyword">public</span> function <a class="code" href="a00157.html#a3">cell</a>($n)
00278         {
00279                 <span class="keywordflow">return</span> $this-&gt;children[$n];
00280         }
00281 
<a name="l00290"></a><a class="code" href="a00157.html#a4">00290</a>         <span class="keyword">public</span> function <a class="code" href="a00096.html#a2">show</a>($alternate = <span class="keyword">false</span>, $columnsAlternate = <span class="keyword">false</span>)
00291         {
00292                 <span class="keywordflow">if</span>($this-&gt;cssClass == '' &amp;&amp; $alternate)
00293                 {
00294                         $this-&gt;<a class="code" href="a00166.html#a7">setCssClass</a>('alternate');
00295                 }
00296 
00297                 $this-&gt;<a class="code" href="a00157.html#b0">showMissingColumns</a>();
00298 
00299                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;row'.$this-&gt;parentProperties().<span class="charliteral">'&gt;'</span>);
00300                 $i = 0;
00301                 foreach($this-&gt;children as $child)
00302                 {
00303                         $alternate = ($columnsAlternate ? (($i = ($i + 1) % 2) == 0) : <span class="keyword">false</span>);
00304 
00305                         $child-&gt;show($alternate);
00306                 }
00307                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;/row&gt;');
00308         }
00309 
00313         <span class="keyword">public</span> function adjustColumnSpan($adjustment)
00314         {
00315                 $this-&gt;width += $adjustment;
00316         }
00317 
<a name="l00321"></a><a class="code" href="a00157.html#b0">00321</a>         <span class="keyword">protected</span> function <a class="code" href="a00157.html#b0">showMissingColumns</a>()
00322         {
00323                 <span class="keywordflow">if</span>($this-&gt;<a class="code" href="a00157.html#a2">width</a> &lt; $this-&gt;parent-&gt;width())
00324                 {
00325                         $missingColumns = $this-&gt;parent-&gt;width() - $this-&gt;width;
00326                         <span class="keywordflow">while</span>($missingColumns &gt; 0)
00327                         {
00328                                 <span class="keyword">new</span> <a class="code" href="a00156.html">TableCell</a>($<span class="keyword">this</span>);
00329                                 $missingColumns--;
00330                         }
00331                 }
00332         }
00333 
00337         <span class="keyword">private</span> function rowSpans()
00338         {
00339                 <span class="keywordflow">return</span> $this-&gt;rowSpans;
00340         }
00341 
<a name="l00342"></a><a class="code" href="a00157.html#p0">00342</a>         <span class="keyword">protected</span> $children;
<a name="l00343"></a><a class="code" href="a00157.html#p1">00343</a>         <span class="keyword">protected</span> $cssClass;
<a name="l00344"></a><a class="code" href="a00157.html#p2">00344</a>         <span class="keyword">protected</span> $parent;
00345 
<a name="l00349"></a><a class="code" href="a00157.html#p3">00349</a>         <span class="keyword">protected</span> $width;
00350         <span class="keyword">private</span> $rowSpans;
00351 }
00352 
<a name="l00356"></a><a class="code" href="a00156.html">00356</a> <span class="keyword">class </span><a class="code" href="a00156.html">TableCell</a> <span class="keyword">extends</span> <a class="code" href="a00141.html">RawContainer</a>
00357 {
<a name="l00364"></a><a class="code" href="a00156.html#a0">00364</a>         <span class="keyword">public</span> function <a class="code" href="a00156.html#a0">__construct</a>(<a class="code" href="a00157.html">TableRow</a> $parent, $text = '')
00365         {
00366                 $this-&gt;colspan = 1;
00367                 $this-&gt;rowspan = 1;
00368 
00369                 parent::__construct($parent, $text);
00370         }
00371 
<a name="l00377"></a><a class="code" href="a00156.html#a1">00377</a>         <span class="keyword">public</span> function <a class="code" href="a00156.html#a1">setColumnSpan</a>($columnSpan)
00378         {
00379                 $this-&gt;parent-&gt;adjustColumnSpan($<a class="code" href="a00156.html#a2">columnSpan</a> - $this-&gt;colspan);
00380 
00381                 $this-&gt;colspan = $columnSpan;
00382         }
00383 
<a name="l00389"></a><a class="code" href="a00156.html#a2">00389</a>         <span class="keyword">public</span> function <a class="code" href="a00156.html#a2">columnSpan</a>()
00390         {
00391                 <span class="keywordflow">return</span> $this-&gt;colspan;
00392         }
00393 
<a name="l00399"></a><a class="code" href="a00156.html#a3">00399</a>         <span class="keyword">public</span> function <a class="code" href="a00156.html#a3">setRowSpan</a>($rowSpan)
00400         {
00401                 $this-&gt;rowspan = $rowSpan;
00402         }
00403 
<a name="l00409"></a><a class="code" href="a00156.html#a4">00409</a>         <span class="keyword">public</span> function <a class="code" href="a00156.html#a4">rowSpan</a>()
00410         {
00411                 <span class="keywordflow">return</span> $this-&gt;rowspan;
00412         }
00413 
<a name="l00417"></a><a class="code" href="a00156.html#a5">00417</a>         <span class="keyword">public</span> function <a class="code" href="a00141.html#a2">show</a>($alternate = <span class="keyword">false</span>)
00418         {
00419                 <span class="keywordflow">if</span>($this-&gt;cssClass == '' &amp;&amp; $alternate)
00420                 {
00421                         $this-&gt;<a class="code" href="a00166.html#a7">setCssClass</a>('alternate');
00422                 }
00423 
00424                 $colspanProperty = ($this-&gt;colspan == <span class="charliteral">'1'</span> ? '' : <span class="stringliteral">" columnspan=\"{$this-&gt;colspan}\""</span>);
00425                 $rowspanProperty = ($this-&gt;rowspan == <span class="charliteral">'1'</span> ? '' : <span class="stringliteral">" rowspan=\"{$this-&gt;rowspan}\""</span>);
00426 
00427                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;cell'.$this-&gt;parentProperties().<span class="stringliteral">"$colspanProperty$rowspanProperty&gt;"</span>);
00428                 parent::show();
00429                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;/cell&gt;');
00430         }
00431 
<a name="l00432"></a><a class="code" href="a00156.html#p0">00432</a>         <span class="keyword">protected</span> $cssClass;
<a name="l00433"></a><a class="code" href="a00156.html#p1">00433</a>         <span class="keyword">protected</span> $parent;
00434 
00435         <span class="keyword">private</span> $colspan;
00436         <span class="keyword">private</span> $rowspan;
00437 }
00438 
<a name="l00454"></a><a class="code" href="a00108.html">00454</a> <span class="keyword">class </span><a class="code" href="a00108.html">GridLayout</a> <span class="keyword">extends</span> <a class="code" href="a00155.html">Table</a>
00455 {
<a name="l00462"></a><a class="code" href="a00108.html#a0">00462</a>         <span class="keyword">public</span> function <a class="code" href="a00108.html#a0">__construct</a>(<a class="code" href="a00096.html">Container</a> $parent, $columns)
00463         {
00464                 parent::__construct($parent);
00465 
00466                 $this-&gt;columns = $columns;
00467                 $this-&gt;currentColumn = $columns;
00468                 $this-&gt;columnWidths = array();
00469                 $this-&gt;<a class="code" href="a00166.html#a9">addCssStyle</a>('border: 0px');
00470         }
00471 
<a name="l00489"></a><a class="code" href="a00108.html#a1">00489</a>         <span class="keyword">public</span> function <a class="code" href="a00108.html#a1">setColumnWidths</a>($widths)
00490         {
00491                 $this-&gt;columnWidths = $widths;
00492         }
00493 
<a name="l00494"></a><a class="code" href="a00108.html#a2">00494</a>         <span class="keyword">public</span> function <a class="code" href="a00108.html#a2">addWidget</a>(<a class="code" href="a00166.html">Widget</a> $widget)
00495         {
00496                 <span class="keywordflow">if</span>(is_a($widget, '<a class="code" href="a00157.html">TableRow</a>'))
00497                 {
00498                         parent::addWidget($widget);
00499                 }
00500                 <span class="keywordflow">else</span>
00501                 {
00502                         <span class="keywordflow">if</span>($this-&gt;currentColumn &gt;= $this-&gt;columns)
00503                         {
00504                                 $this-&gt;currentRow = <span class="keyword">new</span> <a class="code" href="a00157.html">TableRow</a>($<span class="keyword">this</span>);
00505                                 $this-&gt;currentColumn = 0;
00506                         }
00507 
00508                         $cell = <span class="keyword">new</span> <a class="code" href="a00156.html">TableCell</a>($this-&gt;currentRow);
00509                         $cell-&gt;addWidget($widget);
00510                         <span class="keywordflow">if</span>(isset($this-&gt;columnWidths[$this-&gt;currentColumn]))
00511                         {
00512                                 $cell-&gt;addCssStyle(<span class="stringliteral">"width: {$this-&gt;columnWidths[$this-&gt;currentColumn]}"</span>);
00513                         }
00514 
00515                         $this-&gt;currentColumn++;
00516                 }
00517         }
00518 
00519         <span class="keyword">private</span> $columns;
00520         <span class="keyword">private</span> $currentColumn;
00521         <span class="keyword">private</span> $currentRow;
00522         <span class="keyword">private</span> $columnWidths;
00523 }
00524 
00525 ?&gt;
</pre></div>    </div>
  </body>
</html>
Return current item: Aukyla Platform