当前位置: 首页>>代码示例>>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;未经允许,请勿转载。