本文整理汇总了PHP中WikiPage::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::getTitle方法的具体用法?PHP WikiPage::getTitle怎么用?PHP WikiPage::getTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiPage
的用法示例。
在下文中一共展示了WikiPage::getTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performUpdate
protected function performUpdate()
{
$applicationFactory = ApplicationFactory::getInstance();
$parserData = $applicationFactory->newParserData($this->wikiPage->getTitle(), $this->parserOutput);
$pageInfoProvider = $applicationFactory->newMwCollaboratorFactory()->newPageInfoProvider($this->wikiPage, $this->revision, $this->user);
$propertyAnnotator = $applicationFactory->newPropertyAnnotatorFactory()->newPredefinedPropertyAnnotator($parserData->getSemanticData(), $pageInfoProvider);
$propertyAnnotator->addAnnotation();
$parserData->pushSemanticDataToParserOutput();
return true;
}
示例2: protectMessageInPrNamespaces
/**
* Protects a message entry in the PRAd namespace.
* The protection lasts for infinity and acts for group
* @ref $wgPromoterProtectGroup
*
* This really is intended only for use on the original source language
* because those messages are set via the PR UI; not the translate UI.
*
* @param WikiPage $page Page containing the message to protect
* @param User $user User doing the protection (ie: the last one to edit the page)
*/
protected function protectMessageInPrNamespaces($page, $user)
{
global $wgPromoterProtectGroup;
if (!$page->getTitle()->getRestrictions('edit')) {
$var = false;
$page->doUpdateRestrictions(array('edit' => $wgPromoterProtectGroup, 'move' => $wgPromoterProtectGroup), array('edit' => 'infinity', 'move' => 'infinity'), $var, 'Auto protected by Promoter -- Only edit via Special:Promoter.', $user);
}
}
示例3: ClearParentNotification
/**
* Clears notification for parent pages if:
* - User is NOT watching currently viewed subpage
* - User is watching parent page
* - User has 'watchlistsubpages' turned on
*
* @param $article WikiPage object ( subpage )
*
* @author Jakub Kurcek <jakub@wikia-inc.com>
*/
public static function ClearParentNotification(WikiPage $page)
{
global $wgUser;
if ($wgUser->getBoolOption(self::PREFERENCES_ENTRY)) {
if (!$page->getTitle()->userIsWatching()) {
$tmpDBkey = $page->getTitle()->getDBkey();
$arrTitle = explode('/', $tmpDBkey);
if (count($arrTitle > 1)) {
$parentTitle = Title::newFromDBkey($arrTitle[0]);
if ($parentTitle->userIsWatching()) {
$wgUser->clearNotification($parentTitle);
}
}
}
}
return true;
}
示例4: testGetContentHandler
/**
* @covers WikiPage::getContentHandler
*/
public function testGetContentHandler()
{
$page = $this->createPage("WikiPageTest_testGetContentHandler", "some text", CONTENT_MODEL_JAVASCRIPT);
// NOTE: since the content model is not recorded in the database,
// we expect to get the default, namely CONTENT_MODEL_WIKITEXT
$page = new WikiPage($page->getTitle());
$this->assertEquals('WikitextContentHandler', get_class($page->getContentHandler()));
}
示例5: newFromTitle
static function newFromTitle($title)
{
// see if we already have this as our main instance...
if (self::$instance && self::$instance->mTitle == $title) {
return self::$instance;
}
$wikiPage = new WikiPage($title);
if (!$wikiPage) {
return null;
}
$whow = new WikihowArticleEditor();
$whow->mTitleObj = $wikiPage->getTitle();
$whow->mWikiPage = $wikiPage;
$whow->mTitle = $wikiPage->getTitle()->getText();
$text = ContentHandler::getContentText($wikiPage->getContent(Revision::RAW));
$whow->loadFromText($text);
return $whow;
}
示例6: doDelete
/**
* Delete $page
*/
protected function doDelete($page)
{
if ($page instanceof Title) {
$page = new WikiPage($page);
}
if ($this->logActions) {
print "Delete " . $page->getTitle() . " = " . $page->getId() . "\n";
}
$page->doDeleteArticle('-');
}
示例7: onPageContentSave
static function onPageContentSave(WikiPage &$wikiPage, User &$user, Content &$content, &$summary, $isMinor, $isWatch, $section, &$flags, Status &$status)
{
// get the current tags from the page
/////////////////////////////////////
$CurrentReferences;
preg_match_all(self::GetLabelsRegex, $wikiPage->getText(), $matches);
// build it as a "set"
foreach (array_merge($matches[2], $matches[3]) as $toAdd) {
if ($toAdd != '') {
$CurrentReferences[$toAdd] = 1;
}
}
// get the old tags from the database
/////////////////////////////////////
$OldReferences;
if (($rev = $wikiPage->getRevision()) != null && ($prevRev = $rev->getPrevious()) != null) {
preg_match_all(self::GetLabelsRegex, $prevRev->getText(), $matches);
// build it as a "set"
foreach (array_merge($matches[2], $matches[3]) as $toAdd) {
if ($toAdd != '') {
$OldReferences[$toAdd] = 1;
}
}
}
// Resolve differences
//////////////////////
$DB = wfGetDB(DB_MASTER);
$DB->begin();
// start a transaction
// start with the newOnes and make sure that the database is compatable, and remove them
foreach (array_keys($CurrentReferences) as $RefToMakeSureExists) {
if (isset($OldReferences[$RefToMakeSureExists])) {
// if it is already in the array, then we don't have to worry about it; delete it
unset($OldReferences[$RefToMakeSureExists]);
} else {
// if it doesn't exist, we need to add it
try {
$DB->insert(ContentReferencerTableName, array('reference_name' => $RefToMakeSureExists, 'reference_page_name' => (string) $wikiPage->getTitle()));
} catch (Exception $e) {
die($e->getMessage());
}
}
}
// now, anything left in $OldReferences has been deleted. Let's remove it from the database
foreach (array_keys($OldReferences) as $RefToDelete) {
try {
$DB->delete(ContentReferencerTableName, "reference_name='{$RefToDelete}'");
} catch (Exception $e) {
die($e->getMessage());
}
}
$DB->commit();
// end the transaction
}
示例8: onArticlePurge
/**
* Hook: Clear cache (videos by category) when the category page is purged
* @param WikiPage $page
* @return true
*/
public static function onArticlePurge(WikiPage &$page)
{
wfProfileIn(__METHOD__);
$title = $page->getTitle();
if ($title->getNamespace() == NS_CATEGORY) {
$helper = new VideoPageToolHelper();
$helper->invalidateCacheVideosByCategory($title->getDBkey());
}
wfProfileOut(__METHOD__);
return true;
}
示例9: getParserOutput
protected function getParserOutput(WikiPage $wp, ParserOptions $parserOptions)
{
$params = $this->extractRequestParams();
if (!isset($params['text'])) {
throw new Exception('Must specify page text');
}
$parser = new Parser();
$po = $parser->parse($params['text'], $wp->getTitle(), $parserOptions);
$po->setTOCEnabled(false);
$po->setText(str_replace(array("\r", "\n"), '', $po->getText()));
return $po;
}
示例10: doExtendParserOutput
private function doExtendParserOutput($parserOutput)
{
$applicationFactory = ApplicationFactory::getInstance();
$title = $this->wikiPage->getTitle();
$parserData = $applicationFactory->newParserData($title, $parserOutput);
$pageInfoProvider = $applicationFactory->newMwCollaboratorFactory()->newPageInfoProvider($this->wikiPage, $this->revision, $this->user);
$propertyAnnotatorFactory = $applicationFactory->singleton('PropertyAnnotatorFactory');
$propertyAnnotator = $propertyAnnotatorFactory->newNullPropertyAnnotator($parserData->getSemanticData());
$propertyAnnotator = $propertyAnnotatorFactory->newPredefinedPropertyAnnotator($propertyAnnotator, $pageInfoProvider);
$propertyAnnotator->addAnnotation();
$parserData->pushSemanticDataToParserOutput();
}
示例11: doWork
/**
* @return bool
*/
public function doWork()
{
global $wgUseFileCache;
// @todo several of the methods called on $this->page are not declared in Page, but present
// in WikiPage and delegated by Article.
$isCurrent = $this->revid === $this->page->getLatest();
if ($this->content !== null) {
$content = $this->content;
} elseif ($isCurrent) {
// XXX: why use RAW audience here, and PUBLIC (default) below?
$content = $this->page->getContent(Revision::RAW);
} else {
$rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
if ($rev === null) {
$content = null;
} else {
// XXX: why use PUBLIC audience here (default), and RAW above?
$content = $rev->getContent();
}
}
if ($content === null) {
return false;
}
// Reduce effects of race conditions for slow parses (bug 46014)
$cacheTime = wfTimestampNow();
$time = -microtime(true);
$this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions);
$time += microtime(true);
// Timing hack
if ($time > 3) {
// TODO: Use Parser's logger (once it has one)
$logger = MediaWiki\Logger\LoggerFactory::getInstance('slow-parse');
$logger->info('{time} {title}', ['time' => number_format($time, 2), 'title' => $this->page->getTitle()->getPrefixedDBkey(), 'trigger' => 'view']);
}
if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) {
ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid);
}
// Make sure file cache is not used on uncacheable content.
// Output that has magic words in it can still use the parser cache
// (if enabled), though it will generally expire sooner.
if (!$this->parserOutput->isCacheable()) {
$wgUseFileCache = false;
}
if ($isCurrent) {
$this->page->triggerOpportunisticLinksUpdate($this->parserOutput);
}
return true;
}
示例12: onPageContentSaveComplete
/**
* @param WikiPage $article
* @param User $user
* @param $content
* @param $summary
* @param Bool $isMinor
* @param Bool $isWatch
* @param $section
* @param $flags
* @param Revision $revision
* @param $status
* @param $baseRevId
*
* @return bool
*/
public static function onPageContentSaveComplete(WikiPage $article, User $user, $content, $summary, $isMinor, $isWatch, $section, $flags, $revision, $status, $baseRevId)
{
if (is_null($revision)) {
// Ignore null edits
return true;
}
$title = $article->getTitle();
$oldRevisionId = $revision->getParentId();
if ($oldRevisionId !== null && ApprovedRevs::isAssignedToProject($title) && ApprovedRevs::getApprovedRevID($title) === $oldRevisionId) {
if ($user->isAllowed('auto-reapproval-on-save')) {
ApprovedRevs::performAutoReapproval($title, $revision->getId());
} else {
ApprovedRevs::logUnapprovedSave($title, $user, $revision->getId());
}
}
return true;
}
示例13: onArticleDelete
/**
* MediaWiki ArticleDelete hook. Prevent users from deleting stylometricanalysis pages they have not uploaded (except for sysops)
*/
public function onArticleDelete(WikiPage &$wikiPage, User &$user, &$reason, &$error)
{
try {
$title = $wikiPage->getTitle();
if (!$this->isStylometricAnalysisNamespace($title)) {
return true;
}
if (!$this->currentUserIsASysop($user)) {
$error = '<br>' . $this->getMessage('collatehooks-nodeletepermission') . '.';
return false;
}
$deleter = ObjectRegistry::getInstance()->getManuscriptDeskDeleter();
$deleter->deleteStylometricAnalysisData($title->getPrefixedURL());
} catch (Exception $e) {
return true;
}
return true;
}
示例14: onArticleSaveComplete
/**
* Purge RelatedVideos namespace article after an edit
*
* @param WikiPage $article
*/
public static function onArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
{
wfProfileIn(__METHOD__);
$title = $article->getTitle();
if (!empty($title)) {
switch ($title->getNamespace()) {
case NS_RELATED_VIDEOS:
$relatedVideosNSData = RelatedVideosNamespaceData::newFromTitle($title);
$relatedVideosNSData->purge();
break;
case NS_MEDIAWIKI:
if (empty(F::app()->wg->relatedVideosPartialRelease)) {
if ($title->getText() == RelatedVideosNamespaceData::GLOBAL_RV_LIST) {
$relatedVideosNSData = RelatedVideosNamespaceData::newFromTitle($title);
$relatedVideosNSData->purge();
}
}
break;
}
}
wfProfileOut(__METHOD__);
return true;
}
示例15: savePage
function savePage(WikiPage $p)
{
$db = new DatabaseConnection();
// Read values
$ns = $p->getNs();
$uri = $p->getUri();
$title = $p->getTitle();
$content = $p->getContent();
$author = User::getActiveUserId();
// Update
try {
// pull the latest revision of the page
$rs = $db->getSingleRow('SELECT MAX(revision) AS latest FROM wiki WHERE ns=\'%s\' AND uri=\'%s\'', $ns, $uri);
$currev = $rs ? $rs['latest'] : 0;
// set to 0 if no record returned
// bump revision (if no record, 0 becomes 1)
$currev++;
// and insert the new data
$db->updateRow("INSERT INTO wiki SET content='%s',revision='%d',title='%s',ns='%s',uri='%s',lastedit=NOW(),author='%d'", $content, $currev, $title, $ns, $uri, $author);
} catch (DBXException $e) {
throw $e;
}
}