From d5810e1d725de0b57693ae9f3a17a5ba44c979a4 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 28 May 2009 23:25:27 +0000 Subject: [PATCH] MDL-9176 xmldb editor - now it's possible to save from edit file page --- .../edit_xml_file/edit_xml_file.class.php | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 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 99d4578c1d..59b4d59fb7 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 @@ -59,7 +59,10 @@ class edit_xml_file extends XMLDBAction { 'viewphpcode' => 'xmldb', 'reserved' => 'xmldb', 'backtomainview' => 'xmldb', - 'viewxml' => 'xmldb' + 'viewxml' => 'xmldb', + 'pendingchanges' => 'xmldb', + 'pendingchangescannotbesaved' => 'xmldb', + 'save' => 'xmldb' )); } @@ -105,9 +108,10 @@ class edit_xml_file extends XMLDBAction { /// Get it $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); + /// Add the main form $o = '
'; - $o .= '
'; + $o.= '
'; $o.= ' '; $o.= ' '; $o.= ' '; @@ -120,6 +124,17 @@ class edit_xml_file extends XMLDBAction { $o.= '  '; $o.= ' '; $o.= '
'; + /// Calculate the pending changes / save message + $e = ''; + $cansavenow = false; + if ($structure->hasChanged()) { + if (!is_writeable($dirpath . '/install.xml') || !is_writeable($dirpath)) { + $e .= '

' . $this->str['pendingchangescannotbesaved'] . '

'; + } else { + $e .= '

' . $this->str['pendingchanges'] . '

'; + $cansavenow = true; + } + } /// Calculate the buttons $b = '

'; /// The view original XML button @@ -140,16 +155,22 @@ class edit_xml_file extends XMLDBAction { } /// The new statement button $b .= ' [' . $this->str['newstatement'] . ']'; - /// The back to main menu button - $b .= ' [' . $this->str['backtomainview'] . ']'; $b .= '

'; $b .= '

'; + /// The view sql code button $b .= '[' .$this->str['viewsqlcode'] . ']'; /// The view php code button $b .= ' [' . $this->str['viewphpcode'] . ']'; + /// The save button (if possible) + if ($cansavenow) { + $b .= ' [' . $this->str['save'] . ']'; + } + + /// The back to main menu button + $b .= ' [' . $this->str['backtomainview'] . ']'; $b .= '

'; - $o .= $b; + $o .= $e . $b; /// Join all the reserved words into one big array /// Calculate list of available SQL generators -- 2.39.5