芝麻web文件管理V1.00
编辑当前文件:/home/p/r/i/prismawe/www/resupres/application/classes/controller/candidat.php
request->redirect('candidat/list'); } public function action_list() { //on récupère tout les candidats $candidats = ORM::factory('candidat')->find_all(); //on passe tout les candidats à la vue pour affichage $this->template->content = View::factory('candidat/list'); $this->template->content->candidats = $candidats; } public function action_unique() { $this->template->menuActif = 'encyclopedie'; if ($this->request->param('id') != '') { $candidat = ORM::factory('candidat', $this->request->param('id')); if ($candidat->loaded()) { $nom = URL::title($candidat->nom, '_', true); $prenom = URL::title($candidat->prenom, '_', true); $parti = URL::title($candidat->parti->nom, '_', true); if ($this->request->param('nom') != $nom OR $this->request->param('prenom') != $prenom OR $this->request->param('parti') != $parti) { $this->request->redirect('candidat/unique/' . $candidat->id . '-' . $nom . '-' . $prenom . '-' . $parti); } $duels = ORM::factory('duel') ->where('dateDebut', '<', DB::expr('current_date')) ->and_where_open() ->where('candidat1_id', '=', $candidat->id) ->or_where('candidat2_id', '=', $candidat->id) ->and_where_close() ->order_by('id', 'desc') ->find_all(); if ($candidat->isCandidate) { $this->template->metaDescription = 'Fiche du candidat ' . $candidat->prenom . ' ' . $candidat->nom . ' à l\'élection des présidentielles 2012 et membre du ' . $candidat->parti->nom; } else { $this->template->metaDescription = 'Fiche du personnage politique ' . $candidat->prenom . ' ' . $candidat->nom . ' membre du ' . $candidat->parti->nom; } $this->template->metaKeywords = 'Statistiques, sondages, présidentielles 2012, candidats 2012, election 2012,' . $candidat->prenom . ' ' . $candidat->nom . ', sarkozy 2012, le pen 2012, ségolène royale 2012, 2012,' . $candidat->parti->nom . ''; $this->template->pageTitle = $candidat->prenom . ' ' . $candidat->nom . ' ' . $candidat->parti->nom; $this->template->content = View::factory('candidat/unique'); $voteRes = array(); if (count($duels) > 0) { $i = 0; foreach ($duels as $duel) { $nbVoteC1 = ORM::factory('vote') ->where('duel_id', '=', $duel->id) ->and_where('candidat_id', '=', $duel->candidat1_id) ->and_where('candidat_id', '!=', 0) ->find_all() ->count(); $nbVoteC2 = ORM::factory('vote') ->where('duel_id', '=', $duel->id) ->and_where('candidat_id', '=', $duel->candidat2_id) ->and_where('candidat_id', '!=', 0) ->find_all() ->count(); $nbVoteBlanc = 0; if ($nbVoteC1 > $nbVoteC2) { $vainqueur = $duel->candidat1_id; } else if ($nbVoteC2 > $nbVoteC1) { $vainqueur = $duel->candidat2_id; } else { //$vainqueur = ORM::factory('duel'); $vainqueur = '-1'; } // if($row[0]['nbre']>$row[1]['nbre']){ // $vainqueur = $row[0]['candidat_id']; // }else{ // $vainqueur = $row[1]['candidat_id']; // } $voteRes[$duel->id] = $vainqueur; $i++; } $this->template->content->duels = $duels; $this->template->content->voteRes = $voteRes; } else { $this->template->content->duels = 0; } $this->template->content->candidat = $candidat; /* * Flux rss google par mot clé http://news.google.fr/news?output=rss&q=MON_MOT_CLE * http://fr.news.search.yahoo.com/rss?ei=UTF-8&p=MOT_CLE&fr=news_sb_hd&source=yahoo */ /*$url = 'http://fr.news.search.yahoo.com/rss?ei=UTF-8&p=' . URL::title($candidat->parti->nom, '%20', true); //.'&fr=news_sb_hd&source=yahoo'; $rss_file = file_get_contents($url); $xml = new SimpleXMLElement($rss_file); $this->template->content->xml = $xml;//*/ } else { $this->request->redirect('candidat/list'); } } else { $this->request->redirect('candidat/list'); } } }