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


PHP ArrayList::create方法代码示例

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


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

示例1: Inputs

 public function Inputs()
 {
     if (count($this->linkedFields)) {
         return \ArrayList::create();
     }
     $ranged = is_array($this->settings['start']) && count($this->settings['start']) > 1;
     $minName = $ranged ? 'min' : 'value';
     $fields[$minName] = ['Render' => $this->castedCopy(\NumericField::create($this->Name . '[' . $minName . ']'))];
     $fields[$minName]['Render']->Value = is_array($this->settings['start']) ? $this->settings['start'][0] : $this->settings['start'];
     if ($ranged) {
         $fields['max'] = ['Render' => $this->castedCopy(\NumericField::create($this->Name . '[max]'))];
         $fields['max']['Render']->Value = $this->settings['start'][1];
     }
     $count = 0;
     array_walk($fields, function ($field) use(&$count) {
         if (!isset($field['Handle'])) {
             $field['Handle'] = $count % 2 ? 'upper' : 'lower';
         }
         if (isset($field['Render'])) {
             $field['Render']->removeExtraClass('rangeslider-display')->addExtraClass('rangeslider-linked')->setAttribute('data-rangeslider-handle', $field['Handle']);
         }
         $count++;
     });
     $fields = \ArrayList::create(array_map(function ($field) {
         return \ArrayData::create($field);
     }, $fields));
     if ($this->inputCallback && is_callable($this->inputCallback)) {
         call_user_func_array($this->inputCallback, [$fields]);
     }
     $this->extend('updateInputs', $fields);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-mwm-formfields,代码行数:32,代码来源:RangeSliderField.php

示例2: 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());
 }
开发者ID:jaedb,项目名称:dev-tools,代码行数:36,代码来源:DebugTools_ContentControllerExtension.php

示例3: Field

 /**
  * Creates a rendered Programme Crawler Field using the .ss template
  * @param type $properties an array of values to decorate the field
  * @return type a rendered template
  */
 function Field($properties = array())
 {
     $obj = $properties ? $this->customise($properties) : $this;
     $obj->Options = ArrayList::create();
     $dobj = DataObject::create();
     $dobj->MyTitle = 'No Color';
     $dobj->Value = '';
     $dobj->CSSRGB = '255 255 255';
     $dobj->CSSHex = '#ffffff';
     $dobj->CSSCMYK = '0 0 0 0';
     $obj->Options->push($dobj);
     $source = ColourSchemes::get()->sort('ID');
     if ($source) {
         foreach ($source as $value) {
             $mobj = DataObject::create();
             $mobj->MyTitle = $value->OPColor;
             $mobj->Value = $value->CSSColor;
             $mobj->CSSRGB = $value->CSSRGB;
             $mobj->CSSHex = $value->CSSHex;
             $mobj->CSSCMYK = $value->CSSCMYK;
             $obj->Options->push($mobj);
         }
     }
     // directly point to the template file
     $tmp = $obj->renderWith(BASE_PATH . '/' . OPCOLORWORKINGFOLDER . "/templates/OpColorField.ss");
     return $tmp;
 }
开发者ID:helpfulrobot,项目名称:otago-opcolor,代码行数:32,代码来源:OpColorField.php

