aboutsummaryrefslogtreecommitdiff
path: root/w/class/modelanalyse.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-10-28 19:56:27 +0100
committervincent-peugnet <v.peugnet@free.fr>2018-10-28 19:56:27 +0100
commite17392e46259e6f2e012017987cf7c31c171488f (patch)
tree72b61b63e32819e81433e8df6f14dc92b0e3a604 /w/class/modelanalyse.php
parenta91c916248f967da2d4218b575e665242b7c975b (diff)
downloadwcms-e17392e46259e6f2e012017987cf7c31c171488f.tar.gz
wcms-e17392e46259e6f2e012017987cf7c31c171488f.zip
abstract config NWY
Diffstat (limited to 'w/class/modelanalyse.php')
-rw-r--r--w/class/modelanalyse.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/w/class/modelanalyse.php b/w/class/modelanalyse.php
new file mode 100644
index 0000000..b7819aa
--- /dev/null
+++ b/w/class/modelanalyse.php
@@ -0,0 +1,73 @@
+<?php
+
+
+
+class Modelanalyse extends Modelart
+{
+
+
+ public function __construct() {
+ parent::__construct();
+ }
+
+ public function analyseall()
+ {
+ $artlist = $this->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(['id', 'linkfrom']);
+ $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