本文整理汇总了PHP中Title::getPrefixedDBKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getPrefixedDBKey方法的具体用法?PHP Title::getPrefixedDBKey怎么用?PHP Title::getPrefixedDBKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getPrefixedDBKey方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDescription
/**
* Overrides parent class. Meant to be used in rss feed.
* Currently return the article, its debatable if thats a good idea
* or not, but not sure of what better to do. Could regex the wikitext
* and try to return the first paragraph, but thats iffy.
*
* Note, this is only called by the atom/rss feed output, not by
* the sitemap output.
* @return String
*/
public function getDescription()
{
wfProfileIn(__METHOD__);
// This is probably rather inefficient to do for several pages
// but not much worse than the rest of this extension.
$result = '';
$req = new FauxRequest(array('action' => 'parse', 'page' => $this->titleObj->getPrefixedDBKey(), 'prop' => 'text'));
$main = new ApiMain($req);
$main->execute();
$data = $main->getResultData();
if (isset($data['parse']['text']['*'])) {
$result = $this->xmlEncode($data['parse']['text']['*']);
}
wfProfileOut(__METHOD__);
return $result;
}
示例2: getContext
public function getContext(Title $title, $skinName)
{
$wrapper = new GlobalStateWrapper(['wgTitle' => $title]);
$wg = F::app()->wg;
return $wrapper->wrap(function () use($title, $wg, $skinName) {
$wikiFactoryHub = WikiFactoryHub::getInstance();
$hubService = new HubService();
$adPageTypeService = new AdEngine2PageTypeService();
$wikiaPageType = new WikiaPageType();
$sevenOneMediaCombinedUrl = null;
if (!empty($wg->AdDriverUseSevenOneMedia)) {
// TODO: implicitly gets the skin from the context!
$sevenOneMediaCombinedUrl = ResourceLoader::makeCustomURL($wg->Out, ['wikia.ext.adengine.sevenonemedia'], 'scripts');
}
$monetizationServiceAds = null;
if (!empty($wg->AdDriverUseMonetizationService) && !empty($wg->EnableMonetizationModuleExt)) {
$monetizationServiceAds = F::app()->sendRequest('MonetizationModule', 'index')->getData()['data'];
}
$langCode = $title->getPageLanguage()->getCode();
return ['opts' => $this->filterOutEmptyItems(['adsInContent' => $wg->EnableAdsInContent, 'delayBtf' => $wg->AdDriverDelayBelowTheFold, 'enableAdsInMaps' => $wg->AdDriverEnableAdsInMaps, 'pageType' => $adPageTypeService->getPageType(), 'paidAssetDropConfig' => $wg->PaidAssetDropConfig, 'showAds' => $adPageTypeService->areAdsShowableOnPage(), 'trackSlotState' => $wg->AdDriverTrackState, 'usePostScribe' => $wg->Request->getBool('usepostscribe', false)]), 'targeting' => $this->filterOutEmptyItems(['enablePageCategories' => array_search($langCode, $wg->AdPageLevelCategoryLangs) !== false, 'pageArticleId' => $title->getArticleId(), 'pageIsArticle' => !!$title->getArticleId(), 'pageIsHub' => $wikiaPageType->isWikiaHub(), 'pageName' => $title->getPrefixedDBKey(), 'pageType' => $wikiaPageType->getPageType(), 'sevenOneMediaSub2Site' => $wg->AdDriverSevenOneMediaOverrideSub2Site, 'skin' => $skinName, 'wikiCategory' => $wikiFactoryHub->getCategoryShort($wg->CityId), 'wikiCustomKeyValues' => $wg->DartCustomKeyValues, 'wikiDbName' => $wg->DBname, 'wikiDirectedAtChildren' => $wg->WikiDirectedAtChildrenByFounder || $wg->WikiDirectedAtChildrenByStaff, 'wikiIsCorporate' => $wikiaPageType->isCorporatePage(), 'wikiIsTop1000' => $wg->AdDriverWikiIsTop1000, 'wikiLanguage' => $langCode, 'wikiVertical' => $hubService->getCategoryInfoForCity($wg->CityId)->cat_name]), 'providers' => $this->filterOutEmptyItems(['monetizationService' => $wg->AdDriverUseMonetizationService, 'monetizationServiceAds' => $monetizationServiceAds, 'sevenOneMedia' => $wg->AdDriverUseSevenOneMedia, 'sevenOneMediaCombinedUrl' => $sevenOneMediaCombinedUrl, 'taboola' => $wg->AdDriverUseTaboola]), 'slots' => $this->filterOutEmptyItems(['exitstitial' => $wg->EnableOutboundScreenExt, 'exitstitialRedirectDelay' => $wg->OutboundScreenRedirectDelay, 'invisibleHighImpact' => $wg->AdDriverEnableInvisibleHighImpactSlot]), 'forcedProvider' => $wg->AdDriverForcedProvider];
});
}
示例3: inReviewNamespace
/**
* Is this page in reviewable namespace?
* Note: this checks $wgFlaggedRevsWhitelist
* @param Title, $title
* @return bool
*/
public static function inReviewNamespace(Title $title)
{
global $wgFlaggedRevsWhitelist;
if (in_array($title->getPrefixedDBKey(), $wgFlaggedRevsWhitelist)) {
return false;
// page is one exemption whitelist
}
$ns = $title->getNamespace() == NS_MEDIA ? NS_FILE : $title->getNamespace();
// treat NS_MEDIA as NS_FILE
return in_array($ns, self::getReviewNamespaces());
}
示例4: makeHeader
/**
* Helper function for getParsedcontent for making subpage section headers
* @param $contentItem array of data for the content item we're generating the header for
* @return string html (NOTE THIS IS AN OPEN DIV)
*/
protected function makeHeader(Title $title, array $contentItem)
{
global $wgParser;
static $tocLinks = [];
// All used ids for the sections for the toc
$linkRenderer = $wgParser->getLinkRenderer();
$spTitle = Title::newFromText($contentItem['title']);
$spRev = Revision::newFromTitle($spTitle);
// Get display name
if (isset($contentItem['displayTitle'])) {
$spPage = $contentItem['displayTitle'];
} else {
$spPage = $spTitle->getSubpageText();
}
// Generate an id for the section for anchors
// Make sure this matches the ToC anchor generation
$spPageLink = Sanitizer::escapeId(htmlspecialchars($spPage));
$spPageLink2 = $spPageLink;
$spPageLinkCounter = 1;
while (in_array($spPageLink2, $tocLinks)) {
$spPageLink2 = $spPageLink . $spPageLinkCounter;
$spPageLinkCounter++;
}
$tocLinks[] = $spPageLink2;
// Get editsection-style links for the subpage
$sectionLinks = [];
$sectionLinksText = '';
if (isset($spRev)) {
$sectionLinks['viewLink'] = $linkRenderer->makeLink($spTitle, wfMessage('collaborationkit-hub-subpage-view')->inContentLanguage()->text());
}
if ($spTitle->userCan('edit')) {
if (isset($spRev)) {
$linkString = 'edit';
// TODO get appropriate edit link if it's something weird
$sectionLinks['edit'] = $linkRenderer->makeLink($spTitle, wfMessage($linkString)->inContentLanguage()->text(), [], ['action' => 'edit']);
} else {
$linkString = 'create';
$sectionLinks['edit'] = $linkRenderer->makeLink(SpecialPage::getTitleFor('CreateHubFeature'), wfMessage($linkString)->inContentLanguage()->text(), [], ['collaborationhub' => $title->getPrefixedDBKey(), 'feature' => $spTitle->getSubpageText()]);
}
}
if ($title->userCan('edit')) {
$sectionLinks['removeLink'] = $linkRenderer->makeLink($title, wfMessage('collaborationkit-hub-subpage-remove')->inContentLanguage()->text(), [], ['action' => 'edit']);
}
foreach ($sectionLinks as $sectionLink) {
$sectionLinksText .= $this->makeEditSectionLink($sectionLink);
}
$sectionLinksText = Html::rawElement('span', ['class' => 'mw-editsection'], $sectionLinksText);
// Assemble header
// Open general section here since we have the id here
$html = Html::openElement('div', ['class' => 'mw-ck-hub-section', 'id' => $spPageLink2]);
$html .= Html::rawElement('h2', [], Html::element('span', ['class' => 'mw-headline'], $spPage) . $sectionLinksText);
OutputPage::setupOOUI();
return $html;
}
示例5: getForm
/**
* Get "create new repo" form
* @return String
*/
private function getForm()
{
global $wgScript;
return Xml::fieldset(wfMsg('repoadmin-new-legend')) . Xml::openElement('form', array('method' => 'get', 'action' => $wgScript)) . Html::hidden('title', $this->title->getPrefixedDBKey()) . Xml::inputLabel(wfMsg('repoadmin-new-label'), 'repo', 'repo') . Xml::submitButton(wfMsg('repoadmin-new-button')) . '</form></fieldset>';
}
示例6: getJSVars
/**
* Get an array containing the variables to be set in mw.config in JavaScript.
*
* DO NOT CALL THIS FROM OUTSIDE OF THIS CLASS OR Skin::makeGlobalVariablesScript().
* This is only public until that function is removed. You have been warned.
*
* Do not add things here which can be evaluated in ResourceLoaderStartupScript
* - in other words, page-independent/site-wide variables (without state).
* You will only be adding bloat to the html page and causing page caches to
* have to be purged on configuration changes.
* @return array
*/
public function getJSVars()
{
global $wgUseAjax, $wgEnableMWSuggest;
$latestRevID = 0;
$pageID = 0;
$canonicalName = false;
# bug 21115
$title = $this->getTitle();
$ns = $title->getNamespace();
$nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $title->getNsText();
// Get the relevant title so that AJAX features can use the correct page name
// when making API requests from certain special pages (bug 34972).
$relevantTitle = $this->getSkin()->getRelevantTitle();
if ($ns == NS_SPECIAL) {
list($canonicalName, ) = SpecialPageFactory::resolveAlias($title->getDBkey());
} elseif ($this->canUseWikiPage()) {
$wikiPage = $this->getWikiPage();
$latestRevID = $wikiPage->getLatest();
$pageID = $wikiPage->getId();
}
$lang = $title->getPageLanguage();
// Pre-process information
$separatorTransTable = $lang->separatorTransformTable();
$separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
$compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
$digitTransTable = $lang->digitTransformTable();
$digitTransTable = $digitTransTable ? $digitTransTable : array();
$compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
$vars = array('wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $canonicalName, 'wgNamespaceNumber' => $title->getNamespace(), 'wgPageName' => $title->getPrefixedDBKey(), 'wgTitle' => $title->getText(), 'wgCurRevisionId' => $latestRevID, 'wgArticleId' => $pageID, 'wgIsArticle' => $this->isArticle(), 'wgAction' => Action::getActionName($this->getContext()), 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), 'wgCategories' => $this->getCategories(), 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', 'wgPageContentLanguage' => $lang->getCode(), 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgRelevantPageName' => $relevantTitle->getPrefixedDBKey());
if ($lang->hasVariants()) {
$vars['wgUserVariant'] = $lang->getPreferredVariant();
}
foreach ($title->getRestrictionTypes() as $type) {
$vars['wgRestriction' . ucfirst($type)] = $title->getRestrictions($type);
}
if ($wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption('disablesuggest', false)) {
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($this->getUser());
}
if ($title->isMainPage()) {
$vars['wgIsMainPage'] = true;
}
if ($this->mRedirectedFrom) {
$vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBKey();
}
// Allow extensions to add their custom variables to the mw.config map.
// Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
// page-dependant but site-wide (without state).
// Alternatively, you may want to use OutputPage->addJsConfigVars() instead.
wfRunHooks('MakeGlobalVariablesScript', array(&$vars, $this));
// Merge in variables from addJsConfigVars last
return array_merge($vars, $this->mJsConfigVars);
}
示例7: wfLanguageSelectorHTML
function wfLanguageSelectorHTML(Title $title, $style = null, $class = null, $selectorstyle = null, $buttonstyle = null, $showCode = null)
{
global $wgLang, $wgContLang, $wgScript, $wgLanguageSelectorShowCode;
if ($showCode === null) {
$showCode = $wgLanguageSelectorShowCode;
}
static $id = 0;
$id += 1;
$code = $wgLang->getCode();
$html = '';
$html .= Xml::openElement('span', array('id' => 'languageselector-box-' . $id, 'class' => 'languageselector ' . $class, 'style' => $style));
$html .= Xml::openElement('form', array('name' => 'languageselector-form-' . $id, 'id' => 'languageselector-form-' . $id, 'method' => 'get', 'action' => $wgScript, 'style' => 'display:inline;'));
$html .= Html::Hidden('title', $title->getPrefixedDBKey());
$html .= Xml::openElement('select', array('name' => 'setlang', 'id' => 'languageselector-select-' . $id, 'style' => $selectorstyle));
foreach (wfGetLanguageSelectorLanguages() as $ln) {
$name = $wgContLang->getLanguageName($ln);
if ($showCode) {
$name = wfBCP47($ln) . ' - ' . $name;
}
$html .= Xml::option($name, $ln, $ln == $code);
}
$html .= Xml::closeElement('select');
$html .= Xml::submitButton(wfMsg('languageselector-setlang'), array('id' => 'languageselector-commit-' . $id, 'style' => $buttonstyle));
$html .= Xml::closeElement('form');
$html .= Xml::closeElement('span');
return $html;
}
示例8: addQuickFeedback
/**
* Adds a brief feedback form to a page.
* @param OutputPage $out
* @param bool $top, should this form always go on top?
* @param Title $title
*/
protected static function addQuickFeedback( &$data, $top = false, $title ) {
global $wgOut, $wgUser, $wgFeedbackTags;
# Are there any reader input tags?
if( empty($wgFeedbackTags) ) {
return false;
}
# Revision being displayed
$id = $wgOut->getRevisionId();
# Load required messages
$reviewTitle = SpecialPage::getTitleFor( 'ReaderFeedback' );
$action = $reviewTitle->getLocalUrl( 'action=submit' );
$form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action,
'id' => 'mw-feedbackform' ) );
$form .= Xml::openElement( 'fieldset', array('class' => 'feedback_reviewform noprint') );
$form .= "<legend><strong>" . wfMsgHtml( 'readerfeedback' ) . "</strong></legend>\n";
# Avoid clutter
if( !$wgUser->isAllowed('review') ) {
$form .= wfMsgExt( 'readerfeedback-text', array('parse') );
}
$form .= Xml::openElement( 'span', array('id' => 'mw-feedbackselects') );
# Loop through all different flag types
foreach( ReaderFeedback::getFeedbackTags() as $quality => $levels ) {
$selected = ( isset($flags[$quality]) && $flags[$quality] > 0 ) ? $flags[$quality] : -1;
$form .= "<b>" . Xml::label( wfMsgHtml("readerfeedback-$quality"), "wp$quality" ) . ":</b>";
$attribs = array( 'name' => "wp$quality", 'id' => "wp$quality",
'onchange' => "updateFeedbackForm()" );
$form .= ' ' . Xml::openElement( 'select', $attribs );
$levels = array_reverse($levels,true);
foreach( $levels as $i => $name ) {
$optionClass = array( 'class' => "rfb-rating-option-$i" );
$form .= Xml::option( wfMsg("readerfeedback-level-$i"), $i, ($i == $selected), $optionClass ) ."\n";
}
$form .= Xml::option( wfMsg("readerfeedback-level-none"), -1, (-1 == $selected) ) ."\n";
$form .= Xml::closeElement( 'select' )."\n";
}
$form .= Xml::closeElement( 'span' );
$form .= Xml::submitButton( wfMsg('readerfeedback-submit'),
array('id' => 'submitfeedback','accesskey' => wfMsg('readerfeedback-ak-review'),
'title' => wfMsg('readerfeedback-tt-review').' ['.wfMsg('readerfeedback-ak-review').']' )
);
# Hidden params
$form .= Html::hidden( 'title', $reviewTitle->getPrefixedText() ) . "\n";
$form .= Html::hidden( 'target', $title->getPrefixedDBKey() ) . "\n";
$form .= Html::hidden( 'oldid', $id ) . "\n";
$form .= Html::hidden( 'validatedParams', ReaderFeedbackPage::validationKey( $id, $wgUser->getId() ) );
$form .= Html::hidden( 'action', 'submit') . "\n";
$form .= Html::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n";
# Honeypot input
$form .= Xml::input( 'commentary', 12, '', array('style' => 'display:none;') ) . "\n";
$form .= Xml::closeElement( 'fieldset' );
$form .= Xml::closeElement( 'form' );
if( $top ) {
$wgOut->prependHTML( $form );
} else {
$data .= $form;
}
return true;
}
示例9: getDBPrefixedTitle
/**
* Get the DB prefixed title
*
* @return String the prefixed title, with underscores and
* any interwiki and namespace prefixes
*/
public function getDBPrefixedTitle()
{
return $this->Title->getPrefixedDBKey();
}
示例10: __construct
/**
* Constructor for a single item in the feed. Requires the URI of the item.
*/
public function __construct(Title $t, $c, $d)
{
$this->title = $t;
$this->uri = $t->getFullURL();
$this->label = $t->getText();
$article = null;
if (count($c) == 0) {
$article = new Article($t);
$this->creator = array();
$this->creator[] = $article->getUserText();
} else {
$this->creator = $c;
}
$this->date = array();
if (count($d) == 0) {
if (is_null($article)) {
$article = new Article($t);
}
$this->date[] = date("c", strtotime($article->getTimestamp()));
} else {
foreach ($d as $date) {
$this->date[] = $date;
}
}
// get content
if ($t->getNamespace() == NS_MAIN) {
$this->articlename = ':' . $t->getDBkey();
} else {
$this->articlename = $t->getPrefixedDBKey();
}
}