Framework  3.9
wizard_bar.inc
Go to the documentation of this file.
1 <?php
2 /**************************************************************
3 
4  Copyright (c) 2007-2010 Sonjara, Inc
5 
6  Permission is hereby granted, free of charge, to any person
7  obtaining a copy of this software and associated documentation
8  files (the "Software"), to deal in the Software without
9  restriction, including without limitation the rights to use,
10  copy, modify, merge, publish, distribute, sublicense, and/or sell
11  copies of the Software, and to permit persons to whom the
12  Software is furnished to do so, subject to the following
13  conditions:
14 
15  The above copyright notice and this permission notice shall be
16  included in all copies or substantial portions of the Software.
17 
18  Except as contained in this notice, the name(s) of the above
19  copyright holders shall not be used in advertising or otherwise
20  to promote the sale, use or other dealings in this Software
21  without prior written authorization.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30  OTHER DEALINGS IN THE SOFTWARE.
31 
32 *****************************************************************/
33 
34 Fakoli::usingFeature("tab_bar");
35 
36 
37 
44 class WizardBar extends TabBar
45 {
46  var $spacer = "&nbsp;&raquo;&nbsp;";
47  var $strict = false;
48  var $rootSteps = 1;
49  var $scriptLinks = false;
50 
61  function WizardBar($id, $tabs = array(), $queryString = "", $useQueryString = true, $showNumber = false)
62  {
63  parent::TabBar($id, $tabs, $queryString, $useQueryString, $showNumber);
64  }
65 
69  function writeHTML()
70  {
71  $first = true;
72  $future = false;
73  $count = 0;
74 
75  echo "<div id='{$this->id}'";
76 
77  if ($this->cssClass) echo " class='{$this->cssClass}'";
78 
79  echo "><ul>";
80  foreach($this->tabs as $text => $url)
81  {
82 
83  ++$count;
84  $active = "";
85  $style = "";
86 
87  if (!$first)
88  {
90  }
91  else
92  {
93  $spacer = "";
94  $first = false;
95  $style = "first ";
96  }
97 
98  if ($url == $this->page)
99  {
100  $style .= "current";
101  $future = true;
102  }
103  elseif (($this->disabled ||
104  ($future && $this->strict) ||
105  ($future && ($this->queryString == "" && $this->useQueryString)) && $count > $this->rootSteps)
106  || $this->states[$url] == 'disable')
107  {
108  $active = " class='disabled'";
109  $style .= "disabled";
110  }
111 
112  if ($this->showNumber) $text = "$count.&nbsp;$text";
113 
114  if ($this->useQueryString)
115  {
116  $dest = ($this->queryString!="" || ($this->rootSteps > 1 && $count <= $this->rootSteps)) ? $this->appendQueryString($url, $this->queryString) :"#";
117  }
118  else
119  {
120  $dest = ($url == $this->page || $this->disabled || ($future && $this->strict)) ? "#" : $url;
121  }
122 
123  if ($this->anchor)
124  {
125  $dest = ($dest != "#") ? "$dest#{$this->anchor}" : "#{$this->anchor}";
126  }
127 
128  if ($this->scriptLinks)
129  {
130  $link = "href=\"#\"";
131  if ($dest != '#')
132  {
133  $link .= " onclick=\"$dest; return false\"";
134  }
135  }
136  else
137  {
138  $link = "href=\"$dest\"";
139  }
140 
141  if ($this->showStates)
142  {
143  if (array_key_exists($url, $this->flags))
144  {
145  $text = "<img src='{$this->states[$this->flags[$url]]}' style='border: none; display: inline-block;vertical-align: middle'/>&nbsp;$text";
146  }
147  else if ($this->defaultStateImage)
148  {
149  $text = "<img src='{$this->defaultStateImage}' style='border: none; display: inline-block;vertical-align: middle'/>&nbsp;$text";
150  }
151  }
152 
153  echo "<li class='$style'>$spacer<a {$link}{$active}>{$text}</a></li>";
154  }
155 
156  // close wizard div
157  echo "</ul></div>\n";
158  }
159 }
160 ?>
The TabBar class is a user-interface control that manages a line of tabs for multi-page dialogs.
Definition: tab_bar.inc:40
$showNumber
True to display the step number, false if not.
Definition: tab_bar.inc:46
$queryString
The query string parameters to append to the navigation links.
Definition: tab_bar.inc:43
$useQueryString
Whether a query string is being used as the navigation key.
Definition: tab_bar.inc:44
appendQueryString($url, $qs)
Appends a query string to the supplied URL.
Definition: tab_bar.inc:311
$tabs
The tab records in this tab bar.
Definition: tab_bar.inc:42
$id
The DOM ID of the TabBar container element.
Definition: tab_bar.inc:41
The WizardBar class is a user-interface control that draws a stepped nav bar for multi-stage workflow...
Definition: wizard_bar.inc:45
$spacer
Spacer that appears between wizard steps.
Definition: wizard_bar.inc:46
writeHTML()
Writes the HTML for this control to standard output.
Definition: wizard_bar.inc:69
$strict
When strict is set to true, navigation to future steps is always disabled.
Definition: wizard_bar.inc:47
$rootSteps
The number of steps that can be reached without a query string when useQueryString is true.
Definition: wizard_bar.inc:48
WizardBar($id, $tabs=array(), $queryString="", $useQueryString=true, $showNumber=false)
Construct a new WizardBar control.
Definition: wizard_bar.inc:61
$scriptLinks
True to specify that destinations are javascript and should be place in onclick attributes.
Definition: wizard_bar.inc:49