Location: PHPKode > projects > Aukyla Platform > doc/html/a00223.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>Menus.php</h1><div class="fragment"><pre class="fragment">00001 &lt;?php
00002 <span class="comment">/*</span>
00003 <span class="comment">     Menu.php, module which adds a simple menu</span>
00004 <span class="comment">     Copyright (C) 2003 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('GUI.php');
00024 require_once('<a class="code" href="a00115.html">JavaScript</a>.php');
00025 require_once('<a class="code" href="a00134.html">Output</a>.php');
00026 require_once('Widgets.php');
00027 
<a name="l00033"></a><a class="code" href="a00126.html">00033</a> <span class="keyword">class </span><a class="code" href="a00126.html">Menu</a> <span class="keyword">extends</span> <a class="code" href="a00096.html">Container</a>
00034 {
<a name="l00035"></a><a class="code" href="a00126.html#a0">00035</a>         <span class="keyword">public</span> function <a class="code" href="a00126.html#a0">__construct</a>(<a class="code" href="a00096.html">Container</a> $parent, $<span class="keywordtype">id</span> = '')
00036         {
00037                 parent::__construct($parent, $<span class="keywordtype">id</span>);
00038                 <a class="code" href="a00125.html#e0">MainWindow::instance</a>()-&gt;registerMenu($<span class="keyword">this</span>);
00039 
00040                 $this-&gt;sorted = <span class="keyword">true</span>;
00041         }
00042 
<a name="l00046"></a><a class="code" href="a00126.html#a1">00046</a>         <span class="keyword">public</span> function <a class="code" href="a00126.html#a1">addWidget</a>(<a class="code" href="a00127.html">MenuEntry</a> $widget)
00047         {
00048                 parent::addWidget($widget);
00049                 $this-&gt;sorted = <span class="keyword">false</span>;
00050         }
00051 
<a name="l00058"></a><a class="code" href="a00126.html#a2">00058</a>         <span class="keyword">public</span> function <a class="code" href="a00126.html#a2">show</a>()
00059         {
00060                 $this-&gt;sortEntries();
00061 
00062                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;menu'.$this-&gt;parentProperties().<span class="charliteral">'&gt;'</span>);
00063                 parent::show();
00064                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;/menu&gt;');
00065         }
00066 
00067         <span class="comment">// sorts the entries before showing them</span>
00068         <span class="keyword">private</span> function sortEntries()
00069         {
00070                 <span class="keywordflow">if</span>($this-&gt;sorted == <span class="keyword">true</span>)
00071                 {
00072                         <span class="keywordflow">return</span>;
00073                 }
00074 
00075                 <span class="comment">// bubble sort 'm (this is not very time critical)</span>
00076                 <span class="keywordflow">for</span>($i = 1; $i &lt; <span class="keyword">sizeof</span>($this-&gt;children); $i++)
00077                 {
00078                         <span class="keywordflow">if</span>($this-&gt;children[$i]-&gt;priority() &gt; $this-&gt;children[$i - 1]-&gt;priority())
00079                         {
00080                                 $tmp = $this-&gt;children[$i];
00081                                 $this-&gt;children[$i] = $this-&gt;children[$i - 1];
00082                                 $this-&gt;children[$i - 1] = $tmp;
00083                                 <span class="keywordflow">if</span>($i &gt; 1)
00084                                 {
00085                                         $i -= 2;
00086                                 }
00087                         }
00088                 }
00089 
00090                 $this-&gt;sorted = <span class="keyword">true</span>;
00091         }
00092 
<a name="l00093"></a><a class="code" href="a00126.html#p0">00093</a>         <span class="keyword">protected</span> $children;
<a name="l00094"></a><a class="code" href="a00126.html#p1">00094</a>         <span class="keyword">protected</span> $id;
00095 
00096         <span class="keyword">private</span> $sorted;
00097 }
00098 
<a name="l00102"></a><a class="code" href="a00127.html">00102</a> <span class="keyword">class </span><a class="code" href="a00127.html">MenuEntry</a> <span class="keyword">extends</span> <a class="code" href="a00141.html">RawContainer</a>
00103 {
<a name="l00110"></a><a class="code" href="a00127.html#a0">00110</a>         <span class="keyword">public</span> function <a class="code" href="a00127.html#a0">__construct</a>($parent, $text = '')
00111         {
00112                 <span class="keywordflow">if</span>(!is_a($parent, '<a class="code" href="a00126.html">Menu</a>') &amp;&amp; !is_a($parent, '<a class="code" href="a00154.html">SubMenu</a>'))
00113                 {
00114                         die('Can only add a <a class="code" href="a00127.html">MenuEntry</a> to a <a class="code" href="a00126.html">Menu</a> or <a class="code" href="a00154.html">SubMenu</a>!');
00115                 }
00116 
00117                 parent::__construct($parent);
00118 
00119                 $this-&gt;<a class="code" href="a00166.html#a7">setCssClass</a>('entry');
00120                 $this-&gt;<a class="code" href="a00141.html#a1">setText</a>($text);
00121 
00122                 $this-&gt;link = '';
00123                 $this-&gt;<a class="code" href="a00127.html#a3">priority</a> = 0;
00124         }
00125 
<a name="l00131"></a><a class="code" href="a00127.html#a1">00131</a>         <span class="keyword">public</span> function <a class="code" href="a00127.html#a1">setLink</a>($link)
00132         {
00133                 $this-&gt;link = $link;
00134         }
00135 
<a name="l00146"></a><a class="code" href="a00127.html#a2">00146</a>         <span class="keyword">public</span> function <a class="code" href="a00127.html#a2">setPriority</a>($priority)
00147         {
00148                 $this-&gt;<a class="code" href="a00127.html#a3">priority</a> = $priority;
00149         }
00150 
<a name="l00158"></a><a class="code" href="a00127.html#a3">00158</a>         <span class="keyword">public</span> function <a class="code" href="a00127.html#a3">priority</a>()
00159         {
00160                 <span class="keywordflow">return</span> $this-&gt;priority;
00161         }
00162 
<a name="l00163"></a><a class="code" href="a00127.html#a4">00163</a>         <span class="keyword">public</span> function <a class="code" href="a00127.html#a4">show</a>()
00164         {
00165                 $hrefProperty = ($this-&gt;link != '' ? <span class="stringliteral">" href=\"{$this-&gt;link}\""</span> : '');
00166 
00167                 <a class="code" href="a00134.html#e5">Output::write</a>(<span class="stringliteral">"&lt;menuitem label=\"{$this-&gt;text}\"$hrefProperty"</span>.$this-&gt;parentProperties().<span class="charliteral">'&gt;'</span>);
00168                 <a class="code" href="a00096.html#a2">Container::show</a>();
00169                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;/menuitem&gt;');
00170         }
00171 
<a name="l00172"></a><a class="code" href="a00127.html#p0">00172</a>         <span class="keyword">protected</span> $cssClass;
<a name="l00173"></a><a class="code" href="a00127.html#p1">00173</a>         <span class="keyword">protected</span> $cssStyle;
<a name="l00174"></a><a class="code" href="a00127.html#p2">00174</a>         <span class="keyword">protected</span> $text;
00175 
00176         <span class="keyword">private</span> $link;
00177         <span class="keyword">private</span> $priority;
00178 }
00179 
<a name="l00183"></a><a class="code" href="a00128.html">00183</a> <span class="keyword">class </span><a class="code" href="a00128.html">MenuHead</a> <span class="keyword">extends</span> <a class="code" href="a00127.html">MenuEntry</a>
00184 {
<a name="l00185"></a><a class="code" href="a00128.html#a0">00185</a>         <span class="keyword">public</span> function <a class="code" href="a00128.html#a0">__construct</a>($parent, $text = '')
00186         {
00187                 parent::__construct($parent, $text);
00188 
00189                 $this-&gt;<a class="code" href="a00166.html#a7">setCssClass</a>('head');
00190         }
00191 }
00192 
<a name="l00201"></a><a class="code" href="a00154.html">00201</a> <span class="keyword">class </span><a class="code" href="a00154.html">SubMenu</a> <span class="keyword">extends</span> <a class="code" href="a00127.html">MenuEntry</a>
00202 {
<a name="l00206"></a><a class="code" href="a00154.html#a0">00206</a>         <span class="keyword">public</span> function <a class="code" href="a00154.html#a0">__construct</a>($parent, $<span class="keywordtype">id</span>)
00207         {
00208                 parent::__construct($parent);
00209 
00210                 $parent-&gt;setCssClass('aukyla-menu-system');
00211                 $this-&gt;<a class="code" href="a00166.html#a7">setCssClass</a>('submenu');
00212 
00213                 <span class="keywordflow">if</span>($this-&gt;subMenuUsed == <span class="keyword">false</span>)
00214                 {
00215                         $mainWindow = <a class="code" href="a00125.html#e0">MainWindow::instance</a>();
00216                         $mainWindow-&gt;addStylesheet('resources/base/Menus/cssjsmenudhtml.css');
00217                         $mainWindow-&gt;addStylesheet('resources/base/Menus/cssjsmenuhover.css');
00218                 }
00219 
00220                 $this-&gt;subMenuUsed = <span class="keyword">true</span>;
00221 
00222                 $this-&gt;setId($<span class="keywordtype">id</span>);
00223         }
00224 
<a name="l00230"></a><a class="code" href="a00154.html#a1">00230</a>         <span class="keyword">public</span> function <a class="code" href="a00154.html#a1">setLink</a>($link)
00231         {
00232                 $this-&gt;link = $link;
00233         }
00234 
<a name="l00235"></a><a class="code" href="a00154.html#a2">00235</a>         <span class="keyword">public</span> function <a class="code" href="a00154.html#a2">show</a>()
00236         {
00237                 <a class="code" href="a00134.html#e5">Output::write</a>(<span class="stringliteral">"&lt;submenu href=\"{$this-&gt;link}\" label=\"{$this-&gt;text}\""</span>.$this-&gt;parentProperties().<span class="charliteral">'&gt;'</span>);
00238                 <a class="code" href="a00096.html#a2">Container::show</a>();
00239                 <a class="code" href="a00134.html#e5">Output::write</a>('&lt;/submenu&gt;');
00240         }
00241 
<a name="l00242"></a><a class="code" href="a00154.html#p0">00242</a>         <span class="keyword">protected</span> $children;
<a name="l00243"></a><a class="code" href="a00154.html#p1">00243</a>         <span class="keyword">protected</span> $text;
00244 
00245         <span class="keyword">private</span> $link;
00246         <span class="keyword">private</span> <span class="keyword">static</span> $subMenuUsed = <span class="keyword">false</span>;
00247 }
00248 
00249 ?&gt;
</pre></div>    </div>
  </body>
</html>
Return current item: Aukyla Platform