cvs: phpweb /include layout.inc

From: Date: Sat, 07 Jun 2003 20:17:34 +0000
Subject: cvs: phpweb /include layout.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-18587@lists.php.net to get a copy of this message
goba Sat Jun 7 16:17:34 2003 EDT Modified files: /phpweb/include layout.inc Log: Allow the caller of make_image() to opt out from automatic image sizing Use this feature and convert the border attribute in make_submit() to output an [X]HTML compatible <input> tag Index: phpweb/include/layout.inc diff -u phpweb/include/layout.inc:1.165 phpweb/include/layout.inc:1.166 --- phpweb/include/layout.inc:1.165 Sat Jun 7 16:01:07 2003 +++ phpweb/include/layout.inc Sat Jun 7 16:17:34 2003 @@ -1,5 +1,5 @@ <?php -/* $Id: layout.inc,v 1.165 2003/06/07 20:01:07 goba Exp $ */ +/* $Id: layout.inc,v 1.166 2003/06/07 20:17:34 goba Exp $ */ // Set the static content root differently on php.net $_SERVER['STATIC_ROOT'] = ($MYSITE == 'http://www.php.net/') ? @@ -37,13 +37,13 @@ // Return an <img /> tag for a given image file available on the server function make_image($file, $alt = FALSE, $align = FALSE, $extras = FALSE, - $dir = '/images', $border = 0) + $dir = '/images', $border = 0, $addsize = TRUE) { // If no / was provided at the start of $dir, add it $webdir = $_SERVER['STATIC_ROOT'] . ($dir{0} == '/' ? '' : '/') . $dir; // Get width and height values if possible - if ($size = @getimagesize($_SERVER['DOCUMENT_ROOT'] . "$dir/$file")) { + if ($addsize && ($size = @getimagesize($_SERVER['DOCUMENT_ROOT'] . "$dir/$file"))) { $sizeparams = ' ' . trim($size[3]); } else { $sizeparams = ''; @@ -73,8 +73,18 @@ function make_submit($file, $alt = FALSE, $align = FALSE, $extras = FALSE, $dir = '/images', $border = 0) { - return '<input type="image"' . - substr(make_image($file, $alt, $align, $extras, $dir, $border), 4); + // Get an image without size info and convert the + // border attribute to use CSS, as border="" is not + // supported on <input> elements in [X]HTML + $img = make_image($file, $alt, $align, $extras, $dir, 0, FALSE); + $img = str_replace( + "border=\"$border\"", + "style=\"border: {$border}px;\"", + $img + ); + + // Return with ready input image + return '<input type="image"' . substr($img, 4); } // Return a pipe delimiter

« previous php.mirrors (#18587) next »