From: Eloy Lafuente Date: Thu, 5 Nov 2009 15:40:26 +0000 (+0000) Subject: MDL-20749 correct error output - sentences/tables checkers fixed. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fb9514e361b6aa161fed78c63e53e20950582995;p=moodle.git MDL-20749 correct error output - sentences/tables checkers fixed. --- diff --git a/admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php b/admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php index a0354db808..8a284ee111 100644 --- a/admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php +++ b/admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php @@ -1,31 +1,34 @@ . + +/** + * @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 sentence 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_sentence_save extends XMLDBAction { /** @@ -42,6 +45,7 @@ class edit_sentence_save extends XMLDBAction { 'missingfieldsinsentence' => 'xmldb', 'missingvaluesinsentence' => 'xmldb', 'wrongnumberoffieldsorvalues' => 'xmldb', + 'back' => 'xmldb', 'administration' => '' )); } @@ -57,8 +61,8 @@ class edit_sentence_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; @@ -119,16 +123,12 @@ class edit_sentence_save extends XMLDBAction { if (!empty($errors)) { /// 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 ('

' .implode(', ', $errors) . '

-

' . s($sentence) . '

', - 'index.php?action=edit_sentence&sentence=' .$sentenceparam . '&statement=' . urlencode($statementparam) . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); - die; /// re-die :-P + $o = '

' .implode(', ', $errors) . '

+

' . s($sentence) . '

'; + $o.= '[' . $this->str['back'] . ']'; + $this->output = $o; } /// Continue if we aren't under errors diff --git a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php index 69973fadc6..4e0c6c0c86 100644 --- a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php +++ b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php @@ -43,6 +43,7 @@ class edit_table_save extends XMLDBAction { 'tablenameempty' => 'xmldb', 'incorrecttablename' => 'xmldb', 'duplicatetablename' => 'xmldb', + 'back' => 'xmldb', 'administration' => '' )); } @@ -58,8 +59,8 @@ class edit_table_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, $PAGE, $OUTPUT; @@ -104,58 +105,55 @@ class edit_table_save extends XMLDBAction { if (!empty($errors)) { $temptable = new xmldb_table($name); /// 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 ('

' .implode(', ', $errors) . '

-

' . $temptable->readableInfo() . '

', - 'index.php?action=edit_table&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); - die; /// re-die :-P - } - - /// If there is one name change, do it, changing the prev and next - /// atributes of the adjacent tables - if ($tableparam != $name) { - $table->setName($name); - if ($table->getPrevious()) { - $prev =& $structure->getTable($table->getPrevious()); - $prev->setNext($name); - $prev->setChanged(true); - } - if ($table->getNext()) { - $next =& $structure->getTable($table->getNext()); - $next->setPrevious($name); - $next->setChanged(true); + $o = '

' .implode(', ', $errors) . '

+

' . $temptable->getName() . '

'; + $o.= '[' . $this->str['back'] . ']'; + $this->output = $o; + + + /// Continue if we aren't under errors + } else if (empty($errors)) { + /// If there is one name change, do it, changing the prev and next + /// atributes of the adjacent tables + if ($tableparam != $name) { + $table->setName($name); + if ($table->getPrevious()) { + $prev =& $structure->getTable($table->getPrevious()); + $prev->setNext($name); + $prev->setChanged(true); + } + if ($table->getNext()) { + $next =& $structure->getTable($table->getNext()); + $next->setPrevious($name); + $next->setChanged(true); + } + /// Table has changed + $table->setChanged(true); } - /// Table has changed - $table->setChanged(true); - } - /// Set comment - if ($table->getComment() != $comment) { - $table->setComment($comment); - /// Table has changed - $table->setChanged(true); - } + /// Set comment + if ($table->getComment() != $comment) { + $table->setComment($comment); + /// Table has changed + $table->setChanged(true); + } - /// Recalculate the hash - $structure->calculateHash(true); + /// Recalculate the hash + $structure->calculateHash(true); - /// If the hash has changed from the original one, change the version - /// and mark the structure as changed - $origstructure =& $dbdir->xml_file->getStructure(); - if ($structure->getHash() != $origstructure->getHash()) { - $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); - $structure->setChanged(true); - } + /// If the hash has changed from the original one, change the version + /// and mark the structure as changed + $origstructure =& $dbdir->xml_file->getStructure(); + if ($structure->getHash() != $origstructure->getHash()) { + $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); + $structure->setChanged(true); + } - /// Launch postaction if exists (leave this here!) - if ($this->getPostAction() && $result) { - return $this->launch($this->getPostAction()); + /// Launch postaction if exists (leave this here!) + if ($this->getPostAction() && $result) { + return $this->launch($this->getPostAction()); + } } /// Return ok if arrived here