本文整理汇总了PHP中ParserOutput::getCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOutput::getCategories方法的具体用法?PHP ParserOutput::getCategories怎么用?PHP ParserOutput::getCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOutput
的用法示例。
在下文中一共展示了ParserOutput::getCategories方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LinksUpdate
/**
* Constructor
*
* @param Title $title Title of the page we're updating
* @param ParserOutput $parserOutput Output from a full parse of this page
* @param bool $recursive Queue jobs for recursive updates?
*/
function LinksUpdate($title, $parserOutput, $recursive = true)
{
global $wgAntiLockFlags;
if ($wgAntiLockFlags & ALF_NO_LINK_LOCK) {
$this->mOptions = array();
} else {
$this->mOptions = array('FOR UPDATE');
}
$this->mDb = wfGetDB(DB_MASTER);
if (!is_object($title)) {
throw new MWException("The calling convention to LinksUpdate::LinksUpdate() has changed. " . "Please see Article::editUpdates() for an invocation example.\n");
}
$this->mTitle = $title;
$this->mId = $title->getArticleID();
$this->mParserOutput = $parserOutput;
$this->mLinks = $parserOutput->getLinks();
$this->mImages = $parserOutput->getImages();
$this->mTemplates = $parserOutput->getTemplates();
$this->mExternals = $parserOutput->getExternalLinks();
$this->mCategories = $parserOutput->getCategories();
$this->mProperties = $parserOutput->getProperties();
# Convert the format of the interlanguage links
# I didn't want to change it in the ParserOutput, because that array is passed all
# the way back to the skin, so either a skin API break would be required, or an
# inefficient back-conversion.
$ill = $parserOutput->getLanguageLinks();
$this->mInterlangs = array();
foreach ($ill as $link) {
list($key, $title) = explode(':', $link, 2);
$this->mInterlangs[$key] = $title;
}
$this->mRecursive = $recursive;
$this->mTouchTmplLinks = false;
wfRunHooks('LinksUpdateConstructed', array(&$this));
}
示例2: __construct
public function __construct(Title $title, ParserOutput $stableOutput)
{
$this->title = $title;
# Stable version links
$this->sLinks = $stableOutput->getLinks();
$this->sTemplates = $stableOutput->getTemplates();
$this->sImages = $stableOutput->getImages();
$this->sCategories = $stableOutput->getCategories();
}
示例3: addParserOutputMetadata
/**
* Add all metadata associated with a ParserOutput object, but without the actual HTML. This
* includes categories, language links, ResourceLoader modules, effects of certain magic words,
* and so on.
*
* @since 1.24
* @param ParserOutput $parserOutput
*/
public function addParserOutputMetadata($parserOutput)
{
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks($parserOutput->getCategories());
$this->setIndicators($parserOutput->getIndicators());
$this->mNewSectionLink = $parserOutput->getNewSection();
$this->mHideNewSectionLink = $parserOutput->getHideNewSection();
$this->mParseWarnings = $parserOutput->getWarnings();
if (!$parserOutput->isCacheable()) {
$this->enableClientCache(false);
}
$this->mNoGallery = $parserOutput->getNoGallery();
$this->mHeadItems = array_merge($this->mHeadItems, $parserOutput->getHeadItems());
$this->addModules($parserOutput->getModules());
$this->addModuleScripts($parserOutput->getModuleScripts());
$this->addModuleStyles($parserOutput->getModuleStyles());
$this->addJsConfigVars($parserOutput->getJsConfigVars());
$this->mPreventClickjacking = $this->mPreventClickjacking || $parserOutput->preventClickjacking();
// Template versioning...
foreach ((array) $parserOutput->getTemplateIds() as $ns => $dbks) {
if (isset($this->mTemplateIds[$ns])) {
$this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
} else {
$this->mTemplateIds[$ns] = $dbks;
}
}
// File versioning...
foreach ((array) $parserOutput->getFileSearchOptions() as $dbk => $data) {
$this->mImageTimeKeys[$dbk] = $data;
}
// Hooks registered in the object
$parserOutputHooks = $this->getConfig()->get('ParserOutputHooks');
foreach ($parserOutput->getOutputHooks() as $hookInfo) {
list($hookName, $data) = $hookInfo;
if (isset($parserOutputHooks[$hookName])) {
call_user_func($parserOutputHooks[$hookName], $this, $parserOutput, $data);
}
}
// Link flags are ignored for now, but may in the future be
// used to mark individual language links.
$linkFlags = array();
Hooks::run('LanguageLinks', array($this->getTitle(), &$this->mLanguageLinks, &$linkFlags));
Hooks::run('OutputPageParserOutput', array(&$this, $parserOutput));
}
示例4: MWException
/**
* Constructor
*
* @param Title $title Title of the page we're updating
* @param ParserOutput $parserOutput Output from a full parse of this page
* @param bool $recursive Queue jobs for recursive updates?
* @throws MWException
*/
function __construct($title, $parserOutput, $recursive = true)
{
parent::__construct(false);
// no implicit transaction
if (!$title instanceof Title) {
throw new MWException("The calling convention to LinksUpdate::LinksUpdate() has changed. " . "Please see Article::editUpdates() for an invocation example.\n");
}
if (!$parserOutput instanceof ParserOutput) {
throw new MWException("The calling convention to LinksUpdate::__construct() has changed. " . "Please see WikiPage::doEditUpdates() for an invocation example.\n");
}
$this->mTitle = $title;
$this->mId = $title->getArticleID();
if (!$this->mId) {
throw new MWException("The Title object did not provide an article " . "ID. Perhaps the page doesn't exist?");
}
$this->mParserOutput = $parserOutput;
$this->mLinks = $parserOutput->getLinks();
$this->mImages = $parserOutput->getImages();
$this->mTemplates = $parserOutput->getTemplates();
$this->mExternals = $parserOutput->getExternalLinks();
$this->mCategories = $parserOutput->getCategories();
$this->mProperties = $parserOutput->getProperties();
$this->mInterwikis = $parserOutput->getInterwikiLinks();
# Convert the format of the interlanguage links
# I didn't want to change it in the ParserOutput, because that array is passed all
# the way back to the skin, so either a skin API break would be required, or an
# inefficient back-conversion.
$ill = $parserOutput->getLanguageLinks();
$this->mInterlangs = array();
foreach ($ill as $link) {
list($key, $title) = explode(':', $link, 2);
$this->mInterlangs[$key] = $title;
}
foreach ($this->mCategories as &$sortkey) {
# If the sortkey is longer then 255 bytes,
# it truncated by DB, and then doesn't get
# matched when comparing existing vs current
# categories, causing bug 25254.
# Also. substr behaves weird when given "".
if ($sortkey !== '') {
$sortkey = substr($sortkey, 0, 255);
}
}
$this->mRecursive = $recursive;
Hooks::run('LinksUpdateConstructed', array(&$this));
}
示例5: InvalidArgumentException
/**
* Constructor
*
* @param Title $title Title of the page we're updating
* @param ParserOutput $parserOutput Output from a full parse of this page
* @param bool $recursive Queue jobs for recursive updates?
* @throws MWException
*/
function __construct(Title $title, ParserOutput $parserOutput, $recursive = true)
{
parent::__construct(false);
// no implicit transaction
$this->mTitle = $title;
$this->mId = $title->getArticleID(Title::GAID_FOR_UPDATE);
if (!$this->mId) {
throw new InvalidArgumentException("The Title object yields no ID. Perhaps the page doesn't exist?");
}
$this->mParserOutput = $parserOutput;
$this->mLinks = $parserOutput->getLinks();
$this->mImages = $parserOutput->getImages();
$this->mTemplates = $parserOutput->getTemplates();
$this->mExternals = $parserOutput->getExternalLinks();
$this->mCategories = $parserOutput->getCategories();
$this->mProperties = $parserOutput->getProperties();
$this->mInterwikis = $parserOutput->getInterwikiLinks();
# Convert the format of the interlanguage links
# I didn't want to change it in the ParserOutput, because that array is passed all
# the way back to the skin, so either a skin API break would be required, or an
# inefficient back-conversion.
$ill = $parserOutput->getLanguageLinks();
$this->mInterlangs = array();
foreach ($ill as $link) {
list($key, $title) = explode(':', $link, 2);
$this->mInterlangs[$key] = $title;
}
foreach ($this->mCategories as &$sortkey) {
# If the sortkey is longer then 255 bytes,
# it truncated by DB, and then doesn't get
# matched when comparing existing vs current
# categories, causing bug 25254.
# Also. substr behaves weird when given "".
if ($sortkey !== '') {
$sortkey = substr($sortkey, 0, 255);
}
}
$this->mRecursive = $recursive;
Hooks::run('LinksUpdateConstructed', array(&$this));
}
示例6: execute
//.........这里部分代码省略.........
$result_array['wikitext'] = array();
$result->setContent($result_array['wikitext'], $this->text);
}
$result->addValue(null, $this->getModuleName(), $result_array);
return;
}
// Not cached (save or load)
$p_result = $wgParser->parse($params['pst'] ? $this->pstText : $this->text, $titleObj, $popts);
}
$result_array = array();
$result_array['title'] = $titleObj->getPrefixedText();
if (!is_null($oldid)) {
$result_array['revid'] = intval($oldid);
}
if ($params['redirects'] && !is_null($redirValues)) {
$result_array['redirects'] = $redirValues;
}
/* Wikia Change Starts */
if (!$p_result instanceof ParserOutput) {
\Wikia\Logger\WikiaLogger::instance()->error('ApiParse no ParserOutput', ['pageTitle' => $title]);
// generate empty parser output to support code working on it
$p_result = new ParserOutput('');
}
/* Wikia Change Ends */
if (isset($prop['text'])) {
$result_array['text'] = array();
$result->setContent($result_array['text'], $p_result->getText());
}
if (!is_null($params['summary'])) {
$result_array['parsedsummary'] = array();
$result->setContent($result_array['parsedsummary'], Linker::formatComment($params['summary'], $titleObj));
}
if (isset($prop['langlinks'])) {
$result_array['langlinks'] = $this->formatLangLinks($p_result->getLanguageLinks());
}
if (isset($prop['languageshtml'])) {
$languagesHtml = $this->languagesHtml($p_result->getLanguageLinks());
$result_array['languageshtml'] = array();
$result->setContent($result_array['languageshtml'], $languagesHtml);
}
if (isset($prop['categories'])) {
$result_array['categories'] = $this->formatCategoryLinks($p_result->getCategories());
}
if (isset($prop['categorieshtml'])) {
$categoriesHtml = $this->categoriesHtml($p_result->getCategories());
$result_array['categorieshtml'] = array();
$result->setContent($result_array['categorieshtml'], $categoriesHtml);
}
if (isset($prop['links'])) {
$result_array['links'] = $this->formatLinks($p_result->getLinks());
}
if (isset($prop['templates'])) {
$result_array['templates'] = $this->formatLinks($p_result->getTemplates());
}
if (isset($prop['images'])) {
$result_array['images'] = array_keys($p_result->getImages());
}
if (isset($prop['externallinks'])) {
$result_array['externallinks'] = array_keys($p_result->getExternalLinks());
}
if (isset($prop['sections'])) {
$result_array['sections'] = $p_result->getSections();
}
if (isset($prop['displaytitle'])) {
$result_array['displaytitle'] = $p_result->getDisplayTitle() ? $p_result->getDisplayTitle() : $titleObj->getPrefixedText();
}
if (isset($prop['headitems']) || isset($prop['headhtml'])) {
$context = $this->getContext();
$context->setTitle($titleObj);
$context->getOutput()->addParserOutputNoText($p_result);
if (isset($prop['headitems'])) {
$headItems = $this->formatHeadItems($p_result->getHeadItems());
$css = $this->formatCss($context->getOutput()->buildCssLinksArray());
$scripts = array($context->getOutput()->getHeadScripts());
$result_array['headitems'] = array_merge($headItems, $css, $scripts);
}
if (isset($prop['headhtml'])) {
$result_array['headhtml'] = array();
$result->setContent($result_array['headhtml'], $context->getOutput()->headElement($context->getSkin()));
}
}
if (isset($prop['iwlinks'])) {
$result_array['iwlinks'] = $this->formatIWLinks($p_result->getInterwikiLinks());
}
if (isset($prop['wikitext'])) {
$result_array['wikitext'] = array();
$result->setContent($result_array['wikitext'], $this->text);
if (!is_null($this->pstText)) {
$result_array['psttext'] = array();
$result->setContent($result_array['psttext'], $this->pstText);
}
}
$result_mapping = array('redirects' => 'r', 'langlinks' => 'll', 'categories' => 'cl', 'links' => 'pl', 'templates' => 'tl', 'images' => 'img', 'externallinks' => 'el', 'iwlinks' => 'iw', 'sections' => 's', 'headitems' => 'hi');
$this->setIndexedTagNames($result_array, $result_mapping);
$result->addValue(null, $this->getModuleName(), $result_array);
if (!is_null($oldLang)) {
$wgLang = $oldLang;
// Reset $wgLang to $oldLang
}
}