/**
  * Pagination - Displays 12 Images Per page
  *
  * @var string
  */
 public function PaginatedImages()
 {
     $getImages = $this->owner->Images()->sort('SortOrder DESC');
     $getRequest = $this->getRequest();
     $paginatedImages = PaginatedList::create($getImages, $getRequest)->setPageLength(12);
     return $paginatedImages;
 }
 /**
  * Displays a list of all members on the site that belong to the selected
  * groups.
  *
  * @return string
  */
 public function handleList($request)
 {
     $fields = $this->parent->Fields()->filter('MemberListVisible', true);
     $members = $this->parent->Groups()->relation('Members');
     $members = new PaginatedList($members, $request);
     $list = new PaginatedList(new ArrayList(), $request);
     $list->setLimitItems(false);
     $list->setTotalItems($members->getTotalItems());
     foreach ($members as $member) {
         $cols = new ArrayList();
         $public = $member->getPublicFields();
         $link = $this->Link($member->ID);
         foreach ($fields as $field) {
             if ($field->PublicVisibility == 'MemberChoice' && !in_array($field->MemberField, $public)) {
                 $value = null;
             } else {
                 $value = $member->{$field->MemberField};
             }
             $cols->push(new ArrayData(array('Name' => $field->MemberField, 'Title' => $field->Title, 'Value' => $value, 'Sortable' => $member->hasDatabaseField($field->MemberField), 'Link' => $link)));
         }
         $list->push($member->customise(array('Fields' => $cols)));
     }
     $this->data()->Title = _t('MemberProfiles.MEMBERLIST', 'Member List');
     $this->data()->Parent = $this->parent;
     $controller = $this->customise(array('Members' => $list));
     return $controller->renderWith(array('MemberProfileViewer_list', 'MemberProfileViewer', 'Page'));
 }
 /**
  * Get items connected to this news holder paginated
  *
  * @param int $limit  Amount of items
  * @param int $per_page  Items per page
  */
 function NewsItemsPaginated($limit = 999, $per_page = 10)
 {
     $news = $this->NewsItems($limit);
     $items = new PaginatedList($news, $this->request);
     $items->setPageLength($per_page);
     return $items;
 }
 public function PaginatedChildren($limit = 9)
 {
     $list = $this->Children();
     $pages = new PaginatedList($list, $this->getRequest());
     $pages->setpageLength($limit);
     return $pages;
 }
 public function PaginatedArticles()
 {
     $list = ArticlePage::get();
     $pages = new PaginatedList($list, $this->request);
     $pages->setPageLength(6);
     return $pages;
 }
 /**
  * Show the "login" page
  *
  * @return string Returns the "login" page as HTML code.
  */
 public function donators()
 {
     // Vorerst keine Seite erstellt
     $Members = new PaginatedList(self::members()->filter(array("Type" => 'donator')), $this->request);
     $Members->setPageLength(10);
     return $this->customise(new ArrayData(array("Members" => $Members, "SearchForm" => $this->SearchForm())))->renderWith(array('Find_donators', 'Find', $this->stat('template_main'), $this->stat('template')));
 }
 /**
  * Show module list on page
  *
  * @return Array .
  */
 public function ModuleList()
 {
     $modules = ExtensionData::get()->filter(array('Type' => 'Module', 'Accepted' => '1'))->sort('Name');
     $paginatedList = new PaginatedList($modules, $this->request);
     $paginatedList->setPageLength(4);
     return $paginatedList;
 }
 public function PaginatedPages($num = 15)
 {
     $PaginatedPages = new PaginatedList($this->getCityHotels(), $this->request);
     $PaginatedPages->setPageLength($num);
     // Debug::show($PaginatedPages);
     // break;
     return $PaginatedPages;
 }
 static function FilterByDate($class, $filter, $limit, $order)
 {
     $filter .= ' AND (CURDATE() >= FromDate AND (CURDATE() <= ToDate || ToDate IS NULL))';
     $entries = $class::get()->where($filter)->sort($order);
     $list = new PaginatedList($entries, Controller::curr()->request);
     $list->setPageLength($limit);
     return $list;
 }
 /**
  * @param string $type future, all, past
  * @return PaginatedList
  */
 public function getPaginatedItems()
 {
     $items = $this->getItems();
     $paginatedList = new PaginatedList($items, $this->request);
     $paginatedList->setPageLength($this->stat('page_length'));
     $paginatedList->setLimitItems(true);
     return $paginatedList;
 }
 protected function results($phrase = null)
 {
     $products = new DataList("Product");
     $products = $products->setDataQuery($this->query($phrase))->sort("Popularity", "DESC");
     $products = $this->getSorter()->sortList($products);
     $products = new PaginatedList($products, $this->request);
     $products->setPageLength(16);
     return $products;
 }
 /**
  * @return PaginatedList
  */
 public function PaginatedPages()
 {
     // Protect against "Division by 0" error
     if ($this->Items == null || $this->Items == 0) {
         $this->Items = 1;
     }
     $pagination = new PaginatedList($this->AllChildren(), Controller::curr()->request);
     $pagination->setPageLength($this->Items);
     return $pagination;
 }
 public function getOrders($limit = 10)
 {
     if ($Member = Member::currentUser()) {
         $Orders = $Member->Orders()->sort('TransactionDate', 'DESC');
         $list = new PaginatedList($Orders, Controller::curr()->request);
         $list->setPageLength($limit);
         return $list;
     }
     return false;
 }
 /**
  * Show the "login" page
  *
  * @return string Returns the "login" page as HTML code.
  */
 public function requests()
 {
     // Vorerst keine Seite erstellt
     $Contacts = new PaginatedList(Member::currentUser()->OpenConfirmations(), $this->request);
     $Contacts->setPageLength(10);
     if ($Contacts->getTotalItems() == 0) {
         return $this->redirect('contacts/index');
     }
     return $this->customise(new ArrayData(array("Title" => _t('Contacts.REQUESTSTITLE', 'Contacts.REQUESTSTITLE'), "Contacts" => $Contacts)))->renderWith(array('Contacts_requests', 'Contacts', $this->stat('template_main'), $this->stat('template')));
 }
 function Events()
 {
     $where = "StartDate >= CURRENT_DATE";
     $where .= " OR EndDate >= CURRENT_DATE";
     if (!$this->ManageAllEvents) {
         $filter = array("CalendarPageID" => $this->ID);
     }
     $entries = new PaginatedList(CalendarEntry::get()->filter($filter)->Sort('StartDate')->where($where), $this->request);
     $entries->setPageLength(4);
     return $entries;
 }
