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


PHP Piwik::addAction方法代码示例

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


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

示例1: test_makeLogVisitsQueryString_withMultipleIdSites

 public function test_makeLogVisitsQueryString_withMultipleIdSites()
 {
     Piwik::addAction('Live.API.getIdSitesString', function (&$idSites) {
         $idSites = array(2, 3, 4);
     });
     $model = new Model();
     list($sql, $bind) = $model->makeLogVisitsQueryString($idSite = 1, $period = 'month', $date = '2010-01-01', $segment = false, $offset = 0, $limit = 100, $visitorId = false, $minTimestamp = false, $filterSortOrder = false);
     $expectedSql = ' SELECT sub.* FROM
             (
                 SELECT log_visit.*
                 FROM ' . Common::prefixTable('log_visit') . ' AS log_visit
                 WHERE log_visit.idsite in (?,?,?)
                   AND log_visit.visit_last_action_time >= ?
                   AND log_visit.visit_last_action_time <= ?
                 ORDER BY visit_last_action_time DESC
                 LIMIT 0, 100
              ) AS sub
              GROUP BY sub.idvisit
              ORDER BY sub.visit_last_action_time DESC
              LIMIT 100
     ';
     $expectedBind = array('2', '3', '4', '2010-01-01 00:00:00', '2010-02-01 00:00:00');
     $this->assertEquals(SegmentTest::removeExtraWhiteSpaces($expectedSql), SegmentTest::removeExtraWhiteSpaces($sql));
     $this->assertEquals(SegmentTest::removeExtraWhiteSpaces($expectedBind), SegmentTest::removeExtraWhiteSpaces($bind));
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:25,代码来源:ModelTest.php

示例2: setupTestEnvironment

 public function setupTestEnvironment($environment)
 {
     Piwik::addAction("MySQLMetadataProvider.createDao", function (&$dao) {
         require_once dirname(__FILE__) . "/tests/Mocks/MockDataAccess.php";
         $dao = new Mocks\MockDataAccess();
     });
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:7,代码来源:DBStats.php

示例3: setUp

 public function setUp()
 {
     parent::setUp();
     $self = $this;
     Piwik::addAction('API.Request.dispatch.end', function (&$return, $extra) use($self) {
         if ($extra['module'] !== 'Events') {
             return;
         }
         /** @var DataTable $return*/
         // we make sure processed result is the same at any time
         foreach ($return as &$value) {
             $value->setColumn('sum_event_value', '2');
             $value->setColumn('max_event_value', '2');
             $value->setColumn('min_event_value', '2');
             $value->setColumn('sum_daily_nb_uniq_visitors', '2');
             $value->setColumn('avg_event_value', '2');
             if ($value->isSubtableLoaded()) {
                 $subtable = $value->getSubtable();
                 foreach ($subtable->getRows() as $row) {
                     $row->setColumn('sum_event_value', '2');
                     $row->setColumn('max_event_value', '2');
                     $row->setColumn('min_event_value', '2');
                     $row->setColumn('sum_daily_nb_uniq_visitors', '2');
                     $row->setColumn('avg_event_value', '2');
                 }
             }
         }
     });
 }
开发者ID:andrzejewsky,项目名称:plugin-AnonymousPiwikUsageMeasurement,代码行数:29,代码来源:TasksTest.php

示例4: test_make_shouldTriggerExceptionInCaseWrongInstanceCreatedInHandler

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage The Visit object set in the plugin
  */
 public function test_make_shouldTriggerExceptionInCaseWrongInstanceCreatedInHandler()
 {
     Piwik::addAction('Tracker.makeNewVisitObject', function (&$visit) {
         $visit = new Tracker();
     });
     Factory::make();
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:FactoryTest.php

示例5: setUp

 public static function setUp()
 {
     Piwik::addAction('Log.formatFileMessage', array('\\Piwik\\ExceptionHandler', 'formatFileAndDBLogMessage'));
     Piwik::addAction('Log.formatDatabaseMessage', array('\\Piwik\\ExceptionHandler', 'formatFileAndDBLogMessage'));
     Piwik::addAction('Log.formatScreenMessage', array('\\Piwik\\ExceptionHandler', 'formatScreenMessage'));
     set_exception_handler(array('\\Piwik\\ExceptionHandler', 'logException'));
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:7,代码来源:ExceptionHandler.php

示例6: postLoad

 public function postLoad()
 {
     if (PluginManager::getInstance()->isPluginActivated('UserCountry')) {
         WidgetsList::add('General_Visitors', Piwik::translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap');
         WidgetsList::add('Live!', Piwik::translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap');
     }
     Piwik::addAction('Template.leftColumnUserCountry', array('Piwik\\Plugins\\UserCountryMap\\UserCountryMap', 'insertMapInLocationReport'));
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:8,代码来源:UserCountryMap.php

示例7: test_setUserAccess_ShouldNotTriggerRemoveSiteAccessEvent_IfAccessIsAdded

 public function test_setUserAccess_ShouldNotTriggerRemoveSiteAccessEvent_IfAccessIsAdded()
 {
     $eventTriggered = false;
     Piwik::addAction('UsersManager.removeSiteAccess', function () use(&$eventTriggered) {
         $eventTriggered = true;
     });
     $this->api->setUserAccess($this->login, 'admin', array(1, 2));
     $this->assertFalse($eventTriggered, 'UsersManager.removeSiteAccess event was triggered but should not');
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:APITest.php

示例8: testJavascriptTrackingCode_withAllOptionsAndOptionsBeforeTrackerUrl

 /**
  * Tests the generated JS code with options before tracker url
  */
 public function testJavascriptTrackingCode_withAllOptionsAndOptionsBeforeTrackerUrl()
 {
     $generator = new TrackerCodeGenerator();
     Piwik::addAction('Piwik.getJavascriptCode', function (&$codeImpl) {
         $codeImpl['optionsBeforeTrackerUrl'] .= "_paq.push(['setAPIUrl', 'http://localhost/statistics']);\n    ";
     });
     $jsTag = $generator->generate($idSite = 1, $piwikUrl = 'http://localhost/piwik', $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), $pageCustomVariables = array(array("page cvar", "page cvar value")), $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", $doNotTrack = true);
     $expected = "&lt;!-- Piwik --&gt;\n&lt;script type=&quot;text/javascript&quot;&gt;\n  var _paq = _paq || [];\n  _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]);\n  // you can set up to 5 custom variables for each visitor\n  _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]);\n  _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]);\n  // you can set up to 5 custom variables for each action (page view, download, click, site search)\n  _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]);\n  _paq.push([\"setCampaignNameKey\", \"campaignKey\"]);\n  _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]);\n  _paq.push([\"setDoNotTrack\", true]);\n  _paq.push(['trackPageView']);\n  _paq.push(['enableLinkTracking']);\n  (function() {\n    var u=&quot;//localhost/piwik/&quot;;\n    _paq.push(['setAPIUrl', 'http://localhost/statistics']);\n    _paq.push(['setTrackerUrl', u+'piwik.php']);\n    _paq.push(['setSiteId', 1]);\n    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];\n    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);\n  })();\n&lt;/script&gt;\n&lt;noscript&gt;&lt;p&gt;&lt;img src=&quot;//localhost/piwik/piwik.php?idsite=1&quot; style=&quot;border:0;&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&lt;/noscript&gt;\n&lt;!-- End Piwik Code --&gt;\n";
     $this->assertEquals($expected, $jsTag);
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:13,代码来源:TrackerCodeGeneratorTest.php

示例9: test_getMenu_shouldTriggerAddItemsEvent_toBeBackwardsCompatible

 public function test_getMenu_shouldTriggerAddItemsEvent_toBeBackwardsCompatible()
 {
     $this->loadSomePlugins();
     $triggered = false;
     Piwik::addAction('Menu.Reporting.addItems', function () use(&$triggered) {
         $triggered = true;
     });
     $this->menu->getMenu();
     $this->assertTrue($triggered);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:10,代码来源:MenuReportingTest.php

示例10: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $extraSite = Fixture::createWebsite(self::$fixture->dateTime, $ecommerce = 1, "the site");
     Piwik::addAction("ArchiveProcessor.Parameters.getIdSites", function (&$sites, $period) use($extraSite) {
         if (reset($sites) == $extraSite) {
             $sites = array(1, 2, 3);
         }
     });
     Config::getInstance()->General['enable_processing_unique_visitors_multiple_sites'] = 1;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:11,代码来源:MultipleSitesArchivingTest.php

示例11: populateCache

 private static function populateCache()
 {
     if (Development::isEnabled()) {
         return;
     }
     if (SettingsServer::isTrackerApiRequest()) {
         $eventToPersist = 'Tracker.end';
         $mode = '-tracker';
     } else {
         $eventToPersist = 'Request.dispatch.end';
         $mode = '-ui';
     }
     $cache = self::getStorage()->get(self::getCacheFilename() . $mode);
     if (is_array($cache)) {
         self::$content = $cache;
     }
     Piwik::addAction($eventToPersist, array(__CLASS__, 'persistCache'));
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:18,代码来源:PersistentCache.php

示例12: test_initRequestsAndTokednAuth_shouldInitializeFromGetAndPostIfEventDoesNotHandleRequests

 public function test_initRequestsAndTokednAuth_shouldInitializeFromGetAndPostIfEventDoesNotHandleRequests()
 {
     $_GET = array('idsite' => 1);
     $_POST = array('c_i' => 'click');
     Piwik::addAction('Tracker.initRequestSet', function (RequestSet $requestSet) {
         $requestSet->setRequests(array(array('idsite' => '2'), array('idsite' => '3')));
     });
     $requestSet = $this->buildNewRequestSetThatIsNotInitializedYet();
     $requestSet->initRequestsAndTokenAuth();
     $requests = $requestSet->getRequests();
     $this->assertCount(2, $requests);
     $this->assertEquals(array('idsite' => '2'), $requests[0]->getParams());
     $this->assertEquals(array('idsite' => '3'), $requests[1]->getParams());
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:14,代码来源:RequestSetTest.php

示例13: testRunTasks

 /**
  * @group Core
  * 
  * @dataProvider testRunTasksTestCases
  */
 public function testRunTasks($expectedTimetable, $expectedExecutedTasks, $timetableBeforeTaskExecution, $configuredTasks)
 {
     // temporarily unload plugins
     $plugins = \Piwik\Plugin\Manager::getInstance()->getLoadedPlugins();
     $plugins = array_map(function ($p) {
         return $p->getPluginName();
     }, $plugins);
     \Piwik\Plugin\Manager::getInstance()->unloadPlugins();
     // make sure the get tasks event returns our configured tasks
     \Piwik\Piwik::addAction(TaskScheduler::GET_TASKS_EVENT, function (&$tasks) use($configuredTasks) {
         $tasks = $configuredTasks;
     });
     // stub the piwik option object to control the returned option value
     self::stubPiwikOption(serialize($timetableBeforeTaskExecution));
     TaskScheduler::unsetInstance();
     // execute tasks
     $executionResults = TaskScheduler::runTasks();
     // assert methods are executed
     $executedTasks = array();
     foreach ($executionResults as $executionResult) {
         $executedTasks[] = $executionResult['task'];
         $this->assertNotEmpty($executionResult['output']);
     }
     $this->assertEquals($expectedExecutedTasks, $executedTasks);
     // assert the timetable is correctly updated
     $timetable = new ScheduledTaskTimetable();
     $this->assertEquals($expectedTimetable, $timetable->getTimetable());
     // restore loaded plugins & piwik options
     EventDispatcher::getInstance()->clearObservers(TaskScheduler::GET_TASKS_EVENT);
     \Piwik\Plugin\Manager::getInstance()->loadPlugins($plugins);
     self::resetPiwikOption();
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:37,代码来源:TaskSchedulerTest.php

示例14: postLoad

 function postLoad()
 {
     Piwik::addAction('Template.footerVisitsFrequency', array('Piwik\\Plugins\\VisitorInterest\\VisitorInterest', 'footerVisitsFrequency'));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:4,代码来源:VisitorInterest.php

示例15: setupTestEnvironment

 public function setupTestEnvironment($environment)
 {
     Piwik::addAction("MySQLMetadataProvider.createDao", function (&$dao) {
         $dao = new MockDataAccess();
     });
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:6,代码来源:DBStats.php


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