本文整理汇总了PHP中PaginatedList::create方法的典型用法代码示例。如果您正苦于以下问题:PHP PaginatedList::create方法的具体用法?PHP PaginatedList::create怎么用?PHP PaginatedList::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaginatedList
的用法示例。
在下文中一共展示了PaginatedList::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PaginatedImages
/**
* 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;
}
示例2: index
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);
}
示例3: index
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;
}
示例4: emulateuser
/**
* 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());
}
示例5: index
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;
}
示例6: PastOrders
/**
* 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;
}
示例7: PaginatedAllProducts
/**
* 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();
}
}
示例8: index
/**
* 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;
}
示例9: index
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;
}
示例10: object
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"));
}
示例11: index
/**
* @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;
}
示例12: index
/**
* 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"]);
}
示例13: getinfo
/**
* 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;
}
示例14: results
/**
* 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'));
}
示例15: getFiles
/**
* 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);
}