php Piwik-Date类(方法)实例源码

下面列出了php Piwik-Date 类(方法)源码代码实例,从而了解它的用法。

作者:jos    项目:CGE-File-Sharin   
/**
  * @param string $format
  * @param \Piwik\Date $dateStart
  * @param \Piwik\Date $dateEnd
  *
  * @return mixed
  */
 protected static function getTranslatedRange($format, $dateStart, $dateEnd)
 {
     $string = str_replace('From%', '%', $format);
     $string = $dateStart->getLocalized($string);
     $string = str_replace('To%', '%', $string);
     $string = $dateEnd->getLocalized($string);
     return $string;
 }

作者:carriercom    项目:piwi   
protected static function getTable(Date $date, $type)
 {
     $tableNamePrefix = "archive_" . $type;
     $tableName = $tableNamePrefix . "_" . $date->toString('Y_m');
     $tableName = Common::prefixTable($tableName);
     self::createArchiveTablesIfAbsent($tableName, $tableNamePrefix);
     return $tableName;
 }

作者:andrzejewsk    项目:plugin-CustomAlert   
public function test_deleteAlertsForWebsite()
 {
     $this->createAlert('Initial1', array(), array(2));
     $this->createAlert('Initial2', array(), array(1, 2, 3));
     $this->createAlert('Initial3', array(), array(1));
     $this->createAlert('Initial4', array(), array(1, 3));
     $this->createAlert('Initial5', array(), array(2));
     $this->createAlert('Initial6', array(), array(2));
     $this->model->triggerAlert(1, 1, 99, 48, Date::now()->getDatetime());
     $this->model->triggerAlert(1, 2, 99, 48, Date::now()->getDatetime());
     $this->model->triggerAlert(2, 3, 99, 48, Date::now()->getDatetime());
     $this->model->triggerAlert(3, 2, 99, 48, Date::now()->getDatetime());
     $alerts = $this->model->getTriggeredAlerts(array(1, 2, 3), 'superUserLogin');
     $this->assertCount(4, $alerts);
     $this->plugin->deleteAlertsForSite(2);
     $alerts = $this->model->getAllAlerts();
     $this->assertCount(6, $alerts);
     $this->assertEquals($alerts[0]['id_sites'], array());
     $this->assertEquals($alerts[1]['id_sites'], array(1, 3));
     $this->assertEquals($alerts[2]['id_sites'], array(1));
     $this->assertEquals($alerts[3]['id_sites'], array(1, 3));
     $this->assertEquals($alerts[4]['id_sites'], array());
     $this->assertEquals($alerts[5]['id_sites'], array());
     $alerts = $this->model->getTriggeredAlerts(array(1, 2, 3), 'superUserLogin');
     $this->assertCount(2, $alerts);
 }

