getCreationDate() public method

Returns the creation date of the site.
public getCreationDate ( ) : Date
return Date
コード例 #1
0
 public function testSetDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps()
 {
     // test that they return default values
     $defaultTimezone = API::getInstance()->getDefaultTimezone();
     $this->assertEquals('UTC', $defaultTimezone);
     $defaultCurrency = API::getInstance()->getDefaultCurrency();
     $this->assertEquals('USD', $defaultCurrency);
     $excludedIps = API::getInstance()->getExcludedIpsGlobal();
     $this->assertEquals('', $excludedIps);
     $excludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
     $this->assertEquals('', $excludedQueryParameters);
     // test that when not specified, defaults are set as expected
     $idsite = API::getInstance()->addSite("site1", array('http://example.org'));
     $site = new Site($idsite);
     $this->assertEquals('UTC', $site->getTimezone());
     $this->assertEquals('USD', $site->getCurrency());
     $this->assertEquals('', $site->getExcludedQueryParameters());
     $this->assertEquals('', $site->getExcludedIps());
     $this->assertEquals(false, $site->isEcommerceEnabled());
     // set the global timezone and get it
     $newDefaultTimezone = 'UTC+5.5';
     API::getInstance()->setDefaultTimezone($newDefaultTimezone);
     $defaultTimezone = API::getInstance()->getDefaultTimezone();
     $this->assertEquals($newDefaultTimezone, $defaultTimezone);
     // set the default currency and get it
     $newDefaultCurrency = 'EUR';
     API::getInstance()->setDefaultCurrency($newDefaultCurrency);
     $defaultCurrency = API::getInstance()->getDefaultCurrency();
     $this->assertEquals($newDefaultCurrency, $defaultCurrency);
     // set the global IPs to exclude and get it
     $newGlobalExcludedIps = '1.1.1.*,1.1.*.*,150.1.1.1';
     API::getInstance()->setGlobalExcludedIps($newGlobalExcludedIps);
     $globalExcludedIps = API::getInstance()->getExcludedIpsGlobal();
     $this->assertEquals($newGlobalExcludedIps, $globalExcludedIps);
     // set the global URL query params to exclude and get it
     $newGlobalExcludedQueryParameters = 'PHPSESSID,blabla, TesT';
     // removed the space
     $expectedGlobalExcludedQueryParameters = 'PHPSESSID,blabla,TesT';
     API::getInstance()->setGlobalExcludedQueryParameters($newGlobalExcludedQueryParameters);
     $globalExcludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
     $this->assertEquals($expectedGlobalExcludedQueryParameters, $globalExcludedQueryParameters);
     // create a website and check that default currency and default timezone are set
     // however, excluded IPs and excluded query Params are not returned
     $idsite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, $siteSearch = 0, $searchKeywordParameters = 'test1,test2', $searchCategoryParameters = 'test2,test1', '', '', $newDefaultTimezone);
     $site = new Site($idsite);
     $this->assertEquals($newDefaultTimezone, $site->getTimezone());
     $this->assertEquals(date('Y-m-d'), $site->getCreationDate()->toString());
     $this->assertEquals($newDefaultCurrency, $site->getCurrency());
     $this->assertEquals('', $site->getExcludedIps());
     $this->assertEquals('', $site->getExcludedQueryParameters());
     $this->assertEquals('test1,test2', $site->getSearchKeywordParameters());
     $this->assertEquals('test2,test1', $site->getSearchCategoryParameters());
     $this->assertFalse($site->isSiteSearchEnabled());
     $this->assertFalse(Site::isSiteSearchEnabledFor($idsite));
     $this->assertFalse($site->isEcommerceEnabled());
     $this->assertFalse(Site::isEcommerceEnabledFor($idsite));
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: brienomatty/elmsln
 /**
  * Assigns variables to {@link Piwik\View} instances that display an entire page.
  * 
  * The following variables assigned:
  * 
  * **date** - The value of the **date** query parameter.
  * **idSite** - The value of the **idSite** query parameter.
  * **rawDate** - The value of the **date** query parameter.
  * **prettyDate** - A pretty string description of the current period.
  * **siteName** - The current site's name.
  * **siteMainUrl** - The URL of the current site.
  * **startDate** - The start date of the current period. A {@link Piwik\Date} instance.
  * **endDate** - The end date of the current period. A {@link Piwik\Date} instance.
  * **language** - The current language's language code.
  * **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter`
  *                                            INI config option.
  * **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  * 
  * As well as the variables set by {@link setPeriodVariablesView()}.
  * 
  * Will exit on error.
  * 
  * @param View $view
  * @return void
  * @api
  */
 protected function setGeneralVariablesView($view)
 {
     $view->date = $this->strDate;
     try {
         $view->idSite = $this->idSite;
         if (empty($this->site) || empty($this->idSite)) {
             throw new Exception("The requested website idSite is not found in the request, or is invalid.\n\t\t\t\tPlease check that you are logged in Piwik and have permission to access the specified website.");
         }
         $this->setPeriodVariablesView($view);
         $rawDate = Common::getRequestVar('date');
         $periodStr = Common::getRequestVar('period');
         if ($periodStr != 'range') {
             $date = Date::factory($this->strDate);
             $period = Period\Factory::build($periodStr, $date);
         } else {
             $period = new Range($periodStr, $rawDate, $this->site->getTimezone());
         }
         $view->rawDate = $rawDate;
         $view->prettyDate = self::getCalendarPrettyDate($period);
         $view->siteName = $this->site->getName();
         $view->siteMainUrl = $this->site->getMainUrl();
         $datetimeMinDate = $this->site->getCreationDate()->getDatetime();
         $minDate = Date::factory($datetimeMinDate, $this->site->getTimezone());
         $this->setMinDateView($minDate, $view);
         $maxDate = Date::factory('now', $this->site->getTimezone());
         $this->setMaxDateView($maxDate, $view);
         // Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
         $dateStart = $period->getDateStart();
         if ($dateStart->isEarlier($minDate)) {
             $dateStart = $minDate;
         }
         $dateEnd = $period->getDateEnd();
         if ($dateEnd->isLater($maxDate)) {
             $dateEnd = $maxDate;
         }
         $view->startDate = $dateStart;
         $view->endDate = $dateEnd;
         $language = LanguagesManager::getLanguageForSession();
         $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
         $this->setBasicVariablesView($view);
         $view->topMenu = MenuTop::getInstance()->getMenu();
         $view->userMenu = MenuUser::getInstance()->getMenu();
         $notifications = $view->notifications;
         if (empty($notifications)) {
             $view->notifications = NotificationManager::getAllNotificationsToDisplay();
             NotificationManager::cancelAllNonPersistent();
         }
     } catch (Exception $e) {
         Piwik_ExitWithMessage($e->getMessage(), $e->getTraceAsString());
     }
 }
