// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
continue;
}
/// Load the XML file
- $xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
+ $xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
/// Only if the file exists
if (!$xmldb_file->fileExists()) {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
continue;
}
/// Load the XML file
- $xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
+ $xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
/// Only if the file exists
if (!$xmldb_file->fileExists()) {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
continue;
}
/// Load the XML file
- $xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
+ $xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
/// Only if the file exists
if (!$xmldb_file->fileExists()) {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
if (!$dbdir->path_exists) {
return false;
}
- $xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
+ $xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
///Set the XML DTD and schema
$xmldb_file->setDTD($CFG->dirroot . '/lib/xmldb/xmldb.dtd');
$xmldb_file->setSchema($CFG->dirroot . '/lib/xmldb/xmldb.xsd');
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
if (!$dbdir->path_exists) {
continue;
}
- $xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
+ $xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
/// Set dbdir as necessary
if ($xmldb_file->fileExists()) {
$dbdir->xml_exists = true;
* This function will generate all the PHP code needed to
* create one table using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table code to be created
* @return string PHP code to be used to create the table
*/
* This function will generate all the PHP code needed to
* drop one table using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table code to be dropped
* @return string PHP code to be used to drop the table
*/
* This function will generate all the PHP code needed to
* rename one table using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table code to be renamed
* @return string PHP code to be used to rename the table
*/
* implement the upgrade_xxxx_savepoint() php calls in
* upgrade code generated from the editor
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @return string PHP code to be used to stabilish a savepoint
*/
function upgrade_savepoint_php ($structure) {
* This function will generate all the PHP code needed to
* create one field using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to be created
* @return string PHP code to be used to create the field
* This function will generate all the PHP code needed to
* drop one field using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to be dropped
* @return string PHP code to be used to drop the field
* This function will generate all the PHP code needed to
* rename one field using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to be renamed
* @return string PHP code to be used to rename the field
* float to char
* char to float
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to change precision
*/
* This function will generate all the PHP code needed to
* change the precision of one field using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to change precision
*/
* This function will generate all the PHP code needed to
* change the unsigned/signed of one field using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to change unsigned/signed
*/
* This function will generate all the PHP code needed to
* change the nullability of one field using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to change null/not null
*/
* change the enum values (check constraint) of one field
* using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to change its enum
*/
* This function will generate all the PHP code needed to
* change the default of one field using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to change null/not null
*/
* This function will generate all the PHP code needed to
* create one key using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string key key name to be created
* @return string PHP code to be used to create the key
* This function will generate all the PHP code needed to
* drop one key using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string key key name to be dropped
* @return string PHP code to be used to drop the key
* This function will generate all the PHP code needed to
* rename one key using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string key key name to be renamed
* @return string PHP code to be used to rename the key
* This function will generate all the PHP code needed to
* create one index using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string index index name to be created
* @return string PHP code to be used to create the index
* This function will generate all the PHP code needed to
* drop one index using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string index index name to be dropped
* @return string PHP code to be used to drop the index
* This function will generate all the PHP code needed to
* rename one index using XMLDB objects and functions
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string index index name to be renamed
* @return string PHP code to be used to rename the index
* implement the upgrade_xxxx_savepoint() php calls in
* upgrade code generated from the editor
*
- * @param XMLDBStructure structure object containing all the info
+ * @param xmldb_structure structure object containing all the info
* @return string PHP code to be used to stabilish a savepoint
*/
function upgrade_savepoint_php ($structure) {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// all the actions supported will be launched.
/// Add required XMLDB constants
- require_once('../../lib/xmldb/XMLDBConstants.php');
+ require_once('../../lib/xmldb/xmldb_constants.php');
/// Add required XMLDB action classes
require_once('actions/XMLDBAction.class.php');
/// Add required XMLDB DB classes
- require_once('../../lib/xmldb/XMLDBObject.class.php');
- require_once('../../lib/xmldb/XMLDBFile.class.php');
- require_once('../../lib/xmldb/XMLDBStructure.class.php');
+ require_once('../../lib/xmldb/xmldb_object.php');
+ require_once('../../lib/xmldb/xmldb_file.php');
+ require_once('../../lib/xmldb/xmldb_structure.php');
require_once('../../lib/xmldb/XMLDBTable.class.php');
require_once('../../lib/xmldb/XMLDBField.class.php');
require_once('../../lib/xmldb/XMLDBKey.class.php');
*/
public function delete_tables_from_xmldb_file($file, $feedback=true ) {
- $xmldb_file = new XMLDBFile($file);
+ $xmldb_file = new xmldb_file($file);
if (!$xmldb_file->fileExists()) {
return false;
* @return boolean (true on success, false on error)
*/
public function install_from_xmldb_file($file, $continue=true, $feedback=true) {
- $xmldb_file = new XMLDBFile($file);
+ $xmldb_file = new xmldb_file($file);
if (!$xmldb_file->fileExists()) {
return false;
if (isset($matches[1])) {
$part = $matches[1];
/// Convert the comma separated string to an array
- $arr = XMLDBObject::comma2array($part);
+ $arr = xmldb_object::comma2array($part);
if ($arr) {
$value = $this->getConcatSQL($arr);
}
// For further documentation, visit http://docs.moodle.org/en/DDL_functions
/// Add required XMLDB constants
-require_once($CFG->libdir.'/xmldb/XMLDBConstants.php');
+require_once($CFG->libdir.'/xmldb/xmldb_constants.php');
/// Add required XMLDB DB classes
-require_once($CFG->libdir.'/xmldb/XMLDBObject.class.php');
-require_once($CFG->libdir.'/xmldb/XMLDBFile.class.php');
-require_once($CFG->libdir.'/xmldb/XMLDBStructure.class.php');
+require_once($CFG->libdir.'/xmldb/xmldb_object.php');
+require_once($CFG->libdir.'/xmldb/xmldb_file.php');
+require_once($CFG->libdir.'/xmldb/xmldb_structure.php');
require_once($CFG->libdir.'/xmldb/XMLDBTable.class.php');
require_once($CFG->libdir.'/xmldb/XMLDBField.class.php');
require_once($CFG->libdir.'/xmldb/XMLDBKey.class.php');
foreach ($dbdirs as $dbdir) {
$file = $dbdir.'/install.xml';
- $xmldb_file = new XMLDBFile($file);
+ $xmldb_file = new xmldb_file($file);
if (!$xmldb_file->fileExists()) {
continue;
}
-?>
\ No newline at end of file
+?>
/// This class represent one XMLDB Field
-class XMLDBField extends XMLDBObject {
+class XMLDBField extends xmldb_object {
var $type;
var $length;
* Creates one new XMLDBField
*/
function XMLDBField($name) {
- parent::XMLDBObject($name);
+ parent::__construct($name);
$this->type = NULL;
$this->length = NULL;
$this->unsigned = true;
/// This class represent one XMLDB Index
-class XMLDBIndex extends XMLDBObject {
+class XMLDBIndex extends xmldb_object {
var $unique;
var $fields;
* Creates one new XMLDBIndex
*/
function XMLDBIndex($name) {
- parent::XMLDBObject($name);
+ parent::__construct($name);
$this->unique = false;
$this->fields = array();
}
/// This class represent one XMLDB Key
-class XMLDBKey extends XMLDBObject {
+class XMLDBKey extends xmldb_object {
var $type;
var $fields;
* Creates one new XMLDBKey
*/
function XMLDBKey($name) {
- parent::XMLDBObject($name);
+ parent::__construct($name);
$this->type = NULL;
$this->fields = array();
$this->reftable = NULL;
/// (a group of SQL arbitrary sentences)
/// (only INSERT is allowed for now)
-class XMLDBStatement extends XMLDBObject {
+class XMLDBStatement extends xmldb_object {
var $table; // Table we are handling
var $type; // XMLDB_STATEMENT_TYPE
* Creates one new XMLDBStatement
*/
function XMLDBStatement($name) {
- parent::XMLDBObject($name);
+ parent::__construct($name);
$this->table = NULL;
$this->type = XMLDB_STATEMENT_INCORRECT;
$this->sentences = array();
/// This class represent one XMLDB table
-class XMLDBTable extends XMLDBObject {
+class XMLDBTable extends xmldb_object {
var $fields;
var $keys;
* Creates one new XMLDBTable
*/
function XMLDBTable($name) {
- parent::XMLDBObject($name);
+ parent::__construct($name);
$this->fields = array();
$this->keys = array();
$this->indexes = array();
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// This class represents an entire XMLDB file
-class XMLDBFile extends XMLDBObject {
+class xmldb_file extends xmldb_object {
var $path;
var $schema;
var $xmldb_structure;
/**
- * Constructor of the XMLDBFile
+ * Constructor of the xmldb_file
*/
- function XMLDBFile ($path) {
- parent::XMLDBObject($path);
+ function __construct ($path) {
+ parent::__construct($path);
$this->path = $path;
$this->xmldb_structure = NULL;
}
/// Prepare errors
if (!empty($errors)) {
/// Create one structure to store errors
- $structure = new XMLDBStructure($this->path);
+ $structure = new xmldb_structure($this->path);
/// Add errors to structure
$structure->errormsg = 'XML Error: ';
foreach ($errors as $error) {
$parser = xml_parser_create();
if (!xml_parse($parser, file_get_contents($this->path))) {
/// Create one structure to store errors
- $structure = new XMLDBStructure($this->path);
+ $structure = new xmldb_structure($this->path);
/// Add error to structure
$structure->errormsg = sprintf("XML Error: %s at line %d",
xml_error_string(xml_get_error_code($parser)),
/// Load everything to a big array
$xmlarr = xmlize(file_get_contents($this->path));
/// Convert array to xmldb structure
- $this->xmldb_structure = $this->arr2XMLDBStructure($xmlarr);
+ $this->xmldb_structure = $this->arr2xmldb_structure($xmlarr);
/// Analize results
if ($this->xmldb_structure->isLoaded()) {
$this->loaded = true;
}
/**
- * This function takes an xmlized array and put it into one XMLDBStructure
+ * This function takes an xmlized array and put it into one xmldb_structure
*/
- function arr2XMLDBStructure ($xmlarr) {
- $structure = new XMLDBStructure($this->path);
- $structure->arr2XMLDBStructure($xmlarr);
+ function arr2xmldb_structure ($xmlarr) {
+ $structure = new xmldb_structure($this->path);
+ $structure->arr2xmldb_structure($xmlarr);
return $structure;
}
}
/**
- * This function saves the whole XMLDBStructure to its file
+ * This function saves the whole xmldb_structure to its file
*/
function saveXMLFile() {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// This class represent the XMLDB base class where all the common piezes
/// are defined
-class XMLDBObject {
+class xmldb_object {
var $name;
var $comment;
var $errormsg;
/**
- * Creates one new XMLDBObject
+ * Creates one new xmldb_object
*/
- function XMLDBObject($name) {
+ function __construct($name) {
$this->name = $name;
$this->comment = NULL;
$this->previous = NULL;
}
/**
- * This function returns true/false, if the XMLDBObject has been loaded
+ * This function returns true/false, if the xmldb_object has been loaded
*/
function isLoaded() {
return $this->loaded;
}
/**
- * This function returns true/false, if the XMLDBObject has changed
+ * This function returns true/false, if the xmldb_object has changed
*/
function hasChanged() {
return $this->changed;
}
/**
- * This function returns the comment of one XMLDBObject
+ * This function returns the comment of one xmldb_object
*/
function getComment() {
return $this->comment;
}
/**
- * This function returns the hash of one XMLDBObject
+ * This function returns the hash of one xmldb_object
*/
function getHash() {
return $this->hash;
}
/**
- * This function will return the name of the previous XMLDBObject
+ * This function will return the name of the previous xmldb_object
*/
function getPrevious() {
return $this->previous;
}
/**
- * This function will return the name of the next XMLDBObject
+ * This function will return the name of the next xmldb_object
*/
function getNext() {
return $this->next;
}
/**
- * This function will return the name of the XMLDBObject
+ * This function will return the name of the xmldb_object
*/
function getName() {
return $this->name;
}
/**
- * This function will set the comment of the XMLDB object
+ * This function will set the comment of the xmldb_object
*/
function setComment($comment) {
$this->comment = $comment;
}
/**
- * This function will set the previous of the XMLDB object
+ * This function will set the previous of the xmldb_object
*/
function setPrevious($previous) {
$this->previous = $previous;
}
/**
- * This function will set the next of the XMLDB object
+ * This function will set the next of the xmldb_object
*/
function setNext($next) {
$this->next = $next;
}
/**
- * This function will set the hash of the XMLDB object
+ * This function will set the hash of the xmldb_object
*/
function setHash($hash) {
$this->hash = $hash;
}
/**
- * This function will set the loaded field of the XMLDB object
+ * This function will set the loaded field of the xmldb_object
*/
function setLoaded($loaded = true) {
$this->loaded = $loaded;
}
/**
- * This function will set the changed field of the XMLDB object
+ * This function will set the changed field of the xmldb_object
*/
function setChanged($changed = true) {
$this->changed = $changed;
}
/**
- * This function will set the name field of the XMLDB object
+ * This function will set the name field of the xmldb_object
*/
function setName($name) {
$this->name = $name;
}
/**
- * This function will display a readable info about the XMLDBObject
+ * This function will display a readable info about the xmldb_object
* (should be implemented inside each XMLDBxxx object)
*/
function readableInfo() {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// This class represent one XMLDB structure
-class XMLDBStructure extends XMLDBObject {
+class xmldb_structure extends xmldb_object {
var $path;
var $version;
var $statements;
/**
- * Creates one new XMLDBStructure
+ * Creates one new xmldb_structure
*/
- function XMLDBStructure($name) {
- parent::XMLDBObject($name);
+ function construct($name) {
+ parent::__construct($name);
$this->path = NULL;
$this->version = NULL;
$this->tables = array();
/**
* Load data from XML to the structure
*/
- function arr2XMLDBStructure($xmlarr) {
+ function arr2xmldb_structure($xmlarr) {
global $CFG;
}
/**
- * This function calculate and set the hash of one XMLDBStructure
+ * This function calculate and set the hash of one xmldb_structure
*/
function calculateHash($recursive = false) {
if (!$this->loaded) {
/**
* This function returns the number of uses of one field inside
- * a whole XMLDBStructure. Useful to detect if the field must be
+ * a whole xmldb_structure. Useful to detect if the field must be
* locked. Return false if no uses are found.
*/
function getFieldUses($tablename, $fieldname) {
/**
* This function returns the number of uses of one key inside
- * a whole XMLDBStructure. Useful to detect if the key must be
+ * a whole xmldb_structure. Useful to detect if the key must be
* locked. Return false if no uses are found.
*/
function getKeyUses($tablename, $keyname) {
/**
* This function returns the number of uses of one index inside
- * a whole XMLDBStructure. Useful to detect if the index must be
+ * a whole xmldb_structure. Useful to detect if the index must be
* locked. Return false if no uses are found.
*/
function getIndexUses($tablename, $indexname) {