Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2015-07-03 03:54:27 +0300
committersgiehl <stefan@piwik.org>2015-10-06 18:25:13 +0300
commit9ba8f216fd7856ce5fef06bf82ecb8f8a2e7e630 (patch)
tree6ce07d18a85d00b39ab720abe042361c0775aead /plugins/UserCountry
parent8ccc9dc05da021325cdbf141a548637fa52f16b2 (diff)
generate pages instead of implementing them in each controller
Diffstat (limited to 'plugins/UserCountry')
-rw-r--r--plugins/UserCountry/Categories/LocationsSubcategory.php19
-rw-r--r--plugins/UserCountry/Controller.php9
-rw-r--r--plugins/UserCountry/Menu.php6
-rw-r--r--plugins/UserCountry/Reports/Base.php2
-rw-r--r--plugins/UserCountry/Reports/GetCity.php5
-rw-r--r--plugins/UserCountry/Reports/GetContinent.php17
-rw-r--r--plugins/UserCountry/Reports/GetCountry.php3
-rw-r--r--plugins/UserCountry/Reports/GetRegion.php4
-rw-r--r--plugins/UserCountry/templates/getDistinctCountries.twig5
-rw-r--r--plugins/UserCountry/templates/index.twig29
10 files changed, 47 insertions, 52 deletions
diff --git a/plugins/UserCountry/Categories/LocationsSubcategory.php b/plugins/UserCountry/Categories/LocationsSubcategory.php
new file mode 100644
index 0000000000..22be202abd
--- /dev/null
+++ b/plugins/UserCountry/Categories/LocationsSubcategory.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\UserCountry\Categories;
+
+use Piwik\Category\Subcategory;
+
+class LocationsSubcategory extends Subcategory
+{
+ protected $categoryId = 'General_Visitors';
+ protected $id = 'UserCountry_SubmenuLocations';
+ protected $order = 25;
+
+}
diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php
index a241968cbd..0ed417e421 100644
--- a/plugins/UserCountry/Controller.php
+++ b/plugins/UserCountry/Controller.php
@@ -26,18 +26,13 @@ use Piwik\View;
*/
class Controller extends \Piwik\Plugin\ControllerAdmin
{
- public function index()
+ public function getDistinctCountries()
{
- $view = new View('@UserCountry/index');
+ $view = new View('@UserCountry/getDistinctCountries');
$view->urlSparklineCountries = $this->getUrlSparkline('getLastDistinctCountriesGraph');
$view->numberDistinctCountries = $this->getNumberOfDistinctCountries(true);
- $view->dataTableCountry = $this->renderReport('getCountry');
- $view->dataTableContinent = $this->renderReport('getContinent');
- $view->dataTableRegion = $this->renderReport('getRegion');
- $view->dataTableCity = $this->renderReport('getCity');
-
return $view->render();
}
diff --git a/plugins/UserCountry/Menu.php b/plugins/UserCountry/Menu.php
index fa90e258db..92f88a7f14 100644
--- a/plugins/UserCountry/Menu.php
+++ b/plugins/UserCountry/Menu.php
@@ -9,7 +9,6 @@
namespace Piwik\Plugins\UserCountry;
use Piwik\Menu\MenuAdmin;
-use Piwik\Menu\MenuReporting;
use Piwik\Piwik;
class Menu extends \Piwik\Plugin\Menu
@@ -22,9 +21,4 @@ class Menu extends \Piwik\Plugin\Menu
$order = 9);
}
}
-
- public function configureReportingMenu(MenuReporting $menu)
- {
- $menu->addVisitorsItem('UserCountry_SubmenuLocations', $this->urlForAction('index'));
- }
}
diff --git a/plugins/UserCountry/Reports/Base.php b/plugins/UserCountry/Reports/Base.php
index f7a4f34203..c24ec82d24 100644
--- a/plugins/UserCountry/Reports/Base.php
+++ b/plugins/UserCountry/Reports/Base.php
@@ -17,7 +17,7 @@ abstract class Base extends \Piwik\Plugin\Report
{
protected function init()
{
- $this->category = 'General_Visitors';
+ $this->categoryId = 'General_Visitors';
}
protected function getGeoIPReportDocSuffix()
diff --git a/plugins/UserCountry/Reports/GetCity.php b/plugins/UserCountry/Reports/GetCity.php
index ce087c3f3c..e492d12ee2 100644
--- a/plugins/UserCountry/Reports/GetCity.php
+++ b/plugins/UserCountry/Reports/GetCity.php
@@ -22,9 +22,8 @@ class GetCity extends Base
$this->documentation = Piwik::translate('UserCountry_getCityDocumentation') . '<br/>' . $this->getGeoIPReportDocSuffix();
$this->metrics = array('nb_visits', 'nb_uniq_visitors', 'nb_actions');
$this->hasGoalMetrics = true;
- $this->order = 8;
- $this->widgetTitle = Piwik::translate('UserCountry_WidgetLocation')
- . ' (' . Piwik::translate('UserCountry_City') . ')';
+ $this->order = 10;
+ $this->subcategoryId = 'UserCountry_SubmenuLocations';
}
public function configureView(ViewDataTable $view)
diff --git a/plugins/UserCountry/Reports/GetContinent.php b/plugins/UserCountry/Reports/GetContinent.php
index 7ba6d2ca1c..b524c4f048 100644
--- a/plugins/UserCountry/Reports/GetContinent.php
+++ b/plugins/UserCountry/Reports/GetContinent.php
@@ -11,6 +11,9 @@ namespace Piwik\Plugins\UserCountry\Reports;
use Piwik\Piwik;
use Piwik\Plugin\ViewDataTable;
use Piwik\Plugins\UserCountry\Columns\Continent;
+use Piwik\Report\ReportWidgetFactory;
+use Piwik\Widget\WidgetContainerConfig;
+use Piwik\Widget\WidgetsList;
class GetContinent extends Base
{
@@ -23,8 +26,18 @@ class GetContinent extends Base
$this->metrics = array('nb_visits', 'nb_uniq_visitors', 'nb_actions');
$this->hasGoalMetrics = true;
$this->order = 6;
- $this->widgetTitle = Piwik::translate('UserCountry_WidgetLocation')
- . ' (' . Piwik::translate('UserCountry_Continent') . ')';
+
+ $this->subcategoryId = 'UserCountry_SubmenuLocations';
+ }
+
+ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
+ {
+ $widgetsList->addWidgetConfig($factory->createContainerWidget('Continent'));
+
+ $widgetsList->addToContainerWidget('Continent', $factory->createWidget());
+
+ $widget = $factory->createWidget()->setAction('getDistinctCountries')->setName('');
+ $widgetsList->addToContainerWidget('Continent', $widget);
}
public function configureView(ViewDataTable $view)
diff --git a/plugins/UserCountry/Reports/GetCountry.php b/plugins/UserCountry/Reports/GetCountry.php
index 88363e1efa..5b038f7e49 100644
--- a/plugins/UserCountry/Reports/GetCountry.php
+++ b/plugins/UserCountry/Reports/GetCountry.php
@@ -24,8 +24,7 @@ class GetCountry extends Base
$this->metrics = array('nb_visits', 'nb_uniq_visitors', 'nb_actions');
$this->hasGoalMetrics = true;
$this->order = 5;
- $this->widgetTitle = Piwik::translate('UserCountry_WidgetLocation')
- . ' (' . Piwik::translate('UserCountry_Country') . ')';
+ $this->subcategoryId = 'UserCountry_SubmenuLocations';
}
public function configureView(ViewDataTable $view)
diff --git a/plugins/UserCountry/Reports/GetRegion.php b/plugins/UserCountry/Reports/GetRegion.php
index 648b78967b..7e418ebef2 100644
--- a/plugins/UserCountry/Reports/GetRegion.php
+++ b/plugins/UserCountry/Reports/GetRegion.php
@@ -23,8 +23,8 @@ class GetRegion extends Base
$this->metrics = array('nb_visits', 'nb_uniq_visitors', 'nb_actions');
$this->hasGoalMetrics = true;
$this->order = 7;
- $this->widgetTitle = Piwik::translate('UserCountry_WidgetLocation')
- . ' (' . Piwik::translate('UserCountry_Region') . ')';
+
+ $this->subcategoryId = 'UserCountry_SubmenuLocations';
}
public function configureView(ViewDataTable $view)
diff --git a/plugins/UserCountry/templates/getDistinctCountries.twig b/plugins/UserCountry/templates/getDistinctCountries.twig
new file mode 100644
index 0000000000..7a2506f782
--- /dev/null
+++ b/plugins/UserCountry/templates/getDistinctCountries.twig
@@ -0,0 +1,5 @@
+<div class="sparkline">
+ {{ sparkline(urlSparklineCountries) }}
+ {{ 'UserCountry_DistinctCountries'|translate("<strong>"~numberDistinctCountries~"</strong>")|raw }}
+</div>
+<br style="clear:left"/> \ No newline at end of file
diff --git a/plugins/UserCountry/templates/index.twig b/plugins/UserCountry/templates/index.twig
deleted file mode 100644
index fe1a6735dd..0000000000
--- a/plugins/UserCountry/templates/index.twig
+++ /dev/null
@@ -1,29 +0,0 @@
-<div class="row">
-
- <div class="col-md-6">
- {{ postEvent("Template.leftColumnUserCountry") }}
-
- <h2 piwik-enriched-headline>{{ 'UserCountry_Continent'|translate }}</h2>
- {{ dataTableContinent|raw }}
-
- <div class="sparkline">
- {{ sparkline(urlSparklineCountries) }}
- {{ 'UserCountry_DistinctCountries'|translate("<strong>"~numberDistinctCountries~"</strong>")|raw }}
- </div>
- <div style="clear:left"></div>
-
- {{ postEvent("Template.footerUserCountry") }}
- </div>
-
- <div class="col-md-6">
- <h2 piwik-enriched-headline>{{ 'UserCountry_Country'|translate }}</h2>
- {{ dataTableCountry|raw }}
-
- <h2 piwik-enriched-headline>{{ 'UserCountry_Region'|translate }}</h2>
- {{ dataTableRegion|raw }}
-
- <h2 piwik-enriched-headline>{{ 'UserCountry_City'|translate }}</h2>
- {{ dataTableCity|raw }}
- </div>
-
-</div>