public function getScrollMenuItem(ConpherenceParticipant $participant, $direction) { if ($direction == 'up') { $name = pht('Load Newer Threads'); } else { $name = pht('Load Older Threads'); } $item = id(new PHUIListItemView())->addSigil('conpherence-menu-scroller')->setName($name)->setHref($this->baseURI)->setType(PHUIListItemView::TYPE_BUTTON)->setMetadata(array('participant_id' => $participant->getID(), 'conpherence_phid' => $participant->getConpherencePHID(), 'date_touched' => $participant->getDateTouched(), 'direction' => $direction)); return $item; }
/** * Handles the curious case when we are visiting a conpherence directly * by issuing two separate queries. Otherwise, additional conpherences * are fetched asynchronously. Note these can be earlier or later * (up or down), depending on what conpherence was selected on initial * load. */ private function loadParticipationWithMidCursor(ConpherenceParticipant $cursor) { $user = $this->getRequest()->getUser(); $scroll_up_participant = $this->getEmptyParticipant(); $scroll_down_participant = $this->getEmptyParticipant(); // Note this is a bit dodgy since there may be less than this // amount in either the up or down direction, thus having us fail // to fetch LIMIT in total. Whatevs for now and re-visit if we're // fine-tuning this loading process. $too_many = ceil(ConpherenceParticipantQuery::LIMIT / 2) + 1; $participant_query = id(new ConpherenceParticipantQuery())->withParticipantPHIDs(array($user->getPHID()))->setLimit($too_many); $current_selection_epoch = $cursor->getDateTouched(); $set_one = $participant_query->withParticipantCursor($cursor)->setOrder(ConpherenceParticipantQuery::ORDER_NEWER)->execute(); if (count($set_one) == $too_many) { $node = reset($set_one); unset($set_one[$node->getConpherencePHID()]); $scroll_up_participant = $node; } $set_two = $participant_query->withParticipantCursor($cursor)->setOrder(ConpherenceParticipantQuery::ORDER_OLDER)->execute(); if (count($set_two) == $too_many) { $node = end($set_two); unset($set_two[$node->getConpherencePHID()]); $scroll_down_participant = $node; } $participation = array_merge($set_one, $set_two); return array('scroll_up_participant' => $scroll_up_participant, 'scroll_down_participant' => $scroll_down_participant, 'participation' => $participation); }