Beispiel #1
0
 public function getRequests()
 {
     $con = $this->getRequestCondition();
     $url = new Url($this->base->getSelf());
     $count = $url->getParam('count') > 0 ? $url->getParam('count') : 8;
     $count = $count > 16 ? 16 : $count;
     $result = $this->getHandler('AmunService\\User\\Friend')->getRequestResultSet($this->user->getId(), array(), $url->getParam('startIndex'), $count, $url->getParam('sortBy'), $url->getParam('sortOrder'), $con, SQL::FETCH_OBJECT);
     $paging = new Paging($url, $result);
     $this->template->assign('pagingRequests', $paging, 0);
     return $result;
 }
Beispiel #2
0
 private function getForum()
 {
     $con = $this->getRequestCondition();
     $con->add('pageId', '=', $this->page->getId());
     $url = new Url($this->base->getSelf());
     $count = $url->getParam('count') > 0 ? $url->getParam('count') : 8;
     $count = $count > 16 ? 16 : $count;
     $result = $this->getHandler()->getResultSet(array(), $url->getParam('startIndex'), $count, $url->getParam('sortBy'), $url->getParam('sortOrder'), $con, SQL::FETCH_OBJECT);
     $paging = new Paging($url, $result);
     $this->template->assign('pagingForum', $paging, 0);
     return $result;
 }
Beispiel #3
0
 public function getApplications()
 {
     $con = $this->getRequestCondition();
     $con->add('authorId', '=', $this->user->getId());
     $con->add('allowed', '=', 1);
     $url = new Url($this->base->getSelf());
     $count = $url->getParam('count') > 0 ? $url->getParam('count') : 8;
     $count = $count > 16 ? 16 : $count;
     $result = $this->getHandler('AmunService\\Oauth\\Access')->getResultSet(array(), $url->getParam('startIndex'), $count, $url->getParam('sortBy'), $url->getParam('sortOrder'), $con, SQL::FETCH_OBJECT);
     $paging = new Paging($url, $result);
     $this->template->assign('pagingApplications', $paging, 0);
     return $result;
 }
Beispiel #4
0
 private function getFriends()
 {
     $con = $this->getRequestCondition();
     $con->add('authorId', '=', $this->user->getId());
     $con->add('status', '=', Friend\Record::NORMAL);
     // search
     $search = $this->post->search('string');
     if (strlen($search) >= 3 && strlen($search) <= 16) {
         $con->add('friendName', 'LIKE', '%' . $search . '%');
     }
     $url = new Url($this->base->getSelf());
     $count = $url->getParam('count') > 0 ? $url->getParam('count') : 8;
     $count = $count > 16 ? 16 : $count;
     $result = $this->getHandler('AmunService\\User\\Friend')->getResultSet(array(), $url->getParam('startIndex'), $count, $url->getParam('sortBy'), $url->getParam('sortOrder'), $con, Sql::FETCH_OBJECT);
     $paging = new Paging($url, $result);
     $this->template->assign('pagingFriends', $paging, 0);
     return $result;
 }
Beispiel #5
0
 /**
  * @httpMethod GET
  * @path /
  */
 public function doIndex()
 {
     $url = new Url($this->base->getSelf());
     $count = $url->getParam('count') > 0 ? $url->getParam('count') : 8;
     $count = $count > 16 ? 16 : $count;
     $search = $this->get->search('string');
     if (!empty($search)) {
         $search = strlen($search) > 64 ? substr($search, 0, 64) : $search;
         $queryString = new QueryString();
         //$queryString->setDefaultOperator('AND');
         $queryString->setQuery($search);
         $query = new Query();
         $query->setQuery($queryString);
         $query->setFrom($url->getParam('startIndex'));
         $query->setLimit($count);
         $query->setHighlight(array('pre_tags' => array('<mark>'), 'post_tags' => array('</mark>'), 'fields' => array('title' => new \stdClass(), 'content' => new \stdClass())));
         // get elasticsearch client
         $client = new Client(array('host' => $this->registry['search.host'], 'port' => $this->registry['search.port']));
         $index = $client->getIndex('amun');
         $searchResult = $index->search($query);
         $result = new ResultSet($searchResult->getTotalHits(), $url->getParam('startIndex'), $count);
         foreach ($searchResult as $row) {
             $data = $row->getData();
             $data['url'] = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . $data['path'];
             $data['date'] = new DateTime('@' . $data['date']);
             // if we have an highlite overwrite the title or content
             $highlights = $row->getHighlights();
             if (isset($highlights['title'])) {
                 $data['title'] = implode(' ... ', $highlights['title']);
             }
             if (isset($highlights['content'])) {
                 $data['content'] = implode(' ... ', $highlights['content']);
             }
             $result->addData($data);
         }
         $this->template->assign('resultSearch', $result);
         $paging = new Paging($url, $result);
         $this->template->assign('pagingSearch', $paging, 0);
         return $result;
     }
 }
Beispiel #6
0
 private function getNews()
 {
     $con = $this->getRequestCondition();
     $con->add('pageId', '=', $this->page->getId());
     // archive
     $year = (int) $this->getUriFragments('year');
     $month = (int) $this->getUriFragments('month');
     // i think this software will not be used after the year 3000 if so
     // please travel back in time and slap me in the face ... nothing
     // happens ;D
     if ($year > 2010 && $year < 3000 && ($month > 0 && $month < 13)) {
         $date = new DateTime($year . '-' . ($month < 10 ? '0' : '') . $month . '-01', $this->registry['core.default_timezone']);
         $con->add('date', '>=', $date->format(DateTime::SQL));
         $con->add('date', '<', $date->add(new DateInterval('P1M'))->format(DateTime::SQL));
     }
     $url = new Url($this->base->getSelf());
     $count = $url->getParam('count') > 0 ? $url->getParam('count') : 8;
     $count = $count > 16 ? 16 : $count;
     $result = $this->getHandler()->getResultSet(array(), $url->getParam('startIndex'), $count, $url->getParam('sortBy'), $url->getParam('sortOrder'), $con, SQL::FETCH_OBJECT);
     $paging = new Paging($url, $result);
     $this->template->assign('pagingNews', $paging, 0);
     return $result;
 }
Beispiel #7
0
 private function getComments()
 {
     $con = new Condition();
     $con->add('pageId', '=', $this->page->getId());
     $con->add('refId', '=', $this->id);
     $url = new Url($this->base->getSelf());
     $count = $url->getParam('count') > 0 ? $url->getParam('count') : 8;
     $count = $count > 16 ? 16 : $count;
     $result = $this->getHandler('AmunService\\Comment')->getResultSet(array(), $url->getParam('startIndex'), $count, $url->getParam('sortBy'), $url->getParam('sortOrder'), $con, Sql::FETCH_OBJECT);
     $paging = new Paging($url, $result);
     $this->template->assign('pagingComments', $paging, 0);
     return $result;
 }
Beispiel #8
0
 private function getActivities(Account\Record $account)
 {
     $con = $this->getRequestCondition();
     $url = new Url($this->base->getSelf());
     $count = $url->getParam('count') > 0 ? $url->getParam('count') : 8;
     $count = $count > 16 ? 16 : $count;
     $result = $this->getHandler('AmunService\\User\\Activity')->getPublicResultSet($account->id, array(), $url->getParam('startIndex'), $count, $url->getParam('sortBy'), $url->getParam('sortOrder'), $con, Sql::FETCH_OBJECT);
     $paging = new Paging($url, $result, 0);
     $this->template->assign('pagingActivities', $paging);
     return $result;
 }