51 lines
1.5 KiB
PHP

<?php
class attr_email extends attr {
function getDBType() {
return "varchar(255)";
}
function lPost() {
$val = trim(strtolower($_POST[$this->attr_name]));
$this->obj->set($this->attr_name, $val);
}
function render_text( $crop = false ) {
return $this->getCurVal();
}
function validate() {
if ( !preg_match("/^([a-z0-9_\.-]+)@([a-z0-9_\.-]+)\.([a-z\.]{2,6})$/i",strtolower($this->getCurVal()) ) ) {
return 'Неверный формат ввода';
}
}
function render_input() {
return '<input id="' . $this->attr_name . '" type="text" class="form-control" name="' . $this->attr_name . '" value="' .$this->getCurVal() . '">';
}
function getFilter( $sql_where = '' ) {
$fname = $this->obj->obj_name . '_' . $this->attr_name;
$html = '<input class="form-control form-control-sm" id="_f_'.$fname.'" name="'.$fname.'" value="'.htmlentities($_GET[$fname]).'" onkeypress="int13_filter_'.$fname.'();" onKeyUp>
<script>
function int13_filter_'.$fname.'() {
if (window.event.keyCode == 13 || window.event.keyCode == 9) { location.href="'._getCurl(array( $fname, 'curpage' )).'&'.$fname.'=" + $("#_f_'.$fname.'").val(); return true; }
}
</script>';
$sql = '';
if ( $_GET[$fname] ) {
$sql = ' AND `' . $this->attr_name . '` LIKE "%' . db_escape_string($_GET[$fname]) . '%" ';
}
return array('html'=> $html, 'sql'=> $sql);
}
}
?>