<?php
/*
Copyright (C) 2008 by oscim   Project lossim  [ 15.09.2009, 09:17:59] @oscim
// kate: replace-trailing-space-save true; space-indent on; indent-width 2; mixedindent off; indent-mode cstyle; word-wrap-marker-color #41C2A4
ENCODE UTF-8
*/



function net_id($name){
  return str_replace(array('[',']'),array('_'),$name);
}


/**
  new input select function
  @p string $name
  @p array $arryData
  @since lossim 3.7
*/
function input_select($name,$arryData,$default='', $extra='',$tabindex=''){
  $res = '<select name="'.$name.'" id="'.net_id($name).'" ';
  $res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
  $res .= ($extra != '') ? ' '.$extra.'' : '';
  $res .= '>'."\n";

  foreach($arryData as $k => $v) {
    $res .= '<option value="'.$k.'"';
    if($k == trim($default)) $res .= ' selected="selected" ';
    $res .= '>'.$v.'</option>'."\n";
  }

  $res .= '</select>'."\n";
  return $res;
}

/**
  new input select function
  @p string $type
  @since lossim 3.7
*/
function input_button($type='submit',$value='ok',$name='',$tabindex='',$param='') {
  $res = '<input type="'.$type.'" value="'.$value.'" ';
  if (!empty($name)) $res .=  'name="'.$name.'" id="'.net_id($name).'" ' ;
  $res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
  $res .= $param;
  $res .= ' />';

  return $res;
}


# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
# The Original Code is DotClear Weblog.
# The Initial Developer of the Original Code is
# Olivier Meunier.
# Portions created by the Initial Developer are Copyright (C) 2003
# the Initial Developer. All Rights Reserved.
# ***** END LICENSE BLOCK *****
/**
  @date 15.09.2009 17:53:29 oscim function destinée à être remplacé par input_select
*/
function php_f_combobox($name,$arryData,$default='',$tabindex='',$class='',$id='', $extra=''){
  $res = '<select name="'.$name.'" ';
  if($class != '') $res .= 'class="'.$class.'" ';

  if($id != '') $res .= 'id="'.$id.'" ';
  else $res .= 'id="'.$name.'" ';

  $res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';

  if($extra != '') $res .= $extra.' ';

  $res .= '>'."\n";

  foreach($arryData as $k => $v) {
    $res .= '<option value="'.$k.'"';
    if($v == $default) $res .= ' selected="selected"';
    $res .= '>'.$v.'</option>'."\n";
  }
  $res .= '</select>'."\n";

  return $res;
}

function php_f_textField($name,$size,$max,$default='',$tabindex='',$html=''){
  $res = '<input type="text" size="'.$size.'" name="'.$name.'" id="'.net_id($name).'" ';
  $res .= ($max != '') ? 'maxlength="'.$max.'" ' : '';
  $res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
  $res .= ($default != '') ? 'value="'.$default.'" ' : '';
  $res .= $html;
  $res .= ' />';
  return $res;
}

function php_f_textArea($name,$cols,$rows,$default='',$tabindex='',$html='')
{
	$res = '<textarea cols="'.$cols.'" rows="'.$rows.'" ';
	$res .= 'name="'.$name.'" id="'.net_id($name).'" ';
	$res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
	$res .= $html.'>';
	$res .= $default;
	$res .= '</textarea>';

	return $res;
}

function php_f_button($type='submit',$value='ok',$name='',$tabindex='')
{
	$res = '<input type="'.$type.'" value="'.$value.'" ';
	$res .=  'name="'.$name.'" id="'.net_id($name).'" ' ;
	$res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
	$res .= ' />';

	return $res;
}

function php_f_hidden($name,$value){
  return '<input type="hidden" name="'.$name.'" id="'.net_id($name).'" value="'.$value.'" />';
}

function php_f_checkbox($name, $value, $checked=false,$tabindex='',$html=''){
  $res = '<input type="checkbox" value="'.$value.'" ';
  $res .= 'name="'.$name.'" id="'.net_id($name).'" ';
  $res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
  $res .= ($checked) ? 'checked="checked" ' : '';
  $res .= $html.' />';

  return $res;
}

function php_f_radio ($name, $value, $checked=false,$tabindex='',$html='')
{
	$res = '<input type="radio" value="'.$value.'" ';
	$res .= 'name="'.$name.'" id="'.net_id($name).'" ';
	$res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
    $res .= ($checked) ? 'checked="checked" ' : '';
	$res .= $html.' />';

	return $res;
}
?>