本文整理匯總了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));
}
}
}