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


PHP CakeTime::timeAgoInWords方法代码示例

本文整理汇总了PHP中CakeTime::timeAgoInWords方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeTime::timeAgoInWords方法的具体用法?PHP CakeTime::timeAgoInWords怎么用?PHP CakeTime::timeAgoInWords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CakeTime的用法示例。


在下文中一共展示了CakeTime::timeAgoInWords方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: timeAgoInWords

 /**
  * Formats a date into a phrase expressing the relative time.
  *
  * ## Addition options
  *
  * - `element` - The element to wrap the formatted time in.
  *   Has a few additional options:
  *   - `tag` - The tag to use, defaults to 'span'.
  *   - `class` - The class name to use, defaults to `time-ago-in-words`.
  *   - `title` - Defaults to the $dateTime input.
  *
  * @param int|string|DateTime $dateTime UNIX timestamp, strtotime() valid string or DateTime object
  * @param array               $options  Default format if timestamp is used in $dateString
  *
  * @return string Relative time string.
  * @see  CakeTime::timeAgoInWords()
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
  */
 public function timeAgoInWords($dateTime, $options = array())
 {
     $element = NULL;
     if (!empty($options['element'])) {
         $element = array('tag' => 'span', 'class' => 'time-ago-in-words', 'title' => $dateTime);
         if (is_array($options['element'])) {
             $element = $options['element'] + $element;
         } else {
             $element['tag'] = $options['element'];
         }
         unset($options['element']);
     }
     $relativeDate = $this->_engine->timeAgoInWords($dateTime, $options);
     if ($element) {
         $relativeDate = sprintf('<%s%s>%s</%s>', $element['tag'], $this->_parseAttributes($element, array('tag')), $relativeDate, $element['tag']);
     }
     return $relativeDate;
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:36,代码来源:TimeHelper.php

示例5: _sendSignal

 /**
  * Operate over workers by sending a PCNTL signal.
  *
  * Note: The workers status is conveniently stored by ResqueStatus.
  *
  * @return void
  * @see ResqueStatus\ResqueStatus::isSchedulerWorker()
  */
 protected function _sendSignal($title, $workers, $noWorkersMessage, $listTitle, $allActionMessage, $promptMessage, $schedulerWorkerActionMessage, $workerActionMessage, $formatListItem, $successCallback, $signal, $schedulerWorkerAction = null)
 {
     if (!function_exists('pcntl_signal')) {
         return $this->out('<error>' . __d('cake_resque', "This function requires the PCNTL extension") . '</error>');
     }
     $ResqueStatus = $this->ResqueStatus;
     if ($formatListItem === null) {
         $formatListItem = function ($worker, $i) use($ResqueStatus) {
             App::uses('CakeTime', 'Utility');
             return sprintf("    [%3d] - %s, started %s", $i, $ResqueStatus->isSchedulerWorker($worker) ? '<comment>**Scheduler Worker**</comment>' : $worker, CakeTime::timeAgoInWords(call_user_func(CakeResqueShell::$cakeResque . '::getWorkerStartDate', $worker)));
         };
     }
     $this->out('<info>' . $title . '</info>');
     if (empty($workers)) {
         $this->out('   ' . $noWorkersMessage);
     } else {
         $workerIndex = array();
         if (!$this->params['all'] && count($workers) > 1) {
             $this->out($listTitle . ':');
             $i = 1;
             foreach ($workers as $worker) {
                 $this->out($formatListItem($worker, $i++));
             }
             $options = range(1, $i - 1);
             if ($i > 2) {
                 $this->out('    [all] - ' . $allActionMessage);
                 $options[] = 'all';
             }
             $in = $this->in($promptMessage . ': ', $options);
             if ($in == 'all') {
                 $workerIndex = range(1, count($workers));
             } else {
                 $workerIndex[] = $in;
             }
         } else {
             $workerIndex = range(1, count($workers));
         }
         foreach ($workerIndex as $index) {
             $worker = $workers[$index - 1];
             list($hostname, $pid, $queue) = explode(':', (string) $worker);
             if (Configure::read('CakeResque.Scheduler.enabled') === true && $ResqueStatus->isSchedulerWorker($worker)) {
                 if ($schedulerWorkerAction !== null) {
                     $schedulerWorkerAction($worker);
                 }
                 $this->out($schedulerWorkerActionMessage, 0);
             } else {
                 $this->out($workerActionMessage($pid), 0);
             }
             $killResponse = $this->_kill($signal, $pid);
             $successCallback($worker);
             if ($killResponse['code'] === 0) {
                 $this->out('<success>' . __d('cake_resque', 'Done') . '</success>');
             } else {
                 $this->out('<error>' . $killResponse['message'] . '</error>');
             }
         }
     }
     $this->out('');
 }
开发者ID:rchavik,项目名称:Cake-Resque,代码行数:67,代码来源:CakeResqueShell.php


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