libdir . '/xmlize.php');
/// Add all the available SQL generators
$generators = get_list_of_plugins('lib/xmldb/classes/generators');
foreach($generators as $generator) {
require_once ('../../lib/xmldb/classes/generators/' . $generator . '/' . $generator . '.class.php');
}
/// Handle session data
global $XMLDB;
/// The global SESSION object where everything will happen
if (!isset($SESSION->xmldb)) {
$SESSION->xmldb = new stdClass;
}
$XMLDB =& $SESSION->xmldb;
/// Some previous checks
if (! $site = get_site()) {
redirect("$CFG->wwwroot/$CFG->admin/index.php");
}
require_login();
if (!isadmin()) {
error('You must be an administrator to use this page.');
}
/// Fetch all the needed strings
$stradministration = get_string('administration');
/// Body of the script, based on action, we delegate the work
$action = optional_param ('action', 'main_view', PARAM_ALPHAEXT);
/// Get the action path and invoke it
$actionsroot = "$CFG->dirroot/$CFG->admin/xmldb/actions";
$actionclass = $action . '.class.php';
$actionpath = "$actionsroot/$action/$actionclass";
/// Load and invoke the proper action
if (file_exists($actionpath) && is_readable($actionpath)) {
require_once($actionpath);
if ($xmldb_action = new $action) {
//Invoke it
$result = $xmldb_action->invoke();
if ($result) {
/// Based on getDoesGenerate()
switch ($xmldb_action->getDoesGenerate()) {
case ACTION_GENERATE_HTML:
/// Define $CFG->javascript to use our custom javascripts.
/// Save the original one to add it from ours. Global too! :-(
global $standard_javascript;
$standard_javascript = $CFG->javascript; // Save original javascript file
$CFG->javascript = $CFG->dirroot.'/admin/xmldb/javascript.php'; //Use our custom javascript code
/// Go with standard header
print_header("$site->shortname: XMLDB",
"$site->fullname",
"$stradministration -> XMLDB");
print_heading($xmldb_action->getTitle());
echo $xmldb_action->getOutput();
print_footer();
break;
case ACTION_GENERATE_XML:
header('Content-type: application/xhtml+xml');
echo $xmldb_action->getOutput();
break;
}
} else {
error($xmldb_action->getError());
}
} else {
error ("Error: cannot instantiate class (actions/$action/$actionclass)");
}
} else {
error ("Error: wrong action specified ($action)");
}
if ($xmldb_action->getDoesGenerate() != ACTION_GENERATE_XML) {
if ($CFG->debug > 7) {
///print_object($XMLDB);
}
}
?>