From e802d5204b96d645ec3d40b81b4a8bdc6e0ee675 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 4 Nov 2019 23:31:31 +0100 Subject: refactor: switch to psr-4 autoloading --- 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..9f656f5 --- /dev/null +++ b/app/class/Modelanalyse.php @@ -0,0 +1,73 @@ +getlister(); + + $pagelist2 = []; + foreach ($pagelist as $page) { + $page->setlinkfrom($this->analyselinkfrom($page)); + $pagelist2[] = $page; + } + foreach ($pagelist2 as $page) { + $page->setlinkto($this->analyselinkto($page->id(), $pagelist)); + $this->update($page); + } + } + + + public function analyse(Page $page) + { + $page->setlinkfrom($this->analyselinkfrom($page)); + + $pagelist = $this->getlister(); + $page->setlinkto($this->analyselinkto($page->id(), $pagelist)); + + return $page; + } + + + + + public function analyselinkto($id, $pagelist) + { + //analyse les liens vers cet pageicle en fouillant tout les linkfrom de la bdd, génere un tableau à stocker dans l'pageicle + $linkto = []; + foreach ($pagelist as $link) { + if (in_array($id, $link->linkfrom('array')) && $id != $link->id()) { + $linkto[] = $link->id(); + } + } + return $linkto; + } + + public function analyselinkfrom(Page $page) + { + $linkfrom = []; + foreach (self::TEXT_ELEMENTS as $element) { + preg_match_all('#\]\((\?id=|=)(\w+)\)#', $page->$element(), $out); + $linkfrom = array_merge($linkfrom, $out[2]); + } + return array_unique($linkfrom); + + } + +} + + + + + + + +?> \ No newline at end of file -- cgit v1.2.3