Commit graph

1255 commits

Author SHA1 Message Date
Timo Tijhof
1dd14dcec0 EditPage: Optimise loading of mediawiki.toolbar module
Follows-up b3830611c4.

Unlike getEditToolbar(), which only runs if the user preference
is enabled, the loading of mediawiki.action.edit is unconditional.

As mediawiki.toolbar has already been separated from mediawiki.action.edit,
it's easy to load it conditionally instead of via a dependency
(mediawiki.action.edit doesn't depend on it for anything else).

Also:
* Remove odd 'false' values passed to User::getOption(). These
  options are part of MediaWiki core and always exist. The default
  value 'false' was ignored.
* Remove redundant closure. The domready callback already provides
  a closure and 'mw' is not used here (similar to jquery.mw-jump).

Change-Id: Ib2f4633b328cf8090df43b8d286cfcd77f95c5ea
2014-12-19 22:53:49 +00:00
umherirrender
e9586a8e36 Use more pretty output in ResourceLoader debug mode for arrays
Effected:
- mw.language.data
- mw.language.names
- mw.config.set
- mw.user.options.set for defaults
- mw.toolbar

Change-Id: I8a9e718ab15f0b3f80e12b817295c6843a570d46
2014-12-19 17:55:46 +01:00
Kevin Israel
9c2fb8b722 EditPage: Don't warn if the page already redirects to itself
Follows-up 0266068570.

Also improved the wording of the "selfredirect" message.

Change-Id: I89a4647c03ccc31db4812dedac107869b2721833
2014-12-15 19:52:01 +00:00
Tim Starling
90a3418cf2 Fix parenthesis placement in multi-line condition
After talking with the folks in #mediawiki-core, I decided that I can
put up with it, under protest, on the basis that it's arguably
consistent with PSR-2.

Change-Id: I5f0c0f8f0172674797970d306efe6439ce1c2b67
2014-12-11 15:33:38 +11:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
jenkins-bot
6662eb079e Merge "API edit: allow ConfirmEdit to use the merged parse" 2014-12-10 20:22:05 +00:00
Aaron Schulz
17431af154 Reuse page preview parses by using the edit stash system
* This also changes previews to render section edit tokens but
  remove them on output, avoiding cache fragmentation.
* Also shortened the resulting getStashKey() value.

Change-Id: Ic8fa87669106b960c76912b864788b781f6ee2e6
2014-12-09 22:43:01 +00:00
m4tx
0266068570 Display error when user tries to create self-redirect
Bug: T29683
Change-Id: Idcd7a50d12c8f124bc447805654b1a9e86dee3e4
2014-12-08 21:37:42 +01:00
Tim Starling
09a5febb7b API edit: allow ConfirmEdit to use the merged parse
ConfirmEdit was tripling the amount of time it took to save a typical
page via the API, since it was assuming that the APIEditBeforeSave hook
was giving unmerged wikitext, requiring a full parse of the content
before and after the edit in order to check the addurl trigger.
Apparently nobody bothered to update it after Ia59fb6bb.

APIEditBeforeSave is unusable anyway, because it is given the serialized
content, without any information about the content model. It really
needs the Content object in order to do it properly. So instead, adapt
EditFilterMergedContent for the purpose. Incidentally, that avoids the
inelegant defined('MW_API') check in ConfirmEdit's
EditFilterMergedContent handler, since both API and normal edits are
handled by EditFilterMergedContent in the same way.

Unfortunately the interpretation of the 'value' member in the Status
object passed to EditFilterMergedContent is not extensible, being an
integer instead of an associative array. So we add a custom member in
order to get the result array back down the stack.

Another obstacle to this design was the lack of an EditPage object
passed to EditFilterMergedContent. ConfirmEdit was previously directly
calling EditPage::showEditForm() with a $formCallback which outputs the
necessary HTML. Instead, I hacked up runPostMergeFilters() a bit, to
allow the hook to request that the edit page be shown again even if
hookError is not set. Then a new EditPage::showEditForm:fields hook does
the necessary HTML output, instead of $formCallback.

Marked $formCallback as deprecated, since I think it is now unused.

Change-Id: I4b4270dd868a643512d4717927858b6ef0556d8a
2014-12-05 17:10:20 +11:00
Aaron Schulz
3a6c9d36c9 Added ApiStashEdit module for pre-emptive edit parsing
* This lets edits be prepared while users enter edit summaries.
* The edit form will now make use of this API, controlled by
  $wgAjaxEditStash.

Change-Id: I4f4057bc0d1d4a66a8f7cfb7cdc26d443a8eb0c4
2014-12-03 22:38:41 +00:00
csteipp
fcbcab693f SECURITY: Require new right to change content model
Add the user right 'editcontentmodel', which is required to change the
content model while editing a Page.

Bug: 70901
Change-Id: I54f59539f1045092ec0de76c31cb47ca19c56874
2014-11-26 23:57:06 +01:00
Fomafix
3055160858 Use getHtmlCode() instead of getCode() to set the lang attribute
The lang attribute of HTML elements should conform to BCP 47.

Bug: 72939
Change-Id: I9b4a734753af2c9dd7256eec60781553bc76edbf
2014-11-06 14:53:57 +00:00
Chad Horohoe
6c30fff0ba Swap and for &&
Change-Id: I7821a62586cc2d2f929fb3d7d5046958a70efbd0
2014-10-23 13:03:14 -07:00
jenkins-bot
c5173b94e7 Merge "Mention translatewiki.net on edits only, when edit a default message" 2014-10-20 17:08:51 +00:00
umherirrender
ce08326cda Break long lines
Change-Id: I8d4e883058c21023273df88439cd145888833115
2014-10-14 19:30:43 +00:00
umherirrender
1b878854cb Mention translatewiki.net on edits only, when edit a default message
When editing a page in the mediawiki namespace the hint to
translatewiki.net is always shown, but it is unneeded, when the message
is not a default message and maybe used for warnings in abusefilter or
is a gadget description.

Change-Id: I7dbf030311e30ce852459e363c91e988ca15d86d
2014-10-11 21:14:43 +02:00
Matthew Flaschen
92bee8e99f Use neutral instead of progressive for secondary edit page buttons
Only applies if wgUseMediaWikiUIEverywhere is true.

Bug: 71628
Change-Id: Iae6d28e989a7c5b92ba8b31e166aa7b5d3244baf
2014-10-03 17:44:07 -04:00
Bartosz Dziewoński
d3c0ef7e13 mediawiki.toolbar: Properly deprecate #init
Change-Id: I0271258e5f33b21c68b6224ca74123a3723c9788
2014-10-03 13:45:04 +02:00
jenkins-bot
61a82801c2 Merge "Split mediawiki.toolbar from mediawiki.action.edit" 2014-10-03 11:39:10 +00:00
Timo Tijhof
b3830611c4 Split mediawiki.toolbar from mediawiki.action.edit
Follows-up 285c52039b.

Get rid of mediawiki.mediawiki.action.toolbar. Not keeping a
backwards-compat alias since this module is not supposed to be used
publicly in its current form.

Change-Id: I403216c6916e1f4d29216a55c3fe6c92eb68400b
2014-10-02 13:49:42 -07:00
jdlrobson
a155ac55ea Hygiene: Make construction of buttons easier
Stop littering MediaWiki with globals, provide a common
api for generating them similar to how we do text input
attributes before things get out of control.

Adds
* submitButton
* linkButton

Change-Id: I61bb3c358f755ed9f2153d94b744c1a9da02c456
2014-09-30 14:54:56 -07:00
Yuri Astrakhan
89ac348b77 Minor code cleanup and a doc type cleanup
Change-Id: Ib89226a83738d1205405eac3926bfaa578966133
2014-09-24 22:13:19 -04:00
Aaron Schulz
87337428f0 Removed redundant begin/commit calls
Change-Id: I33b496c5c57451eec24080a5b769020979fb51f0
2014-09-16 17:18:21 -07:00
jenkins-bot
98168be936 Merge "Save pages content in the default format of their content type" 2014-09-16 17:43:45 +00:00
jenkins-bot
96efe0bc66 Merge "Revamp classic edit toolbar not to hardcode paths in HTML" 2014-09-16 12:51:21 +00:00
umherirrender
75ed896537 Readd word-separator between edithelp link and newwindow hint
Was removed on I47db5eab4569514d039261d11b6dedb0eeae17b5

Change-Id: I34e10fb4d43384b9170d238629128ab46976f6b2
2014-09-15 20:59:21 +02:00
Tpt
799ce7055d Save pages content in the default format of their content type
Useful in order to be sure that only the default format is saved in the database (allow to implement optional formats useful for APIs but not used in the storage)

Change-Id: Ia703319aefc8d56c377cd7766dc5985c5c3c27c1
2014-09-15 18:58:19 +02:00
Bartosz Dziewoński
285c52039b Revamp classic edit toolbar not to hardcode paths in HTML
Also, try out a way to have per-module LESS variables defined in PHP.
This might come in handy in the future… Maybe for skin theme support?

(I recommend reviewing the file changes in the order below. :D)

includes/resourceloader/ResourceLoaderFileModule.php
  * Pass the context (ResourceLoaderContext) deeper down via
    readStyleFiles() and readStyleFile(). We need it to compile the
    .less files for the right language.
  * Extract LESS compiler creation to getLessCompiler().
  * Allow passing a LESS compiler instance to compileLessFile(), rather
    than getting one after the method is called.

  All of the changes are backwards-compatible.

includes/resourceloader/ResourceLoaderEditToolbarModule.php
  * New module to support getting the language data and passing it to
    LESS variables.

  It might be a good idea to factor out a reusable class for a LESS
  module with additional variables, but that would require more
  attention to design than I gave it.

resources/src/mediawiki.action/mediawiki.action.edit.toolbar/mediawiki.action.edit.toolbar.less
  * Glue code to use the language data defined by the module above and
    put it in final CSS.

includes/EditPage.php
  * Do not hardcode image URLs in output HTML, as they are provided in
    CSS now. This gets rid of some usage of globals.

  In fact, we should be able to finally move the inline JavaScript
  calls out of getEditToolbar(), but I'm already introducing too many
  changes for one patch. That can be done later.

languages/Language.php
  * Add getImageFiles() to complement existing getImageFile() method.
    Misleadingly named, it returns paths for images for the toolbar
    only (and no other ones at all).

skins/common/ → resources/src/mediawiki.action/mediawiki.action.edit.toolbar/
  * Moved all of the button images to new location.

  Also, boring cleanup that was harder before because we treated the
  paths as public API:
  * Placed default ones in en/ subdirectory.
  * Renamed cyrl/ to ru/.
  * Renamed ksh/button_S_italic.png → ksh/button_italic.png.

languages/messages/
  * Adjusting paths and filenames for the changes above.

resources/src/mediawiki.action/mediawiki.action.edit.css
resources/src/mediawiki.action/mediawiki.action.edit.js
  * Added styles and updated the script to make it possible to have
    non-<img> elements as toolbar buttons.
  * Consolidated styles that were already required, but defined
    somewhere else:
    * `cursor: pointer;` (from shared.css)
    * `vertical-align: middle;` (from commonElements.css)

Bug: 69277
Change-Id: I39d8ed4258c7da0fe4fe4c665cdb26c86420769c
2014-09-13 23:16:23 +02:00
jenkins-bot
160c028526 Merge "Fix for Ia9baaf0b: Make previously public variables public again" 2014-09-12 19:52:51 +00:00
jenkins-bot
d78b4eeff8 Merge "Revert "Toolbar: Only show on WikiText pages"" 2014-09-01 14:07:01 +00:00
Helder.wiki
a23f489f7d Revert "Toolbar: Only show on WikiText pages"
Classical toolbar no longer appears in Page namespace on Wikisources.

This reverts commit 7263ef1e00.

Bug: 69447
Bug: 29908
Change-Id: Ifafe41f7bc91183e0db4c10d8340a8b620b380bc
2014-09-01 12:52:12 +00:00
James D. Forrester
95c9eca7bf Better text for <anoneditwarning> in core
The message has been tweaked to be closer to the version used for several
years with success on the English Wikipedia and on some other wikis. In
particular, the calls-to-action now have individual links rather than
expecting users to be able to magically find them themselves, and a user-
facing justification for why they should log in.

Change-Id: I687e47c23618e536a8f3010d7a6f168feb7bfa72
2014-08-30 14:55:29 -07:00
Stephan Gambke
f09e458d39 Fix for Ia9baaf0b: Make previously public variables public again
Change Ia9baaf0b changed the visibility of member variables (many of which are not
otherwise exposed, e.g. by a method) and by that introduced a major API change
breaking extensions.

This patch explicitly marks affected variables as public again, keeping the intent
of the original patch of making phpcs-strict pass on includes/ directory.

Bug: 67522
Bug: 67984
Change-Id: I498512b2a1e615365bb477c1fd210aaa3241ca03
2014-08-29 23:01:53 +02:00
Brian Wolff
b6662ee1a0 Make EditPage::tokenOK public for SemanticForms.
This partially reverts a7fbdd6503

Bug: 67522
Change-Id: Ia390975c3a46f1016567f1bcdabe3ec536bb6af6
2014-08-29 14:04:13 -03:00
umherirrender
b409008ca5 Remove wrong @return from doc blocks
These functions actually does not return anything, so the @return is
wrong here. '@return void' is ignored.

Change-Id: I11495ee05b943c16c1c4715d617c8b50de22276c
2014-08-25 13:50:05 +00:00
umherirrender
7c6a25856c Add missing @return to function docs
Change-Id: I45b9d02f94ecc58372268ec5e6a0b572a0b7e2a9
2014-08-23 23:14:57 +02:00
Bartosz Dziewoński
f05788bac6 EditPage: Remove unused classic toolbar accesskeys data
Clearly this is not going to ever be used. Half of these conflict with
something else anyway.

Change-Id: I21ada83eba4638b3eb820b62c0c1eb90951e6f9b
2014-08-20 18:42:33 +02:00
jdlrobson
aa15d5287d Add blanket support for mediawiki ui via globals
This provides better mobile experiences on various pages
and a more consistent UI across both mobile and desktop.

It does this in two ways.

1) Forces HTMLForms to not use table based layouts so as
not to interfere with responsive nature of mediawiki ui elements

