Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
177 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Classe mère du module Liste.
5
 *
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
14
 */
15
class Wp extends aControleur {
16
 
17
	private $parametres = null;
18
	private $donneesTpl = array();
19
 
20
	public function initialiser() {
21
		spl_autoload_register(array($this, 'chargerClassesWp'));
22
		$this->parametres = new ParametresWp();
23
		$this->capturerParametres();
24
	}
25
 
26
	private function chargerClassesWp($classe) {
27
		$base = dirname(__FILE__).DS;
28
		$robots = Config::get('chemin_modeles').DS.'robots'.DS;
29
		$dossiers = array($base, $robots);
30
		foreach ($dossiers as $chemin) {
31
			$fichierATester = $chemin.$classe.'.php';
32
			if (file_exists($fichierATester)) {
33
				include_once $fichierATester;
34
				return null;
35
			}
36
		}
37
	}
38
 
39
	private function capturerParametres() {
40
		if (isset($_GET['article'])) {
41
			$this->parametres->article = $_GET['article'];
42
		}
43
	}
44
 
45
	public function executerActionParDefaut() {
46
		$this->executerArticleWp();
47
	}
48
 
49
	public function executerArticleWp() {
50
		$this->donneesTpl['article']['recherche'] = $this->parametres->article;
51
		$this->chargerArticle();
52
		$this->setSortie(self::RENDU_CORPS, $this->getVue('article', $this->donneesTpl));
53
	}
54
 
55
	private function chargerArticle() {
56
		$wp = new WikipediaBot('fr');
57
		$wp->chargerPage($this->parametres->article);
58
		$this->donneesTpl['article']['titre'] = $wp->getPageTitre();
59
		$this->donneesTpl['article']['taxobox'] = $wp->rendre($wp->extraireTaxobox());
60
		$this->donneesTpl['article']['intro'] = $wp->rendre($wp->getSectionParNumero(0));
61
		$this->donneesTpl['article']['caracteristiques'] = $wp->rendre($wp->getSectionParTitre('Caractéristiques'));
62
		$this->donneesTpl['article']['contenu'] = $wp->rendre($wp->getPageTxt());
63
	}
64
 
65
	private function creerPageUrl() {
66
		$page = $this->creerPageNom();
67
		$url = "http://fr.wikipedia.org/wiki/$page";
68
		return $url;
69
	}
70
 
71
	private function creerPageNom() {
72
		$page = str_replace(' ', '_', $this->parametres->article);
73
		$page = urlencode($page);
74
		return $page;
75
	}
76
}
77
?>