Output_HTML adapt to bootstrap navbar

This commit is contained in:
sparkyx 2021-05-07 17:44:09 +02:00
parent 29f557e901
commit 581940306e

View file

@ -40,6 +40,12 @@ class Output_Html_Tab
private $class_tab; //!< for normal tab
private $class_tab_selected; //!< for class_tab_selected
private $mode; //!< mode default tabs
private $class_tab_main; //! CSS class for the UL tag
private $class_anchor; //! CSS class for the A tag (anchor) default empty
private $class_div; //! CSS class for the DIV containing the UL default empty
private $class_content_div; //! CSS class for the DIV with content, default empty
private $class_comment ; //! CSS class for the comment default "tabs"
/**
*@example html_tab.test.php
*/
@ -47,18 +53,117 @@ class Output_Html_Tab
{
$this->a_tabs=[];
$this->class_tab="tabs";
$this->class_tab_main="tabs";
$this->class_tab_selected="tabs_selected";
$this->set_mode("tab");
$this->class_anchor="";
$this->class_div="";
$this->class_content_div="";
$this->class_comment="tabs";
}
/**
* @brief CSS class for the comment default "tabs"
* @return type
*/
public function get_class_comment()
{
return $this->class_comment;
}
/**
* @brief CSS class for the comment default "tabs"
* @return type
*/
public function set_class_comment($class_comment)
{
$this->class_comment=$class_comment;
return $this;
}
/**
* @brief CSS class for the DIV with content (default empty)
*/
public function get_class_content_div()
{
return $this->class_content_div;
}
/**
*@brief CSS class for the DIV with content (default empty)
*
* @param string $class_content_div
*/
public function set_class_content_div($class_content_div)
{
$this->class_content_div=$class_content_div;
return $this;
}
/**
* @brief CSS class for the DIV containing the UL
* @return string
*/
public function get_class_div()
{
return $this->class_div;
}
/**
* @brief CSS class for the DIV containing the UL
* @return string
*/
public function set_class_div($class_div)
{
$this->class_div=$class_div;
return $this;
}
/**
* @brief CSS class for the A tag (anchor)
* @return type
*/
public function get_class_anchor()
{
return $this->class_anchor;
}
/**
* @brief CSS class for the A tag (anchor)
* @param type $anchor_class
*/
public function set_class_anchor($anchor_class)
{
$this->class_anchor=$anchor_class;
$this;
}
/**
* @brief get the CSS class for the UL element
* @return type
*/
public function get_class_tab_main()
{
return $this->class_tab_main;
}
/**
* get the mode , possible value are row or tabs
* @brief set the CSS class for the UL element
* @return this
*/
public function set_class_tab_main($class_tab_main)
{
$this->class_tab_main=$class_tab_main;
return $this;
}
/**
* @brief get the mode , possible value are row or tabs , with mode = row , the
* class_content_div is set to row
* @return mixed
*/
public function get_mode()
{
return $this->mode;
return $this;
}
/**
@ -100,7 +205,6 @@ class Output_Html_Tab
public function get_class_tab()
{
return $this->class_tab;
return $this;
}
/**
@ -120,7 +224,6 @@ class Output_Html_Tab
public function get_class_tab_selected()
{
return $this->class_tab_selected;
return $this;
}
/**
@ -169,12 +272,12 @@ class Output_Html_Tab
}
/**
* When printing row , a comment is written if not empty
* When printing row , a comment is written if not empty,
* @param $p_index
*/
protected function print_comment($p_index) {
printf ('<span class="%s"> %s </span>',
$this->get_class_tab(),
$this->get_class_comment(),
$this->a_tabs[$p_index]->get_comment()
);
@ -190,7 +293,8 @@ class Output_Html_Tab
{
return;
}
printf ( '<ul class="%s">',$this->class_tab);
printf('<div class="%s">',$this->class_div);
printf ( '<ul class="%s">',$this->class_tab_main);
for ($i=0; $i<$nb; $i++)
{
printf ('<li id="tab%s" class="%s">',
@ -198,7 +302,8 @@ class Output_Html_Tab
switch ($this->a_tabs[$i]->get_mode())
{
case 'link':
printf ('<a id="%s" href="%s">',
printf ('<a class="%s" id="%s" href="%s">',
$this->class_anchor,
$this->a_tabs[$i]->get_id(),
$this->a_tabs[$i]->get_link());
printf ('<span class="title_%s"> %s </span>',
@ -209,7 +314,8 @@ class Output_Html_Tab
break;
case 'ajax':
printf('<a id="%s" onclick="%s">',
printf('<a class="%s" id="%s" onclick="%s">',
$this->class_anchor,
$this->a_tabs[$i]->get_id(),
$this->a_tabs[$i]->get_link());
printf ('<span class="title_%s"> %s </span>',
@ -223,7 +329,7 @@ class Output_Html_Tab
case 'static':
// show one , hide other
$script=$this->build_js($this->a_tabs[$i]->get_id());
printf('<a onclick="%s">', $script);
printf('<a class="%s" onclick="%s">', $this->class_anchor,$script);
printf ('<span class="title_%s"> %s </span>',
$this->get_class_tab(),
$this->a_tabs[$i]->get_title()
@ -245,6 +351,8 @@ class Output_Html_Tab
}
}
echo '</ul>';
echo '</div>';
if ( $this->get_mode()=="tab" ) {
for ($i=0;$i<$nb;$i++)
{