1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * This class has been auto-generated by the Doctrine ORM Framework |
---|
5 | */ |
---|
6 | class QuestionEcrite extends BaseQuestionEcrite |
---|
7 | { |
---|
8 | |
---|
9 | public function getLink() { |
---|
10 | sfProjectConfiguration::getActive()->loadHelpers(array('Url')); |
---|
11 | return url_for('@question_numero?numero='.$this->numero); |
---|
12 | } |
---|
13 | public function getPersonne() { |
---|
14 | return $this->getParlementaire()->getNom(); |
---|
15 | } |
---|
16 | |
---|
17 | public function __toString() { |
---|
18 | $str = substr(strip_tags($this->question), 0, 250); |
---|
19 | if (strlen($str) == 250) { |
---|
20 | $str .= '...'; |
---|
21 | } else if (!$str) $str = ""; |
---|
22 | return $str; |
---|
23 | } |
---|
24 | |
---|
25 | public function getLastDate() { |
---|
26 | if ($this->date_cloture) |
---|
27 | return $this->date_cloture; |
---|
28 | return $this->date; |
---|
29 | } |
---|
30 | |
---|
31 | public function getTitre() { |
---|
32 | $titre = 'Question N° '.$this->numero.' du '.myTools::displayShortDate($this->date).' ('.preg_replace('/\s*[\/\(].*$/', '', $this->ministere).')'; |
---|
33 | if ($this->date_cloture && !$this->reponse && date("Y-m-d") > $this->date_cloture) $titre .= ' (Retirée)'; |
---|
34 | else if (!$this->reponse) $titre .= ' (Sans réponse)'; |
---|
35 | return $titre; |
---|
36 | } |
---|
37 | |
---|
38 | public function setAuteur($depute) { |
---|
39 | $sexe = null; |
---|
40 | if (preg_match('/^\s*(M+[\s\.ml]{1})[a-z]*\s*([dA-Z].*)\s*$/', $depute, $match)) { |
---|
41 | $nom = $match[2]; |
---|
42 | if (preg_match('/M[ml]/', $match[1])) |
---|
43 | $sexe = 'F'; |
---|
44 | else $sexe = 'H'; |
---|
45 | } else $nom = preg_replace("/^\s*(.*)\s*$/", "\\1", $depute); |
---|
46 | $depute = Doctrine::getTable('Parlementaire')->findOneByNomSexeGroupeCirco($nom, $sexe); |
---|
47 | if (!$depute) print "ERROR: Auteur introuvable in ".$this->source." : ".$nom." // ".$sexe."\n"; |
---|
48 | else { |
---|
49 | $this->_set('Parlementaire', $depute); |
---|
50 | $depute->free(); |
---|
51 | } |
---|
52 | } |
---|
53 | public function uniqueMinistere() |
---|
54 | { |
---|
55 | $ministere = 'Ministère d'; |
---|
56 | if (preg_match('/(Affaires|Espace)(\s+[\wàéëêèïîôöûüÉ]+)/', $this->ministere, $match)) $ministre = $match[1].$match[2]; |
---|
57 | else { |
---|
58 | $ministre = preg_replace('/^.*\/\s*([\wàéëêèïîôöûüÉ]+)$/', '\\1', $this->ministere); |
---|
59 | $ministre = preg_replace('/^([\wàéëêèïîôöûüÉ]+)[,\s].*$/', '\\1', $ministre); |
---|
60 | } |
---|
61 | if (preg_match('/^(Affaires|Sports|Transports|Solidarités)/', $ministre)) $ministere .= 'es '; |
---|
62 | else if (preg_match('/^[AEÉIOU]/', $ministre)) $ministere .= 'e l\''; |
---|
63 | else if (preg_match('/^(Famille|Santé|Coopération|Culture|Défense|Justice|Consommation|Solidarité)/', $ministre)) $ministere .= 'e la '; |
---|
64 | else $ministere .= 'u '; |
---|
65 | if (preg_match('/^Premier/', $ministre)) $ministere = 'Premier Ministre'; |
---|
66 | else $ministere .= $ministre; |
---|
67 | return $ministere; |
---|
68 | } |
---|
69 | public function firstTheme() |
---|
70 | { |
---|
71 | $theme = preg_replace('/^\s*([\w\-àéëêèïîôöûüÉ\s]+)*[,\/:].*$/', '\\1', $this->themes); |
---|
72 | $theme = preg_replace('/^(.*)\s+$/', '\\1', $theme); |
---|
73 | return $theme; |
---|
74 | } |
---|
75 | } |
---|