本文整理汇总了PHP中Piwik\Plugin\Manager类的典型用法代码示例。如果您正苦于以下问题:PHP Manager类的具体用法?PHP Manager怎么用?PHP Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Manager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: arePiwikProAdsEnabled
/**
* Returns true if it is ok to show some Piwik PRO advertising in the Piwik UI.
* @return bool
*/
public function arePiwikProAdsEnabled()
{
if ($this->pluginManager->isPluginActivated('EnterpriseAdmin') || $this->pluginManager->isPluginActivated('LoginAdmin') || $this->pluginManager->isPluginActivated('CloudAdmin') || $this->pluginManager->isPluginActivated('WhiteLabel')) {
return false;
}
$showAds = $this->config->General['piwik_pro_ads_enabled'];
return !empty($showAds);
}
示例2: getAllLogTables
/**
* Get all log table instances defined by any activated and loaded plugin. The returned tables are not sorted in
* any order.
* @return LogTable[]
*/
public function getAllLogTables()
{
if (!isset($this->tablesCache)) {
$tables = $this->pluginManager->findMultipleComponents('Tracker', 'Piwik\\Tracker\\LogTable');
$this->tablesCache = array();
foreach ($tables as $table) {
$this->tablesCache[] = StaticContainer::get($table);
}
}
return $this->tablesCache;
}
示例3: getAllReleaseChannels
/**
* @return ReleaseChannel[]
*/
public function getAllReleaseChannels()
{
$classNames = $this->pluginManager->findMultipleComponents('ReleaseChannel', 'Piwik\\UpdateCheck\\ReleaseChannel');
$channels = array();
foreach ($classNames as $className) {
$channels[] = StaticContainer::get($className);
}
usort($channels, function (ReleaseChannel $a, ReleaseChannel $b) {
if ($a->getOrder() === $b->getOrder()) {
return 0;
}
return $a->getOrder() < $b->getOrder() ? -1 : 1;
});
return $channels;
}
示例4: enrichPluginInformation
private function enrichPluginInformation($plugin)
{
if (empty($plugin)) {
return $plugin;
}
$plugin['isInstalled'] = $this->isPluginInstalled($plugin['name']);
$plugin['isActivated'] = $this->isPluginActivated($plugin['name']);
$plugin['isInvalid'] = $this->pluginManager->isPluginThirdPartyAndBogus($plugin['name']);
$plugin['canBeUpdated'] = $plugin['isInstalled'] && $this->hasPluginUpdate($plugin);
$plugin['lastUpdated'] = $this->toShortDate($plugin['lastUpdated']);
$plugin['hasExceededLicense'] = !empty($plugin['isInstalled']) && !empty($plugin['shop']) && empty($plugin['isFree']) && empty($plugin['isDownloadable']) && !empty($plugin['consumer']['license']['isValid']) && !empty($plugin['consumer']['license']['isExceeded']);
$plugin['isMissingLicense'] = !empty($plugin['isInstalled']) && !empty($plugin['shop']) && empty($plugin['isFree']) && empty($plugin['isDownloadable']) && empty($plugin['consumer']['license']);
if (!empty($plugin['owner']) && strtolower($plugin['owner']) === 'piwikpro' && !empty($plugin['homepage']) && strpos($plugin['homepage'], 'pk_campaign') === false) {
$plugin['homepage'] = $this->advertising->addPromoCampaignParametersToUrl($plugin['homepage'], Advertising::CAMPAIGN_NAME_PROFESSIONAL_SERVICES, 'Marketplace', $plugin['name']);
}
if ($plugin['canBeUpdated']) {
$pluginUpdate = $this->getPluginUpdateInformation($plugin);
$plugin['repositoryChangelogUrl'] = $pluginUpdate['repositoryChangelogUrl'];
$plugin['currentVersion'] = $pluginUpdate['currentVersion'];
}
if (!empty($plugin['activity']['lastCommitDate']) && false === strpos($plugin['activity']['lastCommitDate'], '0000') && false === strpos($plugin['activity']['lastCommitDate'], '1970')) {
$plugin['activity']['lastCommitDate'] = $this->toLongDate($plugin['activity']['lastCommitDate']);
} else {
$plugin['activity']['lastCommitDate'] = null;
}
if (!empty($plugin['versions'])) {
foreach ($plugin['versions'] as $index => $version) {
$plugin['versions'][$index]['release'] = $this->toLongDate($version['release']);
}
}
$plugin = $this->addMissingRequirements($plugin);
return $plugin;
}
示例5: configureTopMenu
public function configureTopMenu(MenuTop $menu)
{
$login = Piwik::getCurrentUserLogin();
$user = APIUsersManager::getInstance()->getUser($login);
if (!empty($user['alias'])) {
$login = $user['alias'];
}
if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
$menu->addItem('General_Help', null, array('module' => 'Feedback', 'action' => 'index'));
}
if (Piwik::isUserIsAnonymous()) {
if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
$menu->addItem($login, null, array('module' => 'Feedback', 'action' => 'index'), 998);
} else {
$menu->addItem($login, null, array('module' => 'API', 'action' => 'listAllAPI'), 998);
}
} else {
$menu->addItem($login, null, array('module' => 'UsersManager', 'action' => 'userSettings'), 998);
}
$module = $this->getLoginModule();
if (Piwik::isUserIsAnonymous()) {
$menu->addItem('Login_LogIn', null, array('module' => $module, 'action' => false), 999);
} else {
$menu->addItem('General_Logout', null, array('module' => $module, 'action' => 'logout', 'idSite' => null), 999);
}
}
示例6: installOrUpdatePluginFromMarketplace
public function installOrUpdatePluginFromMarketplace($pluginName)
{
$this->checkMarketplaceIsEnabled();
$this->pluginName = $pluginName;
try {
$this->makeSureFoldersAreWritable();
$this->makeSurePluginNameIsValid();
$tmpPluginZip = $this->downloadPluginFromMarketplace();
$tmpPluginFolder = dirname($tmpPluginZip) . '/' . basename($tmpPluginZip, '.zip') . '/';
$this->extractPluginFiles($tmpPluginZip, $tmpPluginFolder);
$this->makeSurePluginJsonExists($tmpPluginFolder);
$metadata = $this->getPluginMetadataIfValid($tmpPluginFolder);
$this->makeSureThereAreNoMissingRequirements($metadata);
$this->copyPluginToDestination($tmpPluginFolder);
Filesystem::deleteAllCacheOnUpdate($this->pluginName);
$pluginManager = PluginManager::getInstance();
if ($pluginManager->isPluginLoaded($this->pluginName)) {
$plugin = PluginManager::getInstance()->getLoadedPlugin($this->pluginName);
if (!empty($plugin)) {
$plugin->reloadPluginInformation();
}
}
} catch (\Exception $e) {
if (!empty($tmpPluginZip)) {
Filesystem::deleteFileIfExists($tmpPluginZip);
}
if (!empty($tmpPluginFolder)) {
$this->removeFolderIfExists($tmpPluginFolder);
}
throw $e;
}
$this->removeFileIfExists($tmpPluginZip);
$this->removeFolderIfExists($tmpPluginFolder);
}
示例7: update
static function update()
{
$errors = array();
try {
$checker = new DoNotTrackHeaderChecker();
// enable DoNotTrack check in PrivacyManager if DoNotTrack plugin was enabled
if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('DoNotTrack')) {
$checker->activate();
}
// enable IP anonymization if AnonymizeIP plugin was enabled
if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('AnonymizeIP')) {
IPAnonymizer::activate();
}
} catch (\Exception $ex) {
// pass
}
// disable & delete old plugins
$oldPlugins = array('DoNotTrack', 'AnonymizeIP');
foreach ($oldPlugins as $plugin) {
try {
\Piwik\Plugin\Manager::getInstance()->deactivatePlugin($plugin);
} catch (\Exception $e) {
}
$dir = PIWIK_INCLUDE_PATH . "/plugins/{$plugin}";
if (file_exists($dir)) {
Filesystem::unlinkRecursive($dir, true);
}
if (file_exists($dir)) {
$errors[] = "Please delete this directory manually (eg. using your FTP software): {$dir} \n";
}
}
if (!empty($errors)) {
throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors));
}
}
示例8: update
static function update()
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('PrivacyManager');
} catch (\Exception $e) {
}
}
示例9: getAvailableCommands
/**
* Returns a list of available command classnames.
*
* @return string[]
*/
private function getAvailableCommands()
{
$commands = $this->getDefaultPiwikCommands();
$detected = PluginManager::getInstance()->findMultipleComponents('Commands', 'Piwik\\Plugin\\ConsoleCommand');
$commands = array_merge($commands, $detected);
/**
* Triggered to filter / restrict console commands. Plugins that want to restrict commands
* should subscribe to this event and remove commands from the existing list.
*
* **Example**
*
* public function filterConsoleCommands(&$commands)
* {
* $key = array_search('Piwik\Plugins\MyPlugin\Commands\MyCommand', $commands);
* if (false !== $key) {
* unset($commands[$key]);
* }
* }
*
* @param array &$commands An array containing a list of command class names.
*/
Piwik::postEvent('Console.filterCommands', array(&$commands));
$commands = array_values(array_unique($commands));
return $commands;
}
示例10: getPluginName
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return array
* @throws \RuntimeException
*/
protected function getPluginName(InputInterface $input, OutputInterface $output)
{
$overwrite = $input->getOption('overwrite');
$self = $this;
$validate = function ($pluginName) use($self, $overwrite) {
if (empty($pluginName)) {
throw new \RuntimeException('You have to enter a plugin name');
}
if (strlen($pluginName) > 40) {
throw new \RuntimeException('Your plugin name cannot be longer than 40 characters');
}
if (!Plugin\Manager::getInstance()->isValidPluginName($pluginName)) {
throw new \RuntimeException(sprintf('The plugin name %s is not valid. The name must start with a letter and is only allowed to contain numbers and letters.', $pluginName));
}
$pluginPath = $self->getPluginPath($pluginName);
if (file_exists($pluginPath) && !$overwrite) {
throw new \RuntimeException('A plugin with this name already exists');
}
return $pluginName;
};
$pluginName = $input->getOption('name');
if (empty($pluginName)) {
$dialog = $this->getHelperSet()->get('dialog');
$pluginName = $dialog->askAndValidate($output, 'Enter a plugin name: ', $validate);
} else {
$validate($pluginName);
}
$pluginName = ucfirst($pluginName);
return $pluginName;
}
示例11: isPluginActivated
protected function isPluginActivated($pluginName)
{
if (in_array($pluginName, $this->activatedPluginNames)) {
return true;
}
return $this->pluginManager->isPluginActivated($pluginName);
}
示例12: registerWidgets
public function registerWidgets()
{
if (PluginManager::getInstance()->isPluginActivated('UserCountry')) {
WidgetsList::add('General_Visitors', Piwik::translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap');
WidgetsList::add('Live!', Piwik::translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap');
}
}
示例13: doUpdate
public function doUpdate(Updater $updater)
{
try {
Manager::getInstance()->activatePlugin('Monolog');
} catch (\Exception $e) {
}
}
示例14: factory
/**
* Create a component instance that exists within a specific plugin. Uses the component's
* unqualified class name and expected base type.
*
* This method will only create a class if it is located within the component type's
* associated subdirectory.
*
* @param string $pluginName The name of the plugin the component is expected to belong to,
* eg, `'UserSettings'`.
* @param string $componentClassSimpleName The component's class name w/o namespace, eg,
* `"GetKeywords"`.
* @param string $componentTypeClass The fully qualified class name of the component type, eg,
* `"Piwik\Plugin\Report"`.
* @return mixed|null A new instance of the desired component or null if not found. If the
* plugin is not loaded or activated or the component is not located in
* in the sub-namespace specified by `$componentTypeClass::COMPONENT_SUBNAMESPACE`,
* this method will return null.
*/
public static function factory($pluginName, $componentClassSimpleName, $componentTypeClass)
{
if (empty($pluginName) || empty($componentClassSimpleName)) {
return null;
}
$pluginManager = PluginManager::getInstance();
try {
if (!$pluginManager->isPluginActivated($pluginName)) {
return null;
}
$plugin = $pluginManager->getLoadedPlugin($pluginName);
} catch (Exception $e) {
Log::debug($e);
return null;
}
$subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
$desiredComponentClass = 'Piwik\\Plugins\\' . $pluginName . '\\' . $subnamespace . '\\' . $componentClassSimpleName;
$components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
foreach ($components as $class) {
if ($class == $desiredComponentClass) {
return new $class();
}
}
return null;
}
示例15: update
static function update()
{
try {
Manager::getInstance()->activatePlugin('Monolog');
} catch (\Exception $e) {
}
}