Index: trunk/extensions/SemanticResultFormats/GraphViz/SRF_Graph.php |
— | — | @@ -63,6 +63,7 @@ |
64 | 64 | protected $m_nameProperty = false; |
65 | 65 | protected $m_nodeShape = false; |
66 | 66 | protected $m_parentRelation; |
| 67 | + protected $m_wordWrapLimit = 25; |
67 | 68 | |
68 | 69 | protected function readParameters( $params, $outputmode ) { |
69 | 70 | SMWResultPrinter::readParameters( $params, $outputmode ); |
— | — | @@ -94,6 +95,10 @@ |
95 | 96 | if ( array_key_exists( 'nodeshape', $params ) && in_array( trim( $params['nodeshape'] ), self::$NODE_SHAPES ) ) { |
96 | 97 | $this->m_nodeShape = trim( $params['nodeshape'] ); |
97 | 98 | } |
| 99 | + |
| 100 | + if ( array_key_exists( 'wordwraplimit', $params ) && is_int( $params['wordwraplimit'] ) ) { |
| 101 | + $this->m_wordWrapLimit = (int)$params['wordwraplimit']; |
| 102 | + } |
98 | 103 | } |
99 | 104 | |
100 | 105 | protected function getResultText( /* SMWQueryResult */ $res, $outputmode ) { |
— | — | @@ -162,7 +167,7 @@ |
163 | 168 | $isName = $this->m_nameProperty ? ( $i != 0 && $this->m_nameProperty === $propName ) : $i == 0; |
164 | 169 | |
165 | 170 | if ( $isName ) { |
166 | | - $name = $this->getWordWrappedText( $object->getShortText( $outputmode ), 20 ); |
| 171 | + $name = $this->getWordWrappedText( $object->getShortText( $outputmode ), $this->m_wordWrapLimit ); |
167 | 172 | } |
168 | 173 | |
169 | 174 | if ( !( $this->m_nameProperty && $i == 0 ) ) { |
— | — | @@ -196,7 +201,7 @@ |
197 | 202 | $nodeLinkURL = $nodeLinkTitle->getLocalURL(); |
198 | 203 | } |
199 | 204 | |
200 | | - $text = $this->getWordWrappedText( $text, 20 ); |
| 205 | + $text = $this->getWordWrappedText( $text, $this->m_wordWrapLimit ); |
201 | 206 | |
202 | 207 | if ( $this->m_graphLink ) { |
203 | 208 | $graphInput .= " \"$text\" [URL = \"$nodeLinkURL\"]; "; |
— | — | @@ -236,6 +241,8 @@ |
237 | 242 | /** |
238 | 243 | * Returns the word wrapped version of the provided text. |
239 | 244 | * |
| 245 | + * @since 1.5.4 |
| 246 | + * |
240 | 247 | * @param string $text |
241 | 248 | * @param integer $charLimit |
242 | 249 | * |
— | — | @@ -245,18 +252,21 @@ |
246 | 253 | $segments = array(); |
247 | 254 | |
248 | 255 | while ( strlen( $text ) > $charLimit ) { |
| 256 | + // Find the last space in the allowed range. |
249 | 257 | $splitPosition = strrpos( substr( $text, 0, $charLimit ), ' ' ); |
250 | 258 | |
251 | 259 | if ( $splitPosition === false ) { |
| 260 | + // If there is no space (lond word), find the next space. |
252 | 261 | $splitPosition = strpos( $text, ' ' ); |
253 | 262 | |
254 | 263 | if ( $splitPosition === false ) { |
255 | | - $splitPosition = strlen( $text ); |
| 264 | + // If there are no spaces, everything goes on one line. |
| 265 | + $splitPosition = strlen( $text ) - 1; |
256 | 266 | } |
257 | 267 | } |
258 | 268 | |
259 | | - $segments[] = substr( $text, 0, $splitPosition ); |
260 | | - $text = substr( $text, $splitPosition ); |
| 269 | + $segments[] = substr( $text, 0, $splitPosition + 1 ); |
| 270 | + $text = substr( $text, $splitPosition + 1 ); |
261 | 271 | } |
262 | 272 | |
263 | 273 | $segments[] = $text; |
— | — | @@ -284,6 +294,7 @@ |
285 | 295 | array( 'name' => 'nodeshape', 'type' => 'enumeration', 'description' => wfMsg( 'srf-paramdesc-graph-nodeshape' ), 'values'=> self::$NODE_SHAPES ), |
286 | 296 | array( 'name' => 'nameproperty', 'type' => 'text', 'description' => wfMsg( 'srf-paramdesc-graph-nameprop' ) ), |
287 | 297 | 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' ) ), |
288 | 299 | ); |
289 | 300 | } |
290 | 301 | |
Index: trunk/extensions/SemanticResultFormats/SRF_Messages.php |
— | — | @@ -110,7 +110,8 @@ |
111 | 111 | 'srf_paramdesc_graphlabel' => 'Graph label', |
112 | 112 | 'srf_paramdesc_rankdir' => 'Graph build direction', |
113 | 113 | '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)', |
115 | 116 | ); |
116 | 117 | |
117 | 118 | /** Message documentation (Message documentation) |