Framework  3.9
TwoLevelTabBar Class Reference

The TabBar class is a user-interface control that manages 2 lines of tabs for multi-page dialogs. More...

+ Inheritance diagram for TwoLevelTabBar:
+ Collaboration diagram for TwoLevelTabBar:

Public Member Functions

 TwoLevelTabBar ($tabs, $qs)
 
 setFlags ($flags)
 
 setStates ($states)
 
 getNextPage ()
 Get the next page in the tab list after the current page. More...
 
 findPage ($page)
 Finds the tab containing the specified URL. More...
 
 drawHorizontalCheckList ()
 
 setColor ($color)
 
- Public Member Functions inherited from TabBar
 TabBar ($id, $tabs, $queryString="", $useQueryString=true, $showNumber=false)
 Construct a new TabBar control. More...
 
 preserveQueryString ()
 Preserve the current query string in tab links. More...
 
 dynamicLoad ($container)
 
 writeScript ()
 
 writeHTML ()
 Writes the HTML for this control to standard output. More...
 
 appendQueryString ($url, $qs)
 Appends a query string to the supplied URL. More...
 
 getPage ($idx, $appendQueryString=true)
 Return the URL for the page at the specified tab index. More...
 
 next ()
 Move to the next page in the tab list. More...
 
 drawCheckList ()
 
 drawCheckListEntry ($title, $form)
 
 setDefaultStateImage ($img)
 

Additional Inherited Members

- Public Attributes inherited from TabBar
 $id
 The DOM ID of the TabBar container element. More...
 
 $tabs = array()
 The tab records in this tab bar. More...
 
 $queryString = null
 The query string parameters to append to the navigation links. More...
 
 $useQueryString = true
 Whether a query string is being used as the navigation key. More...
 
 $page = ""
 The current page (for display purposes). This can be set explicitly to force the correct tab display when in a sub-page, for instance. More...
 
 $showNumber
 True to display the step number, false if not. More...
 
 $states = array()
 Array of display states to apply, indexed by tab. More...
 
 $flags = array()
 Array of flags to apply, indexed by tab. More...
 
 $anchor = ""
 Anchor name to generate (leave empty for no anchor tag) More...
 
 $cssClass = ""
 CSS class to apply to the top level container for the tabs. More...
 
 $defaultStateImage
 Image to show in the default tab state. More...
 
 $showStates = true
 true to show tab states, false to ignore them More...
 
 $dynamic = false
 true to indicate dynamic (AJAX-based) loading More...
 
 $container = ""
 The DOM ID of the container that will contain dynamically loaded content. More...
 
 $dynamicLoadHandler = null
 Javascript function to call to handle dynamic content load (optional) More...
 
 $dynamicLoadFirstTab = true
 By default, dynamically loaded tab bars will do a request for the content of the first tab on page load. Set to false to disable this. More...
 
 $disabled = false
 Set to true to generate disabled tab navigation. More...
 

Detailed Description

The TabBar class is a user-interface control that manages 2 lines of tabs for multi-page dialogs.

Example code the include file calling script: $tabs = getTabs(); $qs = ($key) ? "{primary key}=$key" : ""; $tabBar = new TwoLevelTabBar($tabs, $qs); $tabBar->setStates(array("submitted" => "{icon path}")); $tabBar->setDefaultStateImage("{icon_path}");

return $tabBar;

function getTabs() {

$tabs = array( "First Top Level Tab"    =>
                    array(    "First Lower Tab"             =>   "{identifier}",
                              "Second Lower Tab"       =>   "{identifier"),


                    "2nd Top Level Tab" =>
                    array(    "Lower tab"              =>   "{identifier",
                              "Lower tab"              =>   "{identifier") 

);

return $tabs;

}

Definition at line 547 of file tab_bar.inc.

Member Function Documentation

◆ drawHorizontalCheckList()

TwoLevelTabBar::drawHorizontalCheckList ( )

Definition at line 643 of file tab_bar.inc.

