/** * 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 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'))); }
/** * 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; }
/** * @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; }
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; }
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; }
/** * 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'))); }
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; }
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; }
/** * Returns a list of all the comments attached to this record. * * @return PaginatedList */ public function Comments() { $order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by'); $list = new PaginatedList(Comment::get()->where(sprintf("ParentID = '%s' AND BaseClass = '%s'", $this->owner->ID, $this->ownerBaseClass))->sort($order)); $list->setPageLength(Commenting::get_config_value($this->ownerBaseClass, 'comments_per_page')); $controller = Controller::curr(); $list->setPageStart($controller->request->getVar("commentsstart" . $this->owner->ID)); $list->setPaginationGetVar("commentsstart" . $this->owner->ID); $list->MoreThanOnePage(); 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'))); }
public function PaginatedNews() { if ($this->NewsExcerptsPerPage) { $NewsExcerptsPerPage = $this->NewsExcerptsPerPage; } else { $NewsExcerptsPerPage = '15'; } $PaginatedNews = new PaginatedList($this->GetNewsPages(), $this->request); $PaginatedNews->setPageLength($NewsExcerptsPerPage); return $PaginatedNews; }
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; }
/** * 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; }
/** * 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 results($data, $form, $request) { $query = $data['Search']; $filter = 'ParentID = ' . $this->ID . " AND (\"SiteTree\".\"Title\" LIKE '%{$query}%' OR \"SiteTree\".\"Content\" LIKE '%{$query}')"; $articles = ArticlePage::get()->where($filter)->sort('Date DESC'); $perPage = $this->dataRecord->config()->get('articles_per_page'); $paginatedList = new PaginatedList($articles, $request); $paginatedList->setPageLength($perPage); return $this->customise(array('NewsArticles' => $paginatedList))->renderWith(array('ArticleHolder', 'Page')); }
public function testPrevLink() { $list = new PaginatedList(new ArrayList()); $list->setTotalItems(50); $this->assertNull($list->PrevLink()); $list->setCurrentPage(2); $this->assertContains('start=0', $list->PrevLink()); $list->setCurrentPage(3); $this->assertContains('start=10', $list->PrevLink()); $list->setCurrentPage(5); $this->assertContains('start=30', $list->PrevLink()); // Disable paging $list->setPageLength(0); $this->assertNull($list->PrevLink()); }
/** * Return paginated results in class * Only returns items that contain Link() * Limited to 1000 results per page * * @param string * @return ArrayList */ public static function get_items($className, $page = 1) { $items = self::get_filtered_results($className); $list = new PaginatedList($items); $list->setPageLength(1000); $list->setCurrentPage($page); $output = new ArrayList(); /* only push items with a link */ foreach ($list as $item) { $item->ChangeFrequency = self::get_frequency_for_class($className); $item->GooglePriority = self::get_priority_for_class($className); if ($item->hasMethod('SitemapAbsoluteURL')) { $item->SitemapAbsoluteURL = $SitemapAbsoluteURL->SitemapAbsoluteURL(); $output->push($item); } elseif ($item->hasMethod('Link')) { $item->SitemapAbsoluteURL = Director::absoluteURL($item->Link()); $output->push($item); } } /* Make sure we only include one of each link, and no external links (ie: redirector pages */ $output->removeDuplicates('SitemapAbsoluteURL'); $external_links = array(); $base_url = preg_quote(Director::absoluteBaseURL(), '/'); foreach ($output as $item) { if (!preg_match('/^' . $base_url . '/', $item->SitemapAbsoluteURL)) { array_push($external_links, $item->SitemapAbsoluteURL); } } if (count($external_links) > 0) { $output = $output->exclude('SitemapAbsoluteURL', $external_links); } return $output; }
public function PaginatedPhotos() { $paginatedphotos = new PaginatedList($this->Photos(), $this->request); if ($this->PhotosPerPage > 0) { $paginatedphotos->setPageLength($this->PhotosPerPage); } else { $paginatedphotos->setPageLength('20'); } return $paginatedphotos; }
public function PaginatedList() { $list = new PaginatedList($this->list, $this->request); $list->setPageLength($this->getPageLength()); return $list; }
/** * Getter similar to DataObject::get(); returns a SS_List of products filtered by the requirements in self::getRequiredAttributes(); * If an product is free of charge, it can have no price. This is for giveaways and gifts. * * Expected format of $joins: * <pre> * array( * array( * 'table' => 'JoinTableName_1', * 'on' => 'JoinTableOnClause_1', * 'alias' => 'JoinTableAlias_1', * ), * array( * 'table' => 'JoinTableName_2', * 'on' => 'JoinTableOnClause_2', * 'alias' => 'JoinTableAlias_2', * ), * ... * ) * </pre> * * @param string $whereClause to be inserted into the sql where clause * @param string $sort string with sort clause * @param array $joins left join data as multi dimensional array * @param integer $limit DataObject limit * @param array $request Request data * @param integer $pageLength Count of items per page * * @return PaginatedList|ArrayList PaginatedList of products or empty ArrayList * * @author Sebastian Diel <*****@*****.**> * @since 20.10.2014 */ public static function getPaginatedProducts($whereClause = "", $sort = null, $joins = null, $limit = null, $request = null, $pageLength = null) { $paginatedProducts = null; if (is_null($request)) { $request = $_GET; } if (is_null($pageLength)) { $pageLength = SilvercartConfig::ProductsPerPage(); } $products = self::getProducts($whereClause, $sort, $joins, $limit); if ($products instanceof SS_List && $products->exists()) { if ($products instanceof PaginatedList) { $paginatedProducts = $products; } else { $paginatedProducts = new PaginatedList($products, $request); } $paginatedProducts->setPageLength($pageLength); } return $paginatedProducts; }
public function Addons() { $list = new PaginatedList($this->vendor->Addons(), $this->request); $list->setPageLength(15); return $list; }
/** * Returns a list of paginated blog posts based on the BlogPost dataList. * * @return PaginatedList */ public function PaginatedList() { /** * @var Blog $dataRecord */ $dataRecord = $this->dataRecord; $posts = new PaginatedList($this->blogPosts); if ($this->PostsPerPage > 0) { $posts->setPageLength($this->PostsPerPage); } else { $pageSize = 99999; if ($count = $dataRecord->getBlogPosts()->count()) { $pageSize = $count; } $posts->setPageLength($pageSize); } $start = $this->request->getVar($posts->getPaginationGetVar()); $posts->setPageStart($start); return $posts; }
/** * @return null|PaginatedList */ public function DeployHistory() { if ($env = $this->getCurrentEnvironment()) { $history = $env->DeployHistory(); if ($history->count() > 0) { $pagination = new PaginatedList($history, $this->getRequest()); $pagination->setPageLength(8); return $pagination; } } return null; }
/** * The core search engine configuration. * @todo Properly extract the search functions out of the core. * * @param string $keywords Keywords as a space separated string * @return object DataObjectSet of result pages */ public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "ts_rank DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) { //Fix the keywords to be ts_query compatitble: //Spaces must have pipes //@TODO: properly handle boolean operators here. $keywords = trim($keywords); $keywords = str_replace(' ', ' | ', $keywords); $keywords = str_replace('"', "'", $keywords); $keywords = Convert::raw2sql(trim($keywords)); $htmlEntityKeywords = htmlentities($keywords, ENT_NOQUOTES); //We can get a list of all the tsvector columns though this query: //We know what tables to search in based on the $classesToSearch variable: $result = DB::query("SELECT table_name, column_name, data_type FROM information_schema.columns WHERE data_type='tsvector' AND table_name in ('" . implode("', '", $classesToSearch) . "');"); if (!$result->numRecords()) { throw new Exception('there are no full text columns to search'); } $tables = array(); // Make column selection lists $select = array('SiteTree' => array("\"ClassName\"", "\"SiteTree\".\"ID\"", "\"ParentID\"", "\"Title\"", "\"URLSegment\"", "\"Content\"", "\"LastEdited\"", "\"Created\"", "NULL AS \"Filename\"", "NULL AS \"Name\"", "\"CanViewType\""), 'File' => array("\"ClassName\"", "\"File\".\"ID\"", "0 AS \"ParentID\"", "\"Title\"", "NULL AS \"URLSegment\"", "\"Content\"", "\"LastEdited\"", "\"Created\"", "\"Filename\"", "\"Name\"", "NULL AS \"CanViewType\"")); foreach ($result as $row) { if ($row['table_name'] == 'SiteTree') { $showInSearch = "AND \"ShowInSearch\"=1 "; } elseif ($row['table_name'] == 'File') { // File.ShowInSearch was added later, keep the database driver backwards compatible // by checking for its existence first $fields = $this->fieldList($row['table_name']); if (array_key_exists('ShowInSearch', $fields)) { $showInSearch = "AND \"ShowInSearch\"=1 "; } else { $showInSearch = ''; } } else { $showInSearch = ''; } //public function extendedSQL($filter = "", $sort = "", $limit = "", $join = "", $having = ""){ $where = "\"" . $row['table_name'] . "\".\"" . $row['column_name'] . "\" " . $this->default_fts_search_method . ' q ' . $showInSearch; $query = DataList::create($row['table_name'])->where($where, '')->dataQuery()->query(); $query->addFrom(array('tsearch' => ", to_tsquery('" . $this->get_search_language() . "', '{$keywords}') AS q")); $query->setSelect(array()); foreach ($select[$row['table_name']] as $clause) { if (preg_match('/^(.*) +AS +"?([^"]*)"?/i', $clause, $matches)) { $query->selectField($matches[1], $matches[2]); } else { $query->selectField($clause); } } $query->selectField("ts_rank(\"{$row['table_name']}\".\"{$row['column_name']}\", q)", 'Relevance'); $query->setOrderBy(array()); //Add this query to the collection $tables[] = $query->sql(); } $limit = $pageLength; $offset = $start; if ($keywords) { $orderBy = " ORDER BY {$sortBy}"; } else { $orderBy = ''; } $fullQuery = "SELECT * FROM (" . implode(" UNION ", $tables) . ") AS q1 {$orderBy} LIMIT {$limit} OFFSET {$offset}"; // Get records $records = DB::query($fullQuery); $totalCount = 0; foreach ($records as $record) { $objects[] = new $record['ClassName']($record); $totalCount++; } if (isset($objects)) { $results = new ArrayList($objects); } else { $results = new ArrayList(); } $list = new PaginatedList($results); $list->setPageStart($start); $list->setPageLength($pageLength); $list->setTotalItems($totalCount); return $list; }