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


PHP ArrayData::create方法代码示例

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


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

示例1: onAfterInit

 /**
  *
  */
 public function onAfterInit()
 {
     if ($code = PageProoferConfig::get_page_proofer()) {
         $data = ArrayData::create(array('Code' => $code->Code));
         Requirements::customScript($data->renderWith('PageProofer'));
     }
 }
开发者ID:muskie9,项目名称:silverstripe-pageproofer,代码行数:10,代码来源:PageProofer.php

示例2: 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

示例3: 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

示例4: run

 /**
  * will ask the target server to return the file list and the data object list
  * @param type $request
  */
 public function run($request)
 {
     if (!$this->config()->target) {
         throw new Exception('Target not found in yml file. See readme.md for installation instructions.');
     }
     if (!$this->config()->key) {
         throw new Exception('Key not found in yml file. See readme.md for installation instructions.');
     }
     $myurl = Director::absoluteURL('/remoteassetdiff') . '/' . urlencode($this->config()->key);
     $downloadurl = Director::absoluteURL('/remoteassetdownload') . '/' . urlencode($this->config()->key) . '?m=' . time();
     // download without javascript
     if (Director::is_cli()) {
         ini_set('memory_limit', '1024M');
         set_time_limit(0);
         echo "Creating list of files to download" . PHP_EOL;
         $listoffiles = RemoteAssetTask::DownloadFile($myurl);
         $fullist = json_decode($listoffiles);
         if (!is_array($fullist->download)) {
             throw new Exception('Failure to download list of files');
         }
         foreach ($fullist->download as $file) {
             echo "Downloading {$file} ... ";
             try {
                 RemoteAssetTask::DownloadFile($downloadurl . '&download=' . $file);
                 echo "Success" . PHP_EOL;
             } catch (Exception $e) {
                 echo "Failure" . PHP_EOL;
             }
         }
         echo "Done" . PHP_EOL;
         return;
     }
     echo ArrayData::create(array('FetchURL' => $myurl, 'DownloadURL' => $downloadurl, 'Target' => $this->config()->target, 'ToMachine' => Director::absoluteURL('/')))->renderWith('RemoteAssetTask');
 }
开发者ID:otago,项目名称:remote-asset-download,代码行数:38,代码来源:RemoteAssetTask.php

示例5: 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

示例6: renderRows

 protected function renderRows($rows, ArrayIterator $splitcontent, &$pos = -1)
 {
     $output = "";
     $rownumber = 0;
     foreach ($rows as $row) {
         if ($row->cols) {
             $columns = array();
             foreach ($row->cols as $col) {
                 $nextcontent = $splitcontent->current();
                 $isholder = !isset($col->rows);
                 if ($isholder) {
                     $splitcontent->next();
                     //advance iterator if there are no sub-rows
                     $pos++;
                     //wrap split content in a HTMLText object
                     $dbObject = DBField::create_field('HTMLText', $nextcontent, "Content");
                     $dbObject->setOptions(array("shortcodes" => true));
                     $nextcontent = $dbObject;
                 }
                 $width = $col->width ? (int) $col->width : 1;
                 //width is at least 1
                 $columns[] = new ArrayData(array("Width" => $width, "EnglishWidth" => $this->englishWidth($width), "Content" => $isholder ? $nextcontent : $this->renderRows($col->rows, $splitcontent, $pos), "IsHolder" => $isholder, "GridPos" => $pos, "ExtraClasses" => isset($col->extraclasses) ? $col->extraclasses : null));
             }
             $output .= ArrayData::create(array("Columns" => new ArrayList($columns), "RowNumber" => (string) $rownumber++, "ExtraClasses" => isset($row->extraclasses) ? $row->extraclasses : null))->renderWith($this->template);
         } else {
             //every row should have columns!!
         }
     }
     return $output;
 }
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-gridstructuredcontent,代码行数:30,代码来源:GSCRenderer.php

