http://www.mediawiki.org/wiki/Special:Code/MediaWiki/68525
Revision: 68525 Author: juliano Date: 2010-06-24 19:10:52 +0000 (Thu, 24 Jun 2010) Log Message: ----------- 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 trunk/extensions/Wikilog/WikilogItemPager.php Modified: trunk/extensions/Wikilog/Wikilog.i18n.php =================================================================== --- trunk/extensions/Wikilog/Wikilog.i18n.php 2010-06-24 19:10:34 UTC (rev 68524) +++ trunk/extensions/Wikilog/Wikilog.i18n.php 2010-06-24 19:10:52 UTC (rev 68525) @@ -90,6 +90,7 @@ 'wikilog-simple-signature' => '$1 ($2)', # Edit page + 'wikilog-edit-hint' => 'Edit wikilog article: $1', 'wikilog-edit-fieldset-legend' => 'Wikilog options:', 'wikilog-edit-signpub' => 'Sign and publish this article', 'wikilog-edit-signpub-tooltip' => 'Causes this article to be signed and published in its wikilog when saved. Modified: trunk/extensions/Wikilog/WikilogItemPager.php =================================================================== --- trunk/extensions/Wikilog/WikilogItemPager.php 2010-06-24 19:10:34 UTC (rev 68524) +++ trunk/extensions/Wikilog/WikilogItemPager.php 2010-06-24 19:10:52 UTC (rev 68525) @@ -60,6 +60,7 @@ # Local variables. protected $mQuery = null; ///< Wikilog item query data protected $mIncluding = false; ///< If pager is being included + protected $mShowEditLink = false; ///< If edit links are shown. /** * Constructor. @@ -91,11 +92,17 @@ if ( $this->mLimit > $wgWikilogExpensiveLimit ) $this->mLimit = $wgWikilogExpensiveLimit; - # We will need a clean parser if not including. - global $wgParser; - if ( !$this->mIncluding ) { + # Check parser state, setup edit links. + global $wgOut, $wgParser; + if ( $this->mIncluding ) { + $popt = $wgParser->getOptions(); + } else { + $popt = $wgOut->parserOptions(); + + # We will need a clean parser if not including. $wgParser->clearState(); } + $this->mShowEditLink = $popt->getEditSection(); } /** @@ -161,10 +168,10 @@ $heading = $skin->link( $item->mTitle, $titleText, array(), array(), array( 'known', 'noclasses' ) ); + if ( $this->mShowEditLink && $item->mTitle->quickUserCan( 'edit' ) ) { + $heading = $this->doEditLink( $item->mTitle, $item->mName ) . $heading; + } $heading = Xml::tags( 'h2', null, $heading ); - if ( $item->mTitle->quickUserCan( 'edit' ) ) { - $heading = $this->editLink( $item->mTitle ) . $heading; - } # Sumary entry header. $key = $this->mQuery->isSingleWikilog() @@ -226,14 +233,28 @@ /** * Returns a wikilog article edit link, much similar to a section edit * link in normal articles. - * @param $title Wikilog article title object. - * @return HTML fragment. + * @param $title Title The title of the target article. + * @param $tooltip string The tooltip to be included in the link, wrapped + * in the 'wikilog-edit-hint' message. + * @return string HTML fragment. */ - private function editLink( $title ) { + private function doEditLink( $title, $tooltip = null ) { $skin = $this->getSkin(); - $url = $skin->makeKnownLinkObj( $title, wfMsg( 'wikilog-edit-lc' ), 'action=edit' ); - $result = wfMsg( 'editsection-brackets', $url ); - return "<span class=\"editsection\">$result</span>"; + $attribs = array(); + if ( !is_null( $tooltip ) ) { + $attribs['title'] = wfMsg( 'wikilog-edit-hint', $tooltip ); + } + $link = $skin->link( $title, wfMsg( 'wikilog-edit-lc' ), + $attribs, + array( 'action' => 'edit' ), + array( 'noclasses', 'known' ) + ); + + $result = wfMsgHtml ( 'editsection-brackets', $link ); + $result = "<span class=\"editsection\">$result</span>"; + + wfRunHooks( 'DoEditSectionLink', array( $skin, $title, "", $tooltip, &$result ) ); + return $result; } } @@ -488,7 +509,7 @@ case '_wl_actions': if ( $this->mCurrentItem->mTitle->quickUserCan( 'edit' ) ) { - return $this->editLink( $this->mCurrentItem->mTitle ); + return $this->doEditLink( $this->mCurrentItem->mTitle, $this->mCurrentItem->mName ); } else { return ''; } @@ -553,13 +574,26 @@ } /** - * Returns a wikilog article edit link for the actions column of the table. - * @param $title Wikilog article title object. - * @return HTML fragment. + * Returns a wikilog article edit link, much similar to a section edit + * link in normal articles. + * @param $title Title The title of the target article. + * @param $tooltip string The tooltip to be included in the link, wrapped + * in the 'wikilog-edit-hint' message. + * @return string HTML fragment. */ - private function editLink( $title ) { + private function doEditLink( $title, $tooltip = null ) { $skin = $this->getSkin(); - $url = $skin->makeKnownLinkObj( $title, wfMsg( 'wikilog-edit-lc' ), 'action=edit' ); - return wfMsg( 'wikilog-brackets', $url ); + $attribs = array(); + if ( !is_null( $tooltip ) ) { + $attribs['title'] = wfMsg( 'wikilog-edit-hint', $tooltip ); + } + $link = $skin->link( $title, wfMsg( 'wikilog-edit-lc' ), + $attribs, + array( 'action' => 'edit' ), + array( 'noclasses', 'known' ) + ); + + $result = wfMsgHtml ( 'editsection-brackets', $link ); + return $result; } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs