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


PHP CakeTime::nice方法代码示例

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


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

示例1: _mapping

 /**
  * _mapping method
  *
  * @param int $start
  * @param int $end
  * @return array
  */
 protected function _mapping($start = 0, $end = 0)
 {
     $mapping = array();
     for ($i = 1; $i <= 10; $i++) {
         $mapping[$i] = array('version' => $i, 'name' => "00{$i}_schema_dump", 'class' => 'M4af9d151e1484b74ad9d007058157726', 'type' => 'mocks', 'migrated' => null);
         if ($i >= $start && $i <= $end) {
             $mapping[$i]['migrated'] = CakeTime::nice();
         }
     }
     return $mapping;
 }
开发者ID:cakedc,项目名称:migrations,代码行数:18,代码来源:MigrationVersionTest.php

示例2: nice

 /**
  * Returns a nicely formatted date string for given Datetime string.
  *
  * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
  * @param string|DateTimeZone $timezone   User's timezone string or DateTimeZone object
  * @param string              $format     The format to use. If null, `CakeTime::$niceFormat` is used
  *
  * @return string Formatted date string
  * @see  CakeTime::nice()
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
  */
 public function nice($dateString = NULL, $timezone = NULL, $format = NULL)
 {
     return $this->_engine->nice($dateString, $timezone, $format);
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:15,代码来源:TimeHelper.php

示例3: _showInfo

 /**
  * Shows a list of available migrations
  *
  * @param array $mapping Migration mapping
  * @param string $type Can be 'app' or a plugin name
  * @return void
  */
 protected function _showInfo($mapping, $type = null)
 {
     if ($type === null) {
         $type = $this->type;
     }
     $version = $this->Version->getVersion($type);
     if ($version != 0) {
         $info = $mapping[$version];
         $this->out(__d('migrations', 'Current migration version:'));
         $this->out('  #' . sprintf("%'.03d", $version) . ' ' . $info['name']);
         $this->hr();
     }
     $this->out(__d('migrations', 'Available migrations:'));
     foreach ($mapping as $version => $info) {
         $this->out('  [' . sprintf("%'.03d", $version) . '] ' . $info['name']);
         $this->out('        ', false);
         if ($info['migrated'] !== null) {
             $this->out(__d('migrations', 'applied') . ' ' . CakeTime::nice(strtotime($info['migrated'])));
         } else {
             $this->out(__d('migrations', 'not applied'));
         }
     }
 }
开发者ID:cakedc,项目名称:migrations,代码行数:30,代码来源:MigrationShell.php

示例4: nice

 /**
  * Returns a nicely formatted date string for given Datetime string.
  *
  * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
  * @param string|DateTimeZone $timezone User's timezone string or DateTimeZone object
  * @param string $format The format to use. If null, `CakeTime::$niceFormat` is used
  * @return string Formatted date string
  * @see CakeTime::nice()
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
  */
 public function nice($dateString = null, $timezone = null, $format = null)
 {
     return $this->_engine->nice($dateString, $timezone, $format);
 }
开发者ID:basantk,项目名称:cakephp-user-login-basic-2.x,代码行数:14,代码来源:TimeHelper.php

示例5: testRenderCell

    public function testRenderCell()
    {
        $data = array('User' => array('id' => 1, 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'john@doe.com', 'created' => date('Y-m-d H:i:s')), 'Comment' => array(array('id' => 1, 'text' => 'foo bar'), array('id' => 2, 'text' => 'FOO BAR')));
        $result = $this->Table->renderCell('[time][User.created][/time]', $data);
        $expected = CakeTime::nice($data['User']['created']);
        $this->assertEqual($result, $expected);
        $result = $this->Table->renderCell('[truncate length=9 ellipsis=..][Comment.{n, }.text][/truncate]', $data);
        $expected = 'foo bar..';
        $this->assertEqual($result, $expected);
        $result = $this->Table->renderCell('[truncate length=9 ellipsis=..][Comment.{n}.invalid][/truncate]', $data);
        $expected = '';
        $this->assertEqual($result, $expected);
        $result = $this->Table->renderCell('[url]/users/email/[User.email][/url]', $data);
        $expected = $this->Table->url('/users/email/john@doe.com');
        $this->assertEqual($result, $expected);
        $result = $this->Table->renderCell('[image][url full]/users/email/[User.email][/url][/image]', $data);
        $expected = $this->Table->Html->image($this->Table->url('/users/email/john@doe.com', true));
        $this->assertEqual($result, $expected);
        $result = $this->Table->renderCell('[User.[php]return "first_name";[/php]]', $data);
        $expected = 'John';
        $this->assertEqual($result, $expected);
        $txt = <<<TEXT
[php] if ("[User.id]" == "1") {
\techo '
<div class="btn-group pull-right">
  <button type="button" class="btn btn-xs btn-default"><a href="[php]return Router::url(array_merge(array('plugin' => null, 'controller' => 'properties'), array("action" => "view", "[User.id]")));[/php]">[__d|dashboard]Details[/__d]</a></button>
</div>
\t';
}[/php]
TEXT;
        $expected = <<<TEXT

<div class="btn-group pull-right">
  <button type="button" class="btn btn-xs btn-default"><a href="/properties/view/1">Details</a></button>
</div>
\t
TEXT;
        $result = $this->Table->renderCell($txt, $data);
        $this->assertEqual($result, $expected);
        $txt = <<<TEXT
[php] if ("[User.id]" == "1") {
\techo '
<div class="btn-group pull-right">
  <button type="button" class="btn btn-xs btn-default"><a href="[php]return Router::url(array_merge(array('plugin' => null, 'controller' => 'properties'), array("action" => "view", "[User.id]")));[/php]">[__d|dashboard]Details[/__d]</a></button>
  <button type="button" class="btn btn-xs btn-default"><a href="[php]return Router::url(array_merge(array('plugin' => null, 'controller' => 'properties'), array("action" => "view", "[User.id]")));[/php]">[__d|dashboard]Details[/__d]</a></button>
</div>
\t';
}[/php]
TEXT;
        $expected = <<<TEXT

<div class="btn-group pull-right">
  <button type="button" class="btn btn-xs btn-default"><a href="/properties/view/1">Details</a></button>
  <button type="button" class="btn btn-xs btn-default"><a href="/properties/view/1">Details</a></button>
</div>
\t
TEXT;
        $result = $this->Table->renderCell($txt, $data);
        $this->assertEqual($result, $expected);
    }
开发者ID:gourmet,项目名称:common,代码行数:60,代码来源:TableHelperTest.php

示例6: upload

 public function upload()
 {
     $this->layout = 'ajax';
     $this->render(false);
     if ($this->request->is('POST')) {
         if (!empty($this->request->data['Post']['file'])) {
             if (!$this->request->data['Post']['file']['error']) {
                 $extension = pathinfo($this->request->data['Post']['file']['name'], PATHINFO_EXTENSION);
                 if (!in_array($extension, array('jpg', 'jpeg', 'JPG', 'JPEG'))) {
                     echo json_encode(array('error' => __('We only accept JPG or JPEG photo!')));
                     return;
                 }
                 if (!file_exists(IMAGES . 'photos')) {
                     App::uses('Folder', 'Utility');
                     new Folder(IMAGES . 'photos', true, 0775);
                 }
                 $filename = md5(microtime()) . '.jpg';
                 if (@move_uploaded_file($this->request->data['Post']['file']['tmp_name'], IMAGES . 'photos' . DS . $filename)) {
                     if (@exif_read_data(IMAGES . 'photos' . DS . $filename)) {
                         App::uses('CakeTime', 'Utility');
                         $exif = exif_read_data(IMAGES . 'photos' . DS . $filename);
                         $coordinates = $this->_getCoordinates($exif);
                         $datetime_original = isset($exif['DateTimeOriginal']) ? CakeTime::nice($exif['DateTimeOriginal']) : CakeTime::nice();
                         echo json_encode(array('coordinates' => $coordinates, 'photo' => $filename, 'datetime_original' => $datetime_original));
                         return;
                     } else {
                         echo json_encode(array('error' => __('Unable to analyze your photo.')));
                         return;
                     }
                 } else {
                     echo json_encode(array('error' => __('Unable to upload your photo.')));
                     return;
                 }
             } else {
                 echo json_encode(array('error' => $this->request->data['Post']['file']['error']));
                 return;
             }
         }
     }
     echo json_encode(array('photo' => null));
 }
开发者ID:kentux,项目名称:1d1p,代码行数:41,代码来源:PostsController.php


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