diff options
author | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-07-30 23:15:09 +0400 |
---|---|---|
committer | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-07-30 23:15:09 +0400 |
commit | edf2c04f41445fb6f3f5658e887b53a8a49b4e13 (patch) | |
tree | fdb13ce6e0baea2e7badd7a3a6dca5ac19699368 /core/ViewDataTable | |
parent | 12c74e64281ddab9303eb389fcb76f0518651a55 (diff) |
Refs #4040, #4041, added ability to access view properties directly, started documenting view properties and modified ExampleUI plugin to set view properties directly.
Diffstat (limited to 'core/ViewDataTable')
-rw-r--r-- | core/ViewDataTable/Cloud.php | 5 | ||||
-rw-r--r-- | core/ViewDataTable/GenerateGraphHTML.php | 2 | ||||
-rw-r--r-- | core/ViewDataTable/HtmlTable.php | 2 | ||||
-rw-r--r-- | core/ViewDataTable/HtmlTable/AllColumns.php | 3 | ||||
-rw-r--r-- | core/ViewDataTable/HtmlTable/Goals.php | 3 | ||||
-rw-r--r-- | core/ViewDataTable/Properties.php | 141 | ||||
-rw-r--r-- | core/ViewDataTable/Sparkline.php | 2 |
7 files changed, 148 insertions, 10 deletions
diff --git a/core/ViewDataTable/Cloud.php b/core/ViewDataTable/Cloud.php index 02fed10119..28127ca281 100644 --- a/core/ViewDataTable/Cloud.php +++ b/core/ViewDataTable/Cloud.php @@ -49,11 +49,12 @@ class Piwik_ViewDataTable_Cloud extends Piwik_ViewDataTable } $this->mainAlreadyExecuted = true; - $this->isDataAvailable = true; try { $this->loadDataTableFromAPI(); } catch (Exception $e) { - $this->isDataAvailable = false; + Piwik::log("Failed to get data from API: " . $e->getMessage()); + + $this->loadingError = array('message' => $e->getMessage()); } $this->checkStandardDataTable(); diff --git a/core/ViewDataTable/GenerateGraphHTML.php b/core/ViewDataTable/GenerateGraphHTML.php index 24ff479624..2114eb38fa 100644 --- a/core/ViewDataTable/GenerateGraphHTML.php +++ b/core/ViewDataTable/GenerateGraphHTML.php @@ -221,7 +221,6 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable // will be done on the table before the labels are enhanced (see ReplaceColumnNames) $this->disableQueuedFilters(); - $this->isDataAvailable = true; try { $this->loadDataTableFromAPI(); } catch (Piwik_Access_NoAccessException $e) { @@ -229,7 +228,6 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable } catch (Exception $e) { Piwik::log("Failed to get data from API: " . $e->getMessage()); - $this->isDataAvailable = false; $this->loadingError = array('message' => $e->getMessage()); } diff --git a/core/ViewDataTable/HtmlTable.php b/core/ViewDataTable/HtmlTable.php index bc4cc03457..2830ab5cb5 100644 --- a/core/ViewDataTable/HtmlTable.php +++ b/core/ViewDataTable/HtmlTable.php @@ -64,7 +64,6 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable } $this->mainAlreadyExecuted = true; - $this->isDataAvailable = true; try { $this->loadDataTableFromAPI(); } catch (Piwik_Access_NoAccessException $e) { @@ -72,7 +71,6 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable } catch (Exception $e) { Piwik::log("Failed to get data from API: " . $e->getMessage()); - $this->isDataAvailable = false; $this->loadingError = array('message' => $e->getMessage()); } diff --git a/core/ViewDataTable/HtmlTable/AllColumns.php b/core/ViewDataTable/HtmlTable/AllColumns.php index 9b1a1f77d3..3426ef4af3 100644 --- a/core/ViewDataTable/HtmlTable/AllColumns.php +++ b/core/ViewDataTable/HtmlTable/AllColumns.php @@ -38,9 +38,8 @@ class Piwik_ViewDataTable_HtmlTable_AllColumns extends Piwik_ViewDataTable_HtmlT $valid = parent::postDataTableLoadedFromAPI(); if (!$valid) return false; - Piwik_Controller::setPeriodVariablesView($this); $columnUniqueVisitors = false; - if ($this->period == 'day') { + if ($this->dataTableColumnsContains($this->dataTable->getColumns(), 'nb_uniq_visitors')) { $columnUniqueVisitors = 'nb_uniq_visitors'; } diff --git a/core/ViewDataTable/HtmlTable/Goals.php b/core/ViewDataTable/HtmlTable/Goals.php index 3ca37b6c20..618ed20edd 100644 --- a/core/ViewDataTable/HtmlTable/Goals.php +++ b/core/ViewDataTable/HtmlTable/Goals.php @@ -15,6 +15,9 @@ */ class Piwik_ViewDataTable_HtmlTable_Goals extends Piwik_ViewDataTable_HtmlTable { + private $processOnlyIdGoal = null; + private $isEcommerce = false; + protected function getViewDataTableId() { return 'tableGoals'; diff --git a/core/ViewDataTable/Properties.php b/core/ViewDataTable/Properties.php new file mode 100644 index 0000000000..1a899f37b1 --- /dev/null +++ b/core/ViewDataTable/Properties.php @@ -0,0 +1,141 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @category Piwik + * @package Piwik + */ + +/** + * Contains the list of all core DataTable display properties for use with ViewDataTable. + * + * @see Piwik_ViewDataTable for more info. + * + * TODO: change the names of properties to match the const names where appropriate. + */ +class Piwik_ViewDataTable_Properties +{ + /** + * This property determines which Twig template to use when rendering a ViewDataTable. + * + * TODO: shouldn't have this property. should only use visualization classes. + */ + const DATATABLE_TEMPLATE = 'datatable_template'; + + /** + * Controls whether the goals footer icon is shown. + */ + const SHOW_GOALS = 'show_goals'; + + /** + * Array property mapping DataTable column names with their internationalized names. + */ + const COLUMN_NAME_TRANSLATIONS = 'translations'; + + /** + * Controls which column to sort the DataTable by before truncating and displaying. + */ + const SORTED_COLUMN = 'filter_sort_column'; + + /** + * Controls the sort order. Either 'asc' or 'desc'. + * + * @see self::SORTED_COLUMN + */ + const SORT_ORDER = 'filter_sort_order'; + + /** + * The limit used when rendering a jqPlot graph. + * + * TODO: either replace w/ filter_limit, or make it a visualization property. + */ + const GRAPH_LIMIT = 'graph_limit'; + + /** + * The number of items to truncate the data set to before rendering the DataTable view. + */ + const LIMIT = 'filter_limit'; + + /** + * Controls whether the 'Exclude Low Population' option (visible in the popup that displays after + * clicking the 'cog' icon) is shown. + */ + const SHOW_EXCLUDE_LOW_POPULATION = 'show_exclude_low_population'; + + /** + * Controls whether the 'All Columns' footer icon is shown. + */ + const SHOW_ALL_TABLES_VIEW = 'show_table_all_columns'; + + /** + * Controls whether the Row Evolution datatable row action icon is shown. + */ + const DISABLE_ROW_EVOLUTION = 'disable_row_evolution'; + + /** + * The unit to display in jqPlot graphs. + * + * TODO: Either this should be a visualization property, or should be named something different. + */ + const Y_AXIS_UNIT = 'y_axis_unit'; + + /** + * Controls whether the entire view footer is shown. + */ + const SHOW_FOOTER = 'show_footer'; + + /** + * Controls whether the row that contains all footer icons & the limit selector is shown. + */ + const SHOW_FOOTER_ICONS = 'show_footer_icons'; + + /** + * Array property that determines which columns will be shown. Columns not in this array + * should not appear in ViewDataTable visualizations. + * + * Example: array('label', 'nb_visits', 'nb_uniq_visitors') + */ + const COLUMNS_TO_DISPLAY = 'columns_to_display'; + + /** + * Whether to display the logo assocatied with a DataTable row (stored as 'logo' row metadata) + * isntead of the label in Tag Clouds. + */ + const DISPLAY_LOGO_INSTEAD_OF_LABEL = 'display_logo_instead_of_label'; + + /** + * Returns the set of all valid ViewDataTable properties. The result is an array with property + * name as a key. Values of the array are undefined. + * + * @return array + */ + public static function getAllProperties() + { + static $propertiesCache = null; + + if ($propertiesCache === null) { + $klass = new ReflectionClass(__CLASS__); + $propertiesCache = array_flip($klass->getConstants()); + } + + return $propertiesCache; + } + + /** + * Checks if a property is a valid ViewDataTable property, and if not, throws an exception. + * + * @param string $name The property name. + * @throws Exception + */ + public static function checkValidPropertyName($name) + { + $properties = self::getAllProperties(); + if (!isset($properties[$name])) { + throw new Exception("Invalid ViewDataTable display property '$name'. Is this a visualization property? " + . "If so, set it with \$view->visualization_properties->$name = ..."); + } + } +}
\ No newline at end of file diff --git a/core/ViewDataTable/Sparkline.php b/core/ViewDataTable/Sparkline.php index 062a9267b2..c49759cd1f 100644 --- a/core/ViewDataTable/Sparkline.php +++ b/core/ViewDataTable/Sparkline.php @@ -43,10 +43,8 @@ class Piwik_ViewDataTable_Sparkline extends Piwik_ViewDataTable $_GET['period'] = $period; $values = $this->getValuesFromDataTable($this->dataTable); - $this->isDataAvailable = true; if (empty($values)) { $values = array_fill(0, 30, 0); - $this->isDataAvailable = false; } $graph = new Piwik_Visualization_Sparkline(); |