public function beforeFilter(Event $event) { parent::beforeFilter($event); Time::$defaultLocale = 'en-CA'; Time::setToStringFormat('YYYY-MM-dd'); $this->Session = $this->request->session(); $this->set('Session', $this->Session); $this->_icons = $this->Utilities->setIcons(); $this->set('icons', $this->_icons); $title = $this->Utilities->setDefaultTitle(); $breadcrumbs = $this->Utilities->setDefaultBreadcrumbs(); $this->set(compact('title', 'breadcrumbs')); if (empty($this->request->params['prefix'])) { $this->Auth->allow(); $this->viewBuilder()->layout('public'); } // Set the user logged in if (!is_null($this->Auth->user('id'))) { $Users = TableRegistry::get('Users'); $this->_user = $Users->get($this->Auth->user('id')); $this->set('authUser', $this->_user); } else { $this->set('authUser', false); } // $this->set(compact($authUser)); $nav = $this->_setNav(); $this->set(compact('nav')); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $this->View = new View(); $this->Time = new TimeHelper($this->View); Time::$defaultLocale = 'en_US'; }
/** * Initialization hook method. * * Use this method to add common initialization code like loading components. * * e.g. `$this->loadComponent('Security');` * * @return void */ public function initialize() { parent::initialize(); $this->loadComponent('RequestHandler'); $this->loadComponent('Flash'); $this->loadComponent('Auth', ['authorize' => ['Controller'], 'loginRedirect' => ['controller' => 'Pages', 'action' => 'display', 'home'], 'logoutRedirect' => ['controller' => 'Pages', 'action' => 'display', 'home']]); Time::$defaultLocale = 'fr-FR'; }
/** * Initialization hook method. * * Use this method to add common initialization code like loading components. * * @return void */ public function initialize() { parent::initialize(); $this->loadComponent('Flash'); $this->loadComponent('Paginator'); Time::$defaultLocale = 'es-ES'; Time::setToStringFormat('dd-MM-YYYY HH:mm'); }
/** * Initialization hook method. * * Use this method to add common initialization code like loading components. * * e.g. `$this->loadComponent('Security');` * * @return void */ public function initialize() { $this->loadComponent('Flash'); $this->loadComponent('RequestHandler'); // added in line to format date correctly Time::$defaultLocale = 'en-AU'; Time::setToStringFormat('dd/MM/YYYY'); $this->loadComponent('Auth', ['authorize' => ['Controller'], 'authenticate' => ['Form' => ['fields' => ['username' => 'email', 'password' => 'password']]], 'loginRedirect' => ['controller' => 'pages', 'action' => 'home'], 'logoutRedirect' => ['controller' => 'Pages', 'action' => 'display', 'home']]); }
public function initialize() { parent::initialize(); $this->loadComponent('RequestHandler'); $this->loadComponent('Flash'); $this->loadComponent('Auth', ['authorize' => ['Controller'], 'loginRedirect' => ['controller' => 'Characters', 'action' => 'index'], 'logoutRedirect' => ['controller' => 'Users', 'action' => 'login']]); $this->loadComponent('Cookie'); $this->loadComponent('Slack', ['webhook_url' => Configure::read('Slack.webhook_url'), 'enabled' => Configure::read('Slack.enabled')]); Time::$defaultLocale = 'en-GB'; }
/** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); Time::setTestNow($this->now); Time::$defaultLocale = $this->locale; Time::resetToStringFormat(); FrozenTime::setTestNow($this->frozenNow); FrozenTime::$defaultLocale = $this->locale; FrozenTime::resetToStringFormat(); date_default_timezone_set('UTC'); }
/** * viewAllInfo method * * @author Gustavo Marques | Genival Rocha | Caroline Machado * @param UUID $idlotebandejas Primary key loteBandejas. * @return void */ public function viewAllInfo($idlotebandejas = null) { Time::$defaultLocale = 'pt-BR'; $this->loadModel('Alimentacao'); $alimeQuery = $this->Alimentacao->find('all')->where(['fk_lotebandejas' => $idlotebandejas]); $lotebandeja = $this->Lotebandejas->get($idlotebandejas, ['contain' => []]); $this->paginate = ['maxLimit' => 11]; $this->set('alimentacao', $this->paginate($alimeQuery)); $this->set('lotebandeja', $lotebandeja); $this->set('_serialize', ['lotebandeja']); }
/** * list_add method * @author Gustavo Marques | Genival Rocha | Caroline Machado * @param string|null $idBequer Bequer id, string|null $idBequer Numero do Bequer * @return void Redireciona para mesma pagina. */ public function list_add($idBequer = null, $n_bequer = null) { Time::$defaultLocale = 'pt-BR'; $ovosQuery = $this->Ovos->find('all')->where(['fk_bequer' => $idBequer]); $this->paginate = ['maxLimit' => 3]; $this->set('ListOvos', $this->paginate($ovosQuery)); $ovo = $this->Ovos->newEntity(); $this->set('n_bequer', $n_bequer); if ($this->request->is('post')) { $ovo = $this->Ovos->patchEntity($ovo, $this->request->data); $ovo->set(['fk_bequer' => $idBequer]); if ($this->Ovos->save($ovo)) { $this->Flash->success('Ovo salvo com sucesso.'); return $this->redirect(['action' => 'list_add', $idBequer, $n_bequer]); } else { $this->Flash->error('Não foi possível salvar o ovo. Por favor, tente novamente.'); } } $this->set(compact('ovo')); $this->set('_serialize', ['ovo']); }
/** * list_add method * @author Gustavo Marques | Genival Rocha | Caroline Machado * @param UUID|null idAlimentacao Alimentacao id, UUID|null $fk_lotebandejas Foreign key lotebandejas, int|null $n_bandeja Numero da bandeja * @return void Redireciona para mesma pagina. */ public function list_add($fk_lotebandejas = null, $n_bandeja = null) { Time::$defaultLocale = 'pt-BR'; $alimentacaoQuery = $this->Alimentacao->find('all')->where(['fk_lotebandejas' => $fk_lotebandejas]); $this->paginate = ['maxLimit' => 3]; $this->set('ListAlimentacao', $this->paginate($alimentacaoQuery)); $alimentacao = $this->Alimentacao->newEntity(); $this->set('n_bandeja', $n_bandeja); if ($this->request->is('post')) { $alimentacao = $this->Alimentacao->patchEntity($alimentacao, $this->request->data); $alimentacao->set(['fk_lotebandejas' => $fk_lotebandejas]); if ($this->Alimentacao->save($alimentacao)) { $this->Flash->success('Cadastro de Alimentação adicionado com sucesso.'); return $this->redirect(['action' => 'list_add', $fk_lotebandejas, $n_bandeja]); } else { $this->Flash->error('Não foi possível adicionar o cadastro de alimentação. Por favor, tente novamente.'); } } $this->set(compact('alimentacao')); $this->set('_serialize', ['alimentacao']); }
/** * Add method * * @return void Redirects on successful add, renders view otherwise. */ public function add() { Time::$defaultLocale = 'pt-BR'; $this->loadModel('Lotetransporte'); $lotesDisponiveis = $this->Lotetransporte->find('all'); $lotesList = $lotesDisponiveis->find('list', ['value' => 'lotetransporteid', 'valueField' => 'n_transporte']); $this->set('optionLotes', $lotesList); $temperaturatransporte = $this->Temperaturatransporte->newEntity(); if ($this->request->is('post')) { $temperaturatransporte = $this->Temperaturatransporte->patchEntity($temperaturatransporte, $this->request->data); $hora_leitura = $this->request->data('hora_leitura'); $temperaturatransporte->set(['hora_leitura' => $hora_leitura['hour'] . ':' . $hora_leitura['minute']]); if ($this->Temperaturatransporte->save($temperaturatransporte)) { $this->Flash->success('The temperaturatransporte has been saved.'); return $this->redirect(['action' => 'index']); } else { $this->Flash->error('The temperaturatransporte could not be saved. Please, try again.'); } } $this->set(compact('temperaturatransporte')); $this->set('_serialize', ['temperaturatransporte']); }
/** * Add method * * @author Gustavo Marques | Genival Rocha | Caroline Machado * @return void Redirects on successful add, renders view otherwise. */ public function add() { Time::$defaultLocale = 'pt-BR'; $this->loadModel('Lotebandejas'); $this->loadModel('Bequer'); //$lotesRecentes = $this->Lotebandejas->find('all', ['fields' => 'codigo']); $lotesDisponiveis = $this->Lotebandejas->find('all')->join(['table' => 'montagem', 'type' => 'LEFT', 'alias' => 'c', 'conditions' => ['c.fk_lotebandejas = lotebandejas.lotebandejasid']])->where(['c.fk_bequer IS NULL']); $lotesList = $lotesDisponiveis->find('list', ['value' => 'lotebandejasid', 'valueField' => 'codigo']); $this->set('optionLotes', $lotesList); $bequerList = $this->Bequer->find('list', ['value' => 'bequerid', 'valueField' => 'n_bequer', 'order' => ['n_bequer' => 'desc']]); $this->set('optionBequer', $bequerList); $montagem = $this->Montagem->newEntity(); if ($this->request->is('post')) { $arrayBequer = $this->request->data('list_bequer'); if ($arrayBequer == '') { $this->Flash->error('Por favor selecione um béquer.'); } else { $lotebandejasForm = $this->request->data('fk_lotebandejas'); $lotebandejasQuery = $this->Lotebandejas->get($lotebandejasForm); $tipoBandejaConst = $this->request->data('tipo_bandeja') . $lotebandejasQuery->codigo; foreach ($arrayBequer as $value) { $montagem = $this->Montagem->newEntity(); $montagem = $this->Montagem->patchEntity($montagem, $this->request->data); $montagem->set(['fk_bequer' => $value]); $montagem->set(['tipo_bandeja' => $tipoBandejaConst]); if ($this->Montagem->save($montagem)) { $this->Flash->success('Cadastro de montagem adicionado com sucesso.'); } else { $this->Flash->error('Não foi possível adicionar o cadastro de montagem. Por favor, tente novamente.'); } } return $this->redirect(['action' => 'index']); } } $this->set(compact('montagem')); $this->set('_serialize', ['montagem']); }
/** * Tests that parsing a date respects de default timezone in PHP. * * @return void */ public function testParseDateDifferentTimezone() { date_default_timezone_set('Europe/Paris'); Time::$defaultLocale = 'fr-FR'; $result = Time::parseDate('12/03/2015'); $this->assertEquals('2015-03-12', $result->format('Y-m-d')); $this->assertEquals(new \DateTimeZone('Europe/Paris'), $result->tz); }
/** * test formatting dates taking in account preferred i18n locale file * * @return void */ public function testFormat() { $time = strtotime('Thu Jan 14 13:59:28 2010'); $result = $this->Time->format($time); $expected = '1/14/10, 1:59 PM'; $this->assertTimeFormat($expected, $result); $result = $this->Time->format($time, \IntlDateFormatter::FULL); $expected = 'Thursday, January 14, 2010 at 1:59:28 PM GMT'; $this->assertTimeFormat($expected, $result); $result = $this->Time->format('invalid date', null, 'Date invalid'); $expected = 'Date invalid'; $this->assertEquals($expected, $result); I18n::locale('fr_FR'); Time::$defaultLocale = 'fr_FR'; $time = new \Cake\I18n\FrozenTime('Thu Jan 14 13:59:28 2010'); $result = $this->Time->format($time, \IntlDateFormatter::FULL); $expected = 'jeudi 14 janvier 2010 13:59:28 UTC'; $this->assertTimeFormat($expected, $result); }
/** * Tests that __toString uses the i18n formatter * * @return void */ public function testToString() { $time = new Time('2014-04-20 22:10'); Time::$defaultLocale = 'fr-FR'; Time::setToStringFormat(\IntlDateFormatter::FULL); $this->assertTimeFormat('dimanche 20 avril 2014 22:10:00 UTC', (string) $time); }
/** * Index method * * @return void */ public function index() { Time::$defaultLocale = 'pt-BR'; $this->set('bequer', $this->paginate($this->Bequer)); $this->set('_serialize', ['bequer']); }
/** * Set server timezone to UTC. You can change it to another timezone of your * choice but using UTC makes time calculations / conversions easier. */ date_default_timezone_set('America/Sao_Paulo'); /** * Configure the mbstring extension to use the correct encoding. */ mb_internal_encoding(Configure::read('App.encoding')); /** * Set the default locale. This controls how dates, number and currency is * formatted and sets the default language to use for translations. */ ini_set('intl.default_locale', 'pt_BR'); setlocale(LC_ALL, 'pt_BR'); Time::$defaultLocale = 'pt-BR'; Time::setToStringFormat('dd/MM/YYYY'); /** * Register application error and exception handlers. */ $isCli = php_sapi_name() === 'cli'; if ($isCli) { (new ConsoleErrorHandler(Configure::read('Error')))->register(); } else { (new ErrorHandler(Configure::read('Error')))->register(); } // Include the CLI bootstrap overrides. if ($isCli) { require __DIR__ . '/bootstrap_cli.php'; } /**
* For full copyright and license information, please see the LICENSE.txt * Redistributions of files must retain the above copyright notice. * * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @since 0.2.9 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ namespace App\Controller; use Cake\Controller\Controller; use Cake\Database\Type; use Cake\Event\Event; use Cake\I18n\Time; use Cake\Utility\Text; Time::$defaultLocale = 'en_US'; Time::setToStringFormat('MMM d, Y h:mm a'); Type::build('datetime')->useLocaleParser(); /** * Application Controller * * Add your application-wide methods in the class below, your controllers * will inherit them. * * @link http://book.cakephp.org/3.0/en/controllers.html#the-app-controller */ class AppController extends Controller { /** * Initialization hook method. *
/** * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more * advanced ways of loading plugins * * Plugin::loadAll(); // Loads all plugins at once * Plugin::load('Migrations'); //Loads a single plugin named Migrations * */ //Plugin::load('Migrations'); //Plugin::load('Xety/Cake3Upload'); Plugin::loadAll(); // Only try to load DebugKit in development mode // Debug Kit should not be installed on a production system if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } /** * Connect middleware/dispatcher filters. */ DispatcherFactory::add('Asset'); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); //DispatcherFactory::add('LocaleSelector', ['locales' => ['en-US', 'fr-FR']]); /** * Enable default locale format parsing. * This is needed for matching the auto-localized string output of Time() class when parsing dates. */ Type::build('datetime')->useLocaleParser(); Time::$defaultLocale = 'fr-FR';
/** * Tests parsing times using the parseTime function * * @return void */ public function testParseTime() { $time = Time::parseTime('12:54am'); $this->assertNotNull($time); $this->assertEquals('00:54:00', $time->format('H:i:s')); Time::$defaultLocale = 'fr-FR'; $time = Time::parseTime('23:54'); $this->assertNotNull($time); $this->assertEquals('23:54:00', $time->format('H:i:s')); $time = Time::parseTime('31c2:54'); $this->assertNull($time); }
* * Licensed under The MIT License * For full copyright and license information, please see the LICENSE.txt * Redistributions of files must retain the above copyright notice. * * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @since 0.2.9 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ namespace App\Controller; use Cake\Controller\Controller; use Cake\Event\Event; use Cake\I18n\Time; Time::$defaultLocale = 'es-ES'; Time::setToStringFormat('dd-MM-YYYY'); /** * Application Controller * * Add your application-wide methods in the class below, your controllers * will inherit them. * * @link http://book.cakephp.org/3.0/en/controllers.html#the-app-controller */ class AppController extends Controller { /** * Initialization hook method. * * Use this method to add common initialization code like loading components.