Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GetNewPlugins.php « Widgets « CorePluginsAdmin « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e19259c66a8329ae7417686cc7fd6ea8d0232159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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\CorePluginsAdmin\Widgets;

use Piwik\Common;
use Piwik\Plugins\CorePluginsAdmin\MarketplaceApiClient;
use Piwik\Widget\Widget;
use Piwik\Widget\WidgetConfig;
use Piwik\View;

class GetNewPlugins extends Widget
{
    /**
     * @var MarketplaceApiClient
     */
    private $marketplaceApiClient;

    public function __construct(MarketplaceApiClient $marketplaceApiClient)
    {
        $this->marketplaceApiClient = $marketplaceApiClient;
    }

    public static function configure(WidgetConfig $config)
    {
        $config->setCategoryId('About Piwik');
        // TODO it actually shows "recently updated plugins currently". Need a new sort filter in the Marketplace
        // TODO when decided whether to show new plugins or recently updated plugins add translation key
        // we want to show new plugins likely (when changed Marketplace to support actually "newest" plugins)
        $config->setName('Latest Piwik Plugin Updates');
        $config->setOrder(19);
    }

    public function render()
    {
        $isAdminPage = Common::getRequestVar('isAdminPage', 0, 'int');

        if (!empty($isAdminPage)) {
            $template = 'getNewPluginsAdmin';
        } else {
            $template = 'getNewPlugins';
        }

        $plugins = $this->marketplaceApiClient->searchForPlugins('', '', 'newest');

        return $this->renderTemplate($template, array(
            'plugins' => array_splice($plugins, 0, 3)
        ));
    }

}