noalyss Version-9
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
Output_Html_Tab Class Reference

Display the tabs. More...

+ Collaboration diagram for Output_Html_Tab:

Public Member Functions

 __construct ()
 
 add (Html_Tab $p_html_tab)
 Add Html_Tab. More...
 
 build_js ($p_not_hidden)
 Build the javascript to change the class name of the selected tab, hide other div and show the selected one. More...
 
 get_class_anchor ()
 CSS class for the A tag (anchor) More...
 
 get_class_comment ()
 CSS class for the comment default "tabs". More...
 
 get_class_content_div ()
 CSS class for the DIV with content (default empty) More...
 
 get_class_div ()
 CSS class for the DIV containing the UL. More...
 
 get_class_tab ()
 get the CSS class of tabs More...
 
 get_class_tab_main ()
 get the CSS class for the UL element More...
 
 get_class_tab_selected ()
 get the CSS class of tabs_selected More...
 
 get_mode ()
 get the mode , possible value are row or tabs , with mode = row , the class_content_div is set to row More...
 
 output ()
 print the html + javascript code of the tabs and the div More...
 
 set_class_anchor ($anchor_class)
 CSS class for the A tag (anchor) More...
 
 set_class_comment ($class_comment)
 CSS class for the comment default "tabs". More...
 
 set_class_content_div ($class_content_div)
 CSS class for the DIV with content (default empty) More...
 
 set_class_div ($class_div)
 CSS class for the DIV containing the UL. More...
 
 set_class_tab ($class_tab)
 set the CSS class of tabs, default is tabs More...
 
 set_class_tab_main ($class_tab_main)
 set the CSS class for the UL element More...
 
 set_class_tab_selected ($class_tab_selected)
 set the CSS class of tabs, default is tabs_selected More...
 
 set_mode ($mode)
 set the mode , possible values : row , tabs or accordeon More...
 

Protected Member Functions

 print_comment ($p_index)
 When printing row , a comment is written if not empty,. More...
 

Private Member Functions

 print_div ($p_index)
 

Private Attributes

 $a_tabs
 array of html tabs More...
 
 $class_anchor
 CSS class for the UL tag. More...
 
 $class_comment
 CSS class for the DIV with content, default empty. More...
 
 $class_content_div
 CSS class for the DIV containing the UL default empty. More...
 
 $class_div
 CSS class for the A tag (anchor) default empty. More...
 
 $class_tab
 for normal tab More...
 
 $class_tab_main
 
 $class_tab_selected
 for class_tab_selected More...
 
 $mode
 mode default tabs More...
 

Detailed Description

Display the tabs.

See also
Html_Tab
Examples
html_tab.test.php.

Definition at line 35 of file output_html_tab.class.php.

Constructor & Destructor Documentation

◆ __construct()

Output_Html_Tab::__construct ( )

Definition at line 51 of file output_html_tab.class.php.

52 {
53 $this->a_tabs=[];
54 $this->class_tab="tabs";
55 $this->class_tab_main="tabs";
56 $this->class_tab_selected="tabs_selected";
57 $this->set_mode("tab");
58 $this->class_anchor="";
59 $this->class_div="";
60 $this->class_content_div="";
61 $this->class_comment="tabs";
62 }
set_mode($mode)
set the mode , possible values : row , tabs or accordeon

References set_mode().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

Output_Html_Tab::add ( Html_Tab  $p_html_tab)

Add Html_Tab.

Parameters
Html_Tab$p_html_tab

Definition at line 199 of file output_html_tab.class.php.

200 {
201 $this->a_tabs[]=clone $p_html_tab;
202
203 }

◆ build_js()

Output_Html_Tab::build_js (   $p_not_hidden)

Build the javascript to change the class name of the selected tab, hide other div and show the selected one.

Parameters
string$p_not_hiddenid of the showed tab
Returns
javascript string

Definition at line 248 of file output_html_tab.class.php.