2) Applies MediaWiki.UI classes to most pages
If a page is created via Xml or Html classes it will use mediawiki ui
Where possible I've added classes unconditionally, but for cases of buttons
this is behind the $wgUseMediaWikiUIEverywhere global since button styling is
enabled on pages by default and for checkboxes since it is changes HTML markup.

3) Adds all MediaWiki.UI styles to pages which can use it
When enabled:
* Apply these styles to all pages which use HTMLForms
* Apply to EditPage
* Apply to anything that uses certain elements outputted by the
Xml or HTML helper classes
* Apply to History page
* Apply to protection page
* Apply to move page
* Apply to deletion page

Currently kept behind a global to allow us time to finetune
existing elements. After further testing we will look to kill the
globals and make mediawiki.ui the default

See: I430c0fbb79d2a33bb828b2427bda0ee01115d73f
Change-Id: I47db5eab4569514d039261d11b6dedb0eeae17b5
2014-08-15 14:48:00 -07:00
jenkins-bot
e173358375 Merge "EditPage::newSectionSummary should return a value in all code paths" 2014-08-13 16:41:49 +00:00
Bartosz Dziewoński
e0b331d16b Remove some silly references to skins/common/
Change-Id: I7676de39bf43ab01776198531e337b34405b941a
2014-08-07 02:05:42 +02:00
Brad Jorsch
b62f3428de EditPage::newSectionSummary should return a value in all code paths
Followup I72890c06.

