From f802a79b7095c5bfb3255f94a355a6411c790ef2 Mon Sep 17 00:00:00 2001 From: stronk7 <stronk7> Date: Thu, 28 May 2009 18:41:02 +0000 Subject: [PATCH] MDL-19304 xmldb editor - fixed default action for tables & statements --- .../edit_xml_file/edit_xml_file.class.php | 78 +++++++++++-------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/admin/xmldb/actions/edit_xml_file/edit_xml_file.class.php b/admin/xmldb/actions/edit_xml_file/edit_xml_file.class.php index 74b6608bf9..99d4578c1d 100644 --- a/admin/xmldb/actions/edit_xml_file/edit_xml_file.class.php +++ b/admin/xmldb/actions/edit_xml_file/edit_xml_file.class.php @@ -1,31 +1,36 @@ -<?php // $Id$ - -/////////////////////////////////////////////////////////////////////////// -// // -// NOTICE OF COPYRIGHT // -// // -// Moodle - Modular Object-Oriented Dynamic Learning Environment // -// http://moodle.com // -// // -// Copyright (C) 1999 onwards 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 // -// // -/////////////////////////////////////////////////////////////////////////// - -/// This class will edit one loaded XML file +<?php +// This file is part of Moodle - http://moodle.org/ +// +// Moodle 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 3 of the License, or +// (at your option) any later version. +// +// Moodle 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. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. + +/** + * @package xmldb-editor + * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * This class will edit one loaded XML file + * + * Main page to start editing one XML file. From here it's possible to access + * to tables/statements edition plus PHP code generation and other utilities + * + * @package xmldb-editor + * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class edit_xml_file extends XMLDBAction { /** @@ -53,7 +58,8 @@ class edit_xml_file extends XMLDBAction { 'viewsqlcode' => 'xmldb', 'viewphpcode' => 'xmldb', 'reserved' => 'xmldb', - 'backtomainview' => 'xmldb' + 'backtomainview' => 'xmldb', + 'viewxml' => 'xmldb' )); } @@ -144,9 +150,9 @@ class edit_xml_file extends XMLDBAction { $b .= ' <a href="index.php?action=view_structure_php&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['viewphpcode'] . ']</a>'; $b .= '</p>'; $o .= $b; + /// Join all the reserved words into one big array /// Calculate list of available SQL generators - require_once("$CFG->libdir/ddl/sql_generator.php"); $reserved_words = sql_generator::getAllReservedWords(); @@ -157,6 +163,8 @@ class edit_xml_file extends XMLDBAction { $o .= '<table id="listtables" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">'; $row = 0; foreach ($tables as $table) { + /// The table name (link to edit table) + $t = '<a href="index.php?action=edit_table&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">' . $table->getName() . '</a>'; /// Calculate buttons $b = '</td><td class="button cell">'; /// The edit button @@ -184,13 +192,16 @@ class edit_xml_file extends XMLDBAction { } else { $b .= '[' . $this->str['delete'] . ']'; } + $b .= '</td><td class="button cell">'; + /// The view xml button + $b .= '<a href="index.php?action=view_table_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&table=' . $table->getName() . '&select=edited">[' . $this->str['viewxml'] . ']</a>'; /// Detect if the table name is a reserved word if (array_key_exists($table->getName(), $reserved_words)) { $b .= ' <a href="index.php?action=view_reserved_words"><span class="error">' . $this->str['reserved'] . '</span></a>'; } $b .= '</td>'; /// Print table row - $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_table_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&table=' . $table->getName() . '&select=edited">' . $table->getName() . '</a>' . $b . '</tr>'; + $o .= '<tr class="r' . $row . '"><td class="table cell">' . $t . $b . '</tr>'; $row = ($row + 1) % 2; } $o .= '</table>'; @@ -202,6 +213,8 @@ class edit_xml_file extends XMLDBAction { $o .= '<table id="liststatements" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">'; $row = 0; foreach ($statements as $statement) { + /// The statement name (link to edit statement) + $s = '<a href="index.php?action=edit_statement&statement=' . $statement->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">' . $statement->getName() . '</a>'; /// Calculate buttons $b = '</td><td class="button cell">'; /// The edit button @@ -223,9 +236,12 @@ class edit_xml_file extends XMLDBAction { $b .= '</td><td class="button cell">'; /// The delete button $b .= '<a href="index.php?action=delete_statement&statement=' . $statement->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>'; + $b .= '</td><td class="button cell">'; + /// The view xml button + $b .= '<a href="index.php?action=view_statement_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&statement=' . $statement->getName() . '&select=edited">[' . $this->str['viewxml'] . ']</a>'; $b .= '</td>'; /// Print statement row - $o .= '<tr class="r' . $row . '"><td class="statement cell"><a href="index.php?action=view_statement_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&statement=' . $statement->getName() . '&select=edited">' . $statement->getName() . '</a>' . $b . '</tr>'; + $o .= '<tr class="r' . $row . '"><td class="statement cell">' . $s . $b . '</tr>'; $row = ($row + 1) % 2; } $o .= '</table>'; -- 2.39.5