本文整理汇总了PHP中CakeTime类的典型用法代码示例。如果您正苦于以下问题:PHP CakeTime类的具体用法?PHP CakeTime怎么用?PHP CakeTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CakeTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterFind
public function afterFind($results, $primary = false)
{
Configure::write('debug', 2);
App::uses("CakeTime", "Utility");
$gc = new CakeTime();
parent::afterFind($results, $primary);
if (isset($results[0]['Order']['timestamp'])) {
foreach ($results as $key => $val) {
$results[$key]['Order']['created'] = $gc->timeAgoInWords($results[$key]['Order']['timestamp']);
}
}
return $results;
}
示例2: index
/**
* Relatórios
*/
public function index()
{
// Carrega o model Schedules
$this->loadModel('Schedule');
// Se a requisição é do tipo post
if ($this->request->is('post')) {
$this->layout = "print";
$this->set('orientation', 'landscape');
// Opções de busca
$options = array('conditions' => array('Schedule.created >' => CakeTime::format($this->request->data['Reports']['start'], "%Y-%m-%d %H:%M"), 'Schedule.created <' => CakeTime::format($this->request->data['Reports']['end'], "%Y-%m-%d %H:%M")), 'order' => array('Patient.name' => 'asc', 'Schedule.created' => 'asc'));
//debuga options
$this->set(compact('options'));
// Resultados de busca
$schedules = $this->Schedule->find('all', $options);
// Compacta para view
$this->set(compact('schedules'));
$this->render('results');
$this->generated_pdf("relatorio_consolidado_");
} else {
$this->set('orientation', 'landscape');
//$this->layout = "print";
// Faz uma busca e compacta todas as requisições cadastradas
$schedules = $this->Schedule->find('all', array('order' => array('Patient.name' => 'asc', 'Schedule.created' => 'asc')));
$this->set(compact('schedules'));
//$this->render('results');
//$this->generated_pdf("relatorio_teste");
}
}
示例3: getByComponente
public function getByComponente()
{
$this->layout = "ajax";
$incidencias = $this->Incidencia->Componente->find("first", array("contain" => array("Incidencia" => array("conditions" => array("Incidencia.estado" => 1, "Incidencia.fecha between ? and ?" => array(CakeTime::format($this->request->data["Componente"]["fechaInicio"], "%Y-%m-%d"), CakeTime::format($this->request->data["Componente"]["fechaFin"], "%Y-%m-%d")))), "Incidencia.Cruce"), "conditions" => array("Componente.idComponente" => $this->request->data["Componente"]["idComponente"])));
$incidencias = $incidencias["Incidencia"];
$this->set("incidencias", $incidencias);
}
示例4: testTime
/**
* HtmlExtHelperTest::testTime()
*
* @return void
*/
public function testTime()
{
$time = time();
$is = $this->Html->time($time);
$time = CakeTime::i18nFormat($time, '%Y-%m-%d %T');
$expected = '<time datetime="' . $time . '">' . $time . '</time>';
$this->assertEquals($expected, $is);
}
示例5: afterFind
public function afterFind($results, $primary = false)
{
App::uses('CakeTime', 'Utility');
foreach ($results as &$result) {
if (isset($result[$this->alias]['modified'])) {
$result[$this->alias]['niceday'] = CakeTime::niceShort($result[$this->alias]['modified']);
}
}
return $results;
}
示例6: timeAgo
public function timeAgo($timestamp)
{
$timeAgo = CakeTime::timeAgoInWords($timestamp, array('accuracy' => array('hour' => 'hour'), 'end' => '1 year'));
$timeAgo = trim(str_replace('ago', '', str_replace('second', 'seconde', str_replace('hour', 'heure', str_replace('day', 'jour', str_replace('week', 'semaine', str_replace('month', 'mois', $timeAgo)))))));
if ($timeAgo == 'just now') {
$timeAgo = 'il y a quelques secondes';
} else {
$timeAgo = 'il y a ' . $timeAgo;
}
return $timeAgo;
}
示例7: getHolidayInYear
/**
* getHolidayInYear
* 指定された年の祝日日付を返す
* getHolidayのラッパー関数 YYYYに年始まりの日付と最終日付を付与してgetHolidayを呼び出す
*
* @param string $year 指定年(西暦)‘YYYY’ 形式の文字列
* @return array期間内のholidayテーブルのデータ配列が返る
*/
public function getHolidayInYear($year = null)
{
// $yearがnullの場合は現在年
if ($year === null) {
// 未設定時は現在年
$year = CakeTime::format((new NetCommonsTime())->getNowDatetime(), '%Y');
}
$from = $year . '-01-01';
$to = $year . '-12-31';
$holidays = $this->getHoliday($from, $to);
return $holidays;
}
示例8: getTimezoneOffset
/**
* Used for GMT offset for a timezone
* @param string $timezone: timezone name
* @return string GMT offset for the given timezone
* @author Laxmi Saini
*/
function getTimezoneOffset($timezone = null)
{
if ($timezone != '') {
$dateTimeObj = new DateTime();
$date_time_zone = CakeTime::timezone($timezone);
$dateTimeObj->setTimeZone($date_time_zone);
$offset = $dateTimeObj->getOffset();
return $this->formatGmtOffset($offset);
} else {
return "";
}
}
示例9: ageFromBirthdate
/**
* Calculates the current age of someone born on $birthdate.
* Source: stackoverflow.com/questions/3776682/php-calculate-age
* @param sing $birthdate The birthdate.
* @return integer The calculated age.
* @access public
* @static
*/
public static function ageFromBirthdate($birthdate)
{
// convert to format: YYYY-MM-DD
$clean_birthdate = date('Y-m-d', CakeTime::fromString($birthdate));
if (CakeTime::isFuture($clean_birthdate)) {
throw new OutOfRangeException("Birthdate is in the future: {$clean_birthdate}", BedrockTime::EXCEPTION_CODE_FUTURE_BIRTHDATE);
}
//explode the date to get month, day and year
$parts = explode('-', $clean_birthdate);
//get age from date or birthdate
$age = intval(date('md', date('U', mktime(0, 0, 0, $parts[1], $parts[2], $parts[0]))) > date('md') ? date('Y') - $parts[0] - 1 : date('Y') - $parts[0]);
return $age;
}
示例10: isTokenValid
public function isTokenValid($token)
{
$tokenAuth = $this->find('first', array('conditions' => array('Token.token' => $token)));
if ($tokenAuth) {
$expiryDate = $tokenAuth['Token']['token_expiry_date'];
if (CakeTime::gmt($expiryDate) < CakeTime::gmt()) {
return false;
} else {
return $tokenAuth['Token'];
}
} else {
return false;
}
}
示例11: index
/**
* index method
*
* @return void
*/
public function index()
{
$targetYear = null;
// 指定年取り出し
if (isset($this->params['named']['targetYear'])) {
$targetYear = $this->params['named']['targetYear'];
} else {
$targetYear = CakeTime::format((new NetCommonsTime())->getNowDatetime(), '%Y');
}
// 祝日設定リスト取り出し
$holidays = $this->Holiday->getHolidayInYear($targetYear);
// View変数設定
$this->set('holidays', $holidays);
$this->set('targetYear', $targetYear);
}
示例12: admin_login
/**
* Auth Login page
*/
public function admin_login()
{
if (Configure::read('Backend.Auth.enabled') !== true) {
if (isset($this->Auth)) {
$this->redirect($this->Auth->loginAction);
} else {
$this->redirect('/');
}
}
$this->layout = "Backend.auth";
$defaultRedirect = Configure::read('Backend.Dashboard.url') ? Configure::read('Backend.Dashboard.url') : array('plugin' => 'backend', 'controller' => 'backend', 'action' => 'dashboard');
$redirect = false;
if ($this->request->is('post')) {
if (!$this->Auth->login()) {
//Event Backend.Auth.onLoginFail
$eventData = array('user' => $this->request->data['BackendUser'], 'ip' => $this->request->clientIp());
// $event = new CakeEvent('Backend.Controller.Auth.onLoginFail', $this, $eventData);
// $this->getEventManager()->dispatch($event);
$this->Session->setFlash(__d('backend', 'Login failed'), 'error', array(), 'auth');
} else {
//Event Backend.Auth.onLogin
$event = new CakeEvent('Backend.Controller.Auth.onLogin', $this, $this->Auth->user());
//$this->getEventManager()->dispatch($event);
$this->Session->setFlash(__d('backend', 'Login successful'), 'success');
if ($this->Auth->user('lastlogin')) {
$this->Session->setFlash(__d('backend', 'Last login: %s', CakeTime::timeAgoInWords($this->Auth->user('last_login'))), 'default', array(), 'auth');
}
//TODO should the event result return an redirect url?
if ($event->result) {
$redirect = $event->result;
} else {
$redirect = $this->Auth->redirect();
}
$redirect = Router::normalize($redirect);
if ($redirect == '/' || !preg_match('/^\\/admin\\//', $redirect) || $redirect == '/admin/backend') {
$redirect = $defaultRedirect;
}
$this->redirect($redirect);
}
} elseif ($this->Auth->user()) {
$redirect = $this->referer($defaultRedirect, true);
$this->redirect($redirect);
}
$this->set(compact('redirect'));
}
示例13: index
/**
* Loop through active controllers and generate sitemap data.
*/
public function index()
{
$controllers = App::objects('Controller');
$sitemap = array();
// Fetch sitemap data
foreach ($controllers as $controller) {
App::uses($controller, 'Controller');
// Don't load AppController's, SitemapController or Controller's who can't be found
if (strpos($controller, 'AppController') !== false || $controller === 'SitemapController' || !App::load($controller)) {
continue;
}
$instance = new $controller($this->request, $this->response);
$instance->constructClasses();
if (method_exists($instance, '_generateSitemap')) {
if ($data = $instance->_generateSitemap()) {
$sitemap = array_merge($sitemap, $data);
}
}
}
// Cleanup sitemap
if ($sitemap) {
foreach ($sitemap as &$item) {
if (is_array($item['loc'])) {
if (!isset($item['loc']['plugin'])) {
$item['loc']['plugin'] = false;
}
$item['loc'] = h(Router::url($item['loc'], true));
}
if (array_key_exists('lastmod', $item)) {
if (!$item['lastmod']) {
unset($item['lastmod']);
} else {
$item['lastmod'] = CakeTime::format(DateTime::W3C, $item['lastmod']);
}
}
}
}
// Disable direct linking
if (empty($this->request->params['ext'])) {
throw new NotFoundException();
}
// Render view and don't use specific view engines
$this->RequestHandler->respondAs($this->request->params['ext']);
$this->set('sitemap', $sitemap);
}
示例14: follow_expedient
/**
* index method
*
* @return void
*/
public function follow_expedient($idE = null)
{
App::uses('CakeTime', 'Utility');
$confirmas = $this->Confirma->Expediente->find('all', array('conditions' => array('Expediente.user_id' => $idE)));
if (isset($confirmas[0]['Expediente']['previsao_chegada']) && !empty($confirmas[0]['Expediente']['previsao_chegada'])) {
if (CakeTime::isToday($confirmas[0]['Expediente']['previsao_chegada'])) {
/* greet user with a happy birthday message
Enviar um email alertando sobre a data quase vencida.
*/
$vence_hoje = 'Chega Hoje';
if (isset($vence_hoje) && empty($vence_hoje)) {
$vence_hoje = '';
}
$this->set('vence_hoje', $vence_hoje);
}
}
$this->set(compact('confirmas', 'idE'));
}
示例15: register
public function register()
{
if (empty($this->request->data)) {
$queryString = '?' . http_build_query($this->request->query);
$this->set(compact('queryString'));
} else {
$this->request->data['Token']['password'] = Security::hash($this->request->data['Token']['password'], 'md5');
$this->request->data['Token']['token'] = Security::hash($this->request->data['Token']['email'], 'md5');
$this->request->data['Token']['type'] = 'application';
$this->request->data['Token']['token_expiry_date'] = CakeTime::format('+365 days', '%Y-%m-%d');
$this->Token->save($this->request->data);
$bearerTokenReceivingUrl = urldecode($this->request->query['client_bearer_token_receiving_url']);
unset($this->request->query['client_bearer_token_receiving_url']);
$this->request->query['bearer_token'] = $this->request->data['Token']['token'];
$this->request->query['login_type'] = 'application';
return $this->redirect($bearerTokenReceivingUrl . '?' . http_build_query($this->request->query));
}
}