From d7f3313ff4514e38c9f53439cd1a1287e56e45f7 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 11 Nov 2018 17:19:26 +0100 Subject: reboot folder --- app/class/modelanalyse.php | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/class/modelanalyse.php (limited to 'app/class/modelanalyse.php') diff --git a/app/class/modelanalyse.php b/app/class/modelanalyse.php new file mode 100644 index 0000000..379c41a --- /dev/null +++ b/app/class/modelanalyse.php @@ -0,0 +1,73 @@ +getlister(); + + $artlist2 = []; + foreach ($artlist as $art) { + $art->setlinkfrom($this->analyselinkfrom($art)); + $artlist2[] = $art; + } + foreach ($artlist2 as $art) { + $art->setlinkto($this->analyselinkto($art->id(), $artlist)); + $this->update($art); + } + } + + + public function analyse(Art2 $art) + { + $art->setlinkfrom($this->analyselinkfrom($art)); + + $artlist = $this->getlister(); + $art->setlinkto($this->analyselinkto($art->id(), $artlist)); + + return $art; + } + + + + + public function analyselinkto($id, $artlist) + { + //analyse les liens vers cet article en fouillant tout les linkfrom de la bdd, génere un tableau à stocker dans l'article + $linkto = []; + foreach ($artlist as $link) { + if (in_array($id, $link->linkfrom('array')) && $id != $link->id()) { + $linkto[] = $link->id(); + } + } + return $linkto; + } + + public function analyselinkfrom(Art2 $art) + { + $linkfrom = []; + foreach (self::TEXT_ELEMENTS as $element) { + preg_match_all('#\]\((\?id=|=)(\w+)\)#', $art->$element(), $out); + $linkfrom = array_merge($linkfrom, $out[2]); + } + return array_unique($linkfrom); + + } + +} + + + + + + + +?> \ No newline at end of file -- cgit v1.2.3