r84967 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84966‎ | r84967 | r84968 >
Date:16:34, 29 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r84966
Modified paths:
  • /trunk/extensions/SemanticResultFormats/GraphViz/SRF_Graph.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/SRF_Messages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/GraphViz/SRF_Graph.php
@@ -63,6 +63,7 @@
6464 protected $m_nameProperty = false;
6565 protected $m_nodeShape = false;
6666 protected $m_parentRelation;
 67+ protected $m_wordWrapLimit = 25;
6768
6869 protected function readParameters( $params, $outputmode ) {
6970 SMWResultPrinter::readParameters( $params, $outputmode );
@@ -94,6 +95,10 @@
9596 if ( array_key_exists( 'nodeshape', $params ) && in_array( trim( $params['nodeshape'] ), self::$NODE_SHAPES ) ) {
9697 $this->m_nodeShape = trim( $params['nodeshape'] );
9798 }
 99+
 100+ if ( array_key_exists( 'wordwraplimit', $params ) && is_int( $params['wordwraplimit'] ) ) {
 101+ $this->m_wordWrapLimit = (int)$params['wordwraplimit'];
 102+ }
98103 }
99104
100105 protected function getResultText( /* SMWQueryResult */ $res, $outputmode ) {
@@ -162,7 +167,7 @@
163168 $isName = $this->m_nameProperty ? ( $i != 0 && $this->m_nameProperty === $propName ) : $i == 0;
164169
165170 if ( $isName ) {
166 - $name = $this->getWordWrappedText( $object->getShortText( $outputmode ), 20 );
 171+ $name = $this->getWordWrappedText( $object->getShortText( $outputmode ), $this->m_wordWrapLimit );
167172 }
168173
169174 if ( !( $this->m_nameProperty && $i == 0 ) ) {
@@ -196,7 +201,7 @@
197202 $nodeLinkURL = $nodeLinkTitle->getLocalURL();
198203 }
199204
200 - $text = $this->getWordWrappedText( $text, 20 );
 205+ $text = $this->getWordWrappedText( $text, $this->m_wordWrapLimit );
201206
202207 if ( $this->m_graphLink ) {
203208 $graphInput .= " \"$text\" [URL = \"$nodeLinkURL\"]; ";
@@ -236,6 +241,8 @@
237242 /**
238243 * Returns the word wrapped version of the provided text.
239244 *
 245+ * @since 1.5.4
 246+ *
240247 * @param string $text
241248 * @param integer $charLimit
242249 *
@@ -245,18 +252,21 @@
246253 $segments = array();
247254
248255 while ( strlen( $text ) > $charLimit ) {
 256+ // Find the last space in the allowed range.
249257 $splitPosition = strrpos( substr( $text, 0, $charLimit ), ' ' );
250258
251259 if ( $splitPosition === false ) {
 260+ // If there is no space (lond word), find the next space.
252261 $splitPosition = strpos( $text, ' ' );
253262
254263 if ( $splitPosition === false ) {
255 - $splitPosition = strlen( $text );
 264+ // If there are no spaces, everything goes on one line.
 265+ $splitPosition = strlen( $text ) - 1;
256266 }
257267 }
258268
259 - $segments[] = substr( $text, 0, $splitPosition );
260 - $text = substr( $text, $splitPosition );
 269+ $segments[] = substr( $text, 0, $splitPosition + 1 );
 270+ $text = substr( $text, $splitPosition + 1 );
261271 }
262272
263273 $segments[] = $text;
@@ -284,6 +294,7 @@
285295 array( 'name' => 'nodeshape', 'type' => 'enumeration', 'description' => wfMsg( 'srf-paramdesc-graph-nodeshape' ), 'values'=> self::$NODE_SHAPES ),
286296 array( 'name' => 'nameproperty', 'type' => 'text', 'description' => wfMsg( 'srf-paramdesc-graph-nameprop' ) ),
287297 array( 'name' => 'relation', 'type' => 'enumeration', 'description' => wfMsg( 'srf-paramdesc-graph-relation' ), 'values'=> array( 'parent', 'child' ) ),
 298+ array( 'name' => 'wordwraplimit', 'type' => 'int', 'description' => wfMsg( 'srf-paramdesc-graph-wwl' ) ),
288299 );
289300 }
290301
Index: trunk/extensions/SemanticResultFormats/SRF_Messages.php
@@ -110,7 +110,8 @@
111111 'srf_paramdesc_graphlabel' => 'Graph label',
112112 'srf_paramdesc_rankdir' => 'Graph build direction',
113113 'srf_paramdesc_graphlink' => 'Graph link',
114 - 'srf_paramdesc_graphcolor' => 'Graph color'
 114+ 'srf_paramdesc_graphcolor' => 'Graph color',
 115+ 'srf-paramdesc-graph-wwl' => 'Word wrap limit (in # characters)',
115116 );
116117
117118 /** Message documentation (Message documentation)

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84966added word wrapjeroendedauw16:26, 29 March 2011

Status & tagging log