<?php
class Elements {

  private $db;
  private $status;

  public function __construct() {
    $this->db = new Db_layer();
    $this->status = new Status_messages();
  }

  //---[CZ]: vytvořit input typu text
  public function input_text($name, $width, $check_empty, $id, $value) {
    echo "<input type=\"text\" name=\"$name\" style=\"width: $width"."px\"";
    if (isset($_POST["submit"]) AND $check_empty==1 AND $_POST["$name"]=="") { echo " class=\"input-error\""; }
    if ($id!="") { echo " id=\"$name\""; }
    if ($value!="") { echo " value=\"".$this->db->unescape(htmlspecialchars($value))."\""; }
    echo " />";
  }
  
  //---[CZ]: vytvořit input typu button
  public function input_button($value, $class, $onclick) {
    echo "<input type=\"button\" value=\"$value\"";
    if ($class!="") { echo " class=\"$class\""; }
    if ($onclick!="") { echo " id=\"$onclick\""; }
    echo " />";
  }
  
  //---[CZ]: vytvořit input typu submit
  public function button_submit($value) {
    echo "<input type=\"submit\" name=\"submit\" value=\"$value\" class=\"greenbutton\" />";
  }
  
   //---[CZ]: mazací čudlík
  public function button_delete($url) {
    echo "<input type=\"button\" value=\"".LANG_DELETE."\" class=\"redbutton\" onclick=\"if (!confirm('".LANG_ARE_YOU_SURE."')) return false; parent.location='$url;'\" />";
  }
  
  //---[CZ]: textové pole
  public function textarea($name, $width, $height, $check_empty, $id, $value) {
    echo "<textarea name=\"$name\" cols=\"\" rows=\"\" style=\"width: $width"."px; height: $height"."px;\"";
    if (isset($_POST["submit"]) AND $check_empty==1 AND $_POST["$name"]=="") { echo " class=\"input-error\""; }
    if ($id!="") { echo " id=\"$name\""; }
    echo ">";
    if ($value!="") { echo $this->db->unescape(htmlspecialchars($value)); }
    echo "</textarea>";
  }

}
?>