From: x2003bruneau Date: Mon, 10 Jul 2006 09:01:39 +0000 (+0000) Subject: Use dynamic image links X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=c14c86f433c1f00fa3177b6a0aae980ef135d148;p=banana.git Use dynamic image links git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@73 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/banana/misc.inc.php b/banana/misc.inc.php index 3a086cf..5f35d80 100644 --- a/banana/misc.inc.php +++ b/banana/misc.inc.php @@ -92,6 +92,32 @@ function makeHREF($params, $text = null) return '' . $text . ''; } +/** Format tree images links + * @param img STRING Image name (without extension) + * @param alt STRING alternative string + * @param width INT to force width of the image (null if not defined) + * + * This function can be overloaded by defining hook_makeImg() + */ +function makeImg($img, $alt, $width = null) +{ + if (function_exists('hook_makeImg') + && $res = hook_makeImg($img, $alt, $width)) { + return $res; + } + + if (!is_null($width)) { + $width = ' width="' . $width . '"'; + } + + $proto = empty($_SERVER['HTTPS']) ? 'http://' : 'https://'; + $host = $_SERVER['HTTP_HOST']; + $file = dirname($_SERVER['PHP_SELF']) . '/img/' . $img . '.gif'; + $url = $proto . $host . $file; + + return '' . $alt . ''; +} + /******************************************************************************** * HTML STUFF * Taken from php.net diff --git a/banana/spool.inc.php b/banana/spool.inc.php index e681a40..5b5bfb3 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -313,16 +313,16 @@ class BananaSpool function _to_html($_id, $_index, $_first=0, $_last=0, $_ref="", $_pfx_node="", $_pfx_end="", $_head=true) { - $spfx_f = 'o'; - $spfx_n = '*'; - $spfx_Tnd = '+'; - $spfx_Lnd = '`'; - $spfx_snd = '-'; - $spfx_T = '+'; - $spfx_L = '`'; - $spfx_s = '-'; - $spfx_e = ' '; - $spfx_I = '|'; + $spfx_f = makeImg('k1', 'o', 9); + $spfx_n = makeImg('k2', '*', 9); + $spfx_Tnd = makeImg('T-direct', '+', 12); + $spfx_Lnd = makeImg('L-direct', '`', 12); + $spfx_snd = makeImg('s-direct', '-', 5); + $spfx_T = makeImg('T', '+', 12); + $spfx_L = makeImg('L', '`', 12); + $spfx_s = makeImg('s', '-', 5); + $spfx_e = makeImg('e', ' ', 12); + $spfx_I = makeImg('I', '|', 12); if ($_index + $this->overview[$_id]->desc < $_first || $_index > $_last) { return;