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


PHP Title::newFromText方法代码示例

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


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

示例1: convert

 function convert($newFormat, $pageName, $calName, $redirect, $go)
 {
     $search = "{$pageName}/{$calName}";
     $pages = PrefixSearch::titleSearch($search, 1000000);
     //search upto 1,000,000 events (no performace issue)
     $count = $erroredCount = 0;
     foreach ($pages as $page) {
         $retval = false;
         $newPage = $this->convertToNewPage($page, $newFormat);
         $article = new Article(Title::newFromText($page));
         if ($newPage != '') {
             $fromTitle = Title::newFromText($page);
             $toTitle = Title::newFromText($newPage);
             $articleNew = new Article(Title::newFromText($newPage));
             if (!$article->isRedirect() && !$articleNew->exists()) {
                 if ($go) {
                     $retval = $fromTitle->moveTo($toTitle, true, 'CalendarConversion', $redirect);
                 } else {
                     if ($count < 10) {
                         $testRun .= '&nbsp;&nbsp;' . $page . '  &rarr;&rarr;  ' . $newPage . '<br>';
                     }
                 }
             }
         }
     }
     unset($pages);
     if ($go) {
         $ret = "Conversion completed.";
     } else {
         $ret = "<b>Test Results, add '<i>go</i>' to the <i>dateConverter</i> tag to convert:</b><br>{$testRun}";
     }
     return $ret;
 }
开发者ID:mediawiki-extensions,项目名称:mw-calendar,代码行数:33,代码来源:DateConverter.php

