Exemplo n.º 1
0
function form_image($title = false, $input_name, $input_id, $folder, $input_value = false, $array = false)
{
    $title = isset($title) && !empty($title) ? stripinput($title) : "";
    $title2 = isset($title) && !empty($title) ? stripinput($title) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    $input_name = isset($input_name) && !empty($input_name) ? stripinput($input_name) : "";
    $input_id = isset($input_id) && !empty($input_id) ? stripinput($input_id) : "";
    $input_value = isset($input_value) && !empty($input_value) ? stripinput($input_value) : "";
    if (!is_array($array)) {
        $helper_text = "";
        $required = 0;
        $safemode = 0;
        $stacking = 0;
        $placeholder = "";
        $deactivate = "";
        $width = "250px";
        $class = "";
    } else {
        $stacking = array_key_exists('stacking', $array) ? 1 : "";
        $helper_text = array_key_exists("helper", $array) ? $array['helper'] : "";
        $required = array_key_exists('required', $array) && $array['required'] == 1 ? 1 : 0;
        $safemode = array_key_exists('safemode', $array) && $array['safemode'] == 1 ? 1 : 0;
        $placeholder = array_key_exists('placeholder', $array) ? $array['placeholder'] : "Please choose one..";
        $deactivate = array_key_exists("deactivate", $array) && $array['deactivate'] == "1" ? 1 : 0;
        $width = array_key_exists('width', $array) ? "style='width:" . $array['width'] . "'" : "style='width:250px;'";
        $class = array_key_exists('class', $array) ? $array['class'] : "";
    }
    $html = "";
    if (!empty($title)) {
        // turn off coloumn
        if ($stacking == 1) {
            $html .= open_form_title($title, $input_id, $helper_text, $required);
        } else {
            $html .= open_form_title_2($title, $input_id, $helper_text, $required);
        }
    }
    $html .= "";
    $html .= "<div class='input-group' style='width:{$width}'>";
    $html .= "<span class='input-group-btn'><a type='button' data-toggle='modal' data-target='#fileManagerbox' class='btn btn-default btn-sm'>Choose Image</a></span>";
    $html .= "<input type='text' name='{$input_name}' style='width:{$width}' class='form-control {$class}' id='" . $input_id . "' {$width} value='{$input_value}' placeholder='" . $placeholder . "' readonly>";
    $html .= "<input type='hidden' name='def[{$input_name}]' value='[type=media],[title={$title2}],[id={$input_id}],[required={$required}],[safemode={$safemode}]' readonly>";
    $html .= "</div>";
    $html .= "<div class='modal fade' id='fileManagerbox' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true' style='z-index:1100;'>";
    $html .= "<div class='modal-dialog' style='width:1000px'>\n";
    $html .= "<div class='modal-content '>\n";
    $html .= "<div class='modal-header'>\n";
    $html .= " <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>\n";
    $html .= "<h4 class='modal-title' id='myModalLabel'>Choose {$title2}</h4>\n";
    $html .= "</div>\n";
    $html .= "<div class='modal-body'>\n";
    $html .= "<div class='row'>\n";
    $files = glob("{$folder}/*.{jpg,JPEG,jpeg,png,gif,GIF,bmp,BMP,tiff,TIFF}", GLOB_BRACE);
    $html .= "<style>";
    $html .= "\n    .img-container {\n    height: 91px;\n    width: 133px;\n    padding: 0px;\n    border-radius: 4px 4px 0x 0px;\n    overflow: hidden;\n    display: block;\n    text-align: center;\n    vertical-align: middle;\n    margin: auto;\n    }\n\n    .img-container img{\n    max-width: 400px !important;\n    max-height: 102px !important;\n    border-radius:4px 4px 0px 0px;\n    }\n    ";
    $html .= "</style>";
    foreach ($files as $arr => $v) {
        $path = $v;
        $title = str_replace($folder, "", $v);
        $html .= "<div class='col-sm-2 col-md-2 col-lg-2 filepick'>\n";
        $html .= "<div class='panel panel-default'>\n";
        $html .= "<div class='panel-body img-container'>\n";
        $html .= "<img src='{$path}' style='overflow-x:hidden;'>\n";
        $html .= "</div>\n<div class='panel-footer'>\n";
        $html .= "<a href='#' class='btn btn-primary btn-xs btn-block' data-id='{$path}'>\nChoose\n</a>\n";
        $html .= "</div>\n";
        $html .= "</div>\n</div>\n";
    }
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<div class='modal-footer'>\n";
    $html .= "<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>\n";
    $html .= "<button type='button' class='btn btn-primary'>Save changes</button>\n";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "</div>\n";
    if (!empty($title)) {
        // turn off column
        $html .= close_form_title();
    }
    add_to_jquery("\n\n        \$('div.filepick a').on('click', function(e){\n            var ce_id = \$(this).attr('data-id');\n            //alert(ce_id);\n             \$('#" . $input_id . "').val(ce_id);\n            \$('#fileManagerbox').modal('hide');\n         });\n\n    ");
    return $html;
}
Exemplo n.º 2
0
function form_colorpicker($title = false, $input_name, $input_id, $input_value = false, $array = false)
{
    if (!defined("COLORPICKER")) {
        define("COLORPICKER", true);
        add_to_head("<link href='" . DYNAMICS . "assets/colorpick/css/bootstrap-colorpicker.css' rel='stylesheet' media='screen' />");
        add_to_head("<script src='" . DYNAMICS . "assets/colorpick/js/bootstrap-colorpicker.js'></script>");
    }
    global $_POST;
    $title = isset($title) && !empty($title) ? stripinput($title) : "";
    $title2 = isset($title) && !empty($title) ? stripinput($title) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    $input_name = isset($input_name) && !empty($input_name) ? stripinput($input_name) : "";
    $input_id = isset($input_id) && !empty($input_id) ? stripinput($input_id) : "";
    $input_value = isset($input_value) && !empty($input_value) ? stripinput($input_value) : "";
    if (!is_array($array)) {
        $array = array();
        $state_validation = "";
        $placeholder = "";
        $width = "250px";
        $class = "";
        $well = "";
        $deactivate = "";
        $stacking = "";
        $format = "";
        $helper_text = "";
        $required = '0';
        $safemode = '0';
    } else {
        $required = array_key_exists('required', $array) && $array['required'] == 1 ? 1 : 0;
        $safemode = array_key_exists('safemode', $array) && $array['safemode'] == 1 ? 1 : 0;
        $placeholder = array_key_exists('placeholder', $array) ? $array['placeholder'] : "";
        $deactivate = array_key_exists('deactivate', $array) ? $array['deactivate'] : "";
        $class = array_key_exists('class', $array) ? $array['class'] : "";
        $width = array_key_exists('width', $array) ? $array['width'] : "250px";
        $well = array_key_exists('well', $array) ? "style='margin-top:-10px;'" : "";
        $stacking = array_key_exists("stacking", $array) ? 1 : "";
        $format = array_key_exists("format", $array) ? $array['format'] : "rgba";
        // options = the color format - hex | rgb | rgba.
        $helper_text = array_key_exists("helper", $array) ? $array['helper'] : "";
    }
    $html = "";
    if (!empty($title)) {
        // turn off coloumn
        if ($stacking == 1) {
            $html .= open_form_title($title, $input_id, $helper_text, $required);
        } else {
            $html .= open_form_title_2($title, $input_id, $helper_text, $required);
        }
    }
    // start colorpicker
    $html .= "<div id='{$input_id}' style='width:{$width}' class='input-group colorpicker-component bscp colorpicker-element' data-color='{$input_value}' data-color-format='{$format}'>";
    $html .= "<input type='text' name='{$input_name}' class='form-control {$class}' id='" . $input_id . "' value='{$input_value}' data-color-format='{$format}' placeholder='" . $placeholder . "' " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . ">";
    $html .= "<input type='hidden' name='def[{$input_name}]' value='[type=color],[title={$title2}],[id={$input_id}],[required={$required}],[safemode={$safemode}]' readonly>";
    $html .= "<span id='{$input_id}-cp' class='input-group-addon'>";
    $html .= "<i style='background: rgba(255,255,255,1);'></i>";
    $html .= "</span></div>";
    if (!empty($title)) {
        $html .= close_form_title();
    }
    $html .= add_to_jquery("\n    \$('#{$input_id}').colorpicker(\n    {\n    format : '{$format}'\n    });\n    ");
    return $html;
}