Skip to content

Commit

Permalink
Refs #4040, #4041, change the way jqplot.js checks for viewdatatble t…
Browse files Browse the repository at this point in the history
…ypes, changed relatedReports view property name to related_reports and fixed spelling of row_picker_mach_rows_by.
  • Loading branch information
Benaka Moorthi committed Aug 4, 2013
1 parent 2615404 commit 9b5a42a
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 58 deletions.
6 changes: 3 additions & 3 deletions core/JqplotDataGenerator/Evolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function initChartObjectData($dataTable)
// put together configuration for row picker.
// do this for every data table in the array because rows do not
// have to present for each date.
if ($this->properties['row_picker_mach_rows_by'] !== false) {
if ($this->properties['row_picker_match_rows_by'] !== false) {
$rowVisible = $this->handleRowForRowPicker($rowLabel);
if (!$rowVisible) {
continue;
Expand Down Expand Up @@ -146,7 +146,7 @@ protected function initChartObjectData($dataTable)
$this->addSeriesPickerToView();

// configure the row picker
if ($this->properties['row_picker_mach_rows_by'] !== false) {
if ($this->properties['row_picker_match_rows_by'] !== false) {
$visualization->setSelectableRows(array_values($this->rowPickerConfig));
}
}
Expand All @@ -162,7 +162,7 @@ private function handleRowForRowPicker(&$rowLabel)
{
// determine whether row is visible
$isVisible = true;
if ($this->properties['row_picker_mach_rows_by'] == 'label') {
if ($this->properties['row_picker_match_rows_by'] == 'label') {
$isVisible = in_array($rowLabel, $this->properties['row_picker_visible_rows']);
}

Expand Down
9 changes: 5 additions & 4 deletions core/ViewDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function __construct($visualizationClass = null)
$this->viewProperties['exportLimit'] = Config::getInstance()->General['API_datatable_default_limit'];
$this->viewProperties['highlight_summary_row'] = false;
$this->viewProperties['metadata'] = array();
$this->viewProperties['relatedReports'] = array();
$this->viewProperties['related_reports'] = array();
$this->viewProperties['title'] = 'unknown';
$this->viewProperties['tooltip_metadata_name'] = false;
$this->viewProperties['enable_sort'] = true;
Expand All @@ -175,6 +175,7 @@ public function __construct($visualizationClass = null)
$this->viewProperties['subtable_controller_action'] = false;
$this->viewProperties['datatable_css_class'] = false;
$this->viewProperties['filters'] = array();
$this->viewProperties['hide_annotations_view'] = true;
$this->viewProperties['columns_to_display'] = array();

$columns = Common::getRequestVar('columns', false);
Expand Down Expand Up @@ -549,7 +550,7 @@ private static function getAllReportDisplayProperties()

/**
* Sets a view property by name. This function handles special view properties
* like 'translations' & 'relatedReports' that store arrays.
* like 'translations' & 'related_reports' that store arrays.
*
* @param string $name
* @param mixed $value For array properties, $value can be a comma separated string.
Expand All @@ -567,7 +568,7 @@ private function setViewProperty($name, $value)
|| $name == 'filters'
) {
$this->viewProperties[$name] = array_merge($this->viewProperties[$name], $value);
} else if ($name == 'relatedReports') { // TODO: should process after (in overrideViewProperties)
} else if ($name == 'related_reports') { // TODO: should process after (in overrideViewProperties)
$this->addRelatedReports($value);
} else if ($name == 'visualization_properties') {
$this->setVisualizationPropertiesFromMetadata($value);
Expand Down Expand Up @@ -1070,7 +1071,7 @@ private function addRelatedReport($module, $action, $title, $queryParams = array
}

$url = $this->getBaseReportUrl($module, $action, $queryParams);
$this->viewProperties['relatedReports'][$url] = $title;
$this->viewProperties['related_reports'][$url] = $title;
}

private function addRelatedReports($relatedReports)
Expand Down
10 changes: 7 additions & 3 deletions core/ViewDataTable/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*
* @see ViewDataTable - for more info.
*
* TODO: change the names of properties to match the const names where appropriate.
* TODO: list default value for each property
*/
class Properties
Expand Down Expand Up @@ -125,7 +124,7 @@ class Properties
*
* @see also self::TITLE. Both must be set if associating related reports.
*/
const RELATED_REPORTS = 'relatedReports';
const RELATED_REPORTS = 'related_reports';

/**
* The report title. Used with related reports so report headings can be changed when switching
Expand Down Expand Up @@ -180,7 +179,7 @@ class Properties
*
* @see self::ROW_PICKER_VISIBLE_VALUES
*/
const ROW_PICKER_VALUE_COLUMN = 'row_picker_mach_rows_by';
const ROW_PICKER_VALUE_COLUMN = 'row_picker_match_rows_by';

/**
* Contains the list of values available for the Row Picker.
Expand Down Expand Up @@ -372,6 +371,11 @@ class Properties
*/
const SHOW_OFFSET_INFORMATION = 'show_offset_information';

/**
* Controls whether annotations are shown or not.
*/
const HIDE_ANNOTATIONS_VIEW = 'hide_annotations_view';

/**
* Returns the set of all valid ViewDataTable properties. The result is an array with property
* names as keys. Values of the array are undefined.
Expand Down
2 changes: 1 addition & 1 deletion core/Visualization/JqplotGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static function getDefaultPropertyValues()
'show_search' => false,
'show_export_as_image_icon' => true,
'y_axis_unit' => '',
'row_picker_mach_rows_by' => false,
'row_picker_match_rows_by' => false,
'row_picker_visible_rows' => array(),
'visualization_properties' => array(
'JqplotGraph' => array(
Expand Down
7 changes: 1 addition & 6 deletions core/Visualization/JqplotGraph/Evolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ class Evolution extends JqplotGraph
const ID = 'graphEvolution';
const SERIES_COLOR_COUNT = 8;

/**
* Controls whether annotations are shown or not.
*/
const HIDE_ANNOTATIONS_VIEW = 'hide_annotations_view';

public function __construct($view)
{
parent::__construct($view);
Expand All @@ -53,8 +48,8 @@ public static function getDefaultPropertyValues()
$result['show_table'] = false;
$result['show_table'] = false;
$result['show_table_all_columns'] = false;
$result['hide_annotations_view'] = false;
$result['visualization_properties']['Evolution']['graph_height'] = self::GRAPH_HEIGHT . 'px';
$result['visualization_properties']['Evolution']['hide_annotations_view'] = false;
return $result;
}

Expand Down
12 changes: 6 additions & 6 deletions plugins/Actions/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ public function getDisplayPropertiesForEntryPageUrls()
'filter_sort_column' => 'entry_nb_visits',
'filter_sort_order' => 'desc',
'title' => Piwik_Translate('Actions_SubmenuPagesEntry'),
'relatedReports' => array(
'related_reports' => array(
'Actions.getEntryPageTitles' => Piwik_Translate('Actions_EntryPageTitles')
),
'self_url' => $reportUrl
Expand Down Expand Up @@ -810,7 +810,7 @@ public function getDisplayPropertiesForExitPageUrls()
'filter_sort_column' => 'exit_nb_visits',
'filter_sort_order' => 'desc',
'title' => Piwik_Translate('Actions_SubmenuPagesExit'),
'relatedReports' => array(
'related_reports' => array(
'Actions.getExitPageTitles' => Piwik_Translate('Actions_ExitPageTitles')
),
'self_url' => $reportUrl,
Expand Down Expand Up @@ -897,7 +897,7 @@ public function getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch($i
'filter_sort_order' => 'desc',
'show_exclude_low_population' => false,
'title' => $title,
'relatedReports' => $relatedReports
'related_reports' => $relatedReports
);

$this->addExcludeLowPopDisplayProperties($result);
Expand All @@ -920,7 +920,7 @@ public function getDisplayPropertiesForGetPageTitles()
'columns_to_display' => array('label', 'nb_hits', 'nb_visits', 'bounce_rate',
'avg_time_on_page', 'exit_rate', 'avg_time_generation'),
'title' => Piwik_Translate('Actions_SubmenuPageTitles'),
'relatedReports' => array(
'related_reports' => array(
'Actions.getEntryPageTitles' => Piwik_Translate('Actions_EntryPageTitles'),
'Actions.getExitPageTitles' => Piwik_Translate('Actions_ExitPageTitles'),
),
Expand All @@ -946,7 +946,7 @@ public function getDisplayPropertiesForGetEntryPageTitles()
),
'columns_to_display' => array('label', 'entry_nb_visits', 'entry_bounce_count', 'bounce_rate'),
'title' => Piwik_Translate('Actions_EntryPageTitles'),
'relatedReports' => array(
'related_reports' => array(
'Actions.getPageTitles' => Piwik_Translate('Actions_SubmenuPageTitles'),
"Actions.$entryPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesEntry')
),
Expand All @@ -970,7 +970,7 @@ public function getDisplayPropertiesForGetExitPageTitles()
),
'columns_to_display' => array('label', 'exit_nb_visits', 'nb_visits', 'exit_rate'),
'title' => Piwik_Translate('Actions_ExitPageTitles'),
'relatedReports' => array(
'related_reports' => array(
'Actions.getPageTitles' => Piwik_Translate('Actions_SubmenuPageTitles'),
"Actions.$exitPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesExit'),
),
Expand Down
22 changes: 9 additions & 13 deletions plugins/CoreHome/javascripts/jqplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,17 @@ JQPlot.prototype = {

/** Generic render function */
render: function (targetDivId, lang) {
var type = $('#' + targetDivId).closest('div.dataTable').data('dataTableInstance').param['viewDataTable'];
var dataTableDiv = $('#' + targetDivId).closest('div.dataTable');

// preapare the appropriate chart type
switch (type) {// TODO: should rely on CSS, not viewDataTable. otherwise ecommerceOrder row evolution will fail
case 'graphEvolution':
this.prepareEvolutionChart(targetDivId, lang);
break;
case 'graphVerticalBar':
this.prepareBarChart(targetDivId, lang);
break;
case 'graphPie':
this.preparePieChart(targetDivId, lang);
break;
default:
return;
if (dataTableDiv.hasClass('dataTableVizEvolution')) {
this.prepareEvolutionChart(targetDivId, lang);
} else if (dataTableDiv.hasClass('dataTableVizBar')) {
this.prepareBarChart(targetDivId, lang);
} else if (dataTableDiv.hasClass('dataTableVizPie')) {
this.preparePieChart(targetDivId, lang);
} else {
return;
}

// handle replot
Expand Down
10 changes: 5 additions & 5 deletions plugins/CoreHome/templates/_dataTableFooter.twig
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
{% endif %}
</ul>
</div>
{% if isPluginLoaded('Annotations') and not properties.datatable_visualizations.hide_annotations_view|default(true) %}
{% if isPluginLoaded('Annotations') and not properties.hide_annotations_view %}
<div class="annotationView" title="{{ 'Annotations_IconDesc_js'|translate }}">
<a class="tableIcon">
<img width="16" height="16" src="plugins/Zeitgeist/images/grey_marker.png"/>
Expand All @@ -140,16 +140,16 @@
{% endif %}

<div class="datatableRelatedReports">
{% if (properties.relatedReports is not empty) and properties.show_related_reports %}
{% if properties.relatedReports|length == 1 %}
{% if (properties.related_reports is not empty) and properties.show_related_reports %}
{% if properties.related_reports|length == 1 %}
{{ 'General_RelatedReport'|translate }}:
{% else %}
{{ 'General_RelatedReports'|translate }}:
{% endif %}
<ul style="list-style:none;{% if properties.relatedReports|length == 1 %}display:inline-block;{% endif %}}">
<ul style="list-style:none;{% if properties.related_reports|length == 1 %}display:inline-block;{% endif %}}">
<li><span href="{{ properties.self_url }}" style="display:none;">{{ properties.title }}</span></li>

{% for reportUrl,reportTitle in properties.relatedReports %}
{% for reportUrl,reportTitle in properties.related_reports %}
<li><span href="{{ reportUrl }}">{{ reportTitle }}</span></li>
{% endfor %}
</ul>
Expand Down
8 changes: 4 additions & 4 deletions plugins/DBStats/DBStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function getDisplayPropertiesForGetMetricDataSummary()
$this->addPresentationFilters($result);

$result['title'] = Piwik_Translate('DBStats_MetricTables');
$result['relatedReports'] = array(
$result['related_reports'] = array(
'DBStats.getMetricDataSummaryByYear' => Piwik_Translate('DBStats_MetricDataByYear')
);

Expand All @@ -161,7 +161,7 @@ private function getDisplayPropertiesForGetMetricDataSummaryByYear()

$result['translations']['label'] = Piwik_Translate('CoreHome_PeriodYear');
$result['title'] = Piwik_Translate('DBStats_MetricDataByYear');
$result['relatedReports'] = array(
$result['related_reports'] = array(
'DBStats.getMetricDataSummary' => Piwik_Translate('DBStats_MetricTables')
);

Expand All @@ -175,7 +175,7 @@ private function getDisplayPropertiesForGetReportDataSummary()
$this->addPresentationFilters($result);

$result['title'] = Piwik_Translate('DBStats_ReportTables');
$result['relatedReports'] = array(
$result['related_reports'] = array(
'DBStats.getReportDataSummaryByYear' => Piwik_Translate('DBStats_ReportDataByYear')
);

Expand All @@ -190,7 +190,7 @@ private function getDisplayPropertiesForGetReportDataSummaryByYear()

$result['translations']['label'] = Piwik_Translate('CoreHome_PeriodYear');
$result['title'] = Piwik_Translate('DBStats_ReportDataByYear');
$result['relatedReports'] = array(
$result['related_reports'] = array(
'DBStats.getReportDataSummary' => Piwik_Translate('DBStats_ReportTables')
);

Expand Down
10 changes: 5 additions & 5 deletions plugins/DevicesDetection/DevicesDetection.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private function getDisplayPropertiesForGetOsFamilies()
'show_exclude_low_population' => false,
'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelSystemFamily")),
'title' => Piwik_Translate('DeviceDetection_OperatingSystemFamilies'),
'relatedReports' => $this->getOsRelatedReports()
'related_reports' => $this->getOsRelatedReports()
);
}

Expand All @@ -329,7 +329,7 @@ private function getDisplayPropertiesForGetOsVersions()
'show_exclude_low_population' => false,
'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelSystemVersion")),
'title' => Piwik_Translate('DeviceDetection_OperatingSystemVersions'),
'relatedReports' => $this->getOsRelatedReports()
'related_reports' => $this->getOsRelatedReports()
);
}

Expand All @@ -340,7 +340,7 @@ private function getDisplayPropertiesForGetBrowserFamilies()
'show_exclude_low_population' => false,
'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrowserFamily")),
'title' => Piwik_Translate('DevicesDetection_BrowsersFamily'),
'relatedReports' => $this->getBrowserRelatedReports()
'related_reports' => $this->getBrowserRelatedReports()
);
}

Expand All @@ -350,7 +350,7 @@ private function getDisplayPropertiesForGetBrowserVersions()
'show_search' => false,
'show_exclude_low_population' => false,
'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrowserVersion")),
'relatedReports' => $this->getBrowserRelatedReports()
'related_reports' => $this->getBrowserRelatedReports()
);
}

Expand All @@ -369,4 +369,4 @@ private function getBrowserRelatedReports()
'DevicesDetection.getBrowserVersions' => Piwik_Translate('DevicesDetection_BrowserVersions')
);
}
}
}
2 changes: 1 addition & 1 deletion plugins/Referers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public function getEvolutionGraph($fetch = false, $typeReferer = false, array $c
$visibleRows = array($label, $total);
$view->request_parameters_to_modify['rows'] = $label . ',' . $total;
}
$view->row_picker_mach_rows_by = 'label';
$view->row_picker_match_rows_by = 'label';
$view->row_picker_visible_rows = $visibleRows;

$view->documentation = Piwik_Translate('Referers_EvolutionDocumentation') . '<br />'
Expand Down
12 changes: 6 additions & 6 deletions plugins/UserSettings/UserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private function getDisplayPropertiesForGetOS()
return array_merge($this->getBasicUserSettingsDisplayProperties(), array(
'translations' => array('label' => Piwik_Translate('UserSettings_ColumnOperatingSystem')),
'title' => Piwik_Translate('UserSettings_OperatingSystems'),
'relatedReports' => $this->getOsRelatedReports()
'related_reports' => $this->getOsRelatedReports()
));
}

Expand All @@ -217,7 +217,7 @@ private function getDisplayPropertiesForGetOSFamily()
return array_merge($this->getBasicUserSettingsDisplayProperties(), array(
'translations' => array('label' => Piwik_Translate('UserSettings_OperatingSystemFamily')),
'title' => Piwik_Translate('UserSettings_OperatingSystemFamily'),
'relatedReports' => $this->getOsRelatedReports()
'related_reports' => $this->getOsRelatedReports()
));
}

Expand All @@ -226,7 +226,7 @@ private function getDisplayPropertiesForGetBrowserVersion()
$result = array_merge($this->getBasicUserSettingsDisplayProperties(), array(
'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowserVersion')),
'title' => Piwik_Translate('UserSettings_ColumnBrowserVersion'),
'relatedReports' => $this->getBrowserRelatedReports()
'related_reports' => $this->getBrowserRelatedReports()
));
$result['visualization_properties']['JqplotGraph']['max_graph_elements'] = 7;
return $result;
Expand All @@ -237,7 +237,7 @@ private function getDisplayPropertiesForGetBrowser()
$result = array_merge($this->getBasicUserSettingsDisplayProperties(), array(
'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowser')),
'title' => Piwik_Translate('UserSettings_Browsers'),
'relatedReports' => $this->getBrowserRelatedReports()
'related_reports' => $this->getBrowserRelatedReports()
));
$result['visualization_properties']['JqplotGraph']['max_graph_elements'] = 7;
return $result;
Expand All @@ -260,7 +260,7 @@ private function getDisplayPropertiesForGetWideScreen()
'show_offset_information' => false,
'show_pagination_control' => false,
'title' => Piwik_Translate('UserSettings_ColumnTypeOfScreen'),
'relatedReports' => $this->getWideScreenDeviceTypeRelatedReports()
'related_reports' => $this->getWideScreenDeviceTypeRelatedReports()
));
}

Expand All @@ -269,7 +269,7 @@ private function getDisplayPropertiesForGetMobileVsDesktop()
return array_merge($this->getBasicUserSettingsDisplayProperties(), array(
'translations' => array('label' => Piwik_Translate('UserSettings_MobileVsDesktop')),
'title' => Piwik_Translate('UserSettings_MobileVsDesktop'),
'relatedReports' => $this->getWideScreenDeviceTypeRelatedReports()
'related_reports' => $this->getWideScreenDeviceTypeRelatedReports()
));
}

Expand Down
Loading

0 comments on commit 9b5a42a

Please sign in to comment.