function do_method($a, $v = null) { $p = $this->target ? $this->target : $this; $args = optimize_args(func_get_args()); /*get callback*/ foreach ($args as $z) { if (ispack($z) && type($z) == 'object') { $cb = $z; } } $methods = $this->methods($p); if (isStr($a)) { if (isIn($a, $methods)) { $p->{$a}($v); } else { if (isset($cb)) { $cb($p, array($a, $v)); } else { $p->attr($a, $v); } } } else { while (list($i, $v_) = _each($args, $k)) { if (isStr($i)) { $this->do_method($i, $v_); } if (isDrw(OBJ($v_))) { foreach ($v_ as $l => $v1) { $this->do_method($l, $v1); } } } } return $this; }
static function valid_load_file($d) { $m = _drw(OBJ($d)); while (list($i, $v) = $m->each($k)) { if (!_file($v)->exist()) { $m->removes($v); } } return $m->O; }
function assign_link(&$o, $url = '', $targ = '_parent') { if (type(OBJ($o, false)) == 'a') { _($o)->attr(array('href' => $url, 'target' => $targ)); } else { $l = c_link($o, $url, $targ); _($o)->parent()->replaceChild($o, $l); $o = $l; } }
function create($m, $n = null) { $a = new DRW(func_get_args()); $a->next(); $r = new DRW(); $this->explorer($a, $r); return cEle($a->get(0), $r)->set_methods(function ($ref, $n, $args) { if ($n == 'setLegend') { $legend = cEle('legend'); foreach ($args as $v) { if (isDrw($v) && OBJ($v)) { foreach ($v as $i => $v1) { $legend->do_method(array($i => $v1)); } } } $ref->addChild($legend); } if ($n == 'add_option') { $e = cEle('option'); foreach (args_level_1($args) as $v) { if (isDrw($v)) { foreach ($v as $i => $v1) { $e->do_method(array($i => $v1)); } } else { if (!$e->attr('value')) { $e->attr('value', $v); } else { $e->html($v); } $ref->addChild($e); } } } if ($n == 'add_options') { foreach ($args as $v) { $ref->add_option($v); } } }); }
function remove($k = null) { $s = $k == null ? $this->cell : $k->cell; $j = '$this->cell_store->O'; $a = $this->cell_store->O; if (isEle(_drw($s)->eq(0))) { $s = array($s); } foreach ($s as $v1) { $m = $this->cell_store->search($v1); $this->removeChild($v1[0]); if (!count($m[0])) { continue; } foreach ($m[0] as $u) { $w = explode('/', $u[1]); for ($i = 0; $i < count($w); $i++) { pure($w[$i]); $j .= isset($a->O) ? "->O['" . $w[$i] . "']" : "['" . $w[$i] . "']"; $h = OBJ($a, false); $a =& $h[$w[$i]]; } eval('unset(' . $j . ');'); } } return $this; }
function addChild($nodes) { if (!$this->more()) { $a = func_get_args(); pure_args($a); if (isEle(OBJ($a))) { $this->O->appendChild($a); } else { if (isDrw($a)) { foreach ($a as $v) { if (isDrw($v)) { while (list($i, $u) = _each($v, $k)) { $this->addChild($u); } } elseif (isEle($v)) { $this->addChild($v); } } } } } else { foreach ($this->O as $v) { _($v)->addChild(func_get_args()); } } return $this; }