当前位置: 首页>>代码示例>>PHP>>正文


PHP DateTimeHelper::toIso8601方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:ctigelaar,项目名称:craft-guestentries,代码行数:32,代码来源:GuestEntriesController.php

示例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));
         }
     }
 }
开发者ID:ericnormannn,项目名称:m,代码行数:68,代码来源:EntriesController.php


注:本文中的DateTimeHelper::toIso8601方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。