fix tabletree
This commit is contained in:
parent
e4527ad94e
commit
b3f6cfcbd7
2 changed files with 14 additions and 12 deletions
|
|
@ -19,17 +19,19 @@
|
|||
namespace ctiso;
|
||||
use ctiso\Functions;
|
||||
|
||||
function tableTreeWalk($level, $table, $fn) {
|
||||
if (empty ($level)) return $table;
|
||||
$name = array_shift ($level);
|
||||
|
||||
$keys = Functions::key_unique_values($name, $table);
|
||||
$data = array ();
|
||||
foreach ($keys as $index) {
|
||||
list($rows, $table) = Functions::partition (Functions::lcurry(['Functions', '__index'], $index, $name), $table);
|
||||
// $rows = array_filter ($table, lcurry('__index', intval($index), $name));
|
||||
//$rows = array_filter ($table, create_function ('$x', 'return __index ('.intval($index).', \''.$name.'\', $x);'));
|
||||
$data[$index] = call_user_func ($fn, $name, $index, $rows, tableTreeWalk ($level, $rows, $fn));
|
||||
class TableTree {
|
||||
static function walk($level, $table, $fn) {
|
||||
if (empty ($level)) return $table;
|
||||
$name = array_shift ($level);
|
||||
|
||||
$keys = Functions::key_unique_values($name, $table);
|
||||
$data = array ();
|
||||
foreach ($keys as $index) {
|
||||
list($rows, $table) = Functions::partition (Functions::lcurry(['\ctiso\Functions', '__index'], $index, $name), $table);
|
||||
// $rows = array_filter ($table, lcurry('__index', intval($index), $name));
|
||||
//$rows = array_filter ($table, create_function ('$x', 'return __index ('.intval($index).', \''.$name.'\', $x);'));
|
||||
$data[$index] = call_user_func ($fn, $name, $index, $rows, self::walk ($level, $rows, $fn));
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue