/** * 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; }
/** * Index lists all the products * * @param SS_HTTPRequest $request * @return PaginatedList */ public function index(SS_HTTPRequest $request) { $transaction = Session::get("transaction"); // clear old session data if (!empty($transaction)) { Session::clear("transaction"); Session::clear("order"); } $filter = array('Active' => true); $searchQuery = $request->getVar('search'); if ($searchQuery) { $filter['ProductDescription:PartialMatch'] = $searchQuery; } $produts = Products::get()->filter($filter); $paginatedProducts = PaginatedList::create($produts, $request); $paginatedProducts->setPageLength(10); $total = $this->total(); return array('Products' => $paginatedProducts, 'searchQuery' => $searchQuery, 'CartItems' => $this->CartItems(), 'CartItemsCount' => $this->CartItemsCount(), 'CartTotal' => $total["total"], 'ShippingTotal' => $total["shippingtotal"]); }
/** * Action: get info about product set to help you determine how to appropriately use /products * @param SS_HTTPRequest $request */ function getinfo($request) { $limit = $request->getVar('limit') ? $request->getVar('limit') : 1000; $products = $this->ProductList(); $productsItems = PaginatedList::create($products, $request)->setPageLength($limit)->setPaginationGetVar('start'); $count = $products->Count(); $sets = floor($count / $limit); $setcount = $sets; echo '<p>There are a total of <strong>' . $count . '</strong> products.</p>'; echo '<p>Google should be provided with <strong>' . $setcount . '</strong> different feeds, showing ' . $limit . ' per page.</strong>'; for ($i = 0; $i <= $sets; $i++) { $counter = $limit * $i; $link = Director::absoluteURL('/googlebase/products/?limit=' . $limit); if ($i > 0) { $link .= '&start=' . $counter; } echo '<p><a href="' . $link . '" target="_blank">' . $link . '</a></p>'; } die; }
/** * Process and render search results. This has been hacked a bit to load * products into the list (if they exists). Will need to come up with a more * elegant solution to dealing with complex searches of objects though. * * @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 results($data, $form, $request) { $results = $form->getResults(); // For the moment this will also need to be added to your // Page_Controller::results() method (until a more elegant solution can // be found if (class_exists("Product")) { $products = Product::get()->filterAny(array("Title:PartialMatch" => $data["Search"], "StockID" => $data["Search"], "Content:PartialMatch" => $data["Search"])); $results->merge($products); } $results = $results->sort("Title", "ASC"); $data = array('Results' => PaginatedList::create($results, $this->request), 'Query' => $form->getSearchQuery(), 'Title' => _t('SearchForm.SearchResults', 'Search Results')); return $this->owner->customise($data)->renderWith(array('Page_results', 'SearchResults', 'Page')); }
/** * Gets the logs currently in the database * @return {DataList} Data List pointing to the logs in the database */ public function getLogs() { $logs = KapostBridgeLog::get(); $filterFields = $this->LogsForm()->Fields(); //Apply Called Method filter $var = $filterFields->dataFieldByName('CalledMethod')->Value(); if (!empty($var)) { $logs = $logs->filter('Method', Convert::raw2sql($var)); } //Apply Start Date Filter $dateTimeField = $filterFields->dataFieldByName('LogStartDate'); $var = trim($dateTimeField->getDateField()->dataValue() . ' ' . $dateTimeField->getTimeField()->dataValue()); if (!empty($var)) { $logs = $logs->filter('Created:GreaterThan', Convert::raw2sql($var)); } //Apply End Date Filter $var = $filterFields->dataFieldByName('LogEndDate')->Value(); if (!empty($var) && $var != ' 00:00:00') { $logs = $logs->filter('Created:LessThan', Convert::raw2sql($var)); } return PaginatedList::create($logs, $this->request)->setPageLength(self::config()->log_page_length); }
/** * @param SS_HTTPRequest $request * @return array|HTMLText */ public function index(SS_HTTPRequest $request) { $videos = PaginatedList::create($this->data()->getVideoList(), $request)->setPageLength(Config::inst()->get('VideoGroup', 'page_length'))->setPaginationGetVar(Config::inst()->get('VideoGroup', 'pagination_get_var')); $data = array('VideoList' => $videos); if ($request->isAjax()) { return $this->customise($data)->renderWith('VideoList'); } return $data; }
public function getFilteredItemList($paginated = true) { $items = DataList::create($this->ItemType); // add filter $filter = $this->Filter->getValues(); $filterBy = array(); if (count($filter)) { foreach ($filter as $field => $val) { $field = Convert::raw2sql($field); $val = $this->resolveValue($val); if (is_null($val)) { $items = $items->where('"' . $field . '" IS NULL'); } else { $filterBy[$field] = $val; } } $items = $items->filter($filterBy); } $sorts = $this->SortBy->getValues(); if (count($sorts)) { $items = $items->sort($sorts); } foreach ($this->listModifiers as $modifier) { $items = $modifier($items); } if ($paginated && $this->getLimit()) { $request = Controller::curr()->getRequest(); $items = PaginatedList::create($items, $request); $items->setPageLength($this->getLimit()); $items->setPaginationGetVar($this->paginationName()); } return $items; }
/** * Retrieve a paginated list of media holder/page children for your template, with optional date/tag filters parsed from the GET request. * * @parameter/@URLfilter <{MEDIA_PER_PAGE}> integer * @parameter/@URLfilter <{SORT_FIELD}> string * @parameter/@URLfilter <{SORT_ORDER}> string * @URLfilter <{FROM_DATE}> date * @URLfilter <{CATEGORY_FILTER}> string * @URLfilter <{TAG_FILTER}> string * @return paginated list */ public function getPaginatedChildren($limit = 5, $sort = 'Date', $order = 'DESC') { // Retrieve custom request filters. $request = $this->getRequest(); if ($limitVar = $request->getVar('limit')) { $limit = $limitVar; } if ($sortVar = $request->getVar('sort')) { $sort = $sortVar; } if ($orderVar = $request->getVar('order')) { $order = $orderVar; } $from = $request->getVar('from'); $category = $request->getVar('category'); $tag = $request->getVar('tag'); // Apply custom request filters to media page children. $children = MediaPage::get()->where('ParentID = ' . (int) $this->data()->ID); // Validate the date request filter. if ($from) { $valid = true; $date = array(); foreach (explode('-', $from) as $segment) { if (!is_numeric($segment)) { $valid = false; break; } else { $date[] = str_pad($segment, 2, '0', STR_PAD_LEFT); } } if ($valid) { $from = implode('-', $date); $children = $children->where("Date >= '" . Convert::raw2sql("{$from} 00:00:00") . "'"); } } // Determine both category and tag result sets separately, since they both share a database table. $temporary = $children; if ($category) { $children = $categoryChildren = $temporary->filter('Categories.Title', $category); } if ($tag) { $children = $tagChildren = $temporary->filter('Tags.Title', $tag); } // Merge both category and tag result sets. if ($category && $tag) { $intersection = array_uintersect($categoryChildren->toArray(), $tagChildren->toArray(), function ($first, $second) { return $first->ID - $second->ID; }); $children = ArrayList::create($intersection); } // Allow extension customisation. $this->extend('updatePaginatedChildren', $children); return PaginatedList::create($children->sort(Convert::raw2sql($sort) . ' ' . Convert::raw2sql($order)), $request)->setPageLength($limit); }
/** * Get a paginated list of all products at this level and below * * @return PaginatedList */ public function PaginatedAllProducts($limit = 10) { return PaginatedList::create($this->AllProducts(), $this->request)->setPageLength($limit); }
public function PaginatedNewsArticles() { return PaginatedList::create($this->NewsArticles(), $this->request)->setPageLength($this->NewsPageLimit); }
/** * We do not want to use NewsHolder->SubSections because this splits the paginations into * the categories the articles are in which means the pagination will not work or will display * multiple times * * @return Array */ public function TotalChildArticles($number = null) { if (!$number) { $number = $this->numberToDisplay; } $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; if ($start < 0) { $start = 0; } $articles = NewsArticle::get('NewsArticle', '', '"OriginalPublishedDate" DESC, "ID" DESC', '', $start . ',' . $number)->filter(array('ID' => $this->getDescendantIDList())); $entries = PaginatedList::create($articles); $entries->setPaginationFromQuery($articles->dataQuery()->query()); return $entries; }
public function PaginatedArticles($num = 10) { return PaginatedList::create($this->articleList, $this->getRequest())->setPageLength($num); }
/** * Retrieves all the listing items within this source * * @return DataObjectSource */ public function ListingItems() { // need to get the items being listed $source = $this->getListingSource(); $listType = $this->ListType ? $this->ListType : 'Page'; $filter = array(); $objFields = $this->getSelectableFields($listType); if ($source) { $ids = $this->getIdsFrom($source, 1); $ids[] = $source->ID; if (isset($objFields['ParentID']) && count($ids)) { $filter['ParentID:ExactMatch'] = $ids; } } if ($this->StrictType) { $filter['ClassName'] = $listType; } $sortDir = $this->SortDir == 'Ascending' ? 'ASC' : 'DESC'; $sort = $this->SortBy && isset($objFields[$this->SortBy]) ? $this->SortBy : 'Title'; // $sort = $this->CustomSort ? $this->CustomSort : $sort; $sort .= ' ' . $sortDir; $limit = ''; $pageUrlVar = 'page' . $this->ID; $items = DataList::create($listType)->filter($filter)->sort($sort); if ($this->PerPage) { $page = isset($_REQUEST[$pageUrlVar]) ? (int) $_REQUEST[$pageUrlVar] : 0; $items = $items->limit($this->PerPage, $page); } $newList = ArrayList::create(); if ($items) { // note: Access control is no longer being enforced by the page type! You'll need to // manually include canView checks in your listing templates... // foreach ($items as $result) { // if ($result->canView()) { // $newList->push($result); // } // } // $newList = PaginatedList::create($items); $newList->setPaginationGetVar($pageUrlVar); $newList->setPaginationFromQuery($items->dataQuery()->query()); } return $newList; }
/** * Retrieves all the listing items within this source * * @return SS_List */ public function ListingItems() { // need to get the items being listed $source = $this->getListingSource(); $listType = $this->ListType ? $this->ListType : 'Page'; $filter = array(); $objFields = $this->getSelectableFields($listType); if ($source) { $ids = $this->getIdsFrom($source, 1); $ids[] = $source->ID; if (isset($objFields['ParentID']) && count($ids)) { $filter['ParentID:ExactMatch'] = $ids; } } if ($this->StrictType) { $filter['ClassName'] = $listType; } $sortDir = $this->SortDir == 'Ascending' ? 'ASC' : 'DESC'; $sort = $this->SortBy && isset($objFields[$this->SortBy]) ? $this->SortBy : 'Title'; // $sort = $this->CustomSort ? $this->CustomSort : $sort; $sort .= ' ' . $sortDir; $limit = ''; $pageUrlVar = 'page' . $this->ID; $items = DataList::create($listType)->filter($filter)->sort($sort); if ($this->PerPage) { $page = isset($_REQUEST[$pageUrlVar]) ? (int) $_REQUEST[$pageUrlVar] : 0; $items = $items->limit($this->PerPage, $page); } if ($this->ComponentFilterName) { $controller = Controller::has_curr() ? Controller::curr() : null; $tags = array(); if ($controller && $controller instanceof ListingPage_Controller) { $tagName = $controller->getRequest()->latestParam('Action'); if ($tagName) { $tags = $this->ComponentListingItems(); $tags = $tags->filter(array($this->ComponentFilterColumn => $tagName)); $tags = $tags->toArray(); if (!$tags) { // Workaround cms/#1045 // - Stop infinite redirect // @see: https://github.com/silverstripe/silverstripe-cms/issues/1045 unset($controller->extension_instances['OldPageRedirector']); return $controller->httpError(404); } } } if ($tags) { if (count($tags) > 1) { return $controller->httpError(500, 'ComponentFilterColumn provided is not unique. ' . count($tags) . ' matches found in query.'); } $tag = reset($tags); list($parentClass, $componentClass, $pageIDColumnName, $tagIDColumnName, $tagManyManyTable) = singleton($this->ListType)->manyManyComponent($this->ComponentFilterName); $items = $items->innerJoin($tagManyManyTable, "\"{$pageIDColumnName}\" = \"{$parentClass}\".\"ID\" AND \"{$tagIDColumnName}\" = " . (int) $tag->ID); } else { $tags = new ArrayList(); } } $this->extend('updateListingItems', $items); $newList = ArrayList::create(); if ($items) { $newList = PaginatedList::create($items); // ensure the 0 limit is applied if configured as such $newList->setPageLength($this->PerPage); $newList->setPaginationGetVar($pageUrlVar); if ($items instanceof DataList) { $newList->setPaginationFromQuery($items->dataQuery()->query()); } } return $newList; }
/** * Get the list of pages to be displayed in the template * @return DataList */ public function CurrentPages() { if ($this->ShowSearch) { if ($this->UseChildren) { $items = $this->FilterPages(); } else { $items = $this->FilterPages()->sort('SortOrder'); } } else { if ($this->UseChildren) { $items = $this->NormalPages(); } else { $items = $this->NormalPages()->sort('SortOrder'); } } if ($this->getTopLimit()) { return PaginatedList::create($items, Controller::curr()->request)->setPageLength($this->getTopLimit()); } return $items; }
/** * Display the search form results. * * @parameter <{SEARCH_PARAMETERS}> array * @parameter <{SEARCH_FORM}> search form * @return html text */ public function getSearchResults($data = null, $form = null) { // Determine whether a search engine has been selected. $page = $this->data(); $engine = $page->SearchEngine; $classes = Config::inst()->get('FulltextSearchable', 'searchable_classes'); if (!$engine || $engine !== 'Full-Text' && !ClassInfo::exists($engine) || $engine === 'Full-Text' && (!is_array($classes) || count($classes) === 0)) { // The search engine has not been selected. return $this->httpError(404); } // The analytics require the time taken. $time = microtime(true); // Determine whether search parameters have been passed through. if (!isset($data['Search'])) { $data['Search'] = ''; } if (!isset($data['SortBy']) || !$data['SortBy']) { $data['SortBy'] = $page->SortBy; } if (!isset($data['SortDirection']) || !$data['SortDirection']) { $data['SortDirection'] = $page->SortDirection; } $request = $this->getRequest(); if (!isset($form)) { $this->getForm($request); } // Instantiate some default templates. $templates = array('ExtensibleSearch', 'ExtensibleSearchPage', 'Page'); // Determine the search engine that has been selected. if ($engine !== 'Full-Text') { // Determine the search engine specific search results. $results = array('Results' => null); foreach ($this->extension_instances as $instance) { if (get_class($instance) === "{$engine}_Controller") { $instance->setOwner($this); if (method_exists($instance, 'getSearchResults')) { // The analytics require the time taken. $time = microtime(true); $results = $instance->getSearchResults($data, $form); // The search results format needs to be correct. if (!isset($results['Results'])) { $results = array('Results' => $results); } } $instance->clearOwner(); break; } } // Determine the number of search results. $count = isset($results['Count']) ? (int) $results['Count'] : count($results['Results']); // Instantiate the search engine specific templates. $templates = array_merge(array("{$engine}_results", "{$engine}Page_results", 'ExtensibleSearch_results', 'ExtensibleSearchPage_results', 'Page_results', $engine, "{$engine}Page"), $templates); } else { // The paginated list needs to be manipulated, as filtering and sorting is not possible otherwise. $start = $request->getVar('start') ? (int) $request->getVar('start') : 0; $_GET['start'] = 0; $list = $form->getResults(PHP_INT_MAX, $data)->getList(); // The search engine may only support limited hierarchy filtering for multiple sites. $filter = $page->SearchTrees()->column(); if (count($filter) && (($hierarchy = $page::$supports_hierarchy) || ClassInfo::exists('Multisites'))) { // Apply the search trees filtering. $list = $list->filter($hierarchy ? 'ParentID' : 'SiteID', $filter); } // Apply the sorting. $list = $list->sort("{$data['SortBy']} {$data['SortDirection']}"); // The paginated list needs to be instantiated again. $results = array('Title' => 'Search Results', 'Query' => $form->getSearchQuery($data), 'Results' => PaginatedList::create($list)->setPageLength($page->ResultsPerPage)->setPageStart($start)->setTotalItems($count = $list->count())); // Instantiate the full-text specific templates. $templates = array_merge(array('ExtensibleSearch_results', 'ExtensibleSearchPage_results', 'Page_results'), $templates); } // Determine the template to use. $this->extend('updateTemplates', $templates); $output = $this->customise($results)->renderWith($templates); // Determine whether analytics are to be suppressed. if ($request->getVar('analytics') !== 'false') { // Update the search page specific analytics. $this->service->logSearch($data['Search'], $count, microtime(true) - $time, $engine, $page->ID); } // Display the search form results. return $output; }
/** * Return all the dataobjects that were found in this query * * @param $evaluatePermissions * Should we evaluate whether the user can view before adding the result to the dataset? * * @return DataObjectSet */ public function getDataObjects($evaluatePermissions = false, $expandRawObjects = true) { if (!$this->dataObjects) { $this->dataObjects = ArrayList::create(); $result = $this->getResult(); $documents = $result && isset($result->response) ? $result->response : null; if ($documents && isset($documents->docs)) { $totalAdded = 0; foreach ($documents->docs as $doc) { $bits = explode('_', $doc->id); if (count($bits) == 3) { list($type, $id, $stage) = $bits; } else { list($type, $id) = $bits; $stage = Versioned::current_stage(); } if (!$type || !$id) { singleton('SolrUtils')->log("Invalid solr document ID {$doc->id}", SS_Log::WARN); continue; } if (strpos($doc->id, SolrSearchService::RAW_DATA_KEY) === 0) { $object = $this->inflateRawResult($doc, $expandRawObjects); // $object = new ArrayData($data); } else { if (!class_exists($type)) { continue; } // a double sanity check for the stage here. if ($currentStage = Versioned::current_stage()) { if ($currentStage != $stage) { continue; } } $object = DataObject::get_by_id($type, $id); } if ($object && $object->ID) { // check that the user has permission if (isset($doc->score)) { $object->SearchScore = $doc->score; } $canAdd = true; if ($evaluatePermissions) { // check if we've got a way of evaluating perms if ($object->hasMethod('canView')) { $canAdd = $object->canView(); } } if (!$evaluatePermissions || $canAdd) { if ($object->hasMethod('canShowInSearch')) { if ($object->canShowInSearch()) { $this->dataObjects->push($object); } } else { $this->dataObjects->push($object); } } $totalAdded++; } else { singleton('SolrUtils')->log("Object {$doc->id} is no longer in the system, removing from index", SS_Log::WARN); $this->solr->unindex($type, $id); } } $this->totalResults = $documents->numFound; // update the dos with stats about this query $this->dataObjects = PaginatedList::create($this->dataObjects); $this->dataObjects->setPageLength($this->queryParameters->limit)->setPageStart($documents->start)->setTotalItems($documents->numFound)->setLimitItems(false); // $paginatedSet->setPaginationFromQuery($set->dataQuery()->query()); // $this->dataObjects->setPageLimits($documents->start, $this->queryParameters->limit, $documents->numFound); } } return $this->dataObjects; }
function previous($request) { $this->previousCalculations = PaginatedList::create(EVCDataSet::get()->filter(array("Locked" => 1))->where("Title IS NOT NULL AND Title <> ''")); $this->previousCalculations->setPageLength(100); return array(); }
/** * @todo can this be made smaller? Would be nice! * @return ArrayList $allEntries|$records The newsitems, sliced by the amount of length. Set to wished value */ public function allNews() { $siteConfig = $this->getCurrentSiteConfig(); $exclude = array('PublishFrom:GreaterThan' => SS_Datetime::now()->Format('Y-m-d')); $filter = $this->generateAddedFilter(); $allEntries = $this->Newsitems()->filter($filter)->exclude($exclude); /** Pagination pagination pagination. */ if ($allEntries->count() > $siteConfig->PostsPerPage && $siteConfig->PostsPerPage > 0) { $records = PaginatedList::create($allEntries, $this->getRequest()); $records->setPageLength($siteConfig->PostsPerPage); return $records; } return $allEntries; }
/** * Main method to get the folders and/or files to list * * @param string $restrictClass Restrict the listing to a particular File subclass: 'File' or 'Folder' * @return PaginatedList The list of file records */ public function getFiles($restrictClass = null) { $files = $folders = array(); $sourceFolderID = $this->getViewingFolder()->ID; if ($restrictClass != 'File') { // Retrieve the folders $folders = Folder::get(); $excludeFolders = Config::inst()->get('FileListingPage', 'exclude_folder_names'); if (is_array($excludeFolders) && count($excludeFolders)) { $folders = $folders->exclude('Name', array_values($excludeFolders)); } if (($term = $this->request->getVar('term')) && ($term = Convert::raw2sql($term))) { $folders = $folders->leftJoin('File_Terms', 'File.ID = File_Terms.FileID')->leftJoin('TaxonomyTerm', 'File_Terms.TaxonomyTermID = TaxonomyTerm.ID')->where("(File.Title LIKE '%{$term}%') OR (File.Description LIKE '%{$term}%') OR (TaxonomyTerm.Name LIKE '%{$term}%')"); } else { $folders = $folders->filter('ParentID', $sourceFolderID); } $folders = $folders->sort($this->getSortString())->toArray(); } if ($restrictClass != 'Folder') { // Retrieve the files. $files = File::get()->filter('ClassName:not', 'Folder'); if ($term) { $files = $files->leftJoin('File_Terms', 'File.ID = File_Terms.FileID')->leftJoin('TaxonomyTerm', 'File_Terms.TaxonomyTermID = TaxonomyTerm.ID')->where("(File.Title LIKE '%{$term}%') OR (File.Description LIKE '%{$term}%') OR (TaxonomyTerm.Name LIKE '%{$term}%')"); } else { $files = $files->filter('ParentID', $sourceFolderID); } $files = $files->sort($this->getSortString())->toArray(); } // Merge the folders and files, so the folders are displayed first. if ($files && $folders) { $files = array_merge($folders, $files); } elseif ($folders) { $files = $folders; } foreach ($files as $key => $file) { // Make sure the search results are contained under the current category folder. $parent = $file; $found = false; if ($parent->ParentID) { while ($parentID = $parent->ParentID) { if ($parentID == $sourceFolderID) { $found = true; } $parent = File::get()->byID($parentID); } if (!$found) { unset($files[$key]); continue; } } // Make sure any folders link back to the file listing page. $file->Location = $file->ClassName === 'Folder' ? $this::join_links($this->Link(), "?cat={$file->ID}") : ($file->Location = $file->Filename); } $itemsPerPage = $this->data()->ItemsPerPage ? $this->data()->ItemsPerPage : 10; return PaginatedList::create(ArrayList::create($files), $this->getRequest())->setPageLength($itemsPerPage); }
/** * 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()); }
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; }
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; }
/** * 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; }
/** * Return a ArrayList of all blog children of this page. * * @param SS_HTTPRequest $request * @return array|HTMLText * @throws Exception */ public function index(SS_HTTPRequest $request) { /** @var PaginatedList $pagination */ $pagination = PaginatedList::create($this->liveChildren(true), Controller::curr()->request); $items = $this->Items > 0 ? $this->Items : 10; $pagination->setPageLength($items); $data = array('PaginatedPages' => $pagination); if ($request->isAjax()) { return $this->customise($data)->renderWith('PortfolioHolder_Item'); } return $data; }
public function index(SS_HTTPRequest $request) { $screenshots = ModuleScreenshot::get(); if ($search = $request->getVar('Title')) { $screenshots = $screenshots->filter(array('Title:PartialMatch' => $search)); } $paginatedShots = PaginatedList::create($screenshots, $request)->setPageLength(6); $data = array('Results' => $paginatedShots); if ($request->isAjax()) { return $this->customise($data)->renderWith('ScreenShotSearchResults'); } return $data; }
public function object() { $classname = $this->request->param("ID"); $classes_to_search = Searchable::getObjects(); foreach ($classes_to_search as $object) { if ($object["ClassName"] == $classname) { $cols = $object["Columns"]; } } $keywords = $this->getQuery(); $this->customise(array("MetaTitle" => _t('Searchable.SearchResultsFor', "Search Results for '{query}'", 'This is the title used for viewing the results of a search', array('query' => $this->getQuery())), "Results" => PaginatedList::create(Searchable::Results($classname, $cols, $keywords), $this->request)->setPageLength(Searchable::config()->page_length))); $this->extend("onBeforeObject"); return $this->renderWith(array("SearchResults_{$classname}", "SearchResults_object", "SearchResults", "Page")); }
/** * @param SS_HTTPRequest $request * @return array|HTMLText */ public function index(SS_HTTPRequest $request) { /** * Return a ArrayList of all BlogPage children of this page. * * @return PaginatedList */ $pagination = PaginatedList::create($this->liveChildren(true), Controller::curr()->request); $items = $this->Items > 0 ? $this->Items : 10; /** @var PaginatedList $pagination */ $pagination->setPageLength($items); $data = array('PaginatedPages' => $pagination); /** If the request is AJAX */ if ($request->isAjax()) { return $this->customise($data)->renderWith('BlogHolder_Item'); } return $data; }
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); }