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


PHP SitesManager\API类代码示例

本文整理汇总了PHP中Piwik\Plugins\SitesManager\API的典型用法代码示例。如果您正苦于以下问题:PHP API类的具体用法?PHP API怎么用?PHP API使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: check

 /**
  * Check for a newer version
  *
  * @param bool $force Force check
  * @param int $interval Interval used for update checks
  */
 public static function check($force = false, $interval = null)
 {
     if (!self::isAutoUpdateEnabled()) {
         return;
     }
     if ($interval === null) {
         $interval = self::CHECK_INTERVAL;
     }
     $lastTimeChecked = Option::get(self::LAST_TIME_CHECKED);
     if ($force || $lastTimeChecked === false || time() - $interval > $lastTimeChecked) {
         // set the time checked first, so that parallel Piwik requests don't all trigger the http requests
         Option::set(self::LAST_TIME_CHECKED, time(), $autoLoad = 1);
         $parameters = array('piwik_version' => Version::VERSION, 'php_version' => PHP_VERSION, 'url' => Url::getCurrentUrlWithoutQueryString(), 'trigger' => Common::getRequestVar('module', '', 'string'), 'timezone' => API::getInstance()->getDefaultTimezone());
         $url = Config::getInstance()->General['api_service_url'] . '/1.0/getLatestVersion/' . '?' . http_build_query($parameters, '', '&');
         $timeout = self::SOCKET_TIMEOUT;
         if (@Config::getInstance()->Debug['allow_upgrades_to_beta']) {
             $url = 'http://builds.piwik.org/LATEST_BETA';
         }
         try {
             $latestVersion = Http::sendHttpRequest($url, $timeout);
             if (!preg_match('~^[0-9][0-9a-zA-Z_.-]*$~D', $latestVersion)) {
                 $latestVersion = '';
             }
         } catch (Exception $e) {
             // e.g., disable_functions = fsockopen; allow_url_open = Off
             $latestVersion = '';
         }
         Option::set(self::LATEST_VERSION, $latestVersion);
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:36,代码来源:UpdateCheck.php

示例2: setGlobalSettings

 /**
  * Records Global settings when user submit changes
  */
 public function setGlobalSettings()
 {
     $response = new ResponseBuilder(Common::getRequestVar('format'));
     try {
         $this->checkTokenInUrl();
         $timezone = Common::getRequestVar('timezone', false);
         $excludedIps = Common::getRequestVar('excludedIps', false);
         $excludedQueryParameters = Common::getRequestVar('excludedQueryParameters', false);
         $excludedUserAgents = Common::getRequestVar('excludedUserAgents', false);
         $currency = Common::getRequestVar('currency', false);
         $searchKeywordParameters = Common::getRequestVar('searchKeywordParameters', $default = "");
         $searchCategoryParameters = Common::getRequestVar('searchCategoryParameters', $default = "");
         $enableSiteUserAgentExclude = Common::getRequestVar('enableSiteUserAgentExclude', $default = 0);
         $keepURLFragments = Common::getRequestVar('keepURLFragments', $default = 0);
         $api = API::getInstance();
         $api->setDefaultTimezone($timezone);
         $api->setDefaultCurrency($currency);
         $api->setGlobalExcludedQueryParameters($excludedQueryParameters);
         $api->setGlobalExcludedIps($excludedIps);
         $api->setGlobalExcludedUserAgents($excludedUserAgents);
         $api->setGlobalSearchParameters($searchKeywordParameters, $searchCategoryParameters);
         $api->setSiteSpecificUserAgentExcludeEnabled($enableSiteUserAgentExclude == 1);
         $api->setKeepURLFragmentsGlobal($keepURLFragments);
         $toReturn = $response->getResponse();
     } catch (Exception $e) {
         $toReturn = $response->getResponseException($e);
     }
     return $toReturn;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:32,代码来源:Controller.php

示例3: update

 static function update($schema = 'Myisam')
 {
     // force regeneration of cache files following #648
     Piwik::setUserIsSuperUser();
     $allSiteIds = API::getInstance()->getAllSitesId();
     Cache::regenerateCacheWebsiteAttributes($allSiteIds);
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:7,代码来源:0.2.34.php

示例4: setUpWebsites

 /**
  * One site with custom search parameters,
  * One site using default search parameters,
  * One site with disabled site search
  */
 private function setUpWebsites()
 {
     API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
     if (!self::siteCreated($idSite = 1)) {
         self::createWebsite(Date::factory($this->dateTime)->getDatetime(), 0, "Site 1 - Site search", $siteurl = false, $search = 1, $searchKwd = 'q,mykwd,p', $searchCat = 'cats');
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:12,代码来源:SomeVisitsWithNonUnicodePageTitles.php

示例5: setUpWebsitesAndGoals

 private function setUpWebsitesAndGoals()
 {
     $ecommerce = $this->allowConversions ? 1 : 0;
     // tests run in UTC, the Tracker in UTC
     if (!self::siteCreated($idSite = 1)) {
         self::createWebsite($this->dateTime, $ecommerce, "Site 1");
     }
     if (!self::siteCreated($idSite = 2)) {
         self::createWebsite($this->dateTime, 0, "Site 2");
     }
     if ($this->allowConversions) {
         if (!self::goalExists($idSite = 1, $idGoal = 1)) {
             APIGoals::getInstance()->addGoal($this->idSite1, 'all', 'url', 'http', 'contains', false, 5);
         }
         if (!self::goalExists($idSite = 1, $idGoal = 2)) {
             APIGoals::getInstance()->addGoal($this->idSite2, 'all', 'url', 'http', 'contains');
         }
         if (!self::goalExists($idSite = 1, $idGoal = 3)) {
             APIGoals::getInstance()->addGoal($this->idSite1, 'matching URL with campaign parameter', 'url', self::URL_IS_GOAL_WITH_CAMPAIGN_PARAMETERS, 'contains');
         }
     }
     APISitesManager::getInstance()->updateSite($this->idSite1, "Site 1", $urls = null, $ecommerce = null, $siteSearch = null, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 2);
     // KEEP_URL_FRAGMENT_NO No for idSite 1
     APISitesManager::getInstance()->updateSite($this->idSite2, "Site 2", $urls = null, $ecommerce = null, $siteSearch = null, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1);
     // KEEP_URL_FRAGMENT_YES Yes for idSite 2
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:26,代码来源:TwoSitesTwoVisitorsDifferentDays.php

示例6: setSiteManagerApiMock

 private function setSiteManagerApiMock()
 {
     $sitesInfo = $this->sitesInfo;
     $mock = $this->getMock('stdClass', array('getSiteFromId'));
     $mock->expects($this->any())->method('getSiteFromId')->willReturnCallback(function ($idSite) use($sitesInfo) {
         return $sitesInfo[$idSite];
     });
     SitesManagerAPI::setSingletonInstance($mock);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:HtmlTest.php

示例7: setUp

 public function setUp()
 {
     parent::setUp();
     // setup the access layer
     FakeAccess::$superUser = true;
     $this->idSiteAccess = APISitesManager::getInstance()->addSite("test", "http://test");
     \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'MobileMessaging', 'MultiSites'));
     \Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:MobileMessagingTest.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $access = Access::getInstance();
     $access->setSuperUserAccess(true);
     $this->idSiteAccess = APISitesManager::getInstance()->addSite("test", "http://test");
     \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('MultiSites', 'VisitsSummary', 'Actions'));
     \Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:9,代码来源:MultiSitesTest.php

示例9: index

 public function index()
 {
     $view = new View('@ScheduledReports/index');
     $this->setGeneralVariablesView($view);
     $view->countWebsites = count(APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess());
     // get report types
     $reportTypes = API::getReportTypes();
     $view->reportTypes = $reportTypes;
     $view->defaultReportType = self::DEFAULT_REPORT_TYPE;
     $view->defaultReportFormat = ScheduledReports::DEFAULT_REPORT_FORMAT;
     $view->displayFormats = ScheduledReports::getDisplayFormats();
     $reportsByCategoryByType = array();
     $reportFormatsByReportType = array();
     $allowMultipleReportsByReportType = array();
     foreach ($reportTypes as $reportType => $reportTypeIcon) {
         // get report formats
         $reportFormatsByReportType[$reportType] = API::getReportFormats($reportType);
         $allowMultipleReportsByReportType[$reportType] = API::allowMultipleReports($reportType);
         // get report metadata
         $reportsByCategory = array();
         $availableReportMetadata = API::getReportMetadata($this->idSite, $reportType);
         foreach ($availableReportMetadata as $reportMetadata) {
             $reportsByCategory[$reportMetadata['category']][] = $reportMetadata;
         }
         $reportsByCategoryByType[$reportType] = $reportsByCategory;
     }
     $view->reportsByCategoryByReportType = $reportsByCategoryByType;
     $view->reportFormatsByReportType = $reportFormatsByReportType;
     $view->allowMultipleReportsByReportType = $allowMultipleReportsByReportType;
     $reports = array();
     $reportsById = array();
     if (!Piwik::isUserIsAnonymous()) {
         $reports = API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
         foreach ($reports as &$report) {
             $report['recipients'] = API::getReportRecipients($report);
             $reportsById[$report['idreport']] = $report;
         }
     }
     $view->reports = $reports;
     $view->reportsJSON = Common::json_encode($reportsById);
     $view->downloadOutputType = API::OUTPUT_INLINE;
     $view->periods = ScheduledReports::getPeriodToFrequency();
     $view->defaultPeriod = ScheduledReports::DEFAULT_PERIOD;
     $view->defaultHour = ScheduledReports::DEFAULT_HOUR;
     $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
     $view->segmentEditorActivated = false;
     if (API::isSegmentEditorActivated()) {
         $savedSegmentsById = array();
         foreach (APISegmentEditor::getInstance()->getAll($this->idSite) as $savedSegment) {
             $savedSegmentsById[$savedSegment['idsegment']] = $savedSegment['name'];
         }
         $view->savedSegmentsById = $savedSegmentsById;
         $view->segmentEditorActivated = true;
     }
     return $view->render();
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:56,代码来源:Controller.php

示例10: trackVisits

 private function trackVisits()
 {
     if (!$this->trackInvalidRequests) {
         return;
     }
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
     API::getInstance()->setGlobalExcludedUserAgents('globalexcludeduseragent');
     // Trigger empty request
     $trackerUrl = self::getTrackerUrl();
     $response = Http::fetchRemoteFile($trackerUrl);
     self::assertTrue(strpos($response, 'is a free open source web') !== false, 'Piwik empty request response not correct: ' . $response);
     $t = self::getTracker($idSite, $dateTime, $defaultInit = true);
     // test GoogleBot UA visitor
     $t->setUserAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
     self::checkResponse($t->doTrackPageView('bot visit, please do not record'));
     // Test IP Exclusion works with or without IP exclusion
     foreach (array(false, true) as $enable) {
         $excludedIp = '154.1.12.34';
         API::getInstance()->updateSite($idSite, 'new site name', $url = array('http://site.com'), $ecommerce = 0, $ss = 1, $ss_kwd = '', $ss_cat = '', $excludedIp . ',1.2.3.4', $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = 'excludeduseragentstring');
         // Enable IP Anonymization
         $t->DEBUG_APPEND_URL = '&forceIpAnonymization=' . (int) $enable;
         // test with excluded User Agent
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729) (excludeduseragentstring)');
         $t->setIp('211.1.2.3');
         self::checkResponse($t->doTrackPageView('visit from excluded User Agent'));
         $t->setUserAgent('Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0 Google (+https://developers.google.com/+/web/snippet/)');
         self::checkResponse($t->doTrackPageView('visit from excluded User Agent'));
         // test w/ global excluded User Agent
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729) (globalexcludeduseragent)');
         $t->setIp('211.1.2.3');
         self::checkResponse($t->doTrackPageView('visit from global excluded User Agent'));
         // test with excluded IP
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)');
         // restore normal user agent
         $t->setIp($excludedIp);
         self::checkResponse($t->doTrackPageView('visit from IP excluded'));
         // test with global list of excluded IPs
         $excludedIpBis = '145.5.3.4';
         API::getInstance()->setGlobalExcludedIps($excludedIpBis);
         $t->setIp($excludedIpBis);
         self::checkResponse($t->doTrackPageView('visit from IP globally excluded'));
     }
     try {
         @$t->setAttributionInfo(array());
         self::fail();
     } catch (Exception $e) {
     }
     try {
         $t->setAttributionInfo(json_encode('test'));
         self::fail();
     } catch (Exception $e) {
     }
     $t->setAttributionInfo(json_encode(array()));
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:56,代码来源:InvalidVisits.php

示例11: makeVisitorAndAction

 private function makeVisitorAndAction($lastActionTimestamp, $currentActionTime, $isVisitorKnown = false)
 {
     $idsite = API::getInstance()->addSite("name", "http://piwik.net/");
     /** @var Request $request */
     list($visit, $request) = $this->prepareVisitWithRequest(array('idsite' => $idsite), $currentActionTime);
     $visitProperties = new VisitProperties();
     $visitProperties->setProperty('visit_last_action_time', Date::factory($lastActionTimestamp)->getTimestamp());
     $request->setMetadata('CoreHome', 'isVisitorKnown', $isVisitorKnown);
     return array($visit, $visitProperties, $request);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:10,代码来源:VisitRequestProcessorTest.php

示例12: setUp

 public function setUp()
 {
     parent::setUp();
     // setup the access layer
     self::setSuperUser();
     \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('API', 'UserCountry', 'ScheduledReports', 'MobileMessaging', 'VisitsSummary', 'Referrers'));
     \Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
     APISitesManager::getInstance()->addSite("Test", array("http://piwik.net"));
     APISitesManager::getInstance()->addSite("Test", array("http://piwik.net"));
     FakeAccess::setIdSitesView(array($this->idSite, 2));
     APIScheduledReports::$cache = array();
 }
开发者ID:JoeHorn,项目名称:piwik,代码行数:12,代码来源:ApiTest.php

示例13: validateOwner

 function validateOwner()
 {
     try {
         $timezone = $this->owner->getValue();
         if (!empty($timezone)) {
             API::getInstance()->setDefaultTimezone($timezone);
         }
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:12,代码来源:FormFirstWebsiteSetup.php

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     // setup the access layer
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = true;
     //finally we set the user as a Super User by default
     Access::setSingletonInstance($pseudoMockAccess);
     $this->idSiteAccess = APISitesManager::getInstance()->addSite("test", "http://test");
     \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'MobileMessaging', 'MultiSites'));
     \Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:12,代码来源:MobileMessagingTest.php

示例15: getDefaultWebsiteId

 /**
  * Returns default site ID that Piwik should load.
  *
  * _Note: This value is a Piwik setting set by each user._
  *
  * @return bool|int
  * @api
  */
 public function getDefaultWebsiteId()
 {
     $defaultReport = $this->getDefaultReport();
     if (is_numeric($defaultReport) && Piwik::isUserHasViewAccess($defaultReport)) {
         return $defaultReport;
     }
     $sitesId = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
     if (!empty($sitesId)) {
         return $sitesId[0];
     }
     return false;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:20,代码来源:UserPreferences.php


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