當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PaginatedList::push方法代碼示例

本文整理匯總了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'));
 }
開發者ID:helpfulrobot,項目名稱:ajshort-silverstripe-memberprofiles,代碼行數:33,代碼來源:MemberProfileViewer.php

示例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;
 }
開發者ID:silvercart,項目名稱:silvercart,代碼行數:46,代碼來源:SilvercartProductGroupChildProductsWidget.php


注:本文中的PaginatedList::push方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。