diff options
author | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-09-14 23:31:40 +0400 |
---|---|---|
committer | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-09-14 23:31:40 +0400 |
commit | b1205a5db1a884e2e02a8d6845cd2566d05cc355 (patch) | |
tree | 69fdfb613970bea94d4b027993546e5562325533 /core/ViewDataTable.php | |
parent | c1aad8d906d38c0662b264d38aef549f6fea0e62 (diff) |
Refs #4041, force DataTable visualizations to specify which properties should be overridable and move some view properties to different visualizations.
Diffstat (limited to 'core/ViewDataTable.php')
-rw-r--r-- | core/ViewDataTable.php | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index 5fdd36c32a..8f2b0a88c8 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -145,7 +145,6 @@ class ViewDataTable $this->setDefaultProperties(); $this->setViewProperties($viewProperties); - $this->overrideViewPropertiesWithQueryParams(); $this->idSubtable = Common::getRequestVar('idSubtable', false, 'int'); $this->viewProperties['show_footer_icons'] = ($this->idSubtable == false); @@ -154,6 +153,8 @@ class ViewDataTable $this->viewProperties['report_id'] = $currentControllerName . '.' . $currentControllerAction; $this->viewProperties['self_url'] = $this->getBaseReportUrl($currentControllerName, $currentControllerAction); + $this->overrideViewPropertiesWithQueryParams(); + // the exclude low population threshold value is sometimes obtained by requesting data. // to avoid issuing unecessary requests when display properties are determined by metadata, // we allow it to be a closure. @@ -282,14 +283,7 @@ class ViewDataTable */ public function getClientSideProperties() { - $result = array(); - - if ($this->visualizationClass) { - $klass = $this->visualizationClass; - $result = array_merge($result, $klass::getClientSideProperties()); - } - - return $result; + return $this->getPropertyNameListWithMetaProperty(Properties::$clientSideProperties, __FUNCTION__); } /** @@ -300,19 +294,17 @@ class ViewDataTable */ public function getClientSideParameters() { - $result = array( - 'filter_excludelowpop', - 'filter_excludelowpop_value', - 'filter_pattern', - 'filter_column', - ); - - if ($this->visualizationClass) { - $klass = $this->visualizationClass; - $result = array_merge($result, $klass::getClientSideParameters()); - } + return $this->getPropertyNameListWithMetaProperty(Properties::$clientSideParameters, __FUNCTION__); + } - return $result; + /** + * Returns the list of view properties that can be overriden by query parameters. + * + * @return array + */ + public function getOverridableProperties() + { + return $this->getPropertyNameListWithMetaProperty(Properties::$overridableProperties, __FUNCTION__); } public function getCurrentControllerAction() @@ -1244,20 +1236,36 @@ class ViewDataTable private function overrideViewPropertiesWithQueryParams() { - // TODO: should mark properties that are overridable so not all properties can be overidden this way - $queryParams = $_GET + $_POST; - foreach ($queryParams as $name => $value) { - if (empty($value)) { - continue; - } - - $value = Common::getRequestVar($name, $default = null, $type = null, $queryParams); - + $properties = $this->getOverridableProperties(); + foreach ($properties as $name) { if (Properties::isCoreViewProperty($name)) { - $this->viewProperties[$name] = $value; + $default = $this->viewProperties[$name]; + + $this->viewProperties[$name] = $this->getPropertyFromQueryParam($name, $default); } else if (Properties::isValidVisualizationProperty($this->visualizationClass, $name)) { - $this->viewProperties['visualization_properties']->$name = $value; + $default = $this->viewProperties['visualization_properties']->$name; + + $this->viewProperties['visualization_properties']->$name = + $this->getPropertyFromQueryParam($name, $default); } } } + + private function getPropertyFromQueryParam($name, $defaultValue) + { + $type = is_numeric($defaultValue) ? 'int' : null; + return Common::getRequestVar($name, $defaultValue, $type); + } + + /** + * Helper function for getCliendSiteProperties/getClientSideParameters/etc. + */ + private function getPropertyNameListWithMetaProperty($propertyNames, $getPropertiesFunctionName) + { + if ($this->visualizationClass) { + $klass = $this->visualizationClass; + $propertyNames = array_merge($propertyNames, $klass::$getPropertiesFunctionName()); + } + return $propertyNames; + } }
\ No newline at end of file |