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


PHP ArrayData::setField方法代码示例

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


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

示例1: factory

 /**
  * @param  array $data
  * @return DrupalTermContentItem
  */
 public static function factory($source, $data)
 {
     $linkData = $data['link'];
     $item = new self($source, 'menulink:' . $linkData['mlid']);
     $item->DrupalID = $linkData['mlid'];
     $item->Title = html_entity_decode($linkData['title']);
     $item->MenuTitle = $item->Title;
     $item->Description = $linkData['description'];
     $item->Path = $linkData['path'];
     $item->PathAlias = $linkData['path_alias'];
     $item->Href = $linkData['href'];
     $item->Hidden = $linkData['hidden'];
     $item->External = $linkData['external'];
     $item->HasChildren = $linkData['has_children'];
     $item->Weight = $linkData['weight'];
     $item->Depth = $linkData['depth'];
     $options = new ArrayData(array());
     if (isset($linkData['options'])) {
         foreach ($linkData['options'] as $key => $value) {
             $options->setField($key, $value);
         }
     }
     $item->Options = $options;
     // Set the name for the tree.
     $item->Name = $item->MenuTitle;
     // Check if we have to load any node content
     $item->Node = NULL;
     if (strlen($item->Path) > 5 && substr($item->Path, 0, 5) == 'node/') {
         $nodeId = 'node:' . substr($item->Path, 5);
         $item->Node = $source->getObject($source->encodeId($nodeId));
         $item->Title = $item->Node->Title;
     }
     return $item;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-drupal-connector,代码行数:38,代码来源:DrupalMenuLinkContentItem.php

示例2: testSetField

 function testSetField()
 {
     $arrayData = new ArrayData(array());
     $arrayData->setField('d', 'Delta');
     $this->assertTrue($arrayData->hasField('d'));
     $this->assertEquals('Delta', $arrayData->getField('d'));
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例3: factory

 /**
  * @param  array $data
  * @return DrupalTermContentItem
  */
 public static function factory($source, $data)
 {
     $item = new self($source, 'taxonomyterm:' . $data['tid']);
     $item->DrupalID = $data['tid'];
     $item->VocabularyID = $data['vid'];
     $item->TermName = html_entity_decode($data['name']);
     $item->Title = $item->TermName;
     $item->Description = html_entity_decode($data['description']);
     $item->Weight = $data['weight'];
     if (isset($data['language'])) {
         $item->Language = $data['language'];
     }
     if (isset($data['trid'])) {
         $item->TRID = $data['trid'];
     }
     $item->Depth = $data['depth'];
     $parents = new ArrayData(array());
     foreach ($data['parents'] as $key => $value) {
         $parents->setField($key, $value);
     }
     $item->Parents = $parents;
     // Set the name for the tree.
     $item->Name = $item->TermName;
     return $item;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-drupal-connector,代码行数:29,代码来源:DrupalTaxonomyTermContentItem.php

示例4: loadData

 protected function loadData($data)
 {
     if (isset($data['link'])) {
         $linkData = $data['link'];
         $this->DrupalMenuLinkID = $linkData['mlid'];
         $this->MenuTitle = html_entity_decode($linkData['title']);
         $this->Description = $linkData['description'];
         $this->Path = $linkData['path'];
         $this->PathAlias = $linkData['path_alias'];
         $this->Href = $linkData['href'];
         $this->Hidden = $linkData['hidden'];
         $this->External = $linkData['external'];
         $this->HasChildren = $linkData['has_children'];
         $this->Weight = $linkData['weight'];
         $this->Depth = $linkData['depth'];
         $options = new ArrayData(array());
         foreach ($linkData['options'] as $key => $value) {
             $options->setField($key, $value);
         }
         $this->Options = $options;
     }
     // Set the name for the tree.
     $this->Name = $this->MenuTitle;
     // Set up this default. It will get overridden by the DrupalNodeContentItem base class.
     $this->Title = $this->MenuTitle;
 }
开发者ID:robert-h-curry,项目名称:silverstripe-drupal-connector,代码行数:26,代码来源:DrupalMenuLinkContentItem.php

示例5: _convertNode

 private static function _convertNode($node)
 {
     $data = new ArrayData(array('Id' => $node['id'], 'Title' => $node['title']));
     if (isset($node['children'])) {
         $data->setField('Children', self::_convertChildren($node['children']));
     }
     return $data;
 }
开发者ID:helpfulrobot,项目名称:entidi-silverstripe-autotoc,代码行数:8,代码来源:Autotoc.php

示例6: render

 public function render(Controller $controller, ArrayData $data)
 {
     // Require js library
     Requirements::javascript(CONSULTATION_MODULE_DIR . '/js/justGage/raphael.2.1.0.min.js');
     Requirements::javascript(CONSULTATION_MODULE_DIR . '/js/justGage/justgage.1.0.1.min.js');
     // Customise data
     $data->setField('jsData', $this->jsData($data));
     // Perform rendering
     return $controller->customise($data)->renderWith($this->template);
 }
开发者ID:dnadesign,项目名称:silverstripe-consultations,代码行数:10,代码来源:JustGageReport.php

示例7: render

 public function render(Controller $controller, ArrayData $data)
 {
     // Require js library
     Requirements::javascript(CONSULTATION_MODULE_DIR . '/js/chart.js');
     Requirements::javascript(CONSULTATION_MODULE_DIR . '/js/doughnut.init.js');
     Requirements::css(CONSULTATION_MODULE_DIR . '/css/doughnut_report.css');
     // Customise data
     $data->setField('jsData', $this->jsData($data));
     // Perform rendering
     return $controller->customise($data)->renderWith($this->template);
 }
开发者ID:dnadesign,项目名称:silverstripe-consultations,代码行数:11,代码来源:DonutChartReport.php

示例8: array_to_viewabledata

 /**
  * Helper function to convert a multi-dimensional array (associative or indexed) to an {@link ArrayList} or
  * {@link ArrayData} object structure, so that values can be used in templates.
  *
  * @param array $array The (single- or multi-dimensional) array to convert
  * @return object Either an {@link ArrayList} or {@link ArrayData} object, or the original item ($array) if $array
  * isn't an array.
  */
 public static function array_to_viewabledata($array)
 {
     // Don't transform non-arrays
     if (!is_array($array)) {
         return $array;
     }
     // Figure out whether this is indexed or associative
     $keys = array_keys($array);
     $assoc = $keys != array_keys($keys);
     if ($assoc) {
         // Treat as viewable data
         $data = new ArrayData(array());
         foreach ($array as $key => $value) {
             $data->setField($key, self::array_to_viewabledata($value));
         }
         return $data;
     } else {
         // Treat this as basic non-associative list
         $list = new ArrayList();
         foreach ($array as $value) {
             $list->push(self::array_to_viewabledata($value));
         }
         return $list;
     }
 }
开发者ID:udomsak,项目名称:deploynaut,代码行数:33,代码来源:DNEnvironment.php

示例9: getMergeFieldsMap

 /**
  * Allows the use of field values in email body.
  *
  * @param ArrayList fields
  * @return ArrayData
  */
 private function getMergeFieldsMap($fields = array())
 {
     $data = new ArrayData(array());
     foreach ($fields as $field) {
         $data->setField($field->Name, DBField::create_field('Text', $field->Value));
     }
     return $data;
 }
开发者ID:sentromedia,项目名称:letsfund,代码行数:14,代码来源:UserDefinedForm.php

示例10: DetailedForecast

    public function DetailedForecast($days = 5, $render = true)
    {
        $forecast = OpenWeatherMapAPI::detailed_forecast($this->OpenWeatherMapStationID, $days);
        $forecasts = array();
        $list = $forecast->list;
        $result = new ArrayList();
        $ctr = 0;
        $ctrmax = 8 * $days;
        // chart data
        $labels = array();
        $temperaturedata = array();
        $rainfalldata = array();
        $humiditydata = array();
        $cloudcoverdata = array();
        foreach ($list as $forecastdata) {
            error_log('Iterating list for forecast data');
            $fc = $this->json_weather_to_data_object($forecastdata);
            if (isset($forecastdata->rain)) {
                $fc->Rain3Hours = $forecastdata->rain->{'3h'};
            } else {
                $fc->Rain3Hours = 0;
            }
            $dt = $forecastdata->dt;
            $ssdt = new SS_Datetime();
            $ssdt->setValue($dt);
            $fc->DateTime = $ssdt;
            $result->push($fc);
            $q = '"';
            array_push($labels, $q . $ssdt->Format('H:i') . $q);
            array_push($temperaturedata, $q . $fc->TemperatureCurrent . $q);
            error_log('RAIN - pushing ' . $fc->Rain3Hours);
            array_push($rainfalldata, $q . $fc->Rain3Hours . $q);
            array_push($humiditydata, $q . $fc->Humidity . $q);
            array_push($cloudcoverdata, $q . $fc->CloudCoverPercentage . $q);
            $ctr++;
            if ($ctr >= $ctrmax) {
                break;
            }
        }
        $labelcsv = implode(',', $labels);
        $temperaturecsv = implode(',', $temperaturedata);
        $rainfallcsv = implode(',', $rainfalldata);
        $cloudcovercsv = implode(',', $cloudcoverdata);
        $humiditycsv = implode(',', $humiditydata);
        error_log($rainfallcsv);
        // initialise variables for templates
        $varsarray = array('Labels' => $labelcsv, 'Temperatures' => $temperaturecsv, 'Rainfall' => $rainfallcsv, 'Humidity' => $humiditycsv, 'CloudCover' => $cloudcovercsv, 'Forecasts' => $result, 'Station' => $this);
        $vars = new ArrayData($varsarray);
        // get the temperature JavaScript from a template.  Override in your own theme as desired
        $chartOptions = $vars->renderWith('ChartOptionsJS');
        $vars->setField('ChartOptions', $chartOptions);
        $temperatureJS = $vars->renderWith('TemperatureChartJS');
        $rainfallJS = $vars->renderWith('RainfallChartJS');
        $cloudhumidyJS = $vars->renderWith('CloudCoverHumidityChartJS');
        if ($render) {
            Requirements::css('openweathermap/css/openweathermap.css');
            Requirements::javascript('openweathermap/javascript/chart.min.js');
            Requirements::customScript(<<<JS
\t\t\t{$temperatureJS}
\t\t\t{$rainfallJS}
\t\t\t{$cloudhumidyJS}
JS
);
            return $vars->renderWith('ForecastDetailed');
        } else {
            $vars->setField('ChartsJavascript', $temperatureJS . "\n" . $rainfallJS . "\n" . $cloudhumidyJS . "\n");
        }
        $this->TemplateVars = $vars;
    }
开发者ID:helpfulrobot,项目名称:weboftalent-openweathermap,代码行数:69,代码来源:OpenWeatherMapStation.php


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