作者:CaptainShar    项目:SSAD_Projec   
/**
  * Controller action that returns HTML displaying annotations for a site and
  * specific date range.
  *
  * Query Param Input:
  *  - idSite: The ID of the site to get annotations for. Only one allowed.
  *  - date: The date to get annotations for. If lastN is not supplied, this is the start date,
  *          otherwise the start date in the last period.
  *  - period: The period type.
  *  - lastN: If supplied, the last N # of periods will be included w/ the range specified
  *           by date + period.
  *
  * Output:
  *  - HTML displaying annotations for a specific range.
  *
  * @param bool $fetch True if the annotation manager should be returned as a string,
  *                    false if it should be echo-ed.
  * @param bool|string $date Override for 'date' query parameter.
  * @param bool|string $period Override for 'period' query parameter.
  * @param bool|string $lastN Override for 'lastN' query parameter.
  * @return string|void
  */
 public function getAnnotationManager($fetch = false, $date = false, $period = false, $lastN = false)
 {
     $idSite = Common::getRequestVar('idSite');
     if ($date === false) {
         $date = Common::getRequestVar('date', false);
     }
     if ($period === false) {
         $period = Common::getRequestVar('period', 'day');
     }
     if ($lastN === false) {
         $lastN = Common::getRequestVar('lastN', false);
     }
     // create & render the view
     $view = new View('@Annotations/getAnnotationManager');
     $allAnnotations = Request::processRequest('Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN));
     $view->annotations = empty($allAnnotations[$idSite]) ? array() : $allAnnotations[$idSite];
     $view->period = $period;
     $view->lastN = $lastN;
     list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
     $view->startDate = $startDate->toString();
     $view->endDate = $endDate->toString();
     if ($startDate->toString() !== $endDate->toString()) {
         $view->selectedDate = Date::today()->toString();
     } else {
         $view->selectedDate = $endDate->toString();
     }
     $dateFormat = Piwik::translate('CoreHome_ShortDateFormatWithYear');
     $view->startDatePretty = $startDate->getLocalized($dateFormat);
     $view->endDatePretty = $endDate->getLocalized($dateFormat);
     $view->canUserAddNotes = AnnotationList::canUserAddNotesFor($idSite);
     return $view->render();
 }

作者:Abin    项目:piwi   
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;
         }
     }
 }

作者:diosmosi    项目:piwi   
/**
  * Computes the output for the given data table
  *
  * @param DataTable $table
  * @return string
  * @throws Exception
  */
 protected function renderTable($table)
 {
     if (!$table instanceof DataTable\Map || $table->getKeyName() != 'date') {
         throw new Exception("RSS feeds can be generated for one specific website &idSite=X." . "\nPlease specify only one idSite or consider using &format=XML instead.");
     }
     $idSite = Common::getRequestVar('idSite', 1, 'int');
     $period = Common::getRequestVar('period');
     $piwikUrl = SettingsPiwik::getPiwikUrl() . "?module=CoreHome&action=index&idSite=" . $idSite . "&period=" . $period;
     $out = "";
     $moreRecentFirst = array_reverse($table->getDataTables(), true);
     foreach ($moreRecentFirst as $date => $subtable) {
         /** @var DataTable $subtable */
         $timestamp = $subtable->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart()->getTimestamp();
         $site = $subtable->getMetadata(Archive\DataTableFactory::TABLE_METADATA_SITE_INDEX);
         $pudDate = date('r', $timestamp);
         $dateInSiteTimezone = Date::factory($timestamp);
         if ($site) {
             $dateInSiteTimezone = $dateInSiteTimezone->setTimezone($site->getTimezone());
         }
         $dateInSiteTimezone = $dateInSiteTimezone->toString('Y-m-d');
         $thisPiwikUrl = Common::sanitizeInputValue($piwikUrl . "&date={$dateInSiteTimezone}");
         $siteName = $site ? $site->getName() : '';
         $title = $siteName . " on " . $date;
         $out .= "\t<item>\n\t\t<pubDate>{$pudDate}</pubDate>\n\t\t<guid>{$thisPiwikUrl}</guid>\n\t\t<link>{$thisPiwikUrl}</link>\n\t\t<title>{$title}</title>\n\t\t<author>http://piwik.org</author>\n\t\t<description>";
         $out .= Common::sanitizeInputValue($this->renderDataTable($subtable));
         $out .= "</description>\n\t</item>\n";
     }
     $header = $this->getRssHeader();
     $footer = $this->getRssFooter();
     return $header . $out . $footer;
 }

