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


PHP CakeTime类代码示例

本文整理汇总了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;
 }
开发者ID:ashutoshdev,项目名称:pickmeals-web,代码行数:13,代码来源:Order.php

示例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");
     }
 }
开发者ID:patrickacioli,项目名称:exames,代码行数:31,代码来源:ReportsController.php

示例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);
 }
开发者ID:Rabp9,项目名称:registro-incidencias,代码行数:7,代码来源:ReportesController.php

示例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);
 }
开发者ID:ByMyHandsOnly,项目名称:BMHO_Web,代码行数:13,代码来源:HtmlExtHelperTest.php

示例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;
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:10,代码来源:DocumentVersion.php

示例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;
 }
开发者ID:julienasp,项目名称:Pilule,代码行数:11,代码来源:AppHelper.php

示例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;
 }
开发者ID:s-nakajima,项目名称:Holidays,代码行数:20,代码来源:Holiday.php

示例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 "";
     }
 }
开发者ID:yogesha3,项目名称:yogesh-test,代码行数:18,代码来源:TimezoneComponent.php

示例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;
 }
开发者ID:quentinhill,项目名称:bedrock,代码行数:21,代码来源:BedrockTime.php

示例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;
     }
 }
开发者ID:schnauss,项目名称:angular-cakephp-auth,代码行数:14,代码来源:Token.php

示例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);
 }
开发者ID:s-nakajima,项目名称:Holidays,代码行数:20,代码来源:HolidaysController.php

示例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'));
 }
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:48,代码来源:AuthController.php

示例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);
 }
开发者ID:alescx,项目名称:cakephp-utils,代码行数:48,代码来源:SitemapController.php

示例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'));
 }
开发者ID:Goncalves007,项目名称:Projecto-EI,代码行数:23,代码来源:ConfirmasController.php

示例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));
     }
 }
开发者ID:schnauss,项目名称:angular-cakephp-auth,代码行数:18,代码来源:TokensController.php


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