本文整理汇总了PHP中Date::of方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::of方法的具体用法?PHP Date::of怎么用?PHP Date::of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enqueueDB
/**
* enqueueDB
*
* @param string $type
* @param int $id
* @static
* @access public
* @return void
*/
public static function enqueueDB($type = '', $ids = array(), $action = 'index')
{
if ($type != '' && !empty($ids)) {
$db = App::get('db');
$userID = User::getInstance()->get('uidNumber');
$timestamp = Date::of()->toSql();
if ($db->tableExists('#__search_queue') && count($ids) > 0) {
$sql = "INSERT INTO #__search_queue (type, type_id, status, action, created_by, created) VALUES ";
foreach ($ids as $key => $id) {
if (!is_array($id)) {
$sql .= "('" . $type . "'," . $id . ", 0, '" . $action . "', " . $userID . ", '{$timestamp}}'),";
}
}
$sql = rtrim($sql, ',');
$sql .= ';';
try {
$db->setQuery($sql);
$db->query();
return true;
} catch (\Exception $e) {
//@FIXME: properly handle this error
ddie($e->getMessage());
}
} else {
throw new \Hubzero\Exception\Exception('Queue table does not exist.');
}
}
}
示例2: displayTask
/**
* Pull records and build the XML
*
* @return void
*/
public function displayTask()
{
// Incoming
$metadata = Request::getVar('metadataPrefix', 'oai_dc');
$from = Request::getVar('from');
if ($from) {
$from = Date::of($from)->toSql();
}
$until = Request::getVar('until');
if ($until) {
$until = Date::of($until)->toSql();
}
$set = Request::getVar('set');
$resumption = Request::getVar('resumptionToken');
$igran = "YYYY-MM-DD";
$igran .= $this->config->get('gran', 'c') == 'c' ? "Thh:mm:ssZ" : '';
$hubname = rtrim($this->config->get('base_url', str_replace('https', 'http', \Request::base())), '/');
$edate = $this->config->get('edate');
$edate = $edate ? strtotime($edate) : time();
$service = new Service($metadata, rtrim(Request::getSchemeAndHttpHost(), '/') . Route::url('index.php?option=' . $this->_option . '&task=stylesheet&metadataPrefix=' . $metadata));
$service->set('metadataPrefix', $metadata)->set('repositoryName', $this->config->get('repository_name', \Config::get('sitename')))->set('baseURL', $hubname)->set('protocolVersion', '2.0')->set('adminEmail', $this->config->get('email', \Config::get('mailfrom')))->set('earliestDatestamp', gmdate('Y-m-d\\Th:i:s\\Z', $edate))->set('deletedRecord', $this->config->get('del'))->set('granularity', $igran)->set('max', $this->config->get('max', 500))->set('limit', $this->config->get('limig', 50))->set('allow_ore', $this->config->get('allow_ore', 0))->set('gran', $this->config->get('gran', 'c'))->set('resumption', $resumption);
$verb = Request::getVar('verb');
switch ($verb) {
case 'GetRecord':
$service->record(Request::getVar('identifier'));
break;
case 'Identify':
$service->identify();
break;
case 'ListMetadataFormats':
$service->formats();
break;
case 'ListIdentifiers':
$service->identifiers($from, $until, $set);
break;
case 'ListRecords':
$sessionTokenResumptionTemp = Session::get($resumption);
if (!empty($resumption) && empty($sessionTokenResumptionTemp)) {
$service->error($service::ERROR_BAD_RESUMPTION_TOKEN);
}
$service->records($from, $until, $set);
break;
case 'ListSets':
$sessionTokenResumptionTemp = Session::get($resumption);
if (!empty($resumption) && empty($sessionTokenResumptionTemp)) {
$service->error($service::ERROR_BAD_RESUMPTION_TOKEN);
}
$service->sets();
break;
default:
$service->error($service::ERROR_BAD_VERB, Lang::txt('COM_OAIPMH_ILLEGAL_VERB'));
break;
}
Document::setType('xml');
echo $service;
}
示例3: onGetLatest
/**
* Event call to get the latest records
*
* @param integer $num
* @param string $dateField
* @param string $sort
* @return array
*/
public function onGetLatest($num = 5, $dateField = 'created', $sort = 'DESC')
{
$model = Post::getLatest($num, $dateField, $sort)->rows()->toObject();
$objects = array();
foreach ($model as $m) {
$object = new stdClass();
$object->title = $m->title;
$object->body = preg_replace('/[^ .,;a-zA-Z0-9_-]|[,;]/', '', $m->description);
$object->date = Date::of($m->created)->toLocal("F j, Y");
$object->path = $m->url;
$object->id = $m->id;
array_push($objects, $object);
}
return $objects;
}
示例4: onGetLatest
/**
* Event call to get the latest records
*
* @param integer $num
* @param string $dateField
* @param string $sort
* @return array
*/
public function onGetLatest($num = 5, $dateField = 'created', $sort = 'DESC')
{
$model = Resource::getLatest($num, $dateField, $sort)->rows()->toObject();
$objects = array();
foreach ($model as $m) {
$object = new stdClass();
$object->title = $m->title;
$object->body = htmlspecialchars_decode($m->introtext);
$object->date = Date::of($m->publish_up)->toLocal("F j, Y");
$object->path = 'resources/' . $m->id;
$object->id = $m->id;
array_push($objects, $object);
}
return $objects;
}
示例5: down
/**
* Down
**/
public function down()
{
if ($this->db->tableExists('#__feedaggregator_posts')) {
require_once PATH_CORE . DS . 'components' . DS . 'com_feedaggregator' . DS . 'models' . DS . 'post.php';
// Grab rows first
$rows = Post::all()->rows();
// Convert the field
$query = "ALTER TABLE `#__feedaggregator_posts` MODIFY created INT(11);";
$this->db->setQuery($query);
$this->db->query();
// Convert each timestamp into SQL date format
foreach ($rows as $row) {
$row->set('created', Date::of($row->created)->toUnix());
$row->save();
}
}
}
示例6: onPublication
/**
* Return data on a resource view (this will be some form of HTML)
*
* @param object $publication Current publication
* @param string $option Name of the component
* @param array $areas Active area(s)
* @param string $rtrn Data to be returned
* @param string $version Version name
* @param boolean $extended Whether or not to show panel
* @return array
*/
public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true)
{
$view = $this->view();
$publication->authors();
$publication->license();
// Add metadata
Document::setMetaData('citation_title', $view->escape($publication->title));
$nullDate = '0000-00-00 00:00:00';
$thedate = $publication->publish_up;
if (!$thedate || $thedate == $nullDate) {
$thedate = $publication->accepted;
}
if (!$thedate || $thedate == $nullDate) {
$thedate = $publication->submitted;
}
if (!$thedate || $thedate == $nullDate) {
$thedate = $publication->created;
}
if ($thedate && $thedate != $nullDate) {
Document::setMetaData('citation_date', Date::of($thedate)->toLocal('Y-m-d'));
}
if ($doi = $publication->version->get('doi')) {
Document::setMetaData('citation_doi', $view->escape($doi));
}
foreach ($publication->_authors as $contributor) {
if (strtolower($contributor->role) == 'submitter') {
continue;
}
if ($contributor->name) {
$name = stripslashes($contributor->name);
} else {
$name = stripslashes($contributor->p_name);
}
if (!$contributor->organization) {
$contributor->organization = $contributor->p_organization;
}
$contributor->organization = stripslashes(trim($contributor->organization));
Document::setMetaData('citation_author', $view->escape($name));
if ($contributor->organization) {
Document::setMetaData('citation_author_institution', $view->escape($contributor->organization));
}
}
}
示例7: displayTask
/**
* Display the overview
*/
public function displayTask()
{
foreach ($this->getErrors() as $error) {
$this->view->setError($error);
}
$hubSearch = new SearchEngine();
$hubSearch->getLog();
$this->view->logs = array_slice($hubSearch->logs, -10, 10, true);
// Need to fix permissions, www-data must be able to invoke start
//$hubSearch->start();
$helper = new Helper();
$dataTypes = $helper->fetchDataTypes($hubSearch->getConfig());
$insertTime = Date::of($hubSearch->lastInsert())->format('relative');
$this->view->status = $hubSearch->ping();
$this->view->lastInsert = $insertTime;
$this->view->setLayout('overview');
// Display the view
$this->view->display();
}
示例8: onPublication
/**
* Return data on a resource view (this will be some form of HTML)
*
* @param object $publication Current publication
* @param string $option Name of the component
* @param array $areas Active area(s)
* @param string $rtrn Data to be returned
* @param string $version Version name
* @param boolean $extended Whether or not to show panel
* @return array
*/
public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true)
{
$view = $this->view();
$publication->authors();
$publication->license();
// Add metadata
Document::setMetaData('dc.title', $view->escape($publication->title));
$nullDate = '0000-00-00 00:00:00';
if ($publication->publish_up && $publication->publish_up != $nullDate) {
Document::setMetaData('dc.date', Date::of($publication->publish_up)->toLocal('Y-m-d'));
}
if ($publication->submitted && $publication->submitted != $nullDate) {
Document::setMetaData('dc.date.submitted', Date::of($publication->submitted)->toLocal('Y-m-d'));
}
if ($publication->accepted && $publication->accepted != $nullDate) {
Document::setMetaData('dc.date.approved', Date::of($publication->accepted)->toLocal('Y-m-d'));
}
if ($doi = $publication->version->get('doi')) {
Document::setMetaData('dc.identifier', $view->escape($doi));
}
Document::setMetaData('dcterms.description', $view->escape($publication->abstract));
$license = $publication->license();
if (is_object($license)) {
Document::setMetaData('dcterms.license', $view->escape($license->title));
}
foreach ($publication->_authors as $contributor) {
if (strtolower($contributor->role) == 'submitter') {
continue;
}
if ($contributor->name) {
$name = stripslashes($contributor->name);
} else {
$name = stripslashes($contributor->p_name);
}
if (!$contributor->organization) {
$contributor->organization = $contributor->p_organization;
}
$contributor->organization = stripslashes(trim($contributor->organization));
Document::setMetaData('dcterms.creator', $view->escape($name . ($contributor->organization ? ', ' . $contributor->organization : '')));
}
}
示例9: getTimeForWeeklyBar
/**
* Get summary of time for each person on each day of the week
*
* @return void
*/
public static function getTimeForWeeklyBar()
{
$records = Record::all();
$records->select('user_id')->select('SUM(time)', 'time')->select('DATE_FORMAT(CONVERT_TZ(date, "+00:00", "' . Config::get('offset', '+00:00') . '"), "%Y-%m-%d")', 'day')->group('user_id')->group('day');
$users = [User::get('id')];
// Add extra users for proxies
foreach (Proxy::whereEquals('proxy_id', User::get('id')) as $proxy) {
$users[] = $proxy->user_id;
}
$records->whereIn('user_id', $users);
// Get the day of the week
$today = Date::of(Request::getVar('week', time()));
$dateofToday = $today->format('Y-m-d');
$dayOfWeek = $today->format('N') - 1;
$records->having('day', '>=', Date::of(strtotime("{$dateofToday} - {$dayOfWeek}days"))->toLocal('Y-m-d'))->having('day', '<', Date::of(strtotime("{$dateofToday} + " . (7 - $dayOfWeek) . 'days'))->toLocal('Y-m-d'));
$rows = $records->including('user')->rows();
foreach ($rows as $row) {
$row->set('user_name', $row->user->name);
}
echo json_encode($rows->toArray());
exit;
}
示例10: _process
//.........这里部分代码省略.........
$this->model->set('modified_by', User::get('id'));
} else {
$this->model->set('alias', $name);
$this->model->set('created', Date::toSql());
$this->model->set('created_by_user', User::get('id'));
$this->model->set('owned_by_group', $this->_gid);
$this->model->set('owned_by_user', User::get('id'));
$this->model->set('private', $this->config->get('privacy', 1));
}
$this->model->set('title', \Hubzero\Utility\String::truncate($title, 250));
$this->model->set('about', trim(Request::getVar('about', '', 'post', 'none', 2)));
$this->model->set('type', Request::getInt('type', 1, 'post'));
// save advanced permissions
if (isset($_POST['private'])) {
$this->model->set('private', $private);
}
if ($setup && !$this->model->exists()) {
// Copy params from default project type
$objT = $this->model->table('Type');
$this->model->set('params', $objT->getParams($this->model->get('type')));
}
// Save changes
if (!$this->model->store()) {
$this->setError($this->model->getError());
return false;
}
// Save owners for new projects
if ($new) {
$this->_identifier = $this->model->get('alias');
// Group owners
$objO = $this->model->table('Owner');
if ($this->_gid) {
if (!$objO->saveOwners($this->model->get('id'), User::get('id'), 0, $this->_gid, 0, 1, 1, '', $split_group_roles = 0)) {
$this->setError(Lang::txt('COM_PROJECTS_ERROR_SAVING_AUTHORS') . ': ' . $objO->getError());
return false;
}
// Make sure project creator is manager
$objO->reassignRole($this->model->get('id'), $users = array(User::get('id')), 0, 1);
} elseif (!$objO->saveOwners($this->model->get('id'), User::get('id'), User::get('id'), $this->_gid, 1, 1, 1)) {
$this->setError(Lang::txt('COM_PROJECTS_ERROR_SAVING_AUTHORS') . ': ' . $objO->getError());
return false;
}
}
break;
case 'team':
if ($new) {
return false;
}
// Save team
$content = Event::trigger('projects.onProject', array($this->model, 'save', array('team')));
if (isset($content[0]) && $this->next == $this->section) {
if (isset($content[0]['msg']) && !empty($content[0]['msg'])) {
$this->_setNotification($content[0]['msg']['message'], $content[0]['msg']['type']);
}
}
break;
case 'settings':
if ($new) {
return false;
}
// Save privacy
if (isset($_POST['private'])) {
$this->model->set('private', $private);
// Save changes
if (!$this->model->store()) {
$this->setError($this->model->getError());
return false;
}
}
// Save params
$incoming = Request::getVar('params', array());
if (!empty($incoming)) {
foreach ($incoming as $key => $value) {
$this->model->saveParam($key, $value);
// If grant information changed
if ($key == 'grant_status') {
// Meta data for comment
$meta = '<meta>' . Date::of('now')->toLocal('M d, Y') . ' - ' . User::get('name') . '</meta>';
$cbase = $this->model->get('admin_notes');
$cbase .= '<nb:sponsored>' . Lang::txt('COM_PROJECTS_PROJECT_MANAGER_GRANT_INFO_UPDATE') . $meta . '</nb:sponsored>';
$this->model->set('admin_notes', $cbase);
// Save admin notes
if (!$this->model->store()) {
$this->setError($this->model->getError());
return false;
}
$admingroup = $this->config->get('ginfo_group', '');
if (\Hubzero\User\Group::getInstance($admingroup)) {
$admins = Helpers\Html::getGroupMembers($admingroup);
// Send out email to admins
if (!empty($admins)) {
Helpers\Html::sendHUBMessage($this->_option, $this->model, $admins, Lang::txt('COM_PROJECTS_EMAIL_ADMIN_REVIEWER_NOTIFICATION'), 'projects_new_project_admin', 'admin', Lang::txt('COM_PROJECTS_PROJECT_MANAGER_GRANT_INFO_UPDATE'), 'sponsored');
}
}
}
}
}
break;
}
}
示例11: out
/**
* Static method for formatting results
*
* @param object $row Database row
* @return string HTML
*/
public static function out($row)
{
$row->href = Route::url($row->href);
$month = Date::of($row->publish_up)->toLocal('M');
$day = Date::of($row->publish_up)->toLocal('d');
$year = Date::of($row->publish_up)->toLocal('Y');
// Start building the HTML
$html = "\t" . '<li class="event">' . "\n";
$html .= "\t\t" . '<p class="event-date"><span class="month">' . $month . '</span> <span class="day">' . $day . '</span> <span class="year">' . $year . '</span></p>' . "\n";
$html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n";
if ($row->ftext) {
$row->ftext = str_replace('[[BR]]', '', $row->ftext);
// Remove tags to prevent tables from being displayed within a table.
$row->ftext = strip_tags($row->ftext);
$html .= "\t\t" . \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->ftext)), 200) . "\n";
}
$html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href, '/') . '</p>' . "\n";
$html .= "\t" . '</li>' . "\n";
// Return output
return $html;
}
示例12:
</span> <?php
echo \Hubzero\Utility\String::truncate($this->pub->title, 65);
?>
| <?php
echo Lang::txt('COM_PUBLICATIONS_CURATION_VERSION') . ' ' . $this->pub->version_label;
?>
</h3>
</div>
<p class="instruct">
<span class="pubimage"><img src="<?php
echo Route::url('index.php?option=com_publications&id=' . $this->pub->id . '&v=' . $this->pub->version_id) . '/Image:thumb';
?>
" alt="" /></span>
<strong class="block"><?php
echo $this->pub->reviewed ? Lang::txt('COM_PUBLICATIONS_CURATION_RESUBMITTED') : Lang::txt('COM_PUBLICATIONS_CURATION_SUBMITTED');
echo ' ' . Date::of($this->pub->submitted)->toLocal('M d, Y') . ' ' . Lang::txt('COM_PUBLICATIONS_CURATION_BY') . ' ' . $this->pub->modifier('name');
?>
</strong>
<?php
if ($this->pub->curator()) {
?>
<span class="block"><?php
echo Lang::txt('COM_PUBLICATIONS_CURATION_ASSIGNED_CURATOR') . ' <strong>' . $this->pub->curator('name') . ' (' . $this->pub->curator('username') . ')</strong>';
?>
</span>
<?php
}
?>
<?php
echo Lang::txt('COM_PUBLICATIONS_CURATION_REVIEW_AND_ACT');
?>
示例13: substr
<?php
}
?>
<div class="container blog-entries-years">
<h4><?php
echo Lang::txt('COM_BLOG_ENTRIES_BY_YEAR');
?>
</h4>
<ol>
<?php
if ($first->get('id')) {
$entry_year = substr($this->row->get('publish_up'), 0, 4);
$entry_month = substr($this->row->get('publish_up'), 5, 2);
$start = intval(substr($first->get('publish_up'), 0, 4));
$now = Date::of('now')->format("Y");
//$mon = date("m");
for ($i = $now, $n = $start; $i >= $n; $i--) {
?>
<li>
<a href="<?php
echo Route::url('index.php?option=' . $this->option . '&year=' . $i);
?>
">
<?php
echo $i;
?>
</a>
<?php
if ($i == $entry_year) {
?>
示例14: foreach
?>
</h4>
<?php
if (count($this->rows2) <= 0) {
?>
<p><?php
echo Lang::txt('MOD_MYWISHES_NO_WISHES');
?>
</p>
<?php
} else {
?>
<ul class="expandedlist">
<?php
foreach ($this->rows2 as $row) {
$when = Date::of($row->proposed)->relative();
$title = strip_tags($row->about) ? $this->escape(stripslashes($row->subject)) . ' :: ' . \Hubzero\Utility\String::truncate($this->escape(strip_tags($row->about)), 160) : NULL;
?>
<li class="wishlist">
<a href="<?php
echo Route::url('index.php?option=com_wishlist&task=wish&id=' . $row->wishlist . '&wishid=' . $row->id);
?>
" class="tooltips" title="<?php
echo $title;
?>
">
#<?php
echo $row->id;
?>
: <?php
echo \Hubzero\Utility\String::truncate(stripslashes($row->subject), 35);
示例15: _iniSync
/**
* Initiate sync
*
* @return void
*/
protected function _iniSync()
{
// Incoming
$ajax = Request::getInt('ajax', 0);
$auto = Request::getInt('auto', 0);
$queue = Request::getInt('queue', 0);
// Timed sync?
$autoSync = $this->params->get('auto_sync', 0);
$this->_rSync = new Sync($this->_connect);
// Remote service(s) active?
if (!empty($this->_connect->_active) && $this->repo->isLocal()) {
// Get remote files for each active service
foreach ($this->_connect->_active as $servicename) {
// Set syncing service
$this->_rSync->set('service', $servicename);
// Get time of last sync
$synced = $this->model->params->get($servicename . '_sync');
// Stop if auto sync request and not enough time passed
if ($auto && $autoSync && !$queue) {
if ($autoSync < 1) {
$hr = 60 * $autoSync;
$timecheck = Date::of(time() - 1 * $hr * 60);
} else {
$timecheck = Date::of(time() - $autoSync * 60 * 60);
}
if ($synced > $timecheck) {
return json_encode(array('status' => 'waiting'));
}
}
// Send sync request
$success = $this->_rSync->sync($servicename, $queue, $auto);
// Unlock sync
if ($success) {
$this->_rSync->lockSync($servicename, true);
}
// Success message
$this->_rSync->set('message', Lang::txt('PLG_PROJECTS_FILES_SYNC_SUCCESS'));
}
}
$this->_rSync->set('auto', $auto);
if (!$ajax) {
return $this->_browse();
} else {
$this->_rSync->set('output', $this->_browse());
return json_encode($this->_rSync->getStatus());
}
}