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


PHP DataTable::setAllTableMetadata方法代码示例

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


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

示例1: doFilterPageDatatableSearch

 /**
  * This looks very similar to LabelFilter.php should it be refactored somehow? FIXME
  */
 protected function doFilterPageDatatableSearch($callBackParameters, $table, $searchTree)
 {
     // filter a data table array
     if ($table instanceof DataTable\Map) {
         foreach ($table->getDataTables() as $subTable) {
             $filteredSubTable = $this->doFilterPageDatatableSearch($callBackParameters, $subTable, $searchTree);
             if ($filteredSubTable->getRowsCount() > 0) {
                 // match found in a sub table, return and stop searching the others
                 return $filteredSubTable;
             }
         }
         // nothing found in all sub tables
         return new DataTable();
     }
     // filter regular data table
     if ($table instanceof DataTable) {
         // search for the first part of the tree search
         $search = array_shift($searchTree);
         $row = $table->getRowFromLabel($search);
         if ($row === false) {
             // not found
             $result = new DataTable();
             $result->setAllTableMetadata($table->getAllTableMetadata());
             return $result;
         }
         // end of tree search reached
         if (count($searchTree) == 0) {
             $result = new DataTable();
             $result->addRow($row);
             $result->setAllTableMetadata($table->getAllTableMetadata());
             return $result;
         }
         // match found on this level and more levels remaining: go deeper
         $idSubTable = $row->getIdSubDataTable();
         $callBackParameters[6] = $idSubTable;
         /**
          * @var \Piwik\Period $period
          */
         $period = $table->getMetadata('period');
         if (!empty($period)) {
             $callBackParameters[3] = $period->getDateStart() . ',' . $period->getDateEnd();
         }
         $table = call_user_func_array(array($this, 'getDataTableFromArchive'), $callBackParameters);
         return $this->doFilterPageDatatableSearch($callBackParameters, $table, $searchTree);
     }
     throw new Exception("For this API function, DataTable " . get_class($table) . " is not supported");
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:50,代码来源:API.php

示例2: mergeSubtables

 /**
  * Returns a new DataTable in which the rows of this table are replaced with the aggregatated rows of all its subtables.
  *
  * @param string|bool $labelColumn If supplied the label of the parent row will be added to
  *                                 a new column in each subtable row.
  *
  *                                 If set to, `'label'` each subtable row's label will be prepended
  *                                 w/ the parent row's label. So `'child_label'` becomes
  *                                 `'parent_label - child_label'`.
  * @param bool $useMetadataColumn If true and if `$labelColumn` is supplied, the parent row's
  *                                label will be added as metadata and not a new column.
  * @return \Piwik\DataTable
  */
 public function mergeSubtables($labelColumn = false, $useMetadataColumn = false)
 {
     $result = new DataTable();
     $result->setAllTableMetadata($this->getAllTableMetadata());
     foreach ($this->getRowsWithoutSummaryRow() as $row) {
         $subtable = $row->getSubtable();
         if ($subtable !== false) {
             $parentLabel = $row->getColumn('label');
             // add a copy of each subtable row to the new datatable
             foreach ($subtable->getRows() as $id => $subRow) {
                 $copy = clone $subRow;
                 // if the summary row, add it to the existing summary row (or add a new one)
                 if ($id == self::ID_SUMMARY_ROW) {
                     $existing = $result->getRowFromId(self::ID_SUMMARY_ROW);
                     if ($existing === false) {
                         $result->addSummaryRow($copy);
                     } else {
                         $existing->sumRow($copy, $copyMeta = true, $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME));
                     }
                 } else {
                     if ($labelColumn !== false) {
                         // if we're modifying the subtable's rows' label column, then we make
                         // sure to prepend the existing label w/ the parent row's label. otherwise
                         // we're just adding the parent row's label as a new column/metadata.
                         $newLabel = $parentLabel;
                         if ($labelColumn == 'label') {
                             $newLabel .= ' - ' . $copy->getColumn('label');
                         }
                         // modify the child row's label or add new column/metadata
                         if ($useMetadataColumn) {
                             $copy->setMetadata($labelColumn, $newLabel);
                         } else {
                             $copy->setColumn($labelColumn, $newLabel);
                         }
                     }
                     $result->addRow($copy);
                 }
             }
         }
     }
     return $result;
 }
开发者ID:piwik,项目名称:piwik,代码行数:55,代码来源:DataTable.php

示例3: makeMergedWithSiteIndex

 private function makeMergedWithSiteIndex($index, $useSimpleDataTable, $isNumeric)
 {
     if ($useSimpleDataTable) {
         $table = new DataTable\Simple();
     } else {
         $table = new DataTable();
     }
     $table->setAllTableMetadata(array(DataTableFactory::TABLE_METADATA_PERIOD_INDEX => reset($this->periods)));
     foreach ($index as $idsite => $row) {
         if (!empty($row)) {
             $table->addRow(new Row(array(Row::COLUMNS => $row, Row::METADATA => array('idsite' => $idsite))));
         } elseif ($isNumeric) {
             $table->addRow(new Row(array(Row::COLUMNS => $this->defaultRow, Row::METADATA => array('idsite' => $idsite))));
         }
     }
     return $table;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:17,代码来源:DataTableFactory.php


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