3 # FILE: TabbedContentUI.php 5 # Part of the Collection Workflow Integration System (CWIS) 6 # Copyright 2018 Edward Almasy and Internet Scout Research Group 7 # http://scout.wisc.edu/cwis/ 15 # ---- PUBLIC INTERFACE -------------------------------------------------- 28 # check to make sure tab label is not a duplicate or already started 29 if (isset($this->CurrentTab[$TabLabel]))
31 throw new InvalidArgumentException(
32 "Duplicate tab name (\"".$TabLabel.
"\").");
34 if ($TabLabel == $this->CurrentTab)
36 throw new InvalidArgumentException(
37 "Tab \"".$TabLabel.
"\" already started.");
40 # if another tab is currently started 41 if (isset($this->CurrentTab))
47 # set default active tab if no active tab already set 53 # beginning buffering content for new tab 54 $this->CurrentTab = $TabLabel;
67 # check to make sure tab has been started 68 if (!isset($this->CurrentTab))
70 throw new Exception(
"No tab currently in progress.");
73 # stop buffering and save content for tab 74 $this->TabContent[$this->CurrentTab] = ob_get_contents();
77 # note that no tab is currently under way 78 unset($this->CurrentTab);
88 if ($NewValue !== NULL)
92 return $this->ActiveTab;
102 # if tab is currently started 103 if (isset($this->CurrentTab))
109 # check to make sure active tab is valid 110 if (!isset($this->TabContent[$this->
ActiveTab]))
112 throw new Exception(
"Active tab (.\"".$this->ActiveTab.
"\") is invalid.");
115 # make sure JavaScript and CSS needed for tabbed interface is loaded 116 $GLOBALS[
"AF"]->RequireUIFile(
'jquery-ui.css',
118 $GLOBALS[
"AF"]->RequireUIFile(
'jquery-ui.js');
120 # begin tabbed content 121 ?><div
class=
"cw-tab-container"><div
id=
"<?= $Id ?>"><?
PHP 123 # begin tab navigation 124 ?><ul
class=
"cw-tab-nav">
128 foreach ($this->TabContent as $Label => $Content)
130 # add navigation for tab 131 $Suffix = self::GetIdSuffix($Label);
132 ?><li><a href=
"#cw-tabs-<?= $Suffix ?>"><b><?=
133 htmlspecialchars($Label) ?></b></a></li><?
PHP 143 foreach ($this->TabContent as $Label => $Content)
145 # add content section for tab 146 $Suffix = self::GetIdSuffix($Label);
147 ?><div
id=
"cw-tabs-<?= $Suffix ?>"><?= $Content ?></div>
150 # if tab is active save tab index for later use 151 if ($Label == $this->ActiveTab)
153 $ActiveTabIndex = $TabIndex;
161 # add JavaScript to select active tab 162 ?><script type=
'text/javascript'>
163 jQuery(document).ready(
function() {
164 jQuery(
'#<?= $Id ?>').tabs({active:
'<?= $ActiveTabIndex ?>'}); });
168 # ---- PRIVATE INTERFACE ------------------------------------------------- 179 private static function GetIdSuffix($Text)
181 return strtolower(preg_replace(
"/[^a-z]+/i",
"", $Text));
Display($Id="cw-tabs")
Output HTML for tabbed content.
ActiveTab($NewValue=NULL)
Get/set tab to be active (i.e.
BeginTab($TabLabel)
Begin content for tab.
const ORDER_FIRST
Handle item first (i.e.
Class to provide a user interface for displaying content in a tabbed format.