当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityManager::getPoliticos方法代码示例

本文整理汇总了PHP中EntityManager::getPoliticos方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getPoliticos方法的具体用法?PHP EntityManager::getPoliticos怎么用?PHP EntityManager::getPoliticos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityManager的用法示例。


在下文中一共展示了EntityManager::getPoliticos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeRanking

 public function executeRanking(sfWebRequest $request)
 {
     $p = $request->getParameter("p");
     $i = $request->getParameter("i");
     $culture = $this->getUser()->getCulture("es");
     $partido = $request->getParameter("partido", false);
     $institucion = $request->getParameter("institucion", false);
     $redir = false;
     if ($institucion === ALL_FORM_VALUE) {
         $redir = true;
         $institucion = false;
     }
     $page = $request->getParameter("page", "");
     $order = $request->getParameter("o", "");
     $this->forward404Unless(!($order && $order != 'pd' && $order != 'pa' && $order != 'nd' && $order != 'na'));
     if ($order == 'pd' || $page == '1' || !$institucion && $partido == ALL_URL_STRING) {
         $qs = '';
         foreach ($request->getParameterHolder()->getAll() as $key => $value) {
             if ($key != 'module' && $key != 'action' && !($order == 'pd' && $key == 'o' || $page == '1' && $key == 'page') && ($key != 'partido' || ($institucion || $partido != ALL_URL_STRING))) {
                 $qs .= ($qs ? '&' : '?') . "{$key}={$value}";
             }
         }
         $this->redirect("politico/ranking{$qs}", 301);
     }
     $this->order = $order ? $order : 'pd';
     $page = $page ? $page : 1;
     if (!$partido) {
         $partido = ALL_FORM_VALUE;
     }
     if (!$institucion) {
         $institucion = ALL_FORM_VALUE;
     }
     $this->partido = ALL_FORM_VALUE;
     $this->institucion = ALL_FORM_VALUE;
     if ($p != '' || $i != '' || $redir) {
         $url = $this->generateRankingUrl($partido, $institucion, $p, $i, $page);
         $this->redirect($url);
     }
     $this->partidoAC = '';
     if ($partido && $partido != ALL_URL_STRING) {
         $this->partido = $partido;
         $aPartidoCriteria = new Criteria();
         $aPartidoCriteria->add(PartidoPeer::ABREVIATURA, $this->partido);
         $aaPartido = PartidoPeer::doSelectOne($aPartidoCriteria);
         $this->forward404Unless($aaPartido);
         $this->partidoAC = $aaPartido->getAbreviatura() . ', ' . $aaPartido->getNombre();
     } else {
         $this->partido = ALL_URL_STRING;
     }
     $this->institucionAC = '';
     if ($institucion && $institucion != ALL_URL_STRING) {
         $this->institucion = $institucion;
         $aInstitucionCriteria = new Criteria();
         $aInstitucionCriteria->addJoin(array(InstitucionPeer::ID, InstitucionI18nPeer::CULTURE), array(InstitucionI18nPeer::ID, "'{$culture}'"), Criteria::INNER_JOIN);
         $aInstitucionCriteria->add(InstitucionI18nPeer::VANITY, $this->institucion);
         $aInstitucion = InstitucionPeer::doSelectOne($aInstitucionCriteria);
         $this->forward404Unless($aInstitucion);
         if ($aInstitucion->getVanity() != $institucion) {
             $url = $this->generateRankingUrl($partido, $aInstitucion->getVanity());
             $params = $request->getParameterHolder()->getAll();
             foreach ($params as $key => $value) {
                 if ($key != 'module' && $key != 'action' && $key != 'partido' && $key != 'institucion') {
                     $url .= "&{$key}={$value}";
                 }
             }
             $this->redirect($url, 301);
         }
         $this->institucionAC = $aInstitucion->getNombre();
     }
     $filter = array('type' => 'politico', 'partido' => $partido, 'institucion' => $institucion, 'culture' => $culture, 'page' => $page, 'order' => $this->order);
     $this->getUser()->setAttribute("filter_" . Politico::NUM_ENTITY, $filter);
     $this->politicosPager = EntityManager::getPoliticos($partido, $institucion, $culture, $page, $this->order, EntityManager::PAGE_SIZE, &$totalUp, &$totalDown);
     $this->totalUp = $totalUp;
     $this->totalDown = $totalDown;
     $rule = sfContext::getInstance()->getRouting()->getCurrentRouteName();
     $params = "";
     foreach ($request->getParameterHolder()->getAll() as $name => $value) {
         if ($name != 'module' && $name != 'action' && $name != 'o' && $name != 'page') {
             if ($params === "") {
                 $params .= "?";
             } else {
                 $params .= "&";
             }
             $params .= "{$name}={$value}";
         }
     }
     $this->route = "politico/ranking{$params}";
     $this->pageTitle = sfContext::getInstance()->getI18N()->__('Ranking de políticos', array());
     $this->pageTitle .= $this->partido == 'all' ? '' : ', ' . $this->partido;
     $this->pageTitle .= $this->institucion == '0' ? '' : ", ";
     if (isset($aInstitucion)) {
         $this->pageTitle .= $aInstitucion->getNombre();
     }
     switch ($this->order) {
         case 'pa':
             $orderTxt = sfContext::getInstance()->getI18N()->__('votos positivos inverso');
             break;
         case 'nd':
             $orderTxt = sfContext::getInstance()->getI18N()->__('votos negativos');
             break;
//.........这里部分代码省略.........
开发者ID:voota,项目名称:voota,代码行数:101,代码来源:actions.class.php

示例2: execute

 protected function execute($arguments = array(), $options = array())
 {
     $sfContext = sfContext::createInstance($this->configuration);
     $controller = $sfContext->getController();
     $this->cultures = array('ca' => 'cat', 'es' => 'es');
     $culture = $options['culture'];
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     //foreach($this->cultures as $culture => $ext){
     $sfContext->getUser()->setCulture($culture);
     // **************** HOME **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@homepage", true), $culture);
     // **************** Ultimas opiniones **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_politicos_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_partidos_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_propuestas_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_otras_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_politicos_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_partidos_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_propuestas_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_otras_feed_{$culture}", true), $culture);
     // **************** varias **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@about", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@rules", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@search", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@contact", true), $culture);
     // **************** Fichas POLITICOS **********************
     $c = new Criteria();
     //$c->setLimit(5);
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         $this->writeToSitemap("politico-{$culture}", $controller->genUrl("politico/show?id=" . $politico->getVanity(), true), $culture);
     }
     // **************** Fichas PARTIDOS **********************
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("partido-{$culture}", $controller->genUrl("partido/show?id=" . $partido->getAbreviatura(), true), $culture);
     }
     // **************** Fichas PROPUESTAS **********************
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         $this->writeToSitemap("propuesta-{$culture}", $controller->genUrl("propuesta/show?id=" . $propuesta->getVanity(), true), $culture);
     }
     // **************** Fichas USUARIOS **********************
     $c = new Criteria();
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $this->writeToSitemap("usuario-{$culture}", $controller->genUrl("perfil/show?username=" . $usuario->getProfile()->getVanity(), true), $culture);
     }
     // **************** feeds POLITICOS **********************
     $c = new Criteria();
     //$c->setLimit(5);
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         $this->writeToSitemap("politico-feed-{$culture}", $controller->genUrl("politico/show?id=" . $politico->getVanity(), true), $culture);
     }
     // **************** feeds PARTIDOS **********************
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("partido-feed-{$culture}", $controller->genUrl("partido/feed?id=" . $partido->getAbreviatura(), true), $culture);
     }
     // **************** feeds PROPUESTAS **********************
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         $this->writeToSitemap("propuesta-feed-{$culture}", $controller->genUrl("propuesta/feed?id=" . $propuesta->getVanity(), true), $culture);
     }
     // **************** feeds USUARIOS **********************
     $c = new Criteria();
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $this->writeToSitemap("usuario-feed-{$culture}", $controller->genUrl("perfil/feed?username=" . $usuario->getProfile()->getVanity(), true), $culture);
     }
     // **************** ranking PROPUESTAS **********************
     $this->writeToSitemap("propuesta-ranking-{$culture}", $controller->genUrl("propuesta/ranking", true), $culture);
     $pager = EntityManager::getPropuestas($culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("propuesta-ranking-{$culture}", $controller->genUrl("propuesta/ranking?page={$idx}", true), $culture);
     }
     // **************** ranking POLITICOS **********************
     $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking", true), $culture);
     $pager = EntityManager::getPoliticos(false, false, $culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
//.........这里部分代码省略.........
开发者ID:voota,项目名称:voota,代码行数:101,代码来源:genSitemapTask.class.php

示例3: entities_politician

 private function entities_politician($data)
 {
     $sort = $this->getRequestParameter("sort", 'positive');
     $page = $this->getRequestParameter("page", '1');
     $limit = $this->getRequestParameter("limit", self::PAGE_SIZE);
     $institution = $this->getRequestParameter("institution", '');
     $party = $this->getRequestParameter("party", '');
     if ($sort != 'positive' && $sort != 'negative') {
         throw new BadRequestException('Invalid sort value.');
     }
     $pager = EntityManager::getPoliticos($party, $institution, $this->getUser()->getCulture("es"), $page, $sort == 'positive' ? "pd" : "nd", $limit);
     $entities = array();
     foreach ($pager->getResults() as $politico) {
         $entities[] = new Entity($politico);
     }
     return $entities;
 }
开发者ID:voota,项目名称:voota,代码行数:17,代码来源:actions.class.php


注:本文中的EntityManager::getPoliticos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。