Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1388 | Rev 1435 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1388 Rev 1410
Line 28... Line 28...
28
	
28
	
29
	public function getDonnees() {
29
	public function getDonnees() {
30
		$url_wiki = $this->obtenirUrlWikini();
30
		$url_wiki = $this->obtenirUrlWikini();
Line -... Line 31...
-
 
31
		$obj =  json_decode(file_get_contents($url_wiki));
-
 
32
		
31
		$obj =  json_decode(file_get_contents($url_wiki));
33
		//echo '<pre>'.print_r($obj, true).'</pre>';exit;
32
		
34
		
33
		$this->donnees['corps'] = $obj->{'texte'};
35
		$this->donnees['corps'] = $obj->{'texte'};
34
		if (strpos($this->format, "html") != false) {
36
		if (strpos($this->format, "html") != false) {
35
			$this->obtenirCorpsHtml();
37
			$this->obtenirCorpsHtml();
36
		} else {
38
		} else {
Line 37... Line 39...
37
			$this->obtenirCorpsPlain();
39
			$this->obtenirCorpsPlain();
38
		}
40
		}
Line 39... Line 41...
39
		
41
		
-
 
42
		if ($this->donnees['corps'] != "") {
40
		if ($this->donnees['corps'] != "") {
43
			$this->donnees['corps'] = preg_split('/===/', $this->donnees['corps'], -1, PREG_SPLIT_NO_EMPTY);
41
			$this->donnees['corps'] = preg_split('/===/', $this->donnees['corps'], -1, PREG_SPLIT_NO_EMPTY);
44
			
42
			
45
			$this->extraireInfosTableauCorps();
43
			$this->donnees['titre'] = $this->donnees['corps'][0];
46
			
44
			if (strpos($this->format, "html") != false) {
47
			if (strpos($this->format, "html") != false) {
45
				$this->obtenirTitreHtml();
48
				$this->obtenirTitreHtml();
Line 46... Line 49...
46
			} else {
49
			} else {
47
				$this->obtenirTitrePlain();
50
				$this->obtenirTitrePlain();
Line -... Line 51...
-
 
51
			}
-
 
52
		}
-
 
53
		
-
 
54
		return $this->donnees;
-
 
55
	}
-
 
56
	
-
 
57
	private function extraireInfosTableauCorps() {
-
 
58
		
-
 
59
		$this->donnees['titre'] = array_shift($this->donnees['corps']);
-
 
60
		$this->donnees['sources'] = array_pop($this->donnees['corps']);
-
 
61
		// array_pop "gratuit" pour supprimer la case qui ne contient que le terme "sources"
-
 
62
		array_pop($this->donnees['corps']);
-
 
63
		
-
 
64
		$corps_fmt = array();
-
 
65
		// Le tableau contient un titre de section puis son contenu, puis le titre de la section suivante
-
 
66
		// puis son contenu on dépile les éléments deux par deux pour faire un tableau associatif pas trop relou à afficher
-
 
67
		for($i = 0; $i < count($this->donnees['corps']); $i = $i+2) {
Line 48... Line 68...
48
			}
68
				$corps_fmt[$this->donnees['corps'][$i]] = $this->donnees['corps'][$i + 1];
49
		}
69
		}
50
		
70
		
51
		return $this->donnees;
71
		$this->donnees['corps'] = $corps_fmt;