Пример #1
0
 function append($parent_path)
 {
     $values = func_get_args();
     $pkey = join('-', $parent_path);
     if (array_key_exists($pkey, $this->compteurs)) {
         $child_id = $this->compteurs[$pkey] + 1;
     } else {
         $child_id = 0;
     }
     $this->compteurs[$pkey] = $child_id;
     $path = $parent_path;
     array_push($path, $child_id);
     $values[0] = $path;
     $row = array();
     $ids = $this->getColumnIds();
     foreach ($ids as $i => $col) {
         $row[$col] = array_key_exists($i, $values) ? $values[$i] : null;
     }
     $count = count($this->rows);
     $patha = $path;
     $added = false;
     for ($i = 0; $i < $count; $i++) {
         $pathb = $this->rows[$i]['$$path$$'];
         if (wtk_table_tree_path_cmp($patha, $pathb) < 0) {
             array_splice($this->rows, $i, 0, array($row));
             $added = true;
             break;
         }
     }
     if (!$added) {
         array_push($this->rows, $row);
     }
     return $path;
 }
Пример #2
0
 /**
  * @dataProvider pathCmpFixtures
  */
 function testCmp($a, $b, $res)
 {
     $this->assertEquals(wtk_table_tree_path_cmp($a, $b), $res);
 }