当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik_SitesManager_API::getInstance方法代码示例

本文整理汇总了PHP中Piwik_SitesManager_API::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_SitesManager_API::getInstance方法的具体用法?PHP Piwik_SitesManager_API::getInstance怎么用?PHP Piwik_SitesManager_API::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik_SitesManager_API的用法示例。


在下文中一共展示了Piwik_SitesManager_API::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUpWebsites

 /**
  * One site with custom search parameters,
  * One site using default search parameters,
  * One site with disabled site search
  */
 protected static function setUpWebsites()
 {
     Piwik_SitesManager_API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
     self::createWebsite(Piwik_Date::factory(self::$dateTime)->subHour(200)->getDatetime(), 0, "Site 1 - Site search", $siteurl = false, $search = 1, $searchKwd = 'q,mykwd,p', $searchCat = 'cats');
     self::createWebsite(Piwik_Date::factory(self::$dateTime)->subHour(400)->getDatetime(), 0, "Site 2 - Site search use default", $siteurl = false, $search = 1, $searchKwd = '', $searchCat = '');
     self::createWebsite(Piwik_Date::factory(self::$dateTime)->subHour(600)->getDatetime(), 0, "Site 3 - No site search", $siteurl = false, $search = 0);
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:12,代码来源:SiteSearchTest.php

示例2: update

	static function update()
	{
		$obsoleteFiles = array(
			PIWIK_INCLUDE_PATH . '/core/Db/Mysqli.php',
		);
		foreach($obsoleteFiles as $obsoleteFile)
		{
			if(file_exists($obsoleteFile))
			{
				@unlink($obsoleteFile);
			}
		}

		$obsoleteDirectories = array(
			PIWIK_INCLUDE_PATH . '/core/Db/Pdo',
		);
		foreach($obsoleteDirectories as $dir)
		{
			if(file_exists($dir))
			{
				Piwik::unlinkRecursive($dir, true);
			}
		}

		// force regeneration of cache files
		Piwik::setUserIsSuperUser();
		$allSiteIds = Piwik_SitesManager_API::getInstance()->getAllSitesId();
		Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:29,代码来源:0.6.2.php

示例3: __construct

 function __construct($idsite)
 {
     $this->id = $idsite;
     if (!isset(self::$infoSites[$this->id])) {
         self::$infoSites[$this->id] = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
     }
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:7,代码来源:Site.php

示例4: index

 public function index()
 {
     Piwik::checkUserIsNotAnonymous();
     $view = Piwik_View::factory('index');
     $this->setGeneralVariablesView($view);
     $view->currentUserEmail = Piwik::getCurrentUserEmail();
     $allSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
     $view->countWebsites = count($allSites);
     $availableReports = Piwik_API_API::getInstance()->getReportMetadata($this->idSite);
     $reportsByCategory = array();
     foreach ($availableReports as $report) {
         $reportsByCategory[$report['category']][] = $report;
     }
     unset($reportsByCategory['API']);
     $reports = Piwik_PDFReports_API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
     $reportsById = array();
     foreach ($reports as &$report) {
         $report['additional_emails'] = str_replace(',', "\n", $report['additional_emails']);
         $report['reports'] = explode(',', str_replace('.', '_', $report['reports']));
         $reportsById[$report['idreport']] = $report;
     }
     $view->downloadOutputType = Piwik_PDFReports_API::OUTPUT_DOWNLOAD;
     $columnsCount = 2;
     $view->newColumnAfter = ceil(count($reportsByCategory) / $columnsCount);
     $view->reportsByCategory = $reportsByCategory;
     $view->reportsJSON = Piwik_Common::json_encode($reportsById);
     $view->periods = array_merge(array('never' => Piwik_Translate('General_Never')), Piwik_PDFReports_API::getPeriodToFrequency());
     $view->defaultFormat = Piwik_PDFReports::DEFAULT_FORMAT;
     $view->formats = Piwik_ReportRenderer::$availableReportRenderers;
     $view->aggregateReportsFormats = Piwik_PDFReports_API::getAggregateReportsFormats();
     $view->reports = $reports;
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     echo $view->render();
 }
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:34,代码来源:Controller.php

示例5: getScheduledTasks

 function getScheduledTasks($notification)
 {
     // Reports have to be sent when the period ends for all websites
     $maxHourOffset = 0;
     $uniqueTimezones = Piwik_SitesManager_API::getInstance()->getUniqueSiteTimezones();
     $baseDate = Piwik_Date::factory("1971-01-01");
     foreach ($uniqueTimezones as &$timezone) {
         $offsetDate = Piwik_Date::factory($baseDate->toString(), $timezone);
         // Earlier means a negative timezone
         if ($offsetDate->isEarlier($baseDate)) {
             // Gets the timezone offset
             $hourOffset = 24 - date('H', $offsetDate->getTimestamp());
             if ($hourOffset > $maxHourOffset) {
                 $maxHourOffset = $hourOffset;
             }
         }
     }
     $tasks =& $notification->getNotificationObject();
     $dailySchedule = new Piwik_ScheduledTime_Daily();
     $dailySchedule->setHour($maxHourOffset);
     $tasks[] = new Piwik_ScheduledTask($this, 'dailySchedule', $dailySchedule);
     $weeklySchedule = new Piwik_ScheduledTime_Weekly();
     $weeklySchedule->setHour($maxHourOffset);
     $tasks[] = new Piwik_ScheduledTask($this, 'weeklySchedule', $weeklySchedule);
     $monthlySchedule = new Piwik_ScheduledTime_Monthly();
     $monthlySchedule->setHour($maxHourOffset);
     $tasks[] = new Piwik_ScheduledTask($this, 'monthlySchedule', $monthlySchedule);
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:28,代码来源:PDFReports.php

示例6: update

 static function update()
 {
     // force regeneration of cache files following #648
     Piwik::setUserIsSuperUser();
     $allSiteIds = Piwik_SitesManager_API::getInstance()->getAllSitesId();
     Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:7,代码来源:0.2.34.php

示例7: 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();
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:25,代码来源:DocumentationGenerator.test.php

示例8: check

	/**
	 * Check for a newer version
	 *
	 * @param bool $force Force check
	 */
	public static function check($force = false)
	{
		$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
		if($force || $lastTimeChecked === false
			|| time() - self::CHECK_INTERVAL > $lastTimeChecked )
		{
			// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
			Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
			$parameters = array(
				'piwik_version' => Piwik_Version::VERSION,
				'php_version' => PHP_VERSION,
				'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
				'trigger' => Piwik_Common::getRequestVar('module','','string'),
				'timezone' => Piwik_SitesManager_API::getInstance()->getDefaultTimezone(),
			);

			$url = Zend_Registry::get('config')->General->api_service_url;
			$url .= '/1.0/getLatestVersion/';
			$url .= '?' . http_build_query($parameters, '', '&');
			$timeout = self::SOCKET_TIMEOUT;
			try {
				$latestVersion = Piwik_Http::sendHttpRequest($url, $timeout);
				Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
			} catch(Exception $e) {
				// e.g., disable_functions = fsockopen; allow_url_open = Off
				Piwik_SetOption(self::LATEST_VERSION, '');
			}
		}
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:34,代码来源:UpdateCheck.php

示例9: trackVisitsImpl

 protected function trackVisitsImpl($t)
 {
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     $t->disableCookieSupport();
     $t->setUrlReferrer('http://referer.com/page.htm?param=valuewith some spaces');
     // testing URL excluded parameters
     $parameterToExclude = 'excluded_parameter';
     Piwik_SitesManager_API::getInstance()->updateSite($idSite, 'new name', $url = array('http://site.com'), $ecommerce = 0, $excludedIps = null, $parameterToExclude . ',anotherParameter');
     // Record 1st page view
     $urlPage1 = 'http://example.org/index.htm?excluded_Parameter=SHOULD_NOT_DISPLAY&parameter=Should display';
     $t->setUrl($urlPage1);
     $this->checkResponse($t->doTrackPageView('incredible title!'));
     // testing that / and index.htm above record with different URLs
     // Recording the 2nd page after 3 minutes
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.05)->getDatetime());
     $urlPage2 = 'http://example.org/';
     $t->setUrl($urlPage2);
     //		$t->setUrlReferrer($urlPage1);
     $this->checkResponse($t->doTrackPageView('Second page view - should be registered as URL /'));
     //		$t->setUrlReferrer($urlPage2);
     // Click on external link after 6 minutes (3rd action)
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.1)->getDatetime());
     $this->checkResponse($t->doTrackAction('http://dev.piwik.org/svn', 'link'));
     // Click on file download after 12 minutes (4th action)
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.2)->getDatetime());
     $this->checkResponse($t->doTrackAction('http://piwik.org/path/again/latest.zip', 'download'));
     // Create Goal 1: Triggered by JS, after 18 minutes
     $idGoal = Piwik_Goals_API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.3)->getDatetime());
     // Change to Thai  browser to ensure the conversion is credited to FR instead (the visitor initial country)
     $t->setBrowserLanguage('th');
     $this->checkResponse($t->doTrackGoal($idGoal, $revenue = 42));
     // Track same Goal twice (after 24 minutes), should only be tracked once
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.4)->getDatetime());
     $this->checkResponse($t->doTrackGoal($idGoal, $revenue = 42));
     $t->setBrowserLanguage('fr');
     // Final page view (after 27 min)
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.45)->getDatetime());
     $t->setUrl('http://example.org/index.htm');
     $this->checkResponse($t->doTrackPageView('Looking at homepage (again)...'));
     // -
     // End of first visit: 24min
     // Create Goal 2: Matching on URL
     Piwik_Goals_API::getInstance()->addGoal($idSite, 'matching purchase.htm', 'url', '(.*)store\\/purchase\\.(.*)', 'regex', false, $revenue = 1);
     // -
     // Start of returning visit, 1 hour after first page view
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(1)->getDatetime());
     $t->setUrl('http://example.org/store/purchase.htm');
     $t->setUrlReferrer('http://search.yahoo.com/search?p=purchase');
     // Temporary, until we implement 1st party cookies in PiwikTracker
     $t->DEBUG_APPEND_URL = '&_idvc=2';
     // Goal Tracking URL matching, testing custom referer including keyword
     $this->checkResponse($t->doTrackPageView('Checkout/Purchasing...'));
     // -
     // End of second visit
 }
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:57,代码来源:OneVisitorTwoVisits.test.php

示例10: testExcludeQueryParametersSiteAndGlobalExcluded

 /**
  * Testing with some website specific and some global excluded query parameters
  * @group Core
  * @group Tracker
  * @group Tracker_Action
  * @dataProvider getTestUrls
  */
 public function testExcludeQueryParametersSiteAndGlobalExcluded($url, $filteredUrl)
 {
     // testing also that query parameters are case insensitive
     $excludedQueryParameters = 'P2,var[value][date]';
     $excludedGlobalParameters = 'blabla, P4';
     $this->setUpRootAccess();
     $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, $excludedIps = '', $excludedQueryParameters);
     Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($excludedGlobalParameters);
     $this->assertEquals($filteredUrl[1], Piwik_Tracker_Action::excludeQueryParametersFromUrl($url, $idSite));
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:17,代码来源:ActionTest.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     $access = new Piwik_Access();
     Zend_Registry::set('access', $access);
     $access->setSuperUser(true);
     $this->idSiteAccess = Piwik_SitesManager_API::getInstance()->addSite("test", "http://test");
     Piwik_PluginsManager::getInstance()->loadPlugins(array('MultiSites', 'VisitsSummary', 'Actions'));
     Piwik_PluginsManager::getInstance()->installLoadedPlugins();
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:10,代码来源:MultiSitesTest.php

