aboutsummaryrefslogtreecommitdiff
path: root/fn
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-10-12 11:36:05 +0200
committervincent-peugnet <v.peugnet@free.fr>2018-10-12 11:36:05 +0200
commit65796d4a2349e71ca05f5f298d6f94ff792d88b2 (patch)
treeef73e39b4b54ccd36b61b783c438036761d17811 /fn
parent74ccedd6544daac0845a044b5e6d71d577578c69 (diff)
downloadwcms-65796d4a2349e71ca05f5f298d6f94ff792d88b2.tar.gz
wcms-65796d4a2349e71ca05f5f298d6f94ff792d88b2.zip
2.91 folder moves + auto summary
Diffstat (limited to 'fn')
-rw-r--r--fn/fn.w.php (renamed from fn/fn.php)39
1 files changed, 38 insertions, 1 deletions
diff --git a/fn/fn.php b/fn/fn.w.php
index 841b065..6f63a07 100644
--- a/fn/fn.php
+++ b/fn/fn.w.php
@@ -27,7 +27,7 @@ function head($title)
<head>
<meta charset="utf8" />
<meta name="viexport" content="width=device-width" />
- <link href="/css/style.css" rel="stylesheet" />
+ <link href="./css/style.css" rel="stylesheet" />
<title><?= $title ?></title>
</head>
<?php
@@ -139,5 +139,42 @@ function str_clean(string $string)
return str_replace(' ', '_', strtolower(strip_tags($string)));
}
+function sumparser($text)
+{
+ preg_match_all('#<h([1-6]) id="(\w+)">(.+)</h[1-6]>#iU', $text, $out);
+
+
+ $sum = [];
+ foreach ($out[2] as $key => $value) {
+ $sum[$value][$out[1][$key]] = $out[3][$key];
+ }
+
+
+ $sumstring = '';
+ $last = 0;
+ foreach ($sum as $title => $list) {
+ foreach ($list as $h => $link) {
+ if($h > $last) {
+ for ($i = 1; $i <= ($h - $last); $i++) {
+ $sumstring .= '<ul>';
+ }
+ $sumstring .= '<li><a href="#'.$title.'">'.$link.'</a></li>' ;
+ } elseif ($h < $last) {
+ for ($i = 1; $i <= ($last - $h); $i++) {
+ $sumstring .= '</ul>';
+ }
+ $sumstring .= '<li><a href="#'.$title.'">'.$link.'</a></li>' ;
+ } elseif ($h = $last) {
+ $sumstring .= '<li><a href="#'.$title.'">'.$link.'</a></li>' ;
+ }
+ $last = $h;
+ }
+ }
+ for ($i = 1; $i <= ($last); $i++) {
+ $sumstring .= '</ul>';
+ }
+ return $sumstring;
+}
+
?> \ No newline at end of file