78 $this->page = ($config[
'prettyURLs'] ===
false) ? basename($_SERVER[
"PHP_SELF"]) : $_REQUEST[
'identifier'];
79 if ($isAdmin) $this->page =
"/admin/{$this->page}";
83 trace(
"PAGE: **** {$this->page}", 4);
94 $this->queryString = $qs;
95 $this->useQueryString =
true;
99 $this->queryString =
null;
100 $this->useQueryString =
false;
107 $this->dynamic =
true;
113 if (!$this->dynamic)
return $script;
115 $script .= <<<ENDSCRIPT
116 <script type=
"text/javascript">
117 window.addEvent(
'domready',
function()
119 document.id(
'{$this->id}').getElements(
"a").each(
function(a)
121 a.loadTab =
function(
override)
123 if ($this->dynamicLoadHandler)
125 $script .= <<<ENDSCRIPT
127 var url =
override ? override : this.href;
128 {$this->dynamicLoadHandler}(url);
134 $script .= <<<ENDSCRIPT
136 var request =
new Request.HTML(
141 url:
override ? override : this.href,
142 onSuccess:
function(tree, elements, html, script)
144 var container = document.id(
'{$this->container}');
145 container.set(
'text',
'');
146 container.adopt(tree);
148 Browser.exec(script);
158 $script .= <<<ENDSCRIPT
160 a.addEvent(
'click',
function(e)
162 new DOMEvent(e).stop();
164 var parent = a.getParent();
165 document.id(
'{$this->id}').getElements(
"li").each(
function(l) { l.removeClass(
"current"); });
166 parent.addClass(
'current');
173 if ($this->dynamicLoadFirstTab)
175 $script .= <<<ENDSCRIPT
176 document.id(
'{$this->id}').getElements(
"li.current a").each(
function(a)
183 $script .= <<<ENDSCRIPT
194 foreach($this->tabs as $text => $entry)
196 if (is_object($entry) && get_class($entry) ==
"TabBar")
206 if ($this->anchor) echo
"<a name='<?echo $this->anchor?>'></a>";
208 echo
"<div id='{$this->id}'";
210 if ($this->cssClass) echo
" class='{$this->cssClass}'";
214 foreach ($this->tabs as $text => $entry)
221 if ($entry ===
null)
continue;
223 if (is_string($entry))
227 else if (is_object($entry) && get_class($entry) ==
"TabBar")
229 if ($entry->findPage($this->page))
235 $url = $entry->getPage(0,
false);
248 $isMatch = $this->comparePaths($url, $this->page);
253 $style =
" class='current'";
256 if (($this->disabled || ($this->queryString ==
"" && $this->useQueryString)) && $count > 1)
258 $active =
" class='disabled'";
261 if ($this->showNumber) $text =
"$count. $text";
263 if ($this->useQueryString)
265 $dest = ($this->queryString!=
"") ? $this->
appendQueryString($url, $this->queryString) :
"#";
274 $dest = ($dest !=
"#") ?
"$dest#{$this->anchor}" :
"#{$this->anchor}";
277 if ($this->showStates)
279 if (array_key_exists($url, $this->flags))
281 $text =
"<img src='{$this->states[$this->flags[$url]]}' style='border: none; display: inline-block;vertical-align: middle'/> $text";
283 else if ($this->defaultStateImage)
285 $text =
"<img src='{$this->defaultStateImage}' style='border: none; display: inline-block;vertical-align: middle'/> $text";
288 echo
"<li$style><a href=\"$dest\"$active>$text</a></li>";
291 echo
"</ul></div>\n";
293 foreach($this->tabs as $text => $entry)
295 if (is_object($entry) && get_class($entry) ==
"TabBar" &&
296 $entry->findPage($this->page))
319 $url .= (strstr($url,
"?") !==
false) ?
"&$qs" :
"?$qs";
333 foreach($this->tabs as $text => $url)
335 trace(
"getNextPage::text is $text and url is $url; this page is {$this->page}", 3);
338 $dest = ($this->queryString!=
"") ? $this->
appendQueryString($url, $this->queryString) : $url;
339 trace(
"getNextPage::found; dest is$dest", 3);
342 else if ($this->comparePaths($url, $this->page))
345 trace(
"getNextPage::url is this page", 3);
349 return ($found) ?
"" :
false;
357 function getPage($idx, $appendQueryString =
true)
361 foreach($this->tabs as $text => $entry)
363 if (is_object($entry) && get_class($entry) ==
"TabBar")
365 $num = count($entry->tabs);
367 if ($num >= $idx - $i)
370 return $entry->getPage($idx - $i);
383 if ($i == $idx)
break;
387 $dest = ($appendQueryString && $this->queryString!=
"") ? $this->
appendQueryString($url, $this->queryString) : $url;
391 private function comparePaths($url,
$page)
393 trace(
"COMPARE PATHS: $url, $page", 2);
395 if (strpos($url,
"/") ===
false)
397 trace(
"COMPARING PATHS: $url, ".basename(
$page).
" == " . (basename(
$page) == $url), 2);
398 return basename(
$page) == $url;
402 return $page == $url;
413 foreach($this->tabs as $text => $url)
415 if ($this->comparePaths($url,
$page))
442 trace(
"tabbar::next:: next is $next",3);
449 <table
class=
"checklist">
451 foreach($this->tabs as $title => $form)
462 if (get_class($form) ==
"TabBar")
466 <td colspan=
"2" class=
"title"><b><?echo $title?></b></td>
469 foreach($form->tabs as $t => $f)
476 $status = $this->flags[$form];
478 if ($status && $this->states[$status])
480 $img =
"<img src='{$this->states[$status]}' alt='$status'/>";
482 else if ($this->defaultStateImage)
484 $img =
"<img src='{$this->defaultStateImage}' alt=''/>";
488 <td
class=
"status"><?echo $img ?></td>
489 <td
class=
"link"><a href=
"<?echo $form ?>?<?echo $this->queryString?>"><?echo $title ?></a></td>
498 foreach($this->tabs as $text => $entry)
500 if (is_object($entry) && get_class($entry) ==
"TabBar")
502 $entry->defaultStateImage = $img;
506 $this->defaultStateImage = $img;
551 foreach(
$tabs as $text => $entry)
553 if (is_array($entry))
559 $this->
TabBar(
"tabs", $tabs, $qs);
560 $this->showStates =
false;
565 foreach($this->tabs as $text => $entry)
567 if (get_class($entry) ==
"TabBar")
578 foreach($this->tabs as $text => $entry)
580 if (get_class($entry) ==
"TabBar")
594 foreach($this->tabs as $text => $entry)
596 if (get_class($entry) ==
"TabBar")
600 if ($jump)
return $entry->getPage(0);
602 $next = $entry->getNextPage();
604 if ($next ===
false)
continue;
627 foreach($this->tabs as $text => $entry)
629 if (get_class($entry) ==
"TabBar")
631 $found = $entry->findPage(
$page);
646 <table
class=
"checklist">
649 foreach($this->tabs as $title => $steps)
652 <td colspan=
"2" class=
"title"><b><?echo $title?></b></td>
665 foreach($this->tabs as $title => $tabBar)
667 $steps = $tabBar->tabs;
668 $keys = array_keys($steps);
669 $title = $keys[$idx];
670 if (isset($steps[$title]))
672 $form = $steps[$title];
674 $status = $tabBar->flags[$form];
676 if ($status && $this->states[$status])
678 $img =
"<img src='{$this->states[$status]}' alt='$status'/>";
680 else if ($this->defaultStateImage)
682 $img =
"<img src='{$this->defaultStateImage}' alt=''/>";
685 $row .=
"<td class=\"status\">$img</td>";
686 $row .=
"<td class=\"link\"><a href=\"$form?{$this->queryString}\">$title</a></td>";
690 $row .=
"<td class=\"status\"></td>";
691 $row .=
"<td class=\"link\"></td>";
715 foreach($this->tabs as $text => $entry)
717 if (get_class($entry) ==
"TabBar")
719 $entry->cssClass =
"{$color}_subtabs";
723 $this->cssClass =
"{$color}_tabs";
The TabBar class is a user-interface control that manages a line of tabs for multi-page dialogs.
$showNumber
True to display the step number, false if not.
drawCheckListEntry($title, $form)
$queryString
The query string parameters to append to the navigation links.
$dynamicLoadHandler
Javascript function to call to handle dynamic content load (optional)
$disabled
Set to true to generate disabled tab navigation.
$flags
Array of flags to apply, indexed by tab.
$useQueryString
Whether a query string is being used as the navigation key.
appendQueryString($url, $qs)
Appends a query string to the supplied URL.
findPage($page)
Finds the tab containing the specified URL.
writeHTML()
Writes the HTML for this control to standard output.
getPage($idx, $appendQueryString=true)
Return the URL for the page at the specified tab index.
next()
Move to the next page in the tab list.
setDefaultStateImage($img)
$tabs
The tab records in this tab bar.
$dynamicLoadFirstTab
By default, dynamically loaded tab bars will do a request for the content of the first tab on page lo...
$page
The current page (for display purposes). This can be set explicitly to force the correct tab display ...
$states
Array of display states to apply, indexed by tab.
$cssClass
CSS class to apply to the top level container for the tabs.
preserveQueryString()
Preserve the current query string in tab links.
$id
The DOM ID of the TabBar container element.
$container
The DOM ID of the container that will contain dynamically loaded content.
$defaultStateImage
Image to show in the default tab state.
$dynamic
true to indicate dynamic (AJAX-based) loading
TabBar($id, $tabs, $queryString="", $useQueryString=true, $showNumber=false)
Construct a new TabBar control.
getNextPage()
Get the next page in the tab list after the current page.
$anchor
Anchor name to generate (leave empty for no anchor tag)
$showStates
true to show tab states, false to ignore them
The TabBar class is a user-interface control that manages 2 lines of tabs for multi-page dialogs.
drawHorizontalCheckList()
TwoLevelTabBar($tabs, $qs)
findPage($page)
Finds the tab containing the specified URL.
getNextPage()
Get the next page in the tab list after the current page.
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
getCleanQueryString()
Returns the query string for the current page, cleaned of any Fakoli-related navigation parameters.
redirect($page)
Simplified redirect.