示例#1
0
文件: Request.php 项目: visapi/amun
 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;
 }
示例#2
0
文件: Index.php 项目: visapi/amun
 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;
 }
示例#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;
 }
示例#4
0
文件: Friends.php 项目: visapi/amun
 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;
 }
示例#5
0
文件: Index.php 项目: visapi/amun
 /**
  * @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;
     }
 }
示例#6
0
文件: Index.php 项目: visapi/amun
 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;
 }
示例#7
0
文件: View.php 项目: visapi/amun
 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;
 }
示例#8
0
文件: Index.php 项目: visapi/amun
 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;
 }