• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MWTimestamp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getUserFooterData

 /**
  * Get the footer with user information (when joined, how
  * many edits/uploads, visit user page and talk page)
  * @return string
  */
 protected function getUserFooterData()
 {
     $fromDate = $this->targetUser->getRegistration();
     $ts = new MWTimestamp(wfTimestamp(TS_UNIX, $fromDate));
     $diff = $ts->diff(new MWTimestamp());
     if ($fromDate === null) {
         // User was registered in pre-historic times when registration wasn't recorded
         $msg = 'mobile-frontend-profile-footer-ancient';
         $units = 0;
         $fromDate = '20010115000000';
         // No users before that date
     } elseif ($diff->y) {
         $msg = 'mobile-frontend-profile-footer-years';
         $units = $diff->y;
     } elseif ($diff->m) {
         $msg = 'mobile-frontend-profile-footer-months';
         $units = $diff->m;
     } else {
         $msg = 'mobile-frontend-profile-footer-days';
         $units = $diff->d;
     }
     $editCount = $this->targetUser->getEditCount();
     $uploadCount = $this->userInfo->countRecentUploads($fromDate);
     // Ensure that the upload count is compatible with the i18n message
     if ($uploadCount > 500) {
         $uploadCount = 500;
     }
     $username = $this->targetUser->getName();
     return array('editsSummary' => $this->msg($msg, $username)->numParams($units, $editCount, $uploadCount)->parse(), 'linkUserPage' => Linker::link($this->targetUser->getUserPage(), $this->msg('mobile-frontend-profile-userpage-link', $username)->escaped()), 'linkTalk' => $this->getTalkLink());
 }
开发者ID:GoProjectOwner,项目名称:mediawiki-extensions-MobileFrontend,代码行数:35,代码来源:SpecialUserProfile.php


