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


PHP Article::newFromId方法代码示例

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


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

示例1: show

 function show($params)
 {
     global $wgOut;
     // Just parse the details out.
     list($action, $article_id, $queue) = $params;
     $article = Article::newFromId($article_id);
     $this->process($article, $queue);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:8,代码来源:DeleteQueueViewNominate.php

示例2: wfPrintSalo

function wfPrintSalo($name)
{
    $text = $name . " з'їв сала";
    $id = Title::newMainPage()->getArticleId();
    $ar = Article::newFromId($id);
    $ar->updateArticle($text, '', false, false);
    return true;
}
开发者ID:kghbln,项目名称:semantic-social-profile,代码行数:8,代码来源:CustomHook.php

示例3: testPageStatsService

	function testPageStatsService() {
		global $wgTitle, $wgMemc;

		$wgTitle = Title::newMainPage();
		$articleId = $wgTitle->getArticleId();
		$article = Article::newFromId($articleId);
		$key = wfMemcKey('services', 'pageheader', 'current-revision', $articleId);

		// macbre: perform this test only for existing pages
		if (!$wgTitle->exists()) {
			$this->markTestSkipped('Main page cannot be found');
			return;
		}

		$service = new PageStatsService($articleId);

		$this->assertType('array', $service->getMostLinkedCategories());
		$this->assertType('int', $service->getCommentsCount());
		$this->assertType('int', $service->getLikesCount());
		$this->assertType('array', $service->getCurrentRevision());
		$this->assertType('array', $service->getPreviousEdits());
		$this->assertType('string', $service->getFirstRevisionTimestamp());

		// comments counter regenerating
		$comments = $service->getCommentsCount();

		$service->regenerateCommentsCount();
		$this->assertEquals($comments, $service->getCommentsCount());

		// remove cached stats when article is edited
		$user = $flags = $status = false;
		PageStatsService::onArticleSaveComplete($article, $user, false, false, false, false, false, $flags, false, $status, false);

		$data = $wgMemc->get($key);
		$this->assertTrue(empty($data));

		$service->getCurrentRevision();

		$data = $wgMemc->get($key);
		$this->assertFalse(empty($data));

		// remove cached stats when article (comment) is deleted
		PageStatsService::onArticleDeleteComplete($article, $user, false, $articleId);

		$data = $wgMemc->get($key);
		$this->assertTrue(empty($data));

		$service->getCurrentRevision();

		// regenerate data
		$service->regenerateData();

		$data = $wgMemc->get($key);
		$this->assertTrue(empty($data));
	}
开发者ID:schwarer2006,项目名称:wikia,代码行数:55,代码来源:ServiceTest.php

示例4: approveDraft

 /**
  * Overrides content of parent page with contents of draft page
  * @param Title $draftTitle Title object of sub page (draft)
  * @throws PermissionsException
  */
 private function approveDraft(Title $draftTitle)
 {
     // Get Title object of parent page
     $helper = new TemplateDraftHelper();
     $parentTitle = $helper->getParentTitle($draftTitle);
     // Check edit rights
     if (!$parentTitle->userCan('templatedraft')) {
         throw new PermissionsException('edit');
     }
     // Get contents of draft page
     $article = Article::newFromId($draftTitle->getArticleID());
     $draftContent = $article->getContent();
     // Get WikiPage object of parent page
     $page = WikiPage::newFromID($parentTitle->getArticleID());
     // Save to parent page
     $page->doEdit($draftContent, wfMessage('templatedraft-approval-summary')->inContentLanguage()->plain());
     // Remove Draft page
     $draftPage = WikiPage::newFromID($draftTitle->getArticleID());
     $draftPage->doDeleteArticle(wfMessage('templatedraft-draft-removal-summary')->inContentLanguage()->plain());
     // Show a confirmation message to a user after redirect
     BannerNotificationsController::addConfirmation(wfMessage('templatedraft-approval-success-confirmation')->escaped(), BannerNotificationsController::CONFIRMATION_CONFIRM, true);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:ApprovedraftAction.php

示例5: purge

 /**
  * Purges memcache entry
  */
 public function purge()
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     // clear data cache
     $wgMemc->delete($this->mMemcacheKey);
     $this->mData = null;
     $article = Article::newFromId($this->mQuizElementId);
     if (!empty($article)) {
         // purge quizElement page
         $article->doPurge();
         // apply changes to page_touched fields
         $dbw = wfGetDB(DB_MASTER);
         $dbw->commit();
     }
     // purge cached quiz
     if (empty($this->mQuizTitleObject)) {
         $this->load();
     }
     if (!empty($this->mQuizTitleObject)) {
         $quizArticle = new WikiaQuizIndexArticle($this->mQuizTitleObject);
         $quizArticle->doPurge();
     } else {
         // should never get to this point
     }
     wfDebug(__METHOD__ . ": purged quizElement #{$this->mQuizElementId}\n");
     wfProfileOut(__METHOD__);
 }
开发者ID:yusufchang,项目名称:app,代码行数:31,代码来源:WikiaQuizElement.class.php

示例6: purge

 /**
  * Purges memcache entry
  */
 public function purge()
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     // clear data cache
     $wgMemc->delete($this->mMemcacheKey);
     $this->mData = null;
     $article = Article::newFromId($this->mId);
     if (!empty($article)) {
         // purge page
         $article->doPurge();
         // apply changes to page_touched fields
         $dbw = wfGetDB(DB_MASTER);
         $dbw->commit();
     }
     wfDebug(__METHOD__ . ": purged RelatedVideos NS article #{$this->mId}\n");
     wfProfileOut(__METHOD__);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:21,代码来源:RelatedVideosNamespaceData.class.php

示例7: sfAddSpeciesChild

 function sfAddSpeciesChild(&$page_contents, $page_title, $form_title)
 {
     $page_title = $form_title;
     $form_title = $page_title;
     //echo '<pre>'; print_r(func_get_args()); print_r($_GET); exit;
     if (isset($_GET['extend'])) {
         $extend = str_replace('_', ' ', $_GET['extend']);
     }
     if (isset($_GET['child_type'])) {
         $child_type = strtolower($_GET['child_type']);
     } else {
         if (isset($_GET['title'])) {
             if (preg_match('~^Special:FormEdit/([\\w]+)(/([\\w]+))?$~', $_GET['title'], $matches)) {
                 //$extend =
                 $child_type = strtolower($matches[1]);
             }
         }
     }
     if (!isset($extend) || !isset($child_type)) {
         return true;
     }
     $list_title = Title::newFromText($extend);
     $id = $list_title->getArticleID();
     if (!$id) {
         return true;
     }
     $article = Article::newFromId($id);
     $text = $article->getRawText();
     $text = self::removeField($text, array('common', 'primary image'));
     $preload = '';
     //fields which, if present in the plant template, should be removed. These are fields which a small minority of pages will have which were used previously but now cause problems when extending
     $bad_fields = array('cultivar of', 'cultivar name', 'show cultivar group', 'cultivar group', 'is a variety', 'variety type', 'variety name', 'variety of', 'subspecies name', 'subspecies of');
     //$bad_fields=array();
     //echo $text; exit;
     switch ($child_type) {
         case 'cultivar_group':
             if (!strstr($text, "{{Plant\n|")) {
                 //make sure there's an instance of the plant template in the page we're extending
                 return true;
             }
             $text = self::removeField($text, $bad_fields);
             $preload = str_replace("{{Plant\n|", "{{Cultivar group\n|cultivar group of=" . $extend . '|', $text);
             break;
         case 'cultivar':
             if (strstr($text, "{{Plant\n|")) {
                 $text = self::removeField($text, $bad_fields);
                 $preload = str_replace("{{Plant\n|", "{{Cultivar\n|cultivar of=" . $extend . "\n|", $text);
             } elseif (strstr($text, "{{Cultivar group\n|")) {
                 $text = self::removeField($text, $bad_fields);
                 $preload = str_replace("{{Cultivar group\n|", "{{Cultivar\n|cultivar of=" . $extend . "\n|", $text);
             } else {
                 return true;
             }
             break;
         case 'variety':
             $preload = str_replace("{{Plant\n|", '{{Variety', $text);
         case 'subspecies':
             $preload = str_replace("{{Plant\n|", '{{Subspecies', $text);
             break;
     }
     if (isset($preload)) {
         $page_contents = $preload;
     }
     //echo $preload; exit;
     return true;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:66,代码来源:PracticalPlants_Body.php

示例8: editArticle

    function editArticle()
    {
        global $wgOpenStackManagerCreateProjectSALPages;
        if (!OpenStackNovaArticle::canCreatePages()) {
            return;
        }
        $format = <<<RESOURCEINFO
{{Nova Resource
|Resource Type=project
|Project Name=%s
|Members=%s}}
__NOEDITSECTION__
RESOURCEINFO;
        $rawmembers = $this->getMembers();
        $members = array();
        foreach ($rawmembers as $member) {
            array_push($members, 'User:' . $member);
        }
        $text = sprintf($format, $this->getProjectName(), implode(',', $members));
        OpenStackNovaArticle::editArticle($this->getProjectName(), $text);
        if ($wgOpenStackManagerCreateProjectSALPages) {
            $pagename = $this->getProjectName() . "/SAL";
            $id = Title::newFromText($pagename, NS_NOVA_RESOURCE)->getArticleId();
            $article = Article::newFromId($id);
            $content = '';
            if ($article) {
                $content = $article->getRawText();
            }
            $text = "{{SAL|Project Name=" . $this->getProjectName() . "}}";
            if (!strstr($content, $text)) {
                OpenStackNovaArticle::editArticle($pagename, $text);
            }
        }
    }
开发者ID:schwarer2006,项目名称:wikia,代码行数:34,代码来源:OpenStackNovaProject.php

示例9: purge

 /**
  * Purges memcache entry and articles having current poll transcluded
  */
 public function purge()
 {
     global $wgMemc, $wgCityId;
     wfProfileIn(__METHOD__);
     // clear data cache
     $wgMemc->delete($this->mMemcacheKey);
     $this->mData = null;
     $article = Article::newFromId($this->mPollId);
     if (!empty($article)) {
         // purge poll page
         $article->doPurge();
         // purge articles embedding this poll
         $task = (new \Wikia\Tasks\Tasks\HTMLCacheUpdateTask())->wikiId($wgCityId)->title($article->getTitle());
         $task->call('purge', 'templatelinks');
         $task->queue();
         // apply changes to page_touched fields
         $dbw = wfGetDB(DB_MASTER);
         $dbw->commit();
     }
     wfDebug(__METHOD__ . ": purged poll #{$this->mPollId}\n");
     wfProfileOut(__METHOD__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:WikiaPoll.class.php

示例10: _make_links

function _make_links($page_id, $rev_id, $content)
{
    $links = array('image' => 0, 'video' => 0);
    $oArticle = Article::newFromId($page_id);
    if ($oArticle instanceof Article) {
        $editInfo = $oArticle->prepareTextForEdit($content, $rev_id);
        $images = $editInfo->output->getImages();
        if (!empty($images)) {
            foreach ($images as $iname => $dummy) {
                if (substr($iname, 0, 1) == ':') {
                    $links['video']++;
                } else {
                    $links['image']++;
                }
            }
        }
    }
    return $links;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:testArchiveData.php

示例11: show

 function show($params)
 {
     $article_id = $params[1];
     $article = Article::newFromId($article_id);
     $this->process($article);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:6,代码来源:DeleteQueueViewVote.php

示例12: submit

 /**
  * Function that is called after the user confirms the change.
  * Checks for the token and insertes the template. If the token is wrong or the article doesn't exist, preview() is shown
  *
  * @param $page String: title of the page that needs to be edited
  * @param $template String: title of the selected template
  * @param $token String: token that is included in the html form in preview()
  */
 function submit($page, $template, $token)
 {
     global $wgOut, $wgUser;
     if (!$wgUser->matchEditToken($token)) {
         # Wrong Edit token. Show preview page
         $this->preview($page, $template);
         return;
     }
     $id = Title::newFromText($page)->getArticleId();
     if ($id == 0) {
         # Page does not exist. Show preview page
         $wgOut->wrapWikiMsg("<div class='error plainlinks'>\n\$1</div>\n", array('flagpage-nonexistent', $page));
         $this->preview($page, $template);
         return;
     }
     $article = Article::newFromId($id);
     $text = "{{" . $template . "}}\n\n" . $article->getRawText();
     $summary = wfMsg('flagpage-summary', $template);
     $article->doEdit($text, $summary, EDIT_UPDATE, $id);
     $wgOut->addWikiMsg('flagpage-success', $template, $page, $id);
     // FIXME Broken link without oldid
     // TODO Add nice way to undo changes (copy HTML Forms of EditPage.php)
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:31,代码来源:FlagPage.body.php

示例13: time

	$startTime = time();
	$numFailed = 0;
	for($cnt=0; $cnt < $numRedirects; $cnt++){
		$title = $redirectCache[$cnt];
		$redirTo = "NULL";

		// Ignore the result - just doing it to fill the 'redirTo'.
		$titleObj = Title::newFromDBkey($title);
		if( $titleObj ) {
			if($titleObj->exists()){
				$article = Article::newFromID($titleObj->getArticleID());
				if($article && $article->isRedirect()){
					$reTitle = $article->followRedirect(); // follows redirects recursively
					if($reTitle && is_object($reTitle)){
						//unset($article); // hint to garbage collector - doesn't appear to do anything in this case
						$article = Article::newFromId($reTitle->getArticleID());
					}
				}
				if($article){
					$redirTo = $article->getTitle()->getDBkey();
					//$retVal = $article->getRawText(); // don't need the final page text.
					//unset($article); // hint to garbage collector - doesn't appear to do anything in this case
					fwrite($REDIR_FILE, formatForUb("$title")."\t\t".formatForUb("$redirTo")."\n");
				} else {
					print "WARNING: REDIR DID NOT TERMINATE ON VALID FILE: \"$title\"\n";
					$numFailed++;
				}
			}
		}

		// Output progress occasionally (but not constantly to avoid just filling the buffer constantly.
开发者ID:schwarer2006,项目名称:wikia,代码行数:31,代码来源:dumpTitlePageIdMapping.php

示例14: lw_getPage

function lw_getPage($pageTitle, &$finalName = '', $debug = false, $page_namespace = NS_MAIN, &$page_id = '')
{
    $retVal = "";
    $finalName = $pageTitle;
    // Get the text of the end-point article and record what the final article name is.
    $title = Title::newFromText($pageTitle, $page_namespace);
    if ($title) {
        if ($title->exists()) {
            $page_id = $title->getArticleID();
            $article = Article::newFromID($title->getArticleID());
            if (is_object($article)) {
                /* @var $article WikiPage */
                if ($article->isRedirect()) {
                    $reTitle = $article->followRedirect();
                    // follows redirects recursively
                    if ($reTitle instanceof Title) {
                        $article = Article::newFromId($reTitle->getArticleID());
                    } else {
                        $article = null;
                    }
                }
                if (is_object($article)) {
                    $finalName = $article->getTitle()->getDBkey();
                    $retVal = $article->getRawText();
                }
            }
        }
    }
    //	print (!$debug?"":"page code\n$retVal\n");
    return $retVal;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:server.php

示例15: postLoad

 /**
  * Stuff that needs to be done after loading new data.
  */
 protected function postLoad()
 {
     if (isset($this->mDiscussionPageID)) {
         $this->mDiscussionPage = Article::newFromId($this->mDiscussionPageID);
     }
     $this->mArticle = Article::newFromId($this->mArticleID);
     // Split votes.
     if (isset($this->mVotes) && count($this->mVotes)) {
         $this->mVotesEndorse = array();
         $this->mVotesObject = array();
         foreach ($this->mVotes as $vote) {
             $type = ucfirst($vote['type']);
             $arr_name = "mVotes{$type}";
             $this->{$arr_name}[] = $vote;
         }
     } elseif (isset($this->mVotes)) {
         // Clear them.
         $this->mVotesEndorse = array();
         $this->mVotesObject = array();
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:24,代码来源:DeleteQueueItem.php


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