644  {
645 ?>
646  <table class="checklist">
647  <tr>
648 <?
649  foreach($this->tabs as $title => $steps)
650  {
651 ?>
652  <td colspan="2" class="title"><b><?echo $title?></b></td>
653 <?
654  }
655 ?>
656  </tr>
657 <?
658  $idx = 0;
659 
660  do
661  {
662  $found = false;
663  $row = "";
664 
665  foreach($this->tabs as $title => $tabBar)
666  {
667  $steps = $tabBar->tabs;
668  $keys = array_keys($steps);
669  $title = $keys[$idx];
670  if (isset($steps[$title]))
671  {
672  $form = $steps[$title];
673  $found = true;
674  $status = $tabBar->flags[$form];
675 
676  if ($status && $this->states[$status])
677  {
678  $img = "<img src='{$this->states[$status]}' alt='$status'/>";
679  }
680  else if ($this->defaultStateImage)
681  {
682  $img = "<img src='{$this->defaultStateImage}' alt=''/>";
683  }
684 
685  $row .= "<td class=\"status\">$img</td>";
686  $row .= "<td class=\"link\"><a href=\"$form?{$this->queryString}\">$title</a></td>";
687  }
688  else
689  {
690  $row .= "<td class=\"status\"></td>";
691  $row .= "<td class=\"link\"></td>";
692 
693  }
694  }
695 
696  if ($found)
697  {
698 ?>
699  <tr>
700  <?echo $row?>
701  </tr>
702 <?
703  }
704 
705  $idx++;
706  }
707  while($found);
708 ?>
709  </table>
710 <?
711  }

◆ findPage()

TwoLevelTabBar::findPage (   $page)

Finds the tab containing the specified URL.

Parameters
$pageThe page to find
Returns
mixed returns the name of the tab if found, false otherwise

Reimplemented from TabBar.

Definition at line 622 of file tab_bar.inc.

623  {
624  // remove query string if given;
625  $page = preg_replace('/\?.*/', '', $page);
626 
627  foreach($this->tabs as $text => $entry)
628  {
629  if (get_class($entry) == "TabBar")
630  {
631  $found = $entry->findPage($page);
632  if($found)
633  {
634  return $found;
635  }
636  }
637  }
638 
639  return false;
640  }
$page
The current page (for display purposes). This can be set explicitly to force the correct tab display ...
Definition: tab_bar.inc:45

◆ getNextPage()

TwoLevelTabBar::getNextPage ( )

Get the next page in the tab list after the current page.

Returns
string

Reimplemented from TabBar.

Definition at line 590 of file tab_bar.inc.

591  {
592  $jump = false;
593 
594  foreach($this->tabs as $text => $entry)
595  {
596  if (get_class($entry) == "TabBar")
597  {
598  $entry->queryString = $this->queryString;
599 
600  if ($jump) return $entry->getPage(0);
601 
602  $next = $entry->getNextPage();
603 
604  if ($next === false) continue;
605  if ($next === "")
606  {
607  $jump = true;
608  continue;
609  }
610 
611  return $next;
612  }
613  }
614 
615  }
$queryString
The query string parameters to append to the navigation links.
Definition: tab_bar.inc:43

◆ setColor()

TwoLevelTabBar::setColor (   $color)

Definition at line 713 of file tab_bar.inc.

714  {
715  foreach($this->tabs as $text => $entry)
716  {
717  if (get_class($entry) == "TabBar")
718  {
719  $entry->cssClass = "{$color}_subtabs";
720  }
721  }
722 
723  $this->cssClass = "{$color}_tabs";
724  }

◆ setFlags()

TwoLevelTabBar::setFlags (   $flags)

Definition at line 563 of file tab_bar.inc.

564  {
565  foreach($this->tabs as $text => $entry)
566  {
567  if (get_class($entry) == "TabBar")
568  {
569  $entry->flags = $flags;
570  }
571  }
572 
573  $this->flags = $flags;
574  }
$flags
Array of flags to apply, indexed by tab.
Definition: tab_bar.inc:48

◆ setStates()

TwoLevelTabBar::setStates (   $states)

Definition at line 576 of file tab_bar.inc.

577  {
578  foreach($this->tabs as $text => $entry)
579  {
580  if (get_class($entry) == "TabBar")
581  {
582  $entry->states = $states;
583  }
584  }
585 
586  $this->states = $states;
587  }
$states
Array of display states to apply, indexed by tab.
Definition: tab_bar.inc:47

◆ TwoLevelTabBar()

TwoLevelTabBar::TwoLevelTabBar (   $tabs,
  $qs 
)

Definition at line 549 of file tab_bar.inc.

550  {
551  foreach($tabs as $text => $entry)
552  {
553  if (is_array($entry))
554  {
555  $tabs[$text] = new TabBar("subtabs", $entry, $qs);
556  }
557  }
558 
559  $this->TabBar("tabs", $tabs, $qs);
560  $this->showStates = false;
561  }
$tabs
The tab records in this tab bar.
Definition: tab_bar.inc:42
TabBar($id, $tabs, $queryString="", $useQueryString=true, $showNumber=false)
Construct a new TabBar control.
Definition: tab_bar.inc:71

The documentation for this class was generated from the following file: