public static function getWidgetOrderedPager($order, $pageSize, $page, $criteria = null) { $c = $criteria; if ($c == null) { $c = new Criteria(); } if ($order) { $order_dir = 1; if ($order[0] == '+' || $order[0] == '-') { $order_dir = $order[0] == '+' ? $order_dir = 1 : ($order_dir = -1); $order = substr($order, 1); } $fixed_order = "widget_log." . strtoupper($order); $should_sort = in_array($fixed_order, array(WidgetLogPeer::ID, WidgetLogPeer::KSHOW_ID, WidgetLogPeer::ENTRY_ID, WidgetLogPeer::REFERER, WidgetLogPeer::VIEWS, WidgetLogPeer::PLAYS, WidgetLogPeer::IP1_COUNT, WidgetLogPeer::CREATED_AT)); if ($should_sort) { if ($order_dir == 1) { $c->addAscendingOrderByColumn($fixed_order); } else { $c->addDescendingOrderByColumn($fixed_order); } } } $pager = new sfPropelPager('WidgetLog', $pageSize); $pager->setPeerMethod("doSelectJoinentry"); $pager->setPeerCountMethod("doCountJoinentry"); $pager->setCriteria($c); $pager->setPage($page); $pager->init(); return $pager; }
/** * This function returns a pager object holding the specified comments' entries * sorted by a given sort order. * each entry holds the kuser object of its host. * * @param int $subjectType = the type of the object the commens refers to * @param int $subjectId = the id of the object the comments refers to * @param int $pageSize = number of kshows in each page * @param int $page = the requested page * @return the pager object */ public static function getOrderedPager($commentType, $subjectId, $pageSize, $page) { $c = new Criteria(); $c->add(commentPeer::COMMENT_TYPE, $commentType); $c->add(commentPeer::SUBJECT_ID, $subjectId); $c->addDescendingOrderByColumn(commentPeer::BASE_DATE); $c->addJoin(commentPeer::KUSER_ID, kuserPeer::ID, Criteria::INNER_JOIN); $pager = new sfPropelPager('comment', $pageSize); $pager->setCriteria($c); $pager->setPage($page); $pager->setPeerMethod('doSelectJoinkuser'); $pager->setPeerCountMethod('doCountJoinkuser'); $pager->init(); return $pager; }
/** * This function returns a pager object holding the set of shows for which given user contributed media. * * @param int $kuserId = the requested user * @param int $pageSize = number of kshows in each page * @param int $page = the requested page * @return the pager object */ public static function getUserShowsPartOf($kuserId, $pageSize, $page, $order) { $c = new Criteria(); $c->addJoin(self::ID, entryPeer::KSHOW_ID, Criteria::INNER_JOIN); $c->add(entryPeer::KUSER_ID, $kuserId); $c->add(self::PRODUCER_ID, $kuserId, Criteria::NOT_EQUAL); self::setOrder($c, $order); $c->setDistinct(); $pager = new sfPropelPager('kshow', $pageSize); $pager->setCriteria($c); $pager->setPage($page); $pager->setPeerMethod('doSelectJoinkuser'); $pager->setPeerCountMethod('doCountJoinkuser'); $pager->init(); return $pager; }
public static function getUserEntries($kuserId, $pageSize, $page) { $c = new Criteria(); $c->addJoin(entryPeer::KUSER_ID, kuserPeer::ID, Criteria::INNER_JOIN); $c->add(entryPeer::KUSER_ID, $kuserId); $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP); $c->addAscendingOrderByColumn(entryPeer::CREATED_AT); $pager = new sfPropelPager('entry', $pageSize); $pager->setCriteria($c); $pager->setPage($page); $pager->setPeerMethod('doSelectJoinkuser'); $pager->setPeerCountMethod('doCountJoinkuser'); $pager->init(); return $pager; }