--- phpMyEdit.class.1.153.php 2004-11-23 18:59:28.476051600 +0100 +++ phpMyEdit.class.php 2004-11-23 21:02:12.057755200 +0100 @@ -149,6 +149,8 @@ var $navigation; // navigation style var $tabs; // TAB names var $timer = null; // phpMyEdit_timer object + var $childs; // subforms + var $parent; // if not null, parent PME instance // Predefined variables var $comp_ops = array('<'=>'<','<='=>'<=','='=>'=','>='=>'>=','>'=>'>'); @@ -761,7 +763,7 @@ document.getElementById('.$this->js['prefix'].'cur_tab).style.display = "none"; document.getElementById(tab_name).style.display = "block"; '.$this->js['prefix'].'cur_tab = tab_name; - document.'.$this->cgi['prefix']['sys'].'form.'.$this->cgi['prefix']['sys'].'cur_tab.value = tab_name; + document.'.(!$this->display['form'] && isset($this->parent->cgi['prefix']['sys']) ? $this->parent->cgi['prefix']['sys'] : $this->cgi['prefix']['sys']).'form.'.$this->cgi['prefix']['sys'].'cur_tab.value = tab_name; }',"\n\n"; echo '// -->', "\n"; } @@ -1091,6 +1093,8 @@ echo ' wrap="virtual"'; } echo '>',htmlspecialchars($row["qf$k"]),'',"\n"; + } elseif (isset($this->fdd[$k]['child'])) { + $this->childs[$this->fds[$k]]->execute(); } else { $size_ml_props = ''; $maxlen = intval($this->fdd[$k]['maxlen']); @@ -1127,7 +1131,11 @@ $css_postfix = @$this->fdd[$k]['css']['postfix']; $css_class_name = $this->getCSSclass('value', null, true, $css_postfix); echo 'getColAttributes($k),">\n"; - echo $this->cellDisplay($k, $row, $css_class_name); + if (isset($this->fdd[$k]['child'])) { + $this->childs[$this->fds[$k]]->execute(); + } else { + echo $this->cellDisplay($k, $row, $css_class_name); + } echo '',"\n"; } /* }}} */ @@ -3037,6 +3045,48 @@ !isset($this->cgi['prefix']['operation']) && $this->cgi['prefix']['operation'] = 'PME_op_'; !isset($this->cgi['prefix']['sys']) && $this->cgi['prefix']['sys'] = 'PME_sys_'; !isset($this->cgi['prefix']['data']) && $this->cgi['prefix']['data'] = 'PME_data_'; + // Childs + $this->parent = null; + if(isset($opts['childs'])) { + global $HTTP_POST_VARS, $HTTP_GET_VARS; + $all_CGI = array_merge(Array(), @$HTTP_POST_VARS, @$HTTP_GET_VARS); + $cgi_parent = Array(); + foreach($all_CGI as $key => $val) { + if(preg_match('/^('.$this->cgi['prefix']['sys'].'.*)/', $key, $parts)) { + $cgi_parent[$key] = $val; + } + } + foreach($opts['childs'] as $key => $val) { + $val['display']['form'] = false; //form's tag not required for childs + $val['execute'] = 0; //don't execute childs now ! + $child_was_clicked = false; + foreach($all_CGI as $key2 => $val2) { //is last click child related + $child_was_clicked = $child_was_clicked || preg_match('/^('.$val['cgi']['prefix']['sys'].')(save|more|cancel|operation)+(add|view|change|copy|delete)?/', $key2, $parts); + } + foreach($all_CGI as $key2 => $val2) { // + if(preg_match('/^('.$val['cgi']['prefix']['sys'].')('.$this->cgi['prefix']['sys'].'.*)/', $key2, $parts)) { + //if last action was made on thsi child + if($child_was_clicked && $parts[2] != $this->cgi['prefix']['sys'].'cur_tab') { + //...force to previous main action + //shouldn't we here convert + // - morechange=Apply to operation = Change ? + // - operation=Add to operation=Change + correct rec ? + $this->cgi['overwrite'][$parts[2]] = $val2; + } + //backup main sys again (old one will be overwrited by next loop) + $val['cgi']['persist'][$val['cgi']['prefix']['sys'].$parts[2]] = $val2; + } + } + foreach($cgi_parent as $key2 => $val2) { //keep (but protect) parents CGI var + $val['cgi']['persist'][$val['cgi']['prefix']['sys'].$key2] = $val2; + } + $this->childs[$key] = new phpMyEdit($val); //instanciation + $this->childs[$key]->is_child = true; // it's a child + $this->childs[$key]->parent = $this; //it has a parent (persisting tab required) + } + } else { + $this->childs = false; + } // Sorting variables $this->sfn = $this->get_sys_cgi_var('sfn'); isset($this->sfn) || $this->sfn = array();