Example #16
0
 public function PaginatedHeatmapsList()
 {
     $member = Member::currentUser();
     $paginatedList = new PaginatedList(Heatmaps::get()->filter(array('MemberID' => $member->ID, 'Deleted' => 0))->sort('Created', 'DESC'), $this->request);
     if (isset($_GET['start'])) {
         if ($paginatedList->CurrentPage() > $paginatedList->TotalPages()) {
             $this->redirect($paginatedList->LastLink());
         }
     }
     return $paginatedList;
 }
 public function PaginatedNews()
 {
     if ($this->NewsExcerptsPerPage) {
         $NewsExcerptsPerPage = $this->NewsExcerptsPerPage;
     } else {
         $NewsExcerptsPerPage = '15';
     }
     $PaginatedNews = new PaginatedList($this->GetNewsPages(), $this->request);
     $PaginatedNews->setPageLength($NewsExcerptsPerPage);
     return $PaginatedNews;
 }
 public function getNewsItems($pageSize = 10)
 {
     $items = DataObject::get('NewsPage', "ParentID = {$this->ID}")->sort('Date', 'DESC');
     $category = $this->getCategory();
     if ($category) {
         $items = $items->filter('CategoryID', $category->ID);
     }
     $list = new PaginatedList($items, $this->request);
     $list->setPageLength($pageSize);
     return $list;
 }
 /**
  * Show the "terms" page
  *
  * @return string Returns the "terms" page as HTML code.
  */
 public function chat()
 {
     if (!($o_Member = Member::currentUser()->Friend($this->urlParams['ID']))) {
         return $this->redirect('message/index');
     }
     // Update Many Many relation as read
     Member::currentUser()->Friends()->add($o_Member, array('UnreadMessage' => false));
     $Chat = new PaginatedList($o_Member->Messages(), $this->request);
     $Chat->setPageLength(10);
     return $this->customise(new ArrayData(array("ChatPartner" => sprintf(_t('Message.CHATPARTNER', 'Message.CHATPARTNER'), $o_Member->Nickname), "Chat" => $Chat, "MessageForm" => $this->MessageForm())))->renderWith(array('Message_chat', 'Message', $this->stat('template_main'), $this->stat('template')));
 }
 /**
  * Return the submissions from the site
  *
  * @return PaginatedList
  */
 public function getSubmissions($page = 1)
 {
     $record = $this->form->getRecord();
     $submissions = $record->getComponents('Submissions', null, "\"Created\" DESC");
     $query = DB::query(sprintf("SELECT COUNT(*) AS \"CountRows\" FROM \"SubmittedForm\" WHERE \"ParentID\" = '%d'", $record->ID));
     $totalCount = 0;
     foreach ($query as $r) {
         $totalCount = $r['CountRows'];
     }
     $list = new PaginatedList($submissions);
     $list->setCurrentPage($page);
     $list->setPageLength(10);
     $list->setTotalItems($totalCount);
     return $list;
 }
 public function PaginatedNews()
 {
     if (Controller::curr()->ClassName == 'NewsHolder') {
         $NewsExcerptsPerPage = Controller::curr()->NewsExcerptsPerPage;
     }
     if (Controller::curr()->ClassName == 'NewsPage') {
         $NewsExcerptsPerPage = Controller::curr()->Parent->NewsExcerptsPerPage;
     }
     if ($NewsExcerptsPerPage == '0') {
         $NewsExcerptsPerPage = '15';
     }
     $PaginatedNews = new PaginatedList($this->getNewsPages(), Controller::curr()->request);
     $PaginatedNews->setPageLength($NewsExcerptsPerPage);
     return $PaginatedNews;
 }
 public function __construct(\SS_List $list, $request = array())
 {
     parent::__construct($list, $request);
     if (!$this->request->isAjax()) {
         $this->initRequirements();
     }
 }
    /**
     * Process and render search results.
     *
     * @param array $data The raw request data submitted by user
     * @param SearchForm $form The form instance that was submitted
     * @param SS_HTTPRequest $request Request generated for this action
     */
    public function getSearchResults($request)
    {
        $list = new ArrayList();
        $v = $request->getVars();
        $q = $v["Search"];
        $input = DB::getConn()->addslashes($q);
        $data = DB::query(<<<EOF
SELECT
\t`pages`.`ID`,
\t`pages`.`ClassName`,
\t`pages`.`Title`,
\tGROUP_CONCAT(`do`.`Content` SEPARATOR ' ') as `Content`,
\t`pages`.`PageID`,
\tSUM(MATCH (`do`.`Title`, `do`.`Content`) AGAINST ('{$input}' IN NATURAL LANGUAGE MODE)) as `relevance`
FROM
\tSearchableDataObjects as `pages`
JOIN
\tSearchableDataObjects as `do`
ON
\t`pages`.`ID` = `do`.`OwnerID` AND
\t`pages`.`ClassName` = `do`.`OwnerClassName`
WHERE
\t`pages`.`ID` = `pages`.`OwnerID` AND
    `pages`.`ClassName` = `pages`.`OwnerClassName`
GROUP BY
\t`pages`.`ID`,
\t`pages`.`ClassName`
HAVING
\t`relevance`
ORDER BY
\t`relevance` DESC
EOF
);
        foreach ($data as $row) {
            $do = DataObject::get_by_id($row['ClassName'], $row['ID']);
            if (!$do) {
                continue;
            }
            $do->Title = $row['Title'];
            $do->Content = $row['Content'];
            $list->push($do);
        }
        $pageLength = Config::inst()->get('CustomSearch', 'items_per_page');
        $ret = new PaginatedList($list, $request);
        $ret->setPageLength($pageLength);
        return $ret;
    }
 /**
  * Videos function.
  * 
  * @access public
  * @return void
  */
 public function getVideoList()
 {
     $filter = '"ParentID" = ' . $this->ID;
     $limit = 3;
     // Build a list of all IDs for VideoGroups that are children
     $holderIDs = $this->VideoGroupIDs();
     if ($holderIDs) {
         if ($filter) {
             $filter .= ' OR ';
         }
         $filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ")";
     }
     $order = '"SiteTree"."Title" ASC';
     $entries = Video::get()->where($filter)->sort($order);
     $list = new PaginatedList($entries, Controller::curr()->request);
     $list->setPageLength($limit);
     return $list;
 }
 public function index(SS_HTTPRequest $request)
 {
     $properties = Property::get();
     if ($search = $request->getVar('Keywords')) {
         $properties = $properties->filter(array('Title:PartialMatch' => $search));
     }
     if ($arrival = $request->getVar('ArrivalDate')) {
         $arrivalStamp = strtotime($arrival);
         $nightAdder = '+' . $request->getVar('Nights') . ' days';
         $startDate = date('Y-m-d', $arrivalStamp);
         $endDate = date('Y-m-d', strtotime($nightAdder, $arrivalStamp));
         $properties = $properties->filter(array('AvailableStart:LessThanOrEqual' => $startDate, 'AvailableEnd:GreaterThanOrEqual' => $endDate));
     }
     if ($bedrooms = $request->getVar('Bedrooms')) {
         $properties = $properties->filter(array('Bedrooms:GreaterThanOrEqual' => $bedrooms));
     }
     if ($bathrooms = $request->getVar('Bathrooms')) {
         $properties = $properties->filter(array('Bathrooms:GreaterThanOrEqual' => $bathrooms));
     }
     if ($minPrice = $request->getVar('MinPrice')) {
         $properties = $properties->filter(array('PricePerNight:GreaterThanOrEqual' => $minPrice));
     }
     if ($maxPrice = $request->getVar('MaxPrice')) {
         $properties = $properties->filter(array('PricePerNight:LessThanOrEqual' => $maxPrice));
     }
     $paginatedProperties = PaginatedList::create($properties, $request)->setPageLength(15)->setPaginationGetVar('s');
     $data = array('Results' => $paginatedProperties);
     if ($request->isAjax()) {
         return $this->customise($data)->renderWith('PropertySearchResults');
     }
     return $data;
 }
 /** 
  * Action to emulate a specific user
  * @param $request = HTTPRequest
  * @return redirect
  **/
 public function emulateuser($request)
 {
     Requirements::clear();
     Requirements::css(DEVTOOLS_DIR . '/css/dev-tools.css');
     // not enabled, or not allowed >> get out
     if (!$this->CanEmulateUser()) {
         echo 'You cannot do that';
         die;
     }
     // get URL parameters
     $params = $this->owner->getRequest()->params();
     // URL attribute?
     if (!isset($params['ID'])) {
         $members = Member::get();
         $membersList = array();
         foreach ($members as $member) {
             $membersList[$member->ID] = $member;
         }
         $membersList = ArrayList::create($membersList);
         $membersList = PaginatedList::create($membersList, $this->owner->getRequest());
         $membersList->setPageLength(20);
         return $this->owner->customise(array('Users' => $membersList))->renderWith('EmulateUserPage');
     }
     $member = Member::get()->byID($params['ID']);
     if (!isset($member->ID)) {
         echo 'Could not find user by #' . $params['ID'];
         die;
     }
     $member->logIn();
     return $this->owner->redirect($this->owner->Link());
 }