示例7: getInstagramFeedItems

 public function getInstagramFeedItems()
 {
     $api_url = 'https://api.instagram.com/v1/tags/' . $this->configSettings['DefaultHash'] . '/media/recent?client_id=' . $this->configSettings['ClientID'];
     $ch = curl_init();
     curl_setopt_array($ch, array(CURLOPT_URL => $api_url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false));
     $output = curl_exec($ch);
     $instagram_json = json_decode($output);
     $whitelist_fields = array('created_time', 'link', 'images', 'likes');
     $row_array = array();
     foreach ($instagram_json->data as $items) {
         $coloumn_array = array();
         foreach ($items as $key => $value) {
             if (in_array($key, $whitelist_fields)) {
                 if ($key == 'images') {
                     $coloumn_array['LowResImage'] = $value->low_resolution->url;
                     $coloumn_array['StandardResImage'] = $value->standard_resolution->url;
                     $coloumn_array['Thumbnail'] = $value->thumbnail->url;
                 } elseif ($key == 'likes') {
                     $coloumn_array['Likes'] = $value->count;
                 } else {
                     $coloumn_array[$key] = $value;
                 }
             }
         }
         array_push($row_array, ArrayData::create($coloumn_array));
     }
     $instagram_feed_arraylist = ArrayList::create($row_array);
     return $instagram_feed_arraylist->renderWith('InstagramFeed');
 }
开发者ID:fanggu,项目名称:loveyourwater_ss_v3.1.6,代码行数:29,代码来源:InstagramFeed.php

