Skip to content
Extraits de code Groupes Projets
DataTableSummaryRow.php 1,55 ko
Newer Older
  • Learn to ignore specific revisions
  • <?php
    /**
     * Piwik - Open source web analytics
    
    robocoder's avatar
    robocoder a validé
     * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
    
    robocoder's avatar
    robocoder a validé
     * @category Piwik
     * @package Piwik
    
    namespace Piwik\DataTable\Row;
    
    use Piwik\DataTable\Manager;
    
     * This class creates a row from a given DataTable.
     * The row contains
    
     * - for each numeric column, the returned "summary" column is the sum of all the subRows
     * - for every other column, it is ignored and will not be in the "summary row"
    
     * @see \DataTable\Row::sumRow() for more information on the algorithm
    
    robocoder's avatar
    robocoder a validé
     * @package Piwik
    
    class DataTableSummaryRow extends Row
    
         */
        function __construct($subTable = null)
        {
            parent::__construct();
    
            if ($subTable !== null) {
                $this->sumTable($subTable);
            }
        }
    
        /**
    
         * Reset this row to an empty one and sum the associated subTable again.
    
         */
        public function recalculate()
        {
            $id = $this->getIdSubDataTable();
            if ($id !== null) {
    
                $subTable = Manager::getInstance()->getTable($id);
                $this->sumTable($subTable);
    
         */
        private function sumTable($table)
        {
            foreach ($table->getRows() as $row) {
    
    diosmosis's avatar
    diosmosis a validé
                $this->sumRow($row, $enableCopyMetadata = false, $table->metadata[DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME]);