<?php
/**
  @licence GPL 2005-2010  The osCSS developers - osCSS Open Source E-commerce
  @package oscss-2 <www http://www.oscss.org>
  @version Rc-3
  @date  19/05/10, 09:05
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @author Ayatus <www http://www.ayatus.org>
  @encode UTF-8
*/
  function osc_draw_input_field($name, $id = '', $value = '', $type = 'text', $parameters = '', $reinsert_value = true) {
    $field = '<input type="' . $type . '" name="' . $name . '"';
    if (!empty($id)) {
      $field .= ' id="' . $id . '"';
    } else {
      $field .= ' id="' . str_replace(array('[',']'),array(''),$name) . '"';
    }
//     if ( (isset($GLOBALS[$name]) && $key = $GLOBALS[$name]) || (isset($GLOBALS['_GET'][$name]) && $key = $GLOBALS['_GET'][$name]) || (isset($GLOBALS['_POST'][$name]) && $key = $GLOBALS['_POST'][$name]) || (isset($GLOBALS['_SESSION'][$name]) && $key = $GLOBALS['_SESSION'][$name]) && ($reinsert_value) ) {
//       $field .= ' value="' . $key . '"';
//     } elseif ($value != '') {
      $field .= ' value="' . $value . '"';
//     }
    if ($parameters) $field.= ' ' . $parameters;
    $field .= '/>';

    return $field;
  }

  function osc_draw_password_field($name, $id = '', $value = '') {
    return osc_draw_input_field($name, $id, $value, 'password', '', false);
  }

  function osc_draw_hidden_field($name, $id = '', $value = '') {
    return osc_draw_input_field($name, $id, $value, 'hidden', '', false);
  }

  function osc_draw_selection_field($name, $id = '', $type, $value = '', $checked = false) {
    $selection = '<input type="' . $type . '" name="' . $name . '"';
    if (!empty($id)) {
      $selection .= ' id="' . $id . '"';
    } else {
      $selection .= ' id="' . str_replace(array('[',']'),array(''),$name) . '"';
    }
    if ($value != '') $selection .= ' value="' . $value . '"';
    if ( ($checked == true) || (isset($GLOBALS[$name]) && $GLOBALS[$name] == 'on') || ($value == 'on') || (isset($GLOBALS[$name]) &&  $value && $GLOBALS[$name] == $value) ) {
      $selection .= ' checked="checked"';
    }
    $selection .= '/>';

    return $selection;
  }

  function osc_draw_checkbox_field($name, $id = '', $value = '', $checked = false) {
    return osc_draw_selection_field($name, $id, 'checkbox', $value, $checked);
  }

  function osc_draw_radio_field($name, $id = '', $value = '', $checked = false) {
    return osc_draw_selection_field($name, $id, 'radio', $value, $checked);
  }
?>