diff options
Diffstat (limited to 'plugins/CoreVisualizations')
11 files changed, 97 insertions, 91 deletions
diff --git a/plugins/CoreVisualizations/CoreVisualizations.php b/plugins/CoreVisualizations/CoreVisualizations.php index bc175aa36b..06db725f51 100644 --- a/plugins/CoreVisualizations/CoreVisualizations.php +++ b/plugins/CoreVisualizations/CoreVisualizations.php @@ -28,10 +28,10 @@ class CoreVisualizations extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'Visualization.addVisualizations' => 'getAvailableDataTableVisualizations', - 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' + 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', + 'AssetManager.getJavaScriptFiles' => 'getJsFiles', + 'Visualization.addVisualizations' => 'getAvailableDataTableVisualizations', + 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' ); } diff --git a/plugins/CoreVisualizations/JqplotDataGenerator.php b/plugins/CoreVisualizations/JqplotDataGenerator.php index 73eba01367..7c1a638f9a 100644 --- a/plugins/CoreVisualizations/JqplotDataGenerator.php +++ b/plugins/CoreVisualizations/JqplotDataGenerator.php @@ -13,8 +13,8 @@ namespace Piwik\Plugins\CoreVisualizations; use Exception; use Piwik\Common; -use Piwik\DataTable; +use Piwik\DataTable; use Piwik\Metrics; use Piwik\Plugins\CoreVisualizations\JqplotDataGenerator\Chart; @@ -61,7 +61,7 @@ class JqplotDataGenerator /** * Constructor. * - * @param array $properties + * @param array $properties * @param string $graphType * * @internal param \Piwik\ViewDataTable\Visualization\ $visualization diff --git a/plugins/CoreVisualizations/JqplotDataGenerator/Chart.php b/plugins/CoreVisualizations/JqplotDataGenerator/Chart.php index 9590c7ef04..902cbf7f5e 100644 --- a/plugins/CoreVisualizations/JqplotDataGenerator/Chart.php +++ b/plugins/CoreVisualizations/JqplotDataGenerator/Chart.php @@ -63,7 +63,9 @@ class Chart 'internalLabel' => $label ); - array_walk($data, function(&$v) { $v = (float)$v; }); + array_walk($data, function (&$v) { + $v = (float)$v; + }); $this->data[] = & $data; } } @@ -110,11 +112,11 @@ class Chart // See http://www.jqplot.com/docs/files/jqPlotOptions-txt.html $data = array( - 'params' => array( + 'params' => array( 'axes' => &$this->axes, 'series' => &$this->series ), - 'data' => &$this->data + 'data' => &$this->data ); return $data; diff --git a/plugins/CoreVisualizations/JqplotDataGenerator/Evolution.php b/plugins/CoreVisualizations/JqplotDataGenerator/Evolution.php index 3b1eeccab8..342bd1bdb0 100644 --- a/plugins/CoreVisualizations/JqplotDataGenerator/Evolution.php +++ b/plugins/CoreVisualizations/JqplotDataGenerator/Evolution.php @@ -47,9 +47,9 @@ class Evolution extends JqplotDataGenerator // if rows to display are not specified, default to all rows (TODO: perhaps this should be done elsewhere?) $rowsToDisplay = $this->properties['visualization_properties']->rows_to_display - ?: array_unique($dataTable->getColumn('label')) - ?: array(false) // make sure that a series is plotted even if there is no data - ; + ? : array_unique($dataTable->getColumn('label')) + ? : array(false) // make sure that a series is plotted even if there is no data + ; // collect series data to show. each row-to-display/column-to-display permutation creates a series. $allSeriesData = array(); @@ -93,9 +93,9 @@ class Evolution extends JqplotDataGenerator } $link = 'index.php?' . Url::getQueryStringFromParameters(array( - 'module' => 'CoreHome', - 'action' => 'index', - ) + $parameters) + 'module' => 'CoreHome', + 'action' => 'index', + ) + $parameters) . $hash; $axisXOnClick[] = $link; } @@ -118,7 +118,7 @@ class Evolution extends JqplotDataGenerator if ($row === false) { $seriesData[] = 0; } else { - $seriesData[] = $row->getColumn($columnName) ?: 0; + $seriesData[] = $row->getColumn($columnName) ? : 0; } } return $seriesData; diff --git a/plugins/CoreVisualizations/Visualizations/Cloud.php b/plugins/CoreVisualizations/Visualizations/Cloud.php index 36b98c3816..13ea33feac 100644 --- a/plugins/CoreVisualizations/Visualizations/Cloud.php +++ b/plugins/CoreVisualizations/Visualizations/Cloud.php @@ -27,11 +27,11 @@ use Piwik\ViewDataTable\Visualization; class Cloud extends Visualization { const ID = 'cloud'; - + /** * Whether to display the logo assocatied with a DataTable row (stored as 'logo' row metadata) * instead of the label in Tag Clouds. - * + * * Default value: false */ const DISPLAY_LOGO_INSTEAD_OF_LABEL = 'display_logo_instead_of_label'; @@ -53,7 +53,7 @@ class Cloud extends Visualization if ($dataTable->getRowsCount() == 0) { return; } - + $columnToDisplay = isset($view->columns_to_display[1]) ? $view->columns_to_display[1] : 'nb_visits'; $labelMetadata = array(); @@ -85,10 +85,10 @@ class Cloud extends Visualization public static function getDefaultPropertyValues() { return array( - 'show_offset_information' => false, + 'show_offset_information' => false, 'show_exclude_low_population' => false, - 'show_limit_control' => false, - 'visualization_properties' => array( + 'show_limit_control' => false, + 'visualization_properties' => array( 'cloud' => array( 'display_logo_instead_of_label' => false, ) diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable.php b/plugins/CoreVisualizations/Visualizations/HtmlTable.php index a15274e40f..223c1fb9d4 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable.php @@ -34,7 +34,7 @@ class HtmlTable extends Visualization /** * If this property is set to true, subtables will be shown as embedded in the original table. * If false, subtables will be shown as whole tables between rows. - * + * * Default value: false */ const SHOW_EMBEDDED_SUBTABLE = 'show_embedded_subtable'; @@ -42,7 +42,7 @@ class HtmlTable extends Visualization /** * Controls whether the entire DataTable should be rendered (including subtables) or just one * specific table in the tree. - * + * * Default value: false */ const SHOW_EXPANDED = 'show_expanded'; @@ -50,7 +50,7 @@ class HtmlTable extends Visualization /** * When showing an expanded datatable, this property controls whether rows with subtables are * replaced with their subtables, or if they are shown alongside their subtables. - * + * * Default value: false */ const REPLACE_ROW_WITH_SUBTABLE = 'replace_row_with_subtable'; @@ -59,7 +59,7 @@ class HtmlTable extends Visualization * Controls whether any DataTable Row Action icons are shown. If true, no icons are shown. * * @see also self::DISABLE_ROW_EVOLUTION - * + * * Default value: false */ const DISABLE_ROW_ACTIONS = 'disable_row_actions'; @@ -68,7 +68,7 @@ class HtmlTable extends Visualization * Controls whether the row evolution DataTable Row Action icon is shown or not. * * @see also self::DISABLE_ROW_ACTIONS - * + * * Default value: false */ const DISABLE_ROW_EVOLUTION = 'disable_row_evolution'; @@ -77,7 +77,7 @@ class HtmlTable extends Visualization * If true, the 'label', 'nb_visits', 'nb_uniq_visitors' (if present), 'nb_actions', * 'nb_actions_per_visit', 'avg_time_on_site', 'bounce_rate' and 'conversion_rate' (if * goals view is not allowed) are displayed. - * + * * Default value: false */ const SHOW_EXTRA_COLUMNS = 'show_extra_columns'; @@ -85,7 +85,7 @@ class HtmlTable extends Visualization /** * If true, conversions for each existing goal will be displayed for the visits in * each row. - * + * * Default value: false */ const SHOW_GOALS_COLUMNS = 'show_goals_columns'; @@ -95,7 +95,7 @@ class HtmlTable extends Visualization * 'show_goals_columns' property is also true. * * @see also self::SHOW_GOALS_COLUMNS - * + * * Default value: false */ const DISABLE_SUBTABLE_IN_GOALS_VIEW = 'disable_subtable_when_show_goals'; @@ -104,16 +104,16 @@ class HtmlTable extends Visualization * Controls whether the summary row is displayed on every page of the datatable view or not. * If false, the summary row will be treated as the last row of the dataset and will only visible * when viewing the last rows. - * + * * Default value: false */ const KEEP_SUMMARY_ROW = 'keep_summary_row'; /** * If true, the summary row will be colored differently than all other DataTable rows. - * + * * @see also self::KEEP_SUMMARY_ROW - * + * * Default value: false */ const HIGHLIGHT_SUMMARY_ROW = 'highlight_summary_row'; @@ -172,20 +172,20 @@ class HtmlTable extends Visualization public static function getDefaultPropertyValues() { $defaults = array( - 'enable_sort' => true, - 'datatable_js_type' => 'DataTable', - 'filter_limit' => Config::getInstance()->General['datatable_default_limit'], + 'enable_sort' => true, + 'datatable_js_type' => 'DataTable', + 'filter_limit' => Config::getInstance()->General['datatable_default_limit'], 'visualization_properties' => array( 'table' => array( - 'disable_row_evolution' => false, - 'disable_row_actions' => false, - 'show_extra_columns' => false, - 'show_goals_columns' => false, + 'disable_row_evolution' => false, + 'disable_row_actions' => false, + 'show_extra_columns' => false, + 'show_goals_columns' => false, 'disable_subtable_when_show_goals' => false, - 'keep_summary_row' => false, - 'highlight_summary_row' => false, - 'show_expanded' => false, - 'show_embedded_subtable' => false + 'keep_summary_row' => false, + 'highlight_summary_row' => false, + 'show_expanded' => false, + 'show_embedded_subtable' => false ), ), ); @@ -236,10 +236,10 @@ class HtmlTable extends Visualization $view->show_exclude_low_population = true; $view->show_goals = true; $view->translations += array( - 'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'), - 'conversion_rate' => Piwik_Translate('General_ColumnConversionRate'), - 'revenue' => Piwik_Translate('General_ColumnRevenue'), - 'revenue_per_visit' => Piwik_Translate('General_ColumnValuePerVisit'), + 'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'), + 'conversion_rate' => Piwik_Translate('General_ColumnConversionRate'), + 'revenue' => Piwik_Translate('General_ColumnRevenue'), + 'revenue_per_visit' => Piwik_Translate('General_ColumnValuePerVisit'), ); $view->metrics_documentation['nb_visits'] = Piwik_Translate('Goals_ColumnVisits'); @@ -270,14 +270,16 @@ class HtmlTable extends Visualization 'AddColumnsProcessedMetricsGoal', array($ignore = true, $idGoal), $priority = true); // prettify columns - $setRatePercent = function ($rate, $thang = false) { return $rate == 0 ? "0%" : $rate; }; + $setRatePercent = function ($rate, $thang = false) { + return $rate == 0 ? "0%" : $rate; + }; foreach ($view->columns_to_display as $columnName) { if (strpos($columnName, 'conversion_rate') !== false) { $view->filters[] = array('ColumnCallbackReplace', array($columnName, $setRatePercent)); } } - $formatPercent = function ($value) use($idSite) { + $formatPercent = function ($value) use ($idSite) { return MetricsFormatter::getPrettyMoney(sprintf("%.1f", $value), $idSite); }; @@ -288,7 +290,9 @@ class HtmlTable extends Visualization } // this ensures that the value is set to zero for all rows where the value was not set (no conversion) - $identityFunction = function ($value) { return $value; }; + $identityFunction = function ($value) { + return $value; + }; foreach ($view->columns_to_display as $columnName) { if (!$this->isRevenueColumn($columnName)) { $view->filters[] = array('ColumnCallbackReplace', array($columnName, $identityFunction)); @@ -341,7 +345,7 @@ class HtmlTable extends Visualization $view->columns_to_display[] = $column; $view->translations[$column] = Piwik_Translate('Goals_ConversionRate', $goal['name']); $view->metrics_documentation[$column] - = Piwik_Translate('Goals_ColumnConversionRateDocumentation', $goal['quoted_name'] ?: $goal['name']); + = Piwik_Translate('Goals_ColumnConversionRateDocumentation', $goal['quoted_name'] ? : $goal['name']); } $view->columns_to_display[] = 'revenue_per_visit'; @@ -382,23 +386,23 @@ class HtmlTable extends Visualization // set translations & metric docs for goal specific metrics foreach ($idGoals as $idGoal) { $goalName = $allGoals[$idGoal]['name']; - $quotedGoalName = $allGoals[$idGoal]['quoted_name'] ?: $goalName; + $quotedGoalName = $allGoals[$idGoal]['quoted_name'] ? : $goalName; $view->translations += array( - 'goal_' . $idGoal . '_nb_conversions' => Piwik_Translate('Goals_Conversions', $goalName), - 'goal_' . $idGoal . '_conversion_rate' => Piwik_Translate('Goals_ConversionRate', $goalName), - 'goal_' . $idGoal . '_revenue' => - Piwik_Translate('%s ' . Piwik_Translate('General_ColumnRevenue'), $goalName), + 'goal_' . $idGoal . '_nb_conversions' => Piwik_Translate('Goals_Conversions', $goalName), + 'goal_' . $idGoal . '_conversion_rate' => Piwik_Translate('Goals_ConversionRate', $goalName), + 'goal_' . $idGoal . '_revenue' => + Piwik_Translate('%s ' . Piwik_Translate('General_ColumnRevenue'), $goalName), 'goal_' . $idGoal . '_revenue_per_visit' => - Piwik_Translate('%s ' . Piwik_Translate('General_ColumnValuePerVisit'), $goalName), + Piwik_Translate('%s ' . Piwik_Translate('General_ColumnValuePerVisit'), $goalName), ); $view->metrics_documentation += array( - 'goal_' . $idGoal . '_nb_conversions' => Piwik_Translate('Goals_ColumnConversionsDocumentation', $quotedGoalName), - 'goal_' . $idGoal . '_conversion_rate' => Piwik_Translate('Goals_ColumnConversionRateDocumentation', $quotedGoalName), - 'goal_' . $idGoal . '_revenue' => Piwik_Translate('Goals_ColumnRevenueDocumentation', $quotedGoalName), + 'goal_' . $idGoal . '_nb_conversions' => Piwik_Translate('Goals_ColumnConversionsDocumentation', $quotedGoalName), + 'goal_' . $idGoal . '_conversion_rate' => Piwik_Translate('Goals_ColumnConversionRateDocumentation', $quotedGoalName), + 'goal_' . $idGoal . '_revenue' => Piwik_Translate('Goals_ColumnRevenueDocumentation', $quotedGoalName), 'goal_' . $idGoal . '_revenue_per_visit' => - Piwik_Translate('Goals_ColumnRevenuePerVisitDocumentation', Piwik_Translate('Goals_EcommerceAndGoalsMenu')), + Piwik_Translate('Goals_ColumnRevenuePerVisitDocumentation', Piwik_Translate('Goals_EcommerceAndGoalsMenu')), ); } @@ -413,8 +417,8 @@ class HtmlTable extends Visualization // add the ecommerce goal if ecommerce is enabled for the site if (Site::isEcommerceEnabledFor($idSite)) { $ecommerceGoal = array( - 'idgoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER, - 'name' => Piwik_Translate('Goals_EcommerceOrder'), + 'idgoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER, + 'name' => Piwik_Translate('Goals_EcommerceOrder'), 'quoted_name' => false ); $allGoals[$ecommerceGoal['idgoal']] = $ecommerceGoal; diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable/AllColumns.php b/plugins/CoreVisualizations/Visualizations/HtmlTable/AllColumns.php index 20d31e8270..57e3dcef95 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable/AllColumns.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable/AllColumns.php @@ -22,7 +22,7 @@ class AllColumns extends HtmlTable /** * Constructor. - * + * * @param \Piwik\ViewDataTable $view */ public function __construct($view) diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable/Goals.php b/plugins/CoreVisualizations/Visualizations/HtmlTable/Goals.php index e6dd8abbc3..138478fce0 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable/Goals.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable/Goals.php @@ -22,7 +22,7 @@ class Goals extends HtmlTable /** * Constructor. - * + * * @param \Piwik\ViewDataTable $view */ public function __construct($view) diff --git a/plugins/CoreVisualizations/Visualizations/JqplotGraph.php b/plugins/CoreVisualizations/Visualizations/JqplotGraph.php index 42a2fcf1f6..e283920774 100644 --- a/plugins/CoreVisualizations/Visualizations/JqplotGraph.php +++ b/plugins/CoreVisualizations/Visualizations/JqplotGraph.php @@ -27,25 +27,25 @@ class JqplotGraph extends Graph /** * The name of the JavaScript class to use as this graph's external series toggle. The class * must be a subclass of JQPlotExternalSeriesToggle. - * + * * @see self::EXTERNAL_SERIES_TOGGLE_SHOW_ALL - * + * * Default value: false */ const EXTERNAL_SERIES_TOGGLE = 'external_series_toggle'; /** * Whether the graph should show all loaded series upon initial display. - * + * * @see self::EXTERNAL_SERIES_TOGGLE - * + * * Default value: false */ const EXTERNAL_SERIES_TOGGLE_SHOW_ALL = 'external_series_toggle_show_all'; /** * The number of x-axis ticks for each x-axis label. - * + * * Default: 2 */ const X_AXIS_STEP_SIZE = 'x_axis_step_size'; @@ -59,13 +59,13 @@ class JqplotGraph extends Graph /** * Constructor. - * + * * @param \Piwik\ViewDataTable $view */ public function __construct($view) { parent::__construct($view, $template = "@CoreVisualizations/_dataTableViz_jqplotGraph.twig"); - + // do not sort if sorted column was initially "label" or eg. it would make "Visits by Server time" not pretty if ($view->filter_sort_column != 'label') { $columns = $view->columns_to_display; @@ -82,27 +82,27 @@ class JqplotGraph extends Graph /** * Returns an array mapping property names with default values for this visualization. - * + * * @return array */ public static function getDefaultPropertyValues() { $result = parent::getDefaultPropertyValues(); return array_merge_recursive($result, array( - 'show_offset_information' => false, - 'show_pagination_control' => false, - 'show_exclude_low_population' => false, - 'show_search' => false, - 'show_export_as_image_icon' => true, - 'y_axis_unit' => '', - 'visualization_properties' => array( - 'jqplot_graph' => array( - 'external_series_toggle' => false, - 'external_series_toggle_show_all' => false, - 'x_axis_step_size' => 2 - ) - ) - )); + 'show_offset_information' => false, + 'show_pagination_control' => false, + 'show_exclude_low_population' => false, + 'show_search' => false, + 'show_export_as_image_icon' => true, + 'y_axis_unit' => '', + 'visualization_properties' => array( + 'jqplot_graph' => array( + 'external_series_toggle' => false, + 'external_series_toggle_show_all' => false, + 'x_axis_step_size' => 2 + ) + ) + )); } public function getGraphData($dataTable, $properties) diff --git a/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php b/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php index 7520025143..e125f6e757 100644 --- a/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php +++ b/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php @@ -28,13 +28,13 @@ class Evolution extends JqplotGraph /** * Whether to show a line graph or a bar graph. - * + * * Default value: true */ const SHOW_LINE_GRAPH = 'show_line_graph'; public static $clientSideProperties = array('show_line_graph'); - + public static $overridableProperties = array('show_line_graph'); public function __construct($view) diff --git a/plugins/CoreVisualizations/Visualizations/JqplotGraph/Pie.php b/plugins/CoreVisualizations/Visualizations/JqplotGraph/Pie.php index b051439d3d..e9bffcbe73 100644 --- a/plugins/CoreVisualizations/Visualizations/JqplotGraph/Pie.php +++ b/plugins/CoreVisualizations/Visualizations/JqplotGraph/Pie.php @@ -33,7 +33,7 @@ class Pie extends JqplotGraph if ($metricColumn == 'label') { $metricColumn = next($view->columns_to_display); } - $view->columns_to_display = array($metricColumn ?: 'nb_visits'); + $view->columns_to_display = array($metricColumn ? : 'nb_visits'); }; } |