本文整理汇总了PHP中PaginatedList::push方法的典型用法代码示例。如果您正苦于以下问题:PHP PaginatedList::push方法的具体用法?PHP PaginatedList::push怎么用?PHP PaginatedList::push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaginatedList
的用法示例。
在下文中一共展示了PaginatedList::push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleList
/**
* 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'));
}
示例2: getElementsByProductGroup
/**
* Returns a number of products from the chosen productgroup.
*
* @return ArrayList
*
* @author Sebastian Diel <sdiel@pixeltricks.de>,
* Sascha Koehler <skoehler@pixeltricks.de>
* @since 15.07.2015
*/
public function getElementsByProductGroup()
{
$cache = false;
$productGroupPage = Controller::curr();
$elements = new PaginatedList(new ArrayList());
if (method_exists($productGroupPage, 'getProductsPerPageSetting')) {
$elements->pageLength = $productGroupPage->getProductsPerPageSetting();
$elements->pageStart = $productGroupPage->getSqlOffset();
}
$pageEnd = $elements->pageStart + $elements->pageLength;
$elementIdx = 0;
$products = new ArrayList();
if (!$productGroupPage instanceof SilvercartProductGroupPage_Controller || $productGroupPage->getProducts()->count() > 0) {
return $elements;
}
$pageIDsToWorkOn = $productGroupPage->getDescendantIDList();
if (is_array($pageIDsToWorkOn) && count($pageIDsToWorkOn) > 0) {
if (SilvercartConfig::DefaultLanguage() != i18n::get_locale()) {
$translationGroupQuery = 'SELECT "STTG"."TranslationGroupID" FROM "SiteTree_translationgroups" AS "STTG" WHERE "STTG"."OriginalID" IN (' . implode(',', $pageIDsToWorkOn) . ')';
$translationIDsQuery = 'SELECT "STTG2"."OriginalID" FROM "SiteTree_translationgroups" AS "STTG2" WHERE "STTG2"."TranslationGroupID" IN (' . $translationGroupQuery . ')';
$mirrored = 'SELECT "SPGMP"."SilvercartProductID" FROM SilvercartProduct_SilvercartProductGroupMirrorPages AS "SPGMP" WHERE "SPGMP"."SilvercartProductGroupPageID" IN (' . implode(',', $pageIDsToWorkOn) . ') OR "SPGMP"."SilvercartProductGroupPageID" IN (' . $translationIDsQuery . ')';
} else {
$mirrored = 'SELECT "SPGMP"."SilvercartProductID" FROM SilvercartProduct_SilvercartProductGroupMirrorPages AS "SPGMP" WHERE "SPGMP"."SilvercartProductGroupPageID" IN (' . implode(',', $pageIDsToWorkOn) . ')';
}
$products = SilvercartProduct::getProducts('("SilvercartProduct"."SilvercartProductGroupID" IN (' . implode(',', $pageIDsToWorkOn) . ') OR "SilvercartProduct"."ID" IN (' . $mirrored . '))');
}
foreach ($products as $product) {
if ($elementIdx >= $elements->pageStart && $elementIdx < $pageEnd) {
$product->addCartFormIdentifier = $this->ID . '_' . $product->ID;
$elements->push($product);
}
$elementIdx++;
}
$elements->totalSize = $elementIdx;
$productGroupPage->addTotalNumberOfProducts($elements->totalSize);
return $elements;
}