示例#1
0
     break;
 case 'add child':
     $parent = $_POST['keys']['id'];
     break;
 case 'Edit':
     $sql->query("DROP TABLE `%tree_tmp`");
     ddc_gentable_n('%tree_tmp', $ddc_tree_structure, $ddc_tree_structure_keys, $sql);
     $sql->query("INSERT INTO `%tree_tmp` SELECT * FROM `%tree`");
     print "window.location.reload(true);";
     exit;
 case "Cancel":
     $sql->query("DROP TABLE `%tree_tmp`");
     print "window.location.reload(true);";
     exit;
 case "Save":
     $ddc = new ddc_key();
     $ddc->attach('%tree', $sql);
     $ddc2 = new ddc_key();
     $ddc2->attach('%tree_tmp', $sql);
     $ddc->gen_changes($ddc2);
     foreach ($ddc->actions as $i => $r) {
         print "chse.safe_alert(111,'" . js_escape($r->q) . "');";
     }
     $ddc->apply_changes($sql);
     $sql->query("DROP TABLE `%tree`");
     ddc_gentable_n('%tree', $ddc_tree_structure, $ddc_tree_structure_keys, $sql);
     $sql->query("INSERT INTO `%tree` SELECT * FROM `%tree_tmp`");
     //print "window.location.reload(true);";
     exit;
 case 'del':
     $q = "DELETE FROM `" . $workingtable . "` WHERE (SELECT `%tree_selections`.selected FROM `%tree_selections` WHERE `" . $workingtable . "`.id=`%tree_selections`.id )=1";
示例#2
0
 function html_inner()
 {
     global $sql;
     $r = $sql->fetch1($sql->query("SELECT count(1) FROM `" . TABLE_META_TREE_TMP . "`"));
     if ($r > 0) {
         $t = TABLE_META_TREE_TMP;
         $ins = new query_gen_ext('INSERT UPDATE');
         $ins->into->exprs[] = new sql_column(NULL, $t);
         unset($ins_vars);
     } else {
         $t = TABLE_META_TREE;
     }
     $new = new ddc_key();
     $new->attach(TABLE_META_TREE_TMP, $sql);
     $diff = $new->inheritance_update();
     if (is_array($diff)) {
         $this->tbl->html_head();
     }
     if (is_array($diff)) {
         foreach ($diff as $d) {
             $this->args['type'] = $d->type;
             $this->args['id'] = $d->id;
             $this->args['href'] = '';
             $this->args['name'] = $d->descr;
             $this->args['change'] = "";
             $this->args['apply'] = "apply";
             foreach ($d->row as $rk => $rv) {
                 $this->args['change'] .= $rk . "=" . $rv . ";";
                 if (isset($ins) && $d->type == '+') {
                     if (isset($ins_vars[$rk])) {
                         $ins_vars[$rk]->value = $rv;
                     } else {
                         $ins_vars[$rk] = new sql_immed($rv);
                         $ins->set->exprs[] = new sql_expression('=', array(new sql_column(NULL, NULL, $rk), $ins_vars[$rk]));
                     }
                 }
             }
             if (isset($ins) && $d->type == '+') {
                 $this->args['apply'] = $ins->result();
             } else {
                 $this->args['apply'] = "";
             }
             if (isset($ins) && ($d->type == '*q' || $d->type == '-q' || $d->type == '+q')) {
                 $this->args['apply'] = $d->row['query'];
             }
             //$this->args['meta_change']=$d->meta_change;
             //$this->args['change']=count($d->diff);
             $this->row->css_style['background'] = '';
             switch ($d->type) {
                 case '-':
                     $this->row->css_style['background'] = string_to_color('sql_table', 2);
                     break;
                 case '+':
                     $this->row->css_style['background'] = string_to_color('name', 2);
                     break;
                 case '*':
                     $this->row->css_style['background'] = 'yellow';
                     break;
             }
             $this->row->html();
             $this->row->id_alloc();
         }
     } else {
         $this->gen_error->text = $diff;
         $this->gen_error->html();
     }
     if (is_array($diff)) {
         $this->tbl->html_tail();
     }
 }