MDL-32003 more xmldb phpdocs and PHP4-ism cleanup

This commit is contained in:
Petr Skoda 2012-06-06 11:07:18 +02:00
parent 85d6dd382e
commit aaddfac50c
7 changed files with 177 additions and 181 deletions

View File

@ -92,7 +92,7 @@ class xmldb_field extends xmldb_object {
* @param mixed $default meaningful default o null (or false)
* @param xmldb_object $previous
*/
function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
public function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$this->type = NULL;
$this->length = NULL;
$this->notnull = false;
@ -114,7 +114,7 @@ class xmldb_field extends xmldb_object {
* @param mixed $default meaningful default o null (or false)
* @param xmldb_object $previous
*/
function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
public function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$this->type = $type;
/// Try to split the precision into length and decimals and apply
/// each one as needed
@ -142,7 +142,7 @@ class xmldb_field extends xmldb_object {
* Get the type
* @return int
*/
function getType() {
public function getType() {
return $this->type;
}
@ -150,7 +150,7 @@ class xmldb_field extends xmldb_object {
* Get the length
* @return int
*/
function getLength() {
public function getLength() {
return $this->length;
}
@ -158,7 +158,7 @@ class xmldb_field extends xmldb_object {
* Get the decimals
* @return string
*/
function getDecimals() {
public function getDecimals() {
return $this->decimals;
}
@ -166,7 +166,7 @@ class xmldb_field extends xmldb_object {
* Get the notnull
* @return bool
*/
function getNotNull() {
public function getNotNull() {
return $this->notnull;
}
@ -175,7 +175,7 @@ class xmldb_field extends xmldb_object {
* @deprecated since moodle 2.3
* @return bool
*/
function getUnsigned() {
public function getUnsigned() {
return false;
}
@ -183,7 +183,7 @@ class xmldb_field extends xmldb_object {
* Get the sequence
* @return bool
*/
function getSequence() {
public function getSequence() {
return $this->sequence;
}
@ -191,7 +191,7 @@ class xmldb_field extends xmldb_object {
* Get the default
* @return mixed
*/
function getDefault() {
public function getDefault() {
return $this->default;
}
@ -199,7 +199,7 @@ class xmldb_field extends xmldb_object {
* Set the field type
* @param int $type
*/
function setType($type) {
public function setType($type) {
$this->type = $type;
}
@ -207,7 +207,7 @@ class xmldb_field extends xmldb_object {
* Set the field length
* @param int $length
*/
function setLength($length) {
public function setLength($length) {
$this->length = $length;
}
@ -215,7 +215,7 @@ class xmldb_field extends xmldb_object {
* Set the field decimals
* @param string
*/
function setDecimals($decimals) {
public function setDecimals($decimals) {
$this->decimals = $decimals;
}
@ -224,14 +224,14 @@ class xmldb_field extends xmldb_object {
* @deprecated since moodle 2.3
* @param bool $unsigned
*/
function setUnsigned($unsigned=true) {
public function setUnsigned($unsigned=true) {
}
/**
* Set the field notnull
* @param bool $notnull
*/
function setNotNull($notnull=true) {
public function setNotNull($notnull=true) {
$this->notnull = $notnull;
}
@ -239,7 +239,7 @@ class xmldb_field extends xmldb_object {
* Set the field sequence
* @param bool $sequence
*/
function setSequence($sequence=true) {
public function setSequence($sequence=true) {
$this->sequence = $sequence;
}
@ -247,7 +247,7 @@ class xmldb_field extends xmldb_object {
* Set the field default
* @param mixed $default
*/
function setDefault($default) {
public function setDefault($default) {
// Check, warn and auto-fix '' (empty) defaults for CHAR NOT NULL columns, changing them
// to NULL so XMLDB will apply the proper default
if ($this->type == XMLDB_TYPE_CHAR && $this->notnull && $default === '') {
@ -267,8 +267,9 @@ class xmldb_field extends xmldb_object {
/**
* Load data from XML to the table
* @param array $xmlarr
* @return mixed
*/
function arr2xmldb_field($xmlarr) {
public function arr2xmldb_field($xmlarr) {
$result = true;
@ -415,7 +416,7 @@ class xmldb_field extends xmldb_object {
* @param string $type
* @return int
*/
function getXMLDBFieldType($type) {
public function getXMLDBFieldType($type) {
$result = XMLDB_TYPE_INCORRECT;
@ -452,7 +453,7 @@ class xmldb_field extends xmldb_object {
* @param int $type
* @return string
*/
function getXMLDBTypeName($type) {
public function getXMLDBTypeName($type) {
$result = "";
@ -488,7 +489,7 @@ class xmldb_field extends xmldb_object {
* @param bool $recursive
* @return void, modifies $this->hash
*/
function calculateHash($recursive = false) {
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
} else {
@ -503,7 +504,7 @@ class xmldb_field extends xmldb_object {
* This function will output the XML text for one field
* @return string
*/
function xmlOutput() {
public function xmlOutput() {
$o = '';
$o.= ' <FIELD NAME="' . $this->name . '"';
$o.= ' TYPE="' . $this->getXMLDBTypeName($this->type) . '"';
@ -548,7 +549,7 @@ class xmldb_field extends xmldb_object {
* @param string $adofield
* @return void, sets $this->type
*/
function setFromADOField($adofield) {
public function setFromADOField($adofield) {
// Calculate the XMLDB_TYPE
switch (strtolower($adofield->type)) {
@ -636,7 +637,7 @@ class xmldb_field extends xmldb_object {
* @param bool $includeprevious
* @return string
*/
function getPHP($includeprevious=true) {
public function getPHP($includeprevious=true) {
$result = '';
@ -719,7 +720,7 @@ class xmldb_field extends xmldb_object {
* Shows info in a readable format
* @return string
*/
function readableInfo() {
public function readableInfo() {
$o = '';
// type
$o .= $this->getXMLDBTypeName($this->type);
@ -770,7 +771,7 @@ class xmldb_field extends xmldb_object {
* @param xmldb_table $xmldb_table optional when object is table
* @return string null if ok, error message if problem found
*/
function validateDefinition(xmldb_table $xmldb_table=null) {
public function validateDefinition(xmldb_table $xmldb_table=null) {
if (!$xmldb_table) {
return 'Invalid xmldb_field->validateDefinition() call, $xmldb_table is required.';
}

View File

@ -44,7 +44,7 @@ class xmldb_file extends xmldb_object {
* Constructor of the xmldb_file
* @param string $path
*/
function __construct($path) {
public function __construct($path) {
parent::__construct($path);
$this->path = $path;
$this->xmldb_structure = NULL;
@ -54,7 +54,7 @@ class xmldb_file extends xmldb_object {
* Determine if the XML file exists
* @return bool
*/
function fileExists() {
public function fileExists() {
if (file_exists($this->path) && is_readable($this->path)) {
return true;
}
@ -65,14 +65,14 @@ class xmldb_file extends xmldb_object {
* Determine if the XML is writeable
* @return bool
*/
function fileWriteable() {
public function fileWriteable() {
if (is_writeable(dirname($this->path))) {
return true;
}
return false;
}
function getStructure() {
public function getStructure() {
return $this->xmldb_structure;
}
@ -82,7 +82,7 @@ class xmldb_file extends xmldb_object {
* (expat syntax checker or DOM schema validator
* @return true
*/
function validateXMLStructure() {
public function validateXMLStructure() {
// Create and load XML file
$parser = new DOMDocument();
@ -134,7 +134,7 @@ class xmldb_file extends xmldb_object {
* Load and the XMLDB structure from file
* @return true
*/
function loadXMLStructure() {
public function loadXMLStructure() {
if ($this->fileExists()) {
// Let's validate the XML file
if (!$this->validateXMLStructure()) {
@ -167,7 +167,7 @@ class xmldb_file extends xmldb_object {
* @param array $xmlarr
* @return xmldb_structure
*/
function arr2xmldb_structure ($xmlarr) {
public function arr2xmldb_structure ($xmlarr) {
$structure = new xmldb_structure($this->path);
$structure->arr2xmldb_structure($xmlarr);
return $structure;
@ -177,7 +177,7 @@ class xmldb_file extends xmldb_object {
* This function sets the DTD of the XML file
* @param string
*/
function setDTD($path) {
public function setDTD($path) {
$this->dtd = $path;
}
@ -185,7 +185,7 @@ class xmldb_file extends xmldb_object {
* This function sets the schema of the XML file
* @param string
*/
function setSchema($path) {
public function setSchema($path) {
$this->schema = $path;
}
@ -193,7 +193,7 @@ class xmldb_file extends xmldb_object {
* This function saves the whole xmldb_structure to its file
* @return int|bool false on failure, number of written bytes on success
*/
function saveXMLFile() {
public function saveXMLFile() {
$structure = $this->getStructure();

View File

@ -57,7 +57,7 @@ class xmldb_index extends xmldb_object {
* @param string type XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
* @param array fields an array of fieldnames to build the index over
*/
function __construct($name, $type=null, $fields=array()) {
public function __construct($name, $type=null, $fields=array()) {
$this->unique = false;
$this->fields = array();
parent::__construct($name);
@ -70,7 +70,7 @@ class xmldb_index extends xmldb_object {
* @param string type XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
* @param array fields an array of fieldnames to build the index over
*/
function set_attributes($type, $fields) {
public function set_attributes($type, $fields) {
$this->unique = !empty($type) ? true : false;
$this->fields = $fields;
}
@ -79,7 +79,7 @@ class xmldb_index extends xmldb_object {
* Get the index unique
* @return bool
*/
function getUnique() {
public function getUnique() {
return $this->unique;
}
@ -87,7 +87,7 @@ class xmldb_index extends xmldb_object {
* Set the index unique
* @param bool $unique
*/
function setUnique($unique = true) {
public function setUnique($unique = true) {
$this->unique = $unique;
}
@ -95,7 +95,7 @@ class xmldb_index extends xmldb_object {
* Set the index fields
* @param array $fields
*/
function setFields($fields) {
public function setFields($fields) {
$this->fields = $fields;
}
@ -103,7 +103,7 @@ class xmldb_index extends xmldb_object {
* Get the index fields
* @return array
*/
function getFields() {
public function getFields() {
return $this->fields;
}
@ -112,7 +112,7 @@ class xmldb_index extends xmldb_object {
* @param $xmlarr array
* @return bool
*/
function arr2xmldb_index($xmlarr) {
public function arr2xmldb_index($xmlarr) {
$result = true;
@ -197,7 +197,7 @@ class xmldb_index extends xmldb_object {
* This function calculate and set the hash of one xmldb_index
* @retur nvoid, changes $this->hash
*/
function calculateHash($recursive = false) {
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
} else {
@ -210,7 +210,7 @@ class xmldb_index extends xmldb_object {
*This function will output the XML text for one index
* @return string
*/
function xmlOutput() {
public function xmlOutput() {
$o = '';
$o.= ' <INDEX NAME="' . $this->name . '"';
if ($this->unique) {
@ -240,7 +240,7 @@ class xmldb_index extends xmldb_object {
* @param array
* @return void
*/
function setFromADOIndex($adoindex) {
public function setFromADOIndex($adoindex) {
// Set the unique field
$this->unique = false;
@ -256,7 +256,7 @@ class xmldb_index extends xmldb_object {
* Returns the PHP code needed to define one xmldb_index
* @return string
*/
function getPHP() {
public function getPHP() {
$result = '';
@ -282,7 +282,7 @@ class xmldb_index extends xmldb_object {
* Shows info in a readable format
* @return string
*/
function readableInfo() {
public function readableInfo() {
$o = '';
// unique
if ($this->unique) {
@ -305,7 +305,7 @@ class xmldb_index extends xmldb_object {
* @param xmldb_table $xmldb_table optional when object is table
* @return string null if ok, error message if problem found
*/
function validateDefinition(xmldb_table $xmldb_table=null) {
public function validateDefinition(xmldb_table $xmldb_table=null) {
if (!$xmldb_table) {
return 'Invalid xmldb_index->validateDefinition() call, $xmldb_table si required.';
}

View File

@ -48,7 +48,7 @@ class xmldb_key extends xmldb_object {
* @param string $reftable name of the table the FK points to or null
* @param array $reffields an array of fieldnames in the FK table or null
*/
function __construct($name, $type=null, $fields=array(), $reftable=null, $reffields=null) {
public function __construct($name, $type=null, $fields=array(), $reftable=null, $reffields=null) {
$this->type = NULL;
$this->fields = array();
$this->reftable = NULL;
@ -65,7 +65,7 @@ class xmldb_key extends xmldb_object {
* @param string $reftable name of the table the FK points to or null
* @param array $reffields an array of fieldnames in the FK table or null
*/
function set_attributes($type, $fields, $reftable=null, $reffields=null) {
public function set_attributes($type, $fields, $reftable=null, $reffields=null) {
$this->type = $type;
$this->fields = $fields;
$this->reftable = $reftable;
@ -76,7 +76,7 @@ class xmldb_key extends xmldb_object {
* Get the key type
* @return int
*/
function getType() {
public function getType() {
return $this->type;
}
@ -84,7 +84,7 @@ class xmldb_key extends xmldb_object {
* Set the key type
* @param int $type
*/
function setType($type) {
public function setType($type) {
$this->type = $type;
}
@ -92,7 +92,7 @@ class xmldb_key extends xmldb_object {
* Set the key fields
* @param array $fields
*/
function setFields($fields) {
public function setFields($fields) {
$this->fields = $fields;
}
@ -100,7 +100,7 @@ class xmldb_key extends xmldb_object {
* Set the key reftable
* @param string $reftable
*/
function setRefTable($reftable) {
public function setRefTable($reftable) {
$this->reftable = $reftable;
}
@ -108,7 +108,7 @@ class xmldb_key extends xmldb_object {
* Set the key reffields
* @param array $reffields
*/
function setRefFields($reffields) {
public function setRefFields($reffields) {
$this->reffields = $reffields;
}
@ -116,7 +116,7 @@ class xmldb_key extends xmldb_object {
* Get the key fields
* @return array
*/
function getFields() {
public function getFields() {
return $this->fields;
}
@ -124,7 +124,7 @@ class xmldb_key extends xmldb_object {
* Get the key reftable
* @return string
*/
function getRefTable() {
public function getRefTable() {
return $this->reftable;
}
@ -132,7 +132,7 @@ class xmldb_key extends xmldb_object {
* Get the key reffields
* @return array reference to ref fields
*/
function getRefFields() {
public function getRefFields() {
return $this->reffields;
}
@ -141,7 +141,7 @@ class xmldb_key extends xmldb_object {
* @param array $xmlarr
* @return bool success
*/
function arr2xmldb_key($xmlarr) {
public function arr2xmldb_key($xmlarr) {
$result = true;
@ -293,7 +293,7 @@ class xmldb_key extends xmldb_object {
* @param string $type
* @return int
*/
function getXMLDBKeyType($type) {
public function getXMLDBKeyType($type) {
$result = XMLDB_KEY_INCORRECT;
@ -324,7 +324,7 @@ class xmldb_key extends xmldb_object {
* @param int $type
* @return string
*/
function getXMLDBKeyName($type) {
public function getXMLDBKeyName($type) {
$result = '';
@ -353,7 +353,7 @@ class xmldb_key extends xmldb_object {
* This function calculate and set the hash of one xmldb_key
* @param bool $recursive
*/
function calculateHash($recursive = false) {
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
} else {
@ -371,7 +371,7 @@ class xmldb_key extends xmldb_object {
*This function will output the XML text for one key
* @return string
*/
function xmlOutput() {
public function xmlOutput() {
$o = '';
$o.= ' <KEY NAME="' . $this->name . '"';
$o.= ' TYPE="' . $this->getXMLDBKeyName($this->type) . '"';
@ -400,7 +400,7 @@ class xmldb_key extends xmldb_object {
* based on information passed in one ADOkey
* @oaram array $adokey
*/
function setFromADOKey($adokey) {
public function setFromADOKey($adokey) {
// Calculate the XMLDB_KEY
switch (strtolower($adokey['name'])) {
@ -422,7 +422,7 @@ class xmldb_key extends xmldb_object {
* Returns the PHP code needed to define one xmldb_key
* @return string
*/
function getPHP() {
public function getPHP() {
$result = '';
@ -474,7 +474,7 @@ class xmldb_key extends xmldb_object {
* Shows info in a readable format
* @return string
*/
function readableInfo() {
public function readableInfo() {
$o = '';
// type
$o .= $this->getXMLDBKeyName($this->type);

View File

@ -56,7 +56,7 @@ class xmldb_object {
* Creates one new xmldb_object
* @param string $name
*/
function __construct($name) {
public function __construct($name) {
$this->name = $name;
$this->comment = NULL;
$this->previous = NULL;
@ -71,7 +71,7 @@ class xmldb_object {
* This function returns true/false, if the xmldb_object has been loaded
* @return bool
*/
function isLoaded() {
public function isLoaded() {
return $this->loaded;
}
@ -79,7 +79,7 @@ class xmldb_object {
* This function returns true/false, if the xmldb_object has changed
* @return bool
*/
function hasChanged() {
public function hasChanged() {
return $this->changed;
}
@ -87,7 +87,7 @@ class xmldb_object {
* This function returns the comment of one xmldb_object
* @return string
*/
function getComment() {
public function getComment() {
return $this->comment;
}
@ -95,7 +95,7 @@ class xmldb_object {
* This function returns the hash of one xmldb_object
* @return string
*/
function getHash() {
public function getHash() {
return $this->hash;
}
@ -103,7 +103,7 @@ class xmldb_object {
* This function will return the name of the previous xmldb_object
* @return xmldb_object
*/
function getPrevious() {
public function getPrevious() {
return $this->previous;
}
@ -111,7 +111,7 @@ class xmldb_object {
* This function will return the name of the next xmldb_object
* @return xmldb_object
*/
function getNext() {
public function getNext() {
return $this->next;
}
@ -119,7 +119,7 @@ class xmldb_object {
* This function will return the name of the xmldb_object
* @return string
*/
function getName() {
public function getName() {
return $this->name;
}
@ -127,7 +127,7 @@ class xmldb_object {
* This function will return the error detected in the object
* @return string
*/
function getError() {
public function getError() {
return $this->errormsg;
}
@ -135,7 +135,7 @@ class xmldb_object {
* This function will set the comment of the xmldb_object
* @param string $comment
*/
function setComment($comment) {
public function setComment($comment) {
$this->comment = $comment;
}
@ -143,7 +143,7 @@ class xmldb_object {
* This function will set the previous of the xmldb_object
* @param xmldb_object $previous
*/
function setPrevious($previous) {
public function setPrevious($previous) {
$this->previous = $previous;
}
@ -151,7 +151,7 @@ class xmldb_object {
* This function will set the next of the xmldb_object
* @param xmldb_object $next
*/
function setNext($next) {
public function setNext($next) {
$this->next = $next;
}
@ -159,7 +159,7 @@ class xmldb_object {
* This function will set the hash of the xmldb_object
* @param string $hash
*/
function setHash($hash) {
public function setHash($hash) {
$this->hash = $hash;
}
@ -167,7 +167,7 @@ class xmldb_object {
* This function will set the loaded field of the xmldb_object
* @param bool $loaded
*/
function setLoaded($loaded = true) {
public function setLoaded($loaded = true) {
$this->loaded = $loaded;
}
@ -175,14 +175,14 @@ class xmldb_object {
* This function will set the changed field of the xmldb_object
* @param bool $changed
*/
function setChanged($changed = true) {
public function setChanged($changed = true) {
$this->changed = $changed;
}
/**
* This function will set the name field of the xmldb_object
* @param string $name
*/
function setName($name) {
public function setName($name) {
$this->name = $name;
}
@ -192,7 +192,7 @@ class xmldb_object {
* only lowercase a-z, 0-9 and _ are allowed
* @return bool
*/
function checkName () {
public function checkName () {
$result = true;
if ($this->name != preg_replace('/[^a-z0-9_ -]/i', '', $this->name)) {
@ -207,7 +207,7 @@ class xmldb_object {
* @param array $arr
* @return bool
*/
function checkNameValues($arr) {
public function checkNameValues($arr) {
$result = true;
// TODO: Perhaps, add support for reserved words
@ -238,7 +238,7 @@ class xmldb_object {
* @param array $arr
* @return bool true if $arr modified
*/
function fixPrevNext(&$arr) {
public function fixPrevNext(&$arr) {
global $CFG;
if (empty($CFG->xmldbreconstructprevnext)) {
@ -273,7 +273,7 @@ class xmldb_object {
* @param array $arr
* @return bool true means ok, false invalid prev/next present
*/
function checkPreviousNextValues($arr) {
public function checkPreviousNextValues($arr) {
global $CFG;
if (!empty($CFG->xmldbdisablenextprevchecking)) {
return true;
@ -380,7 +380,7 @@ class xmldb_object {
* @param array $arr
* @return array|bool
*/
function orderElements($arr) {
public function orderElements($arr) {
global $CFG;
$result = true;
if (!empty($CFG->xmldbdisablenextprevchecking)) {
@ -430,7 +430,7 @@ class xmldb_object {
* @param array $arr
* @return mixed
*/
function findObjectInArray($objectname, $arr) {
public function findObjectInArray($objectname, $arr) {
foreach ($arr as $i => $object) {
if ($objectname == $object->getName()) {
return $i;
@ -444,7 +444,7 @@ class xmldb_object {
* (should be implemented inside each XMLDBxxx object)
* @return string
*/
function readableInfo() {
public function readableInfo() {
return get_class($this);
}
@ -460,7 +460,7 @@ class xmldb_object {
* defining XMLDB_SKIP_DEBUG_HOOK
* @param string $message
*/
function debug($message) {
public function debug($message) {
// Check for xmldb_debug($message, $xmldb_object)
$funcname = 'xmldb_debug';
@ -476,7 +476,7 @@ class xmldb_object {
* @param string $string
* @return array
*/
function comma2array($string) {
public function comma2array($string) {
$foundquotes = array();
$foundconcats = array();
@ -533,7 +533,7 @@ class xmldb_object {
* @param xmldb_table $xmldb_table optional when object is table
* @return string null if ok, error message if problem found
*/
function validateDefinition(xmldb_table $xmldb_table=null) {
public function validateDefinition(xmldb_table $xmldb_table=null) {
return null;
}
}

View File

@ -41,7 +41,7 @@ class xmldb_structure extends xmldb_object {
* Creates one new xmldb_structure
* @param string $name
*/
function __construct($name) {
public function __construct($name) {
parent::__construct($name);
$this->path = NULL;
$this->version = NULL;
@ -52,7 +52,7 @@ class xmldb_structure extends xmldb_object {
* Returns the path of the structure
* @return string
*/
function getPath() {
public function getPath() {
return $this->path;
}
@ -60,7 +60,7 @@ class xmldb_structure extends xmldb_object {
* Returns the version of the structure
* @return string
*/
function getVersion() {
public function getVersion() {
return $this->version;
}
@ -69,7 +69,7 @@ class xmldb_structure extends xmldb_object {
* @param string $tablename
* @return xmldb_table
*/
function getTable($tablename) {
public function getTable($tablename) {
$i = $this->findTableInArray($tablename);
if ($i !== NULL) {
return $this->tables[$i];
@ -82,7 +82,7 @@ class xmldb_structure extends xmldb_object {
* @param string $tablename
* @return mixed
*/
function findTableInArray($tablename) {
public function findTableInArray($tablename) {
foreach ($this->tables as $i => $table) {
if ($tablename == $table->getName()) {
return $i;
@ -95,7 +95,7 @@ class xmldb_structure extends xmldb_object {
* This function will reorder the array of tables
* @return bool success
*/
protected function orderTables() {
public function orderTables() {
$result = $this->orderElements($this->tables);
if ($result) {
$this->setTables($result);
@ -109,7 +109,7 @@ class xmldb_structure extends xmldb_object {
* Returns the tables of the structure
* @return array
*/
function getTables() {
public function getTables() {
return $this->tables;
}
@ -117,7 +117,7 @@ class xmldb_structure extends xmldb_object {
* Set the structure version
* @param string version
*/
function setVersion($version) {
public function setVersion($version) {
$this->version = $version;
}
@ -127,7 +127,7 @@ class xmldb_structure extends xmldb_object {
* @param xmldb_table $table
* @param mixed $after
*/
function addTable($table, $after=NULL) {
public function addTable($table, $after=NULL) {
// Calculate the previous and next tables
$prevtable = NULL;
@ -136,7 +136,7 @@ class xmldb_structure extends xmldb_object {
if (!$after) {
if ($this->tables) {
end($this->tables);
$prevtable = $this->tables[key($alltables)];
$prevtable = $this->tables[key($this->tables)];
}
} else {
$prevtable = $this->getTable($after);
@ -172,7 +172,7 @@ class xmldb_structure extends xmldb_object {
* Delete one table from the Structure
* @param string $tablename
*/
function deleteTable($tablename) {
public function deleteTable($tablename) {
$table = $this->getTable($tablename);
if ($table) {
@ -203,7 +203,7 @@ class xmldb_structure extends xmldb_object {
* Set the tables
* @param array $tables
*/
function setTables($tables) {
public function setTables($tables) {
$this->tables = $tables;
}
@ -212,7 +212,7 @@ class xmldb_structure extends xmldb_object {
* @param array $xmlarr
* @return bool
*/
function arr2xmldb_structure($xmlarr) {
public function arr2xmldb_structure($xmlarr) {
global $CFG;
@ -305,7 +305,7 @@ class xmldb_structure extends xmldb_object {
* This function calculate and set the hash of one xmldb_structure
* @param bool $recursive
*/
function calculateHash($recursive = false) {
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
} else {
@ -327,7 +327,7 @@ class xmldb_structure extends xmldb_object {
* This function will output the XML text for one structure
* @return string
*/
function xmlOutput() {
public function xmlOutput() {
$o = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
$o.= '<XMLDB PATH="' . $this->path . '"';
$o.= ' VERSION="' . $this->version . '"';
@ -359,7 +359,7 @@ class xmldb_structure extends xmldb_object {
* @param string $tablename
* @return mixed
*/
function getTableUses($tablename) {
public function getTableUses($tablename) {
$uses = array();
@ -396,7 +396,7 @@ class xmldb_structure extends xmldb_object {
* @param string $fieldname
* @return mixed
*/
function getFieldUses($tablename, $fieldname) {
public function getFieldUses($tablename, $fieldname) {
$uses = array();
@ -455,7 +455,7 @@ class xmldb_structure extends xmldb_object {
* @param string $keyname
* @return mixed
*/
function getKeyUses($tablename, $keyname) {
public function getKeyUses($tablename, $keyname) {
$uses = array();
@ -496,11 +496,11 @@ class xmldb_structure extends xmldb_object {
* @param string $indexname
* @return mixed
*/
function getIndexUses($tablename, $indexname) {
public function getIndexUses($tablename, $indexname) {
$uses = array();
// Nothing to check, beause indexes haven't uses! Leave it here
// Nothing to check, because indexes haven't uses! Leave it here
// for future checks...
// Return result
@ -517,7 +517,7 @@ class xmldb_structure extends xmldb_object {
* an array of errors or false
* @return mixed
*/
function getAllErrors() {
public function getAllErrors() {
$errors = array();
// First the structure itself

View File

@ -50,7 +50,7 @@ class xmldb_table extends xmldb_object {
* Creates one new xmldb_table
* @param string $name
*/
function __construct($name) {
public function __construct($name) {
parent::__construct($name);
$this->fields = array();
$this->keys = array();
@ -64,7 +64,7 @@ class xmldb_table extends xmldb_object {
* @param xmldb_object $after
* @return xmldb_field
*/
function addField(&$field, $after=NULL) {
public function addField($field, $after=NULL) {
// Detect duplicates first
if ($this->getField($field->getName())) {
@ -76,16 +76,16 @@ class xmldb_table extends xmldb_object {
$nextfield = NULL;
if (!$after) {
$allfields =& $this->getFields();
$allfields = $this->getFields();
if (!empty($allfields)) {
end($allfields);
$prevfield =& $allfields[key($allfields)];
$prevfield = $allfields[key($allfields)];
}
} else {
$prevfield =& $this->getField($after);
$prevfield = $this->getField($after);
}
if ($prevfield && $prevfield->getNext()) {
$nextfield =& $this->getField($prevfield->getNext());
$nextfield = $this->getField($prevfield->getNext());
}
// Set current field previous and next attributes
@ -118,7 +118,7 @@ class xmldb_table extends xmldb_object {
* @param xmldb_key $key
* @param xmldb_object $after
*/
function addKey(&$key, $after=NULL) {
public function addKey($key, $after=NULL) {
// Detect duplicates first
if ($this->getKey($key->getName())) {
@ -130,16 +130,16 @@ class xmldb_table extends xmldb_object {
$nextkey = NULL;
if (!$after) {
$allkeys =& $this->getKeys();
$allkeys = $this->getKeys();
if (!empty($allkeys)) {
end($allkeys);
$prevkey =& $allkeys[key($allkeys)];
$prevkey = $allkeys[key($allkeys)];
}
} else {
$prevkey =& $this->getKey($after);
$prevkey = $this->getKey($after);
}
if ($prevkey && $prevkey->getNext()) {
$nextkey =& $this->getKey($prevkey->getNext());
$nextkey = $this->getKey($prevkey->getNext());
}
// Set current key previous and next attributes
@ -170,7 +170,7 @@ class xmldb_table extends xmldb_object {
* @param xmldb_index $index
* @param xmldb_object $after
*/
function addIndex(&$index, $after=NULL) {
public function addIndex($index, $after=NULL) {
// Detect duplicates first
if ($this->getIndex($index->getName())) {
@ -182,16 +182,16 @@ class xmldb_table extends xmldb_object {
$nextindex = NULL;
if (!$after) {
$allindexes =& $this->getIndexes();
$allindexes = $this->getIndexes();
if (!empty($allindexes)) {
end($allindexes);
$previndex =& $allindexes[key($allindexes)];
$previndex = $allindexes[key($allindexes)];
}
} else {
$previndex =& $this->getIndex($after);
$previndex = $this->getIndex($after);
}
if ($previndex && $previndex->getNext()) {
$nextindex =& $this->getIndex($previndex->getNext());
$nextindex = $this->getIndex($previndex->getNext());
}
// Set current index previous and next attributes
@ -221,7 +221,7 @@ class xmldb_table extends xmldb_object {
* This function will return the array of fields in the table
* @return array
*/
function &getFields() {
public function getFields() {
return $this->fields;
}
@ -229,7 +229,7 @@ class xmldb_table extends xmldb_object {
* This function will return the array of keys in the table
* @return array
*/
function &getKeys() {
public function getKeys() {
return $this->keys;
}
@ -237,7 +237,7 @@ class xmldb_table extends xmldb_object {
* This function will return the array of indexes in the table
* @return array
*/
function &getIndexes() {
public function getIndexes() {
return $this->indexes;
}
@ -246,13 +246,12 @@ class xmldb_table extends xmldb_object {
* @param string $fieldname
* @return mixed
*/
function &getField($fieldname) {
public function getField($fieldname) {
$i = $this->findFieldInArray($fieldname);
if ($i !== NULL) {
return $this->fields[$i];
}
$null = NULL;
return $null;
return null;
}
/**
@ -260,21 +259,20 @@ class xmldb_table extends xmldb_object {
* @param string $fieldname
* @return mixed
*/
function &findFieldInArray($fieldname) {
public function findFieldInArray($fieldname) {
foreach ($this->fields as $i => $field) {
if ($fieldname == $field->getName()) {
return $i;
}
}
$null = NULL;
return $null;
return null;
}
/**
* This function will reorder the array of fields
* @return bool
*/
function orderFields() {
public function orderFields() {
$result = $this->orderElements($this->fields);
if ($result) {
$this->setFields($result);
@ -289,13 +287,12 @@ class xmldb_table extends xmldb_object {
* @param string $keyname
* @return mixed
*/
function &getKey($keyname) {
public function getKey($keyname) {
$i = $this->findKeyInArray($keyname);
if ($i !== NULL) {
return $this->keys[$i];
}
$null = NULL;
return $null;
return null;
}
/**
@ -303,21 +300,20 @@ class xmldb_table extends xmldb_object {
* @param string $keyname
* @return mixed
*/
function &findKeyInArray($keyname) {
public function findKeyInArray($keyname) {
foreach ($this->keys as $i => $key) {
if ($keyname == $key->getName()) {
return $i;
}
}
$null = NULL;
return $null;
return null;
}
/**
* This function will reorder the array of keys
* @return bool
*/
function orderKeys() {
public function orderKeys() {
$result = $this->orderElements($this->keys);
if ($result) {
$this->setKeys($result);
@ -332,35 +328,33 @@ class xmldb_table extends xmldb_object {
* @param string $indexname
* @return mixed
*/
function &getIndex($indexname) {
public function getIndex($indexname) {
$i = $this->findIndexInArray($indexname);
if ($i !== NULL) {
return $this->indexes[$i];
}
$null = NULL;
return $null;
return null;
}
/**
* Returns the position of one index in the array.
* @param string $idnexname
* @param string $indexname
* @return mixed
*/
function &findIndexInArray($indexname) {
public function findIndexInArray($indexname) {
foreach ($this->indexes as $i => $index) {
if ($indexname == $index->getName()) {
return $i;
}
}
$null = NULL;
return $null;
return null;
}
/**
* This function will reorder the array of indexes
* @return bool
*/
function orderIndexes() {
public function orderIndexes() {
$result = $this->orderElements($this->indexes);
if ($result) {
$this->setIndexes($result);
@ -374,7 +368,7 @@ class xmldb_table extends xmldb_object {
* This function will set the array of fields in the table
* @param array $fields
*/
function setFields($fields) {
public function setFields($fields) {
$this->fields = $fields;
}
@ -382,7 +376,7 @@ class xmldb_table extends xmldb_object {
* This function will set the array of keys in the table
* @param array $keys
*/
function setKeys($keys) {
public function setKeys($keys) {
$this->keys = $keys;
}
@ -390,7 +384,7 @@ class xmldb_table extends xmldb_object {
* This function will set the array of indexes in the table
* @param array $indexes
*/
function setIndexes($indexes) {
public function setIndexes($indexes) {
$this->indexes = $indexes;
}
@ -398,14 +392,14 @@ class xmldb_table extends xmldb_object {
* Delete one field from the table
* @param string $fieldname
*/
function deleteField($fieldname) {
public function deleteField($fieldname) {
$field =& $this->getField($fieldname);
$field = $this->getField($fieldname);
if ($field) {
$i = $this->findFieldInArray($fieldname);
// Look for prev and next field
$prevfield =& $this->getField($field->getPrevious());
$nextfield =& $this->getField($field->getNext());
$prevfield = $this->getField($field->getPrevious());
$nextfield = $this->getField($field->getNext());
// Change their previous and next attributes
if ($prevfield) {
$prevfield->setNext($field->getNext());
@ -428,14 +422,14 @@ class xmldb_table extends xmldb_object {
* Delete one key from the table
* @param string $keyname
*/
function deleteKey($keyname) {
public function deleteKey($keyname) {
$key =& $this->getKey($keyname);
$key = $this->getKey($keyname);
if ($key) {
$i = $this->findKeyInArray($keyname);
// Look for prev and next key
$prevkey =& $this->getKey($key->getPrevious());
$nextkey =& $this->getKey($key->getNext());
$prevkey = $this->getKey($key->getPrevious());
$nextkey = $this->getKey($key->getNext());
// Change their previous and next attributes
if ($prevkey) {
$prevkey->setNext($key->getNext());
@ -456,16 +450,16 @@ class xmldb_table extends xmldb_object {
/**
* Delete one index from the table
* @param string $idnexname
* @param string $indexname
*/
function deleteIndex($indexname) {
public function deleteIndex($indexname) {
$index =& $this->getIndex($indexname);
$index = $this->getIndex($indexname);
if ($index) {
$i = $this->findIndexInArray($indexname);
// Look for prev and next index
$previndex =& $this->getIndex($index->getPrevious());
$nextindex =& $this->getIndex($index->getNext());
$previndex = $this->getIndex($index->getPrevious());
$nextindex = $this->getIndex($index->getNext());
// Change their previous and next attributes
if ($previndex) {
$previndex->setNext($index->getNext());
@ -489,7 +483,7 @@ class xmldb_table extends xmldb_object {
* @param array $xmlarr
* @return bool success
*/
function arr2xmldb_table($xmlarr) {
public function arr2xmldb_table($xmlarr) {
global $CFG;
@ -672,14 +666,14 @@ class xmldb_table extends xmldb_object {
* This function calculate and set the hash of one xmldb_table
* @param bool $recursive
*/
function calculateHash($recursive = false) {
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
} else {
$key = $this->name . $this->comment;
if ($this->fields) {
foreach ($this->fields as $fie) {
$field =& $this->getField($fie->getName());
$field = $this->getField($fie->getName());
if ($recursive) {
$field->calculateHash($recursive);
}
@ -688,7 +682,7 @@ class xmldb_table extends xmldb_object {
}
if ($this->keys) {
foreach ($this->keys as $ke) {
$k =& $this->getKey($ke->getName());
$k = $this->getKey($ke->getName());
if ($recursive) {
$k->calculateHash($recursive);
}
@ -697,7 +691,7 @@ class xmldb_table extends xmldb_object {
}
if ($this->indexes) {
foreach ($this->indexes as $in) {
$index =& $this->getIndex($in->getName());
$index = $this->getIndex($in->getName());
if ($recursive) {
$index->calculateHash($recursive);
}
@ -717,7 +711,7 @@ class xmldb_table extends xmldb_object {
* @param xmldb_table $xmldb_table optional when object is table
* @return string null if ok, error message if problem found
*/
function validateDefinition(xmldb_table $xmldb_table=null) {
public function validateDefinition(xmldb_table $xmldb_table=null) {
// table parameter is ignored
$name = $this->getName();
if (strlen($name) > self::NAME_MAX_LENGTH) {
@ -734,7 +728,7 @@ class xmldb_table extends xmldb_object {
* This function will output the XML text for one table
* @return string
*/
function xmlOutput() {
public function xmlOutput() {
$o = '';
$o.= ' <TABLE NAME="' . $this->name . '"';
if ($this->comment) {
@ -788,8 +782,9 @@ class xmldb_table extends xmldb_object {
* @param bool $sequence XMLDB_SEQUENCE or null (or false)
* @param mixed $default meaningful default o null (or false)
* @param xmldb_object $previous name of the previous field in the table or null (or false)
* @return xmlddb_field
*/
function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
public function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$field = new xmldb_field($name, $type, $precision, $unsigned, $notnull, $sequence, $default);
$this->addField($field, $previous);
@ -806,7 +801,7 @@ class xmldb_table extends xmldb_object {
* @param string $reftable name of the table the FK points to or null
* @param array $reffields an array of fieldnames in the FK table or null
*/
function add_key($name, $type, $fields, $reftable=null, $reffields=null) {
public function add_key($name, $type, $fields, $reftable=null, $reffields=null) {
$key = new xmldb_key($name, $type, $fields, $reftable, $reffields);
$this->addKey($key);
}
@ -819,7 +814,7 @@ class xmldb_table extends xmldb_object {
* @param int $type XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
* @param array $fields an array of fieldnames to build the index over
*/
function add_index($name, $type, $fields) {
public function add_index($name, $type, $fields) {
$index = new xmldb_index($name, $type, $fields);
$this->addIndex($index);
}
@ -829,7 +824,7 @@ class xmldb_table extends xmldb_object {
* looking recursively inside each field/key/index. Returns
* an array of errors or false
*/
function getAllErrors() {
public function getAllErrors() {
$errors = array();
// First the table itself