From 1790ae4d7b27e1356e5ad1b82d0aae5f7b6f0d31 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Fri, 27 Jun 2014 05:27:20 +0200 Subject: automatically detect visualizations within visualization directory --- .../ExampleVisualization/ExampleVisualization.php | 14 ----- plugins/ExampleVisualization/SimpleTable.php | 71 ---------------------- .../Visualizations/SimpleTable.php | 71 ++++++++++++++++++++++ 3 files changed, 71 insertions(+), 85 deletions(-) delete mode 100644 plugins/ExampleVisualization/SimpleTable.php create mode 100644 plugins/ExampleVisualization/Visualizations/SimpleTable.php (limited to 'plugins/ExampleVisualization') diff --git a/plugins/ExampleVisualization/ExampleVisualization.php b/plugins/ExampleVisualization/ExampleVisualization.php index e0f7edb085..f0c42a9598 100644 --- a/plugins/ExampleVisualization/ExampleVisualization.php +++ b/plugins/ExampleVisualization/ExampleVisualization.php @@ -12,18 +12,4 @@ namespace Piwik\Plugins\ExampleVisualization; */ class ExampleVisualization extends \Piwik\Plugin { - /** - * @see Piwik\Plugin::getListHooksRegistered - */ - public function getListHooksRegistered() - { - return array( - 'ViewDataTable.addViewDataTable' => 'getAvailableVisualizations' - ); - } - - public function getAvailableVisualizations(&$visualizations) - { - $visualizations[] = __NAMESPACE__ . '\\SimpleTable'; - } } diff --git a/plugins/ExampleVisualization/SimpleTable.php b/plugins/ExampleVisualization/SimpleTable.php deleted file mode 100644 index 6aca5e83ec..0000000000 --- a/plugins/ExampleVisualization/SimpleTable.php +++ /dev/null @@ -1,71 +0,0 @@ -requestConfig->filter_sort_order = 'desc'; - } - - public function beforeGenericFiltersAreAppliedToLoadedDataTable() - { - // this hook is executed before generic filters like "filter_limit" and "filter_offset" are applied - // Usage: - // $this->dateTable->filter($nameOrClosure); - } - - public function afterGenericFiltersAreAppliedToLoadedDataTable() - { - // this hook is executed after generic filters like "filter_limit" and "filter_offset" are applied - // Usage: - // $this->dateTable->filter($nameOrClosure, $parameters); - } - - public function afterAllFiltersAreApplied() - { - // this hook is executed after the data table is loaded and after all filteres are applied. - // format your data here that you want to pass to the view - - $this->assignTemplateVar('vizTitle', 'MyAwesomeTitle'); - } - - public function beforeRender() - { - // Configure how your visualization should look like, for instance you can disable search - // By defining the config properties shortly before rendering you make sure the config properties have a certain - // value because they could be changed by a report or by request parameters ($_GET / $_POST) before. - // $this->config->show_search = false - } - - public static function canDisplayViewDataTable(ViewDataTable $view) - { - // You usually do not need to implement this method. Here you can define whether your visualization can display - // a specific data table or not. For instance you may only display your visualization in case a single data - // table is requested. Example: - // return $view->isRequestingSingleDataTable(); - - return parent::canDisplayViewDataTable($view); - } -} diff --git a/plugins/ExampleVisualization/Visualizations/SimpleTable.php b/plugins/ExampleVisualization/Visualizations/SimpleTable.php new file mode 100644 index 0000000000..8aeeec7f3b --- /dev/null +++ b/plugins/ExampleVisualization/Visualizations/SimpleTable.php @@ -0,0 +1,71 @@ +requestConfig->filter_sort_order = 'desc'; + } + + public function beforeGenericFiltersAreAppliedToLoadedDataTable() + { + // this hook is executed before generic filters like "filter_limit" and "filter_offset" are applied + // Usage: + // $this->dateTable->filter($nameOrClosure); + } + + public function afterGenericFiltersAreAppliedToLoadedDataTable() + { + // this hook is executed after generic filters like "filter_limit" and "filter_offset" are applied + // Usage: + // $this->dateTable->filter($nameOrClosure, $parameters); + } + + public function afterAllFiltersAreApplied() + { + // this hook is executed after the data table is loaded and after all filteres are applied. + // format your data here that you want to pass to the view + + $this->assignTemplateVar('vizTitle', 'MyAwesomeTitle'); + } + + public function beforeRender() + { + // Configure how your visualization should look like, for instance you can disable search + // By defining the config properties shortly before rendering you make sure the config properties have a certain + // value because they could be changed by a report or by request parameters ($_GET / $_POST) before. + // $this->config->show_search = false + } + + public static function canDisplayViewDataTable(ViewDataTable $view) + { + // You usually do not need to implement this method. Here you can define whether your visualization can display + // a specific data table or not. For instance you may only display your visualization in case a single data + // table is requested. Example: + // return $view->isRequestingSingleDataTable(); + + return parent::canDisplayViewDataTable($view); + } +} -- cgit v1.2.3