作者:carriercom    项目:piwi   
private function trackVisits()
 {
     $dateTimes = $this->dateTimes;
     $days = 0;
     $ridx = 0;
     foreach ($dateTimes as $dateTime) {
         $days++;
         // Fake the visit count cookie
         $debugStringAppend = "&_idvc={$days}";
         $visitor = $this->makeTracker($this->idSite, $dateTime, $debugStringAppend);
         // FIRST VISIT THIS DAY
         $visitor->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1)->getDatetime());
         $visitor->setUrl('http://example.org/homepage');
         $visitor->setUrlReferrer($this->referrerUrls[$ridx++]);
         self::checkResponse($visitor->doTrackPageView('ou pas'));
         // Test change the IP, the visit should not be split but recorded to the same idvisitor
         $visitor->setIp('200.1.15.22');
         $visitor->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)->getDatetime());
         $urlWithThreeSubdirectories = 'http://example.org/sub1/sub2/sub3/news';
         $visitor->setUrl($urlWithThreeSubdirectories);
         self::checkResponse($visitor->doTrackPageView('ou pas'));
         // SECOND VISIT THIS DAY
         $visitor->setForceVisitDateTime(Date::factory($dateTime)->addHour(1)->getDatetime());
         $visitor->setUrl('http://example.org/news');
         $visitor->setUrlReferrer($this->referrerUrls[$ridx++]);
         self::checkResponse($visitor->doTrackPageView('ou pas'));
         if ($days <= 3) {
             $visitor = $this->makeTracker($this->idSite2, $dateTime);
             $visitor->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1)->getDatetime());
             $visitor->setUrl('http://example.org/homepage');
             $visitor->setUrlReferrer($this->referrerUrls[$ridx - 1]);
             self::checkResponse($visitor->doTrackPageView('Second website'));
         }
     }
 }

作者:a4tunad    项目:piwi   
private function trackVisits()
 {
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     // two visits to site 1 & 3
     $visitor1 = self::getTracker($idSite, $dateTime, $defaultInit = true);
     $visitor1->setForceVisitDateTime(Date::factory($this->dateTime)->getDatetime());
     $visitor1->setUrl('http://helios.org/alpha');
     $visitor1->doTrackPageView("page title");
     $visitor1->setIdSite($this->idSite2);
     $visitor1->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(1)->getDatetime());
     $visitor1->setUrl('http://taura.org/');
     $visitor1->doTrackPageView("page title");
     // one visit to site 1
     $visitor2 = self::getTracker($idSite, $dateTime, $defaultInit = true);
     $visitor2->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(2)->getDatetime());
     $visitor2->setUrl('http://helios.org/beta');
     $visitor2->doTrackPageView("page title 2");
     // two visits to site 2 and 3
     $visitor3 = self::getTracker($this->idSite1, $dateTime, $defaultInit = true);
     $visitor3->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(3)->getDatetime());
     $visitor3->setUrl('http://virgon.org/');
     $visitor3->doTrackPageView("page title 2");
     $visitor3->setIdSite($this->idSite2);
     $visitor3->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(4)->getDatetime());
     $visitor3->setUrl('http://taura.org/');
     $visitor3->doTrackPageView("page title");
 }

作者:carriercom    项目:piwi   
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.');
 }

作者:diosmosi    项目:plugin-TasksTimetabl   
public function index()
 {
     Piwik::checkUserHasSuperUserAccess();
     $view = new View('@TasksTimetable/index.twig');
     $this->setGeneralVariablesView($view);
     $tasks = Option::get('TaskScheduler.timetable');
     if (!empty($tasks)) {
         $tasks = unserialize($tasks);
     }
     if (empty($tasks)) {
         $tasks = array();
     } else {
         asort($tasks);
     }
     $tsNow = Date::now()->getTimestamp();
     $dateFormat = Piwik::translate(Date::DATE_FORMAT_LONG) . ' h:mm:ss';
     $formatter = new Formatter();
     $tasksFormatted = array();
     foreach ($tasks as $name => $timestamp) {
         $tasksFormatted[] = array('name' => $name, 'executionDate' => Date::factory($timestamp)->getLocalized($dateFormat), 'ts_difference' => $formatter->getPrettyTimeFromSeconds($timestamp - $tsNow));
     }
     $view->currentTime = Date::now()->getLocalized($dateFormat);
     $view->tasks = $tasksFormatted;
     return $view->render();
 }