Change-Id: Id63c3f3d2c180d193c37091dfe5f1c56e3edb45f
2014-08-04 10:48:00 -04:00
withoutaname
1ebad72b0b Remove functions deprecated since 1.21 from EditPage.php
Specifically functions getContent(), getPreloadedText(), mergeChangesInto()
and setPreloadedText().

Change-Id: I5a258b4f060b1a3ae1218b8a8f424f2c9e8f146e
2014-07-30 09:02:43 -07:00
jenkins-bot
6bb74d527e Merge "Remove functions deprecated since 1.19 from EditPage.php" 2014-07-30 15:59:26 +00:00
withoutaname
8a2c384d6f Remove functions deprecated since 1.19 from EditPage.php
Specifically functions blockedPage(), noCreatePermission(), readOnlyPage()
and userNotLoggedInPage().

Change-Id: I3f8b16037d15a8b743dff975a8d7fe2b531a40d9
2014-07-29 11:42:47 -07:00
Mwalker
b88d4628dc Merge "Toolbar: Only show on WikiText pages" 2014-07-29 16:52:51 +00:00
Étienne Beaulé
c3fcaba02f Enable the creation of empty pages
This change enables the direct creation of empty pages without needing
to use a work-around (such as "{{subst:ns:0}}"). A warning is added as
the message "blankarticle" to request confirmation that the empty page
was meant to be blank. A automatic edit summary has been added when
creating a blank page. The message is: "autosumm-newblank."

