Hi,
I like the idea about putting small icons in front of links to make it
easy to identify the type, but there's one thing that has bothered me
about this from the start: the icon is often separated from the link,
especially when the link is a long raw URL.
The following patch should take care of that. It inserts a span tag
around the icon and the first word in the link and uses the
white-space attribute to make the two stick together.
The 'style' => 'white-space: nowrap' should probably be moved into the
stylesheet, but this demonstrates the idea:
Index: stdlib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v
retrieving revision 1.127
diff -u -3 -r1.127 stdlib.php
--- stdlib.php 24 Sep 2002 01:12:28 -0000 1.127
+++ stdlib.php 5 Oct 2002 23:19:26 -0000
@@ -179,11 +179,27 @@
else {
if (!$linktext)
$linktext = preg_replace("/mailto:/A", "", $url);
+
+ $icon = IconForLink($url);
- $link = HTML::a(array('href' => $url),
- IconForLink($url), $linktext);
+ if ($icon) {
+ /* Get hold of first word: */
+ list($head, $tail) = preg_split('/\s+/', $linktext, 2);
+
+ /* Reintroduce space if necessary: */
+ if (!empty($tail)) $tail = ' ' . $tail;
+
+ /* Keep icon and first word together: */
+ $span = HTML::span(array('style' => 'white-space: nowrap'),
+ $icon, $head);
+
+ $link = HTML::a(array('href' => $url), $span, $tail);
+ } else {
+ $link = HTML::a(array('href' => $url), $linktext);
+ }
}
+
$link->setAttr('class', $linktext ? 'namedurl' : 'rawurl');
return $link;
}
--
Martin Geisler My GnuPG Key: 0xF7F6B57B
See http://gimpster.com/ and http://phpweather.net/ for:
PHP Weather => Shows the current weather on your webpage and
PHP Shell => A telnet-connection (almost :-) in a PHP page.
|