作者:dorelljame    项目:piwi   
private function trackVisits()
 {
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     $t = self::getTracker($idSite, $dateTime, $defaultInit = true);
     $t->setUrlReferrer('http://www.google.com/search?q=piwik');
     $t->setUrl('http://example.org/foo/bar.html');
     self::checkResponse($t->doTrackPageView('http://incredible.title/'));
     $t->setUrl('https://example.org/foo/bar.html');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)->getDatetime());
     self::checkResponse($t->doTrackPageView('https://incredible.title/'));
     $t->setUrl('https://wWw.example.org/foo/bar2.html');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.3)->getDatetime());
     self::checkResponse($t->doTrackPageView('http://www.incredible.title/'));
     $t->setUrl('http://WwW.example.org/foo/bar2.html');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.4)->getDatetime());
     self::checkResponse($t->doTrackPageView('https://www.incredible.title/'));
     $t->setUrl('http://www.example.org/foo/bar3.html');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.5)->getDatetime());
     self::checkResponse($t->doTrackPageView('incredible.title/'));
     $t->setUrl('http://www.my.url/ꟽ碌㒧䊶亄ﶆⅅขκもኸόσशμεޖृ');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.7)->getDatetime());
     self::checkResponse($t->doTrackPageView('Valid URL, although strange looking'));
     $t->setUrl('https://make.wordpress.org/?emoji=😎l&param=test');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.8)->getDatetime());
     self::checkResponse($t->doTrackPageView('Emoji here: %F0%9F%98%8E'));
     // this pageview should be last
     $t->setUrl('https://example.org/foo/bar4.html');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.6)->getDatetime());
     self::checkResponse($t->doTrackPageView('incredible.title/'));
 }

作者:FluentDevelopmen    项目:piwi   
public function setUp()
 {
     parent::setUp();
     $this->archiveTableDao = self::$fixture->piwikEnvironment->getContainer()->get('Piwik\\DataAccess\\ArchiveTableDao');
     ArchiveTableCreator::getBlobTable(Date::factory('2015-01-01'));
     ArchiveTableCreator::getNumericTable(Date::factory('2015-01-01'));
 }

作者:carriercom    项目:piwi   
private function trackVisits()
 {
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     $t = self::getTracker($idSite, $dateTime, $defaultInit = true, $useThirdPartyCookie = 1);
     $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');
     $t->setUrl('http://example.org/%C3%A9%C3%A9%C3%A9%22%27...%20%3Cthis%20is%20cool%3E!');
     $t->setGenerationTime(523);
     self::checkResponse($t->doTrackPageView('incredible title! <>,;'));
     $t->setUrl('http://example.org/dir/file.php?foo=bar&foo2=bar');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)->getDatetime());
     $t->setGenerationTime(123);
     self::checkResponse($t->doTrackPageView('incredible title! <>,;'));
     $t->setUrl('http://example.org/dir/file.php?foo=bar&foo2=bar2');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.3)->getDatetime());
     $t->setGenerationTime(153);
     self::checkResponse($t->doTrackPageView('incredible parent title! <>,; / subtitle <>,;'));
     $t->setUrl('http://example.org/dir/file.php?foo=bar&foo2=bar2');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.31)->getDatetime());
     $t->setGenerationTime(153);
     self::checkResponse($t->doTrackEvent('Category', 'Action', 'Name', 11111));
     $t->setUrl('http://example.org/dir2/file.php?foo=bar&foo2=bar');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.4)->getDatetime());
     $t->setGenerationTime(1233);
     self::checkResponse($t->doTrackPageView('incredible title! <>,;'));
     $t->setUrl('http://example.org/dir2/sub/0/file.php');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.4)->getDatetime());
     // Very high Generation time should be ignored
     $t->setGenerationTime(6350000);
     self::checkResponse($t->doTrackPageView('incredible title! <>,;'));
     $t->setUrl('http://example.org/0');
     $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.4)->getDatetime());
     $t->setGenerationTime(635);
     self::checkResponse($t->doTrackPageView('I am URL zero!'));
 }

