Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv15918/lib
Modified Files:
interwiki.php stdlib.php
Log Message:
Refactor external link icon code.
Index: interwiki.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/interwiki.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** interwiki.php 2001/12/07 05:27:20 1.10
--- interwiki.php 2001/12/11 17:47:10 1.11
***************
*** 48,66 ****
}
- $linkproto='interwiki';
- $ICONS = &$GLOBALS['URL_LINK_ICONS'];
-
- $linkimg = isset($ICONS[$linkproto]) ? $ICONS[$linkproto] : $ICONS['*'];
- if (!empty($linkimg)) {
- $imgtag = Element('img', array('src' => DataURL($linkimg),
- 'alt' => $linkproto,
- 'class' => 'linkicon'));
- $linktext = $imgtag . $linktext;
- }
-
return Element('a', array('href' => $url,
'class' => $class),
! $linktext);
}
// Link InterWiki links
--- 48,56 ----
}
return Element('a', array('href' => $url,
'class' => $class),
! IconForLink('interwiki') . $linktext);
}
+
// Link InterWiki links
Index: stdlib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -r1.56 -r1.57
*** stdlib.php 2001/12/07 22:14:32 1.56
--- stdlib.php 2001/12/11 17:47:10 1.57
***************
*** 101,104 ****
--- 101,128 ----
}
}
+
+ function IconForLink($protocol_or_url) {
+ global $URL_LINK_ICONS;
+
+ list ($proto) = explode(':', $protocol_or_url, 2);
+ echo "PROTO: $proto<br>\n";
+
+ if (isset($URL_LINK_ICONS[$proto])) {
+ $linkimg = $URL_LINK_ICONS[$proto];
+ }
+ elseif (isset($URL_LINK_ICONS['*'])) {
+ $linkimg = $URL_LINK_ICONS['*'];
+ }
+
+ echo "IMG: $linkimg<br>\n";
+
+ if (empty($linkimg))
+ return '';
+
+ return Element('img', array('src' => DataURL($linkimg),
+ 'alt' => $proto,
+ 'class' => 'linkicon'));
+ }
+
function LinkURL($url, $linktext = '') {
***************
*** 119,136 ****
$attr['class'] = 'namedurl';
}
- $linktext = htmlspecialchars($linktext);
-
- $linkproto = substr($url, 0, strpos($url, ":"));
- $ICONS = &$GLOBALS['URL_LINK_ICONS'];
-
- $linkimg = isset($ICONS[$linkproto]) ? $ICONS[$linkproto] : $ICONS['*'];
- if (!empty($linkimg)) {
- $imgtag = Element('img', array('src' => DataURL($linkimg),
- 'alt' => $linkproto,
- 'class' => 'linkicon'));
- $linktext = $imgtag . $linktext;
- }
! return Element('a', $attr, $linktext);
}
--- 143,149 ----
$attr['class'] = 'namedurl';
}
! return Element('a', $attr,
! IconForLink($url) . htmlspecialchars($linktext));
}
|