Example #27
-1
 public function index(SS_HTTPRequest $request)
 {
     $products = Product::get();
     if ($search = $request->getVar('Keywords')) {
         $products = $products->filter(array('Title:PartialMatch' => $search));
     }
     if ($minPrice = $request->getVar('MinPrice')) {
         $products = $products->filter(array('Price:GreaterThanOrEqual' => $minPrice));
     }
     if ($maxPrice = $request->getVar('MaxPrice')) {
         $products = $products->filter(array('Price:LessThanOrEqual' => $maxPrice));
     }
     $paginatedProducts = PaginatedList::create($products, $request)->setPageLength(6);
     $data = array('Results' => $paginatedProducts);
     /*
     if($request->isAjax()){
         return $this->customise(array(
             'Results' => $paginatedProducts
         ))->renderWith('ProductSearchResults');
     }
     */
     if ($request->isAjax()) {
         return $this->customise($data)->renderWith('ProductSearchResults');
     }
     return $data;
 }
 /**
  * Get a paginated list of products
  *
  * @return PaginatedList
  */
 public function PaginatedAllProducts($limit = 10)
 {
     if ($this->dataRecord instanceof ProductCategory) {
         return PaginatedList::create($this->AllProducts(), $this->request)->setPageLength($limit);
     } else {
         return ArrayList::create();
     }
 }
 /**
  * Return all past orders for current member / session.
  */
 public function PastOrders($paginated = false)
 {
     $orders = $this->allorders()->filter("Status", Order::config()->placed_status);
     if ($paginated) {
         $orders = PaginatedList::create($orders, $this->owner->getRequest());
     }
     return $orders;
 }
 public function index(SS_HTTPRequest $request)
 {
     $properties = Property::get();
     $filters = ArrayList::create();
     if ($search = $request->getVar('Keywords')) {
         $filters->push(ArrayData::create(array('Label' => "Keywords: '{$search}'", 'RemoveLink' => HTTP::setGetVar('Keywords', null))));
         $properties = $properties->filter(array('Title:PartialMatch' => $search));
     }
     if ($arrival = $request->getVar('ArrivalDate')) {
         $arrivalStamp = strtotime($arrival);
         $nightAdder = '+' . $request->getVar('Nights') . ' days';
         $startDate = date('Y-m-d', $arrivalStamp);
         $endDate = date('Y-m-d', strtotime($nightAdder, $arrivalStamp));
         $properties = $properties->filter(array('AvailableStart:GreaterThanOrEqual' => $startDate, 'AvailableEnd:LessThanOrEqual' => $endDate));
     }
     if ($bedrooms = $request->getVar('Bedrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bedrooms} bedrooms", 'RemoveLink' => HTTP::setGetVar('Bedrooms', null))));
         $properties = $properties->filter(array('Bedrooms:GreaterThanOrEqual' => $bedrooms));
     }
     if ($bathrooms = $request->getVar('Bathrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bathrooms} bathrooms", 'RemoveLink' => HTTP::setGetVar('Bathrooms', null))));
         $properties = $properties->filter(array('Bathrooms:GreaterThanOrEqual' => $bathrooms));
     }
     if ($minPrice = $request->getVar('MinPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Min. \${$minPrice}", 'RemoveLink' => HTTP::setGetVar('MinPrice', null))));
         $properties = $properties->filter(array('PricePerNight:GreaterThanOrEqual' => $minPrice));
     }
     if ($maxPrice = $request->getVar('MaxPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Max. \${$maxPrice}", 'RemoveLink' => HTTP::setGetVar('MaxPrice', null))));
         $properties = $properties->filter(array('PricePerNight:LessThanOrEqual' => $maxPrice));
     }
     $paginatedProperties = PaginatedList::create($properties, $request)->setPageLength(15)->setPaginationGetVar('s');
     return array('Results' => $paginatedProperties, 'ActiveFilters' => $filters);
 }