示例2: testPreferences

    function testPreferences()
    {
        global $wgUser, $wgOut, $wgTitle;
        // This test makes call to the parser which requires valids Outputpage
        // and Title objects. Set them up there, they will be released at the
        // end of the test.
        $old_wgOut = $wgOut;
        $old_wgTitle = $wgTitle;
        $wgTitle = Title::newFromText('Parser test for Gadgets extension');
        // Proceed with test setup:
        $prefs = array();
        $context = new RequestContext();
        $wgOut = $context->getOutput();
        $wgOut->setTitle(Title::newFromText('test'));
        Gadget::loadStructuredList('* foo | foo.js
==keep-section1==
* bar| bar.js
==remove-section==
* baz [rights=embezzle] |baz.js
==keep-section2==
* quux [rights=read] | quux.js');
        $this->assertTrue(GadgetHooks::getPreferences($wgUser, $prefs), 'GetPrefences hook should return true');
        $options = $prefs['gadgets']['options'];
        $this->assertFalse(isset($options['&lt;gadget-section-remove-section&gt;']), 'Must not show empty sections');
        $this->assertTrue(isset($options['&lt;gadget-section-keep-section1&gt;']));
        $this->assertTrue(isset($options['&lt;gadget-section-keep-section2&gt;']));
        // Restore globals
        $wgOut = $old_wgOut;
        $wgTitle = $old_wgTitle;
    }
开发者ID:Tarendai,项目名称:spring-website,代码行数:30,代码来源:GadgetTest.php

示例3: getSQL

 function getSQL()
 {
     $dbr =& wfGetDB(DB_SLAVE);
     list($page, $pagelinks, $templatelinks) = $dbr->tableNamesN('page', 'pagelinks', 'templatelinks');
     $dMsgText = wfMsgForContent('disambiguationspage');
     $linkBatch = new LinkBatch();
     # If the text can be treated as a title, use it verbatim.
     # Otherwise, pull the titles from the links table
     $dp = Title::newFromText($dMsgText);
     if ($dp) {
         if ($dp->getNamespace() != NS_TEMPLATE) {
             # FIXME we assume the disambiguation message is a template but
             # the page can potentially be from another namespace :/
             wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
         }
         $linkBatch->addObj($dp);
     } else {
         # Get all the templates linked from the Mediawiki:Disambiguationspage
         $disPageObj = $this->getDisambiguationPageObj();
         $res = $dbr->select(array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), 'DisambiguationsPage::getSQL');
         while ($row = $dbr->fetchObject($res)) {
             $linkBatch->addObj(Title::makeTitle(NS_TEMPLATE, $row->pl_title));
         }
         $dbr->freeResult($res);
     }
     $set = $linkBatch->constructSet('lb.tl', $dbr);
     if ($set === false) {
         $set = 'FALSE';
         # We must always return a valid sql query, but this way DB will always quicly return an empty result
         wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
     }
     $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace," . " pb.page_title AS title, la.pl_from AS value" . " FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa" . " WHERE {$set}" . ' AND pa.page_id = la.pl_from' . ' AND pa.page_namespace = ' . NS_MAIN . ' AND pb.page_id = lb.tl_from' . ' AND pb.page_namespace = la.pl_namespace' . ' AND pb.page_title = la.pl_title' . ' ORDER BY lb.tl_namespace, lb.tl_title';
     return $sql;
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:34,代码来源:SpecialDisambiguations.php

示例4: execute

 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isLoggedIn()) {
         $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin');
     }
     $params = $this->extractRequestParams();
     $title = Title::newFromText($params['title']);
     if (!$title) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     $article = new Article($title);
     $res = array('title' => $title->getPrefixedText());
     if ($params['unwatch']) {
         $res['unwatched'] = '';
         $success = $article->doUnwatch();
     } else {
         $res['watched'] = '';
         $success = $article->doWatch();
     }
     if (!$success) {
         $this->dieUsageMsg(array('hookaborted'));
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
开发者ID:ui-libraries,项目名称:TIRWeb,代码行数:25,代码来源:ApiWatch.php

示例5: findTitle

 /**
  * Assuming the user's interface language is fi. Given input Page, it
  * returns Page/fi if it exists, otherwise Page. Given input Page/de,
  * it returns Page/fi if it exists, otherwise Page/de if it exists,
  * otherwise Page.
  *
  * @param string|null $subpage
  * @return Title|null
  */
 public function findTitle($subpage)
 {
     // base = title without language code suffix
     // provided = the title as it was given
     $base = $provided = null;
     if ($subpage !== null) {
         $provided = Title::newFromText($subpage);
         $base = $provided;
     }
     if ($provided && strpos($subpage, '/') !== false) {
         $pos = strrpos($subpage, '/');
         $basepage = substr($subpage, 0, $pos);
         $code = substr($subpage, $pos + 1);
         if (strlen($code) && Language::isKnownLanguageTag($code)) {
             $base = Title::newFromText($basepage);
         }
     }
     if (!$base) {
         return null;
     }
     if ($base->isRedirect()) {
         $page = new WikiPage($base);
         $base = $page->getRedirectTarget();
     }
     $uiCode = $this->getLanguage()->getCode();
     $proposed = $base->getSubpage($uiCode);
     if ($proposed && $proposed->exists() && $uiCode !== $base->getPageLanguage()->getCode()) {
         return $proposed;
     } elseif ($provided && $provided->exists()) {
         return $provided;
     } else {
         return $base;
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:43,代码来源:SpecialMyLanguage.php

示例6: titleSearch

 /**
  * Do a prefix search of titles and return a list of matching page names.
  *
  * @param $search String
  * @param $limit Integer
  * @param $namespaces Array: used if query is not explicitely prefixed
  * @return Array of strings
  */
 public static function titleSearch($search, $limit, $namespaces = array())
 {
     $search = trim($search);
     if ($search == '') {
         return array();
         // Return empty result
     }
     $namespaces = self::validateNamespaces($namespaces);
     // Find a Title which is not an interwiki and is in NS_MAIN
     $title = Title::newFromText($search);
     if ($title && $title->getInterwiki() == '') {
         $ns = array($title->getNamespace());
         if ($ns[0] == NS_MAIN) {
             $ns = $namespaces;
         }
         // no explicit prefix, use default namespaces
         return self::searchBackend($ns, $title->getText(), $limit);
     }
     // Is this a namespace prefix?
     $title = Title::newFromText($search . 'Dummy');
     if ($title && $title->getText() == 'Dummy' && $title->getNamespace() != NS_MAIN && $title->getInterwiki() == '') {
         return self::searchBackend(array($title->getNamespace()), '', $limit);
     }
     return self::searchBackend($namespaces, $search, $limit);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:33,代码来源:PrefixSearch.php

示例7: execute

 function execute($par)
 {
     global $wgOut, $wgUser;
     $wgOut->setRobotPolicy("index,follow");
     $sk = $wgUser->getSkin();
     $topcats = $this->getTopLevelCategories();
     $wgOut->setHTMLTitle('wikiHow Sitemap');
     $count = 0;
     $wgOut->addHTML("\n\t\t\t<style>\n\t\t\t\t#catentry li {\n\t\t\t\t\tmargin-bottom: 0;\n\t\t\t\t}\n\t\t\t\ttable.cats {\n\t\t\t\t\twidth: 100%;\n\t\t\t\t}\n\t\t\t\t.cats td {\n\t\t\t\t\tvertical-align: top;\n\t\t\t\t\tborder: 1px solid #e5e5e5;\n\t\t\t\t\tpadding: 10px;\n\t\t\t\t\tbackground: white;\n\t\t\t\t\t-moz-border-radius: 4px;\n\t\t\t\t\t-webkit-border-radius: 4px;\n\t\t\t\t\t-khtml-border-radius: 4px;\n\t\t\t\t\tborder-radius: 4px;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<table align='center' class='cats' cellspacing=10px>");
     foreach ($topcats as $cat) {
         $t = Title::newFromText($cat, NS_CATEGORY);
         $subcats = $this->getSubcategories($t);
         if ($count % 2 == 0) {
             $wgOut->addHTML("<tr>");
         }
         $wgOut->addHTML("<td><h3>" . $sk->makeLinkObj($t, $t->getText()) . "</h3><ul id='catentry'>");
         foreach ($subcats as $sub) {
             $t = Title::newFromText($sub, NS_CATEGORY);
             $wgOut->addHTML("<li>" . $sk->makeLinkObj($t, $t->getText()) . "</li>\n");
         }
         $wgOut->addHTML("</ul></td>\n");
         if ($count % 2 == 1) {
             $wgOut->addHTML("</tr>");
         }
         $count++;
     }
     $wgOut->addHTML("</table>");
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:28,代码来源:Sitemap.body.php

示例8: getRelated

 public function getRelated()
 {
     wfProfileIn(__METHOD__);
     $result = array();
     $articleIds = array();
     $thumbnailsReplaced = array();
     //TODO move to PathFinderController
     if ($this->getVal('selectby') == 'byTitle') {
         $title = Title::newFromText($this->getVal('article'));
         $articleId = $title->getArticleID();
     } else {
         $articleId = $this->getVal('article');
     }
     $nodes = $this->model->getRelated($this->wg->CityId, $articleId, $this->getVal('datespan'), $this->getVal('userHaveSeenNumber'), $this->getVal('minCount'));
     if (count($nodes) > 0) {
         foreach ($nodes as $node) {
             $targetTitle = Title::newFromID($node->target_id);
             if ($targetTitle != NULL) {
                 $targetURL = $targetTitle->getLocalURL();
                 $result[] = array('cityid' => $node->city_id, 'targetTitle' => $targetTitle, 'targetURL' => $targetURL, 'count' => $node->count, 'updated' => $node->updated);
                 $articleIds[] = $targetTitle->mArticleID;
             }
         }
         $thumbnails = $this->sendSelfRequest('getThumbnails', array('articleIds' => $articleIds, 'width' => 75))->getVal('thumbnails');
         $this->setVal('thumbnails', $thumbnails);
     } else {
         $result = array("No Result");
     }
     $this->setVal('nodes', $result);
     wfProfileOut(__METHOD__);
 }
开发者ID:yusufchang,项目名称:app,代码行数:31,代码来源:PathFinderSpecialController.class.php

示例9: FinishCreate

 /**
  * Updates wiki specific properties set from wiki creation wizard.
  * Context of this method is on the wiki that the values are changing on.
  * Main wiki creation happens on www, and it will redirect to the newly created wiki.
  * The values are read from the session and only accessible by the admin.
  */
 public function FinishCreate()
 {
     global $wgUser, $wgOut, $wgEnableNjordExt;
     if (!$wgUser->isAllowed('finishcreate')) {
         return false;
     }
     $this->skipRendering();
     $this->LoadState();
     $mainPage = wfMsgForContent('mainpage');
     // set theme
     if (!empty($this->params['color-body'])) {
         $themeSettings = new ThemeSettings();
         $themeSettings->saveSettings($this->params);
     }
     // set description on main page
     if (!empty($this->params['wikiDescription'])) {
         $mainTitle = Title::newFromText($mainPage);
         $mainId = $mainTitle->getArticleID();
         $mainArticle = Article::newFromID($mainId);
         if (!empty($mainArticle)) {
             if (!empty($wgEnableNjordExt)) {
                 $newMainPageText = $this->getMoMMainPage($mainArticle);
             } else {
                 $newMainPageText = $this->getClassicMainPage($mainArticle);
             }
             $mainArticle->doEdit($newMainPageText, '');
             $this->initHeroModule($mainPage);
         }
     }
     $wgOut->enableClientCache(false);
     $this->clearState();
     $wgOut->redirect($mainPage . '?wiki-welcome=1');
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:39,代码来源:FinishCreateWikiController.class.php

示例10: __construct

 function __construct(IContextSource $context, $userName = null, $search = '', $including = false, $showAll = false)
 {
     $this->setContext($context);
     $this->mIncluding = $including;
     $this->mShowAll = $showAll;
     if ($userName !== null && $userName !== '') {
         $nt = Title::newFromText($userName, NS_USER);
         $user = User::newFromName($userName, false);
         if (!is_null($nt)) {
             $this->mUserName = $nt->getText();
         }
         if (!$user || $user->isAnon() && !User::isIP($user->getName())) {
             $this->getOutput()->wrapWikiMsg("<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>", array('listfiles-userdoesnotexist', wfEscapeWikiText($userName)));
         }
     }
     if ($search !== '' && !$this->getConfig()->get('MiserMode')) {
         $this->mSearch = $search;
         $nt = Title::newFromURL($this->mSearch);
         if ($nt) {
             $dbr = wfGetDB(DB_SLAVE);
             $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike($dbr->anyString(), strtolower($nt->getDBkey()), $dbr->anyString());
         }
     }
     if (!$including) {
         if ($this->getRequest()->getText('sort', 'img_date') == 'img_date') {
             $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
         } else {
             $this->mDefaultDirection = IndexPager::DIR_ASCENDING;
         }
     } else {
         $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
     }
     parent::__construct($context);
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:34,代码来源:SpecialListfiles.php

示例11: execute

	public function execute( $par ) {
		global $wgOut;

		$title = '';
		$params = array();

		if( IncubatorTest::isContentProject() ) {
			global $wgRequest;
			$title = Title::newFromText( IncubatorTest::displayPrefix() );
			if( $wgRequest->getVal( 'goto' ) != 'infopage' ) {
				$params['goto'] = 'mainpage';
			}
			$url = IncubatorTest::getUrlParam();
			if( $url ) {
				$params['testwiki'] = $url['prefix'];
			}
		}

		# Go to the main page if given invalid title, or if it's not a content project
		if ( !$title ) {
			$title = Title::newMainPage();
		}

		$wgOut->redirect( $title->getLocalURL( $params ) );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:25,代码来源:SpecialMyMainPage.php

示例12: efFastCatSelector

function efFastCatSelector(&$categories)
{
    global $wgTitle, $wgArticle;
    // BugId:26491
    if (empty($wgTitle) || empty($wgArticle)) {
        return true;
    }
    $artname = $wgTitle->getText();
    $artid = $wgArticle->getID();
    $spice = sha1("Kroko-katMeNot-" . $artid . "-" . $artname . "-NotMekat-Schnapp");
    $catUrl = Title::newFromText('FastCat', NS_SPECIAL)->getFullURL();
    $ret = "<form action=\"{$catUrl}\" method='post'>\n<p><b>" . wfMsg('fastcat-box-title') . "</b><br>\n<small>" . wfMsg('fastcat-box-intro') . "</small>\n</p>\n<input type='hidden' name='id' value='{$artid}'>\n<input type='hidden' name='spice' value='{$spice}'>\n<input type='hidden' name='artname' value='{$artname}'>\n<p style=\"text-indent:-1em;margin-left:1em\">";
    $kat = explode("\n", wfMsgForContent('fastcat-categories-list'));
    foreach ($kat as $k) {
        if (strpos($k, '* ') === 0) {
            $k = trim($k, '* ');
            $ret .= "</p><p style=\"text-indent:-1em;margin-left:1em\">\n";
            $ret .= "<button style=\"font-size:smaller;\" name=\"cat\" value=\"{$k}\"><b>{$k}</b></button>\n";
        } else {
            $k = trim($k, '* ');
            $ret .= "<button style=\"font-size:smaller;\" name=\"cat\" value=\"{$k}\">{$k}</button>\n";
        }
    }
    $ret .= <<<EORET
\t\t</p>
\t\t</form>
EORET;
    $categories = $ret;
    return true;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:30,代码来源:FastCat.php

示例13: efAddResourceSpecialPage

function efAddResourceSpecialPage($template, $links)
{
    global $wgTitle, $wgRequest, $wgUser, $wgAddResourceTab;
    // return if we are not on the right special page
    if (!$wgTitle->isSpecial('AddResource')) {
        return true;
    }
    // parse subpage-part. We cannot use $wgTitle->getSubpage() because the
    // special namespaces doesn't have real subpages
    $prefixedText = $wgTitle->getPrefixedText();
    if (strpos($prefixedText, '/') === FALSE) {
        return true;
        // no page given
    }
    $parts = explode('/', $prefixedText);
    $pageName = $parts[count($parts) - 1];
    $title = Title::newFromText($pageName)->getSubjectPage();
    $talkTitle = $title->getTalkPage();
    // Get AddResource URL:
    $resourceCount = getResourceCount($title);
    $resourcesUrl = getResourcesUrl($title);
    $resourcesText = getResourceTabText($resourceCount);
    $resourcesClass = $resourceCount > 0 ? 'is_resources' : 'new is_resources';
    $head = array($title->getNamespaceKey('') => array('class' => $title->exists() ? null : 'new', 'text' => $title->getText(), 'href' => $title->getLocalUrl()), 'resources' => array('class' => $resourcesClass, 'text' => $resourcesText, 'href' => $resourcesUrl));
    $tail = array($title->getNamespaceKey('') . '_talk' => array('class' => $talkTitle->exists() ? null : 'new', 'text' => wfMessage('Talk')->text(), 'href' => $talkTitle->getLocalUrl()));
    $resourceCount = getResourceCount($title);
    $links['namespaces'] = array_merge($head, $links['namespaces'], $tail);
    $links['namespaces']['special']['text'] = '+';
    return true;
}
开发者ID:n0g,项目名称:AddResource,代码行数:30,代码来源:AddResource.php

示例14: WidgetCategoryCloud

function WidgetCategoryCloud($id, $params)
{
    $output = "";
    wfProfileIn(__METHOD__);
    global $wgMemc;
    $key = wfMemcKey("WidgetCategoryCloud", "data");
    $data = $wgMemc->get($key);
    if (is_null($data)) {
        $data = WidgetCategoryCloudCloudizeData(WidgetCategoryCloudGetData());
        $wgMemc->set($key, $data, 3600);
    }
    if (empty($data)) {
        wfProfileOut(__METHOD__);
        return wfMsgForContent("widget-categorycloud-empty");
    }
    foreach ($data as $name => $value) {
        $category = Title::newFromText($name, NS_CATEGORY);
        if (is_object($category)) {
            $class = "cloud" . $value;
            $output .= Xml::openElement("li", array("class" => $class));
            // FIXME fix Wikia:link and use it here
            $output .= Xml::element("a", array("class" => $class, "href" => $category->getLocalURL(), "title" => $category->getFullText()), $category->getBaseText());
            $output .= Xml::closeElement("li");
            $output .= "\n";
        }
    }
    if (empty($output)) {
        wfProfileOut(__METHOD__);
        return wfMsgForContent("widget-categorycloud-empty");
    }
    $output = Xml::openElement("ul") . $output . Xml::closeElement("ul");
    wfProfileOut(__METHOD__);
    return $output;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:WidgetCategoryCloud.php

示例15: testForm

 /**
  * @dataProvider provideValidate
  */
 public function testForm($text, $value)
 {
     $form = HTMLForm::factory('ooui', ['restrictions' => ['class' => HTMLRestrictionsField::class]]);
     $request = new FauxRequest(['wprestrictions' => $text], true);
     $context = new DerivativeContext(RequestContext::getMain());
     $context->setRequest($request);
     $form->setContext($context);
     $form->setTitle(Title::newFromText('Main Page'))->setSubmitCallback(function () {
         return true;
     })->prepareForm();
     $status = $form->trySubmit();
     if ($status instanceof StatusValue) {
         $this->assertEquals($value !== false, $status->isGood());
     } elseif ($value === false) {
         $this->assertNotSame(true, $status);
     } else {
         $this->assertSame(true, $status);
     }
     if ($value !== false) {
         $restrictions = $form->mFieldData['restrictions'];
         $this->assertInstanceOf(MWRestrictions::class, $restrictions);
         $this->assertEquals($value, $restrictions->toArray()['IPAddresses']);
     }
     // sanity
     $form->getHTML($status);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:29,代码来源:HTMLRestrictionsFieldTest.php


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