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


PHP API::getInstance方法代码示例

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


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

示例1: __construct

 public function __construct(Translator $translator)
 {
     parent::__construct();
     $this->translator = $translator;
     $this->idSite = Common::getRequestVar('idSite', null, 'int');
     $this->goals = API::getInstance()->getGoals($this->idSite);
 }
开发者ID:piwik,项目名称:piwik,代码行数:7,代码来源:Controller.php

示例2: setUpGoals

 protected function setUpGoals()
 {
     $api = Goals\API::getInstance();
     foreach ($this->goals as $goal) {
         $api->addGoal($this->idSite, $goal['name'], $goal['match'], $goal['pattern'], $goal['patternType'], $caseSensitive = false, $goal['revenue'], $allowMultipleConversionsPerVisit = false);
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:WidgetizeFixture.php

示例3: configureReportingMenu

 public function configureReportingMenu(MenuReporting $menu)
 {
     $idSite = $this->getIdSite();
     $goals = API::getInstance()->getGoals($idSite);
     $mainGoalMenu = 'Goals_Goals';
     if (count($goals) == 0) {
         $linkToAddNewGoal = $this->urlForAction('addNewGoal', array('idGoal' => null));
         $menu->addItem($mainGoalMenu, '', $linkToAddNewGoal, 25);
         $menu->addItem($mainGoalMenu, 'Goals_AddNewGoal', $linkToAddNewGoal, 1);
         return;
     }
     $order = 1;
     $url = $this->urlForAction('index', array('idGoal' => null));
     $menu->addItem($mainGoalMenu, '', $url, 25);
     $menu->addItem($mainGoalMenu, 'General_Overview', $url, ++$order);
     $group = new Group();
     foreach ($goals as $goal) {
         $subMenuName = str_replace('%', '%%', Translate::clean($goal['name']));
         $params = $this->urlForAction('goalReport', array('idGoal' => $goal['idgoal']));
         $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']);
         if (count($goals) > 3) {
             $group->add($subMenuName, $params, $tooltip);
         } else {
             $menu->addItem($mainGoalMenu, $subMenuName, $params, ++$order, $tooltip);
         }
     }
     if (count($goals) > 3) {
         $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, ++$order, $tooltip = false);
     }
     $menu->addItem($mainGoalMenu, 'Goals_ManageGoals', $this->urlForAction('editGoals'), ++$order);
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:31,代码来源:Menu.php

示例4: trackVisits

 private function trackVisits()
 {
     $dateTime = $this->dateTime;
     $idSite = 1;
     $idGoal_OneConversionPerVisit = $this->idGoal_OneConversionPerVisit;
     $idGoal_MultipleConversionPerVisit = $this->idGoal_MultipleConversionPerVisit;
     $t = self::getTracker($idSite, $dateTime, $defaultInit = true);
     // Record 1st goal, should only have 1 conversion
     $t->setUrl('http://example.org/index.htm');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.3)->getDatetime());
     self::checkResponse($t->doTrackPageView('Thank you mate'));
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.4)->getDatetime());
     self::checkResponse($t->doTrackGoal($idGoal_OneConversionPerVisit, $revenue = 10000000));
     // Record 2nd goal, should record both conversions
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.5)->getDatetime());
     self::checkResponse($t->doTrackGoal($idGoal_MultipleConversionPerVisit, $revenue = 300));
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.6)->getDatetime());
     self::checkResponse($t->doTrackGoal($idGoal_MultipleConversionPerVisit, $revenue = 366));
     // Update & set to not allow multiple
     $goals = API::getInstance()->getGoals($idSite);
     $goal = $goals[$idGoal_OneConversionPerVisit];
     self::assertTrue($goal['allow_multiple'] == 0);
     API::getInstance()->updateGoal($idSite, $idGoal_OneConversionPerVisit, $goal['name'], @$goal['match_attribute'], @$goal['pattern'], @$goal['pattern_type'], @$goal['case_sensitive'], $goal['revenue'], $goal['allow_multiple'] = 1);
     self::assertTrue($goal['allow_multiple'] == 1);
     // 1st goal should Now be tracked
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.61)->getDatetime());
     self::checkResponse($t->doTrackGoal($idGoal_OneConversionPerVisit, $revenue = 656));
     // few minutes later, create a new_visit
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.7)->getDatetime());
     $t->setTokenAuth($this->getTokenAuth());
     $t->setForceNewVisit();
     $t->doTrackPageView('This is tracked in a new visit.');
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:33,代码来源:SomeVisitsAllConversions.php