作者:FluentDevelopmen    项目:piwi   
/**
  * @return bool `true` if the purge was executed, `false` if it was skipped.
  * @throws \Exception
  */
 public function purgeOutdatedArchives()
 {
     if ($this->willPurgingCausePotentialProblemInUI()) {
         $this->logger->info("Purging temporary archives: skipped (browser triggered archiving not enabled & not running after core:archive)");
         return false;
     }
     $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
     $this->logger->info("Purging archives in {tableCount} archive tables.", array('tableCount' => count($archiveTables)));
     // keep track of dates we purge for, since getTablesArchivesInstalled() will return numeric & blob
     // tables (so dates will appear two times, and we should only purge once per date)
     $datesPurged = array();
     foreach ($archiveTables as $table) {
         $date = ArchiveTableCreator::getDateFromTableName($table);
         list($year, $month) = explode('_', $date);
         // Somehow we may have archive tables created with older dates, prevent exception from being thrown
         if ($year > 1990) {
             if (empty($datesPurged[$date])) {
                 $dateObj = Date::factory("{$year}-{$month}-15");
                 $this->archivePurger->purgeOutdatedArchives($dateObj);
                 $this->archivePurger->purgeArchivesWithPeriodRange($dateObj);
                 $datesPurged[$date] = true;
             } else {
                 $this->logger->debug("Date {date} already purged.", array('date' => $date));
             }
         } else {
             $this->logger->info("Skipping purging of archive tables *_{year}_{month}, year <= 1990.", array('year' => $year, 'month' => $month));
         }
     }
     return true;
 }

作者:FluentDevelopmen    项目:piwi   
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(''));
 }

作者:carriercom    项目:piwi   
/**
  * The constructor
  * Initialize some local variables from the request
  * @param int $idSite
  * @param Date $date ($this->date from controller)
  * @param null|string $graphType
  * @throws Exception
  */
 public function __construct($idSite, $date, $graphType = null)
 {
     $this->apiMethod = Common::getRequestVar('apiMethod', '', 'string');
     if (empty($this->apiMethod)) {
         throw new Exception("Parameter apiMethod not set.");
     }
     $this->label = ResponseBuilder::getLabelFromRequest($_GET);
     $this->label = $this->label[0];
     if ($this->label === '') {
         throw new Exception("Parameter label not set.");
     }
     $this->period = Common::getRequestVar('period', '', 'string');
     if (empty($this->period)) {
         throw new Exception("Parameter period not set.");
     }
     $this->idSite = $idSite;
     $this->graphType = $graphType;
     if ($this->period != 'range') {
         // handle day, week, month and year: display last X periods
         $end = $date->toString();
         list($this->date, $lastN) = EvolutionViz::getDateRangeAndLastN($this->period, $end);
     }
     $this->segment = \Piwik\API\Request::getRawSegmentFromRequest();
     $this->loadEvolutionReport();
 }

作者:drabberhorizo    项目:ActiveNativ   
/**
  * The constructor
  * Initialize some local variables from the request
  * @param int $idSite
  * @param Date $date ($this->date from controller)
  * @param null|string $graphType
  * @throws Exception
  */
 public function __construct($idSite, $date, $graphType = 'graphEvolution')
 {
     $this->apiMethod = Common::getRequestVar('apiMethod', '', 'string');
     if (empty($this->apiMethod)) {
         throw new Exception("Parameter apiMethod not set.");
     }
     $this->label = DataTablePostProcessor::getLabelFromRequest($_GET);
     if (!is_array($this->label)) {
         throw new Exception("Expected label to be an array, got instead: " . $this->label);
     }
     $this->label = $this->label[0];
     if ($this->label === '') {
         throw new Exception("Parameter label not set.");
     }
     $this->period = Common::getRequestVar('period', '', 'string');
     PeriodFactory::checkPeriodIsEnabled($this->period);
     $this->idSite = $idSite;
     $this->graphType = $graphType;
     if ($this->period != 'range') {
         // handle day, week, month and year: display last X periods
         $end = $date->toString();
         list($this->date, $lastN) = EvolutionViz::getDateRangeAndLastN($this->period, $end);
     }
     $this->segment = \Piwik\API\Request::getRawSegmentFromRequest();
     $this->loadEvolutionReport();
 }

