hydrate($datas); $this->readoptions(); } public function readoptions() { parse_str(htmlspecialchars_decode($this->options), $datas); $this->hydrate($datas); } /** * Generate a Summary based on header ids. Need to use `$this->headerid` before to scan text * * @return string html list with anchor link */ public function sumparser() { $sumstring = ''; $minlevel = $this->min - 1; $prevlevel = $minlevel; foreach ($this->sum as $header) { if ($header->level < $this->min || $header->level > $this->max) { // not in the accepted range, skiping this header. continue; }; for ($i = $header->level; $i > $prevlevel; $i--) { $sumstring .= ''; } if ($header->level <= $prevlevel) { $sumstring .= '
  • '; } $sumstring .= "id\">$header->title"; $prevlevel = $header->level; } for ($i = $minlevel; $i < $prevlevel; $i++) { $sumstring .= "
  • "; } return $sumstring; } // ________________________________________________ G E T ________________________________________________________ public function fullmatch() { return $this->fullmatch; } public function options() { return $this->options; } public function element() { return $this->element; } // ________________________________________________ S E T ________________________________________________________ public function setfullmatch(string $fullmatch) { $this->fullmatch = $fullmatch; } public function setoptions(string $options) { if (!empty($options)) { $this->options = $options; } } public function setmin($min) { $min = intval($min); if ($min >= 1 && $min <= 6) { $this->min = $min; } } public function setmax($max) { $max = intval($max); if ($max >= 1 && $max <= 6) { $this->max = $max; } } public function setsum(array $sum) { $this->sum = $sum; } public function setelement(string $element) { if (in_array($element, Model::TEXT_ELEMENTS)) { $this->element = $element; } } }