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:
Diffstat (limited to 'plugins/CustomVariables')
-rw-r--r--plugins/CustomVariables/API.php59
-rw-r--r--plugins/CustomVariables/Archiver.php38
-rw-r--r--plugins/CustomVariables/Columns/Base.php12
-rw-r--r--plugins/CustomVariables/Columns/CustomVariableName.php2
-rw-r--r--plugins/CustomVariables/Columns/CustomVariableValue.php2
-rw-r--r--plugins/CustomVariables/Controller.php13
-rw-r--r--plugins/CustomVariables/CustomVariables.php36
-rw-r--r--plugins/CustomVariables/Menu.php33
-rw-r--r--plugins/CustomVariables/Model.php44
-rw-r--r--plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php25
-rw-r--r--plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.controller.js22
-rw-r--r--plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.html54
-rw-r--r--plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.js26
-rw-r--r--plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.less18
-rw-r--r--plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js59
-rw-r--r--plugins/CustomVariables/config/config.php7
-rw-r--r--plugins/CustomVariables/config/test.php4
-rw-r--r--plugins/CustomVariables/lang/cs.json13
-rw-r--r--plugins/CustomVariables/lang/de.json13
-rw-r--r--plugins/CustomVariables/lang/el.json13
-rw-r--r--plugins/CustomVariables/lang/en.json13
-rw-r--r--plugins/CustomVariables/lang/it.json13
-rw-r--r--plugins/CustomVariables/lang/pt-br.json13
-rw-r--r--plugins/CustomVariables/lang/sk.json7
-rw-r--r--plugins/CustomVariables/templates/manage.twig11
-rw-r--r--plugins/CustomVariables/tests/Integration/ModelTest.php2
-rw-r--r--plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml290
-rw-r--r--plugins/CustomVariables/tests/UI/.gitignore2
-rw-r--r--plugins/CustomVariables/tests/UI/CustomVariables_spec.js25
-rw-r--r--plugins/CustomVariables/tests/UI/expected-ui-screenshots/CustomVariables_link_in_menu.pngbin0 -> 6428 bytes
-rw-r--r--plugins/CustomVariables/tests/UI/expected-ui-screenshots/CustomVariables_manage.pngbin0 -> 68494 bytes
31 files changed, 721 insertions, 148 deletions
diff --git a/plugins/CustomVariables/API.php b/plugins/CustomVariables/API.php
index fa3a99dbca..69e6ee720c 100644
--- a/plugins/CustomVariables/API.php
+++ b/plugins/CustomVariables/API.php
@@ -8,10 +8,13 @@
*/
namespace Piwik\Plugins\CustomVariables;
+use Piwik\API\Request;
use Piwik\Archive;
+use Piwik\Container\StaticContainer;
use Piwik\DataTable;
use Piwik\Date;
use Piwik\Metrics;
+use Piwik\Piwik;
use Piwik\Plugins\Actions\Actions\ActionSiteSearch;
/**
@@ -71,6 +74,7 @@ class API extends \Piwik\Plugin\API
}
}
+
if ($flat) {
$dataTable->filterSubtables('Piwik\Plugins\CustomVariables\DataTable\Filter\CustomVariablesValuesFromNameId');
} else {
@@ -109,9 +113,64 @@ class API extends \Piwik\Plugin\API
// Hack Ecommerce product price tracking to display correctly
$dataTable->renameColumn('price_viewed', 'price');
}
+
$dataTable->filter('Piwik\Plugins\CustomVariables\DataTable\Filter\CustomVariablesValuesFromNameId');
return $dataTable;
}
+
+ /**
+ * Get a list of all available custom variable slots (scope + index) and which names have been used so far in
+ * each slot since the beginning of the website.
+ *
+ * @param int $idSite
+ * @return array
+ */
+ public function getUsagesOfSlots($idSite)
+ {
+ Piwik::checkUserHasAdminAccess($idSite);
+
+ $numVars = CustomVariables::getNumUsableCustomVariables();
+
+ $usedCustomVariables = array(
+ 'visit' => array_fill(1, $numVars, array()),
+ 'page' => array_fill(1, $numVars, array()),
+ );
+
+ /** @var DataTable $customVarUsages */
+ $today = StaticContainer::get('CustomVariables.today');
+ $date = '2008-12-12,' . $today;
+ $customVarUsages = Request::processRequest('CustomVariables.getCustomVariables',
+ array('idSite' => $idSite, 'period' => 'range', 'date' => $date,
+ 'format' => 'original')
+ );
+
+ foreach ($customVarUsages->getRows() as $row) {
+ $slots = $row->getMetadata('slots');
+
+ if (!empty($slots)) {
+ foreach ($slots as $slot) {
+ $usedCustomVariables[$slot['scope']][$slot['index']][] = array(
+ 'name' => $row->getColumn('label'),
+ 'nb_visits' => $row->getColumn('nb_visits'),
+ 'nb_actions' => $row->getColumn('nb_actions'),
+ );
+ }
+ }
+ }
+
+ $grouped = array();
+ foreach ($usedCustomVariables as $scope => $scopes) {
+ foreach ($scopes as $index => $cvars) {
+ $grouped[] = array(
+ 'scope' => $scope,
+ 'index' => $index,
+ 'usages' => $cvars
+ );
+ }
+ }
+
+ return $grouped;
+ }
}
diff --git a/plugins/CustomVariables/Archiver.php b/plugins/CustomVariables/Archiver.php
index bc43cbc8dd..39aa9e6bb7 100644
--- a/plugins/CustomVariables/Archiver.php
+++ b/plugins/CustomVariables/Archiver.php
@@ -8,10 +8,10 @@
*/
namespace Piwik\Plugins\CustomVariables;
-use Piwik\Common;
use Piwik\Config;
use Piwik\DataAccess\LogAggregator;
use Piwik\DataArray;
+use Piwik\DataTable;
use Piwik\Metrics;
use Piwik\Tracker\GoalManager;
use Piwik\Tracker;
@@ -35,6 +35,9 @@ class Archiver extends \Piwik\Plugin\Archiver
protected $maximumRowsInSubDataTable;
protected $newEmptyRow;
+ private $metadata = array();
+ private $metadataFlat = array();
+
function __construct($processor)
{
parent::__construct($processor);
@@ -50,7 +53,7 @@ class Archiver extends \Piwik\Plugin\Archiver
public function aggregateMultipleReports()
{
- $columnsAggregationOperation = null;
+ $columnsAggregationOperation = array('slots' => 'uniquearraymerge');
$this->getProcessor()->aggregateDataTableRecords(
self::CUSTOM_VARIABLE_RECORD_NAME,
@@ -74,6 +77,16 @@ class Archiver extends \Piwik\Plugin\Archiver
$this->removeVisitsMetricsFromActionsAggregate();
$this->dataArray->enrichMetricsWithConversions();
$table = $this->dataArray->asDataTable();
+
+ foreach ($table->getRows() as $row) {
+ $label = $row->getColumn('label');
+ if (!empty($this->metadata[$label])) {
+ foreach ($this->metadata[$label] as $name => $value) {
+ $row->addMetadata($name, $value);
+ }
+ }
+ }
+
$blob = $table->getSerialized(
$this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable,
$columnToSort = Metrics::INDEX_NB_VISITS
@@ -118,6 +131,8 @@ class Archiver extends \Piwik\Plugin\Archiver
$key = $row[$keyField];
$value = $this->cleanCustomVarValue($row[$valueField]);
+ $this->addMetadata($keyField, $key, Model::SCOPE_VISIT);
+
$this->dataArray->sumMetricsVisits($key, $row);
$this->dataArray->sumMetricsVisitsPivot($key, $value, $row);
}
@@ -137,6 +152,8 @@ class Archiver extends \Piwik\Plugin\Archiver
$key = $row[$keyField];
$value = $this->cleanCustomVarValue($row[$valueField]);
+ $this->addMetadata($keyField, $key, Model::SCOPE_PAGE);
+
$alreadyAggregated = $this->aggregateEcommerceCategories($key, $value, $row);
if (!$alreadyAggregated) {
$this->aggregateActionByKeyAndValue($key, $value, $row);
@@ -145,6 +162,22 @@ class Archiver extends \Piwik\Plugin\Archiver
}
}
+ private function addMetadata($keyField, $label, $scope)
+ {
+ $index = (int) str_replace('custom_var_k', '', $keyField);
+
+ if (!array_key_exists($label, $this->metadata)) {
+ $this->metadata[$label] = array('slots' => array());
+ }
+
+ $uniqueId = $label . 'scope' . $scope . 'index' . $index;
+
+ if (!isset($this->metadataFlat[$uniqueId])) {
+ $this->metadata[$label]['slots'][] = array('scope' => $scope, 'index' => $index);
+ $this->metadataFlat[$uniqueId] = true;
+ }
+ }
+
/**
* @param string $key
* @param string $value
@@ -205,6 +238,7 @@ class Archiver extends \Piwik\Plugin\Archiver
}
while ($row = $query->fetch()) {
$key = $row[$keyField];
+
$value = $this->cleanCustomVarValue($row[$valueField]);
$this->dataArray->sumMetricsGoals($key, $row);
$this->dataArray->sumMetricsGoalsPivot($key, $value, $row);
diff --git a/plugins/CustomVariables/Columns/Base.php b/plugins/CustomVariables/Columns/Base.php
index 1818ca3145..4c6a4ea542 100644
--- a/plugins/CustomVariables/Columns/Base.php
+++ b/plugins/CustomVariables/Columns/Base.php
@@ -16,7 +16,7 @@ use Piwik\Plugins\CustomVariables\CustomVariables;
class Base extends VisitDimension
{
- protected function configureSegmentsFor($fieldPrefix, $segmentNameSuffix)
+ protected function configureSegmentsFor($segmentNameSuffix)
{
$numCustomVariables = CustomVariables::getNumUsableCustomVariables();
@@ -25,10 +25,7 @@ class Base extends VisitDimension
$segment->setSegment('customVariable' . $segmentNameSuffix);
$segment->setName($this->getName() . ' (' . Piwik::translate('CustomVariables_ScopeVisit') . ')');
$segment->setCategory('CustomVariables_CustomVariables');
- $segment->setSqlSegment($this->getSegmentColumns('log_visit.' . $fieldPrefix, $numCustomVariables));
- $segment->setSuggestedValuesCallback(function ($idSite, $ignore, DataTable $table) use ($segmentNameSuffix) {
- return $table->getColumnsStartingWith('customVariable' . $segmentNameSuffix);
- });
+ $segment->setUnionOfSegments($this->getSegmentColumns('customVariable' . $segmentNameSuffix, $numCustomVariables));
$this->addSegment($segment);
$segment = new Segment();
@@ -36,10 +33,7 @@ class Base extends VisitDimension
$segment->setSegment('customVariablePage' . $segmentNameSuffix);
$segment->setName($this->getName() . ' (' . Piwik::translate('CustomVariables_ScopePage') . ')');
$segment->setCategory('CustomVariables_CustomVariables');
- $segment->setSqlSegment($this->getSegmentColumns('log_link_visit_action.' . $fieldPrefix, $numCustomVariables));
- $segment->setSuggestedValuesCallback(function ($idSite, $ignore, DataTable $table) use ($segmentNameSuffix) {
- return $table->getColumnsStartingWith('customVariablePage' . $segmentNameSuffix);
- });
+ $segment->setUnionOfSegments($this->getSegmentColumns('customVariablePage' . $segmentNameSuffix, $numCustomVariables));
$this->addSegment($segment);
}
diff --git a/plugins/CustomVariables/Columns/CustomVariableName.php b/plugins/CustomVariables/Columns/CustomVariableName.php
index 85aa46436f..b42f2e8ae7 100644
--- a/plugins/CustomVariables/Columns/CustomVariableName.php
+++ b/plugins/CustomVariables/Columns/CustomVariableName.php
@@ -14,7 +14,7 @@ class CustomVariableName extends Base
{
protected function configureSegments()
{
- $this->configureSegmentsFor('custom_var_k', 'Name');
+ $this->configureSegmentsFor('Name');
}
public function getName()
diff --git a/plugins/CustomVariables/Columns/CustomVariableValue.php b/plugins/CustomVariables/Columns/CustomVariableValue.php
index 03046758cf..a565a8136c 100644
--- a/plugins/CustomVariables/Columns/CustomVariableValue.php
+++ b/plugins/CustomVariables/Columns/CustomVariableValue.php
@@ -14,7 +14,7 @@ class CustomVariableValue extends Base
{
protected function configureSegments()
{
- $this->configureSegmentsFor('custom_var_v', 'Value');
+ $this->configureSegmentsFor('Value');
}
public function getName()
diff --git a/plugins/CustomVariables/Controller.php b/plugins/CustomVariables/Controller.php
index 59a4a949de..e73e58b257 100644
--- a/plugins/CustomVariables/Controller.php
+++ b/plugins/CustomVariables/Controller.php
@@ -8,7 +8,20 @@
*/
namespace Piwik\Plugins\CustomVariables;
+use Piwik\Common;
+use Piwik\DataTable;
+use Piwik\Piwik;
+
class Controller extends \Piwik\Plugin\Controller
{
+ public function manage()
+ {
+ $idSite = Common::getRequestVar('idSite');
+
+ Piwik::checkUserHasAdminAccess($idSite);
+
+ return $this->renderTemplate('manage', array());
+ }
+
}
diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php
index b8a57ad6a6..9059482c33 100644
--- a/plugins/CustomVariables/CustomVariables.php
+++ b/plugins/CustomVariables/CustomVariables.php
@@ -22,7 +22,10 @@ class CustomVariables extends \Piwik\Plugin
{
return array(
'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata',
- 'Live.getAllVisitorDetails' => 'extendVisitorDetails'
+ 'Live.getAllVisitorDetails' => 'extendVisitorDetails',
+ 'AssetManager.getJavaScriptFiles' => 'getJsFiles',
+ 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
+ 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
);
}
@@ -144,4 +147,35 @@ class CustomVariables extends \Piwik\Plugin
}
}
+ public function getClientSideTranslationKeys(&$translationKeys)
+ {
+ $translationKeys[] = 'CustomVariables_CustomVariables';
+ $translationKeys[] = 'CustomVariables_ManageDescription';
+ $translationKeys[] = 'CustomVariables_ScopeX';
+ $translationKeys[] = 'CustomVariables_Index';
+ $translationKeys[] = 'CustomVariables_Usages';
+ $translationKeys[] = 'CustomVariables_Unused';
+ $translationKeys[] = 'CustomVariables_CreateNewSlot';
+ $translationKeys[] = 'CustomVariables_UsageDetails';
+ $translationKeys[] = 'CustomVariables_CurrentAvailableCustomVariables';
+ $translationKeys[] = 'CustomVariables_ToCreateCustomVarExecute';
+ $translationKeys[] = 'CustomVariables_CreatingCustomVariableTakesTime';
+ $translationKeys[] = 'CustomVariables_SlotsReportIsGeneratedOverTime';
+ $translationKeys[] = 'General_Loading';
+ $translationKeys[] = 'General_TrackingScopeVisit';
+ $translationKeys[] = 'General_TrackingScopePage';
+ }
+
+ public function getStylesheetFiles(&$stylesheets)
+ {
+ $stylesheets[] = "plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.less";
+ }
+
+ public function getJsFiles(&$jsFiles)
+ {
+ $jsFiles[] = "plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js";
+ $jsFiles[] = "plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.controller.js";
+ $jsFiles[] = "plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.js";
+ }
+
}
diff --git a/plugins/CustomVariables/Menu.php b/plugins/CustomVariables/Menu.php
new file mode 100644
index 0000000000..b97aa1bb01
--- /dev/null
+++ b/plugins/CustomVariables/Menu.php
@@ -0,0 +1,33 @@
+<?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\CustomVariables;
+
+use Piwik\Common;
+use Piwik\Menu\MenuUser;
+use Piwik\Piwik;
+use Piwik\Plugins\UsersManager\UserPreferences;
+
+/**
+ * This class allows you to add, remove or rename menu items.
+ * To configure a menu (such as Admin Menu, Reporting Menu, User Menu...) simply call the corresponding methods as
+ * described in the API-Reference http://developer.piwik.org/api-reference/Piwik/Menu/MenuAbstract
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+ public function configureUserMenu(MenuUser $menu)
+ {
+ $userPreferences = new UserPreferences();
+ $default = $userPreferences->getDefaultWebsiteId();
+ $idSite = Common::getRequestVar('idSite', $default, 'int');
+
+ if (Piwik::isUserHasAdminAccess($idSite)) {
+ $menu->addManageItem('Custom Variables', $this->urlForAction('manage'), $orderId = 15);
+ }
+ }
+}
diff --git a/plugins/CustomVariables/Model.php b/plugins/CustomVariables/Model.php
index 9d98a352fa..235809e1da 100644
--- a/plugins/CustomVariables/Model.php
+++ b/plugins/CustomVariables/Model.php
@@ -15,12 +15,14 @@ use Piwik\Log;
class Model
{
- const SCOPE_PAGE = 'log_link_visit_action';
- const SCOPE_VISIT = 'log_visit';
- const SCOPE_CONVERSION = 'log_conversion';
const DEFAULT_CUSTOM_VAR_COUNT = 5;
+ const SCOPE_PAGE = 'page';
+ const SCOPE_VISIT = 'visit';
+ const SCOPE_CONVERSION = 'conversion';
+
private $scope = null;
+ private $table = null;
public function __construct($scope)
{
@@ -29,21 +31,27 @@ class Model
}
$this->scope = $scope;
+ $this->table = Common::prefixTable($this->getTableNameFromScope($scope));
}
- public function getScopeName()
+ private function getTableNameFromScope($scope)
{
// actually we should have a class for each scope but don't want to overengineer it for now
- switch ($this->scope) {
+ switch ($scope) {
case self::SCOPE_PAGE:
- return 'Page';
+ return 'log_link_visit_action';
case self::SCOPE_VISIT:
- return 'Visit';
+ return 'log_visit';
case self::SCOPE_CONVERSION:
- return 'Conversion';
+ return 'log_conversion';
}
}
+ public function getScopeName()
+ {
+ return ucfirst($this->scope);
+ }
+
/**
* @see getHighestCustomVarIndex()
* @return int
@@ -96,8 +104,7 @@ class Model
private function getCustomVarColumnNames()
{
- $dbTable = $this->getDbTableName();
- $columns = Db::getColumnNamesFromTable($dbTable);
+ $columns = Db::getColumnNamesFromTable($this->table);
$customVarColumns = array_filter($columns, function ($column) {
return false !== strpos($column, 'custom_var_');
@@ -108,14 +115,13 @@ class Model
public function removeCustomVariable()
{
- $dbTable = $this->getDbTableName();
- $index = $this->getHighestCustomVarIndex();
+ $index = $this->getHighestCustomVarIndex();
if ($index < 1) {
return null;
}
- Db::exec(sprintf('ALTER TABLE %s ', $dbTable)
+ Db::exec(sprintf('ALTER TABLE %s ', $this->table)
. sprintf('DROP COLUMN custom_var_k%d,', $index)
. sprintf('DROP COLUMN custom_var_v%d;', $index));
@@ -124,22 +130,16 @@ class Model
public function addCustomVariable()
{
- $dbTable = $this->getDbTableName();
- $index = $this->getHighestCustomVarIndex() + 1;
- $maxLen = CustomVariables::getMaxLengthCustomVariables();
+ $index = $this->getHighestCustomVarIndex() + 1;
+ $maxLen = CustomVariables::getMaxLengthCustomVariables();
- Db::exec(sprintf('ALTER TABLE %s ', $dbTable)
+ Db::exec(sprintf('ALTER TABLE %s ', $this->table)
. sprintf('ADD COLUMN custom_var_k%d VARCHAR(%d) DEFAULT NULL,', $index, $maxLen)
. sprintf('ADD COLUMN custom_var_v%d VARCHAR(%d) DEFAULT NULL;', $index, $maxLen));
return $index;
}
- private function getDbTableName()
- {
- return Common::prefixTable($this->scope);
- }
-
public static function getCustomVariableIndexFromFieldName($fieldName)
{
$onlyNumber = str_replace(array('custom_var_k', 'custom_var_v'), '', $fieldName);
diff --git a/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php b/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php
index 44e6d59350..2b068ba03e 100644
--- a/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php
+++ b/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php
@@ -9,6 +9,8 @@
namespace Piwik\Plugins\CustomVariables\Tracker;
use Piwik\Common;
+use Piwik\Plugins\CustomVariables\Model;
+use Piwik\Tracker\Action;
use Piwik\Tracker\Request;
use Piwik\Tracker\RequestProcessor;
use Piwik\Tracker\Visit\VisitProperties;
@@ -36,7 +38,7 @@ class CustomVariablesRequestProcessor extends RequestProcessor
public function processRequestParams(VisitProperties $visitProperties, Request $request)
{
// TODO: re-add optimization where if custom variables exist in request, don't bother selecting them in Visitor
- $visitorCustomVariables = $request->getCustomVariables($scope = 'visit');
+ $visitorCustomVariables = $request->getCustomVariables($scope = Model::SCOPE_VISIT);
if (!empty($visitorCustomVariables)) {
Common::printDebug("Visit level Custom Variables: ");
Common::printDebug($visitorCustomVariables);
@@ -62,4 +64,25 @@ class CustomVariablesRequestProcessor extends RequestProcessor
$valuesToUpdate = array_merge($valuesToUpdate, $visitCustomVariables);
}
}
+
+ public function afterRequestProcessed(VisitProperties $visitProperties, Request $request)
+ {
+ $action = $request->getMetadata('Actions', 'action');
+
+ if (empty($action) || !($action instanceof Action)) {
+ return;
+ }
+
+ $customVariables = $action->getCustomVariables();
+
+ if (!empty($customVariables)) {
+ Common::printDebug("Page level Custom Variables: ");
+ Common::printDebug($customVariables);
+
+ foreach ($customVariables as $field => $value) {
+ $action->setCustomField($field, $value);
+ }
+ }
+
+ }
}
diff --git a/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.controller.js b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.controller.js
new file mode 100644
index 0000000000..f8098eb114
--- /dev/null
+++ b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.controller.js
@@ -0,0 +1,22 @@
+/*!
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+(function () {
+ angular.module('piwikApp').controller('ManageCustomVarsController', ManageCustomVarsController);
+
+ ManageCustomVarsController.$inject = ['manageCustomVarsModel', 'piwik', '$filter'];
+
+ function ManageCustomVarsController(manageCustomVarsModel, piwik, $filter) {
+ manageCustomVarsModel.fetchUsages();
+
+ this.model = manageCustomVarsModel;
+ this.siteName = piwik.siteName;
+ this.scopes = [
+ {value: 'visit', name: _pk_translate('General_TrackingScopeVisit')},
+ {value: 'page', name: _pk_translate('General_TrackingScopePage')}
+ ];
+ }
+})(); \ No newline at end of file
diff --git a/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.html b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.html
new file mode 100644
index 0000000000..6ab9ea6ba6
--- /dev/null
+++ b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.html
@@ -0,0 +1,54 @@
+<div class="manageCustomVars">
+ <h2 piwik-enriched-headline help-url="http://piwik.org/docs/custom-variables/">{{ 'CustomVariables_CustomVariables'|translate }}</h2>
+
+ <p>
+ <span ng-bind-html="'CustomVariables_ManageDescription'|translate:manageCustomVars.siteName"></span>
+ </p>
+
+ <div class="alert alert-info" ng-show="!manageCustomVars.model.isLoading && manageCustomVars.model.hasCustomVariablesInGeneral && !manageCustomVars.model.hasAtLeastOneUsage">
+ {{ 'CustomVariables_SlotsReportIsGeneratedOverTime'|translate }}
+ </div>
+
+ <div ng-repeat="scope in manageCustomVars.scopes">
+ <h2 class="secondary">{{ 'CustomVariables_ScopeX'|translate:(scope.name) }}</h2>
+ <table class="dataTable entityTable">
+ <thead>
+ <tr>
+ <th>{{'CustomVariables_Index'|translate }}</th>
+ <th>{{'CustomVariables_Usages'|translate }}</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td colspan="3" ng-show="manageCustomVars.model.isLoading">{{ 'General_Loading'|translate }}</td>
+ </tr>
+ <tr ng-repeat="customVariables in manageCustomVars.model.customVariables|filter:{scope: scope.value}">
+ <td class="index">{{ customVariables.index }}</td>
+ <td>
+ <span ng-show="(customVariables.usages|length) === 0"
+ class="unused">{{'CustomVariables_Unused'|translate }}</span>
+ <span ng-show="customVariables.usages|length" ng-repeat="cvar in customVariables.usages|orderBy:'-nb_actions'">
+ <span title="{{ 'CustomVariables_UsageDetails'|translate:(cvar.nb_visits ? cvar.nb_visits : 0):(cvar.nb_actions ? cvar.nb_actions : 0) }}">{{ cvar.name }}</span><span ng-show="!$last">, </span>
+ </span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+
+ <h2 class="secondary" ng-show="!manageCustomVars.model.isLoading">{{ 'CustomVariables_CreateNewSlot'|translate }}</h2>
+
+ <p ng-show="!manageCustomVars.model.isLoading">
+ {{ 'CustomVariables_CreatingCustomVariableTakesTime'|translate }}
+ <br /><br />
+ <span ng-bind-html="'CustomVariables_CurrentAvailableCustomVariables'|translate:('<strong>'+manageCustomVars.model.numSlotsAvailable+'</strong>')"></span>
+ <br />
+ <br />
+ {{ 'CustomVariables_ToCreateCustomVarExecute'|translate }}
+ <br />
+ <br />
+ <code>./console customvariables:set-max-custom-variables {{ manageCustomVars.model.numSlotsAvailable + 1 }}</code>
+ </p>
+
+
+</div> \ No newline at end of file
diff --git a/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.js b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.js
new file mode 100644
index 0000000000..1623d50b27
--- /dev/null
+++ b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.js
@@ -0,0 +1,26 @@
+/*!
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+/**
+ * Usage:
+ * <div piwik-manage-custom-vars>
+ */
+(function () {
+ angular.module('piwikApp').directive('piwikManageCustomVars', piwikManageCustomVars);
+
+ piwikManageCustomVars.$inject = ['piwik'];
+
+ function piwikManageCustomVars(piwik){
+ return {
+ restrict: 'A',
+ scope: {},
+ templateUrl: 'plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.html?cb=' + piwik.cacheBuster,
+ controller: 'ManageCustomVarsController',
+ controllerAs: 'manageCustomVars'
+ };
+ }
+})(); \ No newline at end of file
diff --git a/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.less b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.less
new file mode 100644
index 0000000000..b666abebca
--- /dev/null
+++ b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.less
@@ -0,0 +1,18 @@
+.manageCustomVars {
+ .unused {
+ color: @color-silver;
+ }
+
+ table, p {
+ width: 900px;
+ }
+
+ .alert-info {
+ margin-top: 15px;
+ }
+
+ .scope, .index {
+ width: 90px;
+ max-width: 90px;
+ }
+} \ No newline at end of file
diff --git a/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js
new file mode 100644
index 0000000000..ceb6442a8f
--- /dev/null
+++ b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js
@@ -0,0 +1,59 @@
+/*!
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+(function () {
+ angular.module('piwikApp').factory('manageCustomVarsModel', manageCustomVarsModel);
+
+ manageCustomVarsModel.$inject = ['piwikApi'];
+
+ function manageCustomVarsModel(piwikApi) {
+
+ var model = {
+ customVariables : [],
+ extractions : [],
+ isLoading: false,
+ fetchUsages: fetchUsages,
+ hasCustomVariablesInGeneral: false,
+ hasAtLeastOneUsage: false,
+ numSlotsAvailable: 5,
+ };
+
+ return model;
+
+ function fetchCustomVariables() {
+ return piwikApi.fetch({method: 'CustomVariables.getCustomVariables', period: 'year', date: 'today', filter_limit: 1})
+ .then(function (customVariables) {
+ model.hasCustomVariablesInGeneral = (customVariables && customVariables.length > 0);
+ });
+ }
+
+ function fetchUsages() {
+
+ model.isLoading = true;
+
+ fetchCustomVariables().then(function () {
+ return piwikApi.fetch({method: 'CustomVariables.getUsagesOfSlots'});
+
+ }).then(function (customVariables) {
+ model.customVariables = customVariables;
+
+ angular.forEach(customVariables, function (customVar) {
+ if (customVar.index > model.numSlotsAvailable) {
+ model.numSlotsAvailable = customVar.index;
+ }
+
+ if (customVar.usages && customVar.usages.length > 0) {
+ model.hasAtLeastOneUsage = true;
+ }
+ });
+
+ })['finally'](function () { // .finally() is not IE8 compatible see https://github.com/angular/angular.js/commit/f078762d48d0d5d9796dcdf2cb0241198677582c
+ model.isLoading = false;
+ });
+ }
+
+ }
+})(); \ No newline at end of file
diff --git a/plugins/CustomVariables/config/config.php b/plugins/CustomVariables/config/config.php
index 82a0058e02..cba8dd0f59 100644
--- a/plugins/CustomVariables/config/config.php
+++ b/plugins/CustomVariables/config/config.php
@@ -1,9 +1,6 @@
<?php
return array(
-
- 'tracker.request.processors' => DI\add(array(
- DI\get('Piwik\Plugins\CustomVariables\Tracker\CustomVariablesRequestProcessor'),
- )),
-
+ // in tests we do not use 'today' to make tests results deterministic
+ 'CustomVariables.today' => 'today',
);
diff --git a/plugins/CustomVariables/config/test.php b/plugins/CustomVariables/config/test.php
new file mode 100644
index 0000000000..d1ef28244a
--- /dev/null
+++ b/plugins/CustomVariables/config/test.php
@@ -0,0 +1,4 @@
+<?php
+return array(
+ 'CustomVariables.today' => '2015-01-01'
+); \ No newline at end of file
diff --git a/plugins/CustomVariables/lang/cs.json b/plugins/CustomVariables/lang/cs.json
index 5a75dd2cd1..98a5db6ea6 100644
--- a/plugins/CustomVariables/lang/cs.json
+++ b/plugins/CustomVariables/lang/cs.json
@@ -6,6 +6,17 @@
"CustomVariablesReportDocumentation": "Toto hlášení obsahuje informace o vašich vlastních proměnných. Klikněte na proměnnou pro zobrazení distribuce hodnot. %s Pro více informací si přečtěte %sdokumentaci o vlastních proměnných na piwik.org%s",
"PluginDescription": "Vlastní proměnné jsou páry (jméno, hodnota), které můžete nastavit návštěvníkovi, nebo libovolné akci, pomocí javascriptového API. Piwik potom ohlásí, kolik návštěv, stránek, konverzí bylo pro každé z těchto jmen a hodnot. Prohlédněte si detailně tyto proměnné pro každého uživatele a akci v záznamu návštěvníků.<br \/>Vyžadováno, pokud chcete použít <a href=\"http:\/\/piwik.org\/docs\/ecommerce-analytics\/\">analýzu E-obchodu<\/a>!",
"ScopePage": "rozsah stránky",
- "ScopeVisit": "rozsah návštěvy"
+ "ScopeVisit": "rozsah návštěvy",
+ "ManageDescription": "Tento přehled zobrazuje všechny sloty vlastních proměnných a jejich využití pro stránku '%s'. Jména v každém ze slotů jsou seřazena dle jejich celkového využití.",
+ "ScopeX": "Rozsah %s",
+ "Index": "Index",
+ "Usages": "Využití",
+ "Unused": "Nevyužito",
+ "CreateNewSlot": "Navýšit počet dostupných slotů vlastních proměnných",
+ "UsageDetails": "%s návštěv a %s akcí od vytvoření této webové stránky.",
+ "CreatingCustomVariableTakesTime": "Vytvoření nové vlastní proměnné hodnoty může trvat déle v závislosti na velikosti vaší databáze. Proto je toto možné provést pouze pomocí příkazu spuštěnému v příkazové řádce.",
+ "CurrentAvailableCustomVariables": "Aktuálně můžete použít až %s vlastních proměnných na stránku.",
+ "ToCreateCustomVarExecute": "Pro vytvoření nového slotu pro vlastní proměnnou spusťte následující příkaz ve své instalaci Piwik:",
+ "SlotsReportIsGeneratedOverTime": "Data pro tento report budou dostupná později. Než budou data vidět, může to den nebo dva trvat a poté několik týdnů než bude report vypovídající."
}
} \ No newline at end of file
diff --git a/plugins/CustomVariables/lang/de.json b/plugins/CustomVariables/lang/de.json
index 0dd793331a..c60483ec21 100644
--- a/plugins/CustomVariables/lang/de.json
+++ b/plugins/CustomVariables/lang/de.json
@@ -6,6 +6,17 @@
"CustomVariablesReportDocumentation": "Dieser Bericht enthält Informationen über Ihre benutzerdefinierten Variablen. Klicken Sie auf einen Variablennamen, um die Verteilung der Werte zu sehen. %s Für mehr Informationen über benutzerdefinierte Variablen, lesen Sie die %sDokumentation auf piwik.org%s",
"PluginDescription": "Benutzerdefinierte Variablen sind (Namen-, Wert-) Paare, welche Sie mit Hilfe der Javascript API auf Besucher oder deren Aktionen festlegen können. Piwik wird Sie dann über die Menge an Besuchen, Seiten, Konversionen für jede der benutzerdefinierten Variablen und Werte informieren. Die detaillierten benutzerdefinierten Variablen für jeden Benutzer und Aktionen im Besucher-Log einsehbar.<br \/>Benötigt um das Feature <a href=\"http:\/\/piwik.org\/docs\/ecommerce-analytics\/\">Ecommerce Analyse<\/a>nutzen zu können.",
"ScopePage": "Anwendungsbereich Seite",
- "ScopeVisit": "Anwendungsbereich Besuch"
+ "ScopeVisit": "Anwendungsbereich Besuch",
+ "ManageDescription": "Diese Übersicht zeigt alle benutzerdefinierten Variablen und deren Gebrauch für Webseite %s. Die Namen auf jeder Position sind danach sortiert, wie oft sie insgesamt benützt wurden.",
+ "ScopeX": "Anwendungsbereich %s",
+ "Index": "Index",
+ "Usages": "Verwendungen",
+ "Unused": "Unbenutzt",
+ "CreateNewSlot": "Die Anzahl verfügbarer benutzerdefinierter Variablen erhöhen",
+ "UsageDetails": "%s Besuche und %s Aktionen seit der Erstellung dieser Webseite.",
+ "CreatingCustomVariableTakesTime": "Neue benutzerdefinierte Variablen zu erstellen kann viel Zeit beanspruchen, abhängig von der Grösse Ihrer Datenbank. Deshalb ist dieser Vorgang nur über Kommandozeilen verfügbar.",
+ "CurrentAvailableCustomVariables": "Aktuell können Sie bis zu %s benutzerdefinierte Variablen pro Seite einsetzen.",
+ "ToCreateCustomVarExecute": "Um eine neue benutzerdefinierte Variable zu erstellen, führen Sie in Ihrer Piwik Installation folgende Befehle aus:",
+ "SlotsReportIsGeneratedOverTime": "Daten für diesen Bericht werden periodisch veröffentlicht. Es mag ein oder zwei Tage dauern, bis Daten sichtbar sind und einige Wochen bis der Bericht vollständig aussagekräftig ist."
}
} \ No newline at end of file
diff --git a/plugins/CustomVariables/lang/el.json b/plugins/CustomVariables/lang/el.json
index baf9456547..25b790a4f9 100644
--- a/plugins/CustomVariables/lang/el.json
+++ b/plugins/CustomVariables/lang/el.json
@@ -6,6 +6,17 @@
"CustomVariablesReportDocumentation": "Αυτή η αναφορά περιέχει πληροφορίες για τις Προσαρμοσμένες Μεταβλητές. Πατήστε σε ένα όνομα μεταβλητής για να δείτε την κατανομή των τιμών. %s Για περισσότερες πληροφορίες για τις Προσαρμοσμένες Μεταβλητές γενικά, διαβάστε την %sτεκμηρίωση Προσαρμοσμένων Μεταβλητών στο piwik.org%s.",
"PluginDescription": "Οι Προσαρμοσμένες Μεταβλητές (όνομα, τιμή) είναι ζεύγη που δίνετε με χρήση του Javascript API σε επισκέπτες ή οποιαδήποτε ενέργειά τους. Το Piwik τότε θα αναφέρει τις επισκέψεις, σελίδες, μετατροπές για κάθε μία από τις προσαρμοσμένες αυτές μεταβλητές. Δείτε τις λεπτομερείς Προσαρμοσμένες Μεταβλητές για κάθε χρήστη και ενέργεια στο Ημερολόγιο Επισκεπτών.<br \/>Απαιτείται για τη χρήση του χαρακτηριστικού <a href=\"http:\/\/piwik.org\/docs\/ecommerce-analytics\/\">Αναλυτικά Ηλ. Εμπορίου<\/a>!",
"ScopePage": "σελίδα σκοπού",
- "ScopeVisit": "επίσκεψη σκοπού"
+ "ScopeVisit": "επίσκεψη σκοπού",
+ "ManageDescription": "Η σύνοψη αυτή δείχνει όλες τις σχισμές προσαρμοσμένων μεταβλητών και τις χρήσεις τους για τον ιστοτόπο '%s'. Τα ονόματα σε κάθε σχισμή ταξινομούνται με βάση το πόσο συχνά χρησιμοποιούνται στο σύνολο.",
+ "ScopeX": "Εμβέλεια %s",
+ "Index": "Ευρετήριο",
+ "Usages": "Χρήσεις",
+ "Unused": "Δεν χρησιμοποιούνται",
+ "CreateNewSlot": "Αυξήστε τον αριθμό των σχισμών Προσαρμοσμένων Μεταβλητών",
+ "UsageDetails": "%s επισκέψεις και %s ενέργειες από την δημιουργία του ιστοτόπου.",
+ "CreatingCustomVariableTakesTime": "Η δημιουργία σχισμής προσαρμοσμένης μεταβλητής μπορεί να διαρκέσει αρκετή ώρα ανάλογα με το μέγεθος της βάσης. Οπότε, αυτό είναι πρέπει να γίνεται από εντολή που χρειάζεται να εκτελεστεί από την γραμμή εντολών.",
+ "CurrentAvailableCustomVariables": "Αυτή τη στιγμή μπορείτε να χρησιμοποιήσετε %s Προσαρμοσμένες Μεταβλητές ανά ιστοτόπο.",
+ "ToCreateCustomVarExecute": "Για να δημιουργήσετε μια σχισμή προσαρμοσμένης μεταβλητής πρέπει να εκτελέσετε την παρακάτω εντολή για την εγκατάσταση του PIwik σας:",
+ "SlotsReportIsGeneratedOverTime": "Τα δεδομένα για αυτή την αναφορά θα συμπληρώνονται με το πέρασμα του χρόνου. Μπορεί να χρειαστούν μία ή δύο μέρες για να δείτε δεδομένα και μερικές εβδομάδες μέχρι η αναφορά να είναι ακριβής."
}
} \ No newline at end of file
diff --git a/plugins/CustomVariables/lang/en.json b/plugins/CustomVariables/lang/en.json
index 7d99f97bf2..45052df4d9 100644
--- a/plugins/CustomVariables/lang/en.json
+++ b/plugins/CustomVariables/lang/en.json
@@ -6,6 +6,17 @@
"CustomVariablesReportDocumentation": "This report contains information about your Custom Variables. Click on a variable name to see the distribution of the values. %s For more information about Custom Variables in general, read the %sCustom Variables documentation on piwik.org%s",
"PluginDescription": "Custom Variables are (name, value) pairs that you can assign using the Javascript API to visitors or any of their action. Piwik will then report how many visits, pages, conversions for each of these custom names and values. View the detailed Custom Variables for each user and action in the Visitor Log.<br />Required to use <a href=\"http://piwik.org/docs/ecommerce-analytics/\">Ecommerce Analytics</a> feature!",
"ScopePage": "scope page",
- "ScopeVisit": "scope visit"
+ "ScopeVisit": "scope visit",
+ "ManageDescription": "This overview shows all custom variable slots and their usages for website '%s'. The names within each slot are ordered by how often they were used in total.",
+ "ScopeX": "Scope %s",
+ "Index": "Index",
+ "Usages": "Usages",
+ "Unused": "Unused",
+ "CreateNewSlot": "Increase the number of available Custom Variables slots",
+ "UsageDetails": "%s visits and %s actions since creation of this website.",
+ "CreatingCustomVariableTakesTime": "Creating a new custom variable slot can take a long time depending on the size of your database. Therefore it is only possible to do this via a command which needs to be executed on the command line.",
+ "CurrentAvailableCustomVariables": "Currently you can use up to %s Custom Variables per site.",
+ "ToCreateCustomVarExecute": "To create a new custom variable slot execute the following command within your Piwik installation: ",
+ "SlotsReportIsGeneratedOverTime": "Data for this report will be populated over time. It may take a day or two to see any data and a few weeks until the report is fully accurate."
}
} \ No newline at end of file
diff --git a/plugins/CustomVariables/lang/it.json b/plugins/CustomVariables/lang/it.json
index 3162fc9027..ec7b07a778 100644
--- a/plugins/CustomVariables/lang/it.json
+++ b/plugins/CustomVariables/lang/it.json
@@ -6,6 +6,17 @@
"CustomVariablesReportDocumentation": "Questo report contiene le informazioni sulle variabili personalizzate. Clicca su un nome di variabile per visualizzarne la distribuzione dei valori. %s Per ulteriori informazioni sulle variabili personalizzate in generale, leggere la %sDocumentazione Variabili Personalizzatesu piwik.org %s",
"PluginDescription": "Le variabili personalizzate sono coppie (nome, valore) che puoi assegnare ai visitatori o a una qualunque loro azione tramite API Javascript. Poi Piwik riporterà le visite, le pagine e le conversioni per questi nomi e valori. Guarda nel dettaglio le Variabili Personalizzate per ciascun utente nel Log Visitatori.<br>Necessario per utilizzare la funzione <a href=\"http:\/\/piwik.org\/docs\/ecommerce-analytics\/\">Statistiche Ecommerce<\/a>",
"ScopePage": "ambito pagina",
- "ScopeVisit": "ambito visita"
+ "ScopeVisit": "ambito visita",
+ "ManageDescription": "Questa panoramica mostra tutti gli slot di variabili personali e il loro utilizzo nel sito '%s'. I nomi in ciascuno slot vengono ordinati a seconda di quanto sono stati utilizzati in totale.",
+ "ScopeX": "Ambito %s",
+ "Index": "Indice",
+ "Usages": "Usi",
+ "Unused": "Inutilizzate",
+ "CreateNewSlot": "Aumenta il numero degli slot di variabili personali disponibili",
+ "UsageDetails": "%s visite e %s azioni dalla creazione di questo sito web.",
+ "CreatingCustomVariableTakesTime": "La creazione di un nuovo slot di variabili personali può richiedere un tempo lungo che dipende dalla dimensione del tuo database. Pertanto è possibile fare ciò solo tramite un comando che deve essere eseguito da riga di comando.",
+ "CurrentAvailableCustomVariables": "Attualmente puoi utilizzare fino a %s variabili personali per sito.",
+ "ToCreateCustomVarExecute": "Per creare un nuovo slot di variabili personali esegui il comando seguente nella tua installazione di Piwik.",
+ "SlotsReportIsGeneratedOverTime": "I dati per questo report saranno popolati nel tempo. Ciò può richiedere un giorno o due per vedere dei dati, e qualche settimana perché il report sia totalmente accurato."
}
} \ No newline at end of file
diff --git a/plugins/CustomVariables/lang/pt-br.json b/plugins/CustomVariables/lang/pt-br.json
index 172cf7eabb..9f46739d4a 100644
--- a/plugins/CustomVariables/lang/pt-br.json
+++ b/plugins/CustomVariables/lang/pt-br.json
@@ -6,6 +6,17 @@
"CustomVariablesReportDocumentation": "Este relatório contém informações sobre as suas variáveis ​​personalizadas. Clique em um nome de variável para ver a distribuição dos valores. %s para mais informações sobre variáveis ​​personalizadas em geral, leia a documentação %sCustom Variáveis ​​em piwik.org%s",
"PluginDescription": "Variáveis Personalizadas são pares (nome, valor) que você pode atribuir utilizando a API Javascript para visitantes ou qualquer ações deles. Então, Piwik reporta o número de visitas, páginas e conversões para cada um desses nomes e valores personalizados. Veja as Variáveis Personalizadas detalhadas para cada usuário e ação no Registro de Visitantes.<br \/> É necessário utilizar a função <a href=\"http:\/\/piwik.org\/docs\/ecommerce-analytics\/\">Ecommerce Analytics<\/a>!",
"ScopePage": "página escopo",
- "ScopeVisit": "visita escopo"
+ "ScopeVisit": "visita escopo",
+ "ManageDescription": "Esta visão geral mostra todos os compartimentos personalizados de variáveis ​ e seus usos para o website '%s'. Os nomes dentro de cada compartimento são ordenados por quantas vezes foram utilizados no total.",
+ "ScopeX": "Escopo %s",
+ "Index": "Índice",
+ "Usages": "Utilizações",
+ "Unused": "Não utilizado",
+ "CreateNewSlot": "Aumentar o número de compartimentos de Variáveis ​​Personalizadas disponíveis",
+ "UsageDetails": "%s visitas e %s ações desde a criação deste website.",
+ "CreatingCustomVariableTakesTime": "Criar um novo compartimento de variável personalizada pode levar um longo tempo, dependendo do tamanho do seu banco de dados. Por isso, só é possível fazer isso através de um comando que deve ser executado na linha de comando.",
+ "CurrentAvailableCustomVariables": "Atualmente você pode usar até %s Variáveis Personalizadas por site.",
+ "ToCreateCustomVarExecute": "Para criar um novo compartimento de variável personalizada execute o seguinte comando dentro da sua instalação Piwik:",
+ "SlotsReportIsGeneratedOverTime": "Os dados para este relatório serão preenchidos ao longo do tempo. Pode demorar um dia ou dois para ver todos os dados e algumas semanas até que o relatório seja totalmente preciso."
}
} \ No newline at end of file
diff --git a/plugins/CustomVariables/lang/sk.json b/plugins/CustomVariables/lang/sk.json
index f936be8fdd..84445a2338 100644
--- a/plugins/CustomVariables/lang/sk.json
+++ b/plugins/CustomVariables/lang/sk.json
@@ -1,7 +1,10 @@
{
"CustomVariables": {
- "ColumnCustomVariableName": "Názov vlastnej premmennej",
+ "ColumnCustomVariableName": "Názov vlastnej premennej",
"ColumnCustomVariableValue": "Hodnota vlastnej premennej",
- "CustomVariables": "Vlastné premenné"
+ "CustomVariables": "Vlastné premenné",
+ "ScopeX": "Rozsah %s",
+ "Index": "Index",
+ "Unused": "Nepoužité"
}
} \ No newline at end of file
diff --git a/plugins/CustomVariables/templates/manage.twig b/plugins/CustomVariables/templates/manage.twig
new file mode 100644
index 0000000000..dc170ff2c9
--- /dev/null
+++ b/plugins/CustomVariables/templates/manage.twig
@@ -0,0 +1,11 @@
+{% extends 'user.twig' %}
+
+{% block topcontrols %}
+ <div class="top_bar_sites_selector piwikTopControl">
+ <div piwik-siteselector show-selected-site="true" class="sites_autocomplete"></div>
+ </div>
+{% endblock %}
+
+{% block content %}
+ <div piwik-manage-custom-vars>
+{% endblock %} \ No newline at end of file
diff --git a/plugins/CustomVariables/tests/Integration/ModelTest.php b/plugins/CustomVariables/tests/Integration/ModelTest.php
index 128e5b09ef..905a5f6a1d 100644
--- a/plugins/CustomVariables/tests/Integration/ModelTest.php
+++ b/plugins/CustomVariables/tests/Integration/ModelTest.php
@@ -19,7 +19,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
*/
class ModelTest extends IntegrationTestCase
{
- private static $cvarScopes = array('log_link_visit_action', 'log_visit', 'log_conversion');
+ private static $cvarScopes = array('page', 'visit', 'conversion');
public function setUp()
{
diff --git a/plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml b/plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml
index e504b8e8c7..766be4e97d 100644
--- a/plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml
+++ b/plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml
@@ -17,6 +17,12 @@
</goals>
<nb_conversions>1</nb_conversions>
<revenue>0</revenue>
+ <slots>
+ <row>
+ <scope>visit</scope>
+ <index>1</index>
+ </row>
+ </slots>
<segment>customVariableName==Name_VISIT_1</segment>
<subtable>
<row>
@@ -56,6 +62,12 @@
</goals>
<nb_conversions>1</nb_conversions>
<revenue>0</revenue>
+ <slots>
+ <row>
+ <scope>visit</scope>
+ <index>2</index>
+ </row>
+ </slots>
<segment>customVariableName==Name_VISIT_2</segment>
<subtable>
<row>
@@ -95,6 +107,12 @@
</goals>
<nb_conversions>1</nb_conversions>
<revenue>0</revenue>
+ <slots>
+ <row>
+ <scope>visit</scope>
+ <index>3</index>
+ </row>
+ </slots>
<segment>customVariableName==Name_VISIT_3</segment>
<subtable>
<row>
@@ -134,6 +152,12 @@
</goals>
<nb_conversions>1</nb_conversions>
<revenue>0</revenue>
+ <slots>
+ <row>
+ <scope>visit</scope>
+ <index>4</index>
+ </row>
+ </slots>
<segment>customVariableName==Name_VISIT_4</segment>
<subtable>
<row>
@@ -173,6 +197,12 @@
</goals>
<nb_conversions>1</nb_conversions>
<revenue>0</revenue>
+ <slots>
+ <row>
+ <scope>visit</scope>
+ <index>5</index>
+ </row>
+ </slots>
<segment>customVariableName==Name_VISIT_5</segment>
<subtable>
<row>
@@ -212,6 +242,12 @@
</goals>
<nb_conversions>1</nb_conversions>
<revenue>0</revenue>
+ <slots>
+ <row>
+ <scope>visit</scope>
+ <index>6</index>
+ </row>
+ </slots>
<segment>customVariableName==Name_VISIT_6</segment>
<subtable>
<row>
@@ -251,6 +287,12 @@
</goals>
<nb_conversions>1</nb_conversions>
<revenue>0</revenue>
+ <slots>
+ <row>
+ <scope>visit</scope>
+ <index>7</index>
+ </row>
+ </slots>
<segment>customVariableName==Name_VISIT_7</segment>
<subtable>
<row>
@@ -290,6 +332,12 @@
</goals>
<nb_conversions>1</nb_conversions>
<revenue>0</revenue>
+ <slots>
+ <row>
+ <scope>visit</scope>
+ <index>8</index>
+ </row>
+ </slots>
<segment>customVariableName==Name_VISIT_8</segment>
<subtable>
<row>
@@ -312,100 +360,148 @@
</row>
</subtable>
</row>
- <row>
- <label>Name_PAGE_1</label>
- <nb_actions>1</nb_actions>
- <segment>customVariableName==Name_PAGE_1</segment>
- <subtable>
- <row>
- <label>Val_PAGE1</label>
- <nb_visits>1</nb_visits>
- <nb_actions>1</nb_actions>
- </row>
- </subtable>
- </row>
- <row>
- <label>Name_PAGE_2</label>
- <nb_actions>1</nb_actions>
- <segment>customVariableName==Name_PAGE_2</segment>
- <subtable>
- <row>
- <label>Val_PAGE2</label>
- <nb_visits>1</nb_visits>
- <nb_actions>1</nb_actions>
- </row>
- </subtable>
- </row>
- <row>
- <label>Name_PAGE_3</label>
- <nb_actions>1</nb_actions>
- <segment>customVariableName==Name_PAGE_3</segment>
- <subtable>
- <row>
- <label>Val_PAGE3</label>
- <nb_visits>1</nb_visits>
- <nb_actions>1</nb_actions>
- </row>
- </subtable>
- </row>
- <row>
- <label>Name_PAGE_4</label>
- <nb_actions>1</nb_actions>
- <segment>customVariableName==Name_PAGE_4</segment>
- <subtable>
- <row>
- <label>Val_PAGE4</label>
- <nb_visits>1</nb_visits>
- <nb_actions>1</nb_actions>
- </row>
- </subtable>
- </row>
- <row>
- <label>Name_PAGE_5</label>
- <nb_actions>1</nb_actions>
- <segment>customVariableName==Name_PAGE_5</segment>
- <subtable>
- <row>
- <label>Val_PAGE5</label>
- <nb_visits>1</nb_visits>
- <nb_actions>1</nb_actions>
- </row>
- </subtable>
- </row>
- <row>
- <label>Name_PAGE_6</label>
- <nb_actions>1</nb_actions>
- <segment>customVariableName==Name_PAGE_6</segment>
- <subtable>
- <row>
- <label>Val_PAGE6</label>
- <nb_visits>1</nb_visits>
- <nb_actions>1</nb_actions>
- </row>
- </subtable>
- </row>
- <row>
- <label>Name_PAGE_7</label>
- <nb_actions>1</nb_actions>
- <segment>customVariableName==Name_PAGE_7</segment>
- <subtable>
- <row>
- <label>Val_PAGE7</label>
- <nb_visits>1</nb_visits>
- <nb_actions>1</nb_actions>
- </row>
- </subtable>
- </row>
- <row>
- <label>Name_PAGE_8</label>
- <nb_actions>1</nb_actions>
- <segment>customVariableName==Name_PAGE_8</segment>
- <subtable>
- <row>
- <label>Val_PAGE8</label>
- <nb_visits>1</nb_visits>
- <nb_actions>1</nb_actions>
- </row>
- </subtable>
- </row>
-</result>
+ <row>
+ <label>Name_PAGE_1</label>
+ <nb_actions>1</nb_actions>
+ <slots>
+ <row>
+ <scope>page</scope>
+ <index>1</index>
+ </row>
+ </slots>
+ <segment>customVariableName==Name_PAGE_1</segment>
+ <subtable>
+ <row>
+ <label>Val_PAGE1</label>
+ <nb_visits>1</nb_visits>
+ <nb_actions>1</nb_actions>
+ </row>
+ </subtable>
+ </row>
+ <row>
+ <label>Name_PAGE_2</label>
+ <nb_actions>1</nb_actions>
+ <slots>
+ <row>
+ <scope>page</scope>
+ <index>2</index>
+ </row>
+ </slots>
+ <segment>customVariableName==Name_PAGE_2</segment>
+ <subtable>
+ <row>
+ <label>Val_PAGE2</label>
+ <nb_visits>1</nb_visits>
+ <nb_actions>1</nb_actions>
+ </row>
+ </subtable>
+ </row>
+ <row>
+ <label>Name_PAGE_3</label>
+ <nb_actions>1</nb_actions>
+ <slots>
+ <row>
+ <scope>page</scope>
+ <index>3</index>
+ </row>
+ </slots>
+ <segment>customVariableName==Name_PAGE_3</segment>
+ <subtable>
+ <row>
+ <label>Val_PAGE3</label>
+ <nb_visits>1</nb_visits>
+ <nb_actions>1</nb_actions>
+ </row>
+ </subtable>
+ </row>
+ <row>
+ <label>Name_PAGE_4</label>
+ <nb_actions>1</nb_actions>
+ <slots>
+ <row>
+ <scope>page</scope>
+ <index>4</index>
+ </row>
+ </slots>
+ <segment>customVariableName==Name_PAGE_4</segment>
+ <subtable>
+ <row>
+ <label>Val_PAGE4</label>
+ <nb_visits>1</nb_visits>
+ <nb_actions>1</nb_actions>
+ </row>
+ </subtable>
+ </row>
+ <row>
+ <label>Name_PAGE_5</label>
+ <nb_actions>1</nb_actions>
+ <slots>
+ <row>
+ <scope>page</scope>
+ <index>5</index>
+ </row>
+ </slots>
+ <segment>customVariableName==Name_PAGE_5</segment>
+ <subtable>
+ <row>
+ <label>Val_PAGE5</label>
+ <nb_visits>1</nb_visits>
+ <nb_actions>1</nb_actions>
+ </row>
+ </subtable>
+ </row>
+ <row>
+ <label>Name_PAGE_6</label>
+ <nb_actions>1</nb_actions>
+ <slots>
+ <row>
+ <scope>page</scope>
+ <index>6</index>
+ </row>
+ </slots>
+ <segment>customVariableName==Name_PAGE_6</segment>
+ <subtable>
+ <row>
+ <label>Val_PAGE6</label>
+ <nb_visits>1</nb_visits>
+ <nb_actions>1</nb_actions>
+ </row>
+ </subtable>
+ </row>
+ <row>
+ <label>Name_PAGE_7</label>
+ <nb_actions>1</nb_actions>
+ <slots>
+ <row>
+ <scope>page</scope>
+ <index>7</index>
+ </row>
+ </slots>
+ <segment>customVariableName==Name_PAGE_7</segment>
+ <subtable>
+ <row>
+ <label>Val_PAGE7</label>
+ <nb_visits>1</nb_visits>
+ <nb_actions>1</nb_actions>
+ </row>
+ </subtable>
+ </row>
+ <row>
+ <label>Name_PAGE_8</label>
+ <nb_actions>1</nb_actions>
+ <slots>
+ <row>
+ <scope>page</scope>
+ <index>8</index>
+ </row>
+ </slots>
+ <segment>customVariableName==Name_PAGE_8</segment>
+ <subtable>
+ <row>
+ <label>Val_PAGE8</label>
+ <nb_visits>1</nb_visits>
+ <nb_actions>1</nb_actions>
+ </row>
+ </subtable>
+ </row>
+</result> \ No newline at end of file
diff --git a/plugins/CustomVariables/tests/UI/.gitignore b/plugins/CustomVariables/tests/UI/.gitignore
new file mode 100644
index 0000000000..f39be478e7
--- /dev/null
+++ b/plugins/CustomVariables/tests/UI/.gitignore
@@ -0,0 +1,2 @@
+/processed-ui-screenshots
+/screenshot-diffs \ No newline at end of file
diff --git a/plugins/CustomVariables/tests/UI/CustomVariables_spec.js b/plugins/CustomVariables/tests/UI/CustomVariables_spec.js
new file mode 100644
index 0000000000..1e247fca56
--- /dev/null
+++ b/plugins/CustomVariables/tests/UI/CustomVariables_spec.js
@@ -0,0 +1,25 @@
+/*!
+ * Piwik - free/libre analytics platform
+ *
+ * Screenshot integration tests.
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+describe("CustomVariables", function () {
+ this.timeout(0);
+
+ this.fixture = "Piwik\\Plugins\\CustomVariables\\tests\\Fixtures\\VisitWithManyCustomVariables";
+
+ it('should show an overview of all used custom variables', function (done) {
+ expect.screenshot('manage').to.be.captureSelector('.pageWrap', function (page) {
+ page.load("?idSite=1&period=day&date=2010-01-03&module=CustomVariables&action=manage");
+ }, done);
+ });
+
+ it('should be visible in the menu', function (done) {
+ expect.screenshot('link_in_menu').to.be.captureSelector('li:contains(Manage)', function (page) {
+ }, done);
+ });
+}); \ No newline at end of file
diff --git a/plugins/CustomVariables/tests/UI/expected-ui-screenshots/CustomVariables_link_in_menu.png b/plugins/CustomVariables/tests/UI/expected-ui-screenshots/CustomVariables_link_in_menu.png
new file mode 100644
index 0000000000..39480bbf29
--- /dev/null
+++ b/plugins/CustomVariables/tests/UI/expected-ui-screenshots/CustomVariables_link_in_menu.png
Binary files differ
diff --git a/plugins/CustomVariables/tests/UI/expected-ui-screenshots/CustomVariables_manage.png b/plugins/CustomVariables/tests/UI/expected-ui-screenshots/CustomVariables_manage.png
new file mode 100644
index 0000000000..c03b7e3795
--- /dev/null
+++ b/plugins/CustomVariables/tests/UI/expected-ui-screenshots/CustomVariables_manage.png
Binary files differ