コード例 #3
0
ファイル: Controller.php プロジェクト: pombredanne/ArcherSys
 protected function setDateTodayIfWebsiteCreatedToday()
 {
     $date = Common::getRequestVar('date', false);
     if ($date == 'today' || Common::getRequestVar('period', false) == 'range') {
         return;
     }
     $websiteId = Common::getRequestVar('idSite', false, 'int');
     if ($websiteId) {
         $website = new Site($websiteId);
         $datetimeCreationDate = $website->getCreationDate()->getDatetime();
         $creationDateLocalTimezone = Date::factory($datetimeCreationDate, $website->getTimezone())->toString('Y-m-d');
         $todayLocalTimezone = Date::factory('now', $website->getTimezone())->toString('Y-m-d');
         if ($creationDateLocalTimezone == $todayLocalTimezone) {
             Piwik::redirectToModule('CoreHome', 'index', array('date' => 'today', 'idSite' => $websiteId, 'period' => Common::getRequestVar('period')));
         }
     }
 }
コード例 #4
0
ファイル: Archive.php プロジェクト: carriercomm/piwik
 /**
  * Gets the IDs of the archives we're querying for and stores them in $this->archives.
  * This function will launch the archiving process for each period/site/plugin if
  * metrics/reports have not been calculated/archived already.
  *
  * @param array $archiveGroups @see getArchiveGroupOfReport
  * @param array $plugins List of plugin names to archive.
  */
 private function cacheArchiveIdsAfterLaunching($archiveGroups, $plugins)
 {
     $today = Date::today();
     foreach ($this->params->getPeriods() as $period) {
         $twoDaysBeforePeriod = $period->getDateStart()->subDay(2);
         $twoDaysAfterPeriod = $period->getDateEnd()->addDay(2);
         foreach ($this->params->getIdSites() as $idSite) {
             $site = new Site($idSite);
             // if the END of the period is BEFORE the website creation date
             // we already know there are no stats for this period
             // we add one day to make sure we don't miss the day of the website creation
             if ($twoDaysAfterPeriod->isEarlier($site->getCreationDate())) {
                 Log::verbose("Archive site %s, %s (%s) skipped, archive is before the website was created.", $idSite, $period->getLabel(), $period->getPrettyString());
                 continue;
             }
             // if the starting date is in the future we know there is no visiidsite = ?t
             if ($twoDaysBeforePeriod->isLater($today)) {
                 Log::verbose("Archive site %s, %s (%s) skipped, archive is after today.", $idSite, $period->getLabel(), $period->getPrettyString());
                 continue;
             }
             $this->prepareArchive($archiveGroups, $site, $period);
         }
     }
 }
