. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * Only an HTMLTableMain can create an HTMLTableSuperHeader. * @since 0.84 **/ class HTMLTableSuperHeader extends HTMLTableHeader { /// The headers of each column private $headerSets = []; /// The table that owns the current super header private $table; /** * @param HTMLTableMain $table HTMLTableMain object: table owning the current header * @param string $name the name of the header * @param string $content see inc/HTMLTableEntity#__construct() * @param HTMLTableSuperHeader $father HTMLTableSuperHeader objet (default NULL) **/ function __construct(HTMLTableMain $table, $name, $content, HTMLTableSuperHeader $father = null) { $this->table = $table; parent::__construct($name, $content, $father); } /** * Compute the Least Common Multiple of two integers * * @param $first * @param $second * * @return integer LCM of $first and $second **/ private static function LCM($first, $second) { $result = $first * $second; while ($first > 1) { $reste = $first % $second; if ($reste == 0) { $result = $result / $second; break; // leave when LCM is found } $first = $second; $second = $reste; } return $result; } function isSuperHeader() { return true; } /** * @see HTMLTableHeader::getHeaderAndSubHeaderName() **/ function getHeaderAndSubHeaderName(&$header_name, &$subheader_name) { $header_name = $this->getName(); $subheader_name = ''; } function getCompositeName() { return $this->getName().':'; } protected function getTable() { return $this->table; } /** * compute the total number of current super header colspan: it is the Least Common * Multiple of the colspan of each subHeader it owns. * * @param integer $number the colspan for this header given by the group **/ function updateNumberOfSubHeader($number) { $this->setColSpan(self::LCM($number, $this->getColSpan())); } /** * The super headers always have to be displayed, conversely to sub headers * * @return true **/ function hasToDisplay() { return true; } }