Commit graph

54 commits

Author SHA1 Message Date
Santhosh Thottingal
8824515e57 Fix Bug 30681 - Wrong escaping for inexistent messages.
- If the message does not exist, do an early return from the toString method, instead of going through replaceParameter and format comparisons.
- Avoid getMessageText method.
- If the format is plain, do not escape the angle brackets.

Change-Id: I4561ee75d991ef8df3399ab17e5d75cb81f63f8f
2012-03-28 11:32:04 +05:30
Alexandre Emsenhuber
345a593955 Follow-up r113223: set the "interface" flag in Message to true by default and set it to false when the page is included.
The point is to have the fix applied to all usages of IContextSource::msg() calls instead of only SpecialPage.
2012-03-13 18:41:13 +00:00
Niklas Laxström
455d6dae19 My proposed fix to bug 34987: gender not working in many special pages.
I haven't checked if there are other places whereh context is set to Message class, but if there are they might need a fix too.
2012-03-07 10:13:58 +00:00
Aaron Schulz
0f151738ea r80240: throw an exception if an empty message key array is given 2012-02-07 00:20:27 +00:00
Antoine Musso
1d594f6cc0 update Message class doc
Ping r110054
2012-01-26 14:55:38 +00:00
Chad Horohoe
048b9172f0 Fix r110054, \ -> @ 2012-01-26 13:45:50 +00:00
Antoine Musso
7bdbb72e88 enhance doxygen generation for Message class 2012-01-26 11:34:30 +00:00
Brian Wolff
64988333fd Update documentation on params method of Message class to indicate it can either be varags, or it can also
take an array of all the parameters as the first argument.
2011-12-22 00:51:43 +00:00
John Du Hart
216d661d3b Bug 29524 - Rename RequestContext::getLang to getLanguage
I'll be amazed if this doens't break any tests.
2011-11-21 16:13:21 +00:00
Alexandre Emsenhuber
b212bace90 Per Nikerabbit's comment on r100621:
* Removed OutputPage::setPageTitleMsg() and OutputPage::setHTMLTitleMsg() and make OutputPage::setPageTitle() and OutputPage::setHTMLTitle() accept a Message object
* Updated core calls (including some that I missed last time because of non-matching case)
* Added Message::setContext() and use it in RequestContext so that I don't need to duplicate the call in OutputPage
* Yes, I'm calling $this->msg() on places and then setting the context one more time in OutputPage::setPageTitle() or OutputPage::setHTMLTitle(), but at least I won't be confused about which objects $
2011-10-27 20:23:16 +00:00
Sam Reed
fb32210aee Whitespace/documentation 2011-09-14 15:07:20 +00:00
Platonides
c7137c50a4 Follow up r89585. Clean up after the test, expand inContentLanguage() comment. 2011-06-06 21:24:23 +00:00
Niklas Laxström
73776c92ee Fix for bug 29274 - Message class ignores $wgForceUIMsgAsContentMsg
Also added tests, which pass
2011-06-06 17:55:19 +00:00
Siebrand Mazeland
75c6696aa8 Use consistent notation for "@todo FIXME". Should update http://svn.wikimedia.org/doc/todo.html nicely. 2011-05-17 22:03:20 +00:00
Happy-melon
21813a563c Follow-up r86775: restub $wgLang. Not because it's a good idea, but because I can't see how to avoid the circular dependencies on it *without* stubbing it. Probably easier to just continue the drive to deprecate the global variable altogether. 2011-04-24 10:50:51 +00:00
Alexandre Emsenhuber
b454219e06 Don't double escape html entities for messages obtained through Message::escaped().
Since we require PHP 5.2.3+ and htmlspecialchars() has a fourth parameter to prevent double escaping since... PHP 5.2.3 (per manual), let's use it
2011-04-23 16:27:29 +00:00
Happy-melon
c80535ae10 Stop stubbing $wgLang and $wgContLang. There are no major code paths which do not call either $wgLang or $wgContLang at least once. All index.php calls unstub $wgContLang from MediaWiki::parseTitle() except in the edgecase of viewing pages referenced only by "curid=123", and since those will end up calling OutputPage::output() they will eventually be unstubbed at some point as well. All calls through load.php unstub $wgLang in ResourceLoaderContext::getLanguage() from ResouceLoader::respond() --> ResourceLoader::preloadModuleInfo(). All calls through api.php unstub $wgContLang in ApiResult::cleanUpUTF8() from ApiMain::printResult(). 2011-04-23 15:19:38 +00:00
Sam Reed
42b9b27823 Followup to r86312
<ialex> Reedy: that rev is breaking usage of {{PAGENAME}} in messages, such as in MediaWiki:Noarticles

Allowing optional passing in of a Title object (like it may be set in Message), but if it's not set, or not a title object, fall back and use $wgTitle (I'm sorry!)
2011-04-22 20:17:21 +00:00
Sam Reed
5622567290 Followup rr86304
We need a title object for parsing, do one against the message key

Doesn't seem to be the best way, but it's the most applicable. If I abused $wgTitle, Chad would come and beat me too ;)
2011-04-18 14:02:13 +00:00
Sam Reed
9c19cb6e38 Followup r86304
Things won't just happily accept a ParserOutput object when they were getting strings before

Add missing calling parameter
2011-04-18 13:53:24 +00:00
Sam Reed
3a0ed7a044 * (bug 28532) wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()
* (bug 16129) Transcluded special pages expose strip markers when they output parsed messages

Also adding some related documentation during my travels around the code
2011-04-18 12:43:53 +00:00
Alexandre Emsenhuber
ef1144e2e1 Per Hashar, fix for r83673: only accept StubContLang and StubUserLang for stub objects 2011-03-19 12:53:56 +00:00
Happy-melon
522628555a Implement __toString() magic method for Message objects 2011-03-13 15:12:54 +00:00
Alexandre Emsenhuber
9f4fcee5be Per Jarry1250 on IRC: fix for r81469: accept StubObject in Message::inLanguage(); was breaking api.php?action=query&meta=allmessages 2011-03-10 21:39:24 +00:00
Niklas Laxström
7fb251ba6c Fixed two bugs in message parameter handling:
* missing check for is_array caused $foo["raw"] to return true when $foo is string: bug 27298
* Some parameters could be replaced twice or more: r80764
2011-02-10 09:10:47 +00:00
Alexandre Emsenhuber
195eafd6ef * Add a amtitle param to meta=allmessages
Only used used when amenableparser is passed; the user can now define the page used for {{PAGENAME}} and related stuff instead of being hardcoded to "API"
2011-02-09 15:19:45 +00:00
Alexandre Emsenhuber
304c8ff3d4 Allow parameter to be passed with an array in the first parameter (as other wfMsg*() functions) 2011-02-04 16:47:24 +00:00
Alexandre Emsenhuber
51c6afc751 * Replaced $wgMessageCache by MessageCache::singleton(); since we only use one instance of this class (as for ParserCache, LinkCache)
* MessageCache::singleton() calls wfGetMessageCacheStorage() directly instead of using $messageMemc, just in case this would be called before that variable is set
* Per TimStarling: also removed deprecated methods in MessageCache class: addMessages() and related, [get|set|enable|disable]Transform(), loadAllMessages(), loadMessageFile() and some others. Same for the legacyData stuff in LocalisationCache that was only used by MessageCache::addMessages() and related. 
* Converted remaining extensions
2011-01-26 15:42:04 +00:00
Bryan Tong Minh
269bf3c239 Add automatic formatting of numeric parameters to Message 2011-01-22 20:23:51 +00:00
Alexandre Emsenhuber
c1aa3f3a8d Removed unused global 2011-01-16 20:31:09 +00:00
Daniel Friesen
a7ccb0fbb3 Fix boolean for $editnotice_base message existance check that was messed up in r80248.
Also switch to using === for '' and '-' comparison like Nikerabbit wanted.
2011-01-14 22:46:08 +00:00
Daniel Friesen
39ab3cfc9f Implement Message::isBlank and Message::isDisabled.
And while we're at it... update a random assortment of code using wfEmptyMsg to use the new wfMessage class and our exists/isBlank/isDisabled methods.
2011-01-14 10:51:05 +00:00
Daniel Friesen
2f933fedba Fix bug 14267 by adding support for a MediaWiki:Mainpage-nstab.
Additionally, *cough* *cough*:
* Add a Title::isMainPage helper for the fairly common $title->equals( Title::newMainPage() ); test.
* Update wfMessageFallback to also accept an array of message keys instead of requiring them listed as arguments to the function.
* Move the bulk of wfMessageFallback code into Message.php instead of leaving it in GlobalFunctions.php
* Change the wfMessageFallback implementation so that the Message class handles the fallbacks themselves eliminating any side effects caused by the fact that wfEmptyMsg always used usedb=false, language=userlang when one might actually use a different language or usedb setting in the message object that actually returned the text (this may be considered a wfEmptyMsg regression in 1.18).
* Make blank "" message contents fallback like nonexistant messages do.
* Re use the new tabAction array handling used to support mainpage-nstab in the talk and view tabs instead of making wfEmptyMsg calls directly in SkinTemplate.
2011-01-14 08:32:10 +00:00
Alexandre Emsenhuber
1e22a9dbde Allow OutputPage::parse() to parse in any langauge, modified wfMsgExt() and wfMessage() accordingly 2011-01-05 12:24:39 +00:00
Niklas Laxström
df5e9a91a7 (bug 25273) Message::params() triggers a fatal error.
Patch by hashar.
2010-09-23 19:15:58 +00:00
Chad Horohoe
4a025d936a Skip new object construction if it's going to be the same 2010-09-22 19:19:47 +00:00
Niklas Laxström
9eebeaa3d1 Fix to language handling 2010-09-20 13:24:31 +00:00
Niklas Laxström
ab9595e304 One step forward with the Message class.
wfMessage can be used now. Later the old wfMsg* function will be changed to just wrappers over the new class.
2010-09-02 17:12:56 +00:00
Niklas Laxström
f3511bbc69 Update syntax examples a bit 2010-07-08 09:03:47 +00:00
Niklas Laxström
f33313abdc Fixed a bug in __construct 2010-03-31 10:10:49 +00:00
Niklas Laxström
b4f9c12705 Fix syntax terrors 2010-03-29 19:18:58 +00:00
Max Semenik
3b1a10c0c6 Started tests for Message class, fixed one bug found by them 2010-03-29 14:30:42 +00:00
Niklas Laxström
206632ac47 Message::key() accepts message parameters as varargs. Renamed ::language() to ::inLanguage() 2010-03-29 14:08:23 +00:00
Roan Kattouw
d4cbde99eb Message.php fixes:
* Don't call params() for every param passed to the constructor
* Use self
* Use array_merge() instead of += , the latter behaves contrary to the documentation
* Fix capitalization of toString() calls
* Various style, typo fixes
2010-03-28 19:23:39 +00:00
Niklas Laxström
a92fb166fb Remove options array and move message fetching one level down.
Options is now to value members: format and useDatabase.
fetchMessage() can be overwritten to use other message source
like for example testing purposes.
2010-03-28 15:22:49 +00:00
Chad Horohoe
ecbd13d6e4 Factory functions are static 2010-03-28 14:53:01 +00:00
Alexandre Emsenhuber
77cfdb7bb2 Modified the documentation for better rendering in doxygen 2010-03-25 21:28:27 +00:00
Happy-melon
209fa62c8e Various tweaks and fixes. 2010-03-25 20:52:52 +00:00
Happy-melon
77c882769c Work on Message.php:
* Just one function for adding parameters, not three.  
* Implement an options framework: one extra widget (get-message-not-from-db) already in use in wfMsgNoDB(), others will probably follow, so set up something to keep them clean.
* Lay the groundwork for supporting __tostring() when MW stops supporting PHP < 5.2.0
* Fix various fatal and non-fatal errors
* Make use of r64178 to clean out any dependency on the wfMsg* functions.
2010-03-25 20:34:56 +00:00
Chad Horohoe
9bae2600f1 This is PHP, updating docs to reflect that 2010-03-25 13:10:26 +00:00