style="background: url() no-repeat; width: px; height: px;
if ($disabled)
echo ("background-position: 0px " . (-$height*2) . "px");
else
echo ("cursor: pointer"); ?>
"
if (!$disabled) { ?>
onmouseover="this.style.backgroundPosition='0px px'"
onmouseout="this.style.backgroundPosition='0px 0px'"
if (!empty ($onclick))
echo ("onclick=\"$onclick\" ");
if (!empty ($title))
echo ("title=\"$title\"");
} ?>
>
if (!empty ($caption)) {
$font_size = 13;
$font_bold = TRUE;
$font_color = "505050"; ?>
} ?>
}
function btnimg_submit_wrapper_ ($filename, $width, $height, $title, $action, $onsubmit, $onclick, $disabled)
{
if (!empty ($action))
$onclick = "document.form_universal.action='$action';" . $onclick;
if (!empty ($onsubmit))
$onclick .= ";if ($onsubmit) document.form_universal.submit()";
else
$onclick .= ";document.form_universal.submit()";
return (btnimg ("submit", $color, $caption, $width, $lite, $title, $onclick, $disabled));
}
function btnimg_simple (
$filename,
$width,
$height,
$caption,
$onclick,
$title)
{
btnimg ($filename, $width, $height, $caption, FALSE, $onclick, $title, "");
}
// buttons
$btn_value_created = false;
$btn_handles = array();
define ("BTN_VALUE_NAME", "BTN_VALUE_GROMADA");
// button type
define ("BTN_CLASSIC", 0);
define ("BTN_OK", 1 << 0);
define ("BTN_CANCEL", 1 << 1);
define ("BTN_INFO", 1 << 2);
define ("BTN_BROWSE", 1 << 3);
// button mode
define ("BTN_NORMAL", 0);
define ("BTN_SUBMIT", 1 << 8);
// special
define ("BTN_AUTO", "BTN_AUTO");
define ("BTN_MAX", "100%");
// button caption predefines
define ('BTN_PRIHVATI', 'Prihvati');
define ('BTN_PROMIJENI', 'Promijeni');
define ('BTN_SNIMI', 'Snimi');
define ('BTN_ODUSTANI', 'Odustani');
function btn_create()
{
if (func_num_args() > 0)
$btn_id = func_get_arg (0);
else
$btn_id = uniqid();
$GLOBALS["btn_handles"][$btn_id] = array (
"color" => "",
"title" => "",
"onclick_code" => "",
"onsubmit_code" => "",
"form_action_code" => "",
"disabled" => FALSE,
"lite" => FALSE,
"image" => ""
);
return ($btn_id);
}
function btn_image_set ($btn, $filename)
{
$GLOBALS["btn_handles"][$id]["image"] = $filename;
}
function btn_lite_set ($id, $true_or_false)
{
$GLOBALS["btn_handles"][$id]["lite"] = $true_or_false;
}
function btn_lite ($id)
{
return ($GLOBALS["btn_handles"][$id]["lite"]);
}
function btn_color_set ($id, $color)
{
$GLOBALS["btn_handles"][$id]["color"] = $color;
}
function btn_color ($id)
{
return ($GLOBALS["btn_handles"][$id]["color"]);
}
function btn_onclick_set ($id, $code)
{
$GLOBALS["btn_handles"][$id]["onclick_code"] = $code;
}
function btn_onclick ($id)
{
return ($GLOBALS["btn_handles"][$id]["onclick_code"]);
}
function btn_onsubmit_set ($id, $code)
{
$GLOBALS["btn_handles"][$id]["onsubmit_code"] = $code;
}
function btn_onsubmit ($id)
{
return ($GLOBALS["btn_handles"][$id]["onsubmit_code"]);
}
function btn_form_action_set ($id, $code)
{
$GLOBALS["btn_handles"][$id]["form_action_code"] = $code;
}
function btn_form_action ($id)
{
return ($GLOBALS["btn_handles"][$id]["form_action_code"]);
}
function btn_disable ($id, $true_false)
{
$GLOBALS["btn_handles"][$id]["disabled"] = $true_false;
}
function btn_show ($id, $flags, $caption)
{
$num_args = func_num_args();
if ($num_args < 1)
return;
$id = func_get_arg (0);
$flags = ($num_args > 1) ? func_get_arg (1) : BTN_CLASSIC + BTN_NORMAL;
$caption = ($num_args > 2) ? func_get_arg (2) : "";
$width = ($num_args > 3) ? func_get_arg (3) : BTN_MAX;
$height = ($num_args > 4) ? func_get_arg (4) : BTN_MAX;
$btn = $GLOBALS["btn_handles"][$id];
$caption = str_replace(" ", " ", $caption);
$code = $btn["onclick_code"];
if (!empty ($btn["form_action_code"]))
$code = "document.form_universal.action='{$btn['form_action_code']}';" . $code;
if (!empty ($btn["onsubmit_code"]))
$code .= ";if ({$btn["onsubmit_code"]}) document.form_universal.submit()";
else if (!empty ($code))
$code .= ";document.form_universal.submit()";
switch ($flags & 255) {
case BTN_OK:
$color = "green";
break;
case BTN_CANCEL:
$color = "red";
break;
case BTN_INFO:
$color = "blue";
break;
default:
$color = "yellow";
break;
}
if (!empty ($btn["color"]))
$color = $btn["color"];
if (!empty ($btn["image"]))
btnimg ($btn["image"], $width, $height, $caption, $btn["disabled"], $code, $btn["title"], "");
else
btn_ex ($id, $flags & BTN_BROWSE ? "browse" : "", $color, $caption, $width, $btn["lite"], $btn["title"], $code, $btn["disabled"]);
$GLOBALS["btn_handles"][$id] = array();
}
function btn_ex ($id, $type, $color, $caption, $width, $lite, $title, $onclick, $disabled)
{
global $btn_value_created;
$height = $lite ? 22 : 26;
$font_bold = false;
if ($disabled)
$font_color = 'a0a0a0';
else
switch ($color) {
case 'red':
$font_color = '903030';
$font_bold = true;
break;
case 'green':
$font_color = '007000';
$font_bold = true;
break;
case 'blue':
$font_color = '0050a0';
$font_bold = true;
break;
default: // yellow
$font_color = '000000';
break;
}
$file_prefix = $lite ? 'btnlite_' : 'btn_';
$left_id = 'btn_left_' . $id;
$left_img = "url(".SITE_RO_BUTTONS."/$file_prefix" . $color . '_left.png)';
$body_id = 'btn_body_' . $id;
$body_img = "url(".SITE_RO_BUTTONS."/$file_prefix" . $color . '_body.png)';
$right_id = 'btn_right_' . $id;
$right_img = "url(".SITE_RO_BUTTONS."/$file_prefix" . $color . '_right.png)';
$table_id = 'btn_table_' . $id;
$font_size = $lite ? 11 : 13;
if ($type == 'browse') { ?>