mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 12:39:25 +01:00
Util for developers to make "selected" versions of their navbar icons.
This commit is contained in:
parent
493b2bc85d
commit
4b848e45e8
31
admin/navbar-create.php
Normal file
31
admin/navbar-create.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
$phpgw_info["flags"]["currentapp"] = "admin";
|
||||||
|
$phpgw_info["server"]["site_title"] = "Create a selected navbar image";
|
||||||
|
include("../header.inc.php");
|
||||||
|
?>
|
||||||
|
|
||||||
|
This is a utility that will help developers automatically create "selected" navigation bar images. Currently, it just adds a 1 pixel border around the image in a style that suggests a depressed button.
|
||||||
|
<p>
|
||||||
|
The instructions are as follows:
|
||||||
|
<ol>
|
||||||
|
<li>Select an app from the list below.</li>
|
||||||
|
<li>Right click on the image that appears in your browser and save the image.</li>
|
||||||
|
<li>Name the image "navbar-sel.gif" -- but without the quotes.</li>
|
||||||
|
<li>Copy the image to the images subdirectory of the app.</li>
|
||||||
|
<li>Commit the image to cvs, adding it first if necessary.</li>
|
||||||
|
</ol>
|
||||||
|
<p>
|
||||||
|
<b>NOTE:</b> <i>This app will only work if your server has the GD library compiled into PHP. Furthermore, if your GD library is too new, it will not work with GIF's, only PNG's...</i>
|
||||||
|
<p>
|
||||||
|
<b>NOTE 2:</b> <i>Also, some images seem to give load errors. This is easily fixed by reexporting them as a GIF from Photoshop in GIF89a format. Other programs will also work.</i>
|
||||||
|
<p>
|
||||||
|
<b>Applications</b>
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
while (list($key, $val) = each($phpgw_info["apps"])) {
|
||||||
|
echo "\n<A HREF='navbar-sel.php?filename=".$phpgw_info["server"]["server_root"]."/$key/images/navbar.gif'>";
|
||||||
|
echo $phpgw_info["apps"][$key]["title"]."</A><BR>";
|
||||||
|
}
|
||||||
|
|
||||||
|
include($phpgw_info["server"]["api_dir"] . "/footer.inc.php");
|
||||||
|
?>
|
74
admin/navbar-sel.php
Normal file
74
admin/navbar-sel.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
//
|
||||||
|
// SourceForge Knowledge Base Module v.1.0.0
|
||||||
|
//
|
||||||
|
// Created by Patrick Walsh (pjw@users.sourceforge.net) 6/00
|
||||||
|
// Copyright (c) ... aw, hell, copy all the code you want
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
/*
|
||||||
|
This code was adapted from Rasmus Lerdorf's article on PHPBuilder
|
||||||
|
http://www.phpbuilder.com/columns/rasmus19990124.php3
|
||||||
|
*/
|
||||||
|
|
||||||
|
function openGif($filename) {
|
||||||
|
|
||||||
|
if (!$filename) { $filename = "navbar.gif"; }
|
||||||
|
$im = @imagecreatefromgif($filename);
|
||||||
|
if ($im == "") { /* test for success of file creation */
|
||||||
|
$im = imagecreate(300,15); /* Create a blank image */
|
||||||
|
$bgc = imagecolorallocate($im, 255, 255, 255);
|
||||||
|
$tc = imagecolorallocate($im, 0, 0, 0);
|
||||||
|
imagefilledrectangle($im, 0, 0, 300, 15, $bgc);
|
||||||
|
imagestring($im,1,2,2,"Error loading $filename", $tc);
|
||||||
|
}
|
||||||
|
return $im;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRGB($web_color) {
|
||||||
|
if (strlen($web_color) != 6) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$retval["r"] = hexdec(substr($web_color,0,2));
|
||||||
|
$retval["g"] = hexdec(substr($web_color,2,2));
|
||||||
|
$retval["b"] = hexdec(substr($web_color,4,2));
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$phpgw_info["flags"]["currentapp"] = "admin";
|
||||||
|
$phpgw_info["flags"]["nonavbar"] = True;
|
||||||
|
$phpgw_info["flags"]["noheader"] = True;
|
||||||
|
include("../header.inc.php");
|
||||||
|
|
||||||
|
|
||||||
|
Header( "Content-type: image/gif");
|
||||||
|
|
||||||
|
$border = 1;
|
||||||
|
|
||||||
|
//echo $filename;
|
||||||
|
$im = openGif($filename); /* Open the provided file */
|
||||||
|
$bg = getRGB($phpgw_info["theme"]["navbar_bg"]); /* get navbar theme */
|
||||||
|
$fg = getRGB($phpgw_info["theme"]["navbar_text"]);
|
||||||
|
$navbar_bg = ImageColorAllocate($im, $bg["r"], $bg["g"], $bg["b"]);
|
||||||
|
$navbar_fg = ImageColorAllocate($im, $fg["r"], $fg["g"], $fg["b"]);
|
||||||
|
|
||||||
|
$dk_gray = ImageColorAllocate($im, 128, 128, 128);
|
||||||
|
$lt_gray = ImageColorAllocate($im, 192, 192, 192);
|
||||||
|
|
||||||
|
$dx = ImageSX($im); /* get image size */
|
||||||
|
$dy = ImageSY($im);
|
||||||
|
|
||||||
|
ImageFilledRectangle($im,0, 0, $dx, $border,$dk_gray); /* top */
|
||||||
|
ImageFilledRectangle($im,0, 0, $border, $dy,$dk_gray); /* left */
|
||||||
|
ImageFilledRectangle($im,$dx-$border-1, 0, $dx, $dy,$lt_gray); /* right */
|
||||||
|
ImageFilledRectangle($im,0, $dy-$border-1, $dx, $dy,$lt_gray); /* bottom */
|
||||||
|
|
||||||
|
//ImageGif($im,"$DOCUMENT_ROOT/kb/xml/$filename");
|
||||||
|
|
||||||
|
ImageGif($im);
|
||||||
|
|
||||||
|
ImageDestroy($im);
|
||||||
|
?>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user