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


PHP Linker::formatComment方法代码示例

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


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

示例1: formatDiffRow

 /**
  * Really format a diff for the newsfeed
  *
  * @param $title Title object
  * @param $oldid Integer: old revision's id
  * @param $newid Integer: new revision's id
  * @param $timestamp Integer: new revision's timestamp
  * @param $comment String: new revision's comment
  * @param $actiontext String: text of the action; in case of log event
  * @return String
  */
 public static function formatDiffRow($title, $oldid, $newid, $timestamp, $comment, $actiontext = '')
 {
     global $wgFeedDiffCutoff, $wgLang;
     wfProfileIn(__METHOD__);
     # log enties
     $completeText = '<p>' . implode(' ', array_filter(array($actiontext, Linker::formatComment($comment)))) . "</p>\n";
     // NOTE: Check permissions for anonymous users, not current user.
     //       No "privileged" version should end up in the cache.
     //       Most feed readers will not log in anway.
     $anon = new User();
     $accErrors = $title->getUserPermissionsErrors('read', $anon, true);
     // Can't diff special pages, unreadable pages or pages with no new revision
     // to compare against: just return the text.
     if ($title->getNamespace() < 0 || $accErrors || !$newid) {
         wfProfileOut(__METHOD__);
         return $completeText;
     }
     if ($oldid) {
         wfProfileIn(__METHOD__ . "-dodiff");
         #$diffText = $de->getDiff( wfMsg( 'revisionasof',
         #	$wgLang->timeanddate( $timestamp ),
         #	$wgLang->date( $timestamp ),
         #	$wgLang->time( $timestamp ) ),
         #	wfMsg( 'currentrev' ) );
         // Don't bother generating the diff if we won't be able to show it
         if ($wgFeedDiffCutoff > 0) {
             $de = new DifferenceEngine($title, $oldid, $newid);
             $diffText = $de->getDiff(wfMsg('previousrevision'), wfMsg('revisionasof', $wgLang->timeanddate($timestamp), $wgLang->date($timestamp), $wgLang->time($timestamp)));
         }
         if ($wgFeedDiffCutoff <= 0 || strlen($diffText) > $wgFeedDiffCutoff) {
             // Omit large diffs
             $diffText = self::getDiffLink($title, $newid, $oldid);
         } elseif ($diffText === false) {
             // Error in diff engine, probably a missing revision
             $diffText = "<p>Can't load revision {$newid}</p>";
         } else {
             // Diff output fine, clean up any illegal UTF-8
             $diffText = UtfNormal::cleanUp($diffText);
             $diffText = self::applyDiffStyle($diffText);
         }
         wfProfileOut(__METHOD__ . "-dodiff");
     } else {
         $rev = Revision::newFromId($newid);
         if ($wgFeedDiffCutoff <= 0 || is_null($rev)) {
             $newtext = '';
         } else {
             $newtext = $rev->getText();
         }
         if ($wgFeedDiffCutoff <= 0 || strlen($newtext) > $wgFeedDiffCutoff) {
             // Omit large new page diffs, bug 29110
             $diffText = self::getDiffLink($title, $newid);
         } else {
             $diffText = '<p><b>' . wfMsg('newpage') . '</b></p>' . '<div>' . nl2br(htmlspecialchars($newtext)) . '</div>';
         }
     }
     $completeText .= $diffText;
     wfProfileOut(__METHOD__);
     return $completeText;
 }
开发者ID:yusufchang,项目名称:app,代码行数:70,代码来源:FeedUtils.php

