diff --git a/config/global.ini.php b/config/global.ini.php index 88dfe74664e5018177861486e94e864db356339e..fd9ef2d649b671746bedb1aa4801b41ff25e69c6 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -795,6 +795,7 @@ Plugins[] = Resolution Plugins[] = DevicePlugins Plugins[] = Heartbeat Plugins[] = Intl +Plugins[] = PiwikPro [PluginsInstalled] PluginsInstalled[] = Diagnostics diff --git a/core/PiwikPro/Advertising.php b/core/PiwikPro/Advertising.php index f17011ee7cdf8074c70a156909b661075d731250..dcb94c6fc1ae4e4d1136488519181446f2f90b6f 100644 --- a/core/PiwikPro/Advertising.php +++ b/core/PiwikPro/Advertising.php @@ -15,6 +15,7 @@ use Piwik\Config; * links for differnt landing pages etc. * * @api + * @since 2.16.0 */ class Advertising { diff --git a/core/WidgetsList.php b/core/WidgetsList.php index e91a0f2b38619f73cf50d154987c251878bcca55..8380d7a1eeef505c641d553273c2063c10f04183 100644 --- a/core/WidgetsList.php +++ b/core/WidgetsList.php @@ -147,7 +147,7 @@ class WidgetsList extends Singleton 'Goals_Goals', 'Goals_Ecommerce', '_others_', - 'Example Widgets', + 'About Piwik', 'ExamplePlugin_exampleWidgets', ); diff --git a/plugins/CoreHome/Widgets.php b/plugins/CoreHome/Widgets.php index 17d888bd35c43c6226af07a4cc0740047a27d6a4..1a2c945bff163daa7f2e20a7d69f8366a0f2b809 100644 --- a/plugins/CoreHome/Widgets.php +++ b/plugins/CoreHome/Widgets.php @@ -15,7 +15,7 @@ use Piwik\View; class Widgets extends \Piwik\Plugin\Widgets { - protected $category = 'Example Widgets'; + protected $category = 'About Piwik'; /** * @var Translator diff --git a/plugins/ExampleRssWidget/Widgets.php b/plugins/ExampleRssWidget/Widgets.php index 5fc0667fa85ea1d4d55a9a46e8f19eaa7824c00c..e0d67cdd9f823b944d595702114f4bc9482357fb 100644 --- a/plugins/ExampleRssWidget/Widgets.php +++ b/plugins/ExampleRssWidget/Widgets.php @@ -12,7 +12,7 @@ use Piwik\Piwik; class Widgets extends \Piwik\Plugin\Widgets { - protected $category = 'Example Widgets'; + protected $category = 'About Piwik'; protected function init() { diff --git a/plugins/PiwikPro/PiwikPro.php b/plugins/PiwikPro/PiwikPro.php new file mode 100644 index 0000000000000000000000000000000000000000..1bb25a9482f29ac98c2ea62e332b28bc09b93f48 --- /dev/null +++ b/plugins/PiwikPro/PiwikPro.php @@ -0,0 +1,13 @@ +<?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 +{ +} diff --git a/plugins/PiwikPro/Widgets.php b/plugins/PiwikPro/Widgets.php new file mode 100644 index 0000000000000000000000000000000000000000..89308240e7d347a32bef0a942a996339f30ded53 --- /dev/null +++ b/plugins/PiwikPro/Widgets.php @@ -0,0 +1,60 @@ +<?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>'; + } +} diff --git a/plugins/PiwikPro/lang/en.json b/plugins/PiwikPro/lang/en.json new file mode 100644 index 0000000000000000000000000000000000000000..cafc7b4add4d542237505b689ddf10103a448b6f --- /dev/null +++ b/plugins/PiwikPro/lang/en.json @@ -0,0 +1,5 @@ +{ + "PiwikPro": { + "WidgetBlogTitle": "Piwik PRO Blog" + } +} \ No newline at end of file diff --git a/plugins/PiwikPro/plugin.json b/plugins/PiwikPro/plugin.json new file mode 100644 index 0000000000000000000000000000000000000000..f7a302dafb0f72b64e8ab909afec5ef48ae11b2a --- /dev/null +++ b/plugins/PiwikPro/plugin.json @@ -0,0 +1,5 @@ +{ + "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 diff --git a/plugins/Widgetize/tests/System/WidgetTest.php b/plugins/Widgetize/tests/System/WidgetTest.php index d2d6ec32607714ecec43c95506ea08b93dbc3dcc..4573b708b131628a307d7a0569be36a5c31ca3fb 100644 --- a/plugins/Widgetize/tests/System/WidgetTest.php +++ b/plugins/Widgetize/tests/System/WidgetTest.php @@ -13,6 +13,7 @@ use Piwik\Http\ControllerResolver; use Piwik\Piwik; use Piwik\Plugins\Goals; use Piwik\Plugins\Widgetize\tests\Fixtures\WidgetizeFixture; +use Piwik\Tests\Framework\Mock\PiwikPro\Advertising; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\WidgetsList; @@ -835,9 +836,30 @@ class WidgetTest extends SystemTestCase '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() + ); + } } diff --git a/tests/PHPUnit/Integration/WidgetsListTest.php b/tests/PHPUnit/Integration/WidgetsListTest.php index f741f813f38d8cbeabf5fa779903a0d035aead19..80a77e5a93616baaa2e4c312bcecc86490e2c81c 100644 --- a/tests/PHPUnit/Integration/WidgetsListTest.php +++ b/tests/PHPUnit/Integration/WidgetsListTest.php @@ -46,7 +46,7 @@ class WidgetsListTest extends IntegrationTestCase 'Referrers_Referrers' => 7, 'Goals_Goals' => 1, 'SEO' => 2, - 'Example Widgets' => 4, + 'About Piwik' => 5, 'DevicesDetection_DevicesDetection' => 8, 'Insights_WidgetCategory' => 2 );