示例4: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $subsites = DataObject::get('Subsite');
     if (!$subsites) {
         $subsites = new ArrayList();
     } else {
         $subsites = ArrayList::create($subsites->toArray());
     }
     $subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0)));
     $fields->addFieldToTab('Root.Main', DropdownField::create("CopyContentFromID_SubsiteID", _t('SubsitesVirtualPage.SubsiteField', "Subsite"), $subsites->map('ID', 'Title'))->addExtraClass('subsitestreedropdownfield-chooser no-change-track'), 'CopyContentFromID');
     // Setup the linking to the original page.
     $pageSelectionField = new SubsitesTreeDropdownField("CopyContentFromID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle");
     if (Controller::has_curr() && Controller::curr()->getRequest()) {
         $subsiteID = Controller::curr()->getRequest()->requestVar('CopyContentFromID_SubsiteID');
         $pageSelectionField->setSubsiteID($subsiteID);
     }
     $fields->replaceField('CopyContentFromID', $pageSelectionField);
     // Create links back to the original object in the CMS
     if ($this->CopyContentFromID) {
         $editLink = "admin/pages/edit/show/{$this->CopyContentFromID}/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID;
         $linkToContent = "\n\t\t\t\t<a class=\"cmsEditlink\" href=\"{$editLink}\">" . _t('VirtualPage.EDITCONTENT', 'Click here to edit the content') . "</a>";
         $fields->removeByName("VirtualPageContentLinkLabel");
         $fields->addFieldToTab("Root.Main", $linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent), 'Title');
         $linkToContentLabelField->setAllowHTML(true);
     }
     $fields->addFieldToTab('Root.Main', TextField::create('CustomMetaTitle', $this->fieldLabel('CustomMetaTitle'))->setDescription(_t('SubsitesVirtualPage.OverrideNote', 'Overrides inherited value from the source')), 'MetaTitle');
     $fields->addFieldToTab('Root.Main', TextareaField::create('CustomMetaKeywords', $this->fieldLabel('CustomMetaTitle'))->setDescription(_t('SubsitesVirtualPage.OverrideNote')), 'MetaKeywords');
     $fields->addFieldToTab('Root.Main', TextareaField::create('CustomMetaDescription', $this->fieldLabel('CustomMetaTitle'))->setDescription(_t('SubsitesVirtualPage.OverrideNote')), 'MetaDescription');
     $fields->addFieldToTab('Root.Main', TextField::create('CustomExtraMeta', $this->fieldLabel('CustomMetaTitle'))->setDescription(_t('SubsitesVirtualPage.OverrideNote')), 'ExtraMeta');
     return $fields;
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:32,代码来源:SubsitesVirtualPage.php

示例5: getGoogleBaseCategoryList

 /**
  * Returns list of categories used in GoogleBase.ss template
  * Override with getGoogleBaseCategoryList on Product defaults to getGoogleBaseCategoryList on GoogleBaseProduct
  * @return ArrayList of categories
  */
 public function getGoogleBaseCategoryList()
 {
     $list = $this->owner->GoogleBaseCategories;
     if ($list) {
         $allCategories = ArrayList::create();
         $categories = explode(' > ', $list);
         $string = '';
         $count = 0;
         $used = array();
         foreach ($categories as $k => $category) {
             if (isset($used[$category])) {
                 continue;
             }
             $used[$category] = $category;
             ++$count;
             if ($count == 1) {
                 $string = trim($category);
             } else {
                 $string .= ' > ' . trim($category);
             }
             $allCategories->push(ArrayData::create(array('Category' => $string)));
         }
         return $allCategories;
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:tylerkidd-silverstripe-shop-google-base,代码行数:31,代码来源:GoogleBaseProduct.php

示例6: getAllListsByCategory

 public static function getAllListsByCategory($SummitCategoryID)
 {
     $category = PresentationCategory::get()->byID($SummitCategoryID);
     // An empty array list that we'll use to return results
     $results = ArrayList::create();
     // Get any existing lists made for this category
     $AllLists = SummitSelectedPresentationList::get()->filter('CategoryID', $SummitCategoryID)->sort('ListType', 'ASC');
     // Filter to lists of any other track chairs
     $OtherTrackChairLists = $AllLists->filter('ListType', 'Individual')->exclude('MemberID', Member::currentUser()->ID);
     $MemberList = $category->MemberList(Member::currentUser()->ID);
     $GroupList = $category->GroupList();
     if ($MemberList) {
         $results->push($MemberList);
     }
     foreach ($OtherTrackChairLists as $list) {
         $results->push($list);
     }
     if ($GroupList) {
         $results->push($GroupList);
     }
     // Add each of those lists to our results
     foreach ($results as $list) {
         if ($list->ListType == "Individual") {
             $list->name = $list->Member()->FirstName . ' ' . $list->Member()->Surname;
         }
         if ($list->ListType == "Group") {
             $list->name = 'Team Selections';
         }
     }
     return $results;
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:31,代码来源:SummitSelectedPresentationList.php

示例7: createResponsiveSet

 /**
  * Requires the necessary JS and sends the required HTML structure to the template
  * for a responsive image set
  *
  * @param array $config The configuration of the responsive image set from the config
  * @param array $args The arguments passed to the responsive image method, e.g. $MyImage.ResponsiveSet1(800x600)
  * @param string $method The method, or responsive image set, to generate
  * @return SSViewer
  */
 protected function createResponsiveSet($config, $args, $method)
 {
     Requirements::javascript(RESPONSIVE_IMAGES_DIR . '/javascript/picturefill/external/matchmedia.js');
     Requirements::javascript(RESPONSIVE_IMAGES_DIR . '/javascript/picturefill/picturefill.js');
     if (!isset($config['sizes']) || !is_array($config['sizes'])) {
         throw new Exception("Responsive set {$method} does not have sizes defined in its config.");
     }
     if (isset($args[0])) {
         $defaultDimensions = $args[0];
     } elseif (isset($config['default_size'])) {
         $defaultDimensions = $config['default_size'];
     } else {
         $defaultDimensions = Config::inst()->forClass("ResponsiveImageExtension")->default_size;
     }
     if (isset($args[1])) {
         $methodName = $args[1];
     } elseif (isset($config['method'])) {
         $methodName = $config['method'];
     } else {
         $methodName = Config::inst()->forClass("ResponsiveImageExtension")->default_method;
     }
     $sizes = ArrayList::create();
     foreach ($config['sizes'] as $i => $arr) {
         if (!isset($arr['query'])) {
             throw new Exception("Responsive set {$method} does not have a 'query' element defined for size index {$i}");
         }
         if (!isset($arr['size'])) {
             throw new Exception("Responsive set {$method} does not have a 'size' element defined for size index {$i}");
         }
         list($width, $height) = $this->parseDimensions($arr['size']);
         $sizes->push(ArrayData::create(array('Image' => $this->owner->getFormattedImage($methodName, $width, $height), 'Query' => $arr['query'])));
     }
     list($default_width, $default_height) = $this->parseDimensions($defaultDimensions);
     return $this->owner->customise(array('Sizes' => $sizes, 'DefaultImage' => $this->owner->getFormattedImage($methodName, $default_width, $default_height)))->renderWith('ResponsiveImageSet');
 }
开发者ID:sheadawson,项目名称:silverstripe-responsive-images,代码行数:44,代码来源:ResponsiveImageExtension.php

示例8: Languages

 /**
  * Get a set of content languages (for quick language navigation)
  * @example
  * <code>
  * <!-- in your template -->
  * <ul class="langNav">
  * 		<% loop Languages %>
  * 		<li><a href="$Link" class="$LinkingMode" title="$Title.ATT">$Language</a></li>
  * 		<% end_loop %>
  * </ul>
  * </code>
  *
  * @return ArrayList|null
  */
 public function Languages()
 {
     $locales = TranslatableUtility::get_content_languages();
     // there's no need to show a navigation when there's less than 2 languages. So return null
     if (count($locales) < 2) {
         return null;
     }
     $currentLocale = Translatable::get_current_locale();
     $homeTranslated = null;
     if ($home = SiteTree::get_by_link('home')) {
         /** @var SiteTree $homeTranslated */
         $homeTranslated = $home->getTranslation($currentLocale);
     }
     /** @var ArrayList $langSet */
     $langSet = ArrayList::create();
     foreach ($locales as $locale => $name) {
         Translatable::set_current_locale($locale);
         /** @var SiteTree $translation */
         $translation = $this->owner->hasTranslation($locale) ? $this->owner->getTranslation($locale) : null;
         $langSet->push(new ArrayData(array('Locale' => $locale, 'RFC1766' => i18n::convert_rfc1766($locale), 'Language' => DBField::create_field('Varchar', strtoupper(i18n::get_lang_from_locale($locale))), 'Title' => DBField::create_field('Varchar', html_entity_decode(i18n::get_language_name(i18n::get_lang_from_locale($locale), true), ENT_NOQUOTES, 'UTF-8')), 'LinkingMode' => $currentLocale == $locale ? 'current' : 'link', 'Link' => $translation ? $translation->AbsoluteLink() : ($homeTranslated ? $homeTranslated->Link() : ''))));
     }
     Translatable::set_current_locale($currentLocale);
     i18n::set_locale($currentLocale);
     return $langSet;
 }
开发者ID:bummzack,项目名称:translatable-dataobject,代码行数:39,代码来源:TranslatableUtility.php

示例9: RSSItems

 /**
  * Gets a list of all the items in the RSS feed given a user-provided URL, limit, and date format
  *
  * @return ArrayList
  */
 public function RSSItems()
 {
     if (!$this->FeedURL) {
         return false;
     }
     $doc = new DOMDocument();
     @$doc->load($this->FeedURL);
     $items = $doc->getElementsByTagName('item');
     $feeds = array();
     foreach ($items as $node) {
         $itemRSS = array('title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue);
         $feeds[] = $itemRSS;
     }
     $output = ArrayList::create(array());
     $count = 0;
     foreach ($feeds as $item) {
         if ($count >= $this->Count) {
             break;
         }
         // Cast the Date
         $date = new Date('Date');
         $date->setValue($item['date']);
         // Cast the Title
         $title = new Text('Title');
         $title->setValue($item['title']);
         $output->push(new ArrayData(array('Title' => $title, 'Date' => $date->Format($this->DateFormat), 'Link' => $item['link'])));
         $count++;
     }
     return $output;
 }
开发者ID:helpfulrobot,项目名称:unclecheese-dashboard,代码行数:35,代码来源:DashboardRSSFeedPanel.php

示例10: 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'];
     }
     /** @var ArrayList|News[] $ret */
     $ret = News::get()->filter($filter);
     /** @var ArrayList $returnSet */
     $returnSet = ArrayList::create();
     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:firesphere,项目名称:silverstripe-newsmodule,代码行数:40,代码来源:CommentReport.php

示例11: generateMenuItems

 public function generateMenuItems()
 {
     $all = array();
     $allids = array();
     $public = $this->getPublicNodes();
     foreach ($public as $row) {
         $allids[$row['ID']] = true;
         $all[] = $row;
     }
     // and private nodes
     $private = $this->getPrivateNodes();
     foreach ($private as $row) {
         $allids[$row['ID']] = true;
         $all[] = $row;
     }
     $others = $this->getAdditionalNodes();
     foreach ($others as $row) {
         $allids[$row['ID']] = true;
         $all[] = $row;
     }
     $deferred = array();
     $final = array();
     $hierarchy = array();
     $counter = 0;
     $this->iterateNodes($final, $all, $allids, 0);
     $ordered = ArrayList::create();
     // start at 0
     if (isset($final[0]['kids'])) {
         foreach ($final[0]['kids'] as $id) {
             $node = $final[$id];
             $this->buildLinks($node, null, $ordered, $final);
         }
     }
 }
开发者ID:nyeholt,项目名称:silverstripe-performant,代码行数:34,代码来源:SiteDataService.php

示例12: getItems

 public function getItems()
 {
     $viewables = ArrayList::create();
     $source = $this->AbsoluteSource ? $this->Source() : Controller::curr()->data();
     $items = $this->EnforceShowInMenu ? $source->Children() : $source->AllChildren();
     if (!$items || !$items->Count()) {
         return $viewables;
     }
     if ($this->PageTypes) {
         $types = $this->obj('PageTypes')->getValues();
         if (count($types)) {
             $items = $items->filter(array('ClassName' => array_values($types)));
         }
     }
     if ($this->ExcludeItems && $this->AbsoluteSource && $items->Count()) {
         $excludes = $this->obj('ExcludeItems')->getValues();
         if (count($excludes)) {
             $items = $items->exclude(array('ID' => array_values($excludes)));
         }
     }
     foreach ($items as $item) {
         if ($item->canView()) {
             $viewables->push($item);
         }
     }
     return $viewables;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-ba-sis,代码行数:27,代码来源:ChildPageListBlock.php

示例13: Weather

 public function Weather()
 {
     if (!$this->Location) {
         return false;
     }
     $rnd = time();
     $url = "http://query.yahooapis.com/v1/public/yql?format=json&rnd={$rnd}&diagnostics=true&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=";
     $query = urlencode("select * from weather.forecast where location in (select id from weather.search where query=\"{$this->Location}\") and u=\"{$this->Units}\"");
     $response = file_get_contents($url . $query);
     if ($response) {
         $result = Convert::json2array($response);
         if (!$result["query"]["results"]) {
             return false;
         }
         $days = ArrayList::create(array());
         $channel = isset($result["query"]["results"]["channel"][0]) ? $result["query"]["results"]["channel"][0] : $result["query"]["results"]["channel"];
         $label = $channel["title"];
         $link = $channel["link"];
         $forecast = $channel["item"]["forecast"];
         for ($i = 0; $i < 2; $i++) {
             $item = $forecast[$i];
             $days->push(ArrayData::create(array('High' => $item["high"], 'Low' => $item["low"], 'ImageURL' => "http://l.yimg.com/a/i/us/we/52/" . $item["code"] . ".gif", 'Label' => $i == 0 ? _t('Dashboard.TODAY', 'Today') : _t('Dashboard.TOMORROW', 'Tomorrow'))));
         }
         $html = $this->customise(array('Location' => str_replace("Yahoo! Weather - ", "", $label), 'Link' => $link, 'Days' => $days))->renderWith('DashboardWeatherContent');
         $this->WeatherHTML = $html;
         $this->write();
         return $html;
     }
     return $this->WeatherHTML;
 }
开发者ID:nathancox,项目名称:silverstripe-dashboard,代码行数:30,代码来源:DashboardWeatherPanel.php

示例14: addMessage

 public function addMessage($message, $type)
 {
     if (!is_a($this->Messages, 'ArrayList')) {
         $this->Messages = ArrayList::create();
     }
     $this->Messages->add(ArrayData::create(array('Message' => $message, 'Type' => $type)));
 }
开发者ID:Marketo,项目名称:SilverStripe-Authorized-Redirects,代码行数:7,代码来源:AuthorizedPage.php

示例15: ChartData

 public function ChartData()
 {
     $chartData = array();
     $list = ArrayList::create(array());
     $sqlQuery = new SQLQuery();
     $sqlQuery->setFrom('Addon');
     $sqlQuery->setSelect('Created');
     $sqlQuery->selectField('COUNT(*)', 'CountInOneDay');
     $sqlQuery->addWhere('"Created" >= DATE_SUB(NOW(), INTERVAL 30 DAY)');
     $sqlQuery->addGroupBy('DATE(Created)');
     $result = $sqlQuery->execute();
     if (count($result)) {
         foreach ($result as $row) {
             $date = date('j M Y', strtotime($row['Created']));
             if (!isset($chartData[$date])) {
                 $chartData[$date] = $row['CountInOneDay'];
             }
         }
     }
     if (count($chartData)) {
         foreach ($chartData as $x => $y) {
             $list->push(ArrayData::create(array('XValue' => $x, 'YValue' => $y)));
         }
     }
     return $list;
 }
开发者ID:newleeland,项目名称:addons.silverstripe.org,代码行数:26,代码来源:HomeController.php


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