示例#1
0
 /**
  * {@inheritDoc}
  */
 public function findByName($mask)
 {
     $mask = mb_strtolower($mask);
     if (filter_var($mask, FILTER_VALIDATE_INT)) {
         $needle = sprintf('((.*[^[:alnum:]])|^)%s(([^[:alnum:]].*)|$)', $mask);
     } else {
         $needle = sprintf('.*%s.*', $mask);
     }
     $conditions = array(sprintf("LOWER(%s) RLIKE ?", DbViewPages::TITLE) => $needle);
     return $this->mapper->findAll($conditions);
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function findAuthorshipsOfUser($userId, $siteId, $order = null, $paginated = false, $page = 1, $perPage = 10)
 {
     $result = $this->authorshipMapper->findAuthorshipsOfUser($userId, $siteId, $order, $paginated);
     if ($paginated) {
         $result->setCurrentPageNumber($page);
         $result->setItemCountPerPage($perPage);
     } else {
         $result = iterator_to_array($result);
     }
     if ($result) {
         $pageIds = array();
         foreach ($result as $auth) {
             $pageIds[] = $auth->getPageId();
         }
         $pages = $this->pageMapper->findAll(array(sprintf('%s IN (%s)', DbViewPages::PAGEID, implode(',', $pageIds))));
         $pageByIds = array();
         foreach ($pages as $page) {
             $pageByIds[$page->getId()] = $page;
         }
         foreach ($result as $auth) {
             $auth->setPage($pageByIds[$auth->getPageId()]);
         }
     }
     return $result;
 }
示例#3
0
 /**
  * {@inheritDoc}
  */
 public function findVotesOfUser($userId, $siteId, $order = null, $paginated = false, $page = -1, $perPage = -1)
 {
     $result = $this->mapper->findVotesOfUser($userId, $siteId, $order, $paginated);
     if ($paginated && $result && $page >= 0 && $perPage > 0) {
         $result->setCurrentPageNumber($page);
         $result->setItemCountPerPage($perPage);
     } else {
         $result = iterator_to_array($result);
     }
     if ($result) {
         $pageIds = array();
         foreach ($result as $vote) {
             $pageIds[] = $vote->getPageId();
         }
         if (count($pageIds) > 0) {
             $pages = $this->pageMapper->findAll(array(sprintf('%s IN (%s)', DbViewPages::PAGEID, implode(',', $pageIds))));
             $pageByIds = array();
             foreach ($pages as $page) {
                 $pageByIds[$page->getId()] = $page;
             }
             foreach ($result as $vote) {
                 $vote->setPage($pageByIds[$vote->getPageId()]);
             }
         }
     }
     return $result;
 }