r68525 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68524‎ | r68525 | r68526 >
Date:19:10, 24 June 2010
Author:juliano
Status:deferred
Tags:
Comment:
Consistency fixes on edit links:
* Put edit links inside their h2 heading.
* Honor user preferences when displaying edit links.
Modified paths:
  • /trunk/extensions/Wikilog/Wikilog.i18n.php (modified) (history)
  • /trunk/extensions/Wikilog/WikilogItemPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikilog/WikilogItemPager.php
@@ -60,6 +60,7 @@
6161 # Local variables.
6262 protected $mQuery = null; ///< Wikilog item query data
6363 protected $mIncluding = false; ///< If pager is being included
 64+ protected $mShowEditLink = false; ///< If edit links are shown.
6465
6566 /**
6667 * Constructor.
@@ -91,11 +92,17 @@
9293 if ( $this->mLimit > $wgWikilogExpensiveLimit )
9394 $this->mLimit = $wgWikilogExpensiveLimit;
9495
95 - # We will need a clean parser if not including.
96 - global $wgParser;
97 - if ( !$this->mIncluding ) {
 96+ # Check parser state, setup edit links.
 97+ global $wgOut, $wgParser;
 98+ if ( $this->mIncluding ) {
 99+ $popt = $wgParser->getOptions();
 100+ } else {
 101+ $popt = $wgOut->parserOptions();
 102+
 103+ # We will need a clean parser if not including.
98104 $wgParser->clearState();
99105 }
 106+ $this->mShowEditLink = $popt->getEditSection();
100107 }
101108
102109 /**
@@ -161,10 +168,10 @@
162169 $heading = $skin->link( $item->mTitle, $titleText, array(), array(),
163170 array( 'known', 'noclasses' )
164171 );
 172+ if ( $this->mShowEditLink && $item->mTitle->quickUserCan( 'edit' ) ) {
 173+ $heading = $this->doEditLink( $item->mTitle, $item->mName ) . $heading;
 174+ }
165175 $heading = Xml::tags( 'h2', null, $heading );
166 - if ( $item->mTitle->quickUserCan( 'edit' ) ) {
167 - $heading = $this->editLink( $item->mTitle ) . $heading;
168 - }
169176
170177 # Sumary entry header.
171178 $key = $this->mQuery->isSingleWikilog()
@@ -226,14 +233,28 @@
227234 /**
228235 * Returns a wikilog article edit link, much similar to a section edit
229236 * link in normal articles.
230 - * @param $title Wikilog article title object.
231 - * @return HTML fragment.
 237+ * @param $title Title The title of the target article.
 238+ * @param $tooltip string The tooltip to be included in the link, wrapped
 239+ * in the 'wikilog-edit-hint' message.
 240+ * @return string HTML fragment.
232241 */
233 - private function editLink( $title ) {
 242+ private function doEditLink( $title, $tooltip = null ) {
234243 $skin = $this->getSkin();
235 - $url = $skin->makeKnownLinkObj( $title, wfMsg( 'wikilog-edit-lc' ), 'action=edit' );
236 - $result = wfMsg( 'editsection-brackets', $url );
237 - return "<span class=\"editsection\">$result</span>";
 244+ $attribs = array();
 245+ if ( !is_null( $tooltip ) ) {
 246+ $attribs['title'] = wfMsg( 'wikilog-edit-hint', $tooltip );
 247+ }
 248+ $link = $skin->link( $title, wfMsg( 'wikilog-edit-lc' ),
 249+ $attribs,
 250+ array( 'action' => 'edit' ),
 251+ array( 'noclasses', 'known' )
 252+ );
 253+
 254+ $result = wfMsgHtml ( 'editsection-brackets', $link );
 255+ $result = "<span class=\"editsection\">$result</span>";
 256+
 257+ wfRunHooks( 'DoEditSectionLink', array( $skin, $title, "", $tooltip, &$result ) );
 258+ return $result;
238259 }
239260 }
240261
@@ -488,7 +509,7 @@
489510
490511 case '_wl_actions':
491512 if ( $this->mCurrentItem->mTitle->quickUserCan( 'edit' ) ) {
492 - return $this->editLink( $this->mCurrentItem->mTitle );
 513+ return $this->doEditLink( $this->mCurrentItem->mTitle, $this->mCurrentItem->mName );
493514 } else {
494515 return '';
495516 }
@@ -553,13 +574,26 @@
554575 }
555576
556577 /**
557 - * Returns a wikilog article edit link for the actions column of the table.
558 - * @param $title Wikilog article title object.
559 - * @return HTML fragment.
 578+ * Returns a wikilog article edit link, much similar to a section edit
 579+ * link in normal articles.
 580+ * @param $title Title The title of the target article.
 581+ * @param $tooltip string The tooltip to be included in the link, wrapped
 582+ * in the 'wikilog-edit-hint' message.
 583+ * @return string HTML fragment.
560584 */
561 - private function editLink( $title ) {
 585+ private function doEditLink( $title, $tooltip = null ) {
562586 $skin = $this->getSkin();
563 - $url = $skin->makeKnownLinkObj( $title, wfMsg( 'wikilog-edit-lc' ), 'action=edit' );
564 - return wfMsg( 'wikilog-brackets', $url );
 587+ $attribs = array();
 588+ if ( !is_null( $tooltip ) ) {
 589+ $attribs['title'] = wfMsg( 'wikilog-edit-hint', $tooltip );
 590+ }
 591+ $link = $skin->link( $title, wfMsg( 'wikilog-edit-lc' ),
 592+ $attribs,
 593+ array( 'action' => 'edit' ),
 594+ array( 'noclasses', 'known' )
 595+ );
 596+
 597+ $result = wfMsgHtml ( 'editsection-brackets', $link );
 598+ return $result;
565599 }
566600 }
Index: trunk/extensions/Wikilog/Wikilog.i18n.php
@@ -90,6 +90,7 @@
9191 'wikilog-simple-signature' => '$1 ($2)',
9292
9393 # Edit page
 94+ 'wikilog-edit-hint' => 'Edit wikilog article: $1',
9495 'wikilog-edit-fieldset-legend' => 'Wikilog options:',
9596 'wikilog-edit-signpub' => 'Sign and publish this article',
9697 'wikilog-edit-signpub-tooltip' => 'Causes this article to be signed and published in its wikilog when saved.

Status & tagging log