示例5: trackVisits

 private function trackVisits()
 {
     // tests run in UTC, the Tracker in UTC
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     $t = self::getTracker($idSite, $dateTime, $defaultInit = true);
     // Also testing to record this as a bot while specifically allowing bots
     $t->setUserAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
     $t->DEBUG_APPEND_URL .= '&bots=1';
     $t->DEBUG_APPEND_URL .= '&forceIpAnonymization=1';
     // VISIT 1 = Referrer is "Keyword not defined"
     // Alsotrigger goal to check that attribution goes to this keyword
     $t->setUrlReferrer('http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC&url=http%3A%2F%2Fpiwik.org%2F&ei=&usg=');
     $t->setUrl('http://example.org/this%20is%20cool!?filter=<script>alert(1);</script>{"place":{"place":"0c5b2444-70a0-4932-980c-b4dc0d3f02b5"}}');
     self::checkResponse($t->doTrackPageView('incredible title! (Page URL contains a HTML entity)'));
     $idGoal = 1;
     if (!self::goalExists($idSite, $idGoal)) {
         $idGoal = API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
     }
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.3)->getDatetime());
     self::checkResponse($t->doTrackGoal($idGoal, $revenue = 42));
     // VISIT 2 = Referrer has keyword, but the URL should be rewritten
     // in Live Output to point to google search result page
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(2)->getDatetime());
     $t->setUrlReferrer('http://www.google.com.vn/url?sa=t&rct=j&q=%3C%3E%26%5C%22the%20pdo%20extension%20is%20required%20for%20this%20adapter%20but%20the%20extension%20is%20not%20loaded&source=web&cd=4&ved=0FjAD&url=http%3A%2F%2Fforum.piwik.org%2Fread.php%3F2%2C1011&ei=y-HHAQ&usg=AFQjCN2-nt5_GgDeg&cad=rja');
     // Test with empty title, that the output of Live is valid
     self::checkResponse($t->doTrackPageView(''));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:28,代码来源:TwoVisitsNoKeywordWithBot.php

示例6: getGoalsForIdSite

 private function getGoalsForIdSite($idSite)
 {
     if (empty($idSite)) {
         return array();
     }
     return API::getInstance()->getGoals($idSite);
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:7,代码来源:Base.php

示例7: configureReportingMenu

 public function configureReportingMenu(MenuReporting $menu)
 {
     $idSite = Common::getRequestVar('idSite', null, 'int');
     $goals = API::getInstance()->getGoals($idSite);
     $mainGoalMenu = $this->getGoalCategoryName($idSite);
     $site = new Site($idSite);
     if (count($goals) == 0) {
         $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25);
         if ($site->isEcommerceEnabled()) {
             $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1);
         }
         $menu->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal'));
     } else {
         $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'index', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25);
         if ($site->isEcommerceEnabled()) {
             $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1);
         }
         $menu->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2);
         $group = new Group();
         foreach ($goals as $goal) {
             $subMenuName = str_replace('%', '%%', Translate::clean($goal['name']));
             $params = array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal']);
             $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']);
             if (count($goals) <= 3) {
                 $menu->add($mainGoalMenu, $subMenuName, $params, true, 50, $tooltip);
             } else {
                 $group->add($subMenuName, $params, $tooltip);
             }
         }
         if (count($goals) > 3) {
             $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, $orderId = 50, $tooltip = false);
         }
     }
 }
开发者ID:emersonmatsumoto,项目名称:piwik,代码行数:34,代码来源:Menu.php

