Skip to content
Extraits de code Groupes Projets
Valider cfab30a4 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

fixes #9650 new widget showing piwik pro blog

parent 0d3909d6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -795,6 +795,7 @@ Plugins[] = Resolution ...@@ -795,6 +795,7 @@ Plugins[] = Resolution
Plugins[] = DevicePlugins Plugins[] = DevicePlugins
Plugins[] = Heartbeat Plugins[] = Heartbeat
Plugins[] = Intl Plugins[] = Intl
Plugins[] = PiwikPro
[PluginsInstalled] [PluginsInstalled]
PluginsInstalled[] = Diagnostics PluginsInstalled[] = Diagnostics
......
...@@ -15,6 +15,7 @@ use Piwik\Config; ...@@ -15,6 +15,7 @@ use Piwik\Config;
* links for differnt landing pages etc. * links for differnt landing pages etc.
* *
* @api * @api
* @since 2.16.0
*/ */
class Advertising class Advertising
{ {
......
...@@ -147,7 +147,7 @@ class WidgetsList extends Singleton ...@@ -147,7 +147,7 @@ class WidgetsList extends Singleton
'Goals_Goals', 'Goals_Goals',
'Goals_Ecommerce', 'Goals_Ecommerce',
'_others_', '_others_',
'Example Widgets', 'About Piwik',
'ExamplePlugin_exampleWidgets', 'ExamplePlugin_exampleWidgets',
); );
......
...@@ -15,7 +15,7 @@ use Piwik\View; ...@@ -15,7 +15,7 @@ use Piwik\View;
class Widgets extends \Piwik\Plugin\Widgets class Widgets extends \Piwik\Plugin\Widgets
{ {
protected $category = 'Example Widgets'; protected $category = 'About Piwik';
/** /**
* @var Translator * @var Translator
......
...@@ -12,7 +12,7 @@ use Piwik\Piwik; ...@@ -12,7 +12,7 @@ use Piwik\Piwik;
class Widgets extends \Piwik\Plugin\Widgets class Widgets extends \Piwik\Plugin\Widgets
{ {
protected $category = 'Example Widgets'; protected $category = 'About Piwik';
protected function init() protected function init()
{ {
......
<?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\PiwikPro;
class PiwikPro extends \Piwik\Plugin
{
}
<?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\PiwikPro;
use Piwik\Piwik;
use Piwik\PiwikPro\Advertising;
use Piwik\Plugins\ExampleRssWidget\RssRenderer;
class Widgets extends \Piwik\Plugin\Widgets
{
protected $category = 'About Piwik';
/**
* @var Advertising
*/
private $advertising;
public function __construct(Advertising $advertising)
{
$this->advertising = $advertising;
}
protected function init()
{
if ($this->advertising->arePiwikProAdsEnabled()) {
$this->addWidget('PiwikPro_WidgetBlogTitle', 'rssPiwikPro');
}
}
public function rssPiwikPro()
{
try {
$rss = new RssRenderer('https://piwik.pro/feed/');
$rss->showDescription(true);
return $rss->get();
} catch (\Exception $e) {
return $this->error($e);
}
}
/**
* @param \Exception $e
* @return string
*/
private function error($e)
{
return '<div class="pk-emptyDataTable">'
. Piwik::translate('General_ErrorRequest', array('', ''))
. ' - ' . $e->getMessage() . '</div>';
}
}
{
"PiwikPro": {
"WidgetBlogTitle": "Piwik PRO Blog"
}
}
\ No newline at end of file
{
"name": "PiwikPro",
"description": "Provides widgets to follow Piwik PRO blog and to see info about their products.",
"theme": false
}
\ No newline at end of file
...@@ -13,6 +13,7 @@ use Piwik\Http\ControllerResolver; ...@@ -13,6 +13,7 @@ use Piwik\Http\ControllerResolver;
use Piwik\Piwik; use Piwik\Piwik;
use Piwik\Plugins\Goals; use Piwik\Plugins\Goals;
use Piwik\Plugins\Widgetize\tests\Fixtures\WidgetizeFixture; use Piwik\Plugins\Widgetize\tests\Fixtures\WidgetizeFixture;
use Piwik\Tests\Framework\Mock\PiwikPro\Advertising;
use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\WidgetsList; use Piwik\WidgetsList;
...@@ -835,9 +836,30 @@ class WidgetTest extends SystemTestCase ...@@ -835,9 +836,30 @@ class WidgetTest extends SystemTestCase
'action' => 'rssChangelog', 'action' => 'rssChangelog',
), ),
), ),
array (
'name' => 'Piwik PRO Blog',
'uniqueId' => 'widgetPiwikProrssPiwikPro',
'parameters' =>
array (
'module' => 'PiwikPro',
'action' => 'rssPiwikPro',
),
)
); );
} }
/**
* Use this method to return custom container configuration that you want to apply for the tests.
* This configuration will override Fixture config.
*
* @return array
*/
public static function provideContainerConfigBeforeClass()
{
return array(
'Piwik\PiwikPro\Advertising' => new Advertising()
);
}
} }
......
...@@ -46,7 +46,7 @@ class WidgetsListTest extends IntegrationTestCase ...@@ -46,7 +46,7 @@ class WidgetsListTest extends IntegrationTestCase
'Referrers_Referrers' => 7, 'Referrers_Referrers' => 7,
'Goals_Goals' => 1, 'Goals_Goals' => 1,
'SEO' => 2, 'SEO' => 2,
'Example Widgets' => 4, 'About Piwik' => 5,
'DevicesDetection_DevicesDetection' => 8, 'DevicesDetection_DevicesDetection' => 8,
'Insights_WidgetCategory' => 2 'Insights_WidgetCategory' => 2
); );
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter