Beispiel #1
0
 public function overview()
 {
     $view = $this->configureViewAndCheckPermission('@Marketplace/overview');
     $show = Common::getRequestVar('show', 'plugins', 'string');
     $query = Common::getRequestVar('query', '', 'string', $_POST);
     $sort = new Sort();
     $sort = $sort->getSort();
     $mode = new Mode();
     $mode = $mode->getMode();
     // we're fetching all available plugins to decide which tabs need to be shown in the UI and to know the number
     // of total available plugins
     $allPlugins = $this->plugins->getAllPlugins();
     $allThemes = $this->plugins->getAllThemes();
     $paidPlugins = $this->plugins->getAllPaidPlugins();
     $showThemes = $show === 'themes';
     $showPlugins = !$showThemes;
     $showPaid = $show === 'premium';
     $showAll = !$showPaid;
     if ($showPlugins && $showPaid) {
         $type = PurchaseType::TYPE_PAID;
         $view->numAvailablePlugins = count($paidPlugins);
     } elseif ($showPlugins && $showAll) {
         $type = PurchaseType::TYPE_ALL;
         $view->numAvailablePlugins = count($allPlugins);
     } else {
         $type = PurchaseType::TYPE_ALL;
         $view->numAvailablePlugins = count($allThemes);
     }
     $pluginsToShow = $this->plugins->searchPlugins($query, $sort, $showThemes, $type);
     $paidPluginsToInstallAtOnce = array();
     if (SettingsPiwik::isAutoUpdatePossible()) {
         foreach ($paidPlugins as $paidPlugin) {
             if ($this->canPluginBeInstalled($paidPlugin) || $this->pluginManager->isPluginInstalled($paidPlugin['name']) && !$this->pluginManager->isPluginActivated($paidPlugin['name'])) {
                 $paidPluginsToInstallAtOnce[] = $paidPlugin['name'];
             }
         }
     }
     $view->paidPluginsToInstallAtOnce = $paidPluginsToInstallAtOnce;
     $view->pluginsToShow = $pluginsToShow;
     $view->isValidConsumer = $this->consumer->isValidConsumer();
     $view->paidPlugins = $paidPlugins;
     $view->freePlugins = $allPlugins;
     $view->themes = $allThemes;
     $view->showThemes = $showThemes;
     $view->showPlugins = $showPlugins;
     $view->showFree = $showAll;
     $view->showPaid = $showPaid;
     $view->pluginType = $show;
     $view->pluginTypeOptions = array('plugins' => Piwik::translate('General_Plugins'), 'premium' => Piwik::translate('Marketplace_PaidPlugins'), 'themes' => Piwik::translate('CorePluginsAdmin_Themes'));
     $view->pluginSortOptions = array(Sort::METHOD_LAST_UPDATED => Piwik::translate('Marketplace_SortByLastUpdated'), Sort::METHOD_POPULAR => Piwik::translate('Marketplace_SortByPopular'), Sort::METHOD_NEWEST => Piwik::translate('Marketplace_SortByNewest'), Sort::METHOD_ALPHA => Piwik::translate('Marketplace_SortByAlpha'));
     $view->mode = $mode;
     $view->query = $query;
     $view->sort = $sort;
     $view->hasLicenseKey = $this->licenseKey->has();
     $view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
     $view->installNonce = Nonce::getNonce(static::INSTALL_NONCE);
     $view->updateNonce = Nonce::getNonce(static::UPDATE_NONCE);
     $view->deactivateNonce = Nonce::getNonce(PluginsController::DEACTIVATE_NONCE);
     $view->activateNonce = Nonce::getNonce(PluginsController::ACTIVATE_NONCE);
     $view->isSuperUser = Piwik::hasUserSuperUserAccess();
     $view->isPluginsAdminEnabled = CorePluginsAdmin::isPluginsAdminEnabled();
     $view->isAutoUpdatePossible = SettingsPiwik::isAutoUpdatePossible();
     $view->isAutoUpdateEnabled = SettingsPiwik::isAutoUpdateEnabled();
     return $view->render();
 }