1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * parlementaire actions. |
---|
5 | * |
---|
6 | * @package cpc |
---|
7 | * @subpackage parlementaire |
---|
8 | * @author Your name here |
---|
9 | * @version SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $ |
---|
10 | */ |
---|
11 | class parlementaireActions extends sfActions |
---|
12 | { |
---|
13 | public static function imagetograyscale($im) |
---|
14 | { |
---|
15 | if (imageistruecolor($im)) { |
---|
16 | imagetruecolortopalette($im, false, 256); |
---|
17 | } |
---|
18 | |
---|
19 | for ($c = 0; $c < imagecolorstotal($im); $c++) { |
---|
20 | $col = imagecolorsforindex($im, $c); |
---|
21 | $gray = round(0.299 * $col['red'] + 0.587 * $col['green'] + 0.114 * $col['blue']); |
---|
22 | imagecolorset($im, $c, $gray, $gray, $gray); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | public static function horizontalFlip(&$img) { |
---|
27 | $size_x = imagesx($img); |
---|
28 | $size_y = imagesy($img); |
---|
29 | $temp = imagecreatetruecolor($size_x, $size_y); |
---|
30 | $x = imagecopyresampled($temp, $img, 0, 0, ($size_x-1), 0, $size_x, $size_y, 0-$size_x, $size_y); |
---|
31 | if ($x) { |
---|
32 | $img = $temp; |
---|
33 | } |
---|
34 | else { |
---|
35 | die("Unable to flip image"); |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | public function executePhoto(sfWebRequest $request) |
---|
40 | { |
---|
41 | $rayon = 50; //pour la vignette |
---|
42 | $bordure = 10; |
---|
43 | $work_height = 500; //pour éviter des sentiments d'antialiasing |
---|
44 | |
---|
45 | $slug = $request->getParameter('slug'); |
---|
46 | $parlementaire = Doctrine_Query::create()->from('Parlementaire P')->where('slug = ?', $slug)->fetchOne(); |
---|
47 | $this->forward404Unless($parlementaire); |
---|
48 | $file = tempnam(sys_get_temp_dir(), 'Parl'); |
---|
49 | $photo = $parlementaire->photo; |
---|
50 | if (!strlen($photo)) { |
---|
51 | copy(sfConfig::get('sf_root_dir').'/web/images/xneth/avatar_depute.jpg', $file); |
---|
52 | } else { |
---|
53 | $fh = fopen($file, 'w'); |
---|
54 | fwrite($fh ,$photo); |
---|
55 | fclose($fh); |
---|
56 | } |
---|
57 | list($width, $height, $image_type) = getimagesize($file); |
---|
58 | if (!$width || !$height) { |
---|
59 | copy(sfConfig::get('sf_root_dir').'/web/images/xneth/avatar_depute.jpg', $file); |
---|
60 | list($width, $height, $image_type) = getimagesize($file); |
---|
61 | } |
---|
62 | |
---|
63 | $this->getResponse()->setHttpHeader('content-type', 'image/png'); |
---|
64 | $this->setLayout(false); |
---|
65 | $newheight = ceil($request->getParameter('height', $height)/10)*10; |
---|
66 | if ($newheight > 250) |
---|
67 | $newheight = 250; |
---|
68 | |
---|
69 | $iorig = imagecreatefromjpeg($file); |
---|
70 | $ih = imagecreatetruecolor($work_height*$width/$height, $work_height); |
---|
71 | if ($parlementaire->fin_mandat) |
---|
72 | self::imagetograyscale($iorig); |
---|
73 | imagecopyresampled($ih, $iorig, 0, 0, 0, 0, $work_height*$width/$height, $work_height, $width, $height); |
---|
74 | $width = $work_height*$width/$height; |
---|
75 | $height = $work_height; |
---|
76 | imagedestroy($iorig); |
---|
77 | unlink($file); |
---|
78 | |
---|
79 | if ((isset($parlementaire->autoflip) && $parlementaire->autoflip) XOR $request->getParameter('flip')) { |
---|
80 | self::horizontalFlip($ih); |
---|
81 | } |
---|
82 | |
---|
83 | $groupe = $parlementaire->groupe_acronyme; |
---|
84 | if ($groupe && !$parlementaire->fin_mandat) { |
---|
85 | imagefilledellipse($ih, $width-$rayon, $height-$rayon, $rayon+$bordure, $rayon+$bordure, imagecolorallocate($ih, 255, 255, 255)); |
---|
86 | if ($groupe == 'GDR') { |
---|
87 | imagefilledarc($ih, $width-$rayon, $height-$rayon, $rayon, $rayon, 45, 225, imagecolorallocate($ih, 0, 170, 0), IMG_ARC_EDGED); |
---|
88 | imagefilledarc($ih, $width-$rayon, $height-$rayon, $rayon, $rayon, 225, 45, imagecolorallocate($ih, 240, 0, 0), IMG_ARC_EDGED); |
---|
89 | }else if ($groupe == 'SRC') { |
---|
90 | imagefilledellipse($ih, $width-$rayon, $height-$rayon, $rayon, $rayon, imagecolorallocate($ih, 255, 20, 160)); |
---|
91 | }else if ($groupe == 'UMP') { |
---|
92 | imagefilledellipse($ih, $width-$rayon, $height-$rayon, $rayon, $rayon, imagecolorallocate($ih, 0, 0, 170)); |
---|
93 | }else if ($groupe == 'NC') { |
---|
94 | imagefilledellipse($ih, $width-$rayon, $height-$rayon, $rayon, $rayon, imagecolorallocate($ih, 0, 160, 255)); |
---|
95 | }else if ($groupe == 'NI') { |
---|
96 | imagefilledellipse($ih, $width-$rayon, $height-$rayon, $rayon, $rayon, imagecolorallocate($ih, 255, 255, 255)); |
---|
97 | } |
---|
98 | } |
---|
99 | |
---|
100 | if ($newheight) { |
---|
101 | $newwidth = $newheight*$width/$height; |
---|
102 | $image = imagecreatetruecolor($newwidth, $newheight); |
---|
103 | imagecopyresampled($image, $ih, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
---|
104 | imagedestroy($ih); |
---|
105 | $ih = $image; |
---|
106 | } |
---|
107 | $this->image = $ih; |
---|
108 | $this->getResponse()->addCacheControlHttpHeader('max_age=60'); |
---|
109 | $this->getResponse()->setHttpHeader('Expires', $this->getResponse()->getDate(time()*2)); |
---|
110 | } |
---|
111 | |
---|
112 | public function executeIndex(sfWebRequest $request) { |
---|
113 | $request->setParameter('rss', array(array('link' => '@commentaires_rss', 'title'=>'Les derniers commentaires sur NosDéputés.fr'))); |
---|
114 | } |
---|
115 | |
---|
116 | public function executeRandom(sfWebRequest $request) |
---|
117 | { |
---|
118 | $p = Doctrine::getTable('Parlementaire')->createQuery('p')->where('fin_mandat IS NULL')->orderBy('rand()')->limit(1)->fetchOne(); |
---|
119 | return $this->redirect('@parlementaire?slug='.$p['slug']); |
---|
120 | } |
---|
121 | |
---|
122 | public function executeShow(sfWebRequest $request) |
---|
123 | { |
---|
124 | $this->parlementaire = Doctrine::getTable('Parlementaire')->findOneBySlug($request->getParameter('slug')); |
---|
125 | $this->forward404Unless($this->parlementaire); |
---|
126 | $request->setParameter('rss', array(array('link' => '@parlementaire_rss?slug='.$this->parlementaire->slug, 'title'=>'L\'activité de '.$this->parlementaire->nom), |
---|
127 | array('link' => '@parlementaire_rss_commentaires?slug='.$this->parlementaire->slug, 'title'=>'Les derniers commentaires portant sur l\'activité de '.$this->parlementaire->nom) |
---|
128 | )); |
---|
129 | $this->response->addMeta('keywords', $this->parlementaire->nom.' '.$this->parlementaire->nom_circo.' '.$this->parlementaire->type.' '.$this->parlementaire->groupe_acronyme.' Assemblée nationale'); |
---|
130 | $this->response->addMeta('description', 'Pour tout connaître de l\'activité de '.$this->parlementaire->nom.' à l\'Assemblée Nationale. '.$this->parlementaire->nom.' est '.$this->parlementaire->getLongStatut().' à l\'Assemblée Nationale.'); |
---|
131 | $this->response->addMeta('parlementaire_id', 'd'.$this->parlementaire->id); |
---|
132 | $this->response->addMeta('parlementaire_id_url', 'http://www.nosdeputes.fr/id/'.'d'.$this->parlementaire->id); |
---|
133 | |
---|
134 | $this->commissions_permanentes = array(); |
---|
135 | $this->missions = array(); |
---|
136 | |
---|
137 | foreach ($this->parlementaire->getResponsabilites() as $resp) { |
---|
138 | if (in_array($resp->organisme_id, array(2, 11, 13, 22, 204, 211, 212, 237))) { |
---|
139 | array_push($this->commissions_permanentes, $resp); |
---|
140 | }else{ |
---|
141 | array_push($this->missions, $resp); |
---|
142 | } |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | public function executeId(sfWebRequest $request) |
---|
147 | { |
---|
148 | $id = preg_replace('/^d/', '', $request->getParameter('id')); |
---|
149 | $p = Doctrine::getTable('Parlementaire')->find($id); |
---|
150 | if ($type = $request->getParameter('type')) { |
---|
151 | return $this->redirect('api/parlementaire?type='.$type.'&slug='.$p->slug.'&textplain='.$request->getParameter('textplain')); |
---|
152 | } |
---|
153 | return $this->redirect('@parlementaire?slug='.$p->slug); |
---|
154 | } |
---|
155 | |
---|
156 | public function executeList(sfWebRequest $request) { |
---|
157 | $query = Doctrine::getTable('Parlementaire')->createQuery('p'); |
---|
158 | $query->orderBy('p.nom_de_famille ASC'); |
---|
159 | $this->parlementaires = array(); |
---|
160 | foreach ($query->execute() as $depute) { |
---|
161 | $lettre = $depute->nom_de_famille[0]; |
---|
162 | if (isset($this->parlementaires[$lettre])) $this->parlementaires[$lettre][] = $depute; |
---|
163 | else $this->parlementaires[$lettre] = array($depute); |
---|
164 | } |
---|
165 | $ctquery = Doctrine_Query::create() |
---|
166 | ->from('Parlementaire p') |
---|
167 | ->select('count(distinct p.id) as ct') |
---|
168 | ->fetchOne(); |
---|
169 | $this->total = $ctquery['ct']; |
---|
170 | $ctquery = Doctrine_Query::create() |
---|
171 | ->from('Parlementaire p') |
---|
172 | ->select('count(distinct p.id) as ct') |
---|
173 | ->where('p.fin_mandat IS NULL') |
---|
174 | ->orWhere('p.fin_mandat < p.debut_mandat') |
---|
175 | ->fetchOne(); |
---|
176 | $this->actifs = $ctquery['ct']; |
---|
177 | } |
---|
178 | |
---|
179 | public function executeListProfession(sfWebRequest $request) { |
---|
180 | $this->exact = 0; |
---|
181 | $this->prof = strip_tags(strtolower($request->getParameter('search'))); |
---|
182 | if ($this->prof == "") { |
---|
183 | $this->parlementaires = array(); |
---|
184 | $this->citoyens = array(); |
---|
185 | } |
---|
186 | else { |
---|
187 | $query = Doctrine::getTable('Parlementaire')->createQuery('p') |
---|
188 | ->addSelect('p.fin_mandat') |
---|
189 | ->where('p.profession LIKE ?', $this->prof) |
---|
190 | ->orderBy('p.nom_de_famille ASC'); |
---|
191 | $this->parlementaires = $query->execute(); |
---|
192 | if (count($this->parlementaires) > 0) |
---|
193 | $this->exact = 1; |
---|
194 | else { |
---|
195 | $query = Doctrine::getTable('Parlementaire')->createQuery('p') |
---|
196 | ->addSelect('p.fin_mandat') |
---|
197 | ->where('p.profession LIKE ?', '%'.$this->prof.'%') |
---|
198 | ->orderBy('p.profession ASC') |
---|
199 | ->addOrderBy('p.nom_de_famille ASC'); |
---|
200 | $this->parlementaires = $query->execute(); |
---|
201 | } |
---|
202 | $query = Doctrine::getTable('Citoyen')->createQuery('c') |
---|
203 | ->where('c.is_active = true') |
---|
204 | ->andWhere('c.activite LIKE ?', '%'.$this->prof.'%') |
---|
205 | ->orderBy('c.activite ASC') |
---|
206 | ->addOrderBy('c.login'); |
---|
207 | $this->citoyens = $query->execute(); |
---|
208 | } |
---|
209 | } |
---|
210 | public function executeListGroupe(sfWebRequest $request) { |
---|
211 | $acro = strtolower($request->getParameter('acro')); |
---|
212 | $nom = Organisme::getNomByAcro($acro); |
---|
213 | $this->forward404Unless($nom); |
---|
214 | |
---|
215 | $query = Doctrine::getTable('Parlementaire')->createQuery('p') |
---|
216 | ->select('p.*, po.fonction as fonction, po.importance as imp') |
---|
217 | ->leftJoin('p.ParlementaireOrganisme po') |
---|
218 | ->leftJoin('po.Organisme o') |
---|
219 | ->where('p.fin_mandat IS NULL') |
---|
220 | ->andWhere('p.groupe_acronyme = ?', $acro) |
---|
221 | ->andWhere('o.type = ?', 'groupe') |
---|
222 | ->andWhere('o.nom = ?', $nom); |
---|
223 | $query->orderBy("imp DESC, p.nom_de_famille ASC"); |
---|
224 | $this->parlementaires = array(); |
---|
225 | $this->total = 0; |
---|
226 | foreach ($query->execute() as $depute) { |
---|
227 | $this->total++; |
---|
228 | $imp = $depute->imp; |
---|
229 | if (isset($this->parlementaires[$imp])) $this->parlementaires[$imp][] = $depute; |
---|
230 | else $this->parlementaires[$imp] = array($depute); |
---|
231 | } |
---|
232 | $query2 = Doctrine::getTable('Organisme')->createQuery('o'); |
---|
233 | $query2->where('o.nom = ?', $nom); |
---|
234 | $this->orga = $query2->fetchOne(); |
---|
235 | } |
---|
236 | |
---|
237 | public function executeListOrganisme(sfWebRequest $request) { |
---|
238 | $orga = $request->getParameter('slug'); |
---|
239 | $this->forward404Unless($orga); |
---|
240 | $this->orga = Doctrine::getTable('Organisme')->createQuery('o') |
---|
241 | ->where('o.slug = ?', $orga)->fetchOne(); |
---|
242 | $this->forward404Unless($this->orga); |
---|
243 | |
---|
244 | $pageS = $request->getParameter('pages', 1); |
---|
245 | $pageR = $request->getParameter('page', 1); |
---|
246 | if ($pageS == 1) { |
---|
247 | if ($pageR == 1) |
---|
248 | $this->page = "home"; |
---|
249 | else $this->page = "rapports"; |
---|
250 | } else $this->page = "seances"; |
---|
251 | if ($this->page === "home") { |
---|
252 | $query = Doctrine::getTable('Parlementaire')->createQuery('p') |
---|
253 | ->select('p.*, po.fonction as fonction, po.importance as imp') |
---|
254 | ->leftJoin('p.ParlementaireOrganisme po') |
---|
255 | ->leftJoin('po.Organisme o') |
---|
256 | ->where('o.slug = ?', $orga) |
---|
257 | ->andWhere('p.fin_mandat IS NULL') |
---|
258 | ->orderBy("po.importance DESC, p.nom_de_famille ASC"); |
---|
259 | $this->parlementaires = array(); |
---|
260 | $this->total = 0; |
---|
261 | foreach ($query->execute() as $depute) { |
---|
262 | $this->total++; |
---|
263 | $imp = $depute->imp; |
---|
264 | if (isset($this->parlementaires[$imp])) $this->parlementaires[$imp][] = $depute; |
---|
265 | else $this->parlementaires[$imp] = array($depute); |
---|
266 | } |
---|
267 | } |
---|
268 | if ($this->page === "home" || $this->page === "seances") { |
---|
269 | $query2 = Doctrine::getTable('Seance')->createQuery('s') |
---|
270 | ->leftJoin('s.Organisme o') |
---|
271 | ->where('o.slug = ?', $orga) |
---|
272 | ->orderBy('s.date DESC, s.moment ASC'); |
---|
273 | $this->pagerSeances = Doctrine::getTable('Seance')->getPager($request, $query2); |
---|
274 | } |
---|
275 | if ($this->page === "home" || $this->page === "rapports") { |
---|
276 | $query3 = Doctrine::getTable('Texteloi')->createQuery('t') |
---|
277 | ->leftJoin('t.Organisme o') |
---|
278 | ->where('o.slug = ?', $orga) |
---|
279 | ->orderBy('t.numero DESC, t.annexe ASC'); |
---|
280 | $this->pagerRapports = new sfDoctrinePager('Texteloi',10); |
---|
281 | $this->pagerRapports->setQuery($query3); |
---|
282 | $this->pagerRapports->setPage($pageR); |
---|
283 | $this->pagerRapports->init(); |
---|
284 | } |
---|
285 | } |
---|
286 | |
---|
287 | public function executeTag(sfWebRequest $request) { |
---|
288 | $this->tquery = null; |
---|
289 | if ($this->tag = $request->getParameter('tags')) { |
---|
290 | $tags = split(',', $this->tag); |
---|
291 | |
---|
292 | $this->parlementaires = Doctrine::getTable('Intervention') |
---|
293 | ->createQuery('i') |
---|
294 | ->select('i.id, p.*, count(i.id) as nb') |
---|
295 | ->addFrom('i.Parlementaire p, Tagging tg, Tag t') |
---|
296 | ->where('p.id IS NOT NULL') |
---|
297 | ->andWhere('tg.taggable_id = i.id AND t.id = tg.tag_id') |
---|
298 | ->andWhere('tg.taggable_model = ?', 'Intervention') |
---|
299 | ->andWhereIn('t.name', $tags) |
---|
300 | ->groupBy('p.id') |
---|
301 | ->orderBy('nb DESC') |
---|
302 | ->fetchArray(); |
---|
303 | } |
---|
304 | $this->response->setTitle('Les parlementaires par tag'); |
---|
305 | } |
---|
306 | |
---|
307 | public function executePlot(sfWebRequest $request) |
---|
308 | { |
---|
309 | $slug = $request->getParameter('slug'); |
---|
310 | $this->session = $request->getParameter('time'); |
---|
311 | $this->forward404Unless(preg_match('/^(lastyear|2\d{3}2\d{3})$/', $this->session)); |
---|
312 | $this->parlementaire = Doctrine::getTable('Parlementaire')->findOneBySlug($slug); |
---|
313 | $this->forward404Unless($this->parlementaire); |
---|
314 | $this->sessions = Doctrine_Query::create() |
---|
315 | ->select('s.session') |
---|
316 | ->from('Seance s') |
---|
317 | ->leftJoin('s.Presences p') |
---|
318 | ->where('p.parlementaire_id = ?', $this->parlementaire->id) |
---|
319 | ->andWhere('s.session IS NOT NULL AND s.session <> ""') |
---|
320 | ->groupBy('s.session')->fetchArray(); |
---|
321 | } |
---|
322 | |
---|
323 | public static function topSort($a, $b) { |
---|
324 | if ($b[$_GET['sort']]['value'] == $a[$_GET['sort']]['value']) |
---|
325 | return strcmp($a[0]['nom_de_famille'], $b[0]['nom_de_famille']); |
---|
326 | else return $b[$_GET['sort']]['value'] - $a[$_GET['sort']]['value']; |
---|
327 | } |
---|
328 | |
---|
329 | public function executeTop(sfWebRequest $request) |
---|
330 | { |
---|
331 | $qp = Doctrine::getTable('Parlementaire')->createQuery('p'); |
---|
332 | $this->top_link = '@top_global_sorted?'; |
---|
333 | if (($o = $request->getParameter('organisme'))) { |
---|
334 | $this->top_link = '@top_organisme_global_sorted?organisme='.$o.'&'; |
---|
335 | $organisme = Doctrine::getTable('Organisme')->findOneBySlug($o); |
---|
336 | $this->forward404Unless($organisme); |
---|
337 | $ids = array(); |
---|
338 | foreach(Doctrine::getTable('ParlementaireOrganisme')->createQuery('po') |
---|
339 | ->select('DISTINCT parlementaire_id as id') |
---|
340 | ->where('organisme_id = ?', $organisme->id)->fetchArray() as $id) { |
---|
341 | $ids[] = $id['id']; |
---|
342 | } |
---|
343 | $qp->whereIn('id', $ids); |
---|
344 | } |
---|
345 | $qp->andWhere('fin_mandat IS NULL') |
---|
346 | ->andWhere('debut_mandat < ?', date('Y-m-d', time()-60*60*24*365/2)) |
---|
347 | ->orderBy('nom_de_famille'); |
---|
348 | $parlementaires = $qp->fetchArray(); |
---|
349 | unset($qp); |
---|
350 | $this->tops = array(); |
---|
351 | foreach($parlementaires as $p) { |
---|
352 | $tops = unserialize($p['top']); |
---|
353 | $id = $p['id']; |
---|
354 | $i = 0; |
---|
355 | $this->tops[$id][$i++] = $p; |
---|
356 | |
---|
357 | foreach(array_keys($tops) as $key) { |
---|
358 | $this->tops[$id][$i]['value'] = $tops[$key]['value']; |
---|
359 | |
---|
360 | $this->tops[$id][$i]['style'] = ''; |
---|
361 | if ($tops[$key]['rank'] < 151) |
---|
362 | $this->tops[$id][$i]['style'] = ' style="color:green" '; |
---|
363 | else if ($tops[$key]['rank'] > 577 - 151) |
---|
364 | $this->tops[$id][$i]['style'] = ' style="color:red" '; |
---|
365 | $i++; |
---|
366 | } |
---|
367 | } |
---|
368 | $this->ktop = array_keys($tops); |
---|
369 | $this->sort = $this->getRequestParameter('sort'); |
---|
370 | if (($_GET['sort'] = $this->sort)) { |
---|
371 | usort($this->tops, 'parlementaireActions::topSort'); |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | public static function dateSort($a, $b) { |
---|
376 | $datea = $a->updated_at; |
---|
377 | $dateb = $b->updated_at; |
---|
378 | if (get_class($a) === 'Texteloi') |
---|
379 | $datea = $a->date; |
---|
380 | if (get_class($b) === 'Texteloi') |
---|
381 | $datea = $b->date; |
---|
382 | return str_replace('-', '', $dateb) - str_replace('-', '', $datea); |
---|
383 | } |
---|
384 | public function executeRss(sfWebRequest $request) { |
---|
385 | $this->parlementaire = Doctrine::getTable('Parlementaire')->findOneBySlug($request->getParameter('slug')); |
---|
386 | $this->forward404Unless($this->parlementaire); |
---|
387 | |
---|
388 | $request->setParameter('query', 'tag=parlementaire='.$this->parlementaire); |
---|
389 | $request->setParameter('title', preg_replace('/%/', $this->parlementaire->nom, $request->getParameter('title'))); |
---|
390 | |
---|
391 | if ($o = $request->getParameter('object_type')) |
---|
392 | $request->setParameter('query', $request->getParameter('query').' object_type='.$o); |
---|
393 | $request->setParameter('format', 'rss'); |
---|
394 | return $this->forward('solr', 'search'); |
---|
395 | |
---|
396 | |
---|
397 | $this->limit = 30; |
---|
398 | |
---|
399 | $news = array(); |
---|
400 | $elements = 0; |
---|
401 | if ($request->getParameter('Intervention')) { |
---|
402 | $elements++; |
---|
403 | foreach(Doctrine::getTable('Intervention')->createQuery('i') |
---|
404 | ->where('i.parlementaire_id = ?', $this->parlementaire->id) |
---|
405 | ->limit($this->limit)->orderBy('updated_at DESC')->execute() |
---|
406 | as $n) |
---|
407 | $news[] = $n; |
---|
408 | } |
---|
409 | if ($request->getParameter('QuestionEcrite')) { |
---|
410 | $elements++; |
---|
411 | foreach(Doctrine::getTable('QuestionEcrite')->createQuery('q') |
---|
412 | ->where('q.parlementaire_id = ?', $this->parlementaire->id) |
---|
413 | ->limit($this->limit)->orderBy('updated_at DESC')->execute() |
---|
414 | as $n) |
---|
415 | $news[] = $n; |
---|
416 | } |
---|
417 | if ($request->getParameter('Amendement')) { |
---|
418 | $elements++; |
---|
419 | foreach(Doctrine::getTable('Amendement')->createQuery('a') |
---|
420 | ->leftJoin('a.ParlementaireAmendement pa') |
---|
421 | ->where('pa.parlementaire_id = ?', $this->parlementaire->id) |
---|
422 | ->andWhere('a.sort <> ?', 'Rectifié') |
---|
423 | ->orderBy('updated_at DESC')->limit($this->limit)->execute() |
---|
424 | as $n) |
---|
425 | $news[] = $n; |
---|
426 | } |
---|
427 | if ($request->getParameter('Document')) { |
---|
428 | $elements++; |
---|
429 | $docquery = Doctrine::getTable('Texteloi')->createQuery('t') |
---|
430 | ->leftJoin('t.ParlementaireTexteloi pt') |
---|
431 | ->where('pt.parlementaire_id = ?', $this->parlementaire->id); |
---|
432 | $type = $request->getParameter('type'); |
---|
433 | if ($type) { |
---|
434 | $lois = array('Proposition de loi', 'Proposition de résolution'); |
---|
435 | if ($type === "loi") |
---|
436 | $docquery->andWhere('t.type = ? OR t.type = ?', $lois); |
---|
437 | else if ($type === "rap") |
---|
438 | $docquery->andWhere('t.type != ? AND t.type != ?', $lois); |
---|
439 | } |
---|
440 | foreach($docquery->orderBy('date DESC')->limit($this->limit)->execute() |
---|
441 | as $n) |
---|
442 | $news[] = $n; |
---|
443 | } |
---|
444 | |
---|
445 | if ($elements > 1) usort($news, 'parlementaireActions::dateSort'); |
---|
446 | |
---|
447 | $this->news = $news; |
---|
448 | $this->feed = new sfRssFeed(); |
---|
449 | } |
---|
450 | public function executeError404() { |
---|
451 | } |
---|
452 | } |
---|