本文整理汇总了PHP中CakeTime::format方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeTime::format方法的具体用法?PHP CakeTime::format怎么用?PHP CakeTime::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeTime
的用法示例。
在下文中一共展示了CakeTime::format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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");
}
}
示例2: 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);
}
示例3: 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;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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));
}
}
示例7: updateInfo
public function updateInfo($attrs)
{
$this->create();
if (!empty($attrs['book_id'])) {
$this->set('book_id', $attrs['book_id']);
$book = $this->Book->find('first', array('conditions' => array('Book.id' => $attrs['book_id'])));
}
if (!empty($attrs['user_id'])) {
$this->set('user_id', $attrs['user_id']);
}
if ($attrs['event'] == 'bet_start') {
$content = '[Bet Now!] ' . $book['Book']['title'] . ' | Bet start time:' . CakeTime::format($book['Book']['bet_start'], '%Y/%m/%d %H:%M') . ' , The bet has started!';
} elseif ($attrs['event'] == 'bet_result') {
$content = '[Result Announcement!] ' . $book['Book']['title'] . ' | Announcement time:' . CakeTime::format($book['Book']['modified'], '%Y/%m/%d %H:%M') . ' , The results have been announced!';
}
$this->set('content', $content);
$this->set('event', $attrs['event']);
$this->save();
}
示例8: formatDateFields
public function formatDateFields($results, $dates, $format = "%d/%m/%Y")
{
if (!empty($dates)) {
$setResult = function ($val, $key) use(&$results, $format) {
$innerKey = explode("/", $key);
$results[$innerKey[0]][$innerKey[1]][$innerKey[2]] = CakeTime::format($val, $format);
};
$extracted = Set::extract($results, "/{$this->alias}");
$dateExtracted = Set::classicExtract($extracted, '{\\w+}.{\\w+}.{' . implode("|", $dates) . '}');
$applied = Set::apply("/", $dateExtracted, function ($val) {
return count(Set::filter($val)) > 0 ? $val : null;
});
if ($applied) {
$flatten = Set::flatten($applied, "/");
array_walk($flatten, $setResult);
}
}
return $results;
}
示例9: admin_genericos
function admin_genericos()
{
// $keypass = $this->Auth->user('empresa_id')*2313231323132313;
// $login = array(
// 'acesso' => 1,
// 'empresa_id' => $this->Auth->user('empresa_id'),
// 'post_keypass' => 'BL'.$keypass.'AC'
// );
$this->autoRender = false;
$model = 'Conteudo';
$this->set('model', $model);
$keypass = $this->params->query['keypass'];
$empresa_id = substr($keypass, 2, -2);
$empresa_id = $empresa_id / 2313231323132313;
$sql = "SELECT c.*, e.empresa_id FROM tb_conteudo as c JOIN tb_conteudo_empresas as e ON c.id = e.conteudo_id WHERE e.empresa_id = {$empresa_id}";
$all = $this->{$model}->query($sql);
$json_rdy["conteudos"] = array();
foreach ($all as $content) {
$created = CakeTime::format('%d | %e de %B', $content['c']['created']);
$json_rdy["conteudos"] = array("id" => $content['c']['id'], "categoria_id" => $content['c']['categoria_id'], "titulo" => $content['c']['titulo'], "texto" => $content['c']['texto'], "created" => $created);
}
echo "<pre>";
print_r($json_rdy);
}
示例10: index
/**
* index method
* @param boolean $post
* @return void
*/
public function index($post = null)
{
$user_id = $this->Session->read('user_id');
$this->Round->recursive = -1;
$this->paginate = array('fields' => array('Round.id', 'Round.title', 'Round.description', 'Round.ends_in_date', 'Project.title', 'Project.id'), 'contain' => array('Project'));
$rounds = $this->Round->UsersRound->find('list', array('recursive' => -1, 'fields' => 'UsersRound.round_id', 'group' => 'UsersRound.round_id', 'conditions' => array('UsersRound.user_id' => $user_id)));
$this->Round->contain(false, array('Project'));
App::uses('CakeTime', 'Utility');
$date = CakeTime::format('+1 days', '%Y-%m-%d');
$conditions = array('conditions' => array('AND' => array('Round.id' => $rounds, 'ends_in_date IS NOT NULL', "ends_in_date >= {$date}")));
$data = $this->Session->read('data');
$busqueda = $this->Session->read('search');
if ($post == null) {
$this->Session->delete('data');
$this->Session->delete('search');
$this->set('search', '');
} else {
$conditions['conditions']['OR'] = $data;
$this->set('search', $busqueda);
}
$this->paginate = $conditions;
$name = strtolower($this->name);
$this->set($name, $this->paginate());
}
示例11: analysis
public function analysis()
{
$this->Cookie = $this->Components->load('Cookie');
$this->Cookie->type('rijndael');
$projects = array();
// $this->Cookie->time = '999 hours';
if ($this->request->is(array('post', 'put'))) {
// debug($this->request->data);
if (isset($this->request->data['Participant']['email'])) {
$email = $this->request->data['Participant']['email'];
}
if (isset($this->request->data['Participant']['code'])) {
$code = $this->request->data['Participant']['code'];
}
$project_id = -1;
if (isset($this->request->data['Project']['Project'])) {
$project_id = $this->request->data['Project']['Project'];
}
if ($this->data['Participant']['remember_me'] && isset($code) && isset($email)) {
$cookie = array();
$cookie['email'] = $email;
$cookie['code'] = $code;
if (isset($project_id)) {
$cookie['project_id'] = $project_id;
}
$this->Cookie->write('participantData', $cookie, true, '+2 weeks');
} else {
if ($this->Cookie->check('participantData')) {
$this->Cookie->destroy('participantData');
}
}
$projects = $this->getParticipantProjects($email, $code);
App::uses('Folder', 'Utility');
App::uses('File', 'Utility');
if (isset($this->request->data['Participant']['analyze_File']) && $this->request->data['Participant']['analyze_File']['size'] > 0 && !empty($projects)) {
/* ============================================= */
/* ==============Load analysis=================== */
/* ============================================= */
if ($this->request->data['Participant']['analyze_File']['size'] > $this->filesize2bytes(Configure::read('max_file_size'))) {
$this->Session->setFlash("The file can not be more than " . Configure::read('max_file_size'));
return $this->redirect(array('controller' => 'Participants', 'action' => 'analysis'));
}
$file = $this->request->data['Participant']['analyze_File']['name'];
if (pathinfo($file, PATHINFO_EXTENSION) != 'tsv') {
$this->Session->setFlash("The file must be in TSV format");
return $this->redirect(array('controller' => 'Participants', 'action' => 'analysis'));
}
$file = new File($this->request->data['Participant']['analyze_File']['tmp_name']);
if ($file->readable()) {
$content = $file->read();
$file->close();
$lines = explode("\n", $content);
$incorrectFormat = empty($lines);
$count = 0;
$size = count($lines);
for ($index = 0; $index < $size; $index++) {
if (strlen(trim($lines[$index])) > 0) {
if (!$incorrectFormat) {
$columns = explode("\t", $lines[$index]);
for ($i = 0; $i < count($columns); $i++) {
if (strlen(trim($columns[$i])) == 0) {
$incorrectFormat = true;
}
}
$incorrectFormat = $incorrectFormat || sizeof($columns) != 5;
$count++;
} else {
break;
}
}
}
// $correctFormat = $this->correctTsvFormat($file, 5);
if ($incorrectFormat) {
// $count=$this->incorrecLineTsvFormat($file);
$this->Session->setFlash("Incorrect content file. Line {$count} is incorrect. " . "Content file must be in this format WO2009026621A1->A:12:24->1->0.99->paliperidone");
return $this->redirect(array('controller' => 'Participants', 'action' => 'analysis'));
}
$participantID = $this->Participant->find('first', array("recursive" => -1, "fields" => array("id"), "conditions" => array('Participant.email' => $email, 'Participant.code' => $code)));
$participantID = $participantID["Participant"]["id"];
$this->request->data['Participant']['id'] = $participantID;
$this->participantSaveConnection($this->request->data['Participant'], "uploadAnalysis");
// $this->Participant->UploadedAnnotation->deleteAll(array(
// "participant_id" => $participantID));
//
// $this->Participant->PredictionDocument->deleteAll(array(
// "participant_id" => $participantID,
// "project_id" => $project_id
// ));
$javaJarPath = Configure::read('javaJarPath');
$analyze_program = Configure::read('analyze_program');
$runJava = Configure::read('runJava');
$program = $javaJarPath . DS . $analyze_program;
$path = $this->request->data['Participant']['analyze_File']['tmp_name'];
$file = new File($path);
if ($file->readable()) {
$newPath = $file->Folder->path . DS . md5(date('Y-m-d H:i:s:u')) . $file->name() . "mtmp";
$file->copy($newPath);
$path = $newPath;
} else {
throw new Exception("Ops! file could not be readed");
//.........这里部分代码省略.........
示例12: finalize
/**
* Hurad configuration step
*/
public function finalize()
{
$this->set('title_for_layout', __d('hurad', 'Hurad Configuration'));
$dataSource = ConnectionManager::getDataSource('default');
if ($this->request->is('post')) {
$this->Installer->set($this->request->data);
if ($this->Installer->validates()) {
$search = [];
$search['$[prefix]'] = $dataSource->config['prefix'];
App::uses('CakeTime', 'Utility');
$search['$[created]'] = CakeTime::format('Y-m-d H:i:s', strtotime('now'));
$search['$[modified]'] = CakeTime::format('Y-m-d H:i:s', strtotime('now'));
$request = new CakeRequest();
$search['$[client_ip]'] = $request->clientIp();
$search['$[user_agent]'] = $request::header('USER_AGENT');
$search['$[username]'] = $this->request->data['Installer']['site_username'];
$search['$[email]'] = $this->request->data['Installer']['email'];
$search['$[password]'] = Security::hash($this->request->data['Installer']['site_password'], null, true);
$search['$[title]'] = $this->request->data['Installer']['site_title'];
$serverName = env("SERVER_NAME");
$url = Router::url('/');
$search['$[site_url]'] = rtrim("http://" . $serverName . $url, '/');
if ($dataSource->connected) {
if ($this->__executeSQL("hurad_defaults.sql", $dataSource, $search)) {
$this->Session->setFlash(__d('hurad', 'Hurad successfully installed.'), 'flash_message', array('class' => 'success'));
$this->redirect(array('action' => 'welcome'));
}
} else {
$this->Session->setFlash(__d('hurad', 'Not connected to database.'), 'flash_message', array('class' => 'danger'));
}
}
}
}
示例13: feed
public function feed()
{
$this->Event->contain(array('Artist' => array('fields' => array('id', 'title')), 'Type' => array('fields' => array('id', 'title')), 'Place' => array('fields' => array('id', 'title'))));
$start = $this->request->query['start'];
$end = $this->request->query['end'];
$this->Event->recursive = 1;
$events = $this->Event->find('all', array('conditions' => array('AND' => array('start >=' => $start, 'start <=' => $end)), 'fields' => array('Event.start', 'Event.end', 'Event.title', 'Event.id', 'Event.regular_ticket_price', 'Event.discounted_ticket_price')));
foreach ($events as $key => $event) {
$events[$key]['start'] = CakeTime::toAtom($event['Event']['start']);
$events[$key]['start_day'] = CakeTime::format($event['Event']['start'], '%e %B %Y');
$events[$key]['start_time'] = CakeTime::format($event['Event']['start'], '%Hh%M');
$events[$key]['end'] = CakeTime::toAtom($event['Event']['end']);
$events[$key]['title'] = $event['Event']['title'];
$events[$key]['regular_ticket_price'] = $event['Event']['regular_ticket_price'];
$events[$key]['discounted_ticket_price'] = $event['Event']['discounted_ticket_price'];
unset($events[$key]['Event']);
}
$this->set('data', $events);
$this->layout = 'ajax';
$this->render('../Shared/json/data');
return;
}
示例14: oldCopyRound
public function oldCopyRound($projectId = null)
{
if ($this->request->is('post') || $this->request->is('put')) {
//$this -> autoRender = false;
if (!empty($this->request->data['Round']['Round'])) {
$oldRoundId = $this->request->data['Round']['Round'];
$round = $this->Round->find('first', array('recursive' => -1, 'conditions' => array('Round.id' => $oldRoundId)));
if (trim($this->request->data['Round']['title']) == '' || !isset($this->request->data['Round']['title'])) {
$this->Session->setFlash('Please select one Title');
$this->redirect(array('controller' => 'rounds', 'action' => 'copyRound', $projectId));
}
App::uses('CakeTime', 'Utility');
if (CakeTime::isFuture($round['Round']['ends_in_date'])) {
$this->Round->id = $round['Round']['id'];
$date = CakeTime::format('-1 days', '%Y-%m-%d');
$this->Round->saveField('ends_in_date', $date);
}
if (empty($this->request->data['Round']['User'])) {
$this->Session->setFlash('You must choose at least one user');
$this->redirect(array('controller' => 'rounds', 'action' => 'copyRound', $projectId));
} else {
$oldRoundId = $this->request->data['Round']['Round'];
$this->Round->create();
$this->request->data['Round']['ends_in_date'] = NULL;
$users = $this->request->data['Round']['User'];
$conditions_userRounds = array('UsersRound.round_id' => $oldRoundId, 'UsersRound.user_id' => $users);
//guardamos los usuarios en condiciones
unset($this->request->data['Round']['User']);
$title = $this->request->data['Round']['title'];
$this->request->data['Round']['title'] = $title . '-[0%]';
$errors = "";
//$db = $this->Round->getDataSource();
//$db->begin();
if ($this->Round->save($this->request->data, false)) {
//se deshabilita el save para poder guardar rounds con ends_in_date = NULL
//esta bandera marcara que un round esta en estado de copia
$this->Session->setFlash('We are creating a new version of the round. Please be patient', 'information');
//cortamos la ejecucion parab el usuario pero el script sigue en ejecucion
//de esta forma el usuario puedeseguir navegando
$this->backGround(array('controller' => 'projects', 'action' => 'view', $round['Round']['project_id']));
$round_id = $this->Round->id;
$newRoundId = $this->Round->id;
$size_userRounds = $this->Round->UsersRound->find('count', array('recursive' => -1, 'conditions' => $conditions_userRounds));
/**
* tamaño de particiones
* Haremos una particion de los rounds para no sobrecargar la memoria
* ** */
if ($size_userRounds > 0) {
//hacemos partioces de user_rounds de 100
$particiones_userRounds = 100;
$size_userRounds_total = $size_userRounds;
//si el tamaño es mayor que la particion calculamos cuantas veces vamos a tener que hacer
if ($size_userRounds > $particiones_userRounds) {
$fin_userRounds = $size_userRounds / $particiones_userRounds;
//calculamos el numero de beces a la baja
// por ejemplo 2.5 se haces dos veces
$fin_userRounds = floor($fin_userRounds);
//si existe resto se hace una vez mas
if ($size_userRounds % $particiones_userRounds != 0) {
$fin_userRounds++;
}
} else {
// si no la particion es = al tamaño
$particiones_userRounds = $size_userRounds;
$fin_userRounds = 1;
}
$contador_userRounds = 0;
$procces_userRounds = 0;
$time = date('Y-m-d H:i:s');
//variables para monotorizar la copia
$worked = 0;
$procces = 0;
while ($contador_userRounds < $fin_userRounds) {
$usersRounds = $this->Round->UsersRound->find('all', array('offset' => $procces_userRounds, 'limit' => $particiones_userRounds, 'recursive' => -1, 'fields' => array('UsersRound.id', 'UsersRound.user_id', 'UsersRound.document_id', 'UsersRound.text_marked'), 'conditions' => $conditions_userRounds));
//se eligen bucles for en vez de bucles foreach dado que son mas rapidos si se van a modificar datos
//http://www.phpbench.com/
$usersRoundTam = sizeof($usersRounds);
for ($i = 0; $i < $usersRoundTam; $i++) {
$procces++;
$worked = $procces / $size_userRounds_total * 100;
if (round($worked) % 10 == 0) {
$data = array('Round' => array('title' => $title . '-[' . round($worked) . '%]'));
$this->Round->save($data);
}
$usersRounds[$i]['UsersRound']['created'] = $time;
$conditions = array('Annotation.round_id' => $oldRoundId, 'Annotation.document_id' => $usersRounds[$i]['UsersRound']['document_id'], 'Annotation.user_id' => $usersRounds[$i]['UsersRound']['user_id'], 'Annotation.users_round_id' => $usersRounds[$i]['UsersRound']['id']);
$textoForMatches = $usersRounds[$i]['UsersRound']['text_marked'];
$usersRounds[$i]['UsersRound']['round_id'] = $newRoundId;
unset($usersRounds[$i]['UsersRound']['id']);
unset($usersRounds[$i]['UsersRound']['text_marked']);
$this->Round->UsersRound->create();
if ($this->Round->UsersRound->save($usersRounds[$i])) {
$size_annotations = $this->Round->UsersRound->Annotation->find('count', array('recursive' => -1, 'conditions' => $conditions));
if ($size_annotations > 0) {
$parseKey = Configure::read('parseKey');
$parseIdAttr = Configure::read('parseIdAttr');
/**
* Particiones de anotaciones
*/
$particiones_annotations = 400;
//.........这里部分代码省略.........
示例15: admin_createDta
private function admin_createDta($dtaRequests)
{
$dtaFile = new DTA(DTA_DEBIT);
$dtaFile->setAccountFileSender(array('name' => 'Ringelsoeckchen e.V.', 'bank_code' => 37050299, 'account_number' => 138274368));
$this->Fee->Member->recursive = -1;
foreach ($dtaRequests as $dtaRequest) {
//Get member information
$member = $this->Fee->Member->find('first', array('conditions' => array('id' => $dtaRequest['member_id'])));
//Get yearly fee information
$yearly_fee = $this->Fee->YearlyFee->find('first', array('conditions' => array('year' => $dtaRequest['year'])));
$dtaFile->addExchange(array('name' => $member['Member']['account_holder'], 'bank_code' => $member['Member']['bank_code'], 'account_number' => $member['Member']['account_number']), $yearly_fee['YearlyFee']['fee'], array('Ringelsoeckche Beitrag ' . $dtaRequest['year'], $member['Member']['full_name']));
}
$dtaFile->saveFile(TMP . 'dta.dta');
$this->viewClass = 'Media';
$params = array('id' => 'dta.dta', 'name' => 'Mitgliedsbeitraege' . CakeTime::format('Y-m-d', time()), 'download' => true, 'extension' => 'dta', 'path' => TMP);
$this->set($params);
}