* Put "not yet written" in the title attribute of red links, so that readers unfamiliar with the site might guess what the colour means.
* Fixed minor bugs and refactored code in the vicinity of EditPage::edit().
* (bug 12857) Patrol link on new pages should clear floats
* (bug 12968) Render redirect wikilinks in a redirect class for customization
via user/site CSS.
-* EditPageBeforeEditButtons hook added for altering the edit buttons below the edit box
+* EditPageBeforeEditButtons hook added for altering the edit buttons below the
+ edit box.
+* __HIDDENCAT__ on a category page causes the category to be hidden on the
+ article page.
+* Don't show edit permissions errors on a red link click, just redirect to the
+ article. This is so that readers who don't know what a red link is aren't
+ confused when they are told they are range-blocked.
+* Put "not yet written" in the title attribute of red links, so that readers
+ unfamiliar with the site might guess what the colour means.
=== Bug fixes in 1.12 ===
}
if( wfReadOnly() ) {
- $wgOut->readOnlyPage( $this->getContent() );
+ $this->readOnlyPage( $this->getContent() );
wfProfileOut( __METHOD__ );
return;
}
$permErrors = $this->mTitle->getUserPermissionsErrors('edit', $wgUser);
if( !$this->mTitle->exists() ) {
- # We can't use array_diff here, because that considers ANY TWO
- # ARRAYS TO BE EQUAL. Thanks, PHP.
- $createErrors = $this->mTitle->getUserPermissionsErrors('create', $wgUser);
- foreach( $createErrors as $error ) {
- # in_array() actually *does* work as expected.
- if( !in_array( $error, $permErrors ) ) {
- $permErrors[] = $error;
- }
- }
+ $permErrors = array_merge( $permErrors,
+ wfArrayDiff2( $this->mTitle->getUserPermissionsErrors('create', $wgUser), $permErrors ) );
}
# Ignore some permissions errors.
$remove = array();
foreach( $permErrors as $error ) {
- if ($this->preview || $this->diff &&
+ if ( ( $this->preview || $this->diff ) &&
($error[0] == 'blockedtext' || $error[0] == 'autoblockedtext'))
{
// Don't worry about blocks when previewing/diffing
}
}
}
- $permErrors = array_diff( $permErrors, $remove );
+ $permErrors = wfArrayDiff2( $permErrors, $remove );
- if ( !empty($permErrors) ) {
+ if ( $permErrors ) {
wfDebug( __METHOD__.": User can't edit\n" );
- $wgOut->readOnlyPage( $this->getContent(), true, $permErrors );
+ $this->readOnlyPage( $this->getContent(), true, $permErrors );
wfProfileOut( __METHOD__ );
return;
} else {
wfProfileOut( __METHOD__ );
}
+ /**
+ * Show a read-only error
+ * Parameters are the same as OutputPage:readOnlyPage()
+ * Redirect to the article page if action=editredlink
+ */
+ function readOnlyPage( $source = null, $protected = false, $reasons = array() ) {
+ global $wgRequest, $wgOut;
+ if ( $wgRequest->getVal( 'action' ) === 'editredlink' ) {
+ // The edit page was reached via a red link.
+ // Redirect to the article page and let them click the edit tab if
+ // they really want a permission error.
+ $wgOut->redirect( $this->mTitle->getFullUrl() );
+ } else {
+ $wgOut->readOnlyPage( $source, $protected, $reasons );
+ }
+ }
+
/**
* Should we show a preview when the edit form is first shown?
*
}
}
+/**
+ * Like array_diff( $a, $b ) except that it works with two-dimensional arrays.
+ */
+function wfArrayDiff2( $a, $b ) {
+ return array_udiff( $a, $b, 'wfArrayDiff2_cmp' );
+}
+function wfArrayDiff2_cmp( $a, $b ) {
+ if ( !is_array( $a ) ) {
+ return strcmp( $a, $b );
+ } elseif ( count( $a ) !== count( $b ) ) {
+ return count( $a ) < count( $b ) ? -1 : 1;
+ } else {
+ reset( $a );
+ reset( $b );
+ while( ( list( $keyA, $valueA ) = each( $a ) ) && ( list( $keyB, $valueB ) = each( $b ) ) ) {
+ $cmp = strcmp( $valueA, $valueB );
+ if ( $cmp !== 0 ) {
+ return $cmp;
+ }
+ }
+ return 0;
+ }
+}
/**
* Wrapper for clone(), for compatibility with PHP4-friendly extensions.
* @param $text String: FIXME
* @param $class String: CSS class of the link, default ''.
*/
- function getInternalLinkAttributesObj( &$nt, $text, $class='' ) {
+ function getInternalLinkAttributesObj( &$nt, $text, $class = '', $title = false ) {
$r = ($class != '') ? ' class="' . htmlspecialchars( $class ) . '"' : '';
- $r .= ' title="' . $nt->getEscapedText() . '"';
+ if ( $title === false ) {
+ $r .= ' title="' . $nt->getEscapedText() . '"';
+ } else {
+ $r .= ' title="' . htmlspecialchars( $title ) . '"';
+ }
return $r;
}
if( $nt->getNamespace() == NS_SPECIAL ) {
$q = $query;
} else if ( '' == $query ) {
- $q = 'action=edit';
+ $q = 'action=editredlink';
} else {
- $q = 'action=edit&'.$query;
+ $q = 'action=editredlink&'.$query;
}
$u = $nt->escapeLocalURL( $q );
if ( '' == $text ) {
$text = htmlspecialchars( $nt->getPrefixedText() );
}
- $style = $this->getInternalLinkAttributesObj( $nt, $text, 'new' );
+ $title = wfMsg( 'red-link-title', $nt->getText() );
+ $style = $this->getInternalLinkAttributesObj( $nt, $text, 'new', $title );
list( $inside, $trail ) = Linker::splitTrail( $trail );
$s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
}
$text .= '</ul>';
} else {
- $text .= '<div class="permissions-errors">' . call_user_func_array( 'wfMsgNoTrans', $errors[0]) . '</div>';
+ $text .= '<div class="permissions-errors">' . call_user_func_array( 'wfMsgNoTrans', reset( $errors ) ) . '</div>';
}
return $text;
}
/* Continue... */
case 'edit':
+ case 'editredlink':
if( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) {
$internal = $request->getVal( 'internaledit' );
$external = $request->getVal( 'externaledit' );
'sitenotice' => '-', # the equivalent to wgSiteNotice; don't translate or duplicate this message to other languages
'anonnotice' => '-', # don't translate or duplicate this message to other languages
'newsectionheaderdefaultlevel' => '== $1 ==', # don't translate or duplicate this message to other languages
+'red-link-title' => '$1 (not yet written)',
# Short words for each namespace, by default used in the namespace tab in monobook
'nstab-main' => 'Page',