The API has been updated to permit the creation of empty pages, when
"text" is null, but not non-existant.

Unit tests have also been added to test these features.

Bug: 57238
Bug: 65206
Change-Id: I3457c36a909d1dbfaeed04a1f0568c69e0ef3386
2014-07-25 23:26:18 -04:00
umherirrender
1c68a1ee86 Cleanup some docs (includes/*.php)
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
2014-07-24 19:42:24 +02:00
withoutaname
da5090774f Remove two unused constants from EditPage.php
Specifically constants AS_USER_CANNOT_EDIT and AS_OK

Change-Id: I96b20962b7d4cab5c026a0f03abf9da066fbd9af
2014-07-21 17:50:47 -07:00
umherirrender
53c420e278 Fixed spacing
- use tab as indent instead of spaces
- Added space after closures "function"
- Added spaces around string_concat
- Added newline inside empty blocks
- Removed four spaces after comma

Change-Id: I4425b0c6a69b36f40acfea6511b8950cf09ce2b2
2014-07-20 21:41:41 +02:00
Brad Jorsch
355cbd2e3e Actually detect duplicate section=new submissions
The current check will basically never pass, since it's looking for the
submitted section title to match the section title inserted into the
'newsectionsummary' message.

So let's factor out the code for applying 'newsectionsummary' and use
that for the conflict check. We can't just update $this->summary
earlier, since later checks depend on looking at the submitted summary
rather than the mangled one.

Bug: 67634
Change-Id: I72890c0641f991696ec98b50a6a42b2be7f46f63
2014-07-07 18:49:04 -04:00