本文整理汇总了PHP中Title::getFullText方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getFullText方法的具体用法?PHP Title::getFullText怎么用?PHP Title::getFullText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getFullText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showCode
/**
* Look for the requested qrcode file. If we don't have the code on file,
* first generate then publish it.
*/
public function showCode($label = false)
{
// Check for a provided label and use the page URL as default (but force protocol if requested)
if ($label) {
$this->_label = $label;
// should we sanitize this?
$this->_uploadComment = $label;
} else {
$url = parse_url($this->_title->getFullURL());
$url['scheme'] = $this->_scheme ? $this->_scheme : $url['scheme'];
//$this->_label = http_build_url($url); // http_build_url is part of pecl_http >= 0.21.0 :(
$this->_label = $url['scheme'] . '://' . $url['host'] . (isset($url['port']) ? $url['port'] : '') . (isset($url['path']) ? $url['path'] : '') . (isset($url['query']) ? '?' . $url['query'] : '') . (isset($url['fragment']) ? '#' . $url['fragment'] : '');
$this->_uploadComment = 'Encoded URL for ' . $this->_title->getFullText();
}
// Use this page's title as part of the filename (Also regenerates qrcodes when the label changes).
$this->_dstFileName = 'QR-' . md5($this->_label) . '.png';
$file = wfFindFile($this->_dstFileName);
// Shortcut for RepoGroup::singleton()->findFile()
if ($file && $file->isVisible()) {
wfDebug("QrCode::showCode: Requested file " . $this->_dstFileName . " already exists. Displaying image.\n");
return $this->_displayImage($file);
} else {
wfDebug("QrCode::showCode: Requested file " . $this->_dstFileName . " is new and needs to be generated.\n");
$this->_generate();
return;
}
}
示例2: mGetText
/**
* Get the text to display in the language box for specific language and
* level.
*
* @param $name string
* @param $language String: Language code of language to use.
* @param $level String: Level to use.
* @return String: Text for display, in wikitext format.
*/
protected static function mGetText($name, $language, $level)
{
wfProfileIn(__METHOD__);
global $wgBabelMainCategory, $wgBabelCategoryNames;
if ($wgBabelCategoryNames[$level] === false) {
$categoryLevel = self::$title->getFullText();
} else {
$categoryLevel = ':Category:' . self::mReplaceCategoryVariables($wgBabelCategoryNames[$level], $language);
}
if ($wgBabelMainCategory === false) {
$categoryMain = self::$title->getFullText();
} else {
$categoryMain = ':Category:' . self::mReplaceCategoryVariables($wgBabelMainCategory, $language);
}
// Give grep a chance to find the usages:
// babel-0-n, babel-1-n, babel-2-n, babel-3-n, babel-4-n, babel-5-n, babel-N-n
$text = wfMessage("babel-{$level}-n", $categoryLevel, $categoryMain, '', self::$title->getDBkey())->inLanguage($language)->text();
$fallbackLanguage = Language::getFallbackfor($language);
$fallback = wfMessage("babel-{$level}-n", $categoryLevel, $categoryMain, '', self::$title->getDBkey())->inLanguage($fallbackLanguage ? $fallbackLanguage : $language)->text();
// Give grep a chance to find the usages:
// babel-0, babel-1, babel-2, babel-3, babel-4, babel-5, babel-N
if ($text == $fallback) {
$text = wfMessage("babel-{$level}", $categoryLevel, $categoryMain, $name, self::$title->getDBkey())->inLanguage($language)->text();
}
wfProfileOut(__METHOD__);
return $text;
}
示例3: getCurrentRatingForTag
/**
* Returns the data for the tag in an array, or false is there is no data.
*
* @since 0.1
*
* @param Title $titleObject
* @param string $tagName
*
* @return false or array
*/
protected static function getCurrentRatingForTag(Title $titleObject, $tagName)
{
$title = $titleObject->getFullText();
if (!array_key_exists($title, self::$pageRatings)) {
self::$pageRatings[$title] = array();
// The keys are the tag ids, but they are not known here, so change to tag names, which are known.
foreach (self::getPageRatings($titleObject) as $tagId => $tagData) {
self::$pageRatings[$title][$tagData['name']] = array_merge(array('id' => $tagId), $tagData);
}
}
return array_key_exists($tagName, self::$pageRatings[$title]) ? self::$pageRatings[$title][$tagName] : false;
}
示例4: displayDictionaryPage
/**
* Displays some shorts statistics about the dictionary page.
*
* @since 0.4
*
* @param Article $article
* @param Title $title
*/
protected static function displayDictionaryPage(Article &$article, Title $title)
{
global $wgOut, $wgLang, $wgUser, $egLiveTranslateLanguages;
$dbr = wfGetDb(DB_SLAVE);
$res = $dbr->select('live_translate_memories', array('memory_lang_count', 'memory_tu_count'), array('memory_location' => $title->getFullText()), array('LIMIT' => 1));
foreach ($res as $tm) {
break;
}
if ($tm->memory_tu_count == 0) {
$wgOut->addWikiMsg('livetranslate-dictionary-empty');
} else {
$wgOut->addWikiMsg('livetranslate-dictionary-count', $wgLang->formatNum($tm->memory_tu_count), $wgLang->formatNum($tm->memory_lang_count));
/*
$notAllowedLanguages = array();
foreach ( $tus[0]->getVariants() as $languageCode => $translations ) {
$languageCode = strtolower( $languageCode );
$mappings = LiveTranslateFunctions::getInputLangMapping();
if ( array_key_exists( $languageCode, $mappings ) ) {
$languageCode = $mappings[$languageCode];
}
if ( !in_array( $languageCode, $egLiveTranslateLanguages ) ) {
$notAllowedLanguages[] = $languageCode;
}
}
if ( count( $notAllowedLanguages ) > 0 ) {
$languages = Language::getLanguageNames( false );
foreach ( $notAllowedLanguages as &$notAllowedLang ) {
if ( array_key_exists( $notAllowedLang, $languages ) ) {
$notAllowedLang = $languages[$notAllowedLang];
}
}
$wgOut->addHTML(
Html::element(
'span',
array( 'style' => 'color:darkred' ),
wfMsgExt( 'livetranslate-dictionary-unallowed-langs', 'parsemag', $wgLang->listToText( $notAllowedLanguages ), count( $notAllowedLanguages ) )
)
);
}
*/
}
if ($wgUser->isAllowed('managetms')) {
$wgOut->addHTML(Html::element('a', array('href' => Title::newFromText('Special:LiveTranslate')->getInternalURL()), wfMsg('livetranslate-dictionary-goto-edit')));
}
}
示例5: makeRedirectContent
/**
* Returns a WikitextContent object representing a redirect to the given destination page.
*
* @param Title $destination The page to redirect to.
* @param string $text Text to include in the redirect, if possible.
*
* @return Content
*
* @see ContentHandler::makeRedirectContent
*/
public function makeRedirectContent(Title $destination, $text = '')
{
$optionalColon = '';
if ($destination->getNamespace() == NS_CATEGORY) {
$optionalColon = ':';
} else {
$iw = $destination->getInterwiki();
if ($iw && Language::fetchLanguageName($iw, null, 'mw')) {
$optionalColon = ':';
}
}
$mwRedir = MagicWord::get('redirect');
$redirectText = $mwRedir->getSynonym(0) . ' [[' . $optionalColon . $destination->getFullText() . ']]';
if ($text != '') {
$redirectText .= "\n" . $text;
}
return new WikitextContent($redirectText);
}
示例6: addRedirectLink
/**
* Add redirect link to the article
* @param Title $title
* @param Title $newTitle
* @return Status $status
*/
public function addRedirectLink($title, $newTitle)
{
wfProfileIn(__METHOD__);
$article = new Article($title);
$content = "#REDIRECT [[{$newTitle->getPrefixedText()}]]";
$summary = wfMessage('autoredircomment', $title->getFullText())->inContentLanguage()->text();
$status = $article->doEdit($content, $summary);
wfProfileOut(__METHOD__);
return $status;
}
示例7: hookLinkBegin
/**
* @global bool $wgLanguageLinks;
* @param Skin $skin
* @param Title $target
* @param string $text
* @param array $customAttribs
* @param array $query
* @param array $options
* @param mixed $ret default: null
* @return bool
*/
public static function hookLinkBegin($skin, $target, &$text, &$customAttribs, &$query, &$options, &$ret)
{
# first make link known.
$brokenKey = array_search(self::LINK_OPTION_BROKEN, $options);
if ($brokenKey !== false) {
$options[$brokenKey] = self::LINK_OPTION_KNOWN;
} else {
if (array_search(self::LINK_OPTION_KNOWN, $options) === false) {
$options[] = self::LINK_OPTION_KNOWN;
}
}
$targetNamespace = $target->getNamespace();
if ($targetNamespace == NS_FILE || ${$targetNamespace} == NS_FILE_TALK) {
global $wgFileLinks;
return $wgFileLinks;
} else {
if ($targetNamespace == NS_CATEGORY || $targetNamespace == NS_CATEGORY_TALK) {
global $wgCategoryLinks;
return $wgCategoryLinks;
}
}
# try detect language link
$titleText = $target->getUserCaseDBKey();
#echo PHP_EOL . "TitleText: {$titleText} -- NameSpace: {$target->getNamespaceKey()}";
$titleExploded = explode(':', $titleText, 2);
if (array_key_exists(1, $titleExploded)) {
$languageKey = $titleExploded[0];
#echo PHP_EOL . "Title maybe a LanguageLink: {$languageKey}";
if (array_key_exists($languageKey, self::getLanguageNames())) {
global $wgLanguageLinks;
self::$detectedLanguageLinks[] = $target->getFullText();
#echo PHP_EOL . "LanguageLink detected: {$languageKey} $titleExploded[1]";
return $wgLanguageLinks;
} else {
return true;
}
} else {
return true;
}
}
示例8: getEditToken
/**
* Obtains the needed edit token by making an HTTP GET request
* to the remote wikis API.
*
* @since 0.5
*
* @param Title $title
* @param string $target
*
* @return string or false
*/
protected function getEditToken(Title $title, $target)
{
$requestData = array('action' => 'query', 'format' => 'json', 'intoken' => 'edit', 'prop' => 'info', 'titles' => $title->getFullText());
$parts = array();
foreach ($requestData as $key => $value) {
$parts[] = $key . '=' . urlencode($value);
}
$req = PushFunctions::getHttpRequest($target . '?' . implode('&', $parts), array('method' => 'GET', 'timeout' => 'default'));
if (array_key_exists($target, $this->cookieJars)) {
$req->setCookieJar($this->cookieJars[$target]);
}
$status = $req->execute();
$response = $status->isOK() ? FormatJson::decode($req->getContent()) : null;
$token = false;
if (!is_null($response) && property_exists($response, 'query') && property_exists($response->query, 'pages') && count($response->query->pages) > 0) {
foreach ($response->query->pages as $key => $value) {
$first = $key;
break;
}
if (property_exists($response->query->pages->{$first}, 'edittoken')) {
$token = $response->query->pages->{$first}->edittoken;
} elseif (!is_null($response) && property_exists($response, 'query') && property_exists($response->query, 'error')) {
$this->dieUsage($response->query->error->message, 'token-request-failed');
} else {
$this->dieUsage(wfMsg('push-special-err-token-failed'), 'token-request-failed');
}
} else {
$this->dieUsage(wfMsg('push-special-err-token-failed'), 'token-request-failed');
}
return $token;
}
示例9: getSecondFooter
/**
* Get some extra buttons for another footer
* @param $title Title
* @return string
*/
protected function getSecondFooter(Title $title)
{
$html = '';
if ($title->userCan('edit')) {
$html .= new OOUI\ButtonWidget(['label' => wfMessage('collaborationkit-hub-manage')->inContentLanguage()->text(), 'href' => $title->getLocalURL(['action' => 'edit']), 'flags' => ['primary', 'progressive']]);
// TODO make sure they have create permission, too
$html .= new OOUI\ButtonWidget(['label' => wfMessage('collaborationkit-hub-addpage')->inContentLanguage()->text(), 'href' => SpecialPage::getTitleFor('CreateHubFeature')->getFullUrl(['collaborationhub' => $title->getFullText()]), 'flags' => ['primary', 'progressive']]);
}
return $html;
}
示例10: getInterWikiaURL
public static function getInterWikiaURL(Title &$title, &$url, $query)
{
global $wgArticlePath, $wgScriptPath;
if (in_array($title->mInterwiki, array('w', 'wikia', 'wikicities'))) {
$aLinkParts = explode(':', $title->getFullText());
if ($aLinkParts[1] == 'c') {
$iCityId = self::isWikiExists($aLinkParts[2]);
if ($iCityId) {
$sArticlePath = WikiFactory::getVarValueByName('wgArticlePath', $iCityId);
//I've replaced wgArticlePath to hardcoded value in order to fix FogBug:3066
//This is a persistent issue with getting default value of variable that is not set in WikiFactory
//Similar problem exists when displaying "default value" in WikiFactory - it's not the real default (taken from file)
//it's value for current wiki (community for WikiFactory, www.wikia.com for 3066 bug)
//anyway - current value in CommonSettings.php for wgArticlePath is '/wiki/$1' that's why this hardcoded
//fix will work.. for now.. it would be nice to introduce some function to get REAL DEFAULT VALUE for any variable
//Marooned
$sArticlePath = !empty($sArticlePath) ? $sArticlePath : '/wiki/$1';
//$wgArticlePath;
/* $wgScriptPath is already included in city_url
$sScriptPath = WikiFactory::getVarValueByName('wgScriptPath', $iCityId);
$sScriptPath = !empty($sScriptPath) ? $sScriptPath : $wgScriptPath;
*/
if (!empty($sArticlePath)) {
$sArticleTitle = '';
for ($i = 3; $i < count($aLinkParts); $i++) {
$sArticleTitle .= (!empty($sArticleTitle) ? ':' : '') . $aLinkParts[$i];
}
//RT#54264,#41254
$sArticleTitle = str_replace(' ', '_', $sArticleTitle);
$sArticleTitle = urlencode($sArticleTitle);
$sCityUrl = self::getCityUrl($iCityId);
if (!empty($sCityUrl)) {
$url = str_replace('$1', $sArticleTitle, $sArticlePath);
$url = $sCityUrl . $url;
}
}
}
}
}
return true;
}
示例11: getTalkButton
/**
* Returns an array with details for a talk button.
* @param Title $talkTitle Title object of the talk page
* @param array $talkButton Array with data of desktop talk button
* @return array
*/
protected function getTalkButton($talkTitle, $talkButton)
{
return array('attributes' => array('href' => $talkTitle->getLinkURL(), 'data-title' => $talkTitle->getFullText(), 'class' => MobileUI::iconClass('talk', 'before', 'talk')), 'label' => $talkButton['text']);
}
示例12: getTitleString
/**
* Provided a page, returns the string value of that page's title
* This allows us to accommodate unconventional locations for titles
* @param \Title $title
* @return string
*/
protected function getTitleString(\Title $title)
{
wfProfileIn(__METHOD__);
if (in_array($title->getNamespace(), array(NS_WIKIA_FORUM_BOARD_THREAD, NS_USER_WALL_MESSAGE))) {
$wm = \WallMessage::newFromId($title->getArticleID());
if ($wm) {
$wm->load();
if (!$wm->isMain() && ($main = $wm->getTopParentObj()) && !empty($main)) {
$main->load();
$wm = $main;
}
wfProfileOut(__METHOD__);
return (string) $wm->getMetaTitle();
} else {
\Wikia\Logger\WikiaLogger::instance()->warning('Null WallMessage', ['message_id' => $title->getArticleID()]);
}
}
wfProfileOut(__METHOD__);
return $title->getFullText();
}
示例13: statelessFetchTemplate
/**
* @param Title $title
* @param bool $parser
*
* @return array
*/
static function statelessFetchTemplate($title, $parser = false)
{
$text = "Content of ''" . $title->getFullText() . "''";
$deps = [];
return ['text' => $text, 'finalTitle' => $title, 'deps' => $deps];
}
示例14: newFromRow
/**
* Initialize a new instance from a database row.
*
* @access public
* @param array Database Row
* @param object \DPL\Parameters Object
* @param object Mediawiki Title Object
* @param integer Page Namespace ID
* @param string Page Title as Selected from Query
* @return object \DPL\Article Object
*/
public static function newFromRow($row, Parameters $parameters, \Title $title, $pageNamespace, $pageTitle)
{
global $wgLang, $wgContLang;
$article = new Article($title, $pageNamespace);
$titleText = $title->getText();
if ($parameters->getParameter('shownamespace') === true) {
$titleText = $title->getPrefixedText();
}
if ($parameters->getParameter('replaceintitle') !== null) {
$titleText = preg_replace($parameters->getParameter('replaceintitle')[0], $parameters->getParameter('replaceintitle')[1], $titleText);
}
//Chop off title if longer than the 'titlemaxlen' parameter.
if ($parameters->getParameter('titlemaxlen') !== null && strlen($titleText) > $parameters->getParameter('titlemaxlen')) {
$titleText = substr($titleText, 0, $parameters->getParameter('titlemaxlen')) . '...';
}
if ($parameters->getParameter('showcurid') === true && isset($row['page_id'])) {
$articleLink = '[' . $title->getLinkURL(['curid' => $row['page_id']]) . ' ' . htmlspecialchars($titleText) . ']';
} else {
$articleLink = '[[' . ($parameters->getParameter('escapelinks') && ($pageNamespace == NS_CATEGORY || $pageNamespace == NS_FILE) ? ':' : '') . $title->getFullText() . '|' . htmlspecialchars($titleText) . ']]';
}
$article->mLink = $articleLink;
//get first char used for category-style output
if (isset($row['sortkey'])) {
$article->mStartChar = $wgContLang->convert($wgContLang->firstChar($row['sortkey']));
} else {
$article->mStartChar = $wgContLang->convert($wgContLang->firstChar($pageTitle));
}
$article->mID = intval($row['page_id']);
//External link
if (isset($row['el_to'])) {
$article->mExternalLink = $row['el_to'];
}
//SHOW PAGE_COUNTER
if (isset($row['page_counter'])) {
$article->mCounter = $row['page_counter'];
}
//SHOW PAGE_SIZE
if (isset($row['page_len'])) {
$article->mSize = $row['page_len'];
}
//STORE initially selected PAGE
if (count($parameters->getParameter('linksto')) || count($parameters->getParameter('linksfrom'))) {
if (!isset($row['sel_title'])) {
$article->mSelTitle = 'unknown page';
$article->mSelNamespace = 0;
} else {
$article->mSelTitle = $row['sel_title'];
$article->mSelNamespace = $row['sel_ns'];
}
}
//STORE selected image
if (count($parameters->getParameter('imageused')) > 0) {
if (!isset($row['image_sel_title'])) {
$article->mImageSelTitle = 'unknown image';
} else {
$article->mImageSelTitle = $row['image_sel_title'];
}
}
if ($parameters->getParameter('goal') != 'categories') {
//REVISION SPECIFIED
if ($parameters->getParameter('lastrevisionbefore') || $parameters->getParameter('allrevisionsbefore') || $parameters->getParameter('firstrevisionsince') || $parameters->getParameter('allrevisionssince')) {
$article->mRevision = $row['rev_id'];
$article->mUser = $row['rev_user_text'];
$article->mDate = $row['rev_timestamp'];
$article->mComment = $row['rev_comment'];
}
//SHOW "PAGE_TOUCHED" DATE, "FIRSTCATEGORYDATE" OR (FIRST/LAST) EDIT DATE
if ($parameters->getParameter('addpagetoucheddate')) {
$article->mDate = $row['page_touched'];
} elseif ($parameters->getParameter('addfirstcategorydate')) {
$article->mDate = $row['cl_timestamp'];
} elseif ($parameters->getParameter('addeditdate') && isset($row['rev_timestamp'])) {
$article->mDate = $row['rev_timestamp'];
} elseif ($parameters->getParameter('addeditdate') && isset($row['page_touched'])) {
$article->mDate = $row['page_touched'];
}
//Time zone adjustment
if ($article->mDate) {
$article->mDate = $wgLang->userAdjust($article->mDate);
}
if ($article->mDate && $parameters->getParameter('userdateformat')) {
//Apply the userdateformat
$article->myDate = gmdate($parameters->getParameter('userdateformat'), wfTimeStamp(TS_UNIX, $article->mDate));
}
// CONTRIBUTION, CONTRIBUTOR
if ($parameters->getParameter('addcontribution')) {
$article->mContribution = $row['contribution'];
$article->mContributor = $row['contributor'];
$article->mContrib = substr('*****************', 0, round(log($row['contribution'])));
//.........这里部分代码省略.........
示例15: getSlackTitleText
/**
* Gets nice HTML text for title object containing the link to article page
* and also into edit, delete and article history pages.
*/
function getSlackTitleText(Title $title)
{
global $wgWikiUrl, $wgWikiUrlEnding, $wgWikiUrlEndingEditArticle, $wgWikiUrlEndingDeleteArticle, $wgWikiUrlEndingHistory;
$titleName = $title->getFullText();
return sprintf("%s (%s | %s | %s)", "<" . $wgWikiUrl . $wgWikiUrlEnding . $titleName . "|" . $titleName . ">", "<" . $wgWikiUrl . $wgWikiUrlEnding . $titleName . "&" . $wgWikiUrlEndingEditArticle . "|edit>", "<" . $wgWikiUrl . $wgWikiUrlEnding . $titleName . "&" . $wgWikiUrlEndingDeleteArticle . "|delete>", "<" . $wgWikiUrl . $wgWikiUrlEnding . $titleName . "&" . $wgWikiUrlEndingHistory . "|history>");
}