diff options
Diffstat (limited to 'modules/DataTable/Renderer/Php.php')
-rw-r--r-- | modules/DataTable/Renderer/Php.php | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/modules/DataTable/Renderer/Php.php b/modules/DataTable/Renderer/Php.php index 50aa9df284..7d80ed23e4 100644 --- a/modules/DataTable/Renderer/Php.php +++ b/modules/DataTable/Renderer/Php.php @@ -1,18 +1,18 @@ -<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
- * @version $Id$
- *
- * @package Piwik_DataTable
- */
-
+<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later + * @version $Id$ + * + * @package Piwik_DataTable + */ + /** * Returns the equivalent PHP array for a given DataTable. - * You can specify in the constructor if you want the serialized version.
- * Please note that by default it will produce a flat version of the array.
+ * You can specify in the constructor if you want the serialized version. + * Please note that by default it will produce a flat version of the array. * See the method flatRender() for details. @see flatRender(); * * Works with recursive DataTable (when a row can be associated with a subDataTable). @@ -44,23 +44,23 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer } return $data; } -
- /**
- * Produces a flat php array from the DataTable, putting "columns" and "details" on the same level.
- *
- * For example, when a originalRender() would be
- * array( 'columns' => array( 'col1_name' => value1, 'col2_name' => value2 ),
- * 'details' => array( 'detail1_name' => value_detail) )
- *
- * a flatRender() is
- * array( 'col1_name' => value1,
- * 'col2_name' => value2,
- * 'detail1_name' => value_detail )
- *
- * @return array Php array representing the 'flat' version of the datatable
- *
- */
- public function flatRender( $dataTable = null, $doRenderSubTablesIfAvailable = true )
+ + /** + * Produces a flat php array from the DataTable, putting "columns" and "details" on the same level. + * + * For example, when a originalRender() would be + * array( 'columns' => array( 'col1_name' => value1, 'col2_name' => value2 ), + * 'details' => array( 'detail1_name' => value_detail) ) + * + * a flatRender() is + * array( 'col1_name' => value1, + * 'col2_name' => value2, + * 'detail1_name' => value_detail ) + * + * @return array Php array representing the 'flat' version of the datatable + * + */ + public function flatRender( $dataTable = null, $doRenderSubTablesIfAvailable = true ) { if(is_null($dataTable)) { @@ -78,10 +78,10 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer $this->serialize = $serializeSave; } } -
- // A DataTable_Simple is already flattened so no need to do some crazy stuff to convert it
- else if($dataTable instanceof Piwik_DataTable_Simple)
- {
+ + // A DataTable_Simple is already flattened so no need to do some crazy stuff to convert it + else if($dataTable instanceof Piwik_DataTable_Simple) + { $flatArray = $this->renderSimpleTable($dataTable); // if we return only one numeric value then we print out the result in a simple <result> tag @@ -90,22 +90,22 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer { $flatArray = current($flatArray); } -
- }
- // A normal DataTable needs to be handled specifically
- else
- {
+ + } + // A normal DataTable needs to be handled specifically + else + { $array = $this->renderTable($dataTable, $doRenderSubTablesIfAvailable); - $flatArray = $this->flattenArray($array);
- }
-
- if($this->serialize)
- {
- $flatArray = serialize($flatArray);
- }
-
- return $flatArray;
- }
+ $flatArray = $this->flattenArray($array); + } + + if($this->serialize) + { + $flatArray = serialize($flatArray); + } + + return $flatArray; + } protected function flattenArray($array) { @@ -124,13 +124,13 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer $flatArray[] = $newRow; } return $flatArray; - }
- public function render( $dataTable = null)
+ } + public function render( $dataTable = null) { if(is_null($dataTable)) { $dataTable = $this->table; - }
+ } $toReturn = $this->flatRender( $dataTable ); if( false !== Piwik_Common::getRequestVar('prettyDisplay', false) ) @@ -140,9 +140,9 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer $toReturn = unserialize($toReturn); } $toReturn = "<pre>" . var_export($toReturn, true ) . "</pre>"; - }
- return $toReturn;
- }
+ } + return $toReturn; + } public function originalRender() { @@ -162,7 +162,7 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer return $array; } -
+ protected function renderTable($table, $doRenderSubTablesIfAvailable = true) { |