示例2: testRelativeTimestamp

 /**
  * @dataProvider provideRelativeTimestampTests
  * @covers MWTimestamp::getRelativeTimestamp
  */
 public function testRelativeTimestamp($tsTime, $currentTime, $timeCorrection, $dateFormat, $expectedOutput, $desc)
 {
     $user = $this->getMock('User');
     $user->expects($this->any())->method('getOption')->with('timecorrection')->will($this->returnValue($timeCorrection));
     $tsTime = new MWTimestamp($tsTime);
     $currentTime = new MWTimestamp($currentTime);
     $this->assertEquals($expectedOutput, $tsTime->getRelativeTimestamp($currentTime, $user), $desc);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:12,代码来源:MWTimestampTest.php


示例3: __construct

 function __construct()
 {
     global $wgModerationTimeToOverrideRejection;
     $mw_ts = new MWTimestamp(time());
     $mw_ts->timestamp->modify('-' . intval($wgModerationTimeToOverrideRejection) . ' seconds');
     $this->earliestReapprovableTimestamp = $mw_ts->getTimestamp(TS_MW);
     $this->mblockCheck = new ModerationBlockCheck();
     parent::__construct('Moderation', 'moderation');
 }
开发者ID:ATCARES,项目名称:mediawiki-moderation,代码行数:9,代码来源:SpecialModeration.php


示例4: getLineHtml

 /**
  * Gets the HTML fragment for a watched page.
  *
  * @param Title $title The title of the watched page
  * @param int $ts When the page was last touched
  * @param string $thumb An HTML fragment for the page's thumbnaiL
  * @return string
  */
 public static function getLineHtml(Title $title, $ts, $thumb)
 {
     $titleText = $title->getPrefixedText();
     if ($ts) {
         $ts = new MWTimestamp($ts);
         $lastModified = wfMessage('mobile-frontend-watchlist-modified', $ts->getHumanTimestamp())->text();
         $className = 'title';
     } else {
         $className = 'title new';
         $lastModified = '';
     }
     $html = Html::openElement('li', array('class' => 'page-summary', 'title' => $titleText, 'data-id' => $title->getArticleId())) . Html::openElement('a', array('href' => $title->getLocalUrl(), 'class' => $className));
     $html .= $thumb;
     $html .= Html::element('h3', array(), $titleText) . Html::element('div', array('class' => 'info'), $lastModified) . Html::closeElement('a') . Html::closeElement('li');
     return $html;
 }
开发者ID:GoProjectOwner,项目名称:mediawiki-extensions-MobileFrontend,代码行数:24,代码来源:SpecialMobileEditWatchlist.php


示例5: 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


示例6: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $token = $params['token'];
     $maxage = $params['maxtokenage'];
     $salts = ApiQueryTokens::getTokenTypeSalts();
     $res = array();
     $tokenObj = ApiQueryTokens::getToken($this->getUser(), $this->getRequest()->getSession(), $salts[$params['type']]);
     if ($tokenObj->match($token, $maxage)) {
         $res['result'] = 'valid';
     } elseif ($maxage !== null && $tokenObj->match($token)) {
         $res['result'] = 'expired';
     } else {
         $res['result'] = 'invalid';
     }
     $ts = MediaWiki\Session\Token::getTimestamp($token);
     if ($ts !== null) {
         $mwts = new MWTimestamp();
         $mwts->timestamp->setTimestamp($ts);
         $res['generated'] = $mwts->getTimestamp(TS_ISO_8601);
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
开发者ID:lourinaldi,项目名称:mediawiki,代码行数:23,代码来源:ApiCheckToken.php


示例7: getFormFields

 protected function getFormFields()
 {
     global $wgContLang;
     $timestamp = $this->oldFile->getTimestamp();
     $user = $this->getUser();
     $lang = $this->getLanguage();
     $userDate = $lang->userDate($timestamp, $user);
     $userTime = $lang->userTime($timestamp, $user);
     $siteTs = MWTimestamp::getLocalInstance($timestamp);
     $ts = $siteTs->format('YmdHis');
     $siteDate = $wgContLang->date($ts, false, false);
     $siteTime = $wgContLang->time($ts, false, false);
     $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
     return ['intro' => ['type' => 'info', 'vertical-label' => true, 'raw' => true, 'default' => $this->msg('filerevert-intro', $this->getTitle()->getText(), $userDate, $userTime, wfExpandUrl($this->page->getFile()->getArchiveUrl($this->getRequest()->getText('oldimage')), PROTO_CURRENT))->parseAsBlock()], 'comment' => ['type' => 'text', 'label-message' => 'filerevert-comment', 'default' => $this->msg('filerevert-defaultcomment', $siteDate, $siteTime, $tzMsg)->inContentLanguage()->text()]];
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:15,代码来源:RevertAction.php


示例8: getDateCond

 function getDateCond($year, $month)
 {
     $year = intval($year);
     $month = intval($month);
     // Basic validity checks
     $this->mYear = $year > 0 ? $year : false;
     $this->mMonth = $month > 0 && $month < 13 ? $month : false;
     // Given an optional year and month, we need to generate a timestamp
     // to use as "WHERE rev_timestamp <= result"
     // Examples: year = 2006 equals < 20070101 (+000000)
     // year=2005, month=1    equals < 20050201
     // year=2005, month=12   equals < 20060101
     if (!$this->mYear && !$this->mMonth) {
         return;
     }
     if ($this->mYear) {
         $year = $this->mYear;
     } else {
         // If no year given, assume the current one
         $timestamp = MWTimestamp::getInstance();
         $year = $timestamp->format('Y');
         // If this month hasn't happened yet this year, go back to last year's month
         if ($this->mMonth > $timestamp->format('n')) {
             $year--;
         }
     }
     if ($this->mMonth) {
         $month = $this->mMonth + 1;
         // For December, we want January 1 of the next year
         if ($month > 12) {
             $month = 1;
             $year++;
         }
     } else {
         // No month implies we want up to the end of the year in question
         $month = 1;
         $year++;
     }
     // Y2K38 bug
     if ($year > 2032) {
         $year = 2032;
     }
     $ymd = (int) sprintf("%04d%02d01", $year, $month);
     if ($ymd > 20320101) {
         $ymd = 20320101;
     }
     $this->mOffset = $this->mDb->timestamp("{$ymd}000000");
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:48,代码来源:ReverseChronologicalPager.php


示例9: testGetDateCond

 /**
  * @covers ReverseChronologicalPager::getDateCond
  */
 public function testGetDateCond()
 {
     $pager = $this->getMockForAbstractClass('ReverseChronologicalPager');
     $timestamp = MWTimestamp::getInstance();
     $db = wfGetDB(DB_MASTER);
     $currYear = $timestamp->format('Y');
     $currMonth = $timestamp->format('n');
     // Test that getDateCond sets and returns mOffset
     $this->assertEquals($pager->getDateCond(2006, 6), $pager->mOffset);
     // Test year and month
     $pager->getDateCond(2006, 6);
     $this->assertEquals($pager->mOffset, $db->timestamp('20060701000000'));
     // Test year, month, and day
     $pager->getDateCond(2006, 6, 5);
     $this->assertEquals($pager->mOffset, $db->timestamp('20060606000000'));
     // Test month overflow into the next year
     $pager->getDateCond(2006, 12);
     $this->assertEquals($pager->mOffset, $db->timestamp('20070101000000'));
     // Test day overflow to the next month
     $pager->getDateCond(2006, 6, 30);
     $this->assertEquals($pager->mOffset, $db->timestamp('20060701000000'));
     // Test invalid month (should use end of year)
     $pager->getDateCond(2006, -1);
     $this->assertEquals($pager->mOffset, $db->timestamp('20070101000000'));
     // Test invalid day (should use end of month)
     $pager->getDateCond(2006, 6, 1337);
     $this->assertEquals($pager->mOffset, $db->timestamp('20060701000000'));
     // Test last day of year
     $pager->getDateCond(2006, 12, 31);
     $this->assertEquals($pager->mOffset, $db->timestamp('20070101000000'));
     // Test invalid day that overflows to next year
     $pager->getDateCond(2006, 12, 32);
     $this->assertEquals($pager->mOffset, $db->timestamp('20070101000000'));
     // Test month past current month (should use previous year)
     if ($currMonth < 5) {
         $pager->getDateCond(-1, 5);
         $this->assertEquals($pager->mOffset, $db->timestamp($currYear - 1 . '0601000000'));
     }
     if ($currMonth < 12) {
         $pager->getDateCond(-1, 12);
         $this->assertEquals($pager->mOffset, $db->timestamp($currYear . '0101000000'));
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:46,代码来源:ReverseChronologicalPagerTest.php


示例10: onView

 /**
  * Print the history page for an article.
  */
 function onView()
 {
     $out = $this->getOutput();
     $request = $this->getRequest();
     /**
      * Allow client caching.
      */
     if ($out->checkLastModified($this->page->getTouched())) {
         return;
         // Client cache fresh and headers sent, nothing more to do.
     }
     wfProfileIn(__METHOD__);
     $this->preCacheMessages();
     $config = $this->context->getConfig();
     # Fill in the file cache if not set already
     $useFileCache = $config->get('UseFileCache');
     if ($useFileCache && HTMLFileCache::useFileCache($this->getContext())) {
         $cache = HTMLFileCache::newFromTitle($this->getTitle(), 'history');
         if (!$cache->isCacheGood()) {
             ob_start(array(&$cache, 'saveToFileCache'));
         }
     }
     // Setup page variables.
     $out->setFeedAppendQuery('action=history');
     $out->addModules('mediawiki.action.history');
     if ($config->get('UseMediaWikiUIEverywhere')) {
         $out = $this->getOutput();
         $out->addModuleStyles(array('mediawiki.ui.input', 'mediawiki.ui.checkbox'));
     }
     // Handle atom/RSS feeds.
     $feedType = $request->getVal('feed');
     if ($feedType) {
         $this->feed($feedType);
         wfProfileOut(__METHOD__);
         return;
     }
     // Fail nicely if article doesn't exist.
     if (!$this->page->exists()) {
         $out->addWikiMsg('nohistory');
         # show deletion/move log if there is an entry
         LogEventsList::showLogExtract($out, array('delete', 'move'), $this->getTitle(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
         wfProfileOut(__METHOD__);
         return;
     }
     /**
      * Add date selector to quickly get to a certain time
      */
     $year = $request->getInt('year');
     $month = $request->getInt('month');
     $tagFilter = $request->getVal('tagfilter');
     $tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
     /**
      * Option to show only revisions that have been (partially) hidden via RevisionDelete
      */
     if ($request->getBool('deleted')) {
         $conds = array('rev_deleted != 0');
     } else {
         $conds = array();
     }
     if ($this->getUser()->isAllowed('deletedhistory')) {
         $checkDeleted = Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deleted', 'mw-show-deleted-only', $request->getBool('deleted')) . "\n";
     } else {
         $checkDeleted = '';
     }
     // Add the general form
     $action = htmlspecialchars(wfScript());
     $out->addHTML("<form action=\"{$action}\" method=\"get\" id=\"mw-history-searchform\">" . Xml::fieldset($this->msg('history-fieldset-title')->text(), false, array('id' => 'mw-history-search')) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . "\n" . Html::hidden('action', 'history') . "\n" . Xml::dateMenu($year == null ? MWTimestamp::getLocalInstance()->format('Y') : $year, $month) . '&#160;' . ($tagSelector ? implode('&#160;', $tagSelector) . '&#160;' : '') . $checkDeleted . Xml::submitButton($this->msg('allpagessubmit')->text()) . "\n" . '</fieldset></form>');
     wfRunHooks('PageHistoryBeforeList', array(&$this->page, $this->getContext()));
     // Create and output the list.
     $pager = new HistoryPager($this, $year, $month, $tagFilter, $conds);
     $out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
     $out->preventClickjacking($pager->getPreventClickjacking());
     wfProfileOut(__METHOD__);
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:77,代码来源:HistoryAction.php


示例11: doQuery

 protected function doQuery($sql)
 {
     wfDebug("SQL: [{$sql}]\n");
     if (!StringUtils::isUtf8($sql)) {
         throw new MWException("SQL encoding is invalid\n{$sql}");
     }
     // handle some oracle specifics
     // remove AS column/table/subquery namings
     if (!$this->getFlag(DBO_DDLMODE)) {
         $sql = preg_replace('/ as /i', ' ', $sql);
     }
     // Oracle has issues with UNION clause if the statement includes LOB fields
     // So we do a UNION ALL and then filter the results array with array_unique
     $union_unique = preg_match('/\\/\\* UNION_UNIQUE \\*\\/ /', $sql) != 0;
     // EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
     // you have to select data from plan table after explain
     $explain_id = MWTimestamp::getLocalInstance()->format('dmYHis');
     $sql = preg_replace('/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \'' . $explain_id . '\' FOR', $sql, 1, $explain_count);
     MediaWiki\suppressWarnings();
     $this->mLastResult = $stmt = oci_parse($this->mConn, $sql);
     if ($stmt === false) {
         $e = oci_error($this->mConn);
         $this->reportQueryError($e['message'], $e['code'], $sql, __METHOD__);
         return false;
     }
     if (!oci_execute($stmt, $this->execFlags())) {
         $e = oci_error($stmt);
         if (!$this->ignoreDupValOnIndex || $e['code'] != '1') {
             $this->reportQueryError($e['message'], $e['code'], $sql, __METHOD__);
             return false;
         }
     }
     MediaWiki\restoreWarnings();
     if ($explain_count > 0) {
         return $this->doQuery('SELECT id, cardinality "ROWS" FROM plan_table ' . 'WHERE statement_id = \'' . $explain_id . '\'');
     } elseif (oci_statement_type($stmt) == 'SELECT') {
         return new ORAResult($this, $stmt, $union_unique);
     } else {
         $this->mAffectedRows = oci_num_rows($stmt);
         return true;
     }
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:42,代码来源:DatabaseOracle.php


示例12: getCopyrightAndAuthorList

 /**
  * Get the "MediaWiki is copyright 2001-20xx by lots of cool guys" text
  *
  * @return String
  */
 public static function getCopyrightAndAuthorList()
 {
     global $wgLang;
     if (defined('MEDIAWIKI_INSTALL')) {
         $othersLink = '[//www.mediawiki.org/wiki/Special:Version/Credits ' . wfMessage('version-poweredby-others')->text() . ']';
     } else {
         $othersLink = '[[Special:Version/Credits|' . wfMessage('version-poweredby-others')->text() . ']]';
     }
     $translatorsLink = '[//translatewiki.net/wiki/Translating:MediaWiki/Credits ' . wfMessage('version-poweredby-translators')->text() . ']';
     $authorList = array('Magnus Manske', 'Brion Vibber', 'Lee Daniel Crocker', 'Tim Starling', 'Erik Möller', 'Gabriel Wicke', 'Ævar Arnfjörð Bjarmason', 'Niklas Laxström', 'Domas Mituzas', 'Rob Church', 'Yuri Astrakhan', 'Aryeh Gregor', 'Aaron Schulz', 'Andrew Garrett', 'Raimond Spekking', 'Alexandre Emsenhuber', 'Siebrand Mazeland', 'Chad Horohoe', 'Roan Kattouw', 'Trevor Parscal', 'Bryan Tong Minh', 'Sam Reed', 'Victor Vasiliev', 'Rotem Liss', 'Platonides', 'Antoine Musso', 'Timo Tijhof', 'Daniel Kinzler', 'Jeroen De Dauw', $othersLink, $translatorsLink);
     return wfMessage('version-poweredby-credits', MWTimestamp::getLocalInstance()->format('Y'), $wgLang->listToText($authorList))->text();
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:17,代码来源:SpecialVersion.php


示例13: wfTimestamp

/**
 * Get a timestamp string in one of various formats
 *
 * @param mixed $outputtype A timestamp in one of the supported formats, the
 *   function will autodetect which format is supplied and act accordingly.
 * @param mixed $ts Optional timestamp to convert, default 0 for the current time
 * @return string|bool String / false The same date in the format specified in $outputtype or false
 */
function wfTimestamp($outputtype = TS_UNIX, $ts = 0)
{
    try {
        $timestamp = new MWTimestamp($ts);
        return $timestamp->getTimestamp($outputtype);
    } catch (TimestampException $e) {
        wfDebug("wfTimestamp() fed bogus time value: TYPE={$outputtype}; VALUE={$ts}\n");
        return false;
    }
}
开发者ID:D66Ha,项目名称:mediawiki,代码行数:18,代码来源:GlobalFunctions.php


示例14: dateMenu

 /**
  * @param $year Integer
  * @param $month Integer
  * @return string Formatted HTML
  */
 public static function dateMenu($year, $month)
 {
     # Offset overrides year/month selection
     if ($month && $month !== -1) {
         $encMonth = intval($month);
     } else {
         $encMonth = '';
     }
     if ($year) {
         $encYear = intval($year);
     } elseif ($encMonth) {
         $timestamp = MWTimestamp::getInstance();
         $thisMonth = intval($timestamp->format('n'));
         $thisYear = intval($timestamp->format('Y'));
         if (intval($encMonth) > $thisMonth) {
             $thisYear--;
         }
         $encYear = $thisYear;
     } else {
         $encYear = '';
     }
     // JRS, upgrade 1.21: Add button classes to date menu
     $inputAttribs = array('id' => 'year', 'maxlength' => 4, 'size' => 7, 'class' => 'input_med');
     return self::label(wfMessage('input-year')->text(), 'year', array('class' => 'input_med noborder')) . ' ' . Html::input('year', $encYear, 'number', $inputAttribs) . '&#160;' . self::label(wfMessage('input-month')->text(), 'month', array('class' => 'input_med noborder')) . ' ' . self::monthSelector($encMonth, -1);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:30,代码来源:Xml.php


示例15: send

 /**
  * This function will perform a direct (authenticated) login to
  * a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
  * array of parameters. It requires PEAR:Mail to do that.
  * Otherwise it just uses the standard PHP 'mail' function.
  *
  * @param MailAddress|MailAddress[] $to Recipient's email (or an array of them)
  * @param MailAddress $from Sender's email
  * @param string $subject Email's subject.
  * @param string $body Email's text or Array of two strings to be the text and html bodies
  * @param MailAddress $replyto Optional reply-to email (default: null).
  * @param string $contentType Optional custom Content-Type (default: text/plain; charset=UTF-8)
  * @throws MWException
  * @throws Exception
  * @return Status
  */
 public static function send($to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8')
 {
     global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams, $wgAllowHTMLEmail;
     $mime = null;
     if (!is_array($to)) {
         $to = array($to);
     }
     // mail body must have some content
     $minBodyLen = 10;
     // arbitrary but longer than Array or Object to detect casting error
     // body must either be a string or an array with text and body
     if (!(!is_array($body) && strlen($body) >= $minBodyLen) && !(is_array($body) && isset($body['text']) && isset($body['html']) && strlen($body['text']) >= $minBodyLen && strlen($body['html']) >= $minBodyLen)) {
         // if it is neither we have a problem
         return Status::newFatal('user-mail-no-body');
     }
     if (!$wgAllowHTMLEmail && is_array($body)) {
         // HTML not wanted.  Dump it.
         $body = $body['text'];
     }
     wfDebug(__METHOD__ . ': sending mail to ' . implode(', ', $to) . "\n");
     # Make sure we have at least one address
     $has_address = false;
     foreach ($to as $u) {
         if ($u->address) {
             $has_address = true;
             break;
         }
     }
     if (!$has_address) {
         return Status::newFatal('user-mail-no-addy');
     }
     # Forge email headers
     # -------------------
     #
     # WARNING
     #
     # DO NOT add To: or Subject: headers at this step. They need to be
     # handled differently depending upon the mailer we are going to use.
     #
     # To:
     #  PHP mail() first argument is the mail receiver. The argument is
     #  used as a recipient destination and as a To header.
     #
     #  PEAR mailer has a recipient argument which is only used to
     #  send the mail. If no To header is given, PEAR will set it to
     #  to 'undisclosed-recipients:'.
     #
     #  NOTE: To: is for presentation, the actual recipient is specified
     #  by the mailer using the Rcpt-To: header.
     #
     # Subject:
     #  PHP mail() second argument to pass the subject, passing a Subject
     #  as an additional header will result in a duplicate header.
     #
     #  PEAR mailer should be passed a Subject header.
     #
     # -- hashar 20120218
     $headers['From'] = $from->toString();
     $returnPath = $from->address;
     $extraParams = $wgAdditionalMailParams;
     // Hook to generate custom VERP address for 'Return-Path'
     Hooks::run('UserMailerChangeReturnPath', array($to, &$returnPath));
     # Add the envelope sender address using the -f command line option when PHP mail() is used.
     # Will default to the $from->address when the UserMailerChangeReturnPath hook fails and the
     # generated VERP address when the hook runs effectively.
     $extraParams .= ' -f ' . $returnPath;
     $headers['Return-Path'] = $returnPath;
     if ($replyto) {
         $headers['Reply-To'] = $replyto->toString();
     }
     $headers['Date'] = MWTimestamp::getLocalInstance()->format('r');
     $headers['Message-ID'] = self::makeMsgId();
     $headers['X-Mailer'] = 'MediaWiki mailer';
     # Line endings need to be different on Unix and Windows due to
     # the bug described at http://trac.wordpress.org/ticket/2603
     if (wfIsWindows()) {
         $endl = "\r\n";
     } else {
         $endl = "\n";
     }
     if (is_array($body)) {
         // we are sending a multipart message
         wfDebug("Assembling multipart mime email\n");
         if (!stream_resolve_include_path('Mail/mime.php')) {
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:101,代码来源:UserMailer.php


示例16: showImage

 function showImage()
 {
     global $wgOut;
     $wgOut->disable();
     $info = $this->retrieveCaptcha();
     if ($info) {
         $timestamp = new MWTimestamp();
         $info['viewed'] = $timestamp->getTimestamp();
         $this->storeCaptcha($info);
         $salt = $info['salt'];
         $hash = $info['hash'];
         return $this->getBackend()->streamFile(array('src' => $this->imagePath($salt, $hash), 'headers' => array("Cache-Control: private, s-maxage=0, max-age=3600")))->isOK();
     }
     wfHttpError(500, 'Internal Error', 'Requested bogus captcha image');
     return false;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:16,代码来源:FancyCaptcha.class.php


示例17: dateMenu

 /**
  * @param int $year
  * @param int $month
  * @return string Formatted HTML
  */
 public static function dateMenu($year, $month)
 {
     # Offset overrides year/month selection
     if ($month && $month !== -1) {
         $encMonth = intval($month);
     } else {
         $encMonth = '';
     }
     if ($year) {
         $encYear = intval($year);
     } elseif ($encMonth) {
         $timestamp = MWTimestamp::getInstance();
         $thisMonth = intval($timestamp->format('n'));
         $thisYear = intval($timestamp->format('Y'));
         if (intval($encMonth) > $thisMonth) {
             $thisYear--;
         }
         $encYear = $thisYear;
     } else {
         $encYear = '';
     }
     $inputAttribs = array('id' => 'year', 'maxlength' => 4, 'size' => 7);
     return self::label(wfMessage('year')->text(), 'year') . ' ' . Html::input('year', $encYear, 'number', $inputAttribs) . ' ' . self::label(wfMessage('month')->text(), 'month') . ' ' . self::monthSelector($encMonth, -1);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:29,代码来源:Xml.php


示例18: getHumanTimestampInternal

 /**
  * Convert an MWTimestamp into a pretty human-readable timestamp using
  * the given user preferences and relative base time.
  *
  * @see Language::getHumanTimestamp
  * @param MWTimestamp $ts Timestamp to prettify
  * @param MWTimestamp $relativeTo Base timestamp
  * @param User $user User preferences to use
  * @return string Human timestamp
  * @since 1.26
  */
 private function getHumanTimestampInternal(MWTimestamp $ts, MWTimestamp $relativeTo, User $user)
 {
     $diff = $ts->diff($relativeTo);
     $diffDay = (bool) ((int) $ts->timestamp->format('w') - (int) $relativeTo->timestamp->format('w'));
     $days = $diff->days ?: (int) $diffDay;
     if ($diff->invert || $days > 5 && $ts->timestamp->format('Y') !== $relativeTo->timestamp->format('Y')) {
         // Timestamps are in different years: use full timestamp
         // Also do full timestamp for future dates
         /**
          * @todo FIXME: Add better handling of future timestamps.
          */
         $format = $this->getDateFormatString('both', $user->getDatePreference() ?: 'default');
         $ts = $this->sprintfDate($format, $ts->getTimestamp(TS_MW));
     } elseif ($days > 5) {
         // Timestamps are in same year,  but more than 5 days ago: show day and month only.
         $format = $this->getDateFormatString('pretty', $user->getDatePreference() ?: 'default');
         $ts = $this->sprintfDate($format, $ts->getTimestamp(TS_MW));
     } elseif ($days > 1) {
         // Timestamp within the past week: show the day of the week and time
         $format = $this->getDateFormatString('time', $user->getDatePreference() ?: 'default');
         $weekday = self::$mWeekdayMsgs[$ts->timestamp->format('w')];
         // Messages:
         // sunday-at, monday-at, tuesday-at, wednesday-at, thursday-at, friday-at, saturday-at
         $ts = wfMessage("{$weekday}-at")->inLanguage($this)->params($this->sprintfDate($format, $ts->getTimestamp(TS_MW)))->text();
     } elseif ($days == 1) {
         // Timestamp was yesterday: say 'yesterday' and the time.
         $format = $this->getDateFormatString('time', $user->getDatePreference() ?: 'default');
         $ts = wfMessage('yesterday-at')->inLanguage($this)->params($this->sprintfDate($format, $ts->getTimestamp(TS_MW)))->text();
     } elseif ($diff->h > 1 || $diff->h == 1 && $diff->i > 30) {
         // Timestamp was today, but more than 90 minutes ago: say 'today' and the time.
         $format = $this->getDateFormatString('time', $user->getDatePreference() ?: 'default');
         $ts = wfMessage('today-at')->inLanguage($this)->params($this->sprintfDate($format, $ts->getTimestamp(TS_MW)))->text();
         // From here on in, the timestamp was soon enough ago so that we can simply say
         // XX units ago, e.g., "2 hours ago" or "5 minutes ago"
     } elseif ($diff->h == 1) {
         // Less than 90 minutes, but more than an hour ago.
         $ts = wfMessage('hours-ago')->inLanguage($this)->numParams(1)->text();
     } elseif ($diff->i >= 1) {
         // A few minutes ago.
         $ts = wfMessage('minutes-ago')->inLanguage($this)->numParams($diff->i)->text();
     } elseif ($diff->s >= 30) {
         // Less than a minute, but more than 30 sec ago.
         $ts = wfMessage('seconds-ago')->inLanguage($this)->numParams($diff->s)->text();
     } else {
         // Less than 30 seconds ago.
         $ts = wfMessage('just-now')->text();
     }
     return $ts;
 }
开发者ID:nanasess,项目名称:mediawiki,代码行数:60,代码来源:Language.php


示例19: pstPass2

 /**
  * Pre-save transform helper function
  *
  * @param $text string
  * @param $user User
  *
  * @return string
  */
 private function pstPass2($text, $user)
 {
     global $wgContLang;
     # Note: This is the timestamp saved as hardcoded wikitext to
     # the database, we use $wgContLang here in order to give
     # everyone the same signature and use the default one rather
     # than the one selected in each user's preferences.
     # (see also bug 12815)
     $ts = $this->mOptions->getTimestamp();
     $timestamp = MWTimestamp::getLocalInstance($ts);
     $ts = $timestamp->format('YmdHis');
     $tzMsg = $timestamp->format('T');
     # might vary on DST changeover!
     # Allow translation of timezones through wiki. format() can return
     # whatever crap the system uses, localised or not, so we cannot
     # ship premade translations.
     $key = 'timezone-' . strtolower(trim($tzMsg));
     $msg = wfMessage($key)->inContentLanguage();
     if ($msg->exists()) {
         $tzMsg = $msg->text();
     }
     $d = $wgContLang->timeanddate($ts, false, false) . " ({$tzMsg})";
     # Variable replacement
     # Because mOutputType is OT_WIKI, this will only process {{subst:xxx}} type tags
     $text = $this->replaceVariables($text);
     # This works almost by chance, as the replaceVariables are done before the getUserSig(),
     # which may corrupt this parser instance via its wfMessage()->text() call-
     # Signatures
     $sigText = $this->getUserSig($user);
     $text = strtr($text, array('~~~~~' => $d, '~~~~' => "{$sigText} {$d}", '~~~' => $sigText));
     # Context links ("pipe tricks"): [[|name]] and [[name (context)|]]
     $tc = '[' . Title::legalChars() . ']';
     $nc = '[ _0-9A-Za-z\\x80-\\xff-]';
     # Namespaces can use non-ascii!
     $p1 = "/\\[\\[(:?{$nc}+:|:|)({$tc}+?)( ?\\({$tc}+\\))\\|]]/";
     # [[ns:page (context)|]]
     $p4 = "/\\[\\[(:?{$nc}+:|:|)({$tc}+?)( ?({$tc}+))\\|]]/";
     # [[ns:page(context)|]] (double-width brackets, added in r40257)
     $p3 = "/\\[\\[(:?{$nc}+:|:|)({$tc}+?)( ?\\({$tc}+\\)|)((?:, |,){$tc}+|)\\|]]/";
     # [[ns:page (context), context|]] (using either single or double-width comma)
     $p2 = "/\\[\\[\\|({$tc}+)]]/";
     # [[|page]] (reverse pipe trick: add context from page title)
     # try $p1 first, to turn "[[A, B (C)|]]" into "[[A, B (C)|A, B]]"
     $text = preg_replace($p1, '[[\\1\\2\\3|\\2]]', $text);
     $text = preg_replace($p4, '[[\\1\\2\\3|\\2]]', $text);
     $text = preg_replace($p3, '[[\\1\\2\\3\\4|\\2]]', $text);
     $t = $this->mTitle->getText();
     $m = array();
     if (preg_match("/^({$nc}+:|){$tc}+?( \\({$tc}+\\))\$/", $t, $m)) {
         $text = preg_replace($p2, "[[{$m['1']}\\1{$m['2']}|\\1]]", $text);
     } elseif (preg_match("/^({$nc}+:|){$tc}+?(, {$tc}+|)\$/", $t, $m) && "{$m['1']}{$m['2']}" != '') {
         $text = preg_replace($p2, "[[{$m['1']}\\1{$m['2']}|\\1]]", $text);
     } else {
         # if there's no context, don't bother duplicating the title
         $text = preg_replace($p2, '[[\\1]]', $text);
     }
     # Trim trailing whitespace
     $text = rtrim($text);
     return $text;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:68,代码来源:Parser.php


示例20: formatValue

 function formatValue($name, $value)
 {
     static $msg = null;
     if ($msg === null) {
         $keys = ['anononlyblock', 'createaccountblock', 'noautoblockblock', 'emailblock', 'blocklist-nousertalk', 'unblocklink', 'change-blocklink'];
         foreach ($keys as $key) {
             $msg[$key] = $this->msg($key)->escaped();
         }
     }
     /** @var $row object */
     $row = $this->mCurrentRow;
     $language = $this->getLanguage();
     $formatted = '';
     switch ($name) {
         case 'ipb_timestamp':
             $formatted = htmlspecialchars($language->userTimeAndDate($value, $this->getUser()));
             break;
         case 'ipb_target':
             if ($row->ipb_auto) {
                 $formatted = $this->msg('autoblockid', $row->ipb_id)->parse();
             } else {
                 list($target, $type) = Block::parseTarget($row->ipb_address);
                 switch ($type) {
                     case Block::TYPE_USER:
                     case Block::TYPE_IP:
                         $formatted = Linker::userLink($target->getId(), $target);
                         $formatted .= Linker::userToolLinks($target->getId(), $target, false, Linker::TOOL_LINKS_NOBLOCK);
                         break;
                     case Block::TYPE_RANGE:
                         $formatted = htmlspecialchars($target);
                 }
             }
             break;
         case 'ipb_expiry':
             $formatted = htmlspecialchars($language->formatExpiry($value, true));
             if ($this->getUser()->isAllowed('block')) {
                 if ($row->ipb_auto) {
                     $links[] = Linker::linkKnown(SpecialPage::getTitleFor('Unblock'), $msg['unblocklink'], [], ['wpTarget' => "#{$row->ipb_id}"]);
                 } else {
                     $links[] = Linker::linkKnown(SpecialPage::getTitleFor('Unblock', $row->ipb_address), $msg['unblocklink']);
                     $links[] = Linker::linkKnown(SpecialPage::getTitleFor('Block', $row->ipb_address), $msg['change-blocklink']);
                 }
                 $formatted .= ' ' . Html::rawElement('span', ['class' => 'mw-blocklist-actions'], $this->msg('parentheses')->rawParams($language->pipeList($links))->escaped());
             }
             if ($value !== 'infinity') {
                 $timestamp = new MWTimestamp($value);
                 $formatted .= '<br />' . $this->msg('ipb-blocklist-duration-left', $language->formatDuration($timestamp->getTimestamp() - time(), ['minutes', 'hours', 'days', 'years']))->escaped();
             }
             break;
         case 'ipb_by':
             if (isset($row->by_user_name)) {
                 $formatted = Linker::userLink($value, $row->by_user_name);
                 $formatted .= Linker::userToolLinks($value, $row->by_user_name);
             } else {
                 $formatted = htmlspecialchars($row->ipb_by_text);
                 // foreign user?
             }
             break;
         case 'ipb_reason':
             $formatted = Linker::formatComment($value);
             break;
         case 'ipb_params':
             $properties = [];
             if ($row->ipb_anon_only) {
                 $properties[] = $msg['anononlyblock'];
             }
             if ($row->ipb_create_account) {
                 $properties[] = $msg['createaccountblock'];
             }
             if ($r 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MX_Controller类代码示例发布时间:2022-05-23
下一篇:
PHP MWTidy类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap