Example #1
0
function ddlib_editarCampo(&$dd, &$aDatos, $id)
{
    $aParametros = explode(" ", $dd["tipo"]);
    $tipo = strtolower($aParametros[0]);
    $campo = ddlib_obtenerCampo(&$dd, $aDatos);
    // atributos por defecto
    $defectos = array("adjunto" => array("clase" => "boton"), "infofuncion" => array("clase" => "campo-informativo"), "readonly" => array("clase" => "campo-informativo"), "info" => array("clase" => "campo-informativo"));
    $atributos = _ddlib_atributos($dd, $id, $defectos[$tipo]);
    switch ($tipo) {
        case "hidden":
        case "fijo":
        case "htmldespues":
        case "separadortabla":
        case "separador":
            return "";
        case "adjunto":
            if ($dd["maximo"]) {
                $maximo = min($dd["maximo"], ini_get("upload_max_filesize"));
            } else {
                $maximo = ini_get("upload_max_filesize");
            }
            $adicional = "<span class='tamanno-max'>(MAX: {$maximo} bytes)</span>";
            if ($campo) {
                $visualizar = "<a href='{$aParametros[1]}/{$campo}'>";
                $visualizar .= corta($campo, 50) . "</a><br>";
                $visualizar .= t("Cambiar fichero adjunto: ") . "<input type='file' {$atributos} file='{$maximo}'/>{$adicional}";
                $visualizar .= "<br>" . "Borrar adjunto: " . "<input type='checkbox' name='{$dd[campo]}_BORRAR' value='1' />";
            } else {
                $visualizar = t("Adjuntar nuevo archivo: ") . "<input type='file' {$atributos} />{$adicional}";
            }
            return $visualizar;
        case "imagen":
        case "irudia":
            if ($campo) {
                $visualizar = "<img src='./{$aParametros[1]}/{$campo}' class='irudia' /><br/>";
                $visualizar .= t("Cambiar  imagen: ") . "<input type='file' {$atributos} />\n</br/>";
                $visualizar .= t("Borrar imagen: ") . "<input type='checkbox' name='{$dd[campo]}_BORRAR' value='1' />";
            } else {
                $visualizar .= t("Sin imagen") . "<br/>";
                $visualizar .= t("Nueva  imagen: ") . "<input type='file' {$atributos} />";
            }
            return $visualizar;
            // listas
        // listas
        case "lista":
        case "listavalores":
        case "listasql":
        case "listafuncion":
            $visualizar = "<select {$atributos}>\n";
            //@TODO $visualizar .= _ddlib_option_adicionales ( $dd, $campo );
            switch ($tipo) {
                case "listasql":
                    $lista = mysql_mlistaClavesSQL(substr($dd["tipo"], 8));
                    break;
                case "lista":
                    $lista = $dd["lista"];
                    break;
                case "listavalores":
                    foreach ($dd["lista"] as $valor) {
                        $lista[$valor] = $valor;
                    }
                    break;
                case "listafuncion":
                    $lista = call_user_func($aParametros[1]);
            }
            switch ($dd["formatolista"]) {
                case "checkbox":
                    // @TODO no funciona CHECKBOX
                    foreach ($lista as $value => $opcion) {
                        $selected = $value == $campo ? " checked='checked' " : "";
                        $visualizar .= "<input {$atributos} type='checkbox' value='{$value}'{$selected}/>{$opcion}\n";
                    }
                case "radio":
                    // @TODO no funciona RADIO
                    foreach ($lista as $value => $opcion) {
                        $selected = $value == $campo ? " checked='checked' " : "";
                        $visualizar .= "<input {$atributo} type='radio' value='{$value}'{$selected}/>{$opcion}\n";
                    }
                default:
                    $visualizar = "<select {$atributos}>\n" . _ddlib_option_adicionales($dd, $campo);
                    foreach ($lista as $value => $opcion) {
                        $selected = $value == $campo ? " selected='selected' " : "";
                        $visualizar .= "<option value='{$value}'{$selected}>{$opcion}</option>\n";
                    }
                    $visualizar .= "</select>\n";
            }
            return $visualizar;
        case "checkbox":
            $checked = $campo ? " checked='checked' " : "";
            return "<input type='checkbox' {$atributos} {$checked} value='1' />";
        case "checkboxes":
            if (isset($dd["campos"]) && isset($dd["etiquetas"])) {
                $nCont = 1;
                foreach ($dd["campos"] as $tcampo => $tipo) {
                    $atributos = $aDatos[$tcampo] ? " checked='checked' " : "";
                    $atributos .= " name='{$tcampo}' id='{$id}-{$nCont}' {$dd[atributos]} value='1'";
                    $cRet .= "<input type='checkbox' {$atributos}> ";
                    $cRet .= "<label for='{$id}-{$nCont}'>" . $dd["etiquetas"][$tcampo] . "</label> \n";
                    $nCont++;
                }
                return $cRet;
            }
            return "";
            // funciones informativas
        // funciones informativas
        case "infofijo":
        case "infofuncion":
            $campo = $tipo == "infofijo" ? substr($dd["tipo"], 9) : call_user_func($aParametros[1], $aDatos);
        case "readonly":
        case "info":
            return "<input type='text' {$atributos} value='{$campo}' disabled='disabled' >";
            break;
        case "htmlfijo":
            return substr($dd["tipo"], 9);
        case "html":
        case "htmlfuncion":
            return call_user_func($aParametros[1], $aDatos);
            // contraseƱa
        // contraseƱa
        case "nuevopassword":
        case "verificapassword":
            $size = $aParametros[1] or $size = 40;
            $max = $aParametros[2] or $max = $size;
            return "<input type='password' value='' {$atributos} size='{$size}' maxlength='{$max}'>";
            // textos y cadenas
        // textos y cadenas
        case "texto":
            $rows = $aParametros[2] or $rows = 8;
            $cols = $aParametros[1] or $cols = 40;
            return "<textarea {$atributos} rows='{$rows}' cols='{$cols}'>{$campo}</textarea>";
        case "cadena":
            $size = $aParametros[1] or $size = 40;
            $max = $aParametros[2] or $max = $size;
            return "<input type='text' {$atributos} value='{$campo}' size='{$size}' maxlenght='{$max}' />";
            // los campos fecha se generan mediante el atributo.
        // los campos fecha se generan mediante el atributo.
        default:
            return "<input type='text' {$atributos} value='{$campo}'/>";
    }
    return $visualizar;
}
Example #2
0
/**
* Construye un input a partir de una sentecni Select SQL que devuelve clave, valor.
*/
function mInputSQL($cSQL, $cName, $cValorInicial, $cEstilo = "", $opcionInicial = "")
{
    if ($opcionInicial) {
        if (is_array($opcionInicial)) {
            $TempList = $opcionInicial;
        } else {
            $TempList = array($opcionInicial);
        }
        $TempList = mysql_mlistaClavesSQL($cSQL, $TempList);
    } else {
        $TempList = mysql_mlistaClavesSQL($cSQL);
    }
    $cEstilo = $cEstilo ? " class='{$cEstilo}'" : "";
    //@TODO revisar
    return mInputListaClaves($TempList, $cName, $cValorInicial, $cEstilo);
}