本文整理汇总了PHP中Title::getPrefixedDBkey方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getPrefixedDBkey方法的具体用法?PHP Title::getPrefixedDBkey怎么用?PHP Title::getPrefixedDBkey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getPrefixedDBkey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute($par)
{
$out = $this->getOutput();
$this->setHeaders();
$this->outputHeader();
$opts = new FormOptions();
$opts->add('target', '');
$opts->add('namespace', '', FormOptions::INTNULL);
$opts->add('limit', 50);
$opts->add('from', 0);
$opts->add('back', 0);
$opts->add('hideredirs', false);
$opts->add('hidetrans', false);
$opts->add('hidelinks', false);
$opts->add('hideimages', false);
$opts->fetchValuesFromRequest($this->getRequest());
$opts->validateIntBounds('limit', 0, 5000);
// Give precedence to subpage syntax
if (isset($par)) {
$opts->setValue('target', $par);
}
// Bind to member variable
$this->opts = $opts;
$this->target = Title::newFromURL($opts->getValue('target'));
if (!$this->target) {
$out->addHTML($this->whatlinkshereForm());
return;
}
$this->getSkin()->setRelevantTitle($this->target);
$this->selfTitle = $this->getTitle($this->target->getPrefixedDBkey());
$out->setPageTitle(wfMsg('whatlinkshere-title', $this->target->getPrefixedText()));
$out->setSubtitle(wfMsg('whatlinkshere-backlink', Linker::link($this->target, $this->target->getPrefixedText(), array(), array('redirect' => 'no'))));
$this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
}
示例2: toString
/**
* @return string
*/
public function toString()
{
$paramString = '';
if ($this->params) {
foreach ($this->params as $key => $value) {
if ($paramString != '') {
$paramString .= ' ';
}
if (is_array($value)) {
$value = "array(" . count($value) . ")";
} elseif (is_object($value) && !method_exists($value, '__toString')) {
$value = "object(" . get_class($value) . ")";
}
$value = (string) $value;
if (mb_strlen($value) > 1024) {
$value = "string(" . mb_strlen($value) . ")";
}
$paramString .= "{$key}={$value}";
}
}
if (is_object($this->title)) {
$s = "{$this->command} " . $this->title->getPrefixedDBkey();
if ($paramString !== '') {
$s .= ' ' . $paramString;
}
return $s;
} else {
return "{$this->command} {$paramString}";
}
}
示例3: convertHtmlToWikitext
/**
* Converts html to wikitext
*
* @param Title $title
* @param string $html
* @return string wikitext
*/
protected function convertHtmlToWikitext(Title $title, $html)
{
$wikitext = $this->requestParsoid('POST', 'transform/html/to/wikitext/' . urlencode($title->getPrefixedDBkey()), array('html' => $html, 'scrubWikitext' => 1));
if ($wikitext === false) {
$this->dieUsage('Error contacting the Parsoid server', 'parsoidserver');
}
return $wikitext;
}
开发者ID:Wikia,项目名称:mediawiki-extensions-ContentTranslation,代码行数:15,代码来源:ApiContentTranslationPublish.php
示例4: __construct
/**
* @param Title|string $title Title object or prefixed DB key string
* @param string $action
* @throws MWException
*/
public function __construct($title, $action)
{
$allowedTypes = self::cacheablePageActions();
if (!in_array($action, $allowedTypes)) {
throw new MWException('Invalid file cache type given.');
}
$this->mKey = $title instanceof Title ? $title->getPrefixedDBkey() : (string) $title;
$this->mType = (string) $action;
$this->mExt = 'html';
}
示例5: toString
/**
* @return string
*/
public function toString()
{
$truncFunc = function ($value) {
$value = (string) $value;
if (mb_strlen($value) > 1024) {
$value = "string(" . mb_strlen($value) . ")";
}
return $value;
};
$paramString = '';
if ($this->params) {
foreach ($this->params as $key => $value) {
if ($paramString != '') {
$paramString .= ' ';
}
if (is_array($value)) {
$filteredValue = array();
foreach ($value as $k => $v) {
if (is_scalar($v)) {
$filteredValue[$k] = $truncFunc($v);
} else {
$filteredValue = null;
break;
}
}
if ($filteredValue && count($filteredValue) < 10) {
$value = FormatJson::encode($filteredValue);
} else {
$value = "array(" . count($value) . ")";
}
} elseif (is_object($value) && !method_exists($value, '__toString')) {
$value = "object(" . get_class($value) . ")";
}
$paramString .= "{$key}={$truncFunc($value)}";
}
}
$metaString = '';
foreach ($this->metadata as $key => $value) {
if (is_scalar($value) && mb_strlen($value) < 1024) {
$metaString .= $metaString ? ",{$key}={$value}" : "{$key}={$value}";
}
}
$s = $this->command;
if (is_object($this->title)) {
$s .= " {$this->title->getPrefixedDBkey()}";
}
if ($paramString != '') {
$s .= " {$paramString}";
}
if ($metaString != '') {
$s .= " ({$metaString})";
}
return $s;
}
示例6: newFromTitle
/**
* Construct an ObjectFileCache from a Title and an action
* @param Title|string $title Title object or prefixed DB key string
* @param string $action
* @throws MWException
* @return HTMLFileCache
*/
public static function newFromTitle($title, $action)
{
$cache = new self();
$allowedTypes = self::cacheablePageActions();
if (!in_array($action, $allowedTypes)) {
throw new MWException("Invalid filecache type given.");
}
$cache->mKey = $title instanceof Title ? $title->getPrefixedDBkey() : (string) $title;
$cache->mType = (string) $action;
$cache->mExt = 'html';
return $cache;
}
示例7: toString
/**
* @return string
*/
public function toString()
{
$paramString = '';
if ($this->params) {
foreach ($this->params as $key => $value) {
if ($paramString != '') {
$paramString .= ' ';
}
if (is_array($value)) {
$filteredValue = [];
foreach ($value as $k => $v) {
$json = FormatJson::encode($v);
if ($json === false || mb_strlen($json) > 512) {
$filteredValue[$k] = gettype($v) . '(...)';
} else {
$filteredValue[$k] = $v;
}
}
if (count($filteredValue) <= 10) {
$value = FormatJson::encode($filteredValue);
} else {
$value = "array(" . count($value) . ")";
}
} elseif (is_object($value) && !method_exists($value, '__toString')) {
$value = "object(" . get_class($value) . ")";
}
$flatValue = (string) $value;
if (mb_strlen($value) > 1024) {
$flatValue = "string(" . mb_strlen($value) . ")";
}
$paramString .= "{$key}={$flatValue}";
}
}
$metaString = '';
foreach ($this->metadata as $key => $value) {
if (is_scalar($value) && mb_strlen($value) < 1024) {
$metaString .= $metaString ? ",{$key}={$value}" : "{$key}={$value}";
}
}
$s = $this->command;
if (is_object($this->title)) {
$s .= " {$this->title->getPrefixedDBkey()}";
}
if ($paramString != '') {
$s .= " {$paramString}";
}
if ($metaString != '') {
$s .= " ({$metaString})";
}
return $s;
}
示例8: execute
function execute($par)
{
$out = $this->getOutput();
$this->setHeaders();
$this->outputHeader();
$this->addHelpLink('Help:What links here');
$opts = new FormOptions();
$opts->add('target', '');
$opts->add('namespace', '', FormOptions::INTNULL);
$opts->add('limit', $this->getConfig()->get('QueryPageDefaultLimit'));
$opts->add('from', 0);
$opts->add('back', 0);
$opts->add('hideredirs', false);
$opts->add('hidetrans', false);
$opts->add('hidelinks', false);
$opts->add('hideimages', false);
$opts->add('invert', false);
$opts->fetchValuesFromRequest($this->getRequest());
$opts->validateIntBounds('limit', 0, 5000);
// Give precedence to subpage syntax
if ($par !== null) {
$opts->setValue('target', $par);
}
// Bind to member variable
$this->opts = $opts;
$this->target = Title::newFromText($opts->getValue('target'));
if (!$this->target) {
if (!$this->including()) {
$out->addHTML($this->whatlinkshereForm());
}
return;
}
$this->getSkin()->setRelevantTitle($this->target);
$this->selfTitle = $this->getPageTitle($this->target->getPrefixedDBkey());
$out->setPageTitle($this->msg('whatlinkshere-title', $this->target->getPrefixedText()));
$out->addBacklinkSubtitle($this->target);
$this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
}
示例9: isHubsPage
static function isHubsPage(Title &$title)
{
global $wgHubsPages, $wgContLanguageCode;
wfProfileIn(__METHOD__);
if (empty($wgHubsPages[$wgContLanguageCode])) {
return false;
}
$dbKey = strtolower($title->getPrefixedDBkey());
foreach ($wgHubsPages[$wgContLanguageCode] as $key => $value) {
if (is_array($key)) {
$key = $key['name'];
}
if ($dbKey == strtolower($key)) {
wfProfileOut(__METHOD__);
return true;
}
}
wfProfileOut(__METHOD__);
return false;
}
示例10: toString
/**
* @return string
*/
public function toString()
{
$paramString = '';
if ($this->params) {
foreach ($this->params as $key => $value) {
if ($paramString != '') {
$paramString .= ' ';
}
$paramString .= "{$key}={$value}";
}
}
if (is_object($this->title)) {
$s = "{$this->command} " . $this->title->getPrefixedDBkey();
if ($paramString !== '') {
$s .= ' ' . $paramString;
}
return $s;
} else {
return "{$this->command} {$paramString}";
}
}
示例11: isValidMoveTarget
/**
* Checks if $this can be moved to a given Title
* - Selects for update, so don't call it unless you mean business
*
* @since 1.25
* @return bool
*/
protected function isValidMoveTarget()
{
# Is it an existing file?
if ($this->newTitle->inNamespace(NS_FILE)) {
$file = wfLocalFile($this->newTitle);
$file->load(File::READ_LATEST);
if ($file->exists()) {
wfDebug(__METHOD__ . ": file exists\n");
return false;
}
}
# Is it a redirect with no history?
if (!$this->newTitle->isSingleRevRedirect()) {
wfDebug(__METHOD__ . ": not a one-rev redirect\n");
return false;
}
# Get the article text
$rev = Revision::newFromTitle($this->newTitle, false, Revision::READ_LATEST);
if (!is_object($rev)) {
return false;
}
$content = $rev->getContent();
# Does the redirect point to the source?
# Or is it a broken self-redirect, usually caused by namespace collisions?
$redirTitle = $content ? $content->getRedirectTarget() : null;
if ($redirTitle) {
if ($redirTitle->getPrefixedDBkey() !== $this->oldTitle->getPrefixedDBkey() && $redirTitle->getPrefixedDBkey() !== $this->newTitle->getPrefixedDBkey()) {
wfDebug(__METHOD__ . ": redirect points to other page\n");
return false;
} else {
return true;
}
} else {
# Fail safe (not a redirect after all. strange.)
wfDebug(__METHOD__ . ": failsafe: database says " . $this->newTitle->getPrefixedDBkey() . " is a redirect, but it doesn't contain a valid redirect.\n");
return false;
}
}
示例12: returnTitleToLua
/**
* Extract information from a Title object for return to Lua
*
* This also records a link to this title in the current ParserOutput
* and caches the title for repeated lookups. The caller should call
* incrementExpensiveFunctionCount() if necessary.
*
* @param $title Title Title to return
* @return array Lua data
*/
private function returnTitleToLua(Title $title)
{
// Cache it
$this->titleCache[$title->getPrefixedDBkey()] = $title;
if ($title->getArticleID() > 0) {
$this->idCache[$title->getArticleID()] = $title;
}
// Record a link
if ($this->getParser() && !$title->equals($this->getTitle())) {
$this->getParser()->getOutput()->addLink($title);
}
$ns = $title->getNamespace();
$ret = array('isLocal' => (bool) $title->isLocal(), 'isRedirect' => (bool) $title->isRedirect(), 'interwiki' => $title->getInterwiki(), 'namespace' => $ns, 'nsText' => $title->getNsText(), 'text' => $title->getText(), 'id' => $title->getArticleID(), 'fragment' => $title->getFragment(), 'thePartialUrl' => $title->getPartialURL());
if ($ns === NS_SPECIAL) {
$ret['exists'] = (bool) SpecialPageFactory::exists($title->getDBkey());
} else {
$ret['exists'] = $ret['id'] > 0;
}
if ($ns !== NS_FILE && $ns !== NS_MEDIA) {
$ret['fileExists'] = false;
}
return $ret;
}
示例13: fixRedirects
/**
* Insert jobs into the job queue to fix redirects to the given title
* @param string $type The reason for the fix, see message double-redirect-fixed-<reason>
* @param Title $redirTitle The title which has changed, redirects pointing to this title are fixed
*/
public static function fixRedirects($reason, $redirTitle, $destTitle = false)
{
# Need to use the master to get the redirect table updated in the same transaction
$dbw = wfGetDB(DB_MASTER);
$res = $dbw->select(array('redirect', 'page'), array('page_namespace', 'page_title'), array('page_id = rd_from', 'rd_namespace' => $redirTitle->getNamespace(), 'rd_title' => $redirTitle->getDBkey()), __METHOD__);
if (!$res->numRows()) {
return;
}
$jobs = array();
foreach ($res as $row) {
$title = Title::makeTitle($row->page_namespace, $row->page_title);
if (!$title) {
continue;
}
$jobs[] = new self($title, array('reason' => $reason, 'redirTitle' => $redirTitle->getPrefixedDBkey()));
# Avoid excessive memory usage
if (count($jobs) > 10000) {
Job::batchInsert($jobs);
$jobs = array();
}
}
Job::batchInsert($jobs);
}
示例14: doEditUpdates
/**
* Do standard deferred updates after page edit.
* Update links tables, site stats, search index and message cache.
* Purges pages that include this page if the text was changed here.
* Every 100th edit, prune the recent changes table.
*
* @param Revision $revision
* @param User $user User object that did the revision
* @param array $options Array of options, following indexes are used:
* - changed: boolean, whether the revision changed the content (default true)
* - created: boolean, whether the revision created the page (default false)
* - moved: boolean, whether the page was moved (default false)
* - restored: boolean, whether the page was undeleted (default false)
* - oldrevision: Revision object for the pre-update revision (default null)
* - oldcountable: boolean, null, or string 'no-change' (default null):
* - boolean: whether the page was counted as an article before that
* revision, only used in changed is true and created is false
* - null: if created is false, don't update the article count; if created
* is true, do update the article count
* - 'no-change': don't update the article count, ever
*/
public function doEditUpdates(Revision $revision, User $user, array $options = [])
{
global $wgRCWatchCategoryMembership, $wgContLang;
$options += ['changed' => true, 'created' => false, 'moved' => false, 'restored' => false, 'oldrevision' => null, 'oldcountable' => null];
$content = $revision->getContent();
$logger = LoggerFactory::getInstance('SaveParse');
// See if the parser output before $revision was inserted is still valid
$editInfo = false;
if (!$this->mPreparedEdit) {
$logger->debug(__METHOD__ . ": No prepared edit...\n");
} elseif ($this->mPreparedEdit->output->getFlag('vary-revision')) {
$logger->info(__METHOD__ . ": Prepared edit has vary-revision...\n");
} elseif ($this->mPreparedEdit->output->getFlag('vary-revision-id') && $this->mPreparedEdit->output->getSpeculativeRevIdUsed() !== $revision->getId()) {
$logger->info(__METHOD__ . ": Prepared edit has vary-revision-id with wrong ID...\n");
} elseif ($this->mPreparedEdit->output->getFlag('vary-user') && !$options['changed']) {
$logger->info(__METHOD__ . ": Prepared edit has vary-user and is null...\n");
} else {
wfDebug(__METHOD__ . ": Using prepared edit...\n");
$editInfo = $this->mPreparedEdit;
}
if (!$editInfo) {
// Parse the text again if needed. Be careful not to do pre-save transform twice:
// $text is usually already pre-save transformed once. Avoid using the edit stash
// as any prepared content from there or in doEditContent() was already rejected.
$editInfo = $this->prepareContentForEdit($content, $revision, $user, null, false);
}
// Save it to the parser cache.
// Make sure the cache time matches page_touched to avoid double parsing.
ParserCache::singleton()->save($editInfo->output, $this, $editInfo->popts, $revision->getTimestamp(), $editInfo->revid);
// Update the links tables and other secondary data
if ($content) {
$recursive = $options['changed'];
// bug 50785
$updates = $content->getSecondaryDataUpdates($this->getTitle(), null, $recursive, $editInfo->output);
foreach ($updates as $update) {
if ($update instanceof LinksUpdate) {
$update->setRevision($revision);
$update->setTriggeringUser($user);
}
DeferredUpdates::addUpdate($update);
}
if ($wgRCWatchCategoryMembership && $this->getContentHandler()->supportsCategories() === true && ($options['changed'] || $options['created']) && !$options['restored']) {
// Note: jobs are pushed after deferred updates, so the job should be able to see
// the recent change entry (also done via deferred updates) and carry over any
// bot/deletion/IP flags, ect.
JobQueueGroup::singleton()->lazyPush(new CategoryMembershipChangeJob($this->getTitle(), ['pageId' => $this->getId(), 'revTimestamp' => $revision->getTimestamp()]));
}
}
Hooks::run('ArticleEditUpdates', [&$this, &$editInfo, $options['changed']]);
if (Hooks::run('ArticleEditUpdatesDeleteFromRecentchanges', [&$this])) {
// Flush old entries from the `recentchanges` table
if (mt_rand(0, 9) == 0) {
JobQueueGroup::singleton()->lazyPush(RecentChangesUpdateJob::newPurgeJob());
}
}
if (!$this->exists()) {
return;
}
$id = $this->getId();
$title = $this->mTitle->getPrefixedDBkey();
$shortTitle = $this->mTitle->getDBkey();
if ($options['oldcountable'] === 'no-change' || !$options['changed'] && !$options['moved']) {
$good = 0;
} elseif ($options['created']) {
$good = (int) $this->isCountable($editInfo);
} elseif ($options['oldcountable'] !== null) {
$good = (int) $this->isCountable($editInfo) - (int) $options['oldcountable'];
} else {
$good = 0;
}
$edits = $options['changed'] ? 1 : 0;
$total = $options['created'] ? 1 : 0;
DeferredUpdates::addUpdate(new SiteStatsUpdate(0, $edits, $good, $total));
DeferredUpdates::addUpdate(new SearchUpdate($id, $title, $content));
// If this is another user's talk page, update newtalk.
// Don't do this if $options['changed'] = false (null-edits) nor if
// it's a minor edit and the user doesn't want notifications for those.
if ($options['changed'] && $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $user->getTitleKey() && !($revision->isMinor() && $user->isAllowed('nominornewtalk'))) {
$recipient = User::newFromName($shortTitle, false);
//.........这里部分代码省略.........
示例15: formatHeadings
/**
* This function accomplishes several tasks:
* 1) Auto-number headings if that option is enabled
* 2) Add an [edit] link to sections for users who have enabled the option and can edit the page
* 3) Add a Table of contents on the top for users who have enabled the option
* 4) Auto-anchor headings
*
* It loops through all headlines, collects the necessary data, then splits up the
* string and re-inserts the newly formatted headlines.
*
* @param $text String
* @param string $origText original, untouched wikitext
* @param $isMain Boolean
* @return mixed|string
* @private
*/
function formatHeadings($text, $origText, $isMain = true)
{
global $wgMaxTocLevel, $wgExperimentalHtmlIds;
# Inhibit editsection links if requested in the page
if (isset($this->mDoubleUnderscores['noeditsection'])) {
$maybeShowEditLink = $showEditLink = false;
} else {
$maybeShowEditLink = true;
/* Actual presence will depend on ParserOptions option */
$showEditLink = $this->mOptions->getEditSection();
}
if ($showEditLink) {
$this->mOutput->setEditSectionTokens(true);
}
# Get all headlines for numbering them and adding funky stuff like [edit]
# links - this is for later, but we need the number of headlines right now
$matches = array();
$numMatches = preg_match_all('/<H(?P<level>[1-6])(?P<attrib>.*?' . '>)\\s*(?P<header>[\\s\\S]*?)\\s*<\\/H[1-6] *>/i', $text, $matches);
# if there are fewer than 4 headlines in the article, do not show TOC
# unless it's been explicitly enabled.
$enoughToc = $this->mShowToc && ($numMatches >= 4 || $this->mForceTocPosition);
# Allow user to stipulate that a page should have a "new section"
# link added via __NEWSECTIONLINK__
if (isset($this->mDoubleUnderscores['newsectionlink'])) {
$this->mOutput->setNewSection(true);
}
# Allow user to remove the "new section"
# link via __NONEWSECTIONLINK__
if (isset($this->mDoubleUnderscores['nonewsectionlink'])) {
$this->mOutput->hideNewSection(true);
}
# if the string __FORCETOC__ (not case-sensitive) occurs in the HTML,
# override above conditions and always show TOC above first header
if (isset($this->mDoubleUnderscores['forcetoc'])) {
$this->mShowToc = true;
$enoughToc = true;
}
# headline counter
$headlineCount = 0;
$numVisible = 0;
# Ugh .. the TOC should have neat indentation levels which can be
# passed to the skin functions. These are determined here
$toc = '';
$full = '';
$head = array();
$sublevelCount = array();
$levelCount = array();
$level = 0;
$prevlevel = 0;
$toclevel = 0;
$prevtoclevel = 0;
$markerRegex = "{$this->mUniqPrefix}-h-(\\d+)-" . self::MARKER_SUFFIX;
$baseTitleText = $this->mTitle->getPrefixedDBkey();
$oldType = $this->mOutputType;
$this->setOutputType(self::OT_WIKI);
$frame = $this->getPreprocessor()->newFrame();
$root = $this->preprocessToDom($origText);
$node = $root->getFirstChild();
$byteOffset = 0;
$tocraw = array();
$refers = array();
foreach ($matches[3] as $headline) {
$isTemplate = false;
$titleText = false;
$sectionIndex = false;
$numbering = '';
$markerMatches = array();
if (preg_match("/^{$markerRegex}/", $headline, $markerMatches)) {
$serial = $markerMatches[1];
list($titleText, $sectionIndex) = $this->mHeadings[$serial];
$isTemplate = $titleText != $baseTitleText;
$headline = preg_replace("/^{$markerRegex}\\s*/", "", $headline);
}
if ($toclevel) {
$prevlevel = $level;
}
$level = $matches[1][$headlineCount];
if ($level > $prevlevel) {
# Increase TOC level
$toclevel++;
$sublevelCount[$toclevel] = 0;
if ($toclevel < $wgMaxTocLevel) {
$prevtoclevel = $toclevel;
$toc .= Linker::tocIndent();
//.........这里部分代码省略.........