/** * * @param System\Date $value * @return string */ private function _ToDBString(System\Date $value = null) { if ($value === null) { return $value; } return $value->ToString('Y-m-d H:i:s'); }
/** * * @param Date $value * @return strng */ private function _ToDBString(System\Date $value = null) { if ($value === null) { return $value; } return (string) $value->TimeStamp(); }
function ErrorParams() { switch ($this->error) { case self::ParseFailed: return array($this->format); case self::TooEarly: return array($this->minDate->ToString($this->format)); case self::TooLate: return array($this->maxDate->ToString($this->format)); } return parent::ErrorParams(); }
/** * * @param boolean $publish A flag to activate/deactivate publishing generally * @param Date $from The from date; null denoting no restriction in start date * @param Date $to The to date; null denoting no restriction in end date * @return boolean Returns true if publish is true and now is between from and to date */ public static function IsPublishedNow($publish, Date $from = null, Date $to = null) { if (!$publish) { return false; } $now = Date::Now(); if ($from && $from->IsAfter($now)) { return false; } if ($to && $to->IsBefore($now)) { return false; } return true; }
/** * Adds an url to the sitemap * @param string $url * @param ChangeFrequency $changeFreq * @param float $priority * @param Date $lastMod */ function AddUrl($url, ChangeFrequency $changeFreq = null, $priority = null, Date $lastMod = null) { $elm = $this->domDoc->createElement("url"); $this->AppendTextChild($elm, "loc", $url); if ($changeFreq) { $this->AppendTextChild($elm, "changefreq", (string) $changeFreq); } if ($priority) { $this->AppendTextChild($elm, "priority", $priority); } if ($lastMod) { $this->AppendTextChild($elm, "lastmod", $lastMod->ToString('c')); } $this->urlset->appendChild($elm); }
private function OnSuccess() { $member = $this->confirmer->GetMember(); $member->SetConfirmed(Date::Now()); if ($this->confirm->GetActivate()) { $member->SetActive(true); } $member->Save(); $this->AddGroups($member); if ($this->confirm->GetSuccessUrl()) { Response::Redirect(FrontendRouter::Url($this->confirm->GetSuccessUrl())); } }
/** * Calculates if the cache content needs to be used * @return boolean */ function MustUseCache() { if ($this->cacheLifetime == 0) { return false; } if (!File::Exists($this->file)) { return false; } $now = Date::Now(); $lastMod = File::GetLastModified($this->file); if ($now->TimeStamp() - $lastMod->TimeStamp() < $this->cacheLifetime) { return true; } return false; }
protected function OnSuccess() { $this->member = new Member(); $this->member->SetEMail($this->Value('EMail')); $this->member->SetName($this->Value('Name')); $password = $this->Value('Password'); $salt = String::Start(md5(uniqid(microtime())), 8); $pwHash = hash('sha256', $password . $salt); $this->member->SetPassword($pwHash); $this->member->SetPasswordSalt($salt); $this->member->SetCreated(Date::Now()); $this->member->Save(); $this->SendConfirmMail(); if ($this->register->GetNextUrl()) { Response::Redirect(FrontendRouter::Url($this->register->GetNextUrl())); } }
/** * Gets the last modified date of the file or folder * @param string $path * @return Date Returns null if file doesn't exit or info is not accessible */ static function GetLastModified($path) { $ts = @\filemtime($path); if ($ts !== false) { return Date::FromTimeStamp($ts); } return null; }
/** * Gets a publishing date * @param string $baseName The base name; 'PublishFrom' or 'PublishTo' * @return Date Returns the date */ private function PublishDate($baseName) { if (!$this->Content()->GetPublish()) { return null; } $strDate = $this->Value($baseName . 'Date'); if (!$strDate) { return null; } $date = \DateTime::createFromFormat($this->dateFormat, $strDate); $date->setTime((int) $this->Value($baseName . 'Hour'), (int) $this->Value($baseName . 'Minute'), 0); return Date::FromDateTime($date); }
/** * Deletes log items older then the given amount of days * @param int $days The days */ private function DeleteOldLogItems() { $days = SettingsProxy::Singleton()->Settings()->GetLogLifetime(); $deleteBefore = Date::Now(); $deleteBefore->AddDays(-$days); $tblLogItem = LogItem::Schema()->Table(); $sql = Access::SqlBuilder(); $where = $sql->LT($tblLogItem->Field('Changed'), $sql->Value($deleteBefore)); LogItem::Schema()->Delete($where); }
/** * Updates the version of the bundle * @param string $bundle The bundle name */ private function UpdateBundleVersion($bundle) { $instBundle = InstalledBundle::Schema()->ByBundle($bundle); if (!$instBundle) { $instBundle = new InstalledBundle(); } $instBundle->SetVersion($this->installedBundles[$bundle]); $instBundle->SetBundle($bundle); $instBundle->SetLastUpdate(Date::Now()); $instBundle->Save(); }
/** * True if cache file contents must be used * @param strinh $cacheFile The cache file * @return boolean */ private function MustUseCache($cacheFile) { $seconds = $this->content->GetCacheLifetime(); if ($seconds == 0) { return false; } if (!File::Exists($cacheFile)) { return false; } $now = Date::Now(); $lastMod = File::GetLastModified($cacheFile); if ($now->TimeStamp() - $lastMod->TimeStamp() < $seconds) { return true; } return false; }