Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 * Updating icons
 * Tooltip more readable
 * putting language in General and deprecating redundant translation
  • Loading branch information
mattab committed Feb 3, 2013
1 parent aa7547d commit b202ff1
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 33 deletions.
32 changes: 25 additions & 7 deletions core/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,21 @@ public static function getCalendarPrettyDate($period)
}
}



/**
* Returns the pretty date representation
*
* @param $date string
* @param $period string
* @return string Pretty date
*/
public static function getPrettyDate($date, $period)
{
return self::getCalendarPrettyDate( Piwik_Period::factory($period, Piwik_Date::factory($date)) );
}


/**
* Calculates the evolution from one value to another and returns HTML displaying
* the evolution percent. The HTML includes an up/down arrow and is colored red, black or
Expand All @@ -855,10 +870,9 @@ public static function getCalendarPrettyDate($period)
* @param int $currentValue The value to calculate evolution to.
* @param string $pastDate The date of past value.
* @param int $pastValue The value in the past to calculate evolution from.
* @param bool $isVisits If the value is for visits or some other unit.
* @return string|false The HTML or false if the evolution is 0 and the current value is 0.
*/
protected function getEvolutionHtml( $date, $currentValue, $pastDate, $pastValue, $isVisits = true )
protected function getEvolutionHtml( $date, $currentValue, $pastDate, $pastValue)
{
$evolutionPercent = Piwik_DataTable_Filter_CalculateEvolutionFilter::calculate(
$currentValue, $pastValue, $precision = 2);
Expand All @@ -873,7 +887,7 @@ protected function getEvolutionHtml( $date, $currentValue, $pastDate, $pastValue
$titleEvolutionPercent = $evolutionPercent;
if ($evolutionPercent < 0)
{
$color = "red";
$color = "#e02a3b"; //red
$img = "arrow_down.png";
}
else if ($evolutionPercent == 0)
Expand All @@ -887,11 +901,15 @@ protected function getEvolutionHtml( $date, $currentValue, $pastDate, $pastValue
$titleEvolutionPercent = '+'.$titleEvolutionPercent;
}

$token = $isVisits ? 'MultiSites_TotalsEvolutionSummary' : 'Referers_EvolutionSummaryGeneric';
$title = Piwik_Translate($token,
array($currentValue, $date, $pastValue, $titleEvolutionPercent, $pastDate));
$title = Piwik_Translate('General_EvolutionSummaryGeneric', array(
Piwik_Translate('General_NVisits', $currentValue),
$date,
Piwik_Translate('General_NVisits', $pastValue),
$pastDate,
$titleEvolutionPercent
));

$result = '<span style="display:inline-block" title="'.$title
$result = '<span class="metricEvolution" title="'.$title
. '"><img style="padding-right:4px" src="plugins/MultiSites/images/'.$img.'"/><strong';

if (isset($color))
Expand Down
5 changes: 2 additions & 3 deletions lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
'General_Metadata' => 'Metadata',
'General_OneVisit' => '1 visit',
'General_NVisits' => '%s visits',
'General_EvolutionSummaryGeneric' => '%1$s in %2$s compared to %3$s in %4$s. Evolution: %5$s',
'General_OneDay' => '1 day',
'General_NDays' => '%s days',
'General_MainMetrics' => 'Main metrics',
Expand All @@ -360,7 +361,7 @@
'General_Show_js' => 'show',
'General_Hide_js' => 'hide',
'General_Donate' => 'Donate',
'General_MoreSparklines' => 'More Sparklines',
'General_MoreDetails' => 'More Details',
'Actions_PluginDescription' => 'Reports about the page views, the outlinks and downloads. Outlinks and Downloads tracking is automatic! You can also track your internal website\'s Search Engine.',
'Actions_Actions' => 'Actions',
'Actions_SubmenuPages' => 'Pages',
Expand Down Expand Up @@ -1148,7 +1149,6 @@
'MultiSites_PluginDescription' => 'Displays multi-site executive summary/statistics. Currently maintained as a core Piwik plugin.',
'MultiSites_Evolution' => 'Evolution',
'MultiSites_TopLinkTooltip' => 'Compare Web Analytics stats for all of your Websites.',
'MultiSites_TotalsEvolutionSummary' => '%s visits in %s compared to %s visits (%s) in %s',
'Provider_PluginDescription' => 'Reports the Provider of the visitors.',
'Provider_WidgetProviders' => 'Providers',
'Provider_ColumnProvider' => 'Provider',
Expand Down Expand Up @@ -1207,7 +1207,6 @@
'Referers_WidgetSearchEngines' => 'Search Engines',
'Referers_WidgetOverview' => 'Overview',
'Referers_SocialFooterMessage' => 'This is a subset of the Websites report to the left. It filters out other websites so you can compare your social network referrers directly.',
'Referers_EvolutionSummaryGeneric' => '%s in %s compared to %s (%s) in %s',
'Referers_WidgetGetAll' => 'All Referrers',
'SecurityInfo_PluginDescription' => 'Based on PhpSecInfo from the PHP Security Consortium, this plugin provides security information about your PHP environment and offers suggestions for improvement. It is a tool in a multilayered security approach. It does not replace secure development practices nor audit the code/application.',
'SecurityInfo_Security' => 'Security',
Expand Down
2 changes: 1 addition & 1 deletion plugins/MultiSites/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getSitesInfo($isWidgetized)

echo $view->render();
}

/**
* The Multisites reports displays the first calendar date as the earliest day available for all websites.
* Also, today is the later "today" available across all timezones.
Expand Down
Binary file modified plugins/MultiSites/images/arrow_desc.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/MultiSites/images/arrow_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/MultiSites/images/arrow_down_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/MultiSites/images/arrow_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/MultiSites/images/arrow_up_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/MultiSites/images/stop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions plugins/MultiSites/templates/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@

<div class="centerLargeDiv">

<h2>{'General_AllWebsitesDashboard'|translate}
<span class='smallTitle' {if $totalVisitsEvolution}title="{'MultiSites_TotalsEvolutionSummary'|translate:$totalVisits:$prettyDate:$pastTotalVisits:$totalVisitsEvolution:$pastPeriodPretty}"{/if}>
<h2>{'General_AllWebsitesDashboard'|translate}
{capture assign=nVisits}{'General_NVisits'|translate:$totalVisits}{/capture}
{capture assign=nVisitsLast}{'General_NVisits'|translate:$pastTotalVisits}{/capture}
<span class='smallTitle' {if $totalVisitsEvolution}title="{'General_EvolutionSummaryGeneric'|translate:$nVisits:$prettyDate:$nVisitsLast:$pastPeriodPretty:$totalVisitsEvolution}"{/if}>
{'General_TotalVisitsPageviewsRevenue'|translate:"<strong>$totalVisits</strong>":"<strong>$totalPageviews</strong>":"<strong>$totalRevenue</strong>"}
</span>
</h2>
Expand Down
19 changes: 10 additions & 9 deletions plugins/Referers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ function index()
if ($lastPeriodDate !== false)
{
$date = Piwik_Common::getRequestVar('date');

$period = Piwik_Common::getRequestVar('period');

$prettyDate = self::getPrettyDate($date, $period);
$prettyLastPeriodDate = self::getPrettyDate($lastPeriodDate, $period);

// visit metrics
$previousValues = $this->getReferersVisitorsByType($lastPeriodDate);
$this->addEvolutionPropertiesToView($view, $date, $nameValues, $lastPeriodDate, $previousValues);
$this->addEvolutionPropertiesToView($view, $prettyDate, $nameValues, $prettyLastPeriodDate, $previousValues);

// distinct metrics
$previousValues = $this->getDistinctReferrersMetrics($lastPeriodDate);
$this->addEvolutionPropertiesToView(
$view, $date, $distinctMetrics, $lastPeriodDate, $previousValues, $isVisits = false);
$this->addEvolutionPropertiesToView($view, $prettyDate, $distinctMetrics, $prettyLastPeriodDate, $previousValues);
}

// sparkline for the historical data of the above values
Expand Down Expand Up @@ -685,16 +688,14 @@ private function getDistinctReferrersMetrics( $date = false )
* in this array should be the same as keys in $currentValues.
* @param bool $isVisits Whether the values are counting visits or something else.
*/
private function addEvolutionPropertiesToView( $view, $date, $currentValues, $lastPeriodDate,
$previousValues, $isVisits = false )
private function addEvolutionPropertiesToView( $view, $date, $currentValues, $lastPeriodDate, $previousValues)
{
foreach ($previousValues as $name => $pastValue)
{
$currentValue = $currentValues[$name];
$evolutionName = $name.'Evolution';

$view->$evolutionName = $this->getEvolutionHtml(
$date, $currentValue, $lastPeriodDate, $pastValue, $isVisits);

$view->$evolutionName = $this->getEvolutionHtml($date, $currentValue, $lastPeriodDate, $pastValue);
}
}
}
18 changes: 9 additions & 9 deletions plugins/Referers/templates/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,44 @@
<h2>{'Referers_Type'|translate}</h2>
<div id='leftcolumn'>
<div class="sparkline">{sparkline src=$urlSparklineDirectEntry}
{'Referers_TypeDirectEntries'|translate:"<strong>$visitorsFromDirectEntry</strong>"}{if !empty($visitorsFromDirectEntryPercent)}, <strong>{$visitorsFromDirectEntryPercent}%</strong> of visits{/if}{if !empty($visitorsFromDirectEntryEvolution)}, {$visitorsFromDirectEntryEvolution}{/if}
{'Referers_TypeDirectEntries'|translate:"<strong>$visitorsFromDirectEntry</strong>"}{if !empty($visitorsFromDirectEntryPercent)}, <strong>{$visitorsFromDirectEntryPercent}%</strong> of visits{/if}{if !empty($visitorsFromDirectEntryEvolution)} {$visitorsFromDirectEntryEvolution}{/if}
</div>
<div class="sparkline">{sparkline src=$urlSparklineSearchEngines}
{'Referers_TypeSearchEngines'|translate:"<strong>$visitorsFromSearchEngines</strong>"}{if !empty($visitorsFromSearchEnginesPercent)}, <strong>{$visitorsFromSearchEnginesPercent}%</strong> of visits{/if}{if !empty($visitorsFromSearchEnginesEvolution)}, {$visitorsFromSearchEnginesEvolution}{/if}
{'Referers_TypeSearchEngines'|translate:"<strong>$visitorsFromSearchEngines</strong>"}{if !empty($visitorsFromSearchEnginesPercent)}, <strong>{$visitorsFromSearchEnginesPercent}%</strong> of visits{/if}{if !empty($visitorsFromSearchEnginesEvolution)} {$visitorsFromSearchEnginesEvolution}{/if}
</div>
</div>
<div id='rightcolumn'>
<div class="sparkline">{sparkline src=$urlSparklineWebsites}
{'Referers_TypeWebsites'|translate:"<strong>$visitorsFromWebsites</strong>"}{if !empty($visitorsFromWebsitesPercent)}, <strong>{$visitorsFromWebsitesPercent}%</strong> of visits{/if}{if !empty($visitorsFromWebsitesEvolution)}, {$visitorsFromWebsitesEvolution}{/if}
{'Referers_TypeWebsites'|translate:"<strong>$visitorsFromWebsites</strong>"}{if !empty($visitorsFromWebsitesPercent)}, <strong>{$visitorsFromWebsitesPercent}%</strong> of visits{/if}{if !empty($visitorsFromWebsitesEvolution)} {$visitorsFromWebsitesEvolution}{/if}
</div>
<div class="sparkline">{sparkline src=$urlSparklineCampaigns}
{'Referers_TypeCampaigns'|translate:"<strong>$visitorsFromCampaigns</strong>"}{if !empty($visitorsFromCampaignsPercent)}, <strong>{$visitorsFromCampaignsPercent}%</strong> of visits{/if}{if !empty($visitorsFromCampaignsEvolution)}, {$visitorsFromCampaignsEvolution}{/if}
{'Referers_TypeCampaigns'|translate:"<strong>$visitorsFromCampaigns</strong>"}{if !empty($visitorsFromCampaignsPercent)}, <strong>{$visitorsFromCampaignsPercent}%</strong> of visits{/if}{if !empty($visitorsFromCampaignsEvolution)} {$visitorsFromCampaignsEvolution}{/if}
</div>
</div>

