本文整理汇总了PHP中Piwik_PluginsManager::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_PluginsManager::getInstance方法的具体用法?PHP Piwik_PluginsManager::getInstance怎么用?PHP Piwik_PluginsManager::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_PluginsManager
的用法示例。
在下文中一共展示了Piwik_PluginsManager::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
static function update()
{
try {
Piwik_PluginsManager::getInstance()->activatePlugin('PrivacyManager');
} catch (Exception $e) {
}
}
示例2: dispatch
function dispatch()
{
$language = Piwik_Common::getRequestVar('language', '', 'string');
if($language != '')
{
$updaterController = new Piwik_CoreUpdater_Controller();
$updaterController->saveLanguage();
exit;
}
$updater = new Piwik_Updater();
$updater->addComponentToCheck('core', Piwik_Version::VERSION);
$plugins = Piwik_PluginsManager::getInstance()->getInstalledPlugins();
foreach($plugins as $pluginName => $plugin)
{
$updater->addComponentToCheck($pluginName, $plugin->getVersion());
}
$componentsWithUpdateFile = $updater->getComponentsWithUpdateFile();
if(count($componentsWithUpdateFile) == 0)
{
return;
}
$updaterController = new Piwik_CoreUpdater_Controller();
$updaterController->runUpdaterAndExit($updater, $componentsWithUpdateFile);
}
示例3: getCacheWebsiteAttributes
/**
* Returns array containing data about the website: goals, URLs, etc.
*
* @param int $idSite
* @return array
*/
static function getCacheWebsiteAttributes($idSite)
{
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
static $cache = null;
if (is_null($cache)) {
$cache = new Piwik_CacheFile('tracker');
}
$filename = $idSite;
$cacheContent = $cache->get($filename);
if ($cacheContent !== false) {
return $cacheContent;
}
if (defined('PIWIK_TRACKER_MODE') && PIWIK_TRACKER_MODE) {
require_once PIWIK_INCLUDE_PATH . '/core/PluginsManager.php';
require_once PIWIK_INCLUDE_PATH . '/core/Translate.php';
require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
Zend_Registry::set('db', Piwik_Tracker::getDatabase());
Piwik::createAccessObject();
Piwik::createConfigObject();
Piwik::setUserIsSuperUser();
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsManager->setPluginsToLoad(Zend_Registry::get('config')->Plugins->Plugins->toArray());
}
$content = array();
Piwik_PostEvent('Common.fetchWebsiteAttributes', $content, $idSite);
// if nothing is returned from the plugins, we don't save the content
// this is not expected: all websites are expected to have at least one URL
if (!empty($content)) {
$cache->set($filename, $content);
}
return $content;
}
示例4: update
static function update()
{
// first we disable the plugins and keep an array of warnings messages
$pluginsToDisableMessage = array(
'SearchEnginePosition' => "SearchEnginePosition plugin was disabled, because it is not compatible with the new Piwik 0.6. \n You can download the latest version of the plugin, compatible with Piwik 0.6.\n<a target='_blank' href='?module=Proxy&action=redirect&url=http://dev.piwik.org/trac/ticket/502'>Click here.</a>",
'GeoIP' => "GeoIP plugin was disabled, because it is not compatible with the new Piwik 0.6. \nYou can download the latest version of the plugin, compatible with Piwik 0.6.\n<a target='_blank' href='?module=Proxy&action=redirect&url=http://dev.piwik.org/trac/ticket/45'>Click here.</a>"
);
$disabledPlugins = array();
foreach($pluginsToDisableMessage as $pluginToDisable => $warningMessage)
{
if(Piwik_PluginsManager::getInstance()->isPluginActivated($pluginToDisable))
{
Piwik_PluginsManager::getInstance()->deactivatePlugin($pluginToDisable);
$disabledPlugins[] = $warningMessage;
}
}
// Run the SQL
Piwik_Updater::updateDatabase(__FILE__, self::getSql());
// Outputs warning message, pointing users to the plugin download page
if(!empty($disabledPlugins))
{
throw new Exception("The following plugins were disabled during the upgrade:"
."<ul><li>" .
implode('</li><li>', $disabledPlugins) .
"</li></ul>");
}
}
示例5: test_callableApiMethods_doNotFail
function test_callableApiMethods_doNotFail()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik::createLogObject();
Piwik::createAccessObject();
Piwik::createDatabaseObject();
Piwik::setUserIsSuperUser();
Piwik_Translate::getInstance()->loadEnglishTranslation();
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsManager->loadPlugins(Piwik_Config::getInstance()->Plugins['Plugins']);
Piwik_SitesManager_API::getInstance()->addSite("name", "http://example.org");
$apiGenerator = new Piwik_API_DocumentationGenerator_CallAllMethods();
$requestUrls = $apiGenerator->getAllRequestsWithParameters();
$this->assertTrue(count($requestUrls) > 20);
foreach ($requestUrls as $url) {
$call = new Piwik_API_Request($url);
$output = $call->process();
// var_dump($url);
// var_dump($output);
$this->assertTrue(!empty($output));
}
Piwik_Translate::getInstance()->unloadEnglishTranslation();
$this->pass();
}
示例6: activate
function activate()
{
Piwik::checkUserIsSuperUser();
$pluginName = Piwik_Common::getRequestVar('pluginName', null, 'string');
Piwik_PluginsManager::getInstance()->activatePlugin($pluginName);
Piwik_Url::redirectToUrl('index.php?module=CorePluginsAdmin');
}
示例7: sendRequest
protected function sendRequest($url, $method = 'GET', $data = null, $force = false)
{
// if doing a bulk request, store the url
if ($this->doBulkRequests && !$force) {
$this->storedTrackingActions[] = $url;
return true;
}
if ($method == 'POST') {
$requests = array();
foreach ($this->storedTrackingActions as $action) {
$requests[] = $this->parseUrl($action);
}
$testEnvironmentArgs = array();
} else {
$testEnvironmentArgs = $this->parseUrl($url);
$requests = array($testEnvironmentArgs);
}
// unset cached values
Piwik_Common::$trackerCache = null;
Piwik_Tracker::setForceIp(null);
Piwik_Tracker::setForceDateTime(null);
Piwik_Tracker::setForceVisitorId(null);
// save some values
$plugins = Piwik_Config::getInstance()->Plugins['Plugins'];
$pluginsTracker = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker'];
$oldTrackerConfig = Piwik_Config::getInstance()->Tracker;
Piwik_PluginsManager::getInstance()->unloadPlugins();
// modify config
$GLOBALS['PIWIK_TRACKER_MODE'] = true;
$GLOBALS['PIWIK_TRACKER_LOCAL_TRACKING'] = true;
Piwik_Common::$initTrackerMode = false;
Piwik_Tracker::setTestEnvironment($testEnvironmentArgs, $method);
// set language
$oldLang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $this->acceptLanguage;
// set user agent
$oldUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$_SERVER['HTTP_USER_AGENT'] = $this->userAgent;
// set cookie
$oldCookie = $_COOKIE;
parse_str(parse_url($this->requestCookie, PHP_URL_QUERY), $_COOKIE);
// do tracking and capture output
ob_start();
$localTracker = new Piwik_Tracker();
$localTracker->main($requests);
$output = ob_get_contents();
ob_end_clean();
// restore vars
Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker'] = $pluginsTracker;
Piwik_Config::getInstance()->Tracker = $oldTrackerConfig;
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $oldLang;
$_SERVER['HTTP_USER_AGENT'] = $oldUserAgent;
$_COOKIE = $oldCookie;
$GLOBALS['PIWIK_TRACKER_LOCAL_TRACKING'] = false;
$GLOBALS['PIWIK_TRACKER_MODE'] = false;
unset($_GET['bots']);
// reload plugins
Piwik_PluginsManager::getInstance()->loadPlugins($plugins);
return $output;
}
示例8: process
/**
* Handles the request to the API.
* It first checks that the method called (parameter 'method') is available in the module (it means that the method exists and is public)
* It then reads the parameters from the request string and throws an exception if there are missing parameters.
* It then calls the API Proxy which will call the requested method.
*
* @return mixed The data resulting from the API call
*/
public function process()
{
// read the format requested for the output data
$outputFormat = strtolower(Piwik_Common::getRequestVar('format', 'xml', 'string', $this->request));
// create the response
$response = new Piwik_API_ResponseBuilder($this->request, $outputFormat);
try {
// read parameters
$moduleMethod = Piwik_Common::getRequestVar('method', null, null, $this->request);
list($module, $method) = $this->extractModuleAndMethod($moduleMethod);
if (!Piwik_PluginsManager::getInstance()->isPluginActivated($module)) {
throw new Piwik_FrontController_PluginDeactivatedException($module);
}
$module = "Piwik_" . $module . "_API";
// if a token_auth is specified in the API request, we load the right permissions
$token_auth = Piwik_Common::getRequestVar('token_auth', '', 'string', $this->request);
if ($token_auth) {
Piwik_PostEvent('API.Request.authenticate', $token_auth);
Zend_Registry::get('access')->reloadAccess();
}
// call the method
$returnedValue = Piwik_API_Proxy::getInstance()->call($module, $method, $this->request);
$toReturn = $response->getResponse($returnedValue);
} catch (Exception $e) {
$toReturn = $response->getResponseException($e);
}
return $toReturn;
}
示例9: worldMap
function worldMap()
{
if (!Piwik_PluginsManager::getInstance()->isPluginActivated('UserCountry')) {
return '';
}
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
Piwik::checkUserHasViewAccess($idSite);
$period = Piwik_Common::getRequestVar('period');
$date = Piwik_Common::getRequestVar('date');
$token_auth = Piwik::getCurrentUserTokenAuth();
$view = Piwik_View::factory('worldmap');
$view->dataUrl = "?module=API" . "&method=API.getProcessedReport&format=XML" . "&apiModule=UserCountry&apiAction=getCountry" . "&idSite=" . $idSite . "&period=" . $period . "&date=" . $date . "&token_auth=" . $token_auth . "&segment=" . Piwik_Common::unsanitizeInputValue(Piwik_Common::getRequestVar('segment', '')) . "&filter_limit=-1";
// definition of the color scale
$view->hueMin = 218;
$view->hueMax = 216;
$view->satMin = "0.285";
$view->satMax = "0.9";
$view->lgtMin = ".97";
$view->lgtMax = ".44";
$request = new Piwik_API_Request('method=API.getMetadata&format=PHP' . '&apiModule=UserCountry&apiAction=getCountry' . '&idSite=' . $idSite . '&period=' . $period . '&date=' . $date . '&token_auth=' . $token_auth . '&filter_limit=-1');
$metaData = $request->process();
$metrics = array();
foreach ($metaData[0]['metrics'] as $id => $val) {
if (Piwik_Common::getRequestVar('period') == 'day' || $id != 'nb_uniq_visitors') {
$metrics[] = array($id, $val);
}
}
foreach ($metaData[0]['processedMetrics'] as $id => $val) {
$metrics[] = array($id, $val);
}
$view->metrics = $metrics;
$view->defaultMetric = 'nb_visits';
echo $view->render();
}
示例10: update
static function update()
{
Piwik_Updater::updateDatabase(__FILE__, self::getSql());
try {
Piwik_PluginsManager::getInstance()->activatePlugin('Transitions');
} catch (Exception $e) {
}
}
示例11: activate
public function activate()
{
Piwik::checkUserIsSuperUser();
$this->checkTokenInUrl();
$pluginName = Piwik_Common::getRequestVar('pluginName', null, 'string');
Piwik_PluginsManager::getInstance()->activatePlugin($pluginName);
Piwik_Url::redirectToReferer();
}
示例12: __construct
function __construct()
{
parent::__construct();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik_PluginsManager::getInstance()->unloadPlugins();
Piwik_PluginsManager::getInstance()->loadPlugins(array('LanguagesManager'));
$plugin = Piwik_PluginsManager::getInstance()->getLoadedPlugin('LanguagesManager');
$plugin->install();
}
示例13: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Zend_Registry::set('access', $pseudoMockAccess);
Piwik_PluginsManager::getInstance()->loadPlugins(array('SitesManager'));
}
示例14: setUp
public function setUp()
{
parent::setUp();
$userFile = dirname(__FILE__) . '/Action.config.ini.php';
$config = Piwik_Config::getInstance();
$config->clear();
$config->setTestEnvironment($userFile, false);
Piwik_PluginsManager::getInstance()->loadPlugins(array('SitesManager'));
}
示例15: reloadLanguage
public function reloadLanguage($language = false)
{
if (empty($language)) {
$language = $this->getLanguageToLoad();
}
$this->unloadEnglishTranslation();
$this->loadEnglishTranslation();
$this->loadCoreTranslation($language);
Piwik_PluginsManager::getInstance()->loadPluginTranslations($language);
}