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


PHP Revision::newFromID方法代码示例

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


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

示例1: getFacebookHTML

    function getFacebookHTML($showimages = false)
    {
        global $wgParser, $wgServer;
        $feeds = FeaturedArticles::getFeaturedArticles(1);
        $html = "<fb:title>The How-to Article of the Day</fb:title>\n\t\t\t\t<fb:subtitle><a href='http://www.wikihow.com'>from wikiHow</a></fb:subtitle>\n\t\t";
        $now = time();
        $dbr = wfGetDB(DB_SLAVE);
        foreach ($feeds as $f) {
            $url = $f[0];
            $d = $f[1];
            if ($d > $now) {
                continue;
            }
            $url = str_replace("http://www.wikihow.com/", "", $url);
            $url = str_replace("{$wgServer}/", "", $url);
            $title = Title::newFromURL(urldecode($url));
            // get last safe id
            $res = $dbr->select('revision', array('rev_user', 'rev_id', 'rev_user_text'), array('rev_page' => $title->getArticleId(), 'rev_user>0'), "wfGetFacebookHTML", array('ORDER BY' => 'rev_id desc'));
            $rev_id = 0;
            while ($row = $dbr->fetchObject($res)) {
                $num_edits = $dbr->selectField('revision', 'count(*)', array("rev_user={$row->rev_user}"));
                if ($num_edits > 300) {
                    $rev_id = $row->rev_id;
                    break;
                }
            }
            $dbr->freeResult($res);
            $revision = null;
            if ($rev_id > 0) {
                $revision = Revision::newFromID($rev_id);
            } else {
                $revision = Revision::newFromTitle($title);
            }
            $summary = Article::getSection($revision->getText(), 0);
            $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary);
            if (!$showimages) {
                $summary = preg_replace("/\\[\\[Image[^\\]]*\\]\\]/", "", $summary);
            }
            // strip images
            $output = $wgParser->parse($summary, $title, new ParserOptions());
            $summary = strip_tags($output->getText(), '<img>');
            $img = "";
            $style = 'style="float:right;margin-left:10px;margin-bottom:10px;"';
            if (strpos($summary, "<img") !== false && $showimages) {
                $re = '/<img[^>]*>/';
                preg_match_all($re, $summary, $matches);
                $summary = preg_replace($re, '', $summary);
                $img = $matches[0][0];
                preg_match_all('/width="[0-9]*"/', $img, $matches);
                $width = 200;
                if (sizeof($matches[0]) > 0) {
                    $s_width = str_replace('width=', '', $matches[0][0]);
                    $s_width = str_replace('"', '', $s_width);
                    $s_width = intval($s_width);
                    if ($s_width < $width) {
                        $width = $s_width;
                    }
                }
                $src = "";
                preg_match_all('/src="[^"]*"/', $img, $matches);
                if (sizeof($matches[0]) > 0) {
                    $src = str_replace("src=", "", $matches[0][0]);
                    $src = str_replace('"', "", $src);
                    if (strpos($src, "http://www.wikihow.com") === false) {
                        $src = "http://www.wikihow.com" . $src;
                    }
                }
                $img = "<img src=\"{$src}\" {$style} width=\"{$width}\">";
            } else {
                $img = "<img src=\"http://www.wikihow.com/skins/WikiHow/wikiHow.gif\" {$style} width=\"100\"/>";
            }
            $html .= "<p style=\"font-size:1.2em;margin:2px 0;\"><a href='{$title->getFullURL()}' style=\"font-weight:bold\">" . wfMsg('howto', $title->getText()) . '</a></p>';
            $html .= "<p>\n\t\t\t\t{$img} \n\t\t\t\t{$summary}\n\t\t\t\t</p>\n\t\t\t\t<p><a href='{$title->getFullURL()}'>Read more...</a></p>";
            $html .= '<table style="clear:both;margin:0 auto;"><tr><td>Do you want to do this? |&nbsp;
				</td><td >' . "<fb:share-button class='url' href='{$title->getFullURL()}'/> </td></tr></table>";
            break;
        }
        $html .= '<fb:if-is-own-profile>&nbsp;<fb:else><br/><div style="text-align:right;"><a href="http://apps.facebook.com/howtooftheday">Put this on my profile</a></div></fb:else></fb:if-is-own-profile>';
        return $html;
    }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:80,代码来源:FacebookPage.body.php