249 {
250 $r="";
251 $nb=count($this->a_tabs);
252 $mode=$this->get_mode();
253 if ($mode=="accordeon") {
254 $r .= \Icon_Action::toggle_hide(uniqid(), sprintf("div%s", $p_not_hidden));
255
256 return $r;
257 }
258 for ($i =0 ; $i < $nb;$i++)
259 {
260 if ($mode=="tab") {
261
262 if ( $this->a_tabs[$i]->get_id() != $p_not_hidden) {
263 $r .= sprintf("$('div%s').hide();",$this->a_tabs[$i]->get_id() );
264 $r .= sprintf("$('tab%s').className='%s';",$this->a_tabs[$i]->get_id(),$this->class_tab );
265 } else {
266 $r .= sprintf("$('div%s').show();",$p_not_hidden );
267 $r .= sprintf("$('tab%s').className='%s';",$p_not_hidden ,$this->class_tab_selected);
268
269 }
270 } elseif ($mode=="row") {
271 if ( $this->a_tabs[$i]->get_id() != $p_not_hidden) {
272 $r .= sprintf("Effect.BlindUp('div%s',{duration : 0.7});",$this->a_tabs[$i]->get_id() );
273 $r .= sprintf("$('tab%s').className='%s';",$this->a_tabs[$i]->get_id(),$this->class_tab );
274 } else {
275 $r .= sprintf("Effect.SlideDown('div%s',{duration : 0.7});",$p_not_hidden );
276 $r .= sprintf("$('tab%s').className='%s';",$p_not_hidden ,$this->class_tab_selected);
277
278 }
279 } else {
280 throw new \Exception("OH283.unknow mode [$mode]");
281 }
282 }
283 return $r;
284 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
static toggle_hide($p_id, $p_id_to_hide)
hide or display an element, to be used for an accordon
get_mode()
get the mode , possible value are row or tabs , with mode = row , the class_content_div is set to row
$mode
mode default tabs
if( $delta< 0) elseif( $delta==0)

References $i, $mode, $nb, $r, elseif, get_mode(), and Icon_Action\toggle_hide().

Referenced by output().

+ Here is the call graph for this function:

◆ get_class_anchor()

Output_Html_Tab::get_class_anchor ( )

CSS class for the A tag (anchor)

Returns
type

Definition at line 124 of file output_html_tab.class.php.

125 {
126 return $this->class_anchor;
127 }
$class_anchor
CSS class for the UL tag.

References $class_anchor.

◆ get_class_comment()

Output_Html_Tab::get_class_comment ( )

CSS class for the comment default "tabs".

Returns
type

Definition at line 67 of file output_html_tab.class.php.

68 {
70 }
$class_comment
CSS class for the DIV with content, default empty.

References $class_comment.

Referenced by print_comment().

◆ get_class_content_div()

Output_Html_Tab::get_class_content_div ( )

CSS class for the DIV with content (default empty)

Definition at line 85 of file output_html_tab.class.php.

86 {
88 }
$class_content_div
CSS class for the DIV containing the UL default empty.

References $class_content_div.

◆ get_class_div()

Output_Html_Tab::get_class_div ( )

CSS class for the DIV containing the UL.

Returns
string

Definition at line 104 of file output_html_tab.class.php.

105 {
106 return $this->class_div;
107 }
$class_div
CSS class for the A tag (anchor) default empty.

References $class_div.

◆ get_class_tab()

Output_Html_Tab::get_class_tab ( )

get the CSS class of tabs

Returns
mixed

Definition at line 209 of file output_html_tab.class.php.

210 {
211 return $this->class_tab;
212 }
$class_tab
for normal tab

References $class_tab.

Referenced by output().

◆ get_class_tab_main()

Output_Html_Tab::get_class_tab_main ( )

get the CSS class for the UL element

Returns
type

Definition at line 142 of file output_html_tab.class.php.

143 {
145 }

References $class_tab_main.

◆ get_class_tab_selected()

Output_Html_Tab::get_class_tab_selected ( )

get the CSS class of tabs_selected

Returns
mixed

Definition at line 228 of file output_html_tab.class.php.

229 {
231 }
$class_tab_selected
for class_tab_selected

References $class_tab_selected.

◆ get_mode()

Output_Html_Tab::get_mode ( )

get the mode , possible value are row or tabs , with mode = row , the class_content_div is set to row

Returns
mixed

Definition at line 163 of file output_html_tab.class.php.

164 {
165 return $this->mode;
166 }

References $mode.

Referenced by build_js(), output(), and print_div().

◆ output()

Output_Html_Tab::output ( )

print the html + javascript code of the tabs and the div

Definition at line 301 of file output_html_tab.class.php.

302 {
303 $nb=count($this->a_tabs);
304 if ($nb==0)
305 {
306 return;
307 }
308 printf('<div class="%s">',$this->class_div);
309 printf ( '<ul class="%s">',$this->class_tab_main);
310 $mode=$this->get_mode();
311 for ($i=0; $i<$nb; $i++)
312 {
313 printf ('<li id="tab%s" class="%s">',
314 $this->a_tabs[$i]->get_id(),$this->class_tab);
315 switch ($this->a_tabs[$i]->get_mode())
316 {
317 case 'link':
318 printf ('<a class="%s" id="%s" href="%s">',
319 $this->class_anchor,
320 $this->a_tabs[$i]->get_id(),
321 $this->a_tabs[$i]->get_link());
322 printf ('<span class="title_%s"> %s </span>',
323 $this->get_class_tab(),
324 $this->a_tabs[$i]->get_title()
325 );
326 echo '</a>';
327
328 break;
329 case 'ajax':
330 printf('<a class="%s" id="%s" onclick="%s">',
331 $this->class_anchor,
332 $this->a_tabs[$i]->get_id(),
333 $this->a_tabs[$i]->get_link());
334 printf ('<span class="title_%s"> %s </span>',
335 $this->get_class_tab(),
336 $this->a_tabs[$i]->get_title()
337 );
338
339 echo $this->a_tabs[$i]->get_title();
340 echo '</a>';
341 break;
342 case 'static':
343 // show one , hide other except for accordeon
344 $script=$this->build_js($this->a_tabs[$i]->get_id());
345 if ($mode != 'accordeon') {
346 printf('<a class="%s" onclick="%s">', $this->class_anchor,$script);
347 } else {
349 }
350
351 printf ('<span class="title_%s"> %s </span>',
352 $this->get_class_tab(),
353 $this->a_tabs[$i]->get_title()
354 );
355
356 echo '</a>';
357 $script=$this->build_js($this->a_tabs[$i]->get_id());
358
359 break;
360 default:
361 throw new Exception('OUTPUTHTMLTAB01');
362 break;
363 }
364 if ( $mode =="row" || $mode == "accordeon") {
365 $this->print_comment($i);
366 }
367 echo '</li>';
368 if ( $mode =="row" || $mode == "accordeon") {
369 $this->print_div($i);
370 }
371 }
372 echo '</ul>';
373 echo '</div>';
374
375 if ( $mode=="tab" ) {
376 for ($i=0;$i<$nb;$i++)
377 {
378 $this->print_div($i);
379 }
380
381 }
382 }
print_comment($p_index)
When printing row , a comment is written if not empty,.
build_js($p_not_hidden)
Build the javascript to change the class name of the selected tab, hide other div and show the select...
get_class_tab()
get the CSS class of tabs
print
Type of printing.
$script
Definition: popup.php:125

References $i, $mode, $nb, $script, build_js(), get_class_tab(), get_mode(), print, print_comment(), and print_div().

+ Here is the call graph for this function:

◆ print_comment()

Output_Html_Tab::print_comment (   $p_index)
protected

When printing row , a comment is written if not empty,.

Parameters
$p_index

Definition at line 290 of file output_html_tab.class.php.

290 {
291 printf ('<span class="%s"> %s </span>',
292 $this->get_class_comment(),
293 $this->a_tabs[$p_index]->get_comment()
294 );
295
296 }
get_class_comment()
CSS class for the comment default "tabs".

References get_class_comment().

Referenced by output().

+ Here is the call graph for this function:

◆ print_div()

Output_Html_Tab::print_div (   $p_index)
private

Definition at line 383 of file output_html_tab.class.php.

384 {
385 $class="";
386 if ( $this->get_mode() == "row" ) {
387 $class="tab_row";
388 } elseif ( $this->get_mode() == 'accordeon') {
389 $class="";
390 }
391
392
393 printf('<div id="div%s" style="display:none;clear:both" class="%s">',
394 $this->a_tabs[$p_index]->get_id(),
395 $class);
396 echo $this->a_tabs[$p_index]->get_content();
397 echo '</div>';
398
399 }
$class

References $class, elseif, and get_mode().

Referenced by output().

+ Here is the call graph for this function:

◆ set_class_anchor()

Output_Html_Tab::set_class_anchor (   $anchor_class)

CSS class for the A tag (anchor)

Parameters
type$anchor_class

Definition at line 132 of file output_html_tab.class.php.

133 {
134 $this->class_anchor=$anchor_class;
135 $this;
136 }

◆ set_class_comment()

Output_Html_Tab::set_class_comment (   $class_comment)

CSS class for the comment default "tabs".

Returns
type

Definition at line 76 of file output_html_tab.class.php.

77 {
78 $this->class_comment=$class_comment;
79 return $this;
80 }

References $class_comment.

◆ set_class_content_div()

Output_Html_Tab::set_class_content_div (   $class_content_div)

CSS class for the DIV with content (default empty)

Parameters
string$class_content_div

Definition at line 94 of file output_html_tab.class.php.

95 {
96 $this->class_content_div=$class_content_div;
97 return $this;
98 }

References $class_content_div.

◆ set_class_div()

Output_Html_Tab::set_class_div (   $class_div)

CSS class for the DIV containing the UL.

Returns
string

Definition at line 114 of file output_html_tab.class.php.

115 {
116 $this->class_div=$class_div;
117 return $this;
118 }

References $class_div.

◆ set_class_tab()

Output_Html_Tab::set_class_tab (   $class_tab)

set the CSS class of tabs, default is tabs

Parameters
mixed$class_tab

Definition at line 218 of file output_html_tab.class.php.

219 {
220 $this->class_tab = $class_tab;
221 return $this;
222 }

References $class_tab.

Referenced by set_mode().

◆ set_class_tab_main()

Output_Html_Tab::set_class_tab_main (   $class_tab_main)

set the CSS class for the UL element

Returns
this

Definition at line 152 of file output_html_tab.class.php.

153 {
154 $this->class_tab_main=$class_tab_main;
155 return $this;
156 }

References $class_tab_main.

◆ set_class_tab_selected()

Output_Html_Tab::set_class_tab_selected (   $class_tab_selected)

set the CSS class of tabs, default is tabs_selected

Parameters
mixed$class_tab_selected

Definition at line 237 of file output_html_tab.class.php.

238 {
239 $this->class_tab_selected = $class_tab_selected;
240 return $this;
241 }

References $class_tab_selected.

Referenced by set_mode().

◆ set_mode()

Output_Html_Tab::set_mode (   $mode)

set the mode , possible values : row , tabs or accordeon

Parameters
string$modepossible values : row , tabs or accordeon

Definition at line 172 of file output_html_tab.class.php.

173 {
174 if (! in_array($mode,['tab','row','accordeon'] )) {
175 throw new Exception(_("OUTPUTHTML070 Mode invalide"));
176 }
177 $this->mode = $mode;
178 if ($mode == "row") {
179 $this->set_class_tab_selected("tab_row_selected");
180 $this->set_class_tab("tab_row");
181
182 }elseif ( $mode == "tab") {
183 $this->set_class_tab_selected("tabs_selected");
184 $this->set_class_tab("tabs");
185
186 }elseif ($mode == "accordeon") {
187 $this->set_class_tab_selected("");
188 $this->set_class_tab("tab_row");
189 } else {
190 throw new \Exception("OH186.unknow mode [$mode]");
191 }
192 return $this;
193 }
set_class_tab($class_tab)
set the CSS class of tabs, default is tabs
set_class_tab_selected($class_tab_selected)
set the CSS class of tabs, default is tabs_selected

References $mode, elseif, set_class_tab(), and set_class_tab_selected().

Referenced by __construct().

+ Here is the call graph for this function:

Field Documentation

◆ $a_tabs

Output_Html_Tab::$a_tabs
private

array of html tabs

Definition at line 38 of file output_html_tab.class.php.

◆ $class_anchor

Output_Html_Tab::$class_anchor
private

CSS class for the UL tag.

Definition at line 43 of file output_html_tab.class.php.

Referenced by get_class_anchor().

◆ $class_comment

Output_Html_Tab::$class_comment
private

CSS class for the DIV with content, default empty.

Definition at line 46 of file output_html_tab.class.php.

Referenced by get_class_comment(), and set_class_comment().

◆ $class_content_div

Output_Html_Tab::$class_content_div
private

CSS class for the DIV containing the UL default empty.

Definition at line 45 of file output_html_tab.class.php.

Referenced by get_class_content_div(), and set_class_content_div().

◆ $class_div

Output_Html_Tab::$class_div
private

CSS class for the A tag (anchor) default empty.

Definition at line 44 of file output_html_tab.class.php.

Referenced by get_class_div(), and set_class_div().

◆ $class_tab

Output_Html_Tab::$class_tab
private

for normal tab

Definition at line 39 of file output_html_tab.class.php.

Referenced by get_class_tab(), and set_class_tab().

◆ $class_tab_main

Output_Html_Tab::$class_tab_main
private

Definition at line 42 of file output_html_tab.class.php.

Referenced by get_class_tab_main(), and set_class_tab_main().

◆ $class_tab_selected

Output_Html_Tab::$class_tab_selected
private

for class_tab_selected

Definition at line 40 of file output_html_tab.class.php.

Referenced by get_class_tab_selected(), and set_class_tab_selected().

◆ $mode

Output_Html_Tab::$mode
private

mode default tabs

Definition at line 41 of file output_html_tab.class.php.

Referenced by build_js(), get_mode(), output(), and set_mode().


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