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


PHP DataTable::makeFromSimpleArray方法代码示例

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


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

示例1: renderTable

 /**
  * Computes the output for the given data table
  *
  * @param DataTable $table
  * @return string
  */
 protected function renderTable($table)
 {
     if (is_array($table)) {
         $table = DataTable::makeFromSimpleArray($table);
     }
     if ($table instanceof DataTable\Map) {
         foreach ($table->getDataTables() as $date => $subtable) {
             if ($subtable->getRowsCount()) {
                 $this->buildTableStructure($subtable, '_' . $table->getKeyName(), $date);
             }
         }
     } else {
         if ($table->getRowsCount()) {
             $this->buildTableStructure($table);
         }
     }
     $out = $this->renderDataTable();
     return $out;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:25,代码来源:Html.php

示例2: generateDataTableWithManySubtables

 private function generateDataTableWithManySubtables($numSubtables)
 {
     $dataTable = new DataTable();
     for ($i = 1; $i <= $numSubtables; $i++) {
         $row = new Row(array(Row::COLUMNS => array('label' => 'Label Test ' . $i, 'nb_visits' => $i)));
         $subtable = DataTable::makeFromSimpleArray(array(array('label' => 'subtable' . $i, 'nb_visits' => $i)));
         $row->setSubtable($subtable);
         $dataTable->addRow($row);
     }
     return $dataTable->getSerialized();
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:11,代码来源:ChunksTest.php

示例3: test_disableFilter_DoesActuallyDisableAFilter

 /**
  * @group Core
  */
 public function test_disableFilter_DoesActuallyDisableAFilter()
 {
     $dataTable = DataTable::makeFromSimpleArray(array_fill(0, 100, array()));
     $this->assertSame(100, $dataTable->getRowsCount());
     $dataTable2 = clone $dataTable;
     // verify here the filter is applied
     $dataTable->filter('Limit', array(10, 10));
     $this->assertSame(10, $dataTable->getRowsCount());
     // verify here the filter is not applied as it is disabled
     $dataTable2->disableFilter('Limit');
     $dataTable2->filter('Limit', array(10, 10));
     $this->assertSame(100, $dataTable2->getRowsCount());
     // passing a whole className is expected to work. This way we also make sure not all filters are disabled
     // and it only blocks the given one
     $dataTable2->filter('Piwik\\DataTable\\Filter\\Limit', array(10, 10));
     $this->assertSame(10, $dataTable2->getRowsCount());
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:20,代码来源:DataTableTest.php

示例4: renderTable

 /**
  * Computes the output of the given data table
  *
  * @param DataTable|array $table
  * @param array $allColumns
  * @return string
  */
 protected function renderTable($table, &$allColumns = array())
 {
     if (is_array($table)) {
         $table = DataTable::makeFromSimpleArray($table);
     }
     if ($table instanceof DataTable\Map) {
         $str = $this->renderDataTableMap($table, $allColumns);
     } else {
         $str = $this->renderDataTable($table, $allColumns);
     }
     return $str;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:19,代码来源:Csv.php

示例5: renderTable

 /**
  * Computes the given dataTable output and returns the string/binary
  *
  * @param DataTable $table data table to render
  * @param string $prefix prefix to output before table data
  * @return string
  */
 protected function renderTable($table, $prefix = "")
 {
     if (is_array($table)) {
         // convert array to DataTable
         $table = DataTable::makeFromSimpleArray($table);
     }
     if ($table instanceof DataTable\Map) {
         return $this->renderDataTableMap($table, $prefix);
     }
     if ($table->getRowsCount() == 0) {
         return "Empty table<br />\n";
     }
     static $depth = 0;
     $output = '';
     $i = 1;
     foreach ($table->getRows() as $row) {
         $dataTableMapBreak = false;
         $columns = array();
         foreach ($row->getColumns() as $column => $value) {
             if ($value instanceof DataTable\Map) {
                 $output .= $this->renderDataTableMap($value, $prefix);
                 $dataTableMapBreak = true;
                 break;
             }
             if (is_string($value)) {
                 $value = "'{$value}'";
             } elseif (is_array($value)) {
                 $value = var_export($value, true);
             }
             $columns[] = "'{$column}' => {$value}";
         }
         if ($dataTableMapBreak === true) {
             continue;
         }
         $columns = implode(", ", $columns);
         $metadata = array();
         foreach ($row->getMetadata() as $name => $value) {
             if (is_string($value)) {
                 $value = "'{$value}'";
             } elseif (is_array($value)) {
                 $value = var_export($value, true);
             }
             $metadata[] = "'{$name}' => {$value}";
         }
         $metadata = implode(", ", $metadata);
         $output .= str_repeat($this->prefixRows, $depth) . "- {$i} [" . $columns . "] [" . $metadata . "] [idsubtable = " . $row->getIdSubDataTable() . "]<br />\n";
         if (!is_null($row->getIdSubDataTable())) {
             $subTable = $row->getSubtable();
             if ($subTable) {
                 $depth++;
                 $output .= $this->renderTable($subTable, $prefix . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
                 $depth--;
             } else {
                 $output .= "-- Sub DataTable not loaded<br />\n";
             }
         }
         $i++;
     }
     $metadata = $table->getAllTableMetadata();
     if (!empty($metadata)) {
         $output .= "<hr />Metadata<br />";
         foreach ($metadata as $id => $metadataIn) {
             $output .= "<br />";
             $output .= $prefix . " <b>{$id}</b><br />";
             if (is_array($metadataIn)) {
                 foreach ($metadataIn as $name => $value) {
                     $output .= $prefix . $prefix . "{$name} => {$value}";
                 }
             }
         }
     }
     return $output;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:80,代码来源:Console.php

示例6: getExampleReport

 /**
  * Another example method that returns a data table.
  * @param int    $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @return DataTable
  */
 public function getExampleReport($idSite, $period, $date, $segment = false)
 {
     $table = DataTable::makeFromSimpleArray(array(array('label' => 'My Label 1', 'nb_visits' => '1'), array('label' => 'My Label 2', 'nb_visits' => '5')));
     return $table;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:13,代码来源:API.php


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