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


PHP MWTimestamp::format方法代码示例

本文整理汇总了PHP中MWTimestamp::format方法的典型用法代码示例。如果您正苦于以下问题:PHP MWTimestamp::format方法的具体用法?PHP MWTimestamp::format怎么用?PHP MWTimestamp::format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MWTimestamp的用法示例。


在下文中一共展示了MWTimestamp::format方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHeaderHtml

 /** @inheritdoc **/
 protected function getHeaderHtml()
 {
     if ($this->isUserPage) {
         // The heading is just the username without namespace
         $html = Html::rawElement('h1', array('id' => 'section_0'), $this->pageUser->getName());
         $fromDate = $this->pageUser->getRegistration();
         if (is_string($fromDate)) {
             $fromDateTs = new MWTimestamp(wfTimestamp(TS_UNIX, $fromDate));
             $html .= Html::element('div', array('class' => 'tagline'), $this->msg('mobile-frontend-user-page-member-since', $fromDateTs->format('F, Y')));
         }
     } else {
         $html = parent::getHeaderHtml();
         $vars = $this->getSkinConfigVariables();
         $description = $vars['wgMFDescription'];
         if ($description && !$this->getTitle()->isSpecialPage()) {
             $html .= Html::element('div', array('class' => 'tagline'), $description);
         }
     }
     return $html;
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:21,代码来源:SkinMinervaBeta.php

示例2: checkConditionalRequestHeaders

 /**
  * Check selected RFC 7232 precondition headers
  *
  * RFC 7232 envisions a particular model where you send your request to "a
  * resource", and for write requests that you can read "the resource" by
  * changing the method to GET. When the API receives a GET request, it
  * works out even though "the resource" from RFC 7232's perspective might
  * be many resources from MediaWiki's perspective. But it totally fails for
  * a POST, since what HTTP sees as "the resource" is probably just
  * "/api.php" with all the interesting bits in the body.
  *
  * Therefore, we only support RFC 7232 precondition headers for GET (and
  * HEAD). That means we don't need to bother with If-Match and
  * If-Unmodified-Since since they only apply to modification requests.
  *
  * And since we don't support Range, If-Range is ignored too.
  *
  * @since 1.26
  * @param ApiBase $module Api module being used
  * @return bool True on success, false should exit immediately
  */
 protected function checkConditionalRequestHeaders($module)
 {
     if ($this->mInternalMode) {
         // No headers to check in internal mode
         return true;
     }
     if ($this->getRequest()->getMethod() !== 'GET' && $this->getRequest()->getMethod() !== 'HEAD') {
         // Don't check POSTs
         return true;
     }
     $return304 = false;
     $ifNoneMatch = array_diff($this->getRequest()->getHeader('If-None-Match', WebRequest::GETHEADER_LIST) ?: array(), array(''));
     if ($ifNoneMatch) {
         if ($ifNoneMatch === array('*')) {
             // API responses always "exist"
             $etag = '*';
         } else {
             $etag = $module->getConditionalRequestData('etag');
         }
     }
     if ($ifNoneMatch && $etag !== null) {
         $test = substr($etag, 0, 2) === 'W/' ? substr($etag, 2) : $etag;
         $match = array_map(function ($s) {
             return substr($s, 0, 2) === 'W/' ? substr($s, 2) : $s;
         }, $ifNoneMatch);
         $return304 = in_array($test, $match, true);
     } else {
         $value = trim($this->getRequest()->getHeader('If-Modified-Since'));
         // Some old browsers sends sizes after the date, like this:
         //  Wed, 20 Aug 2003 06:51:19 GMT; length=5202
         // Ignore that.
         $i = strpos($value, ';');
         if ($i !== false) {
             $value = trim(substr($value, 0, $i));
         }
         if ($value !== '') {
             try {
                 $ts = new MWTimestamp($value);
                 if ($ts->getTimestamp(TS_RFC2822) === $value || $ts->format('l, d-M-y H:i:s') . ' GMT' === $value || $ts->format('D M j H:i:s Y') === $value || $ts->format('D M  j H:i:s Y') === $value) {
                     $lastMod = $module->getConditionalRequestData('last-modified');
                     if ($lastMod !== null) {
                         // Mix in some MediaWiki modification times
                         $modifiedTimes = array('page' => $lastMod, 'user' => $this->getUser()->getTouched(), 'epoch' => $this->getConfig()->get('CacheEpoch'));
                         if ($this->getConfig()->get('UseSquid')) {
                             // T46570: the core page itself may not change, but resources might
                             $modifiedTimes['sepoch'] = wfTimestamp(TS_MW, time() - $this->getConfig()->get('SquidMaxage'));
                         }
                         Hooks::run('OutputPageCheckLastModified', array(&$modifiedTimes));
                         $lastMod = max($modifiedTimes);
                         $return304 = wfTimestamp(TS_MW, $lastMod) <= $ts->getTimestamp(TS_MW);
                     }
                 }
             } catch (TimestampException $e) {
                 // Invalid timestamp, ignore it
             }
         }
     }
     if ($return304) {
         $this->getRequest()->response()->statusHeader(304);
         // Avoid outputting the compressed representation of a zero-length body
         MediaWiki\suppressWarnings();
         ini_set('zlib.output_compression', 0);
         MediaWiki\restoreWarnings();
         wfClearOutputBuffers();
         return false;
     }
     return true;
 }
开发者ID:soumyag213,项目名称:mediawiki,代码行数:89,代码来源:ApiMain.php

示例3: getHeaderHtml

 /**
  * Returns the HTML representing the header.
  * @returns {String} html for header
  */
 protected function getHeaderHtml()
 {
     $html = '';
     if ($this->isUserPage) {
         // The heading is just the username without namespace
         $html = Html::rawElement('h1', array('id' => 'section_0'), $this->pageUser->getName());
         $fromDate = $this->pageUser->getRegistration();
         if (is_string($fromDate)) {
             $fromDateTs = new MWTimestamp(wfTimestamp(TS_UNIX, $fromDate));
             $html .= Html::element('div', array('class' => 'tagline'), $this->msg('mobile-frontend-user-page-member-since', $fromDateTs->format('F, Y')));
         }
     } else {
         $title = $this->getOutput()->getPageTitle();
         if ($title) {
             $html = Html::rawElement('h1', array('id' => 'section_0'), $title);
         }
     }
     return $html;
 }
开发者ID:felixonmars,项目名称:mediawiki-extensions-MobileFrontend,代码行数:23,代码来源:SkinMinerva.php


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