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


PHP Title::newFromID方法代码示例

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


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

示例1: formatRow

 function formatRow($row)
 {
     $time = htmlspecialchars($this->getLanguage()->userDate($row->log_timestamp, $this->getUser()));
     $paramsSerialized = unserialize($row->log_params);
     $paramsOldFormat = null;
     // If the params aren't serialized, it's an older log format
     if ($paramsSerialized === false) {
         $paramsOldFormat = explode("\n", $row->log_params);
     }
     $targetName = $paramsSerialized === false ? $paramsOldFormat[0] : $paramsSerialized['4::target'];
     $logPageId = (int) $row->log_page;
     $currentTitle = $logPageId && $logPageId !== 0 ? Title::newFromID($logPageId) : null;
     $targetTitleObj = Title::newFromText($targetName);
     // Make sure the target is NS_MAIN
     if ($targetTitleObj->getNamespace() !== NS_MAIN) {
         return false;
     }
     $originalNameDisplay = '';
     if ($currentTitle && $targetName !== $currentTitle->getFullText()) {
         $originalNameDisplay = ' ' . $this->msg('newarticles-original-title')->params($targetName);
     }
     $pageLink = Linker::link($originalNameDisplay ? $currentTitle : $targetTitleObj);
     $articleTypeDisplay = '';
     if (isset($row->pp_value) && $row->pp_value === 'portal') {
         $pageLink = Html::rawElement('strong', [], $pageLink);
         $articleTypeReadable = WRArticleType::getReadableArticleTypeFromCode($row->pp_value);
         $articleTypeDisplay = $this->msg('newarticles-articletype')->params($articleTypeReadable)->text();
         $articleTypeDisplay = ' ' . $articleTypeDisplay;
     }
     $formattedRow = Html::rawElement('li', [], "{$time}: {$pageLink}{$articleTypeDisplay}{$originalNameDisplay}") . "\n";
     return $formattedRow;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-WRNewArticles,代码行数:32,代码来源:SpecialNewArticles.php

示例2: expandLinkTree

 public function expandLinkTree(&$parser, $limit)
 {
     $parser->disableCache();
     // Build exclusions list (if category, add all members to list)
     $exclusions = array();
     $dbr =& wfGetDB(DB_SLAVE);
     $cl = $dbr->tableName('categorylinks');
     $args = func_get_args();
     array_shift($args);
     array_shift($args);
     foreach ($args as $arg) {
         $title = Title::newFromText($arg);
         $exclusions[$title->getPrefixedText()] = 1;
         if ($title->getNamespace() == NS_CATEGORY) {
             $cat = $dbr->addQuotes($title->getDBkey());
             $res = $dbr->select($cl, 'cl_from', "cl_to = {$cat}");
             while ($row = $dbr->fetchRow($res)) {
                 $exclusions[Title::newFromID($row[0])->getPrefixedText()] = 1;
             }
             $dbr->freeResult($res);
         }
     }
     $this->exclusions = array_keys($exclusions);
     $tree = $this->linkTree($parser->getTitle(), $limit);
     return array($tree, 'found' => true, 'nowiki' => false, 'noparse' => false, 'noargs' => false, 'isHTML' => false);
 }
开发者ID:saper,项目名称:organic-extensions,代码行数:26,代码来源:LinkTree.php

示例3: WidgetBookmarkAddPage

function WidgetBookmarkAddPage($pageId)
{
    global $wgCityId, $wgSitename;
    $key = $wgCityId . ':' . $pageId;
    if (is_numeric($pageId)) {
        // articles, talk pages...
        $title = Title::newFromID($pageId);
    } else {
        // special pages, category pages...
        $title = Title::newFromText($pageId);
    }
    // validate
    if (!$title) {
        return;
    }
    $pages = WidgetBookmarkGetPages();
    // don't duplicate entries
    if (isset($pages[$key])) {
        return $pages;
    }
    // add page
    $pages[$key] = array('city' => $wgCityId, 'wiki' => $wgSitename, 'title' => $title->getPrefixedText(), 'href' => $title->getFullURL());
    // limit number of pages to 20 (the last 20 pages)
    $pages = array_slice($pages, -20, 20, true);
    WidgetBookmarkSavePages($pages);
    return $pages;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:WidgetBookmark.php

示例4: replaceVideoGalleryTag

 public function replaceVideoGalleryTag($pageId, $test = null)
 {
     global $wgTitle;
     $wgTitle = Title::newFromID($pageId);
     if (!$wgTitle) {
         $this->error("Invalid title", true);
     }
     $page = WikiPage::factory($wgTitle);
     # Read the text
     $text = $page->getText();
     $text = preg_replace('/<(\\/?)videogallery([^>]*)>/', '<$1gallery$2>', $text);
     $summary = 'Updating <videogallery> to <gallery>';
     # Do the edit
     $this->output("Replacing page (" . $wgTitle->getDBkey() . ") ... ");
     if ($test) {
         $this->output("(test: no changes) done\n");
     } else {
         $status = $page->doEdit($text, $summary, EDIT_MINOR | EDIT_FORCE_BOT | EDIT_SUPPRESS_RC);
         if ($status->isOK()) {
             $this->output("done\n");
         } else {
             $this->output("failed\n");
             return 0;
         }
         if (!$status->isGood()) {
             $this->output($status->getWikiText() . "\n");
         }
     }
     return 1;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:wikiMigrateVideoGallery.php

示例5: cleanupArticle

 private function cleanupArticle($id, $domain)
 {
     $title = Title::newFromID($id);
     if (!$title) {
         $this->error("Internal error: no page for ID {$id}");
         return;
     }
     $this->output($title->getPrefixedDBkey() . " ...");
     $rev = Revision::newFromTitle($title);
     $currentRevId = $rev->getId();
     while ($rev && ($rev->isDeleted(Revision::DELETED_TEXT) || LinkFilter::matchEntry($rev->getText(), $domain))) {
         $rev = $rev->getPrevious();
     }
     if ($rev && $rev->getId() == $currentRevId) {
         // The regex didn't match the current article text
         // This happens e.g. when a link comes from a template rather than the page itself
         $this->output("False match\n");
     } else {
         $dbw = wfGetDB(DB_MASTER);
         $dbw->begin();
         $page = WikiPage::factory($title);
         if (!$rev) {
             // Didn't find a non-spammy revision, blank the page
             $this->output("blanking\n");
             $page->doEdit('', wfMsgForContent('spam_blanking', $domain));
         } else {
             // Revert to this revision
             $this->output("reverting\n");
             $page->doEdit($rev->getText(), wfMsgForContent('spam_reverting', $domain), EDIT_UPDATE, $rev->getId());
         }
         $dbw->commit();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:33,代码来源:cleanupSpam.php

示例6: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     if (!isset($params['title']) || is_null($params['title'])) {
         $this->dieUsage("The coatitle parameter is required", 'notitle');
     }
     $categoryDBkeys = $this->prepareCategories($params['title']);
     $answeredTitle = Title::newFromText('no' == $params['answered'] ? $this->unanswered_category : $this->answered_category, NS_CATEGORY);
     if (is_null($answeredTitle) || $answeredTitle->getNamespace() != NS_CATEGORY) {
         $this->dieUsage("The name of un/answered category is not valid", 'invalidcategory');
     }
     $this->addFields(array('c1.cl_from', 'c1.cl_timestamp'));
     $this->addTables(array('categorylinks AS c1', 'categorylinks AS c2'));
     $this->addWhere('c1.cl_from = c2.cl_from');
     $this->addWhere('c1.cl_to IN (' . $this->getDB()->makeList($categoryDBkeys) . ')');
     $this->addWhereFld('c2.cl_to', $answeredTitle->getDBkey());
     $this->addOption('ORDER BY', 'c1.cl_timestamp DESC');
     $this->addOption('LIMIT', $params['limit']);
     $this->addOption('DISTINCT');
     $db = $this->getDB();
     $res = $this->select(__METHOD__);
     $data = array();
     while ($row = $db->fetchObject($res)) {
         $title = Title::newFromID($row->cl_from);
         if ($title instanceof Title && $title->isContentPage()) {
             $vals['ns'] = intval($title->getNamespace());
             $vals['title'] = $title->getPrefixedText();
             $data[] = $vals;
         }
     }
     $db->freeResult($res);
     $this->getResult()->setIndexedTagName($data, 'coa');
     $this->getResult()->addValue('query', $this->getModuleName(), $data);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:ApiQueryCategoriesOnAnswers.php

示例7: fixLinksFromArticle

function fixLinksFromArticle( $id ) {
	global $wgTitle, $wgParser;

	$wgTitle = Title::newFromID( $id );
	$dbw = wfGetDB( DB_MASTER );

	$linkCache =& LinkCache::singleton();
	$linkCache->clear();

	if ( is_null( $wgTitle ) ) {
		return;
	}
	$dbw->begin();

	$revision = Revision::newFromTitle( $wgTitle );
	if ( !$revision ) {
		return;
	}

	$options = new ParserOptions;
	$parserOutput = $wgParser->parse( $revision->getText(), $wgTitle, $options, true, true, $revision->getId() );
	$update = new LinksUpdate( $wgTitle, $parserOutput, false );
	$update->doUpdate();
	$dbw->commit();
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:25,代码来源:videoCleanup.php

示例8: getArticleQuality

 /**
  * Returns percentile quality of articleId or null if not found
  * @return int|null
  */
 public function getArticleQuality()
 {
     $cacheKey = wfMemcKey(__CLASS__, self::CACHE_BUSTER, $this->articleId);
     $percentile = $this->app->wg->Memc->get($cacheKey);
     if ($percentile === false) {
         $title = Title::newFromID($this->articleId);
         if ($title === null) {
             return null;
         }
         $article = new Article($title);
         $parserOutput = $article->getParserOutput();
         if (!$parserOutput) {
             //MAIN-3592
             $this->error(__METHOD__, ['message' => 'Article::getParserOutput returned false', 'articleId' => $this->articleId]);
             return null;
         }
         $inputs = ['outbound' => 0, 'inbound' => 0, 'length' => 0, 'sections' => 0, 'images' => 0];
         /**
          *  $title->getLinksTo() and  $title->getLinksFrom() function are
          * too expensive to call it here as we want only the number of links
          */
         $inputs['outbound'] = $this->countOutboundLinks($this->articleId);
         $inputs['inbound'] = $this->countInboundLinks($this->articleId);
         $inputs['sections'] = count($parserOutput->getSections());
         $inputs['images'] = count($parserOutput->getImages());
         $inputs['length'] = $this->getCharsCountFromHTML($parserOutput->getText());
         $quality = $this->computeFormula($inputs);
         $percentile = $this->searchPercentile($quality);
         $this->app->wg->Memc->set($cacheKey, $percentile, self::MEMC_CACHE_TIME);
     }
     return $percentile;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:36,代码来源:ArticleQualityService.php

示例9: checkInitialQueries

 /**
  * Checks some initial queries
  * Note that $title here is *not* a Title object, but a string!
  */
 function checkInitialQueries($title, $action, &$output, $request, $lang)
 {
     if ($request->getVal('printable') == 'yes') {
         $output->setPrintable();
     }
     $ret = NULL;
     if ('' == $title && 'delete' != $action) {
         $ret = Title::newMainPage();
     } elseif ($curid = $request->getInt('curid')) {
         # URLs like this are generated by RC, because rc_title isn't always accurate
         $ret = Title::newFromID($curid);
     } else {
         $ret = Title::newFromURL($title);
         /* check variant links so that interwiki links don't have to worry about
         			   the possible different language variants
         			*/
         if (count($lang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0) {
             $lang->findVariantLink($title, $ret);
         }
     }
     if (($oldid = $request->getInt('oldid')) && (is_null($ret) || $ret->getNamespace() != NS_SPECIAL)) {
         // Allow oldid to override a changed or missing title.
         $rev = Revision::newFromId($oldid);
         if ($rev) {
             $ret = $rev->getTitle();
         }
     }
     return $ret;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:33,代码来源:Wiki.php

示例10: extractTitle

 protected function extractTitle()
 {
     $this->articleTitle = Title::newFromID($this->articleId);
     if (is_null($this->articleTitle)) {
         throw new TitleNotFoundException();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:ArticleMetadataModel.php

示例11: renderFlags

 /**
  * Parses the wrapped wikitext and returns an HTML block of code with rendered flags.
  * @param array $templateCalls
  * @param $pageId
  * @return ParserOutput
  */
 public function renderFlags(array $templateCalls, $pageId)
 {
     global $wgUser;
     $wikitext = $this->wrapAllFlags($templateCalls);
     $title = \Title::newFromID($pageId);
     return \ParserPool::parse($wikitext, $title, \ParserOptions::newFromUser($wgUser));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:FlagView.class.php

示例12: removeImagesFromArticle

 private function removeImagesFromArticle($articleId)
 {
     $title = Title::newFromID($articleId);
     if ($title) {
         $revision = Revision::newFromTitle($title);
         $text = $revision->getText();
         //regular expressions copied out of maintenance/wikiphotoProcessImages.php
         //but modified to remove the leading BR tags if they exist
         //In the callback we keep track of each image name that we remove
         $text = preg_replace_callback('@(<\\s*br\\s*[\\/]?>)*\\s*\\[\\[Image:([^\\]]*)\\]\\]@im', function ($matches) {
             $image = $matches[2];
             $pipeLoc = strpos($image, "|");
             if ($pipeLoc !== false) {
                 $image = substr($image, 0, $pipeLoc);
             }
             AdminImageRemoval::$imagesRemoved[] = $image;
             return '';
         }, $text);
         $text = preg_replace_callback('@(<\\s*br\\s*[\\/]?>)*\\s*\\{\\{largeimage\\|([^\\}]*)\\}\\}@im', function ($matches) {
             $image = $matches[2];
             AdminImageRemoval::$imagesRemoved[] = $image;
             return '';
         }, $text);
         $text = preg_replace('@(<\\s*br\\s*[\\/]?>)*\\s*\\{\\{largeimage\\|[^\\}]*\\}\\}@im', '', $text);
         $article = new Article($title);
         $saved = $article->doEdit($text, 'Removing all images from article.');
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:28,代码来源:AdminImageRemoval.body.php

示例13: run

 public function run($paramArray, $isAsync, $delay)
 {
     echo "bot started\n";
     if (array_key_exists("WS_WSID", $paramArray) && $paramArray["WS_WSID"] != null) {
         $log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
         $ws = WebService::newFromID($paramArray["WS_WSID"]);
         $affectedArticles = $this->updateWSResults($ws);
         $this->setNumberOfTasks(2);
     } else {
         $affectedArticles = $this->updateAllWSResults();
     }
     ksort($affectedArticles);
     $affectedArticles = array_flip($affectedArticles);
     echo "\nRefreshing articles: \n";
     foreach ($affectedArticles as $articleId => $dontCare) {
         echo "\t refreshing articleId: " . $articleId . "\n";
         $title = Title::newFromID($articleId);
         $updatejob = new SMWUpdateJob($title);
         $updatejob->run();
     }
     echo "\nbot finished";
     global $smwgDefaultStore;
     if ($smwgDefaultStore == 'SMWTripleStore' || $smwgDefaultStore == 'SMWTripleStoreQuad') {
         define('SMWH_FORCE_TS_UPDATE', 'TRUE');
         smwfGetStore()->initialize(true);
     }
     return '';
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:28,代码来源:SMW_WSUpdateBot.php

示例14: getExhibitionItems

 public function getExhibitionItems(Title $title)
 {
     wfProfileIn(__METHOD__);
     if (class_exists('CategoryDataService')) {
         $cacheKey = $this->getExhibitionItemsCacheKey($title->getText());
         $items = $this->wg->memc->get($cacheKey);
         if (!is_array($items)) {
             $exh = CategoryDataService::getMostVisited($title->getDBkey(), null, self::EXHIBITION_ITEMS_LIMIT);
             $ids = array_keys($exh);
             $length = count($ids);
             $items = array();
             for ($i = 0; $i < $length; $i++) {
                 $pageId = $ids[$i];
                 $imgRespnse = $this->app->sendRequest('ImageServing', 'index', array('ids' => array($pageId), 'height' => 150, 'width' => 150, 'count' => 1));
                 $img = $imgRespnse->getVal('result');
                 if (!empty($img[$pageId])) {
                     $img = $img[$pageId][0]['url'];
                 } else {
                     $img = false;
                 }
                 $oTitle = Title::newFromID($pageId);
                 $items[] = ['img' => $img, 'title' => $oTitle->getText(), 'url' => $oTitle->getFullURL()];
             }
             $this->wg->memc->set($cacheKey, $items, self::CACHE_TTL_EXHIBITION);
         }
         wfProfileOut(__METHOD__);
         return $items;
     }
     wfProfileOut(__METHOD__);
     return false;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:WikiaMobileCategoryModel.class.php

示例15: doQuery

 /**
  * Fill the internal arrays with the set of articles to be displayed (possibly plus one additional
  * article that indicates further results).
  */
 protected function doQuery()
 {
     global $wgContLang;
     // ask for the list of articles that use the web service
     $options = new SMWRequestOptions();
     $options->limit = $this->limit + 1;
     $options->sort = true;
     $reverse = false;
     if ($this->mFromArticle != '') {
         $options->boundary = $this->mFromArticle;
         $options->ascending = true;
         $options->include_boundary = true;
     } elseif ($this->mUntilArticle != '') {
         $options->boundary = $this->mUntilArticle;
         $options->ascending = false;
         $options->include_boundary = false;
         $reverse = true;
     }
     $articleIDs = WSStorage::getDatabase()->getWSArticles($this->getTitle()->getArticleID(), $options);
     foreach ($articleIDs as $articleId) {
         $this->mArticles[] = Title::newFromID($articleId);
     }
     if ($reverse) {
         $this->mArticles = array_reverse($this->mArticles);
     }
     foreach ($this->mArticles as $title) {
         $this->articles_start_char[] = $wgContLang->convert($wgContLang->firstChar($title->getText()));
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:33,代码来源:SMW_WebServicePage.php


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