Framework  3.9
DataItemTabBar Class Reference

The DataItemTabBar class is a user-interface control that manages a line of tabs for multi-page dialogs. More...

Public Member Functions

 DataItemTabBar ($id, $items, $format=null, $uri="")
 
 appendQueryString ($url, $qs)
 Appends a query string to the supplied URL. More...
 
 writeScript ()
 
 writeHTML ()
 Writes the HTML for this control to standard output. More...
 

Public Attributes

 $id
 The DOM ID of the DataItemTabBar container element. More...
 
 $items
 
 $format
 
 $uri
 
 $primary_key
 
 $spacer
 

Detailed Description

The DataItemTabBar class is a user-interface control that manages a line of tabs for multi-page dialogs.

Unlike the regular TabBar control, a DataItemTabBar is bound to a collection of DataItem objects.

Definition at line 41 of file data_tabs.inc.

Member Function Documentation

◆ appendQueryString()

DataItemTabBar::appendQueryString (   $url,
  $qs 
)

Appends a query string to the supplied URL.

Parameters
string$url
string$qs
Returns
string

Definition at line 73 of file data_tabs.inc.

74  {
75  if ($url[0] == "&")
76  {
77  $url = $qs.$url;
78  }
79  else
80  {
81  $url .= (strstr($url, "?") !== false) ? "&$qs" : "?$qs";
82  }
83  return $url;
84  }

◆ DataItemTabBar()

DataItemTabBar::DataItemTabBar (   $id,
  $items,
  $format = null,
  $uri = "" 
)

Definition at line 52 of file data_tabs.inc.

53  {
54  $this->id = $id;
55  $this->items = $items;
56  $this->format = $format;
57  if (count($this->items))
58  {
59  $this->primary_key = $this->items[0]->getPrimaryKey();
60  }
61 
62  $this->uri = $uri;
63  }
$id
The DOM ID of the DataItemTabBar container element.
Definition: data_tabs.inc:43

◆ writeHTML()

DataItemTabBar::writeHTML ( )

Writes the HTML for this control to standard output.

Definition at line 103 of file data_tabs.inc.

104  {
105  if (array_key_exists($this->primary_key, $_GET))
106  {
107  $key = $_GET[$this->primary_key];
108  }
109  else
110  {
111  $key = $this->items[0]->get($this->primary_key);
112  }
113 
114  $first = true;
115  $future = false;
116 
117  if ($this->anchor) echo "<a name='<?echo $this->anchor?>'></a>";
118 
119  echo "<div id='{$this->id}'";
120 
121  if ($this->cssClass) echo " class='{$this->cssClass}'";
122 
123  echo "><ul>";
124 
125  $count = 0;
126 
127  foreach ($this->items as $item)
128  {
129  ++$count;
130  $active = "";
131  $style = "";
132 
133  $pk = $item->get($this->primary_key);
134 
135  $url = $this->uri . "?" . $this->primary_key . "=" . urlencode($pk);
136 
137  $text = $item->format($this->format);
138 
139  if (!$first)
140  {
141  echo $this->spacer;
142  }
143  else
144  {
145  $first = false;
146  }
147 
148  if ($pk == $key)
149  {
150  $style = " class='current'";
151  }
152 
153  if ($this->showNumber) $text = "$count.&nbsp;$text";
154 
155  $dest = ($this->queryString!="") ? $this->appendQueryString($url, $this->queryString) : $url;
156 
157  if ($this->anchor)
158  {
159  $dest = ($dest != "#") ? "$dest#{$this->anchor}" : "#{$this->anchor}";
160  }
161 
162  if ($this->showStates)
163  {
164  if (array_key_exists($url, $this->flags))
165  {
166  $text = "<img src='{$this->states[$this->flags[$pk]]}' style='border: none; display: inline-block;vertical-align: middle'/>&nbsp;$text";
167  }
168  else if ($this->defaultStateImage)
169  {
170  $text = "<img src='{$this->defaultStateImage}' style='border: none; display: inline-block;vertical-align: middle'/>&nbsp;$text";
171  }
172  }
173  echo "<li$style><a href=\"$dest\"$active>$text</a></li>";
174  }
175 
176  echo "</ul></div>\n";
177  }
appendQueryString($url, $qs)
Appends a query string to the supplied URL.
Definition: data_tabs.inc:73

◆ writeScript()

DataItemTabBar::writeScript ( )

Definition at line 86 of file data_tabs.inc.

87  {
88  $script = <<<ENDSCRIPT
89 <script type='text/javascript'>
90 window.addEvent('load', function()
91 {
92  new ScrollingTabs('{$this->id}');
93 });
94 </script>
95 ENDSCRIPT;
96 
97  return $script;
98  }

Member Data Documentation

◆ $format

DataItemTabBar::$format

Definition at line 46 of file data_tabs.inc.

◆ $id

DataItemTabBar::$id

The DOM ID of the DataItemTabBar container element.

Definition at line 43 of file data_tabs.inc.

◆ $items

DataItemTabBar::$items

Definition at line 45 of file data_tabs.inc.

◆ $primary_key

DataItemTabBar::$primary_key

Definition at line 49 of file data_tabs.inc.

◆ $spacer

DataItemTabBar::$spacer

Definition at line 50 of file data_tabs.inc.

◆ $uri

DataItemTabBar::$uri

Definition at line 48 of file data_tabs.inc.


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