-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor profile summaries into additional classes
- Loading branch information
Showing
3 changed files
with
68 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?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\CustomDimensions\ProfileSummary; | ||
|
||
use Piwik\Piwik; | ||
use Piwik\Plugins\CustomDimensions\CustomDimensions; | ||
use Piwik\Plugins\Live\ProfileSummary\ProfileSummaryAbstract; | ||
use Piwik\View; | ||
|
||
/** | ||
* Class VisitScopeSummary | ||
* | ||
* @api | ||
*/ | ||
class VisitScopeSummary extends ProfileSummaryAbstract | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getName() | ||
{ | ||
return Piwik::translate('CustomDimensions_CustomDimensions') . ' ' . Piwik::translate('General_TrackingScopeVisit'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function render() | ||
{ | ||
if (empty($this->profile['customDimensions']) || empty($this->profile['customDimensions'][CustomDimensions::SCOPE_VISIT])) { | ||
return ''; | ||
} | ||
|
||
$view = new View('@CustomDimensions/_profileSummary.twig'); | ||
$view->visitorData = $this->profile; | ||
$view->scopeName = Piwik::translate('General_TrackingScopeVisit'); | ||
$view->dimensions = $this->profile['customDimensions'][CustomDimensions::SCOPE_VISIT]; | ||
|
||
return $view->render(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getOrder() | ||
{ | ||
return 10; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,13 @@ | ||
{% if visitorData.customDimensions['visit'] is defined and visitorData.customDimensions['visit']|length > 0 %} | ||
<div class="visitor-profile-summary visitor-profile-customdimensions"> | ||
<h1>{{ 'CustomDimensions_CustomDimensions'|translate }} ({{ 'General_TrackingScopeVisit'|translate }})</h1> | ||
<div> | ||
{%- for dimension in visitorData.customDimensions['visit'] -%} | ||
<p> | ||
<span>{{ dimension.name }}: </span> | ||
{%- for value in dimension.values -%} | ||
<strong title="{{ value.count }}x">{{ value.value }}</strong>{% if not loop.last %}, {% endif %} | ||
{%- endfor -%} | ||
</p> | ||
{%- endfor -%} | ||
</div> | ||
<div class="visitor-profile-summary visitor-profile-customdimensions"> | ||
<h1>{{ 'CustomDimensions_CustomDimensions'|translate }} ({{ scopeName }})</h1> | ||
<div> | ||
{%- for dimension in dimensions -%} | ||
<p> | ||
<span>{{ dimension.name }}: </span> | ||
{%- for value in dimension.values -%} | ||
<strong title="{{ value.count }}x">{{ value.value }}</strong>{% if not loop.last %}, {% endif %} | ||
{%- endfor -%} | ||
</p> | ||
{%- endfor -%} | ||
</div> | ||
{% endif %} | ||
|
||
{% if visitorData.customDimensions['action'] is defined and visitorData.customDimensions['action']|length > 0 %} | ||
<div class="visitor-profile-summary visitor-profile-customdimensions"> | ||
<h1>{{ 'CustomDimensions_CustomDimensions'|translate }} ({{ 'General_TrackingScopeAction'|translate }})</h1> | ||
<div> | ||
{%- for dimension in visitorData.customDimensions['action'] -%} | ||
<p> | ||
<span>{{ dimension.name }}: </span> | ||
{%- for value in dimension.values -%} | ||
<strong title="{{ value.count }}x">{{ value.value }}</strong>{% if not loop.last %}, {% endif %} | ||
{%- endfor -%} | ||
</p> | ||
{%- endfor -%} | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> |