function __construct($a = null) { $a = func_get_args(); $this->cell_store = new DRW(); $i = null; $j = null; if (count($a)) { foreach ($a as $v) { isNum($v) ? !$i ? $i = $v : ($j = $v) : ''; } } foreach ($a as $y => $v) { if (isNum($v)) { unset($a[$y]); } elseif (isStr($v)) { $this->child_type = $v; $this->O = $this->c_cell($a); } } if (!$this->O) { $this->O = cEle('div')->css('padding:1px')->do_method($a)->O; } $this->methods = function ($ref, $n, $args) { }; }
function valid_file_name($fs) { if (isStr($fs)) { return preg_match('/[\\/:*?"<>|]/', $fs) ? preg_replace('/[\\/:*?"<>|]/', '_', $fs) : $fs; } if (isDrw($fs)) { $d = array(); foreach ($fs as $v) { $d[] = valid_file_name($v); } return $d; } }
function comboBox_range($from, $to, $assign = '', $opt = 0) { if (isNum($from) && isNum($to) && $from <= $to) { if (!isStr($assign)) { $assign = ''; } $list = createForm()->select->create(array()); for ($i = $from; $i <= $to; $i++) { $list->add_option($i, $opt <= 0 ? $assign . $i : $i . $assign); } return $list; } }
function valid_datetime_object($t) { //only date if (type($t) == '_Date') { $y = $t->get_date(); } elseif (type($t) == 'DateTime') { $y = $t; } if (isStr($t) && isDate($t)) { $s = explode('-', $t); $y = new DateTime(); $y->setDate($s[0], $s[1], $s[2]); } if (isset($y)) { return $y; } else { return false; } }
function trim($t = '') { $a = optimize_args(func_get_args()); if (isNum($a[0])) { $b = shift($a); } else { $b = 0; } trim($this->O); for ($i = 0; $i < count($a); $i++) { foreach ($a as $v) { if (isStr($v)) { if ($v == 'number') { $c = '\\d'; } else { $c = $v; } $lef = '^(\\/?(\\s+|)(' . $c . '+))'; $rig = '(' . $c . '+)?(\\s+|)$'; $this->O = preg_replace('/' . (!isDrw($b) ? $lef . '|' . $rig : ($b[1] < 0 ? $lef : $rig)) . '/', '', $this->O); } } } return $this; }
function append($str = null, $f = null) { $n = $f == null ? $this->name : $f; $s = _file($n, 'a'); if (isStr($str)) { $s->write($str); } return $s; }
function create_db($n) { if (isStr($n)) { $this->query("create database " . $n); } return $this; }
function bind($evt, $js = null) { if (!$this->more()) { if (isStr($evt) && isStr($js)) { if (strtoupper(substr($evt, 0, 2)) != 'ON') { $evt = 'on' . $evt; } $m = $this->attr($evt); $this->attr($evt, ($m ? $m . ';' : '') . $js); } if (isDrw($evt)) { foreach ($evt as $i => $v) { $this->bind($i, $v); } } } else { foreach ($this->O as $v) { _($v)->bind($evt, $js); } } return $this; }
function cItems($n) { $m = cEle('div'); $h = array(); $a = args_level_1(func_get_args()); foreach ($a as $v) { if (!isDrw($v)) { $m->addChild(isStr($v) ? cEle('label', $v) : $v); } else { $h[] = $this->cItems($v); } } return count($h) ? $h : $m; }
function remove_item($i, $j = null) { if (isStr($i) && $j === null) { $t = explode('-', $i); $this->remove_item($t[0], $t[1]); return; } if (isNum($i) && isNum($j)) { $i = (int) $i; $j = (int) $j; if ($this->check_item($i, $j)) { $this->grid[$i][$j] = null; } return; } foreach (func_get_args() as $v) { if (isDrw($v)) { foreach ($v as $l) { if (isStr($l)) { $this->remove_item($l); } } } elseif (isStr($v)) { $this->remove_item($v); } } }