示例8: index

 public function index(SS_HTTPRequest $request)
 {
     $properties = Property::get();
     $filters = ArrayList::create();
     if ($search = $request->getVar('Keywords')) {
         $filters->push(ArrayData::create(array('Label' => "Keywords: '{$search}'", 'RemoveLink' => HTTP::setGetVar('Keywords', null))));
         $properties = $properties->filter(array('Title:PartialMatch' => $search));
     }
     if ($arrival = $request->getVar('ArrivalDate')) {
         $arrivalStamp = strtotime($arrival);
         $nightAdder = '+' . $request->getVar('Nights') . ' days';
         $startDate = date('Y-m-d', $arrivalStamp);
         $endDate = date('Y-m-d', strtotime($nightAdder, $arrivalStamp));
         $properties = $properties->filter(array('AvailableStart:GreaterThanOrEqual' => $startDate, 'AvailableEnd:LessThanOrEqual' => $endDate));
     }
     if ($bedrooms = $request->getVar('Bedrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bedrooms} bedrooms", 'RemoveLink' => HTTP::setGetVar('Bedrooms', null))));
         $properties = $properties->filter(array('Bedrooms:GreaterThanOrEqual' => $bedrooms));
     }
     if ($bathrooms = $request->getVar('Bathrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bathrooms} bathrooms", 'RemoveLink' => HTTP::setGetVar('Bathrooms', null))));
         $properties = $properties->filter(array('Bathrooms:GreaterThanOrEqual' => $bathrooms));
     }
     if ($minPrice = $request->getVar('MinPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Min. \${$minPrice}", 'RemoveLink' => HTTP::setGetVar('MinPrice', null))));
         $properties = $properties->filter(array('PricePerNight:GreaterThanOrEqual' => $minPrice));
     }
     if ($maxPrice = $request->getVar('MaxPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Max. \${$maxPrice}", 'RemoveLink' => HTTP::setGetVar('MaxPrice', null))));
         $properties = $properties->filter(array('PricePerNight:LessThanOrEqual' => $maxPrice));
     }
     $paginatedProperties = PaginatedList::create($properties, $request)->setPageLength(15)->setPaginationGetVar('s');
     return array('Results' => $paginatedProperties, 'ActiveFilters' => $filters);
 }
开发者ID:roopamjain01,项目名称:one_ring,代码行数:34,代码来源:PropertySearchPage.php

示例9: 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

示例10: __construct

 /**
  * Returns an instance of this class
  *
  * @param Controller $controller
  * @param string $name
  */
 public function __construct($controller, $name)
 {
     $fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class)));
     $loginButtonContent = ArrayData::create(array('Label' => _t('RealMeLoginForm.LOGINBUTTON', 'Login or register with RealMe')))->renderWith('RealMeLoginButton');
     $actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent($loginButtonContent)->setAttribute('class', 'realme_button')));
     // Taken from MemberLoginForm
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } elseif (Session::get('BackURL')) {
         $backURL = Session::get('BackURL');
     }
     if (isset($backURL)) {
         // Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page
         if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) {
             $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
         }
     }
     // optionally include requirements {@see /realme/_config/config.yml}
     if ($this->config()->include_jquery) {
         Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
     }
     if ($this->config()->include_javascript) {
         Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js");
     }
     if ($this->config()->include_css) {
         Requirements::css(REALME_MODULE_PATH . "/css/realme.css");
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
开发者ID:silverstripe,项目名称:silverstripe-realme,代码行数:35,代码来源:RealMeLoginForm.php

示例11: 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

示例12: 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

示例13: Field

 public function Field($properties = array())
 {
     if ($this->firstActive) {
         $this->makeFirstActive();
     }
     $properties['endCarousel'] = true;
     $properties['outerCarouselNavigation'] = true;
     $properties['carouselNavigationClasses'] = 'carousel-static';
     if (!isset($properties['startCarousel'])) {
         $properties['startCarousel'] = $this->ID();
     }
     if (!isset($properties['carouselParentAttributes'])) {
         $properties['carouselParentAttributes'] = $this->JSONAttributesHTML;
     }
     if (!isset($properties['slides'])) {
         $properties['slides'] = $this->children;
     }
     if (!isset($properties['carouselNavigation']) && $this->children && $this->children->exists()) {
         $properties['carouselName'] = $this->ID();
         $properties['carouselNavigation'] = ArrayList::create();
         foreach ($this->children as $child) {
             $properties['carouselNavigation']->push(ArrayData::create(array('carouselTitle' => $child->Title(), 'carouselActive' => $child->isActive(), 'carouselName' => $this->ID())));
         }
     }
     return parent::Field($properties);
 }
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-mwm-formfields,代码行数:26,代码来源:SliderComponentField.php

示例14: generateScriptDataFor

 public function generateScriptDataFor($type, $file = null)
 {
     if (!class_exists($type)) {
         throw new Exception("Invalid type defined, no data generated");
     }
     $typeConfig = $this->configFor($type);
     $config = isset($typeConfig[$file]) ? $typeConfig[$file] : array();
     // TODO - allow for specifying things like strtotime things for dates in some manner
     $rules = isset($config['filter']) ? $config['filter'] : null;
     $list = $type::get();
     if ($rules) {
         $list = $this->applyRulesToList($list, $rules);
     }
     $template = isset($config['template']) ? $config['template'] : 'JsonSet';
     $setFields = isset($config['fields']) ? $config['fields'] : null;
     if ($setFields) {
         $setFields = explode(',', $setFields);
     }
     $order = isset($config['order']) ? $config['order'] : 'ID DESC';
     $list = $list->sort($order);
     $list = $list->filterByCallback(function ($item) use($setFields) {
         // extension check was done on the type earlier, here we're just being careful
         if ($item->hasExtension('GenieExtension') && $setFields) {
             $item->setJSONFields($setFields);
         }
         return $item->canView();
     });
     $data = ArrayData::create(array('RootObject' => isset($config['rootObject']) ? $config['rootObject'] : 'window', 'Type' => $type, 'Items' => $list));
     $output = $data->renderWith($template);
     return $output;
 }
开发者ID:helpfulrobot,项目名称:marketo-silverstripe-script-genie,代码行数:31,代码来源:GenieScriptService.php

示例15: getOptions

 public function getOptions()
 {
     $options = ArrayList::create();
     foreach ($this->optionsList as $val => $label) {
         $options->push(ArrayData::create(array('Label' => $label, 'Value' => $val, 'Selected' => $this->Value() == $val)));
     }
     return $options;
 }
开发者ID:helpfulrobot,项目名称:unclecheese-bootstrap-forms,代码行数:8,代码来源:BootstrapButtonGroupField.php


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