static function read_files_in_dir($dir)
 {
     $f = array();
     $d = new DRW();
     $r = function ($l, &$s, &$f) {
         if (!is_dir($l)) {
             return $l;
         }
         $u = opendir($l);
         while (($y = readdir($u)) != false) {
             if ($y == '.' || $y == '..') {
                 continue;
             }
             $loca = $l . $y;
             if (is_dir($loca)) {
                 $s->push($loca);
             } else {
                 $f[] = $loca;
             }
         }
     };
     $q = function (&$d, &$f, $q, $r) {
         $e = new DRW();
         while (($v = $d->pop()) != null) {
             $e = new DRW();
             $r($v[1], $e, $f);
         }
         $d->push($e->O);
         if ($d->count()) {
             $q($d, $f, $q, $r);
         }
     };
     $r($dir, $d, $f);
     if ($d->count()) {
         $q($d, $f, $q, $r);
     }
     return $f;
 }
 function addCells($ag, $inf)
 {
     $a = _drw($ag);
     if (!$a->get('css')) {
         $a->push(array('css' => $inf . 'width:100%'));
     }
     foreach ($a->O as $i => &$v) {
         if (isDrw($v)) {
             if (isset($v['css'])) {
                 preg_match('/([^;]+)?width.*?[^;]+[;|\\w,-]/', $v['css'], $m);
                 if (count($m)) {
                     $j = ($n = explode(':', $m[0])) && $n[0] == 'width';
                 }
                 $r = substr($v['css'], strlen($v['css']) - 1, 1) == ';' ? '' : ';';
                 $v['css'] .= $r . $inf . (isset($j) && $j ? '' : 'width:100%');
             } else {
                 $v['css'] = $inf . 'width:100%';
             }
         }
     }
     $r = $this->c_cell($a->O);
     $s = $this->cell;
     $clone = function (&$c, $p) {
         _drw($c)->copy($y);
         $w = $p->cell_struct($y);
         return array(pure($y, true), &$w);
     };
     if ($s != null && isDrw(_drw($s)->eq(0))) {
         $y = new DRW();
         foreach ($s as $i => &$q) {
             $z = $clone($r, $this);
             $u =& $z[1];
             $y->push($u);
             _($q[0])->addChild($z[0]);
             _drw($q)->eq(1)->push($u);
         }
         $this->cell =& $y->O;
     } else {
         $z = $clone($r, $this);
         $u =& $z[1];
         $os = $s != null ? _($this->cell[0]) : $this;
         if ($s != null) {
             _drw($this->cell)->eq(1)->push($u);
             $this->cell = $u;
         } else {
             $this->cell = $u;
             if (!isDrw($z[1])) {
                 $this->cell_store->push(array('t' . $this->idx++ => $z[1]));
             } else {
                 foreach ($z[1] as $s1 => &$v) {
                     $this->cell_store->push(array('t' . $this->idx++ => $v));
                 }
             }
         }
         $os->addChild($z[0]);
     }
 }
Esempio n. 3
0
 private function pos_and_or($args)
 {
     $a = new DRW(func_get_args());
     $opt = $a->first();
     $a->next();
     foreach ($a->O as $v) {
         if ($opt[1] == 'or' && $this->pos($v) !== false) {
             return true;
         }
         if ($opt[1] == 'and' && $this->pos($v) === false) {
             return false;
         }
     }
     if ($opt[1] == 'or') {
         return false;
     }
     if ($opt[1] == 'and') {
         return true;
     }
 }
 private function sql($m)
 {
     $a = new DRW($m);
     $s = '';
     $c = '';
     $tb = '';
     while ($y = $a->shift()) {
         $k = $y[1];
         if ($k === true) {
             $this->table = $k;
         }
         if (!isStr($k)) {
             continue;
         }
         $j = new STR($k);
         if ($j->bind_pos('or', '>', '<', '=', ',')) {
             if (!$s) {
                 $s = $k;
             } else {
                 $c = ' WHERE ' . $k;
             }
         } else {
             if ($k !== SQL_BIND_INHERIT && !$tb) {
                 $tb = $k;
             } else {
                 $this->order = $k;
             }
         }
     }
     if (!$c) {
         $c = $this->bind;
     }
     return array(!$tb ? $this->table : $tb, $s, $c);
 }
 function attr($a = null, $v = null)
 {
     $m = func_get_args();
     if (!$this->more()) {
         if (!func_num_args()) {
             $s = new DRW();
             if ($this->O->hasAttributes()) {
                 foreach ($this->O->attributes as $v) {
                     $s->push(array($v->name => $v->value));
                 }
             }
             return $s->isEmpty() ? null : $s;
         }
         if (isStr($a) && (isStr($v) || isNum($v))) {
             $this->O->setAttribute($a, $v);
         }
         if (isStr($a) && $v == null) {
             if (preg_match('/\\w/', $a, $q) && $q[0] == '~') {
                 $this->O->removeAttribute($a);
             } else {
                 return $this->O->hasAttribute($a) ? $this->O->getAttribute($a) : null;
             }
         }
         foreach ($m as $v) {
             if (isDrw($v)) {
                 while (list($i, $v1) = _each($v, $k)) {
                     $this->attr($i, $v1);
                 }
             }
         }
     } else {
         $h = array();
         foreach ($this->O as $o) {
             $h[] = _($o)->attr(func_get_args());
         }
         pure($h);
         if (count($h)) {
             return $h;
         }
     }
     return $this;
 }
 function create($m = null, $n = null)
 {
     $a = new DRW(func_get_args());
     while (list($i1, $v) = $a->each($l)) {
         if (isDrw($v)) {
             foreach ($v as $i => $v1) {
                 if ($i == 'type') {
                     unset($a->O[$i1][$i]);
                 }
             }
         }
     }
     $tp = 'input';
     if (!isIn($this->type, array('textarea', 'select', 'label', 'fieldset', 'legend', 'optgroup', 'option'))) {
         $a->push(array('type' => $this->type));
     } else {
         $tp = $this->type;
     }
     return Form::create($tp, $a->O);
 }