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


PHP Article::getLatest方法代码示例

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


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

示例1: testImplementsCallMagic

 /**
  * @depends testImplementsSetMagic
  */
 function testImplementsCallMagic()
 {
     $this->article->mLatest = 33;
     $this->article->mDataLoaded = true;
     $this->assertEquals(33, $this->article->getLatest(), "Article __call magic");
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:9,代码来源:ArticleTest.php

示例2: setPostEditCookie

 /**
  * Sets post-edit cookie indicating the user just saved a particular revision.
  *
  * This uses a temporary cookie for each revision ID so separate saves will never
  * interfere with each other.
  *
  * The cookie is deleted in the mediawiki.action.view.postEdit JS module after
  * the redirect.  It must be clearable by JavaScript code, so it must not be
  * marked HttpOnly. The JavaScript code converts the cookie to a wgPostEdit config
  * variable.
  *
  * Since WebResponse::setcookie does not allow forcing HttpOnly for a single
  * cookie, we have to use PHP's setcookie() directly.
  *
  * We use a path of '/' since wgCookiePath is not exposed to JS
  *
  * If the variable were set on the server, it would be cached, which is unwanted
  * since the post-edit state should only apply to the load right after the save.
  */
 protected function setPostEditCookie()
 {
     global $wgCookiePrefix, $wgCookieDomain;
     $revisionId = $this->mArticle->getLatest();
     $postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
     setcookie($wgCookiePrefix . $postEditKey, '1', time() + self::POST_EDIT_COOKIE_DURATION, '/', $wgCookieDomain);
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:26,代码来源:EditPage.php

示例3: setPostEditCookie

 /**
  * Sets post-edit cookie indicating the user just saved a particular revision.
  *
  * This uses a temporary cookie for each revision ID so separate saves will never
  * interfere with each other.
  *
  * The cookie is deleted in the mediawiki.action.view.postEdit JS module after
  * the redirect.  It must be clearable by JavaScript code, so it must not be
  * marked HttpOnly. The JavaScript code converts the cookie to a wgPostEdit config
  * variable.
  *
  * If the variable were set on the server, it would be cached, which is unwanted
  * since the post-edit state should only apply to the load right after the save.
  *
  * @param int $statusValue The status value (to check for new article status)
  */
 protected function setPostEditCookie($statusValue)
 {
     $revisionId = $this->mArticle->getLatest();
     $postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
     $val = 'saved';
     if ($statusValue == self::AS_SUCCESS_NEW_ARTICLE) {
         $val = 'created';
     } elseif ($this->oldid) {
         $val = 'restored';
     }
     $response = RequestContext::getMain()->getRequest()->response();
     $response->setcookie($postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, array('httpOnly' => false));
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:29,代码来源:EditPage.php

示例4: parseCollectionLine

 function parseCollectionLine(&$collection, $line, $append)
 {
     $line = trim($line);
     if (!$append && preg_match('/^===\\s*(.*?)\\s*===$/', $line, $match)) {
         $collection['subtitle'] = $match[1];
     } elseif (!$append && preg_match('/^==\\s*(.*?)\\s*==$/', $line, $match)) {
         $collection['title'] = $match[1];
     } elseif (substr($line, 0, 1) == ';') {
         // chapter
         return array('type' => 'chapter', 'title' => trim(substr($line, 1)));
     } elseif (substr($line, 0, 1) == ':') {
         // article
         $articleTitle = trim(substr($line, 1));
         if (preg_match('/^\\[\\[:?(.*?)(\\|(.*?))?\\]\\]$/', $articleTitle, $match)) {
             $articleTitle = $match[1];
             if (isset($match[3])) {
                 $displayTitle = $match[3];
             } else {
                 $displayTitle = null;
             }
             $oldid = -1;
             $currentVersion = 1;
         } elseif (preg_match('/^\\[\\{\\{fullurl:(.*?)\\|oldid=(.*?)\\}\\}\\s+(.*?)\\]$/', $articleTitle, $match)) {
             $articleTitle = $match[1];
             if (isset($match[3])) {
                 $displayTitle = $match[3];
             } else {
                 $displayTitle = null;
             }
             $oldid = $match[2];
             $currentVersion = 0;
         } else {
             return null;
         }
         $articleTitle = Title::newFromText($articleTitle);
         if (!$articleTitle) {
             return null;
         }
         if ($oldid < 0) {
             $article = new Article($articleTitle);
         } else {
             $article = new Article($articleTitle, $oldid);
         }
         if (!$article->exists()) {
             return null;
         }
         $revision = Revision::newFromTitle($articleTitle, $article->getOldID());
         $latest = $article->getLatest();
         $oldid = $article->getOldID();
         if (!$oldid) {
             $oldid = $latest;
         }
         $d = array('type' => 'article', 'content_type' => 'text/x-wiki', 'title' => $articleTitle->getPrefixedText(), 'latest' => $latest, 'revision' => $oldid, 'timestamp' => wfTimestamp(TS_UNIX, $revision->getTimestamp()), 'url' => $articleTitle->getCanonicalURL(), 'currentVersion' => $currentVersion);
         if ($displayTitle) {
             $d['displaytitle'] = $displayTitle;
         }
         return $d;
     }
     return null;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:60,代码来源:Collection.body.php

示例5: wfGetDB

 static function util_ResolveRevSpec($page_title, $page_id = 0, $rev_id = 0)
 {
     global $wgTitle;
     $dbr =& wfGetDB(DB_SLAVE);
     if ($rev_id && !$page_id) {
         $rev = Revision::loadFromId($dbr, $rev_id);
         if ($rev) {
             $page_id = $rev->getPage();
         }
     }
     if ($page_id && !$page_title) {
         $wgTitle = Title::newFromID($page_id);
     }
     if ($page_title) {
         $wgTitle = Title::newFromDBkey($page_title);
     }
     $article = new Article($wgTitle);
     $title_db = $wgTitle->getDBkey();
     $page_id_db = $wgTitle->getArticleID();
     $rev_id_db = $article->getLatest();
     if (!$page_id) {
         $page_id = $page_id_db;
     }
     if (!$rev_id) {
         $rev_id = $rev_id_db;
     }
     if (!$page_title) {
         $page_title = $title_db;
     }
     if ($page_id != $page_id_db) {
         wfWikiTrustWarn(__FILE__ . ":" . __LINE__ . ": mismatched pageId: {$page_id} != {$page_id_db}");
     }
     if ($page_title != $title_db) {
         wfWikiTrustWarn(__FILE__ . ":" . __LINE__ . ": mismatched title: {$page_title} != {$title_db}");
     }
     return array($page_title, $page_id, $rev_id);
 }
开发者ID:xzhao314,项目名称:WikiTrust,代码行数:37,代码来源:WikiTrustBase.php

示例6: setPostEditCookie

 /**
  * Sets post-edit cookie indicating the user just saved a particular revision.
  *
  * This uses a temporary cookie for each revision ID so separate saves will never
  * interfere with each other.
  *
  * The cookie is deleted in the mediawiki.action.view.postEdit JS module after
  * the redirect.  It must be clearable by JavaScript code, so it must not be
  * marked HttpOnly. The JavaScript code converts the cookie to a wgPostEdit config
  * variable.
  *
  * We use a path of '/' since wgCookiePath is not exposed to JS
  *
  * If the variable were set on the server, it would be cached, which is unwanted
  * since the post-edit state should only apply to the load right after the save.
  */
 protected function setPostEditCookie()
 {
     $revisionId = $this->mArticle->getLatest();
     $postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
     $response = RequestContext::getMain()->getRequest()->response();
     $response->setcookie($postEditKey, '1', time() + self::POST_EDIT_COOKIE_DURATION, array('path' => '/', 'httpOnly' => false));
 }
开发者ID:crippsy14,项目名称:orange-smorange,代码行数:23,代码来源:EditPage.php

示例7: execute


//.........这里部分代码省略.........
         $requestArray['wpWatchthis'] = '';
     }
     global $wgTitle, $wgRequest;
     $req = new DerivativeRequest($this->getRequest(), $requestArray, true);
     // Some functions depend on $wgTitle == $ep->mTitle
     // TODO: Make them not or check if they still do
     $wgTitle = $titleObj;
     $articleObject = new Article($titleObj);
     $ep = new EditPage($articleObject);
     // allow editing of non-textual content.
     $ep->allowNonTextContent = true;
     $ep->setContextTitle($titleObj);
     $ep->importFormData($req);
     // Run hooks
     // Handle APIEditBeforeSave parameters
     $r = array();
     if (!wfRunHooks('APIEditBeforeSave', array($ep, $ep->textbox1, &$r))) {
         if (count($r)) {
             $r['result'] = 'Failure';
             $apiResult->addValue(null, $this->getModuleName(), $r);
             return;
         } else {
             $this->dieUsageMsg('hookaborted');
         }
     }
     // Do the actual save
     $oldRevId = $articleObject->getRevIdFetched();
     $result = null;
     // Fake $wgRequest for some hooks inside EditPage
     // @todo FIXME: This interface SUCKS
     $oldRequest = $wgRequest;
     $wgRequest = $req;
     $status = $ep->internalAttemptSave($result, $user->isAllowed('bot') && $params['bot']);
     $wgRequest = $oldRequest;
     global $wgMaxArticleSize;
     switch ($status->value) {
         case EditPage::AS_HOOK_ERROR:
         case EditPage::AS_HOOK_ERROR_EXPECTED:
             $this->dieUsageMsg('hookaborted');
         case EditPage::AS_PARSE_ERROR:
             $this->dieUsage($status->getMessage(), 'parseerror');
         case EditPage::AS_IMAGE_REDIRECT_ANON:
             $this->dieUsageMsg('noimageredirect-anon');
         case EditPage::AS_IMAGE_REDIRECT_LOGGED:
             $this->dieUsageMsg('noimageredirect-logged');
         case EditPage::AS_SPAM_ERROR:
             $this->dieUsageMsg(array('spamdetected', $result['spam']));
         case EditPage::AS_BLOCKED_PAGE_FOR_USER:
             $this->dieUsageMsg('blockedtext');
         case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
         case EditPage::AS_CONTENT_TOO_BIG:
             $this->dieUsageMsg(array('contenttoobig', $wgMaxArticleSize));
         case EditPage::AS_READ_ONLY_PAGE_ANON:
             $this->dieUsageMsg('noedit-anon');
         case EditPage::AS_READ_ONLY_PAGE_LOGGED:
             $this->dieUsageMsg('noedit');
         case EditPage::AS_READ_ONLY_PAGE:
             $this->dieReadOnly();
         case EditPage::AS_RATE_LIMITED:
             $this->dieUsageMsg('actionthrottledtext');
         case EditPage::AS_ARTICLE_WAS_DELETED:
             $this->dieUsageMsg('wasdeleted');
         case EditPage::AS_NO_CREATE_PERMISSION:
             $this->dieUsageMsg('nocreate-loggedin');
         case EditPage::AS_BLANK_ARTICLE:
             $this->dieUsageMsg('blankpage');
         case EditPage::AS_CONFLICT_DETECTED:
             $this->dieUsageMsg('editconflict');
             // case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary
         // case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary
         case EditPage::AS_TEXTBOX_EMPTY:
             $this->dieUsageMsg('emptynewsection');
         case EditPage::AS_SUCCESS_NEW_ARTICLE:
             $r['new'] = '';
         case EditPage::AS_SUCCESS_UPDATE:
             $r['result'] = 'Success';
             $r['pageid'] = intval($titleObj->getArticleID());
             $r['title'] = $titleObj->getPrefixedText();
             $r['contentmodel'] = $titleObj->getContentModel();
             $newRevId = $articleObject->getLatest();
             if ($newRevId == $oldRevId) {
                 $r['nochange'] = '';
             } else {
                 $r['oldrevid'] = intval($oldRevId);
                 $r['newrevid'] = intval($newRevId);
                 $r['newtimestamp'] = wfTimestamp(TS_ISO_8601, $pageObj->getTimestamp());
             }
             break;
         case EditPage::AS_SUMMARY_NEEDED:
             $this->dieUsageMsg('summaryrequired');
         case EditPage::AS_END:
         default:
             // $status came from WikiPage::doEdit()
             $errors = $status->getErrorsArray();
             $this->dieUsageMsg($errors[0]);
             // TODO: Add new errors to message map
             break;
     }
     $apiResult->addValue(null, $this->getModuleName(), $r);
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:101,代码来源:ApiEditPage.php

示例8: wfGenerateFamilyTreePage

/**
 * Generate family tree page
 *
 * @param unknown_type $args user, name, ns, title
 * @return GE_SUCCESS, GE_INVALID_ARG, GE_NOT_LOGGED_IN, GE_NOT_AUTHORIZED, GE_NOT_FOUND, GE_DUP_KEY, GE_DB_ERROR
 */
function wfGenerateFamilyTreePage($args)
{
    global $wgUser, $wgAjaxCachePolicy, $wrBotUserID, $wrIsGedcomUpload;
    // set cache policy
    $wgAjaxCachePolicy->setPolicy(0);
    $status = GE_SUCCESS;
    $ns = '';
    $text = '';
    $oldText = '';
    $titleString = '';
    $editFlags = 0;
    $wrIsGedcomUpload = true;
    if (!$wgUser->isLoggedIn()) {
        $status = GE_NOT_LOGGED_IN;
    } else {
        if (wfReadOnly() || $wgUser->getID() != $wrBotUserID) {
            $status = GE_NOT_AUTHORIZED;
        } else {
            $xml = simplexml_load_string($args);
            $ns = (int) $xml['namespace'];
            $titleString = (string) $xml['title'];
            PropagationManager::setWhitelist();
            // only pages to propagate to are on the whitelist
            $existingTitles = (string) $xml['existing_titles'];
            if ($existingTitles) {
                $existingTitles = explode('|', $existingTitles);
                foreach ($existingTitles as $existingTitle) {
                    PropagationManager::addWhitelistPage(Title::newFromText($existingTitle));
                }
            }
            $treeId = (int) $xml['tree_id'];
            $uid = (string) $xml['uid'];
            //   	wfDebug("wfGenerateFamilyTreePage ns=$ns title=$titleString treeId=$treeId\n");
            if (!$titleString || !$treeId) {
                //wfDebug("wfGenerate parmerr $treeId:$titleString\n");
                $status = GE_INVALID_ARG;
            }
        }
    }
    if ($status == GE_SUCCESS) {
        $dbr =& wfGetDB(DB_SLAVE);
        $dbr->ignoreErrors(true);
        $userName = $dbr->selectField('familytree', 'ft_user', array('ft_tree_id' => $treeId));
        $errno = $dbr->lastErrno();
        if ($errno > 0) {
            $status = GE_DB_ERROR;
        } else {
            if ($userName === false) {
                $status = GE_NOT_FOUND;
            } else {
                $wgUser = User::newFromName($userName, false);
                // switch the global user
                if (!$wgUser) {
                    $status = GE_NOT_FOUND;
                }
            }
        }
    }
    if ($status == GE_SUCCESS) {
        $title = Title::newFromText($titleString, $ns);
        $text = $xml->content;
        if ($title == null || !$treeId) {
            //wfDebug("wfGenerate error $treeId $ns $titleString\n");
            $status = GE_INVALID_ARG;
        } else {
            $article = new Article($title, 0);
            if (!$article->exists()) {
                $editFlags = EDIT_NEW;
            } else {
                $oldText = $article->getContent();
                $editFlags = EDIT_UPDATE;
            }
            //         else if ($ns == NS_MYSOURCE) {
            //            $existingMysource = true;
            //            $revid = $title->getLatestRevID(GAID_FOR_UPDATE);
            //         }
            //         // TODO during re-upload, we need to notify users of changes if others are watching; should we not suppress RC in this case?
            //         // also, decide whether FamilyTreePropagator should update ftp or not
            //         // (FamilyTreePropagator also processes the tree checkboxes, so we probably don't want it called)
            //         else {
            ////            $editFlags = EDIT_UPDATE;
            //            $status = GE_DUP_KEY;
            //         }
        }
    }
    if ($status == GE_SUCCESS && ($editFlags == EDIT_NEW || $text != $oldText)) {
        $isUpdatable = true;
        if ($editFlags == EDIT_UPDATE) {
            $revision = Revision::newFromId($article->getLatest());
            if ($revision && $revision->getComment() != 'gedcom upload') {
                $isUpdatable = false;
                error_log("Cannot update existing user-edited page: " . $article->getTitle()->getPrefixedText());
            }
        }
//.........这里部分代码省略.........
开发者ID:k-hasan-19,项目名称:wiki,代码行数:101,代码来源:GedcomAjaxFunctions.php

示例9: overrideRedirect

 public static function overrideRedirect(Title $title, WebRequest $request, &$ignoreRedirect, &$target, Article &$article)
 {
     global $wgMemc, $wgParserCacheExpireTime;
     $fa = FlaggableWikiPage::getTitleInstance($title);
     // on $wgTitle
     if (!$fa->isReviewable()) {
         return true;
         // nothing to do
     }
     # Viewing an old reviewed version...
     if ($request->getVal('stableid')) {
         $ignoreRedirect = true;
         // don't redirect (same as ?oldid=x)
         return true;
     }
     $srev = $fa->getStableRev();
     $view = FlaggablePageView::singleton();
     # Check if we are viewing an unsynced stable version...
     if ($srev && $view->showingStable() && $srev->getRevId() != $article->getLatest()) {
         # Check the stable redirect properties from the cache...
         $key = wfMemcKey('flaggedrevs', 'overrideRedirect', $article->getId());
         $tuple = FlaggedRevs::getMemcValue($wgMemc->get($key), $article);
         if (is_array($tuple)) {
             // cache hit
             list($ignoreRedirect, $target) = $tuple;
         } else {
             // cache miss; fetch the stable rev text...
             $text = $srev->getRevText();
             $redirect = $fa->getRedirectURL(Title::newFromRedirectRecurse($text));
             if ($redirect) {
                 $target = $redirect;
                 // use stable redirect
             } else {
                 $ignoreRedirect = true;
                 // make MW skip redirection
             }
             $data = FlaggedRevs::makeMemcObj(array($ignoreRedirect, $target));
             $wgMemc->set($key, $data, $wgParserCacheExpireTime);
             // cache results
         }
         $clearEnvironment = (bool) $target;
         # Check if the we are viewing a draft or synced stable version...
     } else {
         # In both cases, we can just let MW use followRedirect()
         # on the draft as normal, avoiding any page text hits.
         $clearEnvironment = $article->isRedirect();
     }
     # Environment (e.g. $wgTitle) will change in MediaWiki::initializeArticle
     if ($clearEnvironment) {
         $view->clear();
     }
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:53,代码来源:FlaggedRevsUI.hooks.php

示例10: getCachedWork

 function getCachedWork()
 {
     global $wgOut;
     $parserCache = ParserCache::singleton();
     $this->mArticle->mParserOutput = $parserCache->get($this->mArticle, $this->parserOptions);
     if ($this->mArticle->mParserOutput !== false) {
         wfDebug(__METHOD__ . ": showing contents parsed by someone else\n");
         $wgOut->addParserOutput($this->mArticle->mParserOutput);
         # Ensure that UI elements requiring revision ID have
         # the correct version information.
         $wgOut->setRevisionId($this->mArticle->getLatest());
         return true;
     }
     return false;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:15,代码来源:Article.php


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