示例2: testFormatComment

 /**
  * @dataProvider provideCasesForFormatComment
  * @covers Linker::formatComment
  * @covers Linker::formatAutocomments
  * @covers Linker::formatLinksInComment
  */
 public function testFormatComment($expected, $comment, $title = false, $local = false)
 {
     $this->setMwGlobals(array('wgScript' => '/wiki/index.php', 'wgArticlePath' => '/wiki/$1', 'wgWellFormedXml' => true, 'wgCapitalLinks' => true));
     if ($title === false) {
         // We need a page title that exists
         $title = Title::newFromText('Special:BlankPage');
     }
     $this->assertEquals($expected, Linker::formatComment($comment, $title, $local));
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:15,代码来源:LinkerTest.php

示例3: onView

 public function onView()
 {
     $details = null;
     $request = $this->getRequest();
     $result = $this->page->doRollback($request->getVal('from'), $request->getText('summary'), $request->getVal('token'), $request->getBool('bot'), $details, $this->getUser());
     if (in_array(array('actionthrottledtext'), $result)) {
         throw new ThrottledError();
     }
     if (isset($result[0][0]) && ($result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback')) {
         $this->getOutput()->setPageTitle(wfMsg('rollbackfailed'));
         $errArray = $result[0];
         $errMsg = array_shift($errArray);
         $this->getOutput()->addWikiMsgArray($errMsg, $errArray);
         if (isset($details['current'])) {
             $current = $details['current'];
             if ($current->getComment() != '') {
                 $this->getOutput()->addHTML(wfMessage('editcomment')->rawParams(Linker::formatComment($current->getComment()))->parse());
             }
         }
         return;
     }
     # Display permissions errors before read-only message -- there's no
     # point in misleading the user into thinking the inability to rollback
     # is only temporary.
     if (!empty($result) && $result !== array(array('readonlytext'))) {
         # array_diff is completely broken for arrays of arrays, sigh.
         # Remove any 'readonlytext' error manually.
         $out = array();
         foreach ($result as $error) {
             if ($error != array('readonlytext')) {
                 $out[] = $error;
             }
         }
         $this->getOutput()->showPermissionsErrorPage($out);
         return;
     }
     if ($result == array(array('readonlytext'))) {
         throw new ReadOnlyError();
     }
     $current = $details['current'];
     $target = $details['target'];
     $newId = $details['newid'];
     $this->getOutput()->setPageTitle(wfMsg('actioncomplete'));
     $this->getOutput()->setRobotPolicy('noindex,nofollow');
     if ($current->getUserText() === '') {
         $old = wfMsg('rev-deleted-user');
     } else {
         $old = Linker::userLink($current->getUser(), $current->getUserText()) . Linker::userToolLinks($current->getUser(), $current->getUserText());
     }
     $new = Linker::userLink($target->getUser(), $target->getUserText()) . Linker::userToolLinks($target->getUser(), $target->getUserText());
     $this->getOutput()->addHTML(wfMsgExt('rollback-success', array('parse', 'replaceafter'), $old, $new));
     $this->getOutput()->returnToMain(false, $this->getTitle());
     if (!$request->getBool('hidediff', false) && !$this->getUser()->getBoolOption('norollbackdiff', false)) {
         $de = new DifferenceEngine($this->getTitle(), $current->getId(), $newId, false, true);
         $de->showDiff('', '');
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:57,代码来源:RollbackAction.php

示例4: formatComment

 /**
  * Formats an edit comment
  * @param string $comment The raw comment text
  * @param Title $title The title of the page that was edited
  * @fixme: Duplication with SpecialMobileWatchlist
  *
  * @return string HTML code
  */
 protected function formatComment($comment, $title)
 {
     if ($comment === '') {
         $comment = $this->msg('mobile-frontend-changeslist-nocomment')->plain();
     } else {
         $comment = Linker::formatComment($comment, $title);
         // flatten back to text
         $comment = Sanitizer::stripAllTags($comment);
     }
     return $comment;
 }
开发者ID:negati-ve,项目名称:openshift-mediawiki,代码行数:19,代码来源:MobileSpecialPageFeed.php

示例5: testFormatComment

 /**
  * @dataProvider provideCasesForFormatComment
  * @covers Linker::formatComment
  * @covers Linker::formatAutocomments
  * @covers Linker::formatLinksInComment
  */
 public function testFormatComment($expected, $comment, $title = false, $local = false, $wikiId = null)
 {
     $conf = new SiteConfiguration();
     $conf->settings = array('wgServer' => array('enwiki' => '//en.example.org', 'dewiki' => '//de.example.org'), 'wgArticlePath' => array('enwiki' => '/w/$1', 'dewiki' => '/w/$1'));
     $conf->suffixes = array('wiki');
     $this->setMwGlobals(array('wgScript' => '/wiki/index.php', 'wgArticlePath' => '/wiki/$1', 'wgWellFormedXml' => true, 'wgCapitalLinks' => true, 'wgConf' => $conf));
     if ($title === false) {
         // We need a page title that exists
         $title = Title::newFromText('Special:BlankPage');
     }
     $this->assertEquals($expected, Linker::formatComment($comment, $title, $local, $wikiId));
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:18,代码来源:LinkerTest.php

示例6: onView

 public function onView()
 {
     // TODO: use $this->useTransactionalTimeLimit(); when POST only
     wfTransactionalTimeLimit();
     $details = null;
     $request = $this->getRequest();
     $user = $this->getUser();
     $result = $this->page->doRollback($request->getVal('from'), $request->getText('summary'), $request->getVal('token'), $request->getBool('bot'), $details, $this->getUser());
     if (in_array(array('actionthrottledtext'), $result)) {
         throw new ThrottledError();
     }
     if (isset($result[0][0]) && ($result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback')) {
         $this->getOutput()->setPageTitle($this->msg('rollbackfailed'));
         $errArray = $result[0];
         $errMsg = array_shift($errArray);
         $this->getOutput()->addWikiMsgArray($errMsg, $errArray);
         if (isset($details['current'])) {
             /** @var Revision $current */
             $current = $details['current'];
             if ($current->getComment() != '') {
                 $this->getOutput()->addHTML($this->msg('editcomment')->rawParams(Linker::formatComment($current->getComment()))->parse());
             }
         }
         return;
     }
     #NOTE: Permission errors already handled by Action::checkExecute.
     if ($result == array(array('readonlytext'))) {
         throw new ReadOnlyError();
     }
     #XXX: Would be nice if ErrorPageError could take multiple errors, and/or a status object.
     #     Right now, we only show the first error
     foreach ($result as $error) {
         throw new ErrorPageError('rollbackfailed', $error[0], array_slice($error, 1));
     }
     /** @var Revision $current */
     $current = $details['current'];
     $target = $details['target'];
     $newId = $details['newid'];
     $this->getOutput()->setPageTitle($this->msg('actioncomplete'));
     $this->getOutput()->setRobotPolicy('noindex,nofollow');
     $old = Linker::revUserTools($current);
     $new = Linker::revUserTools($target);
     $this->getOutput()->addHTML($this->msg('rollback-success')->rawParams($old, $new)->parseAsBlock());
     if ($user->getBoolOption('watchrollback')) {
         $user->addWatch($this->page->getTitle(), WatchedItem::IGNORE_USER_RIGHTS);
     }
     $this->getOutput()->returnToMain(false, $this->getTitle());
     if (!$request->getBool('hidediff', false) && !$this->getUser()->getBoolOption('norollbackdiff', false)) {
         $contentHandler = $current->getContentHandler();
         $de = $contentHandler->createDifferenceEngine($this->getContext(), $current->getId(), $newId, false, true);
         $de->showDiff('', '');
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:53,代码来源:RollbackAction.php

示例7: extractRevisionInfo

 /**
  * Extract information from the Revision
  *
  * @param Revision $revision
  * @param object $row Should have a field 'ts_tags' if $this->fld_tags is set
  * @return array
  */
 protected function extractRevisionInfo(Revision $revision, $row)
 {
     $title = $revision->getTitle();
     $user = $this->getUser();
     $vals = array();
     $anyHidden = false;
     if ($this->fld_ids) {
         $vals['revid'] = intval($revision->getId());
         if (!is_null($revision->getParentId())) {
             $vals['parentid'] = intval($revision->getParentId());
         }
     }
     if ($this->fld_flags) {
         $vals['minor'] = $revision->isMinor();
     }
     if ($this->fld_user || $this->fld_userid) {
         if ($revision->isDeleted(Revision::DELETED_USER)) {
             $vals['userhidden'] = true;
             $anyHidden = true;
         }
         if ($revision->userCan(Revision::DELETED_USER, $user)) {
             if ($this->fld_user) {
                 $vals['user'] = $revision->getUserText(Revision::RAW);
             }
             $userid = $revision->getUser(Revision::RAW);
             if (!$userid) {
                 $vals['anon'] = true;
             }
             if ($this->fld_userid) {
                 $vals['userid'] = $userid;
             }
         }
     }
     if ($this->fld_timestamp) {
         $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $revision->getTimestamp());
     }
     if ($this->fld_size) {
         if (!is_null($revision->getSize())) {
             $vals['size'] = intval($revision->getSize());
         } else {
             $vals['size'] = 0;
         }
     }
     if ($this->fld_sha1) {
         if ($revision->isDeleted(Revision::DELETED_TEXT)) {
             $vals['sha1hidden'] = true;
             $anyHidden = true;
         }
         if ($revision->userCan(Revision::DELETED_TEXT, $user)) {
             if ($revision->getSha1() != '') {
                 $vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
             } else {
                 $vals['sha1'] = '';
             }
         }
     }
     if ($this->fld_contentmodel) {
         $vals['contentmodel'] = $revision->getContentModel();
     }
     if ($this->fld_comment || $this->fld_parsedcomment) {
         if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
             $vals['commenthidden'] = true;
             $anyHidden = true;
         }
         if ($revision->userCan(Revision::DELETED_COMMENT, $user)) {
             $comment = $revision->getComment(Revision::RAW);
             if ($this->fld_comment) {
                 $vals['comment'] = $comment;
             }
             if ($this->fld_parsedcomment) {
                 $vals['parsedcomment'] = Linker::formatComment($comment, $title);
             }
         }
     }
     if ($this->fld_tags) {
         if ($row->ts_tags) {
             $tags = explode(',', $row->ts_tags);
             ApiResult::setIndexedTagName($tags, 'tag');
             $vals['tags'] = $tags;
         } else {
             $vals['tags'] = array();
         }
     }
     $content = null;
     global $wgParser;
     if ($this->fetchContent) {
         $content = $revision->getContent(Revision::FOR_THIS_USER, $this->getUser());
         // Expand templates after getting section content because
         // template-added sections don't count and Parser::preprocess()
         // will have less input
         if ($content && $this->section !== false) {
             $content = $content->getSection($this->section, false);
             if (!$content) {
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:101,代码来源:ApiQueryRevisionsBase.php

示例8: formatComment

 /**
  * Formats a comment of revision via Linker:formatComment and Sanitizer::stripAllTags
  * @param string $comment the comment
  * @param string $title the title object of comments page
  * @return string formatted comment
  */
 protected function formatComment($comment, $title)
 {
     if ($comment !== '') {
         $comment = Linker::formatComment($comment, $title);
         // flatten back to text
         $comment = Sanitizer::stripAllTags($comment);
     }
     return $comment;
 }
开发者ID:GoProjectOwner,项目名称:mediawiki-extensions-MobileFrontend,代码行数:15,代码来源:SpecialMobileWatchlist.php

示例9: imageHistoryLine


//.........这里部分代码省略.........
         if ($user->isAllowed('delete')) {
             $q = array('action' => 'delete');
             if (!$iscur) {
                 $q['oldimage'] = $img;
             }
             $row .= Linker::linkKnown($this->title, $this->msg($iscur ? 'filehist-deleteall' : 'filehist-deleteone')->escaped(), array(), $q);
         }
         # Link to hide content. Don't show useless link to people who cannot hide revisions.
         $canHide = $user->isAllowed('deleterevision');
         if ($canHide || $user->isAllowed('deletedhistory') && $file->getVisibility()) {
             if ($user->isAllowed('delete')) {
                 $row .= '<br />';
             }
             // If file is top revision or locked from this user, don't link
             if ($iscur || !$file->userCan(File::DELETED_RESTRICTED, $user)) {
                 $del = Linker::revDeleteLinkDisabled($canHide);
             } else {
                 list($ts, ) = explode('!', $img, 2);
                 $query = array('type' => 'oldimage', 'target' => $this->title->getPrefixedText(), 'ids' => $ts);
                 $del = Linker::revDeleteLink($query, $file->isDeleted(File::DELETED_RESTRICTED), $canHide);
             }
             $row .= $del;
         }
         $row .= '</td>';
     }
     // Reversion link/current indicator
     $row .= '<td>';
     if ($iscur) {
         $row .= $this->msg('filehist-current')->escaped();
     } elseif ($local && $this->title->quickUserCan('edit', $user) && $this->title->quickUserCan('upload', $user)) {
         if ($file->isDeleted(File::DELETED_FILE)) {
             $row .= $this->msg('filehist-revert')->escaped();
         } else {
             $row .= Linker::linkKnown($this->title, $this->msg('filehist-revert')->escaped(), array(), array('action' => 'revert', 'oldimage' => $img, 'wpEditToken' => $user->getEditToken($img)));
         }
     }
     $row .= '</td>';
     // Date/time and image link
     if ($file->getTimestamp() === $this->img->getTimestamp()) {
         $selected = "class='filehistory-selected'";
     }
     $row .= "<td {$selected} style='white-space: nowrap;'>";
     if (!$file->userCan(File::DELETED_FILE, $user)) {
         # Don't link to unviewable files
         $row .= '<span class="history-deleted">' . $lang->userTimeAndDate($timestamp, $user) . '</span>';
     } elseif ($file->isDeleted(File::DELETED_FILE)) {
         if ($local) {
             $this->preventClickjacking();
             $revdel = SpecialPage::getTitleFor('Revisiondelete');
             # Make a link to review the image
             $url = Linker::linkKnown($revdel, $lang->userTimeAndDate($timestamp, $user), array(), array('target' => $this->title->getPrefixedText(), 'file' => $img, 'token' => $user->getEditToken($img)));
         } else {
             $url = $lang->userTimeAndDate($timestamp, $user);
         }
         $row .= '<span class="history-deleted">' . $url . '</span>';
     } else {
         $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl($img);
         $row .= Xml::element('a', array('href' => $url), $lang->userTimeAndDate($timestamp, $user));
     }
     $row .= "</td>";
     // Thumbnail
     if ($this->showThumb) {
         $row .= '<td>' . $this->getThumbForLine($file) . '</td>';
     }
     // Image dimensions + size
     $row .= '<td>';
     $row .= htmlspecialchars($file->getDimensionsString());
     $row .= $this->msg('word-separator')->plain();
     $row .= '<span style="white-space: nowrap;">';
     $row .= $this->msg('parentheses')->rawParams(Linker::formatSize($file->getSize()))->plain();
     $row .= '</span>';
     $row .= '</td>';
     // Uploading user
     $row .= '<td>';
     // Hide deleted usernames
     if ($file->isDeleted(File::DELETED_USER)) {
         $row .= '<span class="history-deleted">' . $this->msg('rev-deleted-user')->escaped() . '</span>';
     } else {
         if ($local) {
             $row .= Linker::userLink($userId, $userText);
             $row .= $this->msg('word-separator')->plain();
             $row .= '<span style="white-space: nowrap;">';
             $row .= Linker::userToolLinks($userId, $userText);
             $row .= '</span>';
         } else {
             $row .= htmlspecialchars($userText);
         }
     }
     $row .= '</td>';
     // Don't show deleted descriptions
     if ($file->isDeleted(File::DELETED_COMMENT)) {
         $row .= '<td><span class="history-deleted">' . $this->msg('rev-deleted-comment')->escaped() . '</span></td>';
     } else {
         $row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment($description, $this->title) . '</td>';
     }
     $rowClass = null;
     wfRunHooks('ImagePageFileHistoryLine', array($this, $file, &$row, &$rowClass));
     $classAttr = $rowClass ? " class='{$rowClass}'" : '';
     return "<tr{$classAttr}>{$row}</tr>\n";
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:101,代码来源:ImagePage.php

示例10: extractRowInfo

 private function extractRowInfo($row)
 {
     $logEntry = DatabaseLogEntry::newFromRow($row);
     $vals = array();
     if ($this->fld_ids) {
         $vals['logid'] = intval($row->log_id);
         $vals['pageid'] = intval($row->page_id);
     }
     if ($this->fld_title || $this->fld_parsedcomment) {
         $title = Title::makeTitle($row->log_namespace, $row->log_title);
     }
     if ($this->fld_title) {
         if (LogEventsList::isDeleted($row, LogPage::DELETED_ACTION)) {
             $vals['actionhidden'] = '';
         } else {
             ApiQueryBase::addTitleInfo($vals, $title);
         }
     }
     if ($this->fld_type || $this->fld_action) {
         $vals['type'] = $row->log_type;
         $vals['action'] = $row->log_action;
     }
     if ($this->fld_details && $row->log_params !== '') {
         if (LogEventsList::isDeleted($row, LogPage::DELETED_ACTION)) {
             $vals['actionhidden'] = '';
         } else {
             self::addLogParams($this->getResult(), $vals, $logEntry->getParameters(), $logEntry->getType(), $logEntry->getSubtype(), $logEntry->getTimestamp(), $logEntry->isLegacy());
         }
     }
     if ($this->fld_user || $this->fld_userid) {
         if (LogEventsList::isDeleted($row, LogPage::DELETED_USER)) {
             $vals['userhidden'] = '';
         } else {
             if ($this->fld_user) {
                 $vals['user'] = $row->user_name;
             }
             if ($this->fld_userid) {
                 $vals['userid'] = $row->user_id;
             }
             if (!$row->log_user) {
                 $vals['anon'] = '';
             }
         }
     }
     if ($this->fld_timestamp) {
         $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->log_timestamp);
     }
     if (($this->fld_comment || $this->fld_parsedcomment) && isset($row->log_comment)) {
         if (LogEventsList::isDeleted($row, LogPage::DELETED_COMMENT)) {
             $vals['commenthidden'] = '';
         } else {
             if ($this->fld_comment) {
                 $vals['comment'] = $row->log_comment;
             }
             if ($this->fld_parsedcomment) {
                 $vals['parsedcomment'] = Linker::formatComment($row->log_comment, $title);
             }
         }
     }
     if ($this->fld_tags) {
         if ($row->ts_tags) {
             $tags = explode(',', $row->ts_tags);
             $this->getResult()->setIndexedTagName($tags, 'tag');
             $vals['tags'] = $tags;
         } else {
             $vals['tags'] = array();
         }
     }
     return $vals;
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:70,代码来源:ApiQueryLogEvents.php

示例11: formatValue

 /**
  * @param string $field
  * @param string $value
  * @return string HTML
  * @throws MWException
  */
 function formatValue($field, $value)
 {
     /** @var $row object */
     $row = $this->mCurrentRow;
     $formatted = '';
     switch ($field) {
         case 'log_timestamp':
             // when timestamp is null, this is a old protection row
             if ($value === null) {
                 $formatted = Html::rawElement('span', array('class' => 'mw-protectedpages-unknown'), $this->msg('protectedpages-unknown-timestamp')->escaped());
             } else {
                 $formatted = htmlspecialchars($this->getLanguage()->userTimeAndDate($value, $this->getUser()));
             }
             break;
         case 'pr_page':
             $title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
             if (!$title) {
                 $formatted = Html::element('span', array('class' => 'mw-invalidtitle'), Linker::getInvalidTitleDescription($this->getContext(), $row->page_namespace, $row->page_title));
             } else {
                 $formatted = Linker::link($title);
             }
             if (!is_null($row->page_len)) {
                 $formatted .= $this->getLanguage()->getDirMark() . ' ' . Html::rawElement('span', array('class' => 'mw-protectedpages-length'), Linker::formatRevisionSize($row->page_len));
             }
             break;
         case 'pr_expiry':
             $formatted = htmlspecialchars($this->getLanguage()->formatExpiry($value, true));
             $title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
             if ($this->getUser()->isAllowed('protect') && $title) {
                 $changeProtection = Linker::linkKnown($title, $this->msg('protect_change')->escaped(), array(), array('action' => 'unprotect'));
                 $formatted .= ' ' . Html::rawElement('span', array('class' => 'mw-protectedpages-actions'), $this->msg('parentheses')->rawParams($changeProtection)->escaped());
             }
             break;
         case 'log_user':
             // when timestamp is null, this is a old protection row
             if ($row->log_timestamp === null) {
                 $formatted = Html::rawElement('span', array('class' => 'mw-protectedpages-unknown'), $this->msg('protectedpages-unknown-performer')->escaped());
             } else {
                 $username = UserCache::singleton()->getProp($value, 'name');
                 if (LogEventsList::userCanBitfield($row->log_deleted, LogPage::DELETED_USER, $this->getUser())) {
                     if ($username === false) {
                         $formatted = htmlspecialchars($value);
                     } else {
                         $formatted = Linker::userLink($value, $username) . Linker::userToolLinks($value, $username);
                     }
                 } else {
                     $formatted = $this->msg('rev-deleted-user')->escaped();
                 }
                 if (LogEventsList::isDeleted($row, LogPage::DELETED_USER)) {
                     $formatted = '<span class="history-deleted">' . $formatted . '</span>';
                 }
             }
             break;
         case 'pr_params':
             $params = array();
             // Messages: restriction-level-sysop, restriction-level-autoconfirmed
             $params[] = $this->msg('restriction-level-' . $row->pr_level)->escaped();
             if ($row->pr_cascade) {
                 $params[] = $this->msg('protect-summary-cascade')->escaped();
             }
             $formatted = $this->getLanguage()->commaList($params);
             break;
         case 'log_comment':
             // when timestamp is null, this is an old protection row
             if ($row->log_timestamp === null) {
                 $formatted = Html::rawElement('span', array('class' => 'mw-protectedpages-unknown'), $this->msg('protectedpages-unknown-reason')->escaped());
             } else {
                 if (LogEventsList::userCanBitfield($row->log_deleted, LogPage::DELETED_COMMENT, $this->getUser())) {
                     $formatted = Linker::formatComment($value !== null ? $value : '');
                 } else {
                     $formatted = $this->msg('rev-deleted-comment')->escaped();
                 }
                 if (LogEventsList::isDeleted($row, LogPage::DELETED_COMMENT)) {
                     $formatted = '<span class="history-deleted">' . $formatted . '</span>';
                 }
             }
             break;
         default:
             throw new MWException("Unknown field '{$field}'");
     }
     return $formatted;
 }
开发者ID:huatuoorg,项目名称:mediawiki,代码行数:88,代码来源:SpecialProtectedpages.php

示例12: execute


//.........这里部分代码省略.........
             $sha1 = strtolower($params['sha1base36']);
             if (!$this->validateSha1Base36Hash($sha1)) {
                 $this->dieUsage('The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash');
             }
         }
         if ($sha1) {
             $this->addWhereFld('fa_sha1', $sha1);
         }
     }
     // Exclude files this user can't view.
     if (!$user->isAllowed('deletedtext')) {
         $bitmask = File::DELETED_FILE;
     } elseif (!$user->isAllowedAny('suppressrevision', 'viewsuppressed')) {
         $bitmask = File::DELETED_FILE | File::DELETED_RESTRICTED;
     } else {
         $bitmask = 0;
     }
     if ($bitmask) {
         $this->addWhere($this->getDB()->bitAnd('fa_deleted', $bitmask) . " != {$bitmask}");
     }
     $limit = $params['limit'];
     $this->addOption('LIMIT', $limit + 1);
     $sort = $params['dir'] == 'descending' ? ' DESC' : '';
     $this->addOption('ORDER BY', array('fa_name' . $sort, 'fa_timestamp' . $sort, 'fa_id' . $sort));
     $res = $this->select(__METHOD__);
     $count = 0;
     $result = $this->getResult();
     foreach ($res as $row) {
         if (++$count > $limit) {
             // We've reached the one extra which shows that there are
             // additional pages to be had. Stop here...
             $this->setContinueEnumParameter('continue', "{$row->fa_name}|{$row->fa_timestamp}|{$row->fa_id}");
             break;
         }
         $file = array();
         $file['id'] = (int) $row->fa_id;
         $file['name'] = $row->fa_name;
         $title = Title::makeTitle(NS_FILE, $row->fa_name);
         self::addTitleInfo($file, $title);
         if ($fld_description && Revision::userCanBitfield($row->fa_deleted, File::DELETED_COMMENT, $user)) {
             $file['description'] = $row->fa_description;
             if (isset($prop['parseddescription'])) {
                 $file['parseddescription'] = Linker::formatComment($row->fa_description, $title);
             }
         }
         if ($fld_user && Revision::userCanBitfield($row->fa_deleted, File::DELETED_USER, $user)) {
             $file['userid'] = (int) $row->fa_user;
             $file['user'] = $row->fa_user_text;
         }
         if ($fld_sha1) {
             $file['sha1'] = wfBaseConvert($row->fa_sha1, 36, 16, 40);
         }
         if ($fld_timestamp) {
             $file['timestamp'] = wfTimestamp(TS_ISO_8601, $row->fa_timestamp);
         }
         if ($fld_size || $fld_dimensions) {
             $file['size'] = $row->fa_size;
             $pageCount = ArchivedFile::newFromRow($row)->pageCount();
             if ($pageCount !== false) {
                 $file['pagecount'] = $pageCount;
             }
             $file['height'] = $row->fa_height;
             $file['width'] = $row->fa_width;
         }
         if ($fld_mediatype) {
             $file['mediatype'] = $row->fa_media_type;
         }
         if ($fld_metadata) {
             $file['metadata'] = $row->fa_metadata ? ApiQueryImageInfo::processMetaData(unserialize($row->fa_metadata), $result) : null;
         }
         if ($fld_bitdepth) {
             $file['bitdepth'] = $row->fa_bits;
         }
         if ($fld_mime) {
             $file['mime'] = "{$row->fa_major_mime}/{$row->fa_minor_mime}";
         }
         if ($fld_archivename && !is_null($row->fa_archive_name)) {
             $file['archivename'] = $row->fa_archive_name;
         }
         if ($row->fa_deleted & File::DELETED_FILE) {
             $file['filehidden'] = true;
         }
         if ($row->fa_deleted & File::DELETED_COMMENT) {
             $file['commenthidden'] = true;
         }
         if ($row->fa_deleted & File::DELETED_USER) {
             $file['userhidden'] = true;
         }
         if ($row->fa_deleted & File::DELETED_RESTRICTED) {
             // This file is deleted for normal admins
             $file['suppressed'] = true;
         }
         $fit = $result->addValue(array('query', $this->getModuleName()), null, $file);
         if (!$fit) {
             $this->setContinueEnumParameter('continue', "{$row->fa_name}|{$row->fa_timestamp}|{$row->fa_id}");
             break;
         }
     }
     $result->addIndexedTagName(array('query', $this->getModuleName()), 'fa');
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:101,代码来源:ApiQueryFilearchive.php

示例13: getInfo

 /**
  * Get result information for an image revision
  *
  * @param File $file
  * @param array $prop Array of properties to get (in the keys)
  * @param ApiResult $result
  * @param array $thumbParams Containing 'width' and 'height' items, or null
  * @param array|bool|string $opts Options for data fetching.
  *   This is an array consisting of the keys:
  *    'version': The metadata version for the metadata option
  *    'language': The language for extmetadata property
  *    'multilang': Return all translations in extmetadata property
  *    'revdelUser': User to use when checking whether to show revision-deleted fields.
  * @return array Result array
  */
 static function getInfo($file, $prop, $result, $thumbParams = null, $opts = false)
 {
     global $wgContLang;
     $anyHidden = false;
     if (!$opts || is_string($opts)) {
         $opts = array('version' => $opts ?: 'latest', 'language' => $wgContLang, 'multilang' => false, 'extmetadatafilter' => array(), 'revdelUser' => null);
     }
     $version = $opts['version'];
     $vals = array(ApiResult::META_TYPE => 'assoc');
     // Timestamp is shown even if the file is revdelete'd in interface
     // so do same here.
     if (isset($prop['timestamp'])) {
         $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $file->getTimestamp());
     }
     // Handle external callers who don't pass revdelUser
     if (isset($opts['revdelUser']) && $opts['revdelUser']) {
         $revdelUser = $opts['revdelUser'];
         $canShowField = function ($field) use($file, $revdelUser) {
             return $file->userCan($field, $revdelUser);
         };
     } else {
         $canShowField = function ($field) use($file) {
             return !$file->isDeleted($field);
         };
     }
     $user = isset($prop['user']);
     $userid = isset($prop['userid']);
     if ($user || $userid) {
         if ($file->isDeleted(File::DELETED_USER)) {
             $vals['userhidden'] = true;
             $anyHidden = true;
         }
         if ($canShowField(File::DELETED_USER)) {
             if ($user) {
                 $vals['user'] = $file->getUser();
             }
             if ($userid) {
                 $vals['userid'] = $file->getUser('id');
             }
             if (!$file->getUser('id')) {
                 $vals['anon'] = true;
             }
         }
     }
     // This is shown even if the file is revdelete'd in interface
     // so do same here.
     if (isset($prop['size']) || isset($prop['dimensions'])) {
         $vals['size'] = intval($file->getSize());
         $vals['width'] = intval($file->getWidth());
         $vals['height'] = intval($file->getHeight());
         $pageCount = $file->pageCount();
         if ($pageCount !== false) {
             $vals['pagecount'] = $pageCount;
         }
         // length as in how many seconds long a video is.
         $length = $file->getLength();
         if ($length) {
             // Call it duration, because "length" can be ambiguous.
             $vals['duration'] = (double) $length;
         }
     }
     $pcomment = isset($prop['parsedcomment']);
     $comment = isset($prop['comment']);
     if ($pcomment || $comment) {
         if ($file->isDeleted(File::DELETED_COMMENT)) {
             $vals['commenthidden'] = true;
             $anyHidden = true;
         }
         if ($canShowField(File::DELETED_COMMENT)) {
             if ($pcomment) {
                 $vals['parsedcomment'] = Linker::formatComment($file->getDescription(File::RAW), $file->getTitle());
             }
             if ($comment) {
                 $vals['comment'] = $file->getDescription(File::RAW);
             }
         }
     }
     $canonicaltitle = isset($prop['canonicaltitle']);
     $url = isset($prop['url']);
     $sha1 = isset($prop['sha1']);
     $meta = isset($prop['metadata']);
     $extmetadata = isset($prop['extmetadata']);
     $commonmeta = isset($prop['commonmetadata']);
     $mime = isset($prop['mime']);
     $mediatype = isset($prop['mediatype']);
//.........这里部分代码省略.........
开发者ID:sukesan1984,项目名称:agrarian-wiki,代码行数:101,代码来源:ApiQueryImageInfo.php

示例14: extractRowInfo

 private function extractRowInfo($row)
 {
     $revision = new Revision($row);
     $title = $revision->getTitle();
     $vals = array();
     if ($this->fld_ids) {
         $vals['revid'] = intval($revision->getId());
         // $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
         if (!is_null($revision->getParentId())) {
             $vals['parentid'] = intval($revision->getParentId());
         }
     }
     if ($this->fld_flags && $revision->isMinor()) {
         $vals['minor'] = '';
     }
     if ($this->fld_user || $this->fld_userid) {
         if ($revision->isDeleted(Revision::DELETED_USER)) {
             $vals['userhidden'] = '';
         } else {
             if ($this->fld_user) {
                 $vals['user'] = $revision->getUserText();
             }
             $userid = $revision->getUser();
             if (!$userid) {
                 $vals['anon'] = '';
             }
             if ($this->fld_userid) {
                 $vals['userid'] = $userid;
             }
         }
     }
     if ($this->fld_timestamp) {
         $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $revision->getTimestamp());
     }
     if ($this->fld_size) {
         if (!is_null($revision->getSize())) {
             $vals['size'] = intval($revision->getSize());
         } else {
             $vals['size'] = 0;
         }
     }
     if ($this->fld_sha1) {
         if ($revision->getSha1() != '') {
             $vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
         } else {
             $vals['sha1'] = '';
         }
     }
     if ($this->fld_comment || $this->fld_parsedcomment) {
         if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
             $vals['commenthidden'] = '';
         } else {
             $comment = $revision->getComment();
             if ($this->fld_comment) {
                 $vals['comment'] = $comment;
             }
             if ($this->fld_parsedcomment) {
                 $vals['parsedcomment'] = Linker::formatComment($comment, $title);
             }
         }
     }
     if ($this->fld_tags) {
         if ($row->ts_tags) {
             $tags = explode(',', $row->ts_tags);
             $this->getResult()->setIndexedTagName($tags, 'tag');
             $vals['tags'] = $tags;
         } else {
             $vals['tags'] = array();
         }
     }
     if (!is_null($this->token)) {
         $tokenFunctions = $this->getTokenFunctions();
         foreach ($this->token as $t) {
             $val = call_user_func($tokenFunctions[$t], $title->getArticleID(), $title, $revision);
             if ($val === false) {
                 $this->setWarning("Action '{$t}' is not allowed for the current user");
             } else {
                 $vals[$t . 'token'] = $val;
             }
         }
     }
     $text = null;
     global $wgParser;
     if ($this->fld_content || !is_null($this->difftotext)) {
         $text = $revision->getText();
         // Expand templates after getting section content because
         // template-added sections don't count and Parser::preprocess()
         // will have less input
         if ($this->section !== false) {
             $text = $wgParser->getSection($text, $this->section, false);
             if ($text === false) {
                 $this->dieUsage("There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection');
             }
         }
     }
     if ($this->fld_content && !$revision->isDeleted(Revision::DELETED_TEXT)) {
         if ($this->generateXML) {
             $wgParser->startExternalParse($title, ParserOptions::newFromContext($this->getContext()), OT_PREPROCESS);
             $dom = $wgParser->preprocessToDom($text);
             if (is_callable(array($dom, 'saveXML'))) {
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:ApiQueryRevisions.php

示例15: formatComment

 public function formatComment($comment, $title = null, $local = false, $wikiId = null)
 {
     return Linker::formatComment($comment, $title, $local, $wikiId);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:4,代码来源:DummyLinker.php


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