示例8: setUp

 public function setUp()
 {
     // add one site
     Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
     // add two goals
     $goals = API::getInstance();
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
     $goals->addGoal($this->idSite, 'all', 'url', 'thing2', 'contains');
     $start = Date::factory($this->date);
     $dates = array();
     for ($day = 0; $day != 31; ++$day) {
         $dates[] = $start->addDay($day);
     }
     $t = BenchmarkTestCase::getLocalTracker($this->idSite);
     $actionNum = 0;
     foreach ($dates as $date) {
         for ($visitNum = 0; $visitNum != 1000; ++$visitNum) {
             if ($visitNum % 2 == 0) {
                 $url = "http://whatever.com/{$actionNum}/0/1/2/3/4/5/6/7/8/9";
                 $referrerUrl = "http://google.com/?q={$actionNum}";
             } else {
                 $url = "http://whatever.com/thing2/{$actionNum}/0/1/2/3/4/5/6/7/8/9";
                 $referrerUrl = "http://";
             }
             $title = "A page title / {$actionNum} / 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 /9";
             $t->setNewVisitorId();
             $t->setForceVisitDateTime($date);
             $t->setUrl($url);
             $t->setUrlReferrer($referrerUrl);
             Fixture::checkResponse($t->doTrackPageView($title));
             ++$actionNum;
         }
     }
 }
开发者ID:Abine,项目名称:piwik,代码行数:34,代码来源:OneSiteThousandsOfDistinctUrlsOverMonth.php

示例9: getSparklines

 public function getSparklines()
 {
     $idGoal = Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
     $view = new View('@Ecommerce/getSparklines');
     $view->onlyConversionOverview = false;
     $view->conversionsOverViewEnabled = true;
     if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
         $goalDefinition['name'] = $this->translator->translate('Goals_Ecommerce');
         $goalDefinition['allow_multiple'] = true;
     } else {
         $goals = GoalsApi::getInstance()->getGoals($this->idSite);
         if (!isset($goals[$idGoal])) {
             Piwik::redirectToModule('Goals', 'index', array('idGoal' => null));
         }
         $goalDefinition = $goals[$idGoal];
     }
     $this->setGeneralVariablesView($view);
     $goal = $this->getMetricsForGoal($idGoal);
     foreach ($goal as $name => $value) {
         $view->{$name} = $value;
     }
     if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
         $goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
         foreach ($goal as $name => $value) {
             $name = 'cart_' . $name;
             $view->{$name} = $value;
         }
     }
     $view->idGoal = $idGoal;
     $view->goalAllowMultipleConversionsPerVisit = $goalDefinition['allow_multiple'];
     return $view->render();
 }
开发者ID:piwik,项目名称:piwik,代码行数:32,代码来源:Controller.php

示例10: 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

示例11: realtimeMap

 /**
  * @param bool $standalone When set to true, the Top controls will be hidden to provide better full screen view
  * @param bool $fetch
  * @param bool|string $segmentOverride
  *
  * @return string
  */
 public function realtimeMap($standalone = false, $fetch = false, $segmentOverride = false)
 {
     $this->checkUserCountryPluginEnabled();
     $idSite = Common::getRequestVar('idSite', 1, 'int');
     Piwik::checkUserHasViewAccess($idSite);
     $token_auth = Piwik::getCurrentUserTokenAuth();
     $view = new View('@UserCountryMap/realtimeMap');
     $view->mapIsStandaloneNotWidget = $standalone;
     $view->metrics = $this->getMetrics($idSite, 'range', self::REAL_TIME_WINDOW, $token_auth);
     $view->defaultMetric = 'nb_visits';
     $liveRefreshAfterMs = (int) Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
     $goals = APIGoals::getInstance()->getGoals($idSite);
     $site = new Site($idSite);
     $hasGoals = !empty($goals) || $site->isEcommerceEnabled();
     // maximum number of visits to be displayed in the map
     $maxVisits = Common::getRequestVar('filter_limit', 100, 'int');
     // some translations
     $locale = array('nb_actions' => Piwik::translate('VisitsSummary_NbActionsDescription'), 'local_time' => Piwik::translate('VisitTime_ColumnLocalTime'), 'from' => Piwik::translate('General_FromReferrer'), 'seconds' => Piwik::translate('UserCountryMap_Seconds'), 'seconds_ago' => Piwik::translate('UserCountryMap_SecondsAgo'), 'minutes' => Piwik::translate('UserCountryMap_Minutes'), 'minutes_ago' => Piwik::translate('UserCountryMap_MinutesAgo'), 'hours' => Piwik::translate('UserCountryMap_Hours'), 'hours_ago' => Piwik::translate('UserCountryMap_HoursAgo'), 'days_ago' => Piwik::translate('UserCountryMap_DaysAgo'), 'actions' => Piwik::translate('VisitsSummary_NbPageviewsDescription'), 'searches' => Piwik::translate('UserCountryMap_Searches'), 'goal_conversions' => Piwik::translate('UserCountryMap_GoalConversions'));
     $segment = $segmentOverride ?: Request::getRawSegmentFromRequest() ?: '';
     $params = array('period' => 'range', 'idSite' => $idSite, 'segment' => $segment, 'token_auth' => $token_auth);
     $realtimeWindow = Common::getRequestVar('realtimeWindow', self::REAL_TIME_WINDOW, 'string');
     if ($realtimeWindow != 'false') {
         // handle special value
         $params['date'] = $realtimeWindow;
     }
     $reqParams = $this->getEnrichedRequest($params, $encode = false);
     $view->config = array('metrics' => array(), 'svgBasePath' => $view->piwikUrl . 'plugins/UserCountryMap/svg/', 'liveRefreshAfterMs' => $liveRefreshAfterMs, '_' => $locale, 'reqParams' => $reqParams, 'siteHasGoals' => $hasGoals, 'maxVisits' => $maxVisits, 'changeVisitAlpha' => Common::getRequestVar('changeVisitAlpha', true, 'int'), 'removeOldVisits' => Common::getRequestVar('removeOldVisits', true, 'int'), 'showFooterMessage' => Common::getRequestVar('showFooterMessage', true, 'int'), 'showDateTime' => Common::getRequestVar('showDateTime', true, 'int'), 'doNotRefreshVisits' => Common::getRequestVar('doNotRefreshVisits', false, 'int'), 'enableAnimation' => Common::getRequestVar('enableAnimation', true, 'int'), 'forceNowValue' => Common::getRequestVar('forceNowValue', false, 'int'));
     return $view->render();
 }
开发者ID:Abine,项目名称:piwik,代码行数:36,代码来源:Controller.php

示例12: getVisitorProfilePopup

 /**
  * Echo's HTML for visitor profile popup.
  */
 public function getVisitorProfilePopup()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $idSite = Common::getRequestVar('idSite', null, 'int');
     $gotoChat = Common::getRequestVar('chat', '0', 'int');
     $idvisitor = Common::getRequestVar('visitorId', null, 'string');
     if (!$gotoChat) {
         $gotoChat = isset($_SESSION['chatViewByDefault']) ? $_SESSION['chatViewByDefault'] : false;
     }
     $conversation = new ChatConversation($idSite, $idvisitor);
     $messages = $conversation->getAllMessages();
     $infos = ChatPersonnalInformation::get($idvisitor);
     if (count($messages) > 0) {
         $lastMsgIndex = count($messages) - 1;
         ChatAcknowledgment::setLastViewed($idvisitor, $messages[$lastMsgIndex]['microtime'], Piwik::getCurrentUserLogin());
     }
     $view = new View('@Chat/getVisitorProfilePopup.twig');
     $view->idSite = $idSite;
     $view->chat = $gotoChat;
     $view->goals = APIGoals::getInstance()->getGoals($idSite);
     $view->visitorData = Request::processRequest('Live.getVisitorProfile', array('checkForLatLong' => true));
     $view->exportLink = $this->getVisitorProfileExportLink();
     $view->messages = $messages;
     $view->infos = $infos;
     if (Common::getRequestVar('showMap', 1) == 1 && !empty($view->visitorData['hasLatLong']) && \Piwik\Plugin\Manager::getInstance()->isPluginLoaded('UserCountryMap')) {
         $view->userCountryMapUrl = $this->getUserCountryMapUrlForVisitorProfile();
     }
     $this->setWidgetizedVisitorProfileUrl($view);
     return $view->render();
 }
开发者ID:WHATNEXTLIMITED,项目名称:piwik-chat,代码行数:33,代码来源:Controller.php

示例13: setUp

 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:7,代码来源:APITest.php

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
     Fixture::createAccessInstance();
     Piwik::setUserHasSuperUserAccess();
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
 }
开发者ID:cemo,项目名称:piwik,代码行数:9,代码来源:APITest.php

示例15: setUpWebsitesAndGoals

 private function setUpWebsitesAndGoals()
 {
     if (!self::siteCreated($idSite = 1)) {
         self::createWebsite($this->dateTime);
     }
     if (!self::goalExists($idSite = 1, $idGoal = 1)) {
         API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:9,代码来源:SomeVisitsCustomVariablesCampaignsNotHeuristics.php


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