作者:carriercom    项目:piwi   
/**
  * Constructor.
  */
 public function __construct()
 {
     $date = $this->month . '-01';
     $classes = get_declared_classes();
     sort($classes);
     foreach ($classes as $className) {
         if (is_subclass_of($className, 'Fixture') && !is_subclass_of($className, __CLASS__) && $className != __CLASS__ && $className != "Piwik_Test_Fixture_SqlDump" && $className != "Piwik\\Tests\\Fixtures\\UpdaterTestFixture") {
             $klassReflect = new ReflectionClass($className);
             if (!strpos($klassReflect->getFilename(), "tests/PHPUnit/Fixtures") && $className != "Test_Piwik_Fixture_CustomAlerts" && $className != "Piwik\\Plugins\\Insights\\tests\\Fixtures\\SomeVisitsDifferentPathsOnTwoDays") {
                 continue;
             }
             $fixture = new $className();
             if (!property_exists($fixture, 'dateTime')) {
                 continue;
             }
             $fixture->dateTime = $this->adjustDateTime($fixture->dateTime, $date);
             $this->fixtures[$className] = $fixture;
             $date = Date::factory($date)->addDay(1)->toString();
         }
     }
     $this->now = $this->fixtures['Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts']->now;
     // make sure Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts is the first fixture
     $fixture = $this->fixtures['Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts'];
     unset($this->fixtures['Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts']);
     $this->fixtures = array_merge(array('Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts' => $fixture), $this->fixtures);
 }

作者:FluentDevelopmen    项目:piwi   
protected static function beforeTableDataCached()
 {
     $date = Date::factory('2010-03-01');
     $archiveTableCreator = new ArchiveTableCreator();
     $archiveTableCreator->getBlobTable($date);
     $archiveTableCreator->getNumericTable($date);
 }

作者:a4tunad    项目:piwi   
private function addAnnotations()
 {
     // create fake access for fake username
     $access = new FakeAccess();
     FakeAccess::$superUser = true;
     Access::setSingletonInstance($access);
     // add two annotations per week for three months, starring every third annotation
     // first month in 2011, second two in 2012
     $count = 0;
     $dateStart = Date::factory('2011-12-01');
     $dateEnd = Date::factory('2012-03-01');
     while ($dateStart->getTimestamp() < $dateEnd->getTimestamp()) {
         $starred = $count % 3 == 0 ? 1 : 0;
         $site1Text = "{$count}: Site 1 annotation for " . $dateStart->toString();
         $site2Text = "{$count}: Site 2 annotation for " . $dateStart->toString();
         API::getInstance()->add($this->idSite1, $dateStart->toString(), $site1Text, $starred);
         API::getInstance()->add($this->idSite2, $dateStart->toString(), $site2Text, $starred);
         $nextDay = $dateStart->addDay(1);
         ++$count;
         $starred = $count % 3 == 0 ? 1 : 0;
         $site1Text = "{$count}: Site 1 annotation for " . $nextDay->toString();
         $site2Text = "{$count}: Site 2 annotation for " . $nextDay->toString();
         API::getInstance()->add($this->idSite1, $nextDay->toString(), $site1Text, $starred);
         API::getInstance()->add($this->idSite2, $nextDay->toString(), $site2Text, $starred);
         $dateStart = $dateStart->addPeriod(1, 'WEEK');
         ++$count;
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号