芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/admin/tool/xmldb/actions/view_table_sql/view_table_sql.class.php
. /** * @package tool_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 the SQL generated for the selected RDBMS for * one table * * @package tool_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 view_table_sql 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( 'selectdb' => 'tool_xmldb', 'back' => '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, $DB; $dbman = $DB->get_manager(); // Do the job, setting result as needed // Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . $dirpath; // Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir = $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir = $XMLDB->editeddirs[$dirpath]; $structure = $editeddir->xml_file->getStructure(); } // Get parameters $tableparam = required_param('table', PARAM_PATH); if (!$table = $structure->getTable($tableparam)) { $this->errormsg = 'Wrong table specified: ' . $tableparam; return false; } // The back to edit table button $b = '
'; $b .= '
[' . $this->str['back'] . ']
'; $b .= '
'; $o = $b; $o.= '
'; $o .= '
'; // Get an array of statements if ($starr = $DB->get_manager()->generator->getCreateTableSQL($table)) { $starr = $dbman->generator->getEndedStatements($starr); $sqltext = ''; foreach ($starr as $st) { $sqltext .= s($st) . "\n\n"; } $sqltext = trim($sqltext); $o.= $sqltext; } $o.= '</textarea>
'; $o.= '
'; $this->output = $o; // Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } // Return ok if arrived here return $result; } }