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


PHP Map::addTable方法代码示例

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


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

示例1: createInstanceWithDataTableMaps

 private function createInstanceWithDataTableMaps()
 {
     $dataTable = new DataTable\Map();
     $subDataTableMap1 = $this->createInstanceWithDataTables();
     $dataTable->addTable($subDataTableMap1, 'subArray1');
     $subDataTableMap2 = $this->createInstanceWithDataTables();
     $dataTable->addTable($subDataTableMap2, 'subArray2');
     return $dataTable;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:MapTest.php

示例2: test_renderDataTable_shouldFail_IfKeynameIsNotDate

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage RSS feeds can be generated for one specific website
  */
 public function test_renderDataTable_shouldFail_IfKeynameIsNotDate()
 {
     $map = new DataTable\Map();
     $dataTable = new DataTable();
     $dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
     $map->addTable($dataTable, 'table1');
     $map->addTable($dataTable, 'table2');
     $this->builder->renderDataTable($map);
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:13,代码来源:RssRendererTest.php

示例3: test_renderDataTable_shouldRenderDataTableMaps

    public function test_renderDataTable_shouldRenderDataTableMaps()
    {
        $map = new DataTable\Map();
        $dataTable = new DataTable();
        $dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
        $dataTable2 = new DataTable();
        $dataTable2->addRowFromSimpleArray(array('nb_visits' => 3, 'nb_random' => 6));
        $map->addTable($dataTable, 'table1');
        $map->addTable($dataTable2, 'table2');
        $response = $this->builder->renderDataTable($map);
        $this->assertEquals('<?xml version="1.0" encoding="utf-8" ?>
<results>
	<result defaultKeyName="table1">
		<row>
			<nb_visits>5</nb_visits>
			<nb_random>10</nb_random>
		</row>
	</result>
	<result defaultKeyName="table2">
		<row>
			<nb_visits>3</nb_visits>
			<nb_random>6</nb_random>
		</row>
	</result>
</results>', $response);
    }
开发者ID:a4tunado,项目名称:piwik,代码行数:26,代码来源:XmlRendererTest.php

示例4: _getDataTableMap_containsDataTableMap_simpleOneRow

 protected function _getDataTableMap_containsDataTableMap_simpleOneRow()
 {
     $table = new DataTable\Map();
     $table->setKeyName('parentArrayKey');
     $table->addTable($this->_getDataTableSimpleOneRowMapTest(), 'idSite');
     return $table;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:7,代码来源:JSONTest.php

示例5: handleTableReport

 /**
  * Enhance a $dataTable using metadata :
  *
  * - remove metrics based on $reportMetadata['metrics']
  * - add 0 valued metrics if $dataTable doesn't provide all $reportMetadata['metrics']
  * - format metric values to a 'human readable' format
  * - extract row metadata to a separate Simple|Set : $rowsMetadata
  * - translate metric names to a separate array : $columns
  *
  * @param int $idSite enables monetary value formatting based on site currency
  * @param \Piwik\DataTable\Map|\Piwik\DataTable\Simple $dataTable
  * @param array $reportMetadata
  * @param bool $showRawMetrics
  * @param bool|null $formatMetrics
  * @return array Simple|Set $newReport with human readable format & array $columns list of translated column names & Simple|Set $rowsMetadata
  */
 private function handleTableReport($idSite, $dataTable, &$reportMetadata, $showRawMetrics = false, $formatMetrics = null)
 {
     $hasDimension = isset($reportMetadata['dimension']);
     $columns = @$reportMetadata['metrics'] ?: array();
     if ($hasDimension) {
         $columns = array_merge(array('label' => $reportMetadata['dimension']), $columns);
     }
     if (isset($reportMetadata['processedMetrics']) && is_array($reportMetadata['processedMetrics'])) {
         $processedMetricsAdded = Metrics::getDefaultProcessedMetrics();
         foreach ($reportMetadata['processedMetrics'] as $processedMetricId => $processedMetricTranslation) {
             // this processed metric can be displayed for this report
             if ($processedMetricTranslation && $processedMetricId !== $processedMetricTranslation) {
                 $columns[$processedMetricId] = $processedMetricTranslation;
             } elseif (isset($processedMetricsAdded[$processedMetricId])) {
                 // for instance in case 'nb_visits' => 'nb_visits' we will translate it
                 $columns[$processedMetricId] = $processedMetricsAdded[$processedMetricId];
             }
         }
     }
     // Display the global Goal metrics
     if (isset($reportMetadata['metricsGoal'])) {
         $metricsGoalDisplay = array('revenue');
         // Add processed metrics to be displayed for this report
         foreach ($metricsGoalDisplay as $goalMetricId) {
             if (isset($reportMetadata['metricsGoal'][$goalMetricId])) {
                 $columns[$goalMetricId] = $reportMetadata['metricsGoal'][$goalMetricId];
             }
         }
     }
     $columns = $this->hideShowMetrics($columns);
     $totals = array();
     // $dataTable is an instance of Set when multiple periods requested
     if ($dataTable instanceof DataTable\Map) {
         // Need a new Set to store the 'human readable' values
         $newReport = new DataTable\Map();
         $newReport->setKeyName("prettyDate");
         // Need a new Set to store report metadata
         $rowsMetadata = new DataTable\Map();
         $rowsMetadata->setKeyName("prettyDate");
         // Process each Simple entry
         foreach ($dataTable->getDataTables() as $simpleDataTable) {
             $this->removeEmptyColumns($columns, $reportMetadata, $simpleDataTable);
             list($enhancedSimpleDataTable, $rowMetadata) = $this->handleSimpleDataTable($idSite, $simpleDataTable, $columns, $hasDimension, $showRawMetrics, $formatMetrics);
             $enhancedSimpleDataTable->setAllTableMetadata($simpleDataTable->getAllTableMetadata());
             $period = $simpleDataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getLocalizedLongString();
             $newReport->addTable($enhancedSimpleDataTable, $period);
             $rowsMetadata->addTable($rowMetadata, $period);
             $totals = $this->aggregateReportTotalValues($simpleDataTable, $totals);
         }
     } else {
         $this->removeEmptyColumns($columns, $reportMetadata, $dataTable);
         list($newReport, $rowsMetadata) = $this->handleSimpleDataTable($idSite, $dataTable, $columns, $hasDimension, $showRawMetrics, $formatMetrics);
         $totals = $this->aggregateReportTotalValues($dataTable, $totals);
     }
     return array($newReport, $columns, $rowsMetadata, $totals);
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:72,代码来源:ProcessedReport.php

示例6: test_renderDataTable_shouldRenderDataTableMaps

 public function test_renderDataTable_shouldRenderDataTableMaps()
 {
     $map = new DataTable\Map();
     $dataTable = new DataTable();
     $dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
     $dataTable2 = new DataTable();
     $dataTable2->addRowFromSimpleArray(array('nb_visits' => 3, 'nb_random' => 6));
     $map->addTable($dataTable, 'table1');
     $map->addTable($dataTable2, 'table2');
     $response = $this->builder->renderDataTable($map);
     $expected = array('table1' => array(array('nb_visits' => 5, 'nb_random' => 10)), 'table2' => array(array('nb_visits' => 3, 'nb_random' => 6)));
     $this->assertEquals($expected, $response);
 }
开发者ID:Abine,项目名称:piwik,代码行数:13,代码来源:PhpRendererTest.php

示例7: generateOverviewReport

 private function generateOverviewReport($method, $idSite, $period, $date, $segment, array $defaultParams)
 {
     $tableManager = DataTable\Manager::getInstance();
     /** @var DataTable[] $tables */
     $tables = array();
     foreach ($this->getOverviewReports() as $reportId => $reportParams) {
         if (!empty($reportParams)) {
             foreach ($defaultParams as $key => $defaultParam) {
                 if (!array_key_exists($key, $reportParams)) {
                     $reportParams[$key] = $defaultParam;
                 }
             }
         }
         $firstTableId = $tableManager->getMostRecentTableId();
         $table = $this->requestApiMethod($method, $idSite, $period, $date, $reportId, $segment, $reportParams);
         $reportTableIds[] = $table->getId();
         $tableManager->deleteTablesExceptIgnored($reportTableIds, $firstTableId);
         $tables[] = $table;
     }
     $map = new DataTable\Map();
     foreach ($tables as $table) {
         $map->addTable($table, $table->getMetadata('reportName'));
     }
     return $map;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:25,代码来源:API.php

示例8: createDataTableMapFromIndex

 /**
  * Creates a Set from an array index.
  *
  * @param array $index @see DataCollection
  * @param array $resultIndices @see make
  * @param array $keyMetadata The metadata to add to the table when it's created.
  * @return DataTable\Map
  */
 private function createDataTableMapFromIndex($index, $resultIndices, $keyMetadata = array())
 {
     $resultIndexLabel = reset($resultIndices);
     $resultIndex = key($resultIndices);
     array_shift($resultIndices);
     $result = new DataTable\Map();
     $result->setKeyName($resultIndexLabel);
     foreach ($index as $label => $value) {
         $keyMetadata[$resultIndex] = $label;
         if (empty($resultIndices)) {
             $newTable = $this->createDataTable($value, $keyMetadata);
         } else {
             $newTable = $this->createDataTableMapFromIndex($value, $resultIndices, $keyMetadata);
         }
         $result->addTable($newTable, $this->prettifyIndexLabel($resultIndex, $label));
     }
     return $result;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:26,代码来源:DataTableFactory.php

示例9: makeMergedTableWithPeriodAndSiteIndex

 private function makeMergedTableWithPeriodAndSiteIndex($index, $resultIndices, $useSimpleDataTable, $isNumeric)
 {
     $map = new DataTable\Map();
     $map->setKeyName($resultIndices[self::TABLE_METADATA_PERIOD_INDEX]);
     // we save all tables of the map in this array to be able to add rows fast
     $tables = array();
     foreach ($this->periods as $range => $period) {
         // as the resulting table is "merged", we do only set Period metedata and no metadata for site. Instead each
         // row will have an idsite metadata entry.
         $metadata = array(self::TABLE_METADATA_PERIOD_INDEX => $period);
         if ($useSimpleDataTable) {
             $table = new DataTable\Simple();
         } else {
             $table = new DataTable();
         }
         $table->setAllTableMetadata($metadata);
         $map->addTable($table, $this->prettifyIndexLabel(self::TABLE_METADATA_PERIOD_INDEX, $range));
         $tables[$range] = $table;
     }
     foreach ($index as $idsite => $table) {
         $rowMeta = array('idsite' => $idsite);
         foreach ($table as $range => $row) {
             if (!empty($row)) {
                 $tables[$range]->addRow(new Row(array(Row::COLUMNS => $row, Row::METADATA => $rowMeta)));
             } elseif ($isNumeric) {
                 $tables[$range]->addRow(new Row(array(Row::COLUMNS => $this->defaultRow, Row::METADATA => $rowMeta)));
             }
         }
     }
     return $map;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:31,代码来源:DataTableFactory.php

示例10: test_renderDataTable_shouldRenderDataTableMaps

    public function test_renderDataTable_shouldRenderDataTableMaps()
    {
        $map = new DataTable\Map();
        $dataTable = new DataTable();
        $dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
        $dataTable2 = new DataTable();
        $dataTable2->addRowFromSimpleArray(array('nb_visits' => 3, 'nb_random' => 6));
        $map->addTable($dataTable, 'table1');
        $map->addTable($dataTable2, 'table2');
        $response = $this->builder->renderDataTable($map);
        $this->assertEquals('defaultKeyName,nb_visits,nb_random
table1,5,10
table2,3,6', $response);
    }
开发者ID:diosmosis,项目名称:piwik,代码行数:14,代码来源:CsvRendererTest.php

示例11: test_renderDataTable_shouldRenderDataTableMaps

    public function test_renderDataTable_shouldRenderDataTableMaps()
    {
        $map = new DataTable\Map();
        $dataTable = new DataTable();
        $dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
        $dataTable2 = new DataTable();
        $dataTable2->addRowFromSimpleArray(array('nb_visits' => 3, 'nb_random' => 6));
        $map->addTable($dataTable, 'table1');
        $map->addTable($dataTable2, 'table2');
        $response = $this->builder->renderDataTable($map);
        $this->assertEquals('<table id="MultiSites_getAll" border="1">
<thead>
	<tr>
		<th>_defaultKeyName</th>
		<th>nb_visits</th>
		<th>nb_random</th>
	</tr>
</thead>
<tbody>
	<tr>
		<td>table1</td>
		<td>5</td>
		<td>10</td>
	</tr>
	<tr>
		<td>table2</td>
		<td>3</td>
		<td>6</td>
	</tr>
</tbody>
</table>
', $response);
    }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:33,代码来源:HtmlRendererTest.php

示例12: test_hasDataTableUsers_shouldHandleADataTableMap

 public function test_hasDataTableUsers_shouldHandleADataTableMap()
 {
     $map = new DataTable\Map();
     $map->addTable(new DataTable(), 'label1');
     $map->addTable(new DataTable(), 'label2');
     $map->addTable($this->getDataTableWithoutUsersColumn(), 'label3');
     $this->assertNotDataTableHasUsers($map);
     $map->addTable($this->getDataTableWithZeroUsers(), 'label4');
     $map->addTable(new DataTable(), 'label5');
     $this->assertNotDataTableHasUsers($map);
     $map->addTable($this->getDataTableWithUsers(), 'label6');
     $this->assertDataTableHasUsers($map);
 }
开发者ID:cemo,项目名称:piwik,代码行数:13,代码来源:UserIdTest.php

示例13: test_renderDataTable_shouldRenderDataTableMaps

 public function test_renderDataTable_shouldRenderDataTableMaps()
 {
     $map = new DataTable\Map();
     $dataTable = new DataTable();
     $dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
     $dataTable2 = new DataTable();
     $dataTable2->addRowFromSimpleArray(array('nb_visits' => 3, 'nb_random' => 6));
     $map->addTable($dataTable, 'table1');
     $map->addTable($dataTable2, 'table2');
     $response = $this->jsonBuilder->renderDataTable($map);
     $this->assertEquals('{"table1":[{"nb_visits":5,"nb_random":10}],"table2":[{"nb_visits":3,"nb_random":6}]}', $response);
     $this->assertNoJsonError($response);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:13,代码来源:JsonRendererTest.php


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