From 313b5a35508a8238f4ba4bb016415bbef62a4e42 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 25 Sep 2006 22:53:39 +0000 Subject: [PATCH] Minor changes to improve behaviour of selections. --- .../view_table_php/view_table_php.class.php | 81 ++++++++++++++----- .../actions/view_table_php/view_table_php.js | 10 ++- 2 files changed, 70 insertions(+), 21 deletions(-) diff --git a/admin/xmldb/actions/view_table_php/view_table_php.class.php b/admin/xmldb/actions/view_table_php/view_table_php.class.php index ffaaafd357..2780f499ac 100644 --- a/admin/xmldb/actions/view_table_php/view_table_php.class.php +++ b/admin/xmldb/actions/view_table_php/view_table_php.class.php @@ -43,7 +43,11 @@ class view_table_php extends XMLDBAction { 'selectfieldkeyindex' => 'xmldb', 'view' => 'xmldb', 'table' => 'xmldb', + 'selectonecommand' => 'xmldb', 'selectonefieldkeyindex' => 'xmldb', + 'mustselectonefield' => 'xmldb', + 'mustselectonekey' => 'xmldb', + 'mustselectoneindex' => 'xmldb', 'back' => 'xmldb' )); } @@ -97,6 +101,7 @@ class view_table_php extends XMLDBAction { $commandparam = optional_param('command', 'add_field', PARAM_PATH); $origfieldkeyindexparam = optional_param('fieldkeyindex', $defaultfieldkeyindex, PARAM_PATH); $fieldkeyindexparam = preg_replace('/[fki]#/i', '', $origfieldkeyindexparam); ///Strip the initials + $fieldkeyindexinitial = substr($origfieldkeyindexparam, 0, 1); //To know what we have selected /// The back to edit xml button $b = '

'; @@ -107,22 +112,27 @@ class view_table_php extends XMLDBAction { /// The table currently being edited $o .= '

' . $this->str['table'] . ': ' . s($tableparam) . '

'; + /// To indent the menu selections + $optionspacer = '   '; + /// Calculate the popup of commands - $commands = array('add_field', - 'drop_field', - 'rename_field (not imp!)', - 'change_field_type (not imp!)', - 'change_field_precision', - 'change_field_unsigned', - 'change_field_notnull', - 'change_field_sequence (not imp!)', - 'change_field_enum (not imp!)', - 'change_field_default'); + $commands = array('Fields', + $optionspacer . 'add_field', + $optionspacer . 'drop_field', + $optionspacer . 'rename_field (not imp!)', + $optionspacer . 'change_field_type (not imp!)', + $optionspacer . 'change_field_precision', + $optionspacer . 'change_field_unsigned', + $optionspacer . 'change_field_notnull', + $optionspacer . 'change_field_sequence (not imp!)', + $optionspacer . 'change_field_enum (not imp!)', + $optionspacer . 'change_field_default', + 'Keys', + 'Indexes'); foreach ($commands as $command) { - $popcommands[$command] = str_replace('_', ' ', $command); + $popcommands[str_replace($optionspacer, '', $command)] = str_replace('_', ' ', $command); } /// Calculate the popup of fields/keys/indexes - $optionspacer = '   '; if ($fields) { $popfields['fieldshead'] = 'Fields'; foreach ($fields as $field) { @@ -158,29 +168,60 @@ class view_table_php extends XMLDBAction { /// Check we have selected some field/key/index from the popup if ($fieldkeyindexparam == 'fieldshead' || $fieldkeyindexparam == 'keyshead' || $fieldkeyindexparam == 'indexeshead') { $o.= s($this->str['selectonefieldkeyindex']); - } else { + /// Check we have selected some command from the popup + } else if ($commandparam == 'Fields' || $commandparam == 'Keys' || $commandparam == 'Indexes') { + $o.= s($this->str['selectonecommand']); + } else { /// Based on current params, call the needed function switch ($commandparam) { case 'add_field': - $o.= s($this->add_field_php($structure, $tableparam, $fieldkeyindexparam)); + if ($fieldkeyindexinitial == 'f') { //Only if we have got one field + $o.= s($this->add_field_php($structure, $tableparam, $fieldkeyindexparam)); + } else { + $o.= $this->str['mustselectonefield']; + } break; case 'drop_field': - $o.= s($this->drop_field_php($structure, $tableparam, $fieldkeyindexparam)); + if ($fieldkeyindexinitial == 'f') { //Only if we have got one field + $o.= s($this->drop_field_php($structure, $tableparam, $fieldkeyindexparam)); + } else { + $o.= $this->str['mustselectonefield']; + } break; case 'rename_field': - $o.= s($this->rename_field_php($structure, $tableparam, $fieldkeyindexparam)); + if ($fieldkeyindexinitial == 'f') { //Only if we have got one field + $o.= s($this->rename_field_php($structure, $tableparam, $fieldkeyindexparam)); + } else { + $o.= $this->str['mustselectonefield']; + } break; case 'change_field_precision': - $o.= s($this->change_field_precision_php($structure, $tableparam, $fieldkeyindexparam)); + if ($fieldkeyindexinitial == 'f') { //Only if we have got one field + $o.= s($this->change_field_precision_php($structure, $tableparam, $fieldkeyindexparam)); + } else { + $o.= $this->str['mustselectonefield']; + } break; case 'change_field_unsigned': - $o.= s($this->change_field_unsigned_php($structure, $tableparam, $fieldkeyindexparam)); + if ($fieldkeyindexinitial == 'f') { //Only if we have got one field + $o.= s($this->change_field_unsigned_php($structure, $tableparam, $fieldkeyindexparam)); + } else { + $o.= $this->str['mustselectonefield']; + } break; case 'change_field_notnull': - $o.= s($this->change_field_notnull_php($structure, $tableparam, $fieldkeyindexparam)); + if ($fieldkeyindexinitial == 'f') { //Only if we have got one field + $o.= s($this->change_field_notnull_php($structure, $tableparam, $fieldkeyindexparam)); + } else { + $o.= $this->str['mustselectonefield']; + } break; case 'change_field_default': - $o.= s($this->change_field_default_php($structure, $tableparam, $fieldkeyindexparam)); + if ($fieldkeyindexinitial == 'f') { //Only if we have got one field + $o.= s($this->change_field_default_php($structure, $tableparam, $fieldkeyindexparam)); + } else { + $o.= $this->str['mustselectonefield']; + } break; } } diff --git a/admin/xmldb/actions/view_table_php/view_table_php.js b/admin/xmldb/actions/view_table_php/view_table_php.js index 1fb1d888bf..071f08678b 100644 --- a/admin/xmldb/actions/view_table_php/view_table_php.js +++ b/admin/xmldb/actions/view_table_php/view_table_php.js @@ -31,9 +31,17 @@ } /** - * This function disables some elements from the fields/keys/indexes drop down + * This function disables some elements from the command and from the fields/keys/indexes drop downs */ function disablePopupHeads() { + var popup = document.getElementById("menucommand"); + var i = popup.length; + while (i--) { + option = popup[i]; + if (option.value == "Fields" || option.value == "Keys" || option.value == "Indexes") { + popup[i].disabled = true; + } + } var popup = document.getElementById("menufieldkeyindex"); var i = popup.length; while (i--) { -- 2.39.5