示例12: getAll

 /**
  * Returns a report displaying the total visits, actions and revenue, as
  * well as the evolution of these values, of all existing sites over a
  * specified period of time.
  * 
  * If the specified period is not a 'range', this function will calculcate
  * evolution metrics. Evolution metrics are metrics that display the
  * percent increase/decrease of another metric since the last period.
  * 
  * This function will merge the result of the archive query so each
  * row in the result DataTable will correspond to the metrics of a single
  * site. If a date range is specified, the result will be a
  * DataTable_Array, but it will still be merged.
  * 
  * @param string $period The period type to get data for.
  * @param string $date The date(s) to get data for.
  * @param string $segment The segments to get data for.
  */
 public function getAll($period, $date, $segment = false)
 {
     Piwik::checkUserHasSomeViewAccess();
     $isGoalPluginEnabled = Piwik_Common::isGoalPluginEnabled();
     // get site data for every viewable site and cache them
     if (Piwik::isUserIsSuperUser()) {
         $sites = Piwik_SitesManager_API::getInstance()->getAllSites();
         Piwik_Site::setSites($sites);
     } else {
         $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
         Piwik_Site::setSitesFromArray($sites);
     }
     // build the archive type used to query archive data
     $archive = Piwik_Archive::build('all', $period, $date, $segment);
     // determine what data will be displayed
     $fieldsToGet = array('nb_visits', 'nb_actions');
     if ($isGoalPluginEnabled) {
         $revenueMetric = Piwik_Goals::getRecordName('revenue');
         $fieldsToGet[] = $revenueMetric;
     }
     // get the data
     $dataTable = $archive->getDataTableFromNumeric($fieldsToGet);
     // get rid of the DataTable_Array that is created by the IndexedBySite archive type
     $dataTable = $dataTable->mergeChildren();
     // if the period isn't a range & a lastN/previousN date isn't used, we get the same
     // data for the last period to show the evolution of visits/actions/revenue
     if ($period != 'range' && !preg_match('/(last|previous)([0-9]*)/', $date, $regs)) {
         if (strpos($date, ',')) {
             $rangePeriod = new Piwik_Period_Range($period, $date);
             $lastStartDate = Piwik_Period_Range::removePeriod($period, $rangePeriod->getDateStart(), $n = 1);
             $lastEndDate = Piwik_Period_Range::removePeriod($period, $rangePeriod->getDateEnd(), $n = 1);
             $strLastDate = "{$lastStartDate},{$lastEndDate}";
         } else {
             $strLastDate = Piwik_Period_Range::removePeriod($period, Piwik_Date::factory($date), $n = 1)->toString();
         }
         $pastArchive = Piwik_Archive::build('all', $period, $strLastDate, $segment);
         $pastData = $pastArchive->getDataTableFromNumeric($fieldsToGet);
         $pastData = $pastData->mergeChildren();
         // use past data to calculate evolution percentages
         $this->calculateEvolutionPercentages($dataTable, $pastData, $fieldsToGet);
     }
     // move the site id to a metadata column
     $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'idsite'));
     // set the label of each row to the site name
     $getNameFor = array('Piwik_Site', 'getNameFor');
     $dataTable->filter('ColumnCallbackReplace', array('label', $getNameFor));
     // rename the revenue column from the metric name to 'revenue'
     if ($isGoalPluginEnabled) {
         $mapping = array($revenueMetric => 'revenue');
         $dataTable->filter('ReplaceColumnNames', array($mapping));
     }
     // Ensures data set sorted, for Metadata output
     $dataTable->filter('Sort', array('nb_visits', 'desc', $naturalSort = false));
     return $dataTable;
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:73,代码来源:API.php