<div style="clear:both" />

<p style="float:left">
<br/><br/>
<strong>{'General_MoreSparklines'|translate}</strong>&nbsp;<a href="#" class="section-toggler-link" data-section-id="distinctReferrersByType">({'General_Show_js'|translate})</a>
<h2>{'General_MoreDetails'|translate}&nbsp;<a href="#" class="section-toggler-link" data-section-id="distinctReferrersByType">({'General_Show_js'|translate})</a></h2>
</p>

<div id="distinctReferrersByType" style="display:none;float:left">
<table cellpadding="15">
<tr><td width="50%">
<div class="sparkline">{sparkline src=$urlSparklineDistinctSearchEngines}
<strong>{$numberDistinctSearchEngines}</strong> {'Referers_DistinctSearchEngines'|translate}{if !empty($numberDistinctSearchEnginesEvolution)}, {$numberDistinctSearchEnginesEvolution}{/if}
<strong>{$numberDistinctSearchEngines}</strong> {'Referers_DistinctSearchEngines'|translate}{if !empty($numberDistinctSearchEnginesEvolution)} {$numberDistinctSearchEnginesEvolution}{/if}
</div>
<div class="sparkline">{sparkline src=$urlSparklineDistinctKeywords}
<strong>{$numberDistinctKeywords}</strong> {'Referers_DistinctKeywords'|translate}{if !empty($numberDistinctKeywordsEvolution)}, {$numberDistinctKeywordsEvolution}{/if}
<strong>{$numberDistinctKeywords}</strong> {'Referers_DistinctKeywords'|translate}{if !empty($numberDistinctKeywordsEvolution)} {$numberDistinctKeywordsEvolution}{/if}
</div>
</td>
<td width="50%">
<div class="sparkline">{sparkline src=$urlSparklineDistinctWebsites}
<strong>{$numberDistinctWebsites}</strong> {'Referers_DistinctWebsites'|translate} {'Referers_UsingNDistinctUrls'|translate:"<strong>$numberDistinctWebsitesUrls</strong>"}{if !empty($numberDistinctWebsitesEvolution)}, {$numberDistinctWebsitesEvolution}{/if}
<strong>{$numberDistinctWebsites}</strong> {'Referers_DistinctWebsites'|translate} {'Referers_UsingNDistinctUrls'|translate:"<strong>$numberDistinctWebsitesUrls</strong>"}{if !empty($numberDistinctWebsitesEvolution)} {$numberDistinctWebsitesEvolution}{/if}
</div>
<div class="sparkline">{sparkline src=$urlSparklineDistinctCampaigns}
<strong>{$numberDistinctCampaigns}</strong> {'Referers_DistinctCampaigns'|translate}{if !empty($numberDistinctCampaignsEvolution)}, {$numberDistinctCampaignsEvolution}{/if}
<strong>{$numberDistinctCampaigns}</strong> {'Referers_DistinctCampaigns'|translate}{if !empty($numberDistinctCampaignsEvolution)} {$numberDistinctCampaignsEvolution}{/if}
</div>
</td></tr>
</table>
Expand Down
4 changes: 2 additions & 2 deletions plugins/SEO/templates/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<form method="post" style="padding: 8px;" >
<div align="left" class="mediumtext">
{'Installation_SetupWebSiteURL'|translate|ucfirst}
<input type="text" id="seoUrl" size="30" value="{$urlToRank|escape:'html'}" class="textbox" />
<input type="text" id="seoUrl" size="15" value="{$urlToRank|escape:'html'}" class="textbox" />
<span style="padding-left:2px;">
<input type="submit" id="rankbutton" value="{'SEO_Rank'|translate}" />
</span>
Expand Down Expand Up @@ -39,4 +39,4 @@
{/if}
</div>
</form>
</div>
</div>
7 changes: 7 additions & 0 deletions themes/default/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -772,3 +772,10 @@ table.entityTable tr td a {
.section-toggler-link:hover {
text-decoration:underline;
}

.metricEvolution {
display:inline-block;
font-size:9pt;
opacity:0.75;
}

0 comments on commit b202ff1

Please sign in to comment.