当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::newFromTitle方法代码示例

本文整理汇总了PHP中Category::newFromTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::newFromTitle方法的具体用法?PHP Category::newFromTitle怎么用?PHP Category::newFromTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category::newFromTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: efCategoryBlueLinks

/**
 * @param $skin DummyLinker
 * @param $target Title
 * @param $text String
 * @param $customAttribs array
 * @param $query array
 * @param $options string|array
 * @param $ret
 * @return bool
 */
function efCategoryBlueLinks($skin, $target, &$text, &$customAttribs, &$query, &$options, &$ret)
{
    // paranoia
    if (is_null($target)) {
        return true;
    }
    // only affects non-existing Category pages that has content
    if ($target->exists() || $target->getNamespace() != NS_CATEGORY || Category::newFromTitle($target)->getPageCount() == 0) {
        return true;
    }
    // remove "broken" assumption/override
    $brokenKey = array_search('broken', $options);
    if ($brokenKey !== false) {
        unset($options[$brokenKey]);
    }
    // make the link "blue"
    $options[] = 'known';
    // add a class to identify non-existing links, in case we (or our users) want to modify display
    if (array_key_exists('class', $customAttribs)) {
        $customAttribs['class'] = $customAttribs['class'] . ' newcategory';
    } else {
        $customAttribs['class'] = 'newcategory';
    }
    return true;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:35,代码来源:CategoryBlueLinks.php

示例2: onAfterInitialize

 /**
  * set appropriate status code for deleted pages
  *
  * @author ADi
  * @author Władysław Bodzek <wladek@wikia-inc.com>
  * @param Title $title
  * @param Article $article
  * @return bool
  */
 public static function onAfterInitialize(&$title, &$article, &$output)
 {
     if (!$title->exists() && $title->isDeleted()) {
         $setDeletedStatusCode = true;
         // handle special cases
         switch ($title->getNamespace()) {
             case NS_CATEGORY:
                 // skip non-empty categories
                 if (Category::newFromTitle($title)->getPageCount() > 0) {
                     $setDeletedStatusCode = false;
                 }
                 break;
             case NS_FILE:
                 // skip existing file with deleted description
                 $file = wfFindFile($title);
                 if ($file && $file->exists()) {
                     $setDeletedStatusCode = false;
                 }
                 break;
         }
         if ($setDeletedStatusCode) {
             $output->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE);
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:SEOTweaksHooksHelper.class.php

示例3: hasViewableContent

 /**
  * Don't return a 404 for categories in use.
  */
 function hasViewableContent()
 {
     if (parent::hasViewableContent()) {
         return true;
     } else {
         $cat = Category::newFromTitle($this->mTitle);
         return $cat->getId() != 0;
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:12,代码来源:CategoryPage.php

示例4: __construct

 function __construct($title, $from = '', $until = '')
 {
     global $wgCategoryPagingLimit;
     $this->title = $title;
     $this->from = $from;
     $this->until = $until;
     $this->limit = $wgCategoryPagingLimit;
     $this->cat = Category::newFromTitle($title);
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:9,代码来源:CategoryPage.php

示例5: __construct

 /**
  * @since 1.19 $context is a second, required parameter
  * @param Title $title
  * @param IContextSource $context
  * @param array $from An array with keys page, subcat,
  *        and file for offset of results of each section (since 1.17)
  * @param array $until An array with 3 keys for until of each section (since 1.17)
  * @param array $query
  */
 function __construct($title, IContextSource $context, $from = array(), $until = array(), $query = array())
 {
     $this->title = $title;
     $this->setContext($context);
     $this->from = $from;
     $this->until = $until;
     $this->limit = $context->getConfig()->get('CategoryPagingLimit');
     $this->cat = Category::newFromTitle($title);
     $this->query = $query;
     $this->collation = Collation::singleton();
     unset($this->query['title']);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:21,代码来源:CategoryViewer.php

示例6: hasViewableContent

 /**
  * Don't return a 404 for categories in use.
  * In use defined as: either the actual page exists
  * or the category currently has members.
  */
 public function hasViewableContent()
 {
     if (parent::hasViewableContent()) {
         return true;
     } else {
         $cat = Category::newFromTitle($this->mTitle);
         // If any of these are not 0, then has members
         if ($cat->getPageCount() || $cat->getSubcatCount() || $cat->getFileCount()) {
             return true;
         }
     }
     return false;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:18,代码来源:WikiCategoryPage.php

示例7: __construct

 /**
  * @since 1.19 $context is a second, required parameter
  * @param Title $title
  * @param IContextSource $context
  * @param array $from An array with keys page, subcat,
  *        and file for offset of results of each section (since 1.17)
  * @param array $until An array with 3 keys for until of each section (since 1.17)
  * @param array $query
  */
 function __construct($title, IContextSource $context, $from = array(), $until = array(), $query = array())
 {
     $this->title = $title;
     $this->setContext($context);
     $this->getOutput()->addModuleStyles(array('mediawiki.action.view.categoryPage.styles'));
     $this->from = $from;
     $this->until = $until;
     $this->limit = $context->getConfig()->get('CategoryPagingLimit');
     $this->cat = Category::newFromTitle($title);
     $this->query = $query;
     $this->collation = Collation::singleton();
     unset($this->query['title']);
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:22,代码来源:CategoryViewer.php

示例8: pagesInCategory

 public function pagesInCategory($category = null, $which = null)
 {
     $this->checkType('pagesInCategory', 1, $category, 'string');
     $this->checkTypeOptional('pagesInCategory', 2, $which, 'string', 'all');
     $title = Title::makeTitleSafe(NS_CATEGORY, $category);
     if (!$title) {
         return array(0);
     }
     $cacheKey = $title->getDBkey();
     if (!isset($this->pagesInCategoryCache[$cacheKey])) {
         $this->incrementExpensiveFunctionCount();
         $category = Category::newFromTitle($title);
         $counts = array('all' => (int) $category->getPageCount(), 'subcats' => (int) $category->getSubcatCount(), 'files' => (int) $category->getFileCount());
         $counts['pages'] = $counts['all'] - $counts['subcats'] - $counts['files'];
         $this->pagesInCategoryCache[$cacheKey] = $counts;
     }
     if ($which === '*') {
         return array($this->pagesInCategoryCache[$cacheKey]);
     }
     if (!isset($this->pagesInCategoryCache[$cacheKey][$which])) {
         $this->checkType('pagesInCategory', 2, $which, "one of '*', 'all', 'pages', 'subcats', or 'files'");
     }
     return array($this->pagesInCategoryCache[$cacheKey][$which]);
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:24,代码来源:SiteLibrary.php

示例9: addSubcategory

 /**
  * Add a subcategory to the internal lists, using a title object
  * @deprecated since 1.17 kept for compatibility, please use addSubcategoryObject instead
  */
 function addSubcategory(Title $title, $sortkey, $pageLength)
 {
     wfDeprecated(__METHOD__, '1.17');
     $this->addSubcategoryObject(Category::newFromTitle($title), $sortkey, $pageLength);
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:9,代码来源:CategoryViewer.php

示例10: showHit


//.........这里部分代码省略.........
			if ( $sectionText == '' ) {
				$sectionText = null;
			}

			$section = "<span class='searchalttitle'>" .
				$this->msg( 'search-section' )->rawParams(
					Linker::linkKnown( $sectionTitle, $sectionText ) )->text() .
				"</span>";
		}

		// format text extract
		$extract = "<div class='searchresult'>" . $result->getTextSnippet( $terms ) . "</div>";

		$lang = $this->getLanguage();

		// format score
		if ( is_null( $result->getScore() ) ) {
			// Search engine doesn't report scoring info
			$score = '';
		} else {
			$percent = sprintf( '%2.1f', $result->getScore() * 100 );
			$score = $this->msg( 'search-result-score' )->numParams( $percent )->text()
				. ' - ';
		}

		// format description
		$byteSize = $result->getByteSize();
		$wordCount = $result->getWordCount();
		$timestamp = $result->getTimestamp();
		$size = $this->msg( 'search-result-size', $lang->formatSize( $byteSize ) )
			->numParams( $wordCount )->escaped();

		if ( $t->getNamespace() == NS_CATEGORY ) {
			$cat = Category::newFromTitle( $t );
			$size = $this->msg( 'search-result-category-size' )
				->numParams( $cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount() )
				->escaped();
		}

		$date = $lang->userTimeAndDate( $timestamp, $this->getUser() );

		// link to related articles if supported
		$related = '';
		if ( $result->hasRelated() ) {
			$st = SpecialPage::getTitleFor( 'Search' );
			$stParams = array_merge(
				$this->powerSearchOptions(),
				array(
					'search' => $this->msg( 'searchrelated' )->inContentLanguage()->text() .
						':' . $t->getPrefixedText(),
					'fulltext' => $this->msg( 'search' )->text()
				)
			);

			$related = ' -- ' . Linker::linkKnown(
				$st,
				$this->msg( 'search-relatedarticle' )->text(),
				array(),
				$stParams
			);
		}

		// Include a thumbnail for media files...
		if ( $t->getNamespace() == NS_FILE ) {
			$img = wfFindFile( $t );
			if ( $img ) {
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:67,代码来源:SpecialSearch.php

示例11: addSubcategory

 /**
  * Add a subcategory to the internal lists, using a title object
  * @deprecated kept for compatibility, please use addSubcategoryObject instead
  */
 function addSubcategory(Title $title, $sortkey, $pageLength)
 {
     $this->addSubcategoryObject(Category::newFromTitle($title), $sortkey, $pageLength);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:8,代码来源:CategoryPage.php

示例12: renderNode

 /**
  * Returns a string with a HTML represenation of the given page.
  * @param $title Title
  * @param int $children
  * @param bool $loadchildren
  * @return string
  */
 function renderNode($title, $children = 0, $loadchildren = false)
 {
     global $wgCategoryTreeUseCategoryTable;
     if ($wgCategoryTreeUseCategoryTable && $title->getNamespace() == NS_CATEGORY && !$this->isInverse()) {
         $cat = Category::newFromTitle($title);
     } else {
         $cat = null;
     }
     return $this->renderNodeInfo($title, $cat, $children, $loadchildren);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:17,代码来源:CategoryTreeFunctions.php

示例13: pageInfo


//.........这里部分代码省略.........
         $pOutput->setIndexPolicy('index');
     }
     // Use robot policy logic
     $policy = $this->page->getRobotPolicy('view', $pOutput);
     $pageInfo['header-basic'][] = array($this->msg('pageinfo-robot-policy'), $this->msg("pageinfo-robot-{$policy['index']}"));
     $unwatchedPageThreshold = $config->get('UnwatchedPageThreshold');
     if ($user->isAllowed('unwatchedpages') || $unwatchedPageThreshold !== false && $pageCounts['watchers'] >= $unwatchedPageThreshold) {
         // Number of page watchers
         $pageInfo['header-basic'][] = array($this->msg('pageinfo-watchers'), $lang->formatNum($pageCounts['watchers']));
         if ($config->get('ShowUpdatedMarker') && isset($pageCounts['visitingWatchers'])) {
             $minToDisclose = $config->get('UnwatchedPageSecret');
             if ($pageCounts['visitingWatchers'] > $minToDisclose || $user->isAllowed('unwatchedpages')) {
                 $pageInfo['header-basic'][] = array($this->msg('pageinfo-visiting-watchers'), $lang->formatNum($pageCounts['visitingWatchers']));
             } else {
                 $pageInfo['header-basic'][] = array($this->msg('pageinfo-visiting-watchers'), $this->msg('pageinfo-few-visiting-watchers'));
             }
         }
     } elseif ($unwatchedPageThreshold !== false) {
         $pageInfo['header-basic'][] = array($this->msg('pageinfo-watchers'), $this->msg('pageinfo-few-watchers')->numParams($unwatchedPageThreshold));
     }
     // Redirects to this page
     $whatLinksHere = SpecialPage::getTitleFor('Whatlinkshere', $title->getPrefixedText());
     $pageInfo['header-basic'][] = array(Linker::link($whatLinksHere, $this->msg('pageinfo-redirects-name')->escaped(), array(), array('hidelinks' => 1, 'hidetrans' => 1, 'hideimages' => $title->getNamespace() == NS_FILE)), $this->msg('pageinfo-redirects-value')->numParams(count($title->getRedirectsHere())));
     // Is it counted as a content page?
     if ($this->page->isCountable()) {
         $pageInfo['header-basic'][] = array($this->msg('pageinfo-contentpage'), $this->msg('pageinfo-contentpage-yes'));
     }
     // Subpages of this page, if subpages are enabled for the current NS
     if (MWNamespace::hasSubpages($title->getNamespace())) {
         $prefixIndex = SpecialPage::getTitleFor('Prefixindex', $title->getPrefixedText() . '/');
         $pageInfo['header-basic'][] = array(Linker::link($prefixIndex, $this->msg('pageinfo-subpages-name')->escaped()), $this->msg('pageinfo-subpages-value')->numParams($pageCounts['subpages']['total'], $pageCounts['subpages']['redirects'], $pageCounts['subpages']['nonredirects']));
     }
     if ($title->inNamespace(NS_CATEGORY)) {
         $category = Category::newFromTitle($title);
         // $allCount is the total number of cat members,
         // not the count of how many members are normal pages.
         $allCount = (int) $category->getPageCount();
         $subcatCount = (int) $category->getSubcatCount();
         $fileCount = (int) $category->getFileCount();
         $pagesCount = $allCount - $subcatCount - $fileCount;
         $pageInfo['category-info'] = array(array($this->msg('pageinfo-category-total'), $lang->formatNum($allCount)), array($this->msg('pageinfo-category-pages'), $lang->formatNum($pagesCount)), array($this->msg('pageinfo-category-subcats'), $lang->formatNum($subcatCount)), array($this->msg('pageinfo-category-files'), $lang->formatNum($fileCount)));
     }
     // Page protection
     $pageInfo['header-restrictions'] = array();
     // Is this page affected by the cascading protection of something which includes it?
     if ($title->isCascadeProtected()) {
         $cascadingFrom = '';
         $sources = $title->getCascadeProtectionSources();
         // Array deferencing is in PHP 5.4 :(
         foreach ($sources[0] as $sourceTitle) {
             $cascadingFrom .= Html::rawElement('li', array(), Linker::linkKnown($sourceTitle));
         }
         $cascadingFrom = Html::rawElement('ul', array(), $cascadingFrom);
         $pageInfo['header-restrictions'][] = array($this->msg('pageinfo-protect-cascading-from'), $cascadingFrom);
     }
     // Is out protection set to cascade to other pages?
     if ($title->areRestrictionsCascading()) {
         $pageInfo['header-restrictions'][] = array($this->msg('pageinfo-protect-cascading'), $this->msg('pageinfo-protect-cascading-yes'));
     }
     // Page protection
     foreach ($title->getRestrictionTypes() as $restrictionType) {
         $protectionLevel = implode(', ', $title->getRestrictions($restrictionType));
         if ($protectionLevel == '') {
             // Allow all users
             $message = $this->msg('protect-default')->escaped();
         } else {
开发者ID:rugby110,项目名称:mediawiki,代码行数:67,代码来源:InfoAction.php

示例14: showHit

 /**
  * Format a single hit result
  *
  * @param SearchResult $result
  * @param array $terms Terms to highlight
  *
  * @return string
  */
 protected function showHit($result, $terms)
 {
     if ($result->isBrokenTitle()) {
         return '';
     }
     $title = $result->getTitle();
     $titleSnippet = $result->getTitleSnippet();
     if ($titleSnippet == '') {
         $titleSnippet = null;
     }
     $link_t = clone $title;
     Hooks::run('ShowSearchHitTitle', array(&$link_t, &$titleSnippet, $result, $terms, $this));
     $link = Linker::linkKnown($link_t, $titleSnippet);
     //If page content is not readable, just return the title.
     //This is not quite safe, but better than showing excerpts from non-readable pages
     //Note that hiding the entry entirely would screw up paging.
     if (!$title->userCan('read', $this->getUser())) {
         return "<li>{$link}</li>\n";
     }
     // If the page doesn't *exist*... our search index is out of date.
     // The least confusing at this point is to drop the result.
     // You may get less results, but... oh well. :P
     if ($result->isMissingRevision()) {
         return '';
     }
     // format redirects / relevant sections
     $redirectTitle = $result->getRedirectTitle();
     $redirectText = $result->getRedirectSnippet();
     $sectionTitle = $result->getSectionTitle();
     $sectionText = $result->getSectionSnippet();
     $categorySnippet = $result->getCategorySnippet();
     $redirect = '';
     if (!is_null($redirectTitle)) {
         if ($redirectText == '') {
             $redirectText = null;
         }
         $redirect = "<span class='searchalttitle'>" . $this->msg('search-redirect')->rawParams(Linker::linkKnown($redirectTitle, $redirectText))->text() . "</span>";
     }
     $section = '';
     if (!is_null($sectionTitle)) {
         if ($sectionText == '') {
             $sectionText = null;
         }
         $section = "<span class='searchalttitle'>" . $this->msg('search-section')->rawParams(Linker::linkKnown($sectionTitle, $sectionText))->text() . "</span>";
     }
     $category = '';
     if ($categorySnippet) {
         $category = "<span class='searchalttitle'>" . $this->msg('search-category')->rawParams($categorySnippet)->text() . "</span>";
     }
     // format text extract
     $extract = "<div class='searchresult'>" . $result->getTextSnippet($terms) . "</div>";
     $lang = $this->getLanguage();
     // format description
     $byteSize = $result->getByteSize();
     $wordCount = $result->getWordCount();
     $timestamp = $result->getTimestamp();
     $size = $this->msg('search-result-size', $lang->formatSize($byteSize))->numParams($wordCount)->escaped();
     if ($title->getNamespace() == NS_CATEGORY) {
         $cat = Category::newFromTitle($title);
         $size = $this->msg('search-result-category-size')->numParams($cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount())->escaped();
     }
     $date = $lang->userTimeAndDate($timestamp, $this->getUser());
     $fileMatch = '';
     // Include a thumbnail for media files...
     if ($title->getNamespace() == NS_FILE) {
         $img = $result->getFile();
         $img = $img ?: wfFindFile($title);
         if ($result->isFileMatch()) {
             $fileMatch = "<span class='searchalttitle'>" . $this->msg('search-file-match')->escaped() . "</span>";
         }
         if ($img) {
             $thumb = $img->transform(array('width' => 120, 'height' => 120));
             if ($thumb) {
                 $desc = $this->msg('parentheses')->rawParams($img->getShortDesc())->escaped();
                 // Float doesn't seem to interact well with the bullets.
                 // Table messes up vertical alignment of the bullets.
                 // Bullets are therefore disabled (didn't look great anyway).
                 return "<li>" . '<table class="searchResultImage">' . '<tr>' . '<td style="width: 120px; text-align: center; vertical-align: top;">' . $thumb->toHtml(array('desc-link' => true)) . '</td>' . '<td style="vertical-align: top;">' . "{$link} {$redirect} {$category} {$section} {$fileMatch}" . $extract . "<div class='mw-search-result-data'>{$desc} - {$date}</div>" . '</td>' . '</tr>' . '</table>' . "</li>\n";
             }
         }
     }
     $html = null;
     $score = '';
     if (Hooks::run('ShowSearchHit', array($this, $result, $terms, &$link, &$redirect, &$section, &$extract, &$score, &$size, &$date, &$related, &$html))) {
         $html = "<li><div class='mw-search-result-heading'>" . "{$link} {$redirect} {$category} {$section} {$fileMatch}</div> {$extract}\n" . "<div class='mw-search-result-data'>{$size} - {$date}</div>" . "</li>\n";
     }
     return $html;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:96,代码来源:SpecialSearch.php

示例15: getUploadedMediaCount

 public function getUploadedMediaCount()
 {
     return Category::newFromTitle($this->getTrackingCategory())->getFileCount();
 }
开发者ID:DanielDobre,项目名称:fossology,代码行数:4,代码来源:UploadWizardCampaign.php


注:本文中的Category::newFromTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。