Exemplo n.º 1
0
 public function formatTree($tree, &$objects)
 {
     $obj = '';
     $pid = $row = 1;
     $info = ['TA' => [$this->LNG['obj_tables'], 1], 'VI' => [$this->LNG['obj_views'], 3], 'PR' => [$this->LNG['obj_procs'], 5], 'FU' => [$this->LNG['obj_funcs'], 7], 'TR' => [$this->LNG['obj_trigs'], 9], 'EV' => [$this->LNG['obj_events'], 11]];
     // Находим таблицы с префиксами
     $tab_prefix_last = $tab_prefix = '*';
     for ($i = 0, $l = count($objects['TA']); $i < $l; ++$i) {
         $t = $objects['TA'][$i];
         $tab_prefix = preg_match('/^([a-z0-9]+_)/', $t[0], $m) ? $m[1] : '*';
         if ($tab_prefix != $tab_prefix_last) {
             if ($tab_prefix != '*') {
                 $objects['TA']['*'][] = $tab_prefix;
             }
             $tab_prefix_last = $tab_prefix;
         }
         $objects['TA'][$tab_prefix][] = $t;
         unset($objects['TA'][$i]);
     }
     foreach ($objects as $type => $o) {
         if (!count($o)) {
             continue;
         }
         if ($type == 'TA') {
             $open_childs = count($o['*']) > 1 ? 0 : 1;
             $obj .= "[{$row},0," . sxd_esc($info[$type][0]) . ',1,1,1],';
             ++$row;
             foreach ($o['*'] as $value) {
                 if (is_string($value)) {
                     if (count($o[$value]) > 1) {
                         $obj .= "[{$row},1,'{$value}*',1,1,{$open_childs}],";
                         $pid = $row++;
                         for ($i = 0, $l = count($o[$value]); $i < $l; ++$i) {
                             $checked = $o[$value][$i][1] == '' && $o[$value][$i][2] == '' ? 2 : 1;
                             $obj .= "[{$row},{$pid}," . sxd_esc($o[$value][$i][0]) . ",2,{$checked},{$o[$value][$i][2]}],";
                             ++$row;
                         }
                     } else {
                         $value = $o[$value][0];
                     }
                 }
                 //$pid = 1;
                 if (is_array($value)) {
                     $checked = $value[1] == '' && $value[2] == '' ? 2 : 1;
                     $obj .= "[{$row},1,'{$value[0]}',2,{$checked},{$value[2]}],";
                     ++$row;
                 }
             }
         } else {
             $obj .= "[{$row},0," . sxd_esc($info[$type][0]) . ",{$info[$type][1]},1,1],";
             $pid = $row++;
             ++$info[$type][1];
             for ($i = 0, $l = count($o); $i < $l; ++$i) {
                 $o[$i] = sxd_esc($o[$i], false);
                 $obj .= "[{$row},{$pid},'{$o[$i]}',{$info[$type][1]},1,0],";
                 ++$row;
             }
         }
     }
     $add = '';
     if ($tree == 'restore') {
         $add = "z('autoinc').disabled = z('restore_type').disabled = " . ($obj ? 'false' : 'true') . ';';
     }
     return ($obj ? 'sxd.tree.' . $tree . '.drawTree([' . substr_replace($obj, ']', -1) . ');' : "sxd.tree.{$tree}.error(sxd.lng('err_sxd2'));") . $add;
 }
Exemplo n.º 2
0
 function formatTree($tree, &$objects)
 {
     $obj = "";
     $pid = $row = 1;
     $info = array("TA" => array($this->LNG["obj_tables"], 1), "VI" => array($this->LNG["obj_views"], 3), "PR" => array($this->LNG["obj_procs"], 5), "FU" => array($this->LNG["obj_funcs"], 7), "TR" => array($this->LNG["obj_trigs"], 9), "EV" => array($this->LNG["obj_events"], 11));
     $tab_prefix_last = $tab_prefix = "*";
     for ($i = 0, $l = count($objects["TA"]); $i < $l; $i++) {
         $t = $objects["TA"][$i];
         $tab_prefix = preg_match("/^([a-z0-9]+_)/", $t[0], $m) ? $m[1] : "*";
         if ($tab_prefix != $tab_prefix_last) {
             if ($tab_prefix != "*") {
                 $objects["TA"]["*"][] = $tab_prefix;
             }
             $tab_prefix_last = $tab_prefix;
         }
         $objects["TA"][$tab_prefix][] = $t;
         unset($objects["TA"][$i]);
     }
     foreach ($objects as $type => $o) {
         if (!count($o)) {
             continue;
         }
         if ($type == "TA") {
             $open_childs = count($o["*"]) > 1 ? 0 : 1;
             $obj .= "[{$row},0," . sxd_esc($info[$type][0]) . ",1,1,1],";
             $row++;
             foreach ($o["*"] as $value) {
                 if (is_string($value)) {
                     if (count($o[$value]) > 1) {
                         $obj .= "[{$row},1,'{$value}*',1,1,{$open_childs}],";
                         $pid = $row++;
                         for ($i = 0, $l = count($o[$value]); $i < $l; $i++) {
                             $checked = $o[$value][$i][1] == "" && $o[$value][$i][2] == "" ? 2 : 1;
                             $obj .= "[{$row},{$pid}," . sxd_esc($o[$value][$i][0]) . ",2,{$checked},{$o[$value][$i][2]}],";
                             $row++;
                         }
                     } else {
                         $value = $o[$value][0];
                     }
                 }
                 if (is_array($value)) {
                     $checked = $value[1] == "" && $value[2] == "" ? 2 : 1;
                     $obj .= "[{$row},1,'{$value[0]}',2,{$checked},{$value[2]}],";
                     $row++;
                 }
             }
         } else {
             $obj .= "[{$row},0," . sxd_esc($info[$type][0]) . ",{$info[$type][1]},1,1],";
             $pid = $row++;
             $info[$type][1]++;
             for ($i = 0, $l = count($o); $i < $l; $i++) {
                 $o[$i] = sxd_esc($o[$i], false);
                 $obj .= "[{$row},{$pid},'{$o[$i]}',{$info[$type][1]},1,0],";
                 $row++;
             }
         }
     }
     $add = "";
     if ($tree == "restore") {
         $add = "z('autoinc').disabled = z('prefix').disabled = z('restore_type').disabled = z('prefix_from').disabled = z('prefix_to').disabled = z('savesql').disabled = " . ($obj ? "false" : "true") . ";";
     }
     return ($obj ? "sxd.tree." . $tree . ".drawTree([" . substr_replace($obj, "]", -1) . ");" : "sxd.tree.{$tree}.error(sxd.lng('err_sxd2'));") . $add;
 }