]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20749 fixed the class edit_field_save to output errors properly. Will
authorEloy Lafuente <stronk7@moodle.org>
Thu, 5 Nov 2009 13:38:02 +0000 (13:38 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Thu, 5 Nov 2009 13:38:02 +0000 (13:38 +0000)
be beutifying the output a bit later

admin/xmldb/actions/edit_field_save/edit_field_save.class.php
lang/en_utf8/xmldb.php

index 21db40d1d6fc3f5a62211a0e285ba4f4f996ca51..88bda80db898f0e4b8f313d9c3185d52a5c4a856 100644 (file)
@@ -1,31 +1,34 @@
 <?php
 
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// 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 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/>.
 
-/// This class will save the changes performed to one field
+/**
+ * @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 verifies all the data introduced when editing a field for correctness,
+ * peforming changes / displaying errors depending of the results.
+ *
+ * @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_field_save extends XMLDBAction {
 
     /**
@@ -50,6 +53,7 @@ class edit_field_save extends XMLDBAction {
             'numberincorrectdecimals' => 'xmldb',
             'floatincorrectdecimals' => 'xmldb',
             'defaultincorrect' => 'xmldb',
+            'back' => 'xmldb',
             'administration' => ''
         ));
     }
@@ -65,8 +69,8 @@ class edit_field_save extends XMLDBAction {
         $result = true;
 
     /// Set own core attributes
-        $this->does_generate = ACTION_NONE;
-        //$this->does_generate = ACTION_GENERATE_HTML;
+        //$this->does_generate = ACTION_NONE;
+        $this->does_generate = ACTION_GENERATE_HTML;
 
     /// These are always here
         global $CFG, $XMLDB;
@@ -231,17 +235,11 @@ class edit_field_save extends XMLDBAction {
             $tempfield->setSequence($sequence);
             $tempfield->setDefault($default);
         /// Prepare the output
-            $site = get_site();
-            $PAGE->navbar->add($this->str['administration'], '../index.php');
-            $PAGE->navbar->add('XMLDB', 'index.php');
-            $PAGE->set_title("$site->shortname: XMLDB");
-            $PAGE->set_heading($site->fullname);
-            echo $OUTPUT->header();
-            notice ('<p>' .implode(', ', $errors) . '</p>
-                     <p>' . $tempfield->readableInfo() . '</p>',
-                    'index.php?action=edit_field&amp;field=' .$field->getName() . '&amp;table=' . $table->getName()
-                    . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
-            die; /// re-die :-P
+            $o = '<p>' .implode(', ', $errors) . '</p>
+                  <p>' . $name . ': ' . $tempfield->readableInfo() . '</p>';
+            $o.= '<a href="index.php?action=edit_field&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() .
+                 '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
+            $this->output = $o;
         }
 
     /// Continue if we aren't under errors
index 57b467217078b2f7105b54e90d3888703bcb20b9..cda13ec468c77c1f9336bc9a42f8d665535b4227 100644 (file)
@@ -61,6 +61,7 @@ $string['duplicatefieldname'] = 'Another field with that name exists';
 $string['duplicatekeyname'] = 'Another key with that name exists';
 $string['edit'] = 'Edit';
 $string['edit_field'] = 'Edit Field';
+$string['edit_field_save'] = 'Save Field';
 $string['edit_index'] = 'Edit Index';
 $string['edit_key'] = 'Edit Key';
 $string['edit_sentence'] = 'Edit Sentence';