* Added article size limit, $wgMaxArticleSize
* (bug 4974) Don't follow redirected talk page on "new messages" link
* (bug 4970) Make category paging limits configurable
+* (bug 4535) Warn user when editing CSS or JS subpage of a skin that doesn't exist
=== Caveats ===
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
- $this->isCssJsSubpage = $wgTitle->isCssJsSubpage();
+ $this->isCssJsSubpage = $wgTitle->isCssJsSubpage();
+ $this->isValidCssJsSubpage = $wgTitle->isValidCssJsSubpage();
/* Notice that we can't use isDeleted, because it returns true if article is ever deleted
* no matter it's current state
if( wfReadOnly() ) {
$wgOut->addWikiText( wfMsg( 'readonlywarning' ) );
- } else if ( $this->isCssJsSubpage and 'preview' != $this->formtype) {
- $wgOut->addWikiText( wfMsg( 'usercssjsyoucanpreview' ));
- } else if( $wgUser->isAnon() && $this->formtype != 'preview' ) {
+ } elseif( $wgUser->isAnon() && $this->formtype != 'preview' ) {
$wgOut->addWikiText( wfMsg( 'anoneditwarning' ) );
+ } else {
+ if( $this->isCssJsSubpage && $this->formtype != 'preview' ) {
+ # Check the skin exists
+ if( $this->isValidCssJsSubpage ) {
+ $wgOut->addWikiText( wfMsg( 'usercssjsyoucanpreview' ) );
+ } else {
+ $wgOut->addWikiText( wfMsg( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ) );
+ }
+ }
}
-
+
if( $this->mTitle->isProtected( 'edit' ) ) {
if( $this->mTitle->isSemiProtected() ) {
$notice = wfMsg( 'semiprotectedpagewarning' );
function isCssJsSubpage() {
return ( NS_USER == $this->mNamespace and preg_match("/\\.(css|js)$/", $this->mTextform ) );
}
+ /**
+ * Is this a *valid* .css or .js subpage of a user page?
+ * Check that the corresponding skin exists
+ */
+ function isValidCssJsSubpage() {
+ global $wgValidSkinNames;
+ return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), $wgValidSkinNames ) );
+ }
+ /**
+ * Trim down a .css or .js subpage title to get the corresponding skin name
+ */
+ function getSkinFromCssJsSubpage() {
+ $subpage = explode( '/', $this->mTextform );
+ $subpage = $subpage[ count( $subpage ) - 1 ];
+ return( str_replace( array( '.css', '.js' ), array( '', '' ), $subpage ) );
+ }
/**
* Is this a .css subpage of a user page?
* @return bool
'usercssjsyoucanpreview' => '<strong>Tip:</strong> Use the \'Show preview\' button to test your new CSS/JS before saving.',
'usercsspreview' => '\'\'\'Remember that you are only previewing your user CSS, it has not yet been saved!\'\'\'',
'userjspreview' => '\'\'\'Remember that you are only testing/previewing your user JavaScript, it has not yet been saved!\'\'\'',
+'userinvalidcssjstitle' => "'''Warning:''' There is no skin \"$1\". Remember that custom .css and .js pages use a lowercase title, e.g. User:Foo/monobook.css as opposed to User:Foo/Monobook.css.",
'updated' => '(Updated)',
'note' => '<strong>Note:</strong>',
'previewnote' => '<strong>This is only a preview; changes have not yet been saved!</strong>',