From eafc2b70e876a64561013c226c1166f45f6cafa7 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 11 Sep 2006 22:06:35 +0000 Subject: [PATCH] Some more improvements. Not finished yet. --- .../view_table_php/view_table_php.class.php | 66 ++++++++++++++----- .../actions/view_table_php/view_table_php.js | 45 +++++++++++++ 2 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 admin/xmldb/actions/view_table_php/view_table_php.js 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 fdefe8728f1..b51a35a8561 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 @@ -42,6 +42,8 @@ class view_table_php extends XMLDBAction { 'selectaction' => 'xmldb', 'selectfieldkeyindex' => 'xmldb', 'view' => 'xmldb', + 'table' => 'xmldb', + 'selectonefieldkeyindex' => 'xmldb', 'back' => 'xmldb' )); } @@ -86,19 +88,25 @@ class view_table_php extends XMLDBAction { $field = reset($fields); $defaultfieldkeyindex = null; if ($field) { - $defaultfieldkeyindex = $field->getName(); + $defaultfieldkeyindex = 'f#' . $field->getName(); } + $keys = $table->getKeys(); + $indexes = $table->getIndexes(); /// Get parameters $commandparam = optional_param('command', 'add_field', PARAM_PATH); $fieldkeyindexparam = optional_param('fieldkeyindex', $defaultfieldkeyindex, PARAM_PATH); + $fieldkeyindexparam = preg_replace('/[fki]#/i', '', $fieldkeyindexparam); ///Strip the initials /// The back to edit xml button $b = '

'; - $b .= '[' . $this->str['back'] . ']'; + $b .= '[' . $this->str['back'] . ']'; $b .= '

'; $o = $b; + /// The table currently being edited + $o .= '

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

'; + /// Calculate the popup of commands $commands = array('add_field', 'drop_field', @@ -106,32 +114,56 @@ class view_table_php extends XMLDBAction { foreach ($commands as $command) { $popcommands[$command] = str_replace('_', ' ', $command); } - /// Calculate the popup of tables - foreach ($fields as $field) { - $poptables[$field->getName()] = $field->getName(); + /// Calculate the popup of fields/keys/indexes + $optionspacer = '   '; + if ($fields) { + $poptables['fieldshead'] = 'Fields'; + foreach ($fields as $field) { + $poptables['f#' . $field->getName()] = $optionspacer . $field->getName(); + } } + if ($keys) { + $poptables['keyshead'] = 'Keys'; + foreach ($keys as $key) { + $poptables['k#' . $key->getName()] = $optionspacer . $key->getName(); + } + } + if ($indexes) { + $poptables['indexeshead'] = 'Indexes'; + foreach ($indexes as $index) { + $poptables['i#' . $index->getName()] = $optionspacer . $index->getName(); + } + } + /// Now build the form $o.= '
'; $o.= ' '; + $o.= ' '; $o.= ' '; $o.= ' '; - $o.= ' '; + $o.= ' '; $o.= ' '; $o.= '
' . choose_from_menu($popcommands, 'command', $commandparam, '', '', 0, true) . ' ' .choose_from_menu($poptables, 'table', $tableparam, '', '', 0, true) . '
' . choose_from_menu($popcommands, 'command', $commandparam, '', '', 0, true) . ' ' .choose_from_menu($poptables, 'fieldkeyindex', 'f#' . $fieldkeyindexparam, '', '', 0, true) . '
'; $o.= '
'; + $o.= ' '; $o.= ' '; $o.= '
'; diff --git a/admin/xmldb/actions/view_table_php/view_table_php.js b/admin/xmldb/actions/view_table_php/view_table_php.js new file mode 100644 index 00000000000..fcd9dded1f9 --- /dev/null +++ b/admin/xmldb/actions/view_table_php/view_table_php.js @@ -0,0 +1,45 @@ +/// $Id $ + +/////////////////////////////////////////////////////////////////////////// +// // +// NOTICE OF COPYRIGHT // +// // +// Moodle - Modular Object-Oriented Dynamic Learning Environment // +// http://moodle.com // +// // +// Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com // +// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details: // +// // +// http://www.gnu.org/copyleft/gpl.html // +// // +/////////////////////////////////////////////////////////////////////////// + +/// Register the needed events + onload=function() { + /// Adjust the form on load + disablePopupHeads(); + } + +/** + * This function disables some elements from the fields/keys/indexes drop down + */ +function disablePopupHeads() { + var popup = document.getElementById("menufieldkeyindex"); + var i = popup.length; + while (i--) { + option = popup[i]; + if (option.value == "fieldshead" || option.value == "keyshead" || option.value == "indexeshead") { + popup[i].disabled = true; + } + } +}