本文整理汇总了PHP中EntityManager::getPartidos方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getPartidos方法的具体用法?PHP EntityManager::getPartidos怎么用?PHP EntityManager::getPartidos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::getPartidos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeRanking
public function executeRanking(sfWebRequest $request)
{
$culture = sfContext::getInstance()->getUser()->getCulture('es');
$institucion = $request->getParameter("institucion");
$i = $request->getParameter("i");
$page = $request->getParameter("page", "");
$order = $request->getParameter("o", "");
if ($order == 'pd' || $page == '1') {
$qs = '';
foreach ($request->getParameterHolder()->getAll() as $key => $value) {
if ($key != 'module' && $key != 'action' && !($order == 'pd' && $key == 'o' || $page == '1' && $key == 'page')) {
$qs .= ($qs ? '&' : '?') . "{$key}={$value}";
}
}
$this->redirect("politico/ranking{$qs}", 301);
}
if ($i != '') {
$url = $this->generateRankingUrl($institucion, $i);
$this->redirect($url);
}
$this->order = $order ? $order : 'pd';
$page = $page ? $page : 1;
$filter = array('type' => 'partido', 'partido' => false, 'institucion' => $institucion, 'culture' => $culture, 'page' => $page, 'order' => $this->order);
$this->getUser()->setAttribute("filter_" . Partido::NUM_ENTITY, $filter);
$this->partidosPager = EntityManager::getPartidos($institucion, $culture, $page, $this->order, EntityManager::PAGE_SIZE, &$totalUp, &$totalDown);
$this->totalUp = $totalUp;
$this->totalDown = $totalDown;
$this->institucion = $institucion;
$this->institucionAC = '';
if ($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($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();
}
/* Lista de instituciones
$c = new Criteria();
$c->addAscendingOrderByColumn(InstitucionPeer::ORDEN);
$c->add(InstitucionPeer::IS_MAIN, true);
$this->instituciones = InstitucionPeer::doSelect($c);
Fin Lista de instituciones */
//$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 = "partido/ranking{$params}";
$this->pageTitle = sfContext::getInstance()->getI18N()->__('Ranking de partidos', array());
$this->pageTitle .= !$this->institucion || $this->institucion == '0' || !isset($aInstitucion) ? '' : ", " . $aInstitucion->getNombre();
if ($this->order && $this->order != 'pd') {
switch ($this->order) {
case 'pa':
$orderTxt = sfContext::getInstance()->getI18N()->__('votos positivos inverso');
break;
case 'nd':
$orderTxt = sfContext::getInstance()->getI18N()->__('votos negativos');
break;
case 'na':
$orderTxt = sfContext::getInstance()->getI18N()->__('votos negativos inverso');
break;
}
$this->pageTitle .= ", {$orderTxt}";
}
if ($page && $page != 1) {
$this->pageTitle .= " " . sfContext::getInstance()->getI18N()->__('(Pág. %1%)', array('%1%' => $page));
}
$this->title = $this->pageTitle . ' - Voota';
$this->response->addMeta('Title', $this->title);
$description = sfContext::getInstance()->getI18N()->__('Los partidos más votados en Voota');
$description .= !$this->institucion || $this->institucion == '0' || !isset($aInstitucion) ? '' : ", " . $aInstitucion->getNombre();
$description .= ': ';
if ($this->partidosPager->getNbResults() > 0) {
foreach ($this->partidosPager->getResults() as $idx => $partido) {
if ($idx < 5) {
$description .= ($idx == 0 ? "" : ", ") . $partido->getAbreviatura();
}
}
}
if ($this->partidosPager->getNbResults() > 5) {
$description .= ', ...';
}
//.........这里部分代码省略.........
示例2: execute
//.........这里部分代码省略.........
$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()) {
$idx++;
$this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?page={$idx}", true), $culture);
}
# ranking de polis filtrados por partido
$c = new Criteria();
$c->add(PartidoPeer::IS_ACTIVE, true);
$partidos = PartidoPeer::doSelect($c);
foreach ($partidos as $partido) {
$this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura(), true), $culture);
$pager = EntityManager::getPoliticos($partido->getAbreviatura(), false, $culture);
$idx = 1;
while ($idx < $pager->getLastPage()) {
$idx++;
$this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&page={$idx}", true), $culture);
}
# ranking de polis filtrados por partido e insti
$c = new Criteria();
$c->add(InstitucionPeer::IS_ACTIVE, true);
$c->addJoin(PoliticoInstitucionPeer::INSTITUCION_ID, InstitucionPeer::ID);
$c->addJoin(PoliticoPeer::ID, PoliticoInstitucionPeer::POLITICO_ID);
$c->add(PoliticoPeer::PARTIDO_ID, $partido->getId());
$instis = InstitucionPeer::doSelect($c);
foreach ($instis as $insti) {
$this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&institucion=" . $insti->getVanity(), true), $culture);
$pager = EntityManager::getPoliticos($partido->getAbreviatura(), $insti->getVanity(), $culture);
$idx = 1;
while ($idx < $pager->getLastPage()) {
$idx++;
$this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
}
}
}
# ranking de polis filtrados por insti
$c = new Criteria();
$c->add(InstitucionPeer::IS_ACTIVE, true);
$instis = InstitucionPeer::doSelect($c);
foreach ($instis as $insti) {
$this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=all&institucion=" . $insti->getVanity(), true), $culture);
$pager = EntityManager::getPoliticos(false, $insti->getVanity(), $culture);
$idx = 1;
while ($idx < $pager->getLastPage()) {
$idx++;
$this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=all&institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
}
}
// **************** ranking PARTIDOS **********************
$this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking", true), $culture);
$pager = EntityManager::getPartidos(false, $culture);
$idx = 1;
while ($idx < $pager->getLastPage()) {
$idx++;
$this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?page={$idx}", true), $culture);
}
$c = new Criteria();
$c->add(InstitucionPeer::IS_ACTIVE, true);
$instis = InstitucionPeer::doSelect($c);
foreach ($instis as $insti) {
$this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?institucion=" . $insti->getVanity(), true), $culture);
$pager = EntityManager::getPartidos($insti->getVanity(), $culture);
$idx = 1;
while ($idx < $pager->getLastPage()) {
$idx++;
$this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
}
}
// **************** elecciones **********************
$c = new Criteria();
$convocatorias = ConvocatoriaPeer::doSelect($c);
foreach ($convocatorias as $convocatoria) {
$this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('eleccion/show?vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
$used = array();
foreach ($convocatoria->getListasJoinCircunscripcion() as $geoLista) {
if (!in_array($geoLista->getCircunscripcion()->getGeo(), $used)) {
$used[] = $geoLista->getCircunscripcion()->getGeo();
$this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('eleccion/show?geo=' . $geoLista->getCircunscripcion()->getGeo()->getNombre() . '&vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
}
$this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('lista/show?partido=' . $geoLista->getPartido()->getAbreviatura() . '&geo=' . $geoLista->getCircunscripcion()->getGeo()->getNombre() . '&vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
}
}
//}
$this->closeAll($culture);
}
示例3: entities_party
private function entities_party($data)
{
$sort = $this->getRequestParameter("sort", 'positive');
$page = $this->getRequestParameter("page", '1');
$limit = $this->getRequestParameter("limit", self::PAGE_SIZE);
if ($sort != 'positive' && $sort != 'negative') {
throw new BadRequestException('Invalid sort value.');
}
$pager = EntityManager::getPartidos("", $this->getUser()->getCulture("es"), $page, $sort == 'positive' ? "pd" : "nd", $limit);
$entities = array();
foreach ($pager->getResults() as $partido) {
$entities[] = new Entity($partido);
}
return $entities;
}