<?php
//-----------------------------------------------------------------------------
//
// Copyright (C) 2003-2005 Oy Realnode Ab
//
//-----------------------------------------------------------------------------
//
// submenu_img.php
// Part of the Emilda Project (http://www.emilda.org/)
//
// Description
// Dynamic submenu image creation.
//
// Authors
// Christoffer Landtman <landtman (at) realnode com>
// Erik Berglund <berglund (at) realnode com>
// Mattias Nordstrom <nordstrom (at) realnode com>
//
//-----------------------------------------------------------------------------
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//-----------------------------------------------------------------------------
//
// $Id: submenu_img.php,v 1.13 2005/01/10 22:11:54 mnordstr Exp $
//
//-----------------------------------------------------------------------------
// Id used to identify this page within functions.
$PageID = 'SUBMENU_IMG';
require_once 'config.inc';
$template = (isset($_REQUEST['template'])) ? $_REQUEST['template'] : 'default';
$layout_config = config_to_array('templates/' . $template . '/layout_config');
$string = (isset($_REQUEST['text'])) ? $_REQUEST['text'] : '';
$string = str_replace('_', ' ', $string);
if (isset($layout_config['submenu']['img_src']))
{
$im = ImageCreateFromPNG('templates/' . $template . '/img/' . $layout_config['submenu']['img_src']);
//ImageTTFText($im, 59, 0, 9, 21, -$gray, "/var/userwww/eb/test/schlbk.ttf", $string);
//ImageTTFText($im, 59, 0, 10, 20, -$red, "/var/userwww/eb/test/schlbk.ttf", $string);
$use_shadow = FALSE;
if (isset($layout_config['submenu']['font_number']) && is_int($layout_config['submenu']['font_number']))
{
$font = $layout_config['submenu']['font_number'];
if ($font < 1 || $font > 5) {
$font = 4;
}
}
else
{
$font = 4;
}
if (isset($layout_config['submenu']['shadow_rgb']) && sizeof($layout_config['submenu']['shadow_rgb']) == 3)
{
$colors = $layout_config['submenu']['shadow_rgb'];
$shadow_color = ImageColorAllocate($im, $colors[0], $colors[1], $colors[2]);
$use_shadow = TRUE;
}
else
{
$shadow_color = ImageColorAllocate($im, 128, 128, 128);
}
if (isset($layout_config['submenu']['shadow_xy']) && sizeof($layout_config['submenu']['shadow_xy']) == 2)
{
$xy = $layout_config['submenu']['shadow_xy'];
imagestring ($im, $font, $xy[0], $xy[1], $string, $shadow_color);
}
elseif ($use_shadow) //if a shadow color has been defined, but no coordinates given
{
imagestring ($im, $font, 1, 1, $string, $shadow_color);
}
if (isset($layout_config['submenu']['text_rgb']) && sizeof($layout_config['submenu']['text_rgb']) == 3)
{
$colors = $layout_config['submenu']['text_rgb'];
$text_color = ImageColorAllocate($im, $colors[0], $colors[1], $colors[2]);
}
else
{
$text_color = ImageColorAllocate($im, 0, 0, 0); //black is default
}
if (isset($layout_config['submenu']['text_xy']) && sizeof($layout_config['submenu']['text_xy']) == 2)
{
$xy = $layout_config['submenu']['text_xy'];
imagestring ($im, $font, $xy[0], $xy[1], $string, $text_color);
}
else
{
imagestring ($im, $font, 1, 1, $string, $text_color);
}
Header("Content-type: image/png");
Header("Expires: " . date("r", (date("U", (date("U")+3600))))); //Image cache.
ImagePNG($im);
ImageDestroy ($im);
}
?>