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


PHP Title::makeTitleSafe方法代码示例

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


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

示例1: getDefinitions

 public function getDefinitions()
 {
     $groups = MessageGroups::getAllGroups();
     $keys = array();
     /**
      * @var $g MessageGroup
      */
     foreach ($groups as $g) {
         $states = $g->getMessageGroupStates()->getStates();
         foreach (array_keys($states) as $state) {
             $keys["Translate-workflow-state-{$state}"] = $state;
         }
     }
     $defs = TranslateUtils::getContents(array_keys($keys), $this->getNamespace());
     foreach ($keys as $key => $state) {
         if (!isset($defs[$key])) {
             // @todo Use jobqueue
             $title = Title::makeTitleSafe($this->getNamespace(), $key);
             $page = new WikiPage($title);
             $content = ContentHandler::makeContent($state, $title);
             $page->doEditContent($content, wfMessage('translate-workflow-autocreated-summary', $state)->inContentLanguage()->text(), 0, false, FuzzyBot::getUser());
         } else {
             // Use the wiki translation as definition if available.
             // getContents returns array( content, last author )
             list($content, ) = $defs[$key];
             $keys[$key] = $content;
         }
     }
     return $keys;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:30,代码来源:WorkflowStatesMessageGroup.php

示例2: formatResult

 function formatResult(&$skin, $row)
 {
     global $wgContLang;
     $title = Title::makeTitleSafe(NS_IMAGE, $row->title);
     $label = htmlspecialchars($wgContLang->convert($title->getText()));
     return $skin->makeKnownLinkObj($title, $label);
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:7,代码来源:SpecialUncategorizedimages.php

示例3: testUpdate_iwlinks

 public function testUpdate_iwlinks()
 {
     list($t, $po) = $this->makeTitleAndParserOutput("Testing", 111);
     $target = Title::makeTitleSafe(NS_MAIN, "Foo", '', 'linksupdatetest');
     $po->addInterwikiLink($target);
     $this->assertLinksUpdate($t, $po, 'iwlinks', 'iwl_prefix, iwl_title', 'iwl_from = 111', array(array('linksupdatetest', 'Foo')));
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:7,代码来源:LinksUpdateTest.php

示例4: create

 /**
  * Create category.
  *
  * @param $category String: Name of category to create.
  * @param $code String: Code of language that the category is for.
  * @param $level String: Level that the category is for.
  */
 public static function create($category, $code, $level = null)
 {
     $category = strip_tags($category);
     $title = Title::makeTitleSafe(NS_CATEGORY, $category);
     if ($title === null || $title->exists()) {
         return;
     }
     global $wgLanguageCode;
     $language = BabelLanguageCodes::getName($code, $wgLanguageCode);
     if ($level === null) {
         $text = wfMsgForContent('babel-autocreate-text-main', $language, $code);
     } else {
         $text = wfMsgForContent('babel-autocreate-text-levels', $level, $language, $code);
     }
     $user = self::user();
     # Do not add a message if the username is invalid or if the account that adds it, is blocked
     if (!$user || $user->isBlocked()) {
         return;
     }
     if (!$title->quickUserCan('create', $user)) {
         return;
         # The Babel AutoCreate account is not allowed to create the page
     }
     /* $article->doEdit will call $wgParser->parse.
      * Calling Parser::parse recursively is baaaadd... (bug 29245)
      * @todo FIXME: surely there is a better way?
      */
     global $wgParser, $wgParserConf;
     $oldParser = $wgParser;
     $parserClass = $wgParserConf['class'];
     $wgParser = new $parserClass($wgParserConf);
     $article = new Article($title, 0);
     $article->doEdit($text, wfMsgForContent('babel-autocreate-reason', wfMsgForContent('babel-url')), EDIT_FORCE_BOT, false, $user);
     $wgParser = $oldParser;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:42,代码来源:BabelAutoCreate.class.php

示例5: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     global $wgFeed, $wgFeedClasses, $wgSitename, $wgLanguageCode;
     if (!$wgFeed) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     if (!isset($wgFeedClasses[$params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     global $wgMiserMode;
     if ($params['showsizediff'] && $wgMiserMode) {
         $this->dieUsage('Size difference is disabled in Miser Mode', 'sizediffdisabled');
     }
     $msg = wfMessage('Contributions')->inContentLanguage()->text();
     $feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
     $feedUrl = SpecialPage::getTitleFor('Contributions', $params['user'])->getFullURL();
     $target = $params['user'] == 'newbies' ? 'newbies' : Title::makeTitleSafe(NS_USER, $params['user'])->getText();
     $feed = new $wgFeedClasses[$params['feedformat']]($feedTitle, htmlspecialchars($msg), $feedUrl);
     $pager = new ContribsPager($this->getContext(), array('target' => $target, 'namespace' => $params['namespace'], 'year' => $params['year'], 'month' => $params['month'], 'tagFilter' => $params['tagfilter'], 'deletedOnly' => $params['deletedonly'], 'topOnly' => $params['toponly'], 'showSizeDiff' => $params['showsizediff']));
     $feedItems = array();
     if ($pager->getNumRows() > 0) {
         foreach ($pager->mResult as $row) {
             $feedItems[] = $this->feedItem($row);
         }
     }
     ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:28,代码来源:ApiFeedContributions.php

示例6: setTypeAndPossibleValues

 function setTypeAndPossibleValues()
 {
     $proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
     if ($proptitle === null) {
         return;
     }
     $store = smwfGetStore();
     // this returns an array of objects
     $allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
     $label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
     $propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
     $this->mPropertyType = $propValue->findPropertyTypeID();
     foreach ($allowed_values as $allowed_value) {
         // HTML-unencode each value
         $this->mPossibleValues[] = html_entity_decode($allowed_value);
         if (count($label_formats) > 0) {
             $label_format = $label_formats[0];
             $prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
             $label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
             $label_value->setOutputFormat($label_format);
             $this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
         }
     }
     // HACK - if there were any possible values, set the property
     // type to be 'enumeration', regardless of what the actual type is
     if (count($this->mPossibleValues) > 0) {
         $this->mPropertyType = 'enumeration';
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:29,代码来源:SF_TemplateField.php

示例7: getPages

 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     $username = $context->getUser();
     if ($username === null) {
         return array();
     }
     // Get the normalized title of the user's user page
     $userpageTitle = Title::makeTitleSafe(NS_USER, $username);
     if (!$userpageTitle instanceof Title) {
         return array();
     }
     $userpage = $userpageTitle->getPrefixedDBkey();
     // Needed so $excludepages works
     $pages = array("{$userpage}/common.js" => array('type' => 'script'), "{$userpage}/" . $context->getSkin() . '.js' => array('type' => 'script'), "{$userpage}/common.css" => array('type' => 'style'), "{$userpage}/" . $context->getSkin() . '.css' => array('type' => 'style'));
     // Hack for bug 26283: if we're on a preview page for a CSS/JS page,
     // we need to exclude that page from this module. In that case, the excludepage
     // parameter will be set to the name of the page we need to exclude.
     $excludepage = $context->getRequest()->getVal('excludepage');
     if (isset($pages[$excludepage])) {
         // This works because $excludepage is generated with getPrefixedDBkey(),
         // just like the keys in $pages[] above
         unset($pages[$excludepage]);
     }
     return $pages;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:29,代码来源:ResourceLoaderUserModule.php

示例8: execute

 public function execute()
 {
     global $wgUser;
     $username = $this->getOption('username', false);
     if ($username === false) {
         $user = User::newSystemUser('ScriptImporter', ['steal' => true]);
     } else {
         $user = User::newFromName($username);
     }
     $wgUser = $user;
     $baseUrl = $this->getArg(1);
     $pageList = $this->fetchScriptList();
     $this->output('Importing ' . count($pageList) . " pages\n");
     foreach ($pageList as $page) {
         $title = Title::makeTitleSafe(NS_MEDIAWIKI, $page);
         if (!$title) {
             $this->error("{$page} is an invalid title; it will not be imported\n");
             continue;
         }
         $this->output("Importing {$page}\n");
         $url = wfAppendQuery($baseUrl, ['action' => 'raw', 'title' => "MediaWiki:{$page}"]);
         $text = Http::get($url, [], __METHOD__);
         $wikiPage = WikiPage::factory($title);
         $content = ContentHandler::makeContent($text, $wikiPage->getTitle());
         $wikiPage->doEditContent($content, "Importing from {$url}", 0, false, $user);
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:27,代码来源:importSiteScripts.php

示例9: execute

 function execute()
 {
     global $wgOut;
     $this->limit = min($this->request->getInt('limit', 50), 5000);
     if ($this->limit <= 0) {
         $this->limit = 50;
     }
     $this->from = $this->request->getInt('from');
     $this->back = $this->request->getInt('back');
     $targetString = isset($this->par) ? $this->par : $this->request->getVal('target');
     if (is_null($targetString)) {
         $wgOut->addHTML($this->whatlinkshereForm());
         return;
     }
     $this->target = Title::newFromURL($targetString);
     if (!$this->target) {
         $wgOut->addHTML($this->whatlinkshereForm());
         return;
     }
     $this->selfTitle = Title::makeTitleSafe(NS_SPECIAL, 'Whatlinkshere/' . $this->target->getPrefixedDBkey());
     $wgOut->setPageTitle(wfMsg('whatlinkshere-title', $this->target->getPrefixedText()));
     $wgOut->setSubtitle(wfMsg('linklistsub'));
     $wgOut->addHTML(wfMsgExt('whatlinkshere-barrow', array('escapenoentities')) . ' ' . $this->skin->makeLinkObj($this->target, '', 'redirect=no') . "<br />\n");
     $this->showIndirectLinks(0, $this->target, $this->limit, $this->from, $this->back);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:25,代码来源:SpecialWhatlinkshere.php

示例10: ifcategory

 function ifcategory(&$parser, $category = '', $then = '', $else = '', $pagename = '')
 {
     if ($category === '') {
         return $then;
     }
     if ($pagename === '') {
         $title = $parser->getTitle();
         $page = $title->getDBkey();
         $ns = $title->getNamespace();
     } else {
         $title = Title::newFromText($pagename);
         if (!$title instanceof Title || !$title->exists()) {
             return $else;
         }
         $page = $title->getDBkey();
         $ns = $title->getNamespace();
     }
     $cattitle = Title::makeTitleSafe(NS_CATEGORY, $category);
     if (!$cattitle instanceof Title) {
         return $else;
     }
     $catkey = $cattitle->getDBkey();
     $db = wfGetDB(DB_SLAVE);
     $res = $db->select(array('page', 'categorylinks'), 'cl_from', array('page_id=cl_from', 'page_namespace' => $ns, 'page_title' => $page, 'cl_to' => $catkey), __METHOD__, array('LIMIT' => 1));
     if ($db->numRows($res) == 0) {
         return $else;
     }
     return $then;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:29,代码来源:CategoryTests.php

示例11: formatValue

 function formatValue($name, $value)
 {
     global $wgLang, $wgContLang;
     static $linker = null;
     if (empty($linker)) {
         $linker = class_exists('DummyLinker') ? new DummyLinker() : new Linker();
     }
     $row = $this->mCurrentRow;
     $ns = $row->page_namespace;
     $title = $row->page_title;
     if (is_null($ns)) {
         $ns = $row->thread_article_namespace;
         $title = $row->thread_article_title;
     }
     switch ($name) {
         case 'thread_subject':
             $title = Title::makeTitleSafe($ns, $title);
             $link = $linker->link($title, $value, array(), array(), array('known'));
             return Html::rawElement('div', array('dir' => $wgContLang->getDir()), $link);
         case 'th_timestamp':
             $formatted = $wgLang->timeanddate($value);
             $title = Title::makeTitleSafe($ns, $title);
             return $linker->link($title, $formatted, array(), array('lqt_oldid' => $row->th_id));
         default:
             return parent::formatValue($name, $value);
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:27,代码来源:TalkpageHistoryView.php

示例12: execute

 function execute($par)
 {
     global $wgRequest, $wgOut;
     $this->setHeaders();
     $this->outputHeader();
     $file = !is_null($par) ? $par : $wgRequest->getText('file');
     $title = Title::makeTitleSafe(NS_FILE, $file);
     if (!$title instanceof Title || $title->getNamespace() != NS_FILE) {
         $this->showForm($title);
     } else {
         $file = wfFindFile($title);
         if ($file && $file->exists()) {
             $url = $file->getURL();
             $width = $wgRequest->getInt('width', -1);
             $height = $wgRequest->getInt('height', -1);
             if ($width != -1) {
                 $mto = $file->transform(array('width' => $width, 'height' => $height));
                 if ($mto && !$mto->isError()) {
                     $url = $mto->getURL();
                 }
             }
             $wgOut->redirect($url);
         } else {
             $wgOut->setStatusCode(404);
             $this->showForm($title);
         }
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:28,代码来源:SpecialFilepath.php

示例13: makeMemberList

 /**
  * @param $username string
  * @return CollaborationListContent
  */
 public static function makeMemberList($username, $initialDescription)
 {
     $linkToUserpage = Title::makeTitleSafe(NS_USER, $username)->getPrefixedText();
     $newMemberList = ["displaymode" => "members", "columns" => [["items" => [["title" => $linkToUserpage]]]], "options" => ["mode" => "normal"], "description" => "{$initialDescription}"];
     $newMemberListJson = FormatJson::encode($newMemberList, "\t", FormatJson::ALL_OK);
     return new CollaborationListContent($newMemberListJson);
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-CollaborationKit,代码行数:11,代码来源:CollaborationListContentHandler.php

示例14: setTypeAndPossibleValues

 function setTypeAndPossibleValues()
 {
     // The presence of "-" at the beginning of a property name
     // (which happens if SF tries to parse an inverse query)
     // leads to an error in SMW - just exit if that's the case.
     if (strpos($this->mSemanticProperty, '-') === 0) {
         return;
     }
     $proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
     if ($proptitle === null) {
         return;
     }
     $store = SFUtils::getSMWStore();
     // this returns an array of objects
     $allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
     $label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
     $propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
     $this->mPropertyType = $propValue->findPropertyTypeID();
     foreach ($allowed_values as $allowed_value) {
         // HTML-unencode each value
         $this->mPossibleValues[] = html_entity_decode($allowed_value);
         if (count($label_formats) > 0) {
             $label_format = $label_formats[0];
             $prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
             $label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
             $label_value->setOutputFormat($label_format);
             $this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
         }
     }
     // HACK - if there were any possible values, set the property
     // type to be 'enumeration', regardless of what the actual type is
     if (count($this->mPossibleValues) > 0) {
         $this->mPropertyType = 'enumeration';
     }
 }
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:35,代码来源:SF_TemplateField.php

示例15: categories

 /**
  * The category list template. Used by article pages on view and edit save.
  */
 public function categories()
 {
     wfProfileIn(__METHOD__);
     $categories = $this->request->getVal('categories', array());
     $data = array();
     // Because $out->getCategoryLinks doesn't maintain the order of the stored category data,
     // we have to build this information ourselves manually. This is essentially the same
     // code from $out->addCategoryLinks() but it results in a different data format.
     foreach ($categories as $category) {
         // Support category name or category data object
         $name = is_array($category) ? $category['name'] : $category;
         $originalName = $name;
         $title = Title::makeTitleSafe(NS_CATEGORY, $name);
         if ($title != null) {
             $this->wg->ContLang->findVariantLink($name, $title, true);
             if ($name != $originalName && array_key_exists($name, $data)) {
                 continue;
             }
             $text = $this->wg->ContLang->convertHtml($title->getText());
             $data[$name] = array('link' => Linker::link($title, $text), 'name' => $text, 'type' => CategoryHelper::getCategoryType($originalName));
         } else {
             \Wikia\Logger\WikiaLogger::instance()->warning("Unsafe category provided", ['name' => $name]);
         }
     }
     $this->response->setVal('categories', $data);
     wfProfileOut(__METHOD__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:CategorySelectController.class.php


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