diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-10-04 05:10:51 +0200 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-10-04 05:10:51 +0200 |
commit | 67b20c49ec4e5efb4526fc64ef679dfb6dd41e30 (patch) | |
tree | 289a6da21e036b62c881bc505a079d5d64dc1c20 /class/class.w.art.php | |
parent | c3c4be4a4efd1404aad19797c15d2a9a6ffe29a6 (diff) | |
download | wcms-67b20c49ec4e5efb4526fc64ef679dfb6dd41e30.tar.gz wcms-67b20c49ec4e5efb4526fc64ef679dfb6dd41e30.zip |
2.8 auto-tag-update + help + tabs
Diffstat (limited to 'class/class.w.art.php')
-rw-r--r-- | class/class.w.art.php | 48 |
1 files changed, 43 insertions, 5 deletions
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 = '<ul>'; + foreach ($artlist as $art) { + $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->intro() . '">' . $art->titre() . '</a></li>'; + } + $replace .= '</ul>'; + $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('<img src="/', '<img src="../media/', $html); @@ -315,13 +353,13 @@ class Art public function settag($tag) { - if(is_string($tag)) { + if (is_string($tag)) { if (strlen($tag) < self::LEN and is_string($tag)) { $tag = strip_tags(trim(strtolower($tag))); $tag = str_replace('*', '', $tag); $tag = str_replace(' ', '', $tag); - + $taglist = explode(",", $tag); $taglist = array_filter($taglist); $this->tag = $taglist; |