示例13: testIsVisitorIpExcluded

 /**
  * @group Core
  * @group Tracker
  * @group Tracker_Visit
  * @dataProvider getExcludedIpTestData
  */
 public function testIsVisitorIpExcluded($excludedIp, $tests)
 {
     $visit = new Test_Piwik_TrackerVisit_public();
     $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0, $excludedIp);
     $visit->setRequest(array('idsite' => $idsite));
     // test that IPs within the range, or the given IP, are excluded
     foreach ($tests as $ip => $expected) {
         $testIpIsExcluded = Piwik_IP::P2N($ip);
         $this->assertSame($expected, $visit->public_isVisitorIpExcluded($testIpIsExcluded));
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:17,代码来源:VisitTest.php

示例14: index

 public function index()
 {
     Piwik::checkUserIsSuperUser();
     $sitesList = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
     $view = Piwik_View::factory('index');
     $this->setBasicVariablesView($view);
     $view->assign('sitesList', $sitesList);
     $view->nonce = Piwik_Nonce::getNonce('Piwik_VisitorGenerator.generate');
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:11,代码来源:Controller.php

示例15: add

 /**
  * Adds a new entry to the menu.
  *
  * @param string      $menuName
  * @param string      $subMenuName
  * @param string      $url
  * @param bool        $displayedForCurrentUser
  * @param int         $order
  * @param bool|string $tooltip Tooltip to display.
  */
 public function add($menuName, $subMenuName, $url, $displayedForCurrentUser, $order = 50, $tooltip = false)
 {
     if ($displayedForCurrentUser) {
         // make sure the idSite value used is numeric (hack-y fix for #3426)
         if (!is_numeric(Piwik_Common::getRequestVar('idSite', false))) {
             $idSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
             $url['idSite'] = reset($idSites);
         }
         $this->menuEntries[] = array($menuName, $subMenuName, $url, $order, $tooltip);
     }
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:21,代码来源:Abstract.php


注:本文中的Piwik_SitesManager_API::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。