Index: trunk/extensions/SemanticResultFormats/GraphViz/SRF_Graph.php |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | $isName = $this->m_nameProperty ? ( $i != 0 && $this->m_nameProperty === $propName ) : $i == 0; |
164 | 164 | |
165 | 165 | if ( $isName ) { |
166 | | - $name = $object->getShortText( $outputmode ); |
| 166 | + $name = $this->getWordWrappedText( $object->getShortText( $outputmode ), 20 ); |
167 | 167 | } |
168 | 168 | |
169 | 169 | if ( !( $this->m_nameProperty && $i == 0 ) ) { |
— | — | @@ -194,7 +194,11 @@ |
195 | 195 | if ( $this->m_graphLink ) { |
196 | 196 | $nodeLinkTitle = Title::newFromText( $text ); |
197 | 197 | $nodeLinkURL = $nodeLinkTitle->getLocalURL(); |
198 | | - |
| 198 | + } |
| 199 | + |
| 200 | + $text = $this->getWordWrappedText( $text, 20 ); |
| 201 | + |
| 202 | + if ( $this->m_graphLink ) { |
199 | 203 | $graphInput .= " \"$text\" [URL = \"$nodeLinkURL\"]; "; |
200 | 204 | } |
201 | 205 | |
— | — | @@ -230,6 +234,37 @@ |
231 | 235 | } |
232 | 236 | |
233 | 237 | /** |
| 238 | + * Returns the word wrapped version of the provided text. |
| 239 | + * |
| 240 | + * @param string $text |
| 241 | + * @param integer $charLimit |
| 242 | + * |
| 243 | + * @return string |
| 244 | + */ |
| 245 | + protected function getWordWrappedText( $text, $charLimit ) { |
| 246 | + $segments = array(); |
| 247 | + |
| 248 | + while ( strlen( $text ) > $charLimit ) { |
| 249 | + $splitPosition = strrpos( substr( $text, 0, $charLimit ), ' ' ); |
| 250 | + |
| 251 | + if ( $splitPosition === false ) { |
| 252 | + $splitPosition = strpos( $text, ' ' ); |
| 253 | + |
| 254 | + if ( $splitPosition === false ) { |
| 255 | + $splitPosition = strlen( $text ); |
| 256 | + } |
| 257 | + } |
| 258 | + |
| 259 | + $segments[] = substr( $text, 0, $splitPosition ); |
| 260 | + $text = substr( $text, $splitPosition ); |
| 261 | + } |
| 262 | + |
| 263 | + $segments[] = $text; |
| 264 | + |
| 265 | + return implode( '\n', $segments ); |
| 266 | + } |
| 267 | + |
| 268 | + /** |
234 | 269 | * (non-PHPdoc) |
235 | 270 | * @see SMWResultPrinter::getName() |
236 | 271 | */ |