/**
  * Đưa ra 1 phần tử ở vị trí dòng $i, cột $j
  * @param $i
  * @param $j
  */
 public function generate_item($i, $j)
 {
     $mis = $this->get_total_items($i, $j);
     if (($picks = $this->group_top_right_items($i, $j)) !== false) {
         //if($i==1&&$j==2) out1($picks,'b');
         $picks = _drw($picks);
         if (count($e = $picks->removes($mis)->O)) {
             //if($i==1&&$j==2) out1($e,'b');
             if (count($e) > 1) {
                 if ($this->get_col_items($j + 1) !== null) {
                     $e = cross_array('max', true, $this->get_col_items($j + 1), $e);
                 }
             }
             $get = get_rand_item($e);
             //$get=pick_rand_number(1,$size,$mis);
         } else {
             $get = pick_rand_number(1, $this->size, $mis);
         }
     } else {
         $get = pick_rand_number(1, $this->size, $mis);
     }
     if ($get == false) {
         echo '{-----------<br>' . $i . ',' . ($j - 1);
         dump($this->group_top_right_items($i, $j - 1));
         echo '-------------}<br>';
     }
     return $get;
 }
 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 c_rows($n)
 {
     $rs = array();
     $a = args_level_1(func_get_args());
     if (count($a) && ($s = _drw($a)->fir()) && !isDrw($s[1])) {
         $a = array($a);
     }
     foreach ($a as $v) {
         $rs[] = cEle('tr')->addChild($this->c_cols($v));
     }
     _($this->O)->addChild($rs);
     return $this;
 }
 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;
 }
示例#5
0
 function l_trim($a)
 {
     $m = _drw(func_get_args())->push(-1)->O;
     $this->trim($m);
     return $this;
 }
 function fetch($z)
 {
     /*array('table'=>'huy','limit'=>3,'format'=>'array')*/
     $a = func_get_args();
     $cols = '*';
     if (isDrw($a[0])) {
         $table = _drw($a[0])->get('table');
         if (!$table) {
             $table = $this->table;
             $cols = isDrw($table) ? isStr($table[1]) ? $table[1] : '*' : '*';
         }
         $limit = _drw($a[0])->get('limit');
         if (!$limit) {
             $limit = '';
         } else {
             $limit = ' LIMIT ' . $limit;
         }
         $format = _drw($a[0])->get('format');
     } else {
         $table = $a[0];
     }
     if (!$format) {
         $format = 'array';
     }
     $query = "select " . $cols . " from " . $table . $this->bind . $this->order . $limit;
     $this->query($query);
     $dt = $this->fetch_data();
     return $format == 'array' ? $dt : (object) $dt;
 }
function img($src, $attr = null)
{
    $c = _drw(array('src' => $src))->push($attr);
    return cEle('img', $c->O);
}
 function sh($i = 0)
 {
     return $this->more() ? _drw($this->O)->eq($i) : $this->O;
 }