sesskey_protected = false; // This action doesn't need sesskey protection /// Get needed strings $this->loadStrings(array( 'change' => 'xmldb', 'edit' => 'xmldb', 'up' => 'xmldb', 'down' => 'xmldb', 'delete' => 'xmldb', 'vieworiginal' => 'xmldb', 'viewedited' => 'xmldb', 'tables' => 'xmldb', 'statements' => 'xmldb', 'newtable' => 'xmldb', 'newtablefrommysql' => 'xmldb', 'newstatement' => 'xmldb', 'viewsqlcode' => 'xmldb', 'viewphpcode' => 'xmldb', 'reserved' => 'xmldb', 'backtomainview' => '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_NONE; $this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting $result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dir if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; if ($dbdir) { /// Only if the directory exists and it has been loaded if (!$dbdir->path_exists || !$dbdir->xml_loaded) { return false; } /// Check if the in-memory object exists and create it if (empty($XMLDB->editeddirs)) { $XMLDB->editeddirs = array(); } /// Check if the dir exists and copy it from dbdirs if (!isset($XMLDB->editeddirs[$dirpath])) { $XMLDB->editeddirs[$dirpath] = unserialize(serialize($dbdir)); } /// Get it $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); /// Add the main form $o = '
'; $o .= '
'; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= '
Path:' . s($structure->getPath()) . '
Version:' . s($structure->getVersion()) . '
 
'; $o.= '
'; /// Calculate the buttons $b = '

'; /// The view original XML button $b .= ' [' . $this->str['vieworiginal'] . ']'; /// The view edited XML button if ($structure->hasChanged()) { $b .= ' [' . $this->str['viewedited'] . ']'; } else { $b .= ' [' . $this->str['viewedited'] . ']'; } /// The new table button $b .= ' [' . $this->str['newtable'] . ']'; /// The new from MySQL button if ($CFG->dbfamily == 'mysql') { $b .= ' [' . $this->str['newtablefrommysql'] . ']'; } else { $b .= ' [' . $this->str['newtablefrommysql'] . ']'; } /// 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'] . ']'; $b .= '

'; $o .= $b; /// Join all the reserved words into one big array /// Calculate list of available SQL generators $plugins = get_list_of_plugins('lib/xmldb/classes/generators'); $reserved_words = array(); foreach($plugins as $plugin) { $classname = 'XMLDB' . $plugin; $generator = new $classname(); $reserved_words = array_merge($reserved_words, $generator->getReservedWords()); } sort($reserved_words); $reserved_words = array_unique($reserved_words); /// Add the tables list $tables =& $structure->getTables(); if ($tables) { $o .= '

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

'; $o .= ''; $row = 0; foreach ($tables as $table) { /// Calculate buttons $b = ''; /// Print table row $o .= ''; $row = ($row + 1) % 2; } $o .= '
'; /// The edit button $b .= '[' . $this->str['edit'] . ']'; $b .= ''; /// The up button if ($table->getPrevious()) { $b .= '[' . $this->str['up'] . ']'; } else { $b .= '[' . $this->str['up'] . ']'; } $b .= ''; /// The down button if ($table->getNext()) { $b .= '[' . $this->str['down'] . ']'; } else { $b .= '[' . $this->str['down'] . ']'; } $b .= ''; /// The delete button (if we have more than one and it isn't used) if (count($tables) > 1 && !$structure->getTableUses($table->getName())) { ///!$structure->getTableUses($table->getName())) { $b .= '[' . $this->str['delete'] . ']'; } else { $b .= '[' . $this->str['delete'] . ']'; } /// Detect if the table name is a reserved word if (in_array($table->getName(), $reserved_words)) { $b .= ' ' . $this->str['reserved'] . ''; } $b .= '
' . $table->getName() . '' . $b . '
'; } ///Add the statements list $statements =& $structure->getStatements(); if ($statements) { $o .= '

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

'; $o .= ''; $row = 0; foreach ($statements as $statement) { /// Calculate buttons $b = ''; /// Print statement row $o .= ''; $row = ($row + 1) % 2; } $o .= '
'; /// The edit button $b .= '[' . $this->str['edit'] . ']'; $b .= ''; /// The up button if ($statement->getPrevious()) { $b .= '[' . $this->str['up'] . ']'; } else { $b .= '[' . $this->str['up'] . ']'; } $b .= ''; /// The down button if ($statement->getNext()) { $b .= '[' . $this->str['down'] . ']'; } else { $b .= '[' . $this->str['down'] . ']'; } $b .= ''; /// The delete button $b .= '[' . $this->str['delete'] . ']'; $b .= '
' . $statement->getName() . '' . $b . '
'; } ///Add the back to main $this->output = $o; } } /// Launch postaction if exists (leave this unmodified) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } return $result; } } ?>