diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2020-01-21 17:41:48 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2020-01-21 17:41:48 +0100 |
commit | e2ad3e4c6be5a8110b10114a574ab3b4a3212ec2 (patch) | |
tree | 82ef5abe92933d836c45a430516f4fbbd3a5ce33 /app | |
parent | 937e9c12ee8ca097813ffe022f097ae1c7d47744 (diff) | |
download | wcms-e2ad3e4c6be5a8110b10114a574ab3b4a3212ec2.tar.gz wcms-e2ad3e4c6be5a8110b10114a574ab3b4a3212ec2.zip |
summary limits fix issue #35
Diffstat (limited to 'app')
-rw-r--r-- | app/class/Controllerinfo.php | 12 | ||||
-rw-r--r-- | app/class/Modelrender.php | 12 |
2 files changed, 11 insertions, 13 deletions
diff --git a/app/class/Controllerinfo.php b/app/class/Controllerinfo.php index fd8232c..7b27cea 100644 --- a/app/class/Controllerinfo.php +++ b/app/class/Controllerinfo.php @@ -5,8 +5,7 @@ use Michelf\MarkdownExtra; class Controllerinfo extends Controller { - - public function __construct($render) { + public function __construct($render){ parent::__construct($render); } @@ -20,21 +19,14 @@ class Controllerinfo extends Controller $htmlman = file_get_contents(Model::MAN_FILE); $htmlman = $render->rendermanual($htmlman); - $summary = $render->sumparser(2, 3); - + $summary = $render->sumparser(2, 4); $this->showtemplate('info', ['version' => getversion(), 'manual' => $htmlman, 'summary' => $summary]); } - } } - - - - - } diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index aa59416..e321568 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -45,7 +45,7 @@ class Modelrender extends Modelpage public function rendermanual(string $text) : string { $text = $this->markdown($text); - $text = $this->headerid($text, 4); + $text = $this->headerid($text, 5); return $text; } @@ -485,17 +485,23 @@ class Modelrender extends Modelpage /** * Generate a Summary based on header ids. Need to use `$this->headerid` before to scan text * + * @param int $min Minimum header deepness to start the summary : Between 1 and 6. + * @param int $max Maximum header deepness to start the summary : Between 1 and 6. + * * @return string html list with anchor link */ - function sumparser(int $start = 1, int $end = 6) : string + function sumparser(int $min = 1, int $max = 6) : string { + $min = $min >= 1 && $min <= 6 && $min <= $max ? $min : 1; + $end = $max >=1 && $max <= 6 && $max >= $min ? $max : 6; + $sum = $this->sum; $filteredsum = []; foreach ($sum as $key => $menu) { $deepness = array_keys($menu)[0]; - if($deepness >= $start && $deepness <= $end) { + if($deepness >= $min && $deepness <= $max) { $filteredsum[$key] = $menu; } } |