. /** * @package tool * @subpackage xmldb * @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 show all the actions available under the XMLDB editor interface * * From here, files can be created, edited, saved and deleted, plus some * extra utilities like displaying docs, xml info and performing various consistency tests * * @package tool * @subpackage xmldb * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class main_view extends XMLDBAction { /** * Init method, every subclass will have its own */ function init() { parent::init(); // Set own custom attributes $this->sesskey_protected = false; // This action doesn't need sesskey protection // Get needed strings $this->loadStrings(array( 'load' => 'tool_xmldb', 'create' => 'tool_xmldb', 'edit' => 'tool_xmldb', 'save' => 'tool_xmldb', 'revert' => 'tool_xmldb', 'unload' => 'tool_xmldb', 'delete' => 'tool_xmldb', 'reservedwords' => 'tool_xmldb', 'gotolastused' => 'tool_xmldb', 'checkindexes' => 'tool_xmldb', 'checkdefaults' => 'tool_xmldb', 'checkforeignkeys' => 'tool_xmldb', 'checkbigints' => 'tool_xmldb', 'checkoraclesemantics' => 'tool_xmldb', 'doc' => 'tool_xmldb', 'viewxml' => 'tool_xmldb', 'pendingchangescannotbesavedreload' => 'tool_xmldb' )); } /** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; // Set own core attributes $this->does_generate = ACTION_GENERATE_HTML; // These are always here global $CFG, $XMLDB, $SESSION, $DB; // Get lastused $o = ''; if (isset($SESSION->lastused)) { if ($lastused = $SESSION->lastused) { // Print link $o .= '
' . $this->str['gotolastused'] . '
'; } } else { $lastused = NULL; } // Calculate the buttons $b = ' '; // Send buttons to output $o .= $b; // Do the job // Get the list of DB directories $result = $this->launch('get_db_directories'); // Display list of DB directories if everything is ok if ($result && !empty($XMLDB->dbdirs)) { $o .= ''; // The create button if ($dbdir->path_exists && !file_exists($key . '/install.xml') && is_writeable($key)) { $b .= '[' . $this->str['create'] . ']'; } else { $b .= '[' . $this->str['create'] . ']'; } $b .= ' | '; // The load button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && empty($dbdir->xml_loaded)) { $b .= '[' . $this->str['load'] . ']'; } else { $b .= '[' . $this->str['load'] . ']'; } $b .= ' | '; // The edit button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && is_readable($key) && !empty($dbdir->xml_loaded)) { $b .= '[' . $this->str['edit'] . ']'; } else { $b .= '[' . $this->str['edit'] . ']'; } $b .= ' | '; // The save button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_writeable($key . '/install.xml') && is_writeable($key) && !empty($dbdir->xml_loaded) && !empty($dbdir->xml_changed)) { $b .= '[' . $this->str['save'] . ']'; // Check if the file has been manually edited while being modified in the editor if ($dbdir->filemtime != filemtime($key . '/install.xml')) { // File manually modified. Add to errors. if ($structure =& $dbdir->xml_file->getStructure()) { $structure->errormsg = 'Warning: File locally modified while using the XMLDB Editor. Saving will overwrite local changes'; } } } else { $b .= '[' . $this->str['save'] . ']'; } $b .= ' | '; // The document button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && is_readable($key)) { $b .= '[' . $this->str['doc'] . ']'; } else { $b .= '[' . $this->str['doc'] . ']'; } $b .= ' | '; // The view xml button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml')) { $b .= '[' . $this->str['viewxml'] . ']'; } else { $b .= '[' . $this->str['viewxml'] . ']'; } $b .= ' | '; // The revert button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && is_writeable($key) && !empty($dbdir->xml_loaded) && !empty($dbdir->xml_changed)) { $b .= '[' . $this->str['revert'] . ']'; } else { $b .= '[' . $this->str['revert'] . ']'; } $b .= ' | '; // The unload button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && !empty($dbdir->xml_loaded) && empty($dbdir->xml_changed)) { $b .= '[' . $this->str['unload'] . ']'; } else { $b .= '[' . $this->str['unload'] . ']'; } $b .= ' | '; // The delete button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && is_writeable($key) && empty($dbdir->xml_loaded)) { $b .= '[' . $this->str['delete'] . ']'; } else { $b .= '[' . $this->str['delete'] . ']'; } $b .= ' | '; // include the higlight if ($hithis) { $o .= '|
' . $f . ' | ' . $b . '|||||||||
' . $f . ' | ' . $b . '|||||||||
' . implode (', ', $errors) . ' | |||||||||
' . implode (', ', $errors) . ' | |||||||||
'; } else { $o .= ' | |||||||||
'; } $o .= 'Table ' . $table->getName() . ', field ' . $field->getName() . ' has ENUM info'; if (!empty($field->hasenumsenabled)) { $o .= ' that seems to be active (true). ENUMs support has been dropped in Moodle 2.0, ' . ' the XMLDB Editor will delete any ENUM reference next time you save this file' . ' and you MUST provide one upgrade block in your code to drop them from DB. See' . ' ' . ' Moodle Docs for more info and examples.'; } else { $o .= ' that seem to be inactive (false). ENUMs support has been dropped in Moodle 2.0,' . ' the XMLDB Editor will, simply, delete any ENUM reference next time you save this file.' . ' No further action is necessary.'; } $o .= ' | |||||||||
'; } else { $o .= ' | |||||||||
'; } $o .= $this->str['pendingchangescannotbesavedreload']; $o .= ' |