示例2: execute

 public function execute()
 {
     // The data is hot but user-dependent, like page views, so we set vary cookies
     $this->getMain()->setCacheMode('anon-public-user-private');
     // Get parameters
     $params = $this->extractRequestParams();
     $text = $params['text'];
     $title = $params['title'];
     $page = $params['page'];
     $pageid = $params['pageid'];
     $oldid = $params['oldid'];
     $model = $params['contentmodel'];
     $format = $params['contentformat'];
     if (!is_null($page) && (!is_null($text) || $title != 'API')) {
         $this->dieUsage('The page parameter cannot be used together with the text and title parameters', 'params');
     }
     $prop = array_flip($params['prop']);
     if (isset($params['section'])) {
         $this->section = $params['section'];
     } else {
         $this->section = false;
     }
     // The parser needs $wgTitle to be set, apparently the
     // $title parameter in Parser::parse isn't enough *sigh*
     // TODO: Does this still need $wgTitle?
     global $wgParser, $wgTitle;
     // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang breaks
     $oldLang = null;
     if (isset($params['uselang']) && $params['uselang'] != $this->getContext()->getLanguage()->getCode()) {
         $oldLang = $this->getContext()->getLanguage();
         // Backup language
         $this->getContext()->setLanguage(Language::factory($params['uselang']));
     }
     $redirValues = null;
     // Return result
     $result = $this->getResult();
     if (!is_null($oldid) || !is_null($pageid) || !is_null($page)) {
         if (!is_null($oldid)) {
             // Don't use the parser cache
             $rev = Revision::newFromID($oldid);
             if (!$rev) {
                 $this->dieUsage("There is no revision ID {$oldid}", 'missingrev');
             }
             if (!$rev->userCan(Revision::DELETED_TEXT, $this->getUser())) {
                 $this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied');
             }
             $titleObj = $rev->getTitle();
             $wgTitle = $titleObj;
             $pageObj = WikiPage::factory($titleObj);
             $popts = $pageObj->makeParserOptions($this->getContext());
             $popts->enableLimitReport(!$params['disablepp']);
             // If for some reason the "oldid" is actually the current revision, it may be cached
             if ($rev->isCurrent()) {
                 // May get from/save to parser cache
                 $p_result = $this->getParsedContent($pageObj, $popts, $pageid, isset($prop['wikitext']));
             } else {
                 // This is an old revision, so get the text differently
                 $this->content = $rev->getContent(Revision::FOR_THIS_USER, $this->getUser());
                 if ($this->section !== false) {
                     $this->content = $this->getSectionContent($this->content, 'r' . $rev->getId());
                 }
                 // Should we save old revision parses to the parser cache?
                 $p_result = $this->content->getParserOutput($titleObj, $rev->getId(), $popts);
             }
         } else {
             // Not $oldid, but $pageid or $page
             if ($params['redirects']) {
                 $reqParams = array('action' => 'query', 'redirects' => '');
                 if (!is_null($pageid)) {
                     $reqParams['pageids'] = $pageid;
                 } else {
                     // $page
                     $reqParams['titles'] = $page;
                 }
                 $req = new FauxRequest($reqParams);
                 $main = new ApiMain($req);
                 $main->execute();
                 $data = $main->getResultData();
                 $redirValues = isset($data['query']['redirects']) ? $data['query']['redirects'] : array();
                 $to = $page;
                 foreach ((array) $redirValues as $r) {
                     $to = $r['to'];
                 }
                 $pageParams = array('title' => $to);
             } elseif (!is_null($pageid)) {
                 $pageParams = array('pageid' => $pageid);
             } else {
                 // $page
                 $pageParams = array('title' => $page);
             }
             $pageObj = $this->getTitleOrPageId($pageParams, 'fromdb');
             $titleObj = $pageObj->getTitle();
             if (!$titleObj || !$titleObj->exists()) {
                 $this->dieUsage("The page you specified doesn't exist", 'missingtitle');
             }
             $wgTitle = $titleObj;
             if (isset($prop['revid'])) {
                 $oldid = $pageObj->getLatest();
             }
             $popts = $pageObj->makeParserOptions($this->getContext());
//.........这里部分代码省略.........
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:101,代码来源:ApiParse.php

示例3: execute

 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if (is_null($params['text']) && is_null($params['appendtext']) && is_null($params['prependtext']) && $params['undo'] == 0) {
         $this->dieUsageMsg(array('missingtext'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj || $titleObj->isExternal()) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     if ($params['redirect']) {
         if ($titleObj->isRedirect()) {
             $oldTitle = $titleObj;
             $titles = Title::newFromRedirectArray(Revision::newFromTitle($oldTitle)->getText(Revision::FOR_THIS_USER));
             $redirValues = array();
             foreach ($titles as $id => $newTitle) {
                 if (!isset($titles[$id - 1])) {
                     $titles[$id - 1] = $oldTitle;
                 }
                 $redirValues[] = array('from' => $titles[$id - 1]->getPrefixedText(), 'to' => $newTitle->getPrefixedText());
                 $titleObj = $newTitle;
             }
             $this->getResult()->setIndexedTagName($redirValues, 'r');
             $this->getResult()->addValue(null, 'redirects', $redirValues);
         }
     }
     // Some functions depend on $wgTitle == $ep->mTitle
     global $wgTitle;
     $wgTitle = $titleObj;
     if ($params['createonly'] && $titleObj->exists()) {
         $this->dieUsageMsg(array('createonly-exists'));
     }
     if ($params['nocreate'] && !$titleObj->exists()) {
         $this->dieUsageMsg(array('nocreate-missing'));
     }
     // Now let's check whether we're even allowed to do this
     $errors = $titleObj->getUserPermissionsErrors('edit', $wgUser);
     if (!$titleObj->exists()) {
         $errors = array_merge($errors, $titleObj->getUserPermissionsErrors('create', $wgUser));
     }
     if (count($errors)) {
         $this->dieUsageMsg($errors[0]);
     }
     $articleObj = new Article($titleObj);
     $toMD5 = $params['text'];
     if (!is_null($params['appendtext']) || !is_null($params['prependtext'])) {
         // For non-existent pages, Article::getContent()
         // returns an interface message rather than ''
         // We do want getContent()'s behavior for non-existent
         // MediaWiki: pages, though
         if ($articleObj->getID() == 0 && $titleObj->getNamespace() != NS_MEDIAWIKI) {
             $content = '';
         } else {
             $content = $articleObj->getContent();
         }
         if (!is_null($params['section'])) {
             // Process the content for section edits
             global $wgParser;
             $section = intval($params['section']);
             $content = $wgParser->getSection($content, $section, false);
             if ($content === false) {
                 $this->dieUsage("There is no section {$section}.", 'nosuchsection');
             }
         }
         $params['text'] = $params['prependtext'] . $content . $params['appendtext'];
         $toMD5 = $params['prependtext'] . $params['appendtext'];
     }
     if ($params['undo'] > 0) {
         if ($params['undoafter'] > 0) {
             if ($params['undo'] < $params['undoafter']) {
                 list($params['undo'], $params['undoafter']) = array($params['undoafter'], $params['undo']);
             }
             $undoafterRev = Revision::newFromID($params['undoafter']);
         }
         $undoRev = Revision::newFromID($params['undo']);
         if (is_null($undoRev) || $undoRev->isDeleted(Revision::DELETED_TEXT)) {
             $this->dieUsageMsg(array('nosuchrevid', $params['undo']));
         }
         if ($params['undoafter'] == 0) {
             $undoafterRev = $undoRev->getPrevious();
         }
         if (is_null($undoafterRev) || $undoafterRev->isDeleted(Revision::DELETED_TEXT)) {
             $this->dieUsageMsg(array('nosuchrevid', $params['undoafter']));
         }
         if ($undoRev->getPage() != $articleObj->getID()) {
             $this->dieUsageMsg(array('revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText()));
         }
         if ($undoafterRev->getPage() != $articleObj->getID()) {
             $this->dieUsageMsg(array('revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText()));
         }
         $newtext = $articleObj->getUndoText($undoRev, $undoafterRev);
         if ($newtext === false) {
             $this->dieUsageMsg(array('undo-failure'));
         }
         $params['text'] = $newtext;
         // If no summary was given and we only undid one rev,
         // use an autosummary
         if (is_null($params['summary']) && $titleObj->getNextRevisionID($undoafterRev->getID()) == $params['undo']) {
             $params['summary'] = wfMsgForContent('undo-summary', $params['undo'], $undoRev->getUserText());
//.........这里部分代码省略.........
开发者ID:GodelDesign,项目名称:Godel,代码行数:101,代码来源:ApiEditPage.php

示例4: execute

 public function execute()
 {
     // The data is hot but user-dependent, like page views, so we set vary cookies
     $this->getMain()->setCacheMode('anon-public-user-private');
     // Get parameters
     $params = $this->extractRequestParams();
     $text = $params['text'];
     $title = $params['title'];
     $page = $params['page'];
     $oldid = $params['oldid'];
     if (!is_null($page) && (!is_null($text) || $title != "API")) {
         $this->dieUsage("The page parameter cannot be used together with the text and title parameters", 'params');
     }
     $prop = array_flip($params['prop']);
     $revid = false;
     // The parser needs $wgTitle to be set, apparently the
     // $title parameter in Parser::parse isn't enough *sigh*
     global $wgParser, $wgUser, $wgTitle, $wgEnableParserCache;
     $popts = new ParserOptions();
     $popts->setTidy(true);
     $popts->enableLimitReport();
     $redirValues = null;
     if (!is_null($oldid) || !is_null($page)) {
         if (!is_null($oldid)) {
             // Don't use the parser cache
             $rev = Revision::newFromID($oldid);
             if (!$rev) {
                 $this->dieUsage("There is no revision ID {$oldid}", 'missingrev');
             }
             if (!$rev->userCan(Revision::DELETED_TEXT)) {
                 $this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied');
             }
             $text = $rev->getText(Revision::FOR_THIS_USER);
             $titleObj = $rev->getTitle();
             $wgTitle = $titleObj;
             $p_result = $wgParser->parse($text, $titleObj, $popts);
         } else {
             if ($params['redirects']) {
                 $req = new FauxRequest(array('action' => 'query', 'redirects' => '', 'titles' => $page));
                 $main = new ApiMain($req);
                 $main->execute();
                 $data = $main->getResultData();
                 $redirValues = @$data['query']['redirects'];
                 $to = $page;
                 foreach ((array) $redirValues as $r) {
                     $to = $r['to'];
                 }
             } else {
                 $to = $page;
             }
             $titleObj = Title::newFromText($to);
             if (!$titleObj) {
                 $this->dieUsage("The page you specified doesn't exist", 'missingtitle');
             }
             $articleObj = new Article($titleObj);
             if (isset($prop['revid'])) {
                 $oldid = $articleObj->getRevIdFetched();
             }
             // Try the parser cache first
             $p_result = false;
             $pcache = ParserCache::singleton();
             if ($wgEnableParserCache) {
                 $p_result = $pcache->get($articleObj, $wgUser);
             }
             if (!$p_result) {
                 $p_result = $wgParser->parse($articleObj->getContent(), $titleObj, $popts);
                 if ($wgEnableParserCache) {
                     $pcache->save($p_result, $articleObj, $popts);
                 }
             }
         }
     } else {
         $titleObj = Title::newFromText($title);
         if (!$titleObj) {
             $titleObj = Title::newFromText("API");
         }
         $wgTitle = $titleObj;
         if ($params['pst'] || $params['onlypst']) {
             $text = $wgParser->preSaveTransform($text, $titleObj, $wgUser, $popts);
         }
         if ($params['onlypst']) {
             // Build a result and bail out
             $result_array['text'] = array();
             $this->getResult()->setContent($result_array['text'], $text);
             $this->getResult()->addValue(null, $this->getModuleName(), $result_array);
             return;
         }
         $p_result = $wgParser->parse($text, $titleObj, $popts);
     }
     // Return result
     $result = $this->getResult();
     $result_array = array();
     if ($params['redirects'] && !is_null($redirValues)) {
         $result_array['redirects'] = $redirValues;
     }
     if (isset($prop['text'])) {
         $result_array['text'] = array();
         $result->setContent($result_array['text'], $p_result->getText());
     }
     if (!is_null($params['summary'])) {
//.........这里部分代码省略.........
开发者ID:rocLv,项目名称:conference,代码行数:101,代码来源:ApiParse.php

示例5: parseTitleOrRevID

 /**
  * Parse what can be a revision ID or an article name
  * @param $str Mixed: revision ID or an article name
  * @return Title or Revision object, or NULL
  */
 private function parseTitleOrRevID($str)
 {
     $retval = false;
     if (is_numeric($str)) {
         $retval = Revision::newFromID($str);
     }
     if (!$retval) {
         $retval = Title::newFromURL($str);
     }
     return $retval;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:16,代码来源:ChangeAuthor.body.php

示例6: execute

 public function execute()
 {
     $params = $this->extractRequestParams(false);
     // If any of those parameters are used, work in 'enumeration' mode.
     // Enum mode can only be used when exactly one page is provided.
     // Enumerating revisions on multiple pages make it extremely
     // difficult to manage continuations and require additional SQL indexes
     $enumRevMode = !is_null($params['user']) || !is_null($params['excludeuser']) || !is_null($params['limit']) || !is_null($params['startid']) || !is_null($params['endid']) || $params['dir'] === 'newer' || !is_null($params['start']) || !is_null($params['end']);
     $pageSet = $this->getPageSet();
     $pageCount = $pageSet->getGoodTitleCount();
     $revCount = $pageSet->getRevisionCount();
     // Optimization -- nothing to do
     if ($revCount === 0 && $pageCount === 0) {
         return;
     }
     if ($revCount > 0 && $enumRevMode) {
         $this->dieUsage('The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids');
     }
     if ($pageCount > 1 && $enumRevMode) {
         $this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.', 'multpages');
     }
     if (!is_null($params['difftotext'])) {
         $this->difftotext = $params['difftotext'];
     } elseif (!is_null($params['diffto'])) {
         if ($params['diffto'] == 'cur') {
             $params['diffto'] = 0;
         }
         if ((!ctype_digit($params['diffto']) || $params['diffto'] < 0) && $params['diffto'] != 'prev' && $params['diffto'] != 'next') {
             $this->dieUsage('rvdiffto must be set to a non-negative number, "prev", "next" or "cur"', 'diffto');
         }
         // Check whether the revision exists and is readable,
         // DifferenceEngine returns a rather ambiguous empty
         // string if that's not the case
         if ($params['diffto'] != 0) {
             $difftoRev = Revision::newFromID($params['diffto']);
             if (!$difftoRev) {
                 $this->dieUsageMsg(array('nosuchrevid', $params['diffto']));
             }
             if ($difftoRev->isDeleted(Revision::DELETED_TEXT)) {
                 $this->setWarning("Couldn't diff to r{$difftoRev->getID()}: content is hidden");
                 $params['diffto'] = null;
             }
         }
         $this->diffto = $params['diffto'];
     }
     $db = $this->getDB();
     $this->addTables('page');
     $this->addFields(Revision::selectFields());
     $this->addWhere('page_id = rev_page');
     $prop = array_flip($params['prop']);
     // Optional fields
     $this->fld_ids = isset($prop['ids']);
     // $this->addFieldsIf('rev_text_id', $this->fld_ids); // should this be exposed?
     $this->fld_flags = isset($prop['flags']);
     $this->fld_timestamp = isset($prop['timestamp']);
     $this->fld_comment = isset($prop['comment']);
     $this->fld_parsedcomment = isset($prop['parsedcomment']);
     $this->fld_size = isset($prop['size']);
     $this->fld_sha1 = isset($prop['sha1']);
     $this->fld_userid = isset($prop['userid']);
     $this->fld_user = isset($prop['user']);
     $this->token = $params['token'];
     // Possible indexes used
     $index = array();
     $userMax = $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
     $botMax = $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;
     $limit = $params['limit'];
     if ($limit == 'max') {
         $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
         $this->getResult()->setParsedLimit($this->getModuleName(), $limit);
     }
     if (!is_null($this->token) || $pageCount > 0) {
         $this->addFields(Revision::selectPageFields());
     }
     if (isset($prop['tags'])) {
         $this->fld_tags = true;
         $this->addTables('tag_summary');
         $this->addJoinConds(array('tag_summary' => array('LEFT JOIN', array('rev_id=ts_rev_id'))));
         $this->addFields('ts_tags');
     }
     if (!is_null($params['tag'])) {
         $this->addTables('change_tag');
         $this->addJoinConds(array('change_tag' => array('INNER JOIN', array('rev_id=ct_rev_id'))));
         $this->addWhereFld('ct_tag', $params['tag']);
         global $wgOldChangeTagsIndex;
         $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
     }
     if (isset($prop['content']) || !is_null($this->difftotext)) {
         // For each page we will request, the user must have read rights for that page
         foreach ($pageSet->getGoodTitles() as $title) {
             if (!$title->userCan('read')) {
                 $this->dieUsage('The current user is not allowed to read ' . $title->getPrefixedText(), 'accessdenied');
             }
         }
         $this->addTables('text');
         $this->addWhere('rev_text_id=old_id');
         $this->addFields('old_id');
         $this->addFields(Revision::selectTextFields());
         $this->fld_content = isset($prop['content']);
         $this->expandTemplates = $params['expandtemplates'];
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:ApiQueryRevisions.php

示例7: execute

 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     if (!in_array('sysop', $wgUser->getGroups())) {
         $wgOut->setArticleRelated(false);
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     if ($target) {
         if (preg_match("@[^0-9]@", $target)) {
             $t = Title::newFromURL($target);
         } else {
             $r = Revision::newFromID($target);
             if ($wgRequest->getVal('popup')) {
                 $wgOut->setArticleBodyOnly(true);
                 $wgOut->addHTML("<style type='text/css'>\n\t\t\t\t\t\ttable.diff  {\n\t\t\t\t\t\t\tmargin-left: auto; margin-right: auto;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttable.diff td {\n\t\t\t\t\t\t\tmax-width: 400px;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>");
             }
             $wgOut->addHTML("Revid: {$r->mId}\n");
             $d = self::getDiffToMeasure($r);
             $de = new DifferenceEngine($r->mTitle, $d['revlo']->mId, $d['revhi']->mId);
             self::getPoints($r, $d, $de, true);
             if (!$d['revlo']) {
                 $de->mOldRev = null;
                 $de->mOldid = null;
             }
             $de->showDiffPage();
             return;
         }
     } else {
         $rp = new RandomPage();
         $t = $rp->getRandomTitle();
     }
     $wgOut->addHTML("<script type='text/javascript'>\nfunction getPoints(rev) {\n\t\$('#img-box').load('/Special:Points/' + rev + '?popup=true', function() {\n\t\t\t\$('#img-box').dialog({\n\t\t\t   width: 750,\n\t\t\t   modal: true,\n\t\t\t\ttitle: 'Points', \n\t\t\t   show: 'slide',\n\t\t\t\tcloseOnEscape: true,\n\t\t\t\tposition: 'center'\n\t\t\t});\n\t});\n\treturn false;\n}\n</script>\n");
     // get the groups of edits
     $group = self::getEditGroups($t);
     $wgOut->addHTML("Title: <a href='{$t->getFullURL()}?action=history' target='new'>{$t->getFullText()}</a><br/><br/>");
     $wgOut->addHTML("<table width='100%'><tr><td><u>User</u></td><td><u># Edits</u></td>");
     $wgOut->addHTML("<td><u>Date</u></td><td><u>Points</u></td></tr>");
     foreach ($group as $g) {
         $r = Revision::newFromID($g['max_revid']);
         $d = self::getDiffToMeasure($r);
         $de = new DifferenceEngine($r->mTitle, $d['revlo']->mId, $d['revhi']->mId);
         $points = self::getPoints($r, $d, $de);
         $date = date("Y-m-d", wfTimestamp(TS_UNIX, $g['max_revtimestamp']));
         $wgOut->addHTML("<tr><td>{$g['user_text']}</td><td>{$g['edits']}</td><td>{$date}</td>");
         $wgOut->addHTML("<td><a href='#' onclick='return getPoints({$g['max_revid']});'>{$points}</a></td></tr>");
     }
     $wgOut->addHTML("</table>");
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:51,代码来源:Points.body.php

示例8: execute

 public function execute()
 {
     // The data is hot but user-dependent, like page views, so we set vary cookies
     $this->getMain()->setCacheMode('anon-public-user-private');
     // Get parameters
     $params = $this->extractRequestParams();
     $text = $params['text'];
     $title = $params['title'];
     $page = $params['page'];
     $pageid = $params['pageid'];
     $oldid = $params['oldid'];
     if (!is_null($page) && (!is_null($text) || $title != 'API')) {
         $this->dieUsage('The page parameter cannot be used together with the text and title parameters', 'params');
     }
     $prop = array_flip($params['prop']);
     if (isset($params['section'])) {
         $this->section = $params['section'];
     } else {
         $this->section = false;
     }
     // The parser needs $wgTitle to be set, apparently the
     // $title parameter in Parser::parse isn't enough *sigh*
     // TODO: Does this still need $wgTitle?
     global $wgParser, $wgTitle, $wgLang;
     // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang breaks
     $oldLang = null;
     if (isset($params['uselang']) && $params['uselang'] != $wgLang->getCode()) {
         $oldLang = $wgLang;
         // Backup wgLang
         $wgLang = Language::factory($params['uselang']);
     }
     $popts = ParserOptions::newFromContext($this->getContext());
     $popts->setTidy(true);
     $popts->enableLimitReport(!$params['disablepp']);
     $redirValues = null;
     // Return result
     $result = $this->getResult();
     if (!is_null($oldid) || !is_null($pageid) || !is_null($page)) {
         if (!is_null($oldid)) {
             // Don't use the parser cache
             $rev = Revision::newFromID($oldid);
             if (!$rev) {
                 $this->dieUsage("There is no revision ID {$oldid}", 'missingrev');
             }
             if (!$rev->userCan(Revision::DELETED_TEXT, $this->getUser())) {
                 $this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied');
             }
             $titleObj = $rev->getTitle();
             $wgTitle = $titleObj;
             // If for some reason the "oldid" is actually the current revision, it may be cached
             if ($titleObj->getLatestRevID() === intval($oldid)) {
                 // May get from/save to parser cache
                 $p_result = $this->getParsedSectionOrText($titleObj, $popts, $pageid, isset($prop['wikitext']));
             } else {
                 // This is an old revision, so get the text differently
                 $this->text = $rev->getText(Revision::FOR_THIS_USER, $this->getUser());
                 if ($this->section !== false) {
                     $this->text = $this->getSectionText($this->text, 'r' . $rev->getId());
                 }
                 // Should we save old revision parses to the parser cache?
                 $p_result = $wgParser->parse($this->text, $titleObj, $popts);
             }
         } else {
             // Not $oldid, but $pageid or $page
             if ($params['redirects']) {
                 $reqParams = array('action' => 'query', 'redirects' => '');
                 if (!is_null($pageid)) {
                     $reqParams['pageids'] = $pageid;
                 } else {
                     // $page
                     $reqParams['titles'] = $page;
                 }
                 $req = new FauxRequest($reqParams);
                 $main = new ApiMain($req);
                 $main->execute();
                 $data = $main->getResultData();
                 $redirValues = isset($data['query']['redirects']) ? $data['query']['redirects'] : array();
                 $to = $page;
                 foreach ((array) $redirValues as $r) {
                     $to = $r['to'];
                 }
                 $titleObj = Title::newFromText($to);
             } else {
                 if (!is_null($pageid)) {
                     $reqParams['pageids'] = $pageid;
                     $titleObj = Title::newFromID($pageid);
                 } else {
                     // $page
                     $to = $page;
                     $titleObj = Title::newFromText($to);
                 }
             }
             if (!is_null($pageid)) {
                 if (!$titleObj) {
                     // Still throw nosuchpageid error if pageid was provided
                     $this->dieUsageMsg(array('nosuchpageid', $pageid));
                 }
             } elseif (!$titleObj || !$titleObj->exists()) {
                 $this->dieUsage("The page you specified doesn't exist", 'missingtitle');
             }
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:media-wiki-law,代码行数:101,代码来源:ApiParse.php

示例9: parseTitleOrRevID

 private function parseTitleOrRevID($str)
 {
     // Parse what can be a revision ID or an article name
     // Returns: Title or Revision object, or NULL
     $retval = false;
     if (is_numeric($str)) {
         $retval = Revision::newFromID($str);
     }
     if (!$retval) {
         $retval = Title::newFromURL($str);
     }
     return $retval;
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:13,代码来源:ChangeAuthor.body.php

示例10: execute


//.........这里部分代码省略.........
             $mode = $contentHandler->getModelID();
             $this->dieUsage("Can't append to pages using content model {$mode}", 'appendnotsupported');
         }
         if (!is_null($params['section'])) {
             if (!$contentHandler->supportsSections()) {
                 $modelName = $contentHandler->getModelID();
                 $this->dieUsage("Sections are not supported for this content model: {$modelName}.", 'sectionsnotsupported');
             }
             if ($params['section'] == 'new') {
                 // DWIM if they're trying to prepend/append to a new section.
                 $content = null;
             } else {
                 // Process the content for section edits
                 $section = $params['section'];
                 $content = $content->getSection($section);
                 if (!$content) {
                     $this->dieUsage("There is no section {$section}.", 'nosuchsection');
                 }
             }
         }
         if (!$content) {
             $text = '';
         } else {
             $text = $content->serialize($contentFormat);
         }
         $params['text'] = $params['prependtext'] . $text . $params['appendtext'];
         $toMD5 = $params['prependtext'] . $params['appendtext'];
     }
     if ($params['undo'] > 0) {
         if ($params['undoafter'] > 0) {
             if ($params['undo'] < $params['undoafter']) {
                 list($params['undo'], $params['undoafter']) = array($params['undoafter'], $params['undo']);
             }
             $undoafterRev = Revision::newFromID($params['undoafter']);
         }
         $undoRev = Revision::newFromID($params['undo']);
         if (is_null($undoRev) || $undoRev->isDeleted(Revision::DELETED_TEXT)) {
             $this->dieUsageMsg(array('nosuchrevid', $params['undo']));
         }
         if ($params['undoafter'] == 0) {
             $undoafterRev = $undoRev->getPrevious();
         }
         if (is_null($undoafterRev) || $undoafterRev->isDeleted(Revision::DELETED_TEXT)) {
             $this->dieUsageMsg(array('nosuchrevid', $params['undoafter']));
         }
         if ($undoRev->getPage() != $pageObj->getID()) {
             $this->dieUsageMsg(array('revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText()));
         }
         if ($undoafterRev->getPage() != $pageObj->getID()) {
             $this->dieUsageMsg(array('revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText()));
         }
         $newContent = $contentHandler->getUndoContent($pageObj->getRevision(), $undoRev, $undoafterRev);
         if (!$newContent) {
             $this->dieUsageMsg('undo-failure');
         }
         $params['text'] = $newContent->serialize($params['contentformat']);
         // If no summary was given and we only undid one rev,
         // use an autosummary
         if (is_null($params['summary']) && $titleObj->getNextRevisionID($undoafterRev->getID()) == $params['undo']) {
             $params['summary'] = wfMessage('undo-summary')->params($params['undo'], $undoRev->getUserText())->inContentLanguage()->text();
         }
     }
     // See if the MD5 hash checks out
     if (!is_null($params['md5']) && md5($toMD5) !== $params['md5']) {
         $this->dieUsageMsg('hashcheckfailed');
     }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:67,代码来源:ApiEditPage.php

示例11: getNotificationTypes

 /**
  * Handler for EchoGetNotificationTypes hook, Adjust the notify types (e.g. web, email) which
  * are applicable to this event and user based on various user options. In other words, allow
  * certain non-echo user options to override the echo notification options.
  * @param $user User
  * @param $event EchoEvent
  * @param $notifyTypes
  * @return bool
  */
 public static function getNotificationTypes($user, $event, &$notifyTypes)
 {
     $type = $event->getType();
     if (!$user->getOption('enotifminoredits')) {
         $extra = $event->getExtra();
         if (!empty($extra['revid'])) {
             $rev = Revision::newFromID($extra['revid']);
             if ($rev->isMinor()) {
                 $notifyTypes = array_diff($notifyTypes, array('email'));
             }
         }
     }
     return true;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:23,代码来源:Hooks.php

示例12: array

    $dbw->update("imageadder", array("imageadder_hasimage" => 0, "imageadder_skip" => 0), array("imageadder_page" => $t->getArticleID()));
    // last revision comment?
    $row = $dbr->selectRow('revision', '*', array('rev_page' => $t->getArticleID()), "fix intro adder", array("ORDER BY" => "rev_id desc", "LIMIT" => 1));
    if ($row->rev_comment == "Added Image using ImageAdder Tool") {
        $a = new Article($t);
        $a->commitRollback($row->rev_user_text, "Rolling back bug", false, &$results);
        echo "{$t->getFullURL()} rolled back \n";
        continue;
    }
    // how many sections?
    $r = Revision::newFromTitle($t);
    if (!$r) {
        echo "Can't make revision out of {$row->rc_title}\n";
        continue;
    }
    $text = $r->getText();
    preg_match_all("@^==.*==@m", $text, $matches);
    if (sizeof($matches[0]) == 0) {
        echo "{$t->getFullURL()} has no sections\n";
        // get the last edit
        $lastgood_rev = $dbr->selectRow("revision", "*", array('rev_page' => $t->getArticleID(), 'rev_comment != "Added Image using ImageAdder Tool"', "rev_id < {$row->rev_id}"), "fix intro adder", array("ORDER BY" => "rev_id desc", "LIMIT" => 1));
        $rev = Revision::newFromID($lastgood_rev->rev_id);
        if (!$rev) {
            // ?
            continue;
        }
        $text = $rev->getText();
        $a = new Article($t);
        $a->doEdit($text, "Rolling back bug going back to rev {$lastgood_rev->rev_id} by {$lastgood_rev->rev_user_text}");
    }
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:31,代码来源:fix_intro_adder_bug.php

示例13: getLastRevisionText

 function getLastRevisionText()
 {
     $lastrev = $this->getLastRevID();
     $r = Revision::newFromID($lastrev);
     if (!$r) {
         return null;
     }
     return $r->getText();
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:9,代码来源:QC.body.php

示例14: statusInterface

	protected function statusInterface() {
		global $wgOut, $wgUser, $wgPremoderationStrict;
		
		$params = $this->mParams;
		if( !isset( $params['id'] ) ) {
			$wgOut->setPageTitle( wfMsg( 'premoderation-manager-invalidaction' ) );
			$wgOut->addWikiMsg( 'premoderation-invalidaction' );
			return;		
		}
		
		$id = intval( $params['id'] );
		$dbr = wfGetDB( DB_SLAVE );
		$res = $dbr->select(
			'pm_queue',
			'*',
			"pmq_id = '$id'",
			__METHOD__,
			array( 'LIMIT' => 1 )
		);
		$row = $dbr->fetchRow( $res );
		if( !$row ) {
			$wgOut->setPageTitle( wfMsg( 'premoderation-manager-invalidaction' ) );
			$wgOut->addWikiMsg( 'premoderation-notexists-id' );
			return;
		}
		
		$wgOut->setPageTitle( wfMsg( 'premoderation-manager-status' ) );
		$wgOut->addWikiMsg( 'premoderation-status-intro' );
		
		$wgOut->addHTML( '<h2>' . wfMsg( 'premoderation-status-info' ) . '</h2>' .
			$this->getListTableHeader( 'status' ) . $this->formatListTableRow( $row ) .
			Xml::closeElement( 'table' ) );
		
		if( $wgUser->isAllowed( 'premoderation-viewip' ) ) {
			$wgOut->addWikiMsg( 'premoderation-private-ip', $row['pmq_ip'] );
		}
		
		$rev = Revision::newFromID( $row['pmq_page_last_id'] );
		$diff = new DifferenceEngine();
		$diff->showDiffStyle();
		$formattedDiff = $diff->generateDiffBody(
			isset( $rev ) ? $rev->getText() : '', $row['pmq_text']
		);
		
		$wgOut->addHTML( '<h2>' . wfMsg( 'premoderation-diff-h2' ) . '</h2>' .
			"<table class='mw-abusefilter-diff-multiline'><col class='diff-marker' />" .
			"<col class='diff-content' /><col class='diff-marker' /><col class='diff-content' />" .
			"<tbody>" . $formattedDiff . "</tbody></table>" );
		
		if( $row['pmq_status'] == 'approved' ) {
			return;
		}
		
		$externalConflicts = $this->checkExternalConflicts( $row['pmq_page_last_id'],
			$row['pmq_page_ns'], $row['pmq_page_title'] );
		if( $externalConflicts ) {
			$wgOut->addHTML( '<h2>' . wfMsg( 'premoderation-external-conflicts-h2' ) . '</h2>' );
			if( $wgPremoderationStrict ) {
				$wgOut->addWikiMsg( 'premoderation-error-externals' );
				return;			
			}
			$wgOut->addWikiMsg( 'premoderation-external-edits' );
		}
		
		$this->checkInternalConflicts( $dbr, $id, $row['pmq_page_ns'], $row['pmq_page_title'] );
		
		$final = Xml::fieldset( wfMsg( 'premoderation-status-fieldset' ) ) .
			Xml::openElement( 'form', array( 'id' => 'prem-status-form', 'method' => 'post' ) ) .
			$this->getStatusForm( $row['pmq_status'] ) .
			'<input type="hidden" name="id" value="' . $id . '" />' .
			Xml::closeElement( 'form' ) . Xml::closeElement( 'fieldset' );
			
		$wgOut->addHTML( $final );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:74,代码来源:SpecialPremoderation.php

示例15: execute

 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if (is_null($params['title'])) {
         $this->dieUsageMsg(array('missingparam', 'title'));
     }
     if (is_null($params['xpath'])) {
         $this->dieUsage(array('missingparam', 'xpath'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj || $titleObj->isExternal()) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     // Some functions depend on $wgTitle == $ep->mTitle
     global $wgTitle;
     $wgTitle = $titleObj;
     if ($params['nocreate'] && !$titleObj->exists()) {
         $this->dieUsageMsg(array('nocreate-missing'));
     }
     // Now let's check whether we're even allowed to do this
     $errors = $titleObj->getUserPermissionsErrors('edit', $wgUser);
     if (!$titleObj->exists()) {
         $errors = array_merge($errors, $titleObj->getUserPermissionsErrors('create', $wgUser));
     }
     if (count($errors)) {
         $this->dieUsageMsg($errors[0]);
     }
     $articleObj = new Article($titleObj);
     if (!is_null($params['rid'])) {
         $revObj = Revision::newFromID($params['rid']);
         if (is_null($revObj) || $revObj->isDeleted(Revision::DELETED_TEXT)) {
             $this->dieUsageMsg(array('nosuchrevid', $params['rid']));
         }
         if ($revObj->getPage() != $articleObj->getID()) {
             $this->dieUsageMsg(array('revwrongpage', $revObj->getID(), $titleObj->getPrefixedText()));
         }
         if (!$params['force_update'] && !$revObj->isCurrent()) {
             $this->dieUsage("Page revision id is not current '{$titleObj->getPrefixedText()} ({$params['rid']})'", 'revnotcurrent');
         }
     } else {
         $params['rid'] = 0;
     }
     $verb = $params['verb'];
     $xpath = $params['xpath'];
     try {
         $wom = WOMProcessor::getPageObject($titleObj, $params['rid']);
         $obj_ids = WOMProcessor::getObjIdByXPath2($wom, $xpath);
         $obj_id = null;
         foreach ($obj_ids as $id) {
             if ($id != '') {
                 $obj_id = $id;
                 break;
             }
         }
         if ($obj_id == null) {
             throw new MWException(__METHOD__ . ": object does not found, xpath: {$xpath}");
         }
         if ($verb == 'remove') {
             $wom->removePageObject($obj_id);
         } elseif ($verb == 'removeall') {
             foreach ($obj_ids as $id) {
                 if ($id == '') {
                     continue;
                 }
                 $wom->removePageObject($id);
             }
         } else {
             if (is_null($params['text'])) {
                 $this->dieUsageMsg(array('missingparam', 'text'));
             }
             $toMD5 = $params['text'];
             // See if the MD5 hash checks out
             if (!is_null($params['md5']) && md5($toMD5) !== $params['md5']) {
                 $this->dieUsageMsg(array('hashcheckfailed'));
             }
             $text = $params['text'];
             if ($verb == 'insert') {
                 $text = WOMProcessor::getValidText($text, $wom->getObject($obj_id)->getParent(), $wom);
                 // no need to parse or merge object model but use text
                 $wom->insertPageObject(new WOMTextModel($text), $obj_id);
             } elseif ($verb == 'update') {
                 $text = WOMProcessor::getValidText($text, $wom->getObject($obj_id)->getParent(), $wom);
                 $wom->updatePageObject(new WOMTextModel($text), $obj_id);
             } elseif ($verb == 'append') {
                 $parent = $wom->getObject($obj_id);
                 if (!$parent instanceof WikiObjectModelCollection) {
                     throw new MWException(__METHOD__ . ": Object is not a collection object '{$title} ({$revision_id}) - {$obj_id}'");
                 }
                 $text = WOMProcessor::getValidText($text, $parent, $wom);
                 $wom->appendChildObject(new WOMTextModel($text), $obj_id);
             } elseif ($verb == 'attribute') {
                 $obj = $wom->getObject($obj_id);
                 $kv = explode('=', $text, 2);
                 if (count($kv) != 2) {
                     throw new MWException(__METHOD__ . ": value should be 'key=value' in attribute mode");
                 }
                 $obj->setXMLAttribute(trim($kv[0]), trim($kv[1]));
             }
         }
//.........这里部分代码省略.........
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:WOM_SetObjectModel.php


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