本文整理汇总了PHP中DateTimeHelper::toIso8601方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeHelper::toIso8601方法的具体用法?PHP DateTimeHelper::toIso8601怎么用?PHP DateTimeHelper::toIso8601使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeHelper
的用法示例。
在下文中一共展示了DateTimeHelper::toIso8601方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _returnSuccess
/**
* Returns a 'success' response.
*
* @param $entry
* @return void
*/
private function _returnSuccess($entry, $faked = false)
{
$successEvent = new GuestEntriesEvent($this, array('entry' => $entry, 'faked' => $faked));
craft()->guestEntries->onSuccess($successEvent);
if (craft()->request->isAjaxRequest()) {
$return['success'] = true;
$return['id'] = $entry->id;
$return['title'] = $entry->title;
if (craft()->request->isCpRequest()) {
$return['cpEditUrl'] = $entry->getCpEditUrl();
}
$return['authorUsername'] = $entry->getAuthor()->username;
$return['dateCreated'] = DateTimeHelper::toIso8601($entry->dateCreated);
$return['dateUpdated'] = DateTimeHelper::toIso8601($entry->dateUpdated);
$return['postDate'] = $entry->postDate ? DateTimeHelper::toIso8601($entry->postDate) : null;
$this->returnJson($return);
} else {
craft()->userSession->setNotice(Craft::t('Entry saved.'));
// TODO: Remove for 2.0
if (isset($_POST['redirect']) && mb_strpos($_POST['redirect'], '{entryId}') !== false) {
Craft::log('The {entryId} token within the ‘redirect’ param on entries/saveEntry requests has been deprecated. Use {id} instead.', LogLevel::Warning);
$_POST['redirect'] = str_replace('{entryId}', '{id}', $_POST['redirect']);
}
$this->redirectToPostedUrl($entry);
}
}
示例2: actionSaveEntry
/**
* Saves an entry.
*
* @return null
*/
public function actionSaveEntry()
{
$this->requirePostRequest();
$entry = $this->_getEntryModel();
// Permission enforcement
$this->enforceEditEntryPermissions($entry);
$userSessionService = craft()->userSession;
$currentUser = $userSessionService->getUser();
if ($entry->id) {
// Is this another user's entry (and it's not a Single)?
if ($entry->authorId != $currentUser->id && $entry->getSection()->type != SectionType::Single) {
if ($entry->enabled) {
// Make sure they have permission to make live changes to those
$userSessionService->requirePermission('publishPeerEntries:' . $entry->sectionId);
}
}
}
// Populate the entry with post data
$this->_populateEntryModel($entry);
// Even more permission enforcement
if ($entry->enabled) {
if ($entry->id) {
$userSessionService->requirePermission('publishEntries:' . $entry->sectionId);
} else {
if (!$currentUser->can('publishEntries:' . $entry->sectionId)) {
$entry->enabled = false;
}
}
}
// Save the entry (finally!)
if (craft()->entries->saveEntry($entry)) {
if (craft()->request->isAjaxRequest()) {
$return['success'] = true;
$return['id'] = $entry->id;
$return['title'] = $entry->title;
$return['cpEditUrl'] = $entry->getCpEditUrl();
$author = $entry->getAuthor()->getAttributes();
if (isset($author['password'])) {
unset($author['password']);
}
$return['author'] = $author;
$return['dateCreated'] = DateTimeHelper::toIso8601($entry->dateCreated);
$return['dateUpdated'] = DateTimeHelper::toIso8601($entry->dateUpdated);
$return['postDate'] = $entry->postDate ? DateTimeHelper::toIso8601($entry->postDate) : null;
$this->returnJson($return);
} else {
$userSessionService->setNotice(Craft::t('Entry saved.'));
if (isset($_POST['redirect']) && mb_strpos($_POST['redirect'], '{entryId}') !== false) {
craft()->deprecator->log('EntriesController::actionSaveEntry():entryId_redirect', 'The {entryId} token within the ‘redirect’ param on entries/saveEntry requests has been deprecated. Use {id} instead.');
$_POST['redirect'] = str_replace('{entryId}', '{id}', $_POST['redirect']);
}
$this->redirectToPostedUrl($entry);
}
} else {
if (craft()->request->isAjaxRequest()) {
$this->returnJson(array('errors' => $entry->getErrors()));
} else {
$userSessionService->setError(Craft::t('Couldn’t save entry.'));
// Send the entry back to the template
craft()->urlManager->setRouteVariables(array('entry' => $entry));
}
}
}