From 67b20c49ec4e5efb4526fc64ef679dfb6dd41e30 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Thu, 4 Oct 2018 05:10:51 +0200 Subject: 2.8 auto-tag-update + help + tabs --- class/class.w.art.php | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'class/class.w.art.php') diff --git a/class/class.w.art.php b/class/class.w.art.php index 2238f71..12ff1e3 100644 --- a/class/class.w.art.php +++ b/class/class.w.art.php @@ -73,7 +73,9 @@ class Art public function updatelien() { - $this->lien = search($this->md(true), self::DEBUT, self::FIN); + $this->lien = []; + $this->lien = array_unique(search($this->md(true), self::DEBUT, self::FIN)); + } public static function classvarlist() @@ -100,6 +102,38 @@ class Art } + public function autotaglist() + { + $pattern = "/%%(\w*)%%/"; + preg_match_all($pattern, $this->md(), $out); + return $out[1]; + + } + + public function autotaglistupdate($taglist) + { + foreach ($taglist as $tag => $artlist) { + $replace = ''; + $this->html = str_replace('%%' . $tag . '%%', $replace, $this->html); + } + } + + public function autotaglistcalc($taglist) + { + foreach ($taglist as $tag => $artlist) { + foreach ($artlist as $art) { + if(!in_array($art->id(), $this->lien('array')) && $art->id() != $this->id()) { + $this->lien[] = $art->id(); + } + } + } + } + + // _____________________________________________________ G E T ____________________________________________________ public function id($type = 'string') @@ -181,7 +215,7 @@ class Art public function md($expand = false) { - if($expand == true) { + if ($expand == true) { $md = str_replace('](=', '](?id=', $this->html); } else { $md = $this->html; @@ -192,6 +226,7 @@ class Art public function html(App $app) { $html = Markdown::defaultTransform($this->html); + $html = str_replace('href="=', 'href="?id=', $html); foreach ($this->lien('array') as $id) { $title = "Cet article n'existe pas encore"; @@ -205,7 +240,10 @@ class Art $html = str_replace($lien, $titlelien, $html); } - $html = str_replace('href="=', 'href="?id=', $html); + + + $html = str_replace('%TITLE%', $this->titre(), $html); + $html = str_replace('%DESCRIPTION%', $this->intro(), $html); $html = str_replace('href="../media/', ' class="file" target="_blank" href="../media/', $html); $html = str_replace('href="http', ' class="external" target="_blank" href="http', $html); $html = str_replace('tag = $taglist; -- cgit v1.2.3