当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayList::push方法代码示例

本文整理汇总了PHP中ArrayList::push方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayList::push方法的具体用法?PHP ArrayList::push怎么用?PHP ArrayList::push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayList的用法示例。


在下文中一共展示了ArrayList::push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AvailableWidgets

 /**
  *
  * @return ArrayList
  */
 public function AvailableWidgets()
 {
     $widgets = new ArrayList();
     foreach ($this->widgetClasses as $widgetClass) {
         $classes = ClassInfo::subclassesFor($widgetClass);
         if (isset($classes['Widget'])) {
             unset($classes['Widget']);
         } else {
             if (isset($classes[0]) && $classes[0] == 'Widget') {
                 unset($classes[0]);
             }
         }
         foreach ($classes as $class) {
             $available = Config::inst()->get($class, 'only_available_in');
             if (!empty($available) && is_array($available)) {
                 if (in_array($this->Name, $available)) {
                     $widgets->push(singleton($class));
                 }
             } else {
                 $widgets->push(singleton($class));
             }
         }
     }
     return $widgets;
 }
开发者ID:hailwood,项目名称:silverstripe-widgets,代码行数:29,代码来源:WidgetAreaEditor.php

示例2: BillingHistory

 public function BillingHistory()
 {
     $billingHistory = new ArrayList();
     $orders = Order::get()->filter(array('MemberID' => Member::currentUserID(), 'OrderStatus' => 'c'))->sort('Created');
     foreach ($orders as $order) {
         $productId = $order->ProductID;
         if (($productId == 1 || $productId == 2 || $productId == 3) && $order->IsTrial == 1) {
             $productDesc = 'First Month Trial';
         } else {
             $product = Product::get()->byID($productId);
             $productDesc = $product->Name;
         }
         $creditCard = $order->CreditCard();
         $ccNumber = 'XXXX-XXXX-XXXX-' . substr($creditCard->CreditCardNumber, -4);
         $orderDetails = array('Date' => $order->Created, 'Description' => $productDesc, 'CCType' => strtoupper($creditCard->CreditCardType), 'CCNumber' => $ccNumber, 'Amount' => $order->Amount);
         $billingHistory->push(new ArrayData($orderDetails));
     }
     $memBillHistory = MemberBillingHistory::get()->filter('MemberID', Member::currentUserID())->sort('Created');
     foreach ($memBillHistory as $history) {
         $creditCard = $history->CreditCard();
         $ccNumber = 'XXXX-XXXX-XXXX-' . substr($creditCard->CreditCardNumber, -4);
         $details = array('Date' => $history->Created, 'Description' => $history->Product()->Name, 'CCType' => strtoupper($creditCard->CreditCardType), 'CCNumber' => $ccNumber, 'Amount' => $history->Product()->RecurringPrice);
         $billingHistory->push(new ArrayData($details));
     }
     $sortedBillingHistory = $billingHistory->sort('Date');
     return $sortedBillingHistory;
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:27,代码来源:AccountSettings.php

示例3: getHTMLFragments

 /**
  * @param GridField $gridField
  *
  * @return array
  */
 public function getHTMLFragments($gridField)
 {
     Requirements::css(CMC_BULKUPDATER_MODULE_DIR . '/css/CmcGridFieldBulkUpdater.css');
     Requirements::javascript(CMC_BULKUPDATER_MODULE_DIR . '/javascript/CmcGridFieldBulkUpdater.js');
     Requirements::add_i18n_javascript(CMC_BULKUPDATER_MODULE_DIR . '/lang/js');
     //initialize column data
     $cols = new ArrayList();
     $fields = $gridField->getConfig()->getComponentByType('GridFieldEditableColumns')->getDisplayFields($gridField);
     foreach ($gridField->getColumns() as $col) {
         $fieldName = $col;
         $fieldType = '';
         $fieldLabel = '';
         if (isset($fields[$fieldName])) {
             $fieldData = $fields[$fieldName];
             if (isset($fieldData['field'])) {
                 $fieldType = $fieldData['field'];
             }
             if (isset($fieldData['title'])) {
                 $fieldLabel = $fieldData['title'];
             }
         }
         //Debug::show($fieldType);
         if (class_exists($fieldType) && $fieldType != 'ReadonlyField') {
             $field = new $fieldType($fieldName, $fieldLabel);
             if ($fieldType == 'DatetimeField' || $fieldType == 'DateField' || $fieldType == 'TimeField') {
                 $field->setValue(date('Y-m-d H:i:s'));
                 $field->setConfig('showcalendar', true);
             }
             $cols->push(new ArrayData(array('UpdateField' => $field, 'Name' => $fieldName, 'Title' => $fieldLabel)));
         } else {
             $meta = $gridField->getColumnMetadata($col);
             $cols->push(new ArrayData(array('Name' => $col, 'Title' => $meta['title'])));
         }
     }
     $templateData = array();
     if (!count($this->config['actions'])) {
         user_error('Trying to use GridFieldBulkManager without any bulk action.', E_USER_ERROR);
     }
     //set up actions
     $actionsListSource = array();
     $actionsConfig = array();
     foreach ($this->config['actions'] as $action => $actionData) {
         $actionsListSource[$action] = $actionData['label'];
         $actionsConfig[$action] = $actionData['config'];
     }
     reset($this->config['actions']);
     $firstAction = key($this->config['actions']);
     $dropDownActionsList = DropdownField::create('bulkActionName', '')->setSource($actionsListSource)->setAttribute('class', 'bulkActionName no-change-track')->setAttribute('id', '');
     //initialize buttonLabel
     $buttonLabel = _t('CMC_GRIDFIELD_BULK_UPDATER.ACTION1_BTN_LABEL', $this->config['actions'][$firstAction]['label']);
     //add menu if more than one action
     if (count($this->config['actions']) > 1) {
         $templateData = array('Menu' => $dropDownActionsList->FieldHolder());
         $buttonLabel = _t('CMC_GRIDFIELD_BULK_UPDATER.ACTION_BTN_LABEL', 'Go');
     }
     //Debug::show($buttonLabel);
     $templateData = array_merge($templateData, array('Button' => array('Label' => $buttonLabel, 'Icon' => $this->config['actions'][$firstAction]['config']['icon']), 'Select' => array('Label' => _t('CMC_GRIDFIELD_BULK_UPDATER.SELECT_ALL_LABEL', 'Select all')), 'Colspan' => count($gridField->getColumns()) - 1, 'Cols' => $cols));
     $templateData = new ArrayData($templateData);
     return array('header' => $templateData->renderWith('CmcBulkUpdaterButtons'));
 }
开发者ID:cmcramer,项目名称:cmc-silverstripe-gridfieldbulkupdater,代码行数:65,代码来源:CmcGridFieldBulkUpdater.php

示例4: CustomMenu

 /**
  * Generate an list of items that will be loaded into the custom menu
  *
  * @param $menu template slug for retriving a menu
  * @return ArrayList
  */
 public function CustomMenu($menu = "")
 {
     $menu_items = new ArrayList();
     if (isset($menu)) {
         // Ensure argument is safe for database
         $menu = Convert::raw2sql($menu);
         $filter = array('Slug' => $menu);
         if ($menu = CustomMenuHolder::get()->filter($filter)->first()) {
             // If a custom order is set, use it
             if ($menu->Order) {
                 $order = explode(',', $menu->Order);
             }
             if (isset($order) && is_array($order) && count($order) > 0) {
                 foreach ($order as $item) {
                     $menu_items->push($menu->Pages()->find('ID', $item));
                 }
             } else {
                 foreach ($menu->Pages() as $item) {
                     $menu_items->push($item);
                 }
             }
         }
     }
     return $menu_items;
 }
开发者ID:helpfulrobot,项目名称:henrypenny-silverstripe-custommenus,代码行数:31,代码来源:CustomMenu.php

示例5: SplitSetIntoGridRows

 public function SplitSetIntoGridRows($itemsInGridMethod, $numberOfCols)
 {
     error_log("GRID ROWS");
     $itemsInGrid = $this->owner->{$itemsInGridMethod}();
     $position = 1;
     $columns = new ArrayList();
     $result = new ArrayList();
     foreach ($itemsInGrid as $key => $item) {
         $columns->push($item);
         error_log("Comparing position {$position} > number of cols {$numberOfCols}");
         if ($position >= $numberOfCols) {
             error_log("NEW ROW");
             $position = 1;
             $row = new ArrayList();
             $row->Columns = $columns;
             $result->push($row);
             $columns = new ArrayList();
         } else {
             $position = $position + 1;
         }
     }
     if ($columns->Count() > 0) {
         $row = new ArrayList();
         $row->Columns = $columns;
         $result->push($row);
     }
     // FIXME add padding?
     return $result;
     //$result = new DataObjectSet();
 }
开发者ID:helpfulrobot,项目名称:weboftalent-gridrows,代码行数:30,代码来源:GridRowsExtension.php

示例6: sitemap

 /**
  * We need to disable Translatable before retreiving the DataObjects or 
  * Pages for the sitemap, because otherwise only pages in the default 
  * language are found.
  * 
  * Next we need to add the alternatives for each Translatable Object 
  * included in the sitemap: basically these are the Translations plus 
  * the current object itself
  * 
  * @return Array
  */
 public function sitemap()
 {
     Translatable::disable_locale_filter();
     $sitemap = parent::sitemap();
     Translatable::enable_locale_filter();
     $updatedItems = new ArrayList();
     foreach ($sitemap as $items) {
         foreach ($items as $item) {
             if ($item->hasExtension('Translatable')) {
                 $translations = $item->getTranslations();
                 if ($translations) {
                     $alternatives = new ArrayList();
                     foreach ($translations as $translation) {
                         $translation->GoogleLocale = $this->getGoogleLocale($translation->Locale);
                         $alternatives->push($translation);
                     }
                     $item->GoogleLocale = $this->getGoogleLocale($item->Locale);
                     $alternatives->push($item);
                     $item->Alternatives = $alternatives;
                 }
                 $updatedItems->push($item);
             }
         }
     }
     if (!empty($updatedItems)) {
         return array('Items' => $updatedItems);
     } else {
         return $sitemap;
     }
 }
开发者ID:helpfulrobot,项目名称:martimiz-silverstripe-translatablegooglesitemaps,代码行数:41,代码来源:TranslatableGoogleSitemapController.php

示例7: sourceRecords

 /**
  * Setup the list of records to show.
  * @param array $params array of filter-rules.
  * @param array $sort
  * @param integer $limit
  * @return ArrayList with the records.
  */
 public function sourceRecords($params, $sort, $limit)
 {
     if ($sort) {
         $parts = explode(' ', $sort);
         $field = $parts[0];
         $direction = $parts[1];
     }
     $filter = array('Comments.ID:GreaterThan' => 0);
     if (count($params) > 0 && isset($params['Title'])) {
         $filter['News.Title:PartialMatch'] = $params['Title'];
     }
     $ret = News::get()->filter($filter);
     $returnSet = new ArrayList();
     if ($ret) {
         foreach ($ret as $record) {
             $record->Commentcount = $record->Comments()->count();
             $record->Spamcount = $record->Comments()->filter(array('AkismetMarked' => 1))->count();
             $record->Hiddencount = $record->Comments()->filter(array('AkismetMarked' => 0, 'Visible' => 0))->count();
             if (isset($params['Comment']) && $params['Comment'] == 'SPAMCOUNT' && $record->Spamcount > 0) {
                 $returnSet->push($record);
             } elseif (isset($params['Comment']) && $params['Comment'] == 'HIDDENCOUNT' && $record->Hiddencount > 0) {
                 $returnSet->push($record);
             } elseif (isset($params['Comment']) && $params['Comment'] == '' || !isset($params['Comment'])) {
                 $returnSet->push($record);
             }
         }
     }
     return $returnSet;
 }
开发者ID:MilesSummers,项目名称:silverstripe-newsmodule,代码行数:36,代码来源:CommentReport.php

示例8: unsignedAgreements

 /**
  * returns sorted User Agreements to be signed
  * @return ArrayList UserAgreement's required
  **/
 public function unsignedAgreements()
 {
     // are there any required agreements for this users groups?
     $groupIDs = $this->owner->Groups()->getIdList();
     $agreementsRemaining = new ArrayList();
     $requiredAgreements = $groupIDs ? UserAgreement::get()->filter('Archived', false)->filterAny('GroupID', $groupIDs) : null;
     $this->owner->extend('updateRequiredAgreements', $requiredAgreements);
     // collect agreements to be signed - checking agreement type (one off vs session)
     if ($requiredAgreements) {
         //Flush the component cache - which causes the First Agreement for each Member to be shown twice on the first occurrence
         $this->owner->flushCache();
         $signedAgreements = $this->owner->SignedAgreements();
         foreach ($requiredAgreements as $required) {
             if (!$signedAgreements->find('UserAgreementID', $required->ID)) {
                 $agreementsRemaining->push($required);
             } else {
                 if ($required->Type == 'Every Login') {
                     $signings = $this->owner->SignedAgreements("UserAgreementID='" . $required->ID . "'");
                     if (!$signings->find('SessionID', session_id())) {
                         $agreementsRemaining->push($required);
                     }
                 }
             }
         }
         $agreementsRemaining->sort('Sort', 'ASC');
     }
     return $agreementsRemaining;
 }
开发者ID:rodneyway,项目名称:silverstripe-useragreement,代码行数:32,代码来源:UserAgreementMember.php

示例9: listProducts

 public function listProducts()
 {
     $idlist = $this->getProductIdsForPage();
     if (is_array($idlist)) {
         $prods = Product::get()->byIDs($idlist)->sort('SortKey, Brand, Sold asc');
         #Nollst�ll
         $oldpostBrand = "";
         $oldpostSold = "";
         $outdata = new ArrayList();
         foreach ($prods as $prod) {
             if ($oldpostBrand != $prod->Brand || $oldpostSold != $prod->Sold) {
                 //                Rubrik ska skrivas ut  s�  den stoppas in i en egen ArrayData
                 $headerRow = new ArrayData(array('isHeaderRow' => true, 'HeaderBrand' => $prod->Brand, 'HeaderSold' => $prod->Sold));
                 $outdata->push($headerRow);
             }
             #Vanlig row
             $thisrow = $prod;
             $outdata->push($thisrow);
             #spara undan f�r att j�mf�ra
             $oldpostBrand = $prod->Brand;
             $oldpostSold = $prod->Sold;
         }
         return $outdata;
     }
 }
开发者ID:shoaibafzal,项目名称:Tiptop-musik-SilverStripe,代码行数:25,代码来源:Page.php

示例10: AvailableWidgets

 /**
  *
  * @return ArrayList
  */
 public function AvailableWidgets()
 {
     $widgets = new ArrayList();
     foreach ($this->widgetClasses as $widgetClass) {
         $classes = ClassInfo::subclassesFor($widgetClass);
         if (isset($classes['Widget'])) {
             unset($classes['Widget']);
         } else {
             if (isset($classes[0]) && $classes[0] == 'Widget') {
                 unset($classes[0]);
             }
         }
         $record = $this->form->getRecord();
         $availableWidgets = null;
         $restrictedWidgets = null;
         if ($record) {
             $availableWidgets = $record->config()->available_widgets;
             $restrictedWidgets = $record->config()->restricted_widgets;
         }
         foreach ($classes as $class) {
             if (!empty($availableWidgets) && is_array($availableWidgets) && !in_array($class, $availableWidgets) || !empty($restrictedWidgets) && is_array($restrictedWidgets) && in_array($class, $restrictedWidgets)) {
                 continue;
             }
             $available = Config::inst()->get($class, 'only_available_in');
             if (!empty($available) && is_array($available)) {
                 if (in_array($this->Name, $available)) {
                     $widgets->push(singleton($class));
                 }
             } else {
                 $widgets->push(singleton($class));
             }
         }
     }
     return $widgets;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-advancedwidgeteditor,代码行数:39,代码来源:AdvancedWidgetAreaEditor.php

示例11: testConvertDataObjectSet

 public function testConvertDataObjectSet()
 {
     $do = $this->getDataObjectStub(array('getAllowedFields', 'DynamicField'), array('Title' => 'This is a test title', 'Something' => 'Not allowed'));
     $do->expects($this->any())->method('getAllowedFields')->will($this->returnValue(array('Title', 'DynamicField')));
     $do->expects($this->any())->method('DynamicField')->will($this->returnValue('Test'));
     $formatter = $this->getFormatterStub();
     $dos = new ArrayList();
     $dos->push(clone $do);
     $dos->push(clone $do);
     $this->assertEquals(array(array('Title' => 'This is a test title', 'DynamicField' => 'Test'), array('Title' => 'This is a test title', 'DynamicField' => 'Test')), $formatter->convertDataObjectSet($dos));
 }
开发者ID:helpfulrobot,项目名称:heyday-silverstripe-flexibledataformatters,代码行数:11,代码来源:FlexibleDataFormatterTest.php

示例12: sequenceGridListItems

 /**
  * Inserts manually added blocks at front of list.
  *
  * @param \ArrayList|\DataList $items
  * @param                      $filters
  * @param array                $parameters
  */
 public function sequenceGridListItems(&$items, $filters, &$parameters = [])
 {
     $out = new \ArrayList();
     $blocks = $this->related()->Sort('Sort desc');
     foreach ($blocks as $block) {
         $out->push($block);
     }
     foreach ($items as $item) {
         $out->push($item);
     }
     $items = $out;
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:19,代码来源:HasGridListBlocks.php

示例13: getEventsContainer

 public function getEventsContainer($number)
 {
     $events = $this->getEvents()->limit($number)->toArray();
     $eventsAll = new ArrayList();
     for ($i = 0; $i < $number; $i++) {
         if (array_key_exists($i, $events)) {
             $eventsAll->push($events[$i]);
         } else {
             $eventsAll->push(null);
         }
     }
     return $eventsAll;
 }
开发者ID:shawn3a,项目名称:beardpapa,代码行数:13,代码来源:HomePage.php

示例14: InlineGalleries

 public function InlineGalleries()
 {
     $result = new ArrayList();
     // find child galleries
     foreach ($this->owner->AllChildren() as $child) {
         if ($child->ClassName == 'GalleryPage') {
             $result->push($child);
         }
     }
     if ($this->owner->AttachedGalleryID != 0) {
         $result->push($this->owner->AttachedGallery());
     }
     return $result;
 }
开发者ID:gordonbanderson,项目名称:ss3gallery,代码行数:14,代码来源:AttachedGalleryExtension.php

示例15: GetItems

 public function GetItems(ArrayList $photoset)
 {
     $photos = PhotoItem::get()->filter("PhotoAlbumID", $this->owner->ID);
     if ($photos) {
         foreach ($photos as $photo) {
             if ($photo->getComponent("Photo")->exists()) {
                 $photoset->push($photo);
             } elseif ($photo->getComponent("VideoItem")->exists()) {
                 $photoset->push($photo);
             }
         }
     }
     return $photoset;
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-video-embed,代码行数:14,代码来源:PhotoAlbumExtension.php


注:本文中的ArrayList::push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。