public function renderArray($array) { $result = parent::renderArray($array); // if $array is a simple associative array, remove the JSON root array that is added by renderDataTable if (!empty($array) && Piwik::isAssociativeArray($array) && !Piwik::isMultiDimensionalArray($array)) { $result = substr($result, 1, strlen($result) - 2); } return $result; }
public function renderArray($array) { if (!Piwik::isMultiDimensionalArray($array)) { return $this->renderDataTable($array); } if ($this->shouldSerialize(1)) { return serialize($array); } return $array; }
public function renderArray($array) { if (Piwik::isMultiDimensionalArray($array)) { $jsonRenderer = Renderer::factory('json'); $jsonRenderer->setTable($array); $result = $jsonRenderer->render(); return $this->applyJsonpIfNeeded($result); } return $this->renderDataTable($array); }
public function renderArray($array) { if (Piwik::isMultiDimensionalArray($array)) { $jsonRenderer = Renderer::factory('json'); $jsonRenderer->setTable($array); $result = $jsonRenderer->render(); return $this->applyJsonpIfNeeded($result); } $result = $this->renderDataTable($array); // if $array is a simple associative array, remove the JSON root array that is added by renderDataTable if (!empty($array) && Piwik::isAssociativeArray($array) && !Piwik::isMultiDimensionalArray($array)) { $result = substr($result, 1, strlen($result) - 2); } return $result; }
protected function handleArray($array) { $firstArray = null; $firstKey = null; if (!empty($array)) { $firstArray = reset($array); $firstKey = key($array); } $isAssoc = !empty($firstArray) && is_numeric($firstKey) && is_array($firstArray) && !Piwik::isMultiDimensionalArray($array) && count(array_filter(array_keys($firstArray), 'is_string')); if ($isAssoc) { $hideColumns = Common::getRequestVar('hideColumns', '', 'string', $this->request); $showColumns = Common::getRequestVar('showColumns', '', 'string', $this->request); if ($hideColumns !== '' || $showColumns !== '') { $columnDelete = new ColumnDelete(new DataTable(), $hideColumns, $showColumns); $array = $columnDelete->filter($array); } } return $this->apiRenderer->renderArray($array); }