r101287 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101286‎ | r101287 | r101288 >
Date:21:41, 29 October 2011
Author:mkroetzsch
Status:resolved (Comments)
Tags:
Comment:
fixed " "/"_" encoding in fragment extraction;
improved display of page values on Property: pages
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -237,7 +237,7 @@
238238 $wgOut->setHTMLTitle( $this->subject->getTitle() );
239239 $html = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n" .
240240 "<tr class=\"smwb-title\"><td colspan=\"2\">\n" .
241 - $this->subject->getShortHTMLText( smwfGetLinker() ) . "\n" .
 241+ $this->subject->getLongHTMLText( smwfGetLinker() ) . "\n" .
242242 "</td></tr>\n</table>\n";
243243
244244 return $html;
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php
@@ -98,7 +98,7 @@
9999 if ( $value != '' ) {
100100 if ( $value{0} == '#' ) {
101101 if ( is_null( $this->m_contextPage ) ) {
102 - $this->addError( wfMsgForContent( 'smw_notitle', $value ) );
 102+ $this->addError( wfMsgForContent( 'smw_notitle', $value ) );
103103 return;
104104 } else {
105105 $this->m_title = Title::makeTitle( $this->m_contextPage->getNamespace(),
@@ -117,7 +117,7 @@
118118 $this->addError( wfMsgForContent( 'smw_wrong_namespace',
119119 $wgContLang->getNsText( $this->m_fixNamespace ) ) );
120120 } else {
121 - $this->m_fragment = $this->m_title->getFragment();
 121+ $this->m_fragment = str_replace( ' ', '_', $this->m_title->getFragment() );
122122 $this->m_prefixedtext = '';
123123 $this->m_id = -1; // unset id
124124 $this->m_dataitem = SMWDIWikiPage::newFromTitle( $this->m_title, $this->m_typeid );
@@ -250,9 +250,9 @@
251251 // There should not be a linebreak after an impage, just like there is no linebreak after
252252 // other values (whether formatted or not).
253253 return '[[' . $this->getWikiLinkTarget() . '|' .
254 - $this->getWikiValue() . '|frameless|border|text-top]]';
 254+ $this->getLongCaptionText() . '|frameless|border|text-top]]';
255255 } else {
256 - return '[[:' . $this->getWikiLinkTarget() . '|' . $this->getWikiValue() . ']]';
 256+ return '[[:' . $this->getWikiLinkTarget() . '|' . $this->getLongCaptionText() . ']]';
257257 }
258258 }
259259
@@ -276,10 +276,10 @@
277277 return htmlspecialchars( $this->getWikiValue() );
278278 } elseif ( $this->getNamespace() == NS_MEDIA ) { // this extra case is really needed
279279 return $linker->makeMediaLinkObj( $this->getTitle(),
280 - htmlspecialchars( $this->getWikiValue() ) );
 280+ htmlspecialchars( $this->getLongCaptionText() ) );
281281 } else { // all others use default linking, no embedding of images here
282282 return $linker->makeLinkObj( $this->getTitle(),
283 - htmlspecialchars( $this->getWikiValue() ) );
 283+ htmlspecialchars( $this->getLongCaptionText() ) );
284284 }
285285 }
286286
@@ -425,7 +425,7 @@
426426 * @return string
427427 */
428428 protected function getShortCaptionText() {
429 - if ( $this->m_fragment && $this->m_fragment{0} != '_' ) {
 429+ if ( $this->m_fragment != '' && $this->m_fragment{0} != '_' ) {
430430 $fragmentText = '#' . $this->m_fragment;
431431 } else {
432432 $fragmentText = '';
@@ -434,6 +434,25 @@
435435 }
436436
437437 /**
 438+ * Get a long caption used to label this value. In particular, this
 439+ * includes namespace and interwiki prefixes, while fragments are only
 440+ * included if they do not start with an underscore (used for generated
 441+ * fragment names that are not helpful for users and that might change
 442+ * easily).
 443+ *
 444+ * @since 1.7
 445+ * @return string
 446+ */
 447+ protected function getLongCaptionText() {
 448+ if ( $this->m_fragment && $this->m_fragment{0} != '_' ) {
 449+ $fragmentText = '#' . $this->m_fragment;
 450+ } else {
 451+ $fragmentText = '';
 452+ }
 453+ return ( $this->m_fixNamespace == NS_MAIN ? $this->getPrefixedText() : $this->getText() ) . $fragmentText;
 454+ }
 455+
 456+ /**
438457 * Compute a text that can be used in wiki text to link to this
439458 * datavalue. Processing includes some escaping and adding the
440459 * fragment.
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php
@@ -157,7 +157,7 @@
158158
159159 // Property name
160160 $searchlink = SMWInfolink::newBrowsingLink( '+', $dvWikiPage->getShortHTMLText() );
161 - $r .= '<tr><td class="smwpropname">' . $dvWikiPage->getLongHTMLText( smwfGetLinker() ) .
 161+ $r .= '<tr><td class="smwpropname">' . $dvWikiPage->getShortHTMLText( smwfGetLinker() ) .
162162 '&#160;' . $searchlink->getHTML( smwfGetLinker() ) . '</td><td class="smwprops">';
163163
164164 // Property values
@@ -174,7 +174,7 @@
175175
176176 if ( $i < $smwgMaxPropertyValues + 1 ) {
177177 $dv = SMWDataValueFactory::newDataItemValue( $di, $this->mProperty );
178 - $r .= $dv->getLongHTMLText( smwfGetLinker() ) . $dv->getInfolinkText( SMW_OUTPUT_HTML, smwfGetLinker() );
 178+ $r .= $dv->getShortHTMLText( smwfGetLinker() ) . $dv->getInfolinkText( SMW_OUTPUT_HTML, smwfGetLinker() );
179179 } else {
180180 $searchlink = SMWInfolink::newInversePropertySearchLink( '…', $dvWikiPage->getWikiValue(), $this->mTitle->getText() );
181181 $r .= $searchlink->getHTML( smwfGetLinker() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r101467adressed fixme for r101287 (deprecated syntax $string{0} and imprecise string...mkroetzsch12:45, 1 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   08:49, 30 October 2011

{0} is deprecated syntax for indexing strings, should use [0].

+		if ( $this->m_fragment && $this->m_fragment{0} != '_' ) {

Is "000" not a valid fragment?

#Comment by Markus Krötzsch (talk | contribs)   12:47, 1 November 2011

Thanks. Fixed in r101467.

Status & tagging log