isSortRecursiveEnabled() public method

コード例 #1
0
ファイル: Sort.php プロジェクト: bossrabbit/piwik
 /**
  * Sorts the DataTable rows using the supplied callback function.
  *
  * @param string $functionCallback A comparison callback compatible with {@link usort}.
  * @param string $columnSortedBy The column name `$functionCallback` sorts by. This is stored
  *                               so we can determine how the DataTable was sorted in the future.
  */
 private function sort(DataTable $table, $functionCallback)
 {
     $table->setTableSortedBy($this->columnToSort);
     $rows = $table->getRowsWithoutSummaryRow();
     // get column value and label only once for performance tweak
     $values = array();
     if ($functionCallback === 'numberSort') {
         foreach ($rows as $key => $row) {
             $values[$key] = array($this->getColumnValue($row), $row->getColumn('label'));
         }
     } else {
         foreach ($rows as $key => $row) {
             $values[$key] = $this->getColumnValue($row);
         }
     }
     uasort($values, array($this, $functionCallback));
     $sortedRows = array();
     foreach ($values as $key => $value) {
         $sortedRows[] = $rows[$key];
     }
     $table->setRows($sortedRows);
     unset($rows);
     unset($sortedRows);
     if ($table->isSortRecursiveEnabled()) {
         foreach ($table->getRowsWithoutSummaryRow() as $row) {
             $subTable = $row->getSubtable();
             if ($subTable) {
                 $subTable->enableRecursiveSort();
                 $this->sort($subTable, $functionCallback);
             }
         }
     }
 }