コード例 #5
0
ファイル: Controller.php プロジェクト: piwik/piwik
 /**
  * Assigns variables to {@link Piwik\View} instances that display an entire page.
  *
  * The following variables assigned:
  *
  * **date** - The value of the **date** query parameter.
  * **idSite** - The value of the **idSite** query parameter.
  * **rawDate** - The value of the **date** query parameter.
  * **prettyDate** - A pretty string description of the current period.
  * **siteName** - The current site's name.
  * **siteMainUrl** - The URL of the current site.
  * **startDate** - The start date of the current period. A {@link Piwik\Date} instance.
  * **endDate** - The end date of the current period. A {@link Piwik\Date} instance.
  * **language** - The current language's language code.
  * **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter`
  *                                            INI config option.
  * **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  *
  * As well as the variables set by {@link setPeriodVariablesView()}.
  *
  * Will exit on error.
  *
  * @param View $view
  * @return void
  * @api
  */
 protected function setGeneralVariablesView($view)
 {
     $view->idSite = $this->idSite;
     $this->checkSitePermission();
     $this->setPeriodVariablesView($view);
     $view->siteName = $this->site->getName();
     $view->siteMainUrl = $this->site->getMainUrl();
     $siteTimezone = $this->site->getTimezone();
     $datetimeMinDate = $this->site->getCreationDate()->getDatetime();
     $minDate = Date::factory($datetimeMinDate, $siteTimezone);
     $this->setMinDateView($minDate, $view);
     $maxDate = Date::factory('now', $siteTimezone);
     $this->setMaxDateView($maxDate, $view);
     $rawDate = Common::getRequestVar('date');
     Period::checkDateFormat($rawDate);
     $periodStr = Common::getRequestVar('period');
     if ($periodStr != 'range') {
         $date = Date::factory($this->strDate);
         $validDate = $this->getValidDate($date, $minDate, $maxDate);
         $period = Period\Factory::build($periodStr, $validDate);
         if ($date->toString() !== $validDate->toString()) {
             // we to not always change date since it could convert a strDate "today" to "YYYY-MM-DD"
             // only change $this->strDate if it was not valid before
             $this->setDate($validDate);
         }
     } else {
         $period = new Range($periodStr, $rawDate, $siteTimezone);
     }
     // Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
     $dateStart = $period->getDateStart();
     $dateStart = $this->getValidDate($dateStart, $minDate, $maxDate);
     $dateEnd = $period->getDateEnd();
     $dateEnd = $this->getValidDate($dateEnd, $minDate, $maxDate);
     if ($periodStr == 'range') {
         // make sure we actually display the correct calendar pretty date
         $newRawDate = $dateStart->toString() . ',' . $dateEnd->toString();
         $period = new Range($periodStr, $newRawDate, $siteTimezone);
     }
     $view->date = $this->strDate;
     $view->prettyDate = self::getCalendarPrettyDate($period);
     $view->prettyDateLong = $period->getLocalizedLongString();
     $view->rawDate = $rawDate;
     $view->startDate = $dateStart;
     $view->endDate = $dateEnd;
     $language = LanguagesManager::getLanguageForSession();
     $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
     $this->setBasicVariablesView($view);
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->adminMenu = MenuAdmin::getInstance()->getMenu();
     $notifications = $view->notifications;
     if (empty($notifications)) {
         $view->notifications = NotificationManager::getAllNotificationsToDisplay();
         NotificationManager::cancelAllNonPersistent();
     }
 }