Class Model

Description

This class contains the functions to manage the data model based in Nested Set Model. This file contains the constants to config the model.

To use these functions, you need before to connect to data base.

Located in /ModelClass.php (line 162)


	
			
Variable Summary
Method Summary
Model __construct ([Bool $debug = false])
Bool addChild (String $nombreNodo, String $tipo, String $nombrePadre, String $nombreHermano, [Bool $debug = false])
Integer createRelation (String $name, [Bool $debug = false])
void deleteAllDB ([Bool $debug = false])
Bool deleteElement (String $name, String $type, [Bool $debug = false])
Boolean deleteElementStruct (String $name)
Bool deleteRelation (String $name, [Bool $debug = false])
Bool deleteTables ([Bool $print = false], [ $debug = false])
Bool deleteValue (String $path, [Bool $debug = false])
Bool existsElement ( $elementName, String $name)
Bool existsRelation (String $name)
Array getAllNodes (String $nodeRoot, Bool $completePath)
Array getAllowedTypes ()
Array getElementNameFromIds (Array $arrayIDS)
Array getElementsByType (String $nombretipo, [Bool $debug = false])
Integer getId (String $name, String $type, [Bool $debug = false])
Array getIdsByProperty (Array $array, [Bool $debug = false])
Integer getIdStruct (String $path)
Array getInmChildren (String $root, [Bool $completePath = false])
String getNameElementId (Integer $elementid)
String getNameStructId (Integer $structid)
Array getParams ()
Array getRelation (String $name, [Bool $debug = false])
Mixed getTypeStruct (String $name)
String getValue (String $path, [Bool $debug = false])
Array getValuesFromPath (String $path, Bool $debug)
Bool initializateDB (TablesParameters $tablesParameters, [Bool $print = false], [ $debug = false])
Bool initializeStruct ([Bool $debug = false])
Bool insertElement (String $type, String $name, [Bool $debug = false])
Bool install ()
void loadData ([Bool $debug = false])
void loadElements ([Bool $debug = false])
void loadStructure ([Bool $debug = false])
void loadXML (String $fileName)
void printArraysXML ()
void printList (String $elemento, Bool $showtype, Bool $showid, Bool $removeSlash, Bool $showbuttons, Bool $activarResaltado)
void printStructure ()
String removeFirstRoot (String $string)
String removeFirstSlash (String $string)
Bool renameElement ( $elementId,  $newName, [Bool $debug = false], Integer $elementId:, String $newName:)
Bool setValue (String $path, String $value, [Bool $debug = false])
Boolean validateStructName (String $name)
Variables
DataHandler $gestorDatos (line 172)
  • access: public
ElementHandler $gestorElementos (line 177)
  • access: public
StructHandler $gestorEstructura (line 182)
  • access: public
RelationHandler $gestorRelaciones (line 187)
  • access: public
Array $parametros (line 167)
  • var: Array with parameters.
  • access: public
Methods
Constructor __construct (line 195)

This function loads the configuration parameters from the constants defined before.

Model __construct ([Bool $debug = false])
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
addChild (line 720)

This function inserts a child in structure tree.

Only with this function all structure can be managed. (Use names without internal root).

  • return: true if node has been inserted. false if not.
  • access: public
Bool addChild (String $nombreNodo, String $tipo, String $nombrePadre, String $nombreHermano, [Bool $debug = false])
  • String $nombreNodo: (Relative name, without path)
  • String $tipo: (a valid node type)
  • String $nombrePadre: ("" to a new root).
  • String $nombreHermano: ("" to most left child).
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
createRelation (line 539)

This function creates a relation between two elements

  • return: with the id of the relation if it has been created. -1 if it has not been created.
  • access: public
Integer createRelation (String $name, [Bool $debug = false])
  • String $name: String with the relation name (TYPE-ID/TYPE2-ID)
  • Bool $debug: if true function will throw debug messages as USER_NOTICE.
deleteAllDB (line 875)

This function deletes all data from tables, not drop tables.

  • access: public
void deleteAllDB ([Bool $debug = false])
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
deleteElement (line 524)

This function deletes an element and all its data.

  • return: true if it has been deleted. false if not.
  • access: public
Bool deleteElement (String $name, String $type, [Bool $debug = false])
  • String $name: contains the name of the element to delete.
  • String $type: contains the type of the element to delete.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
deleteElementStruct (line 285)

This function deletes the subtree in structure with root node specified by $name

  • return: true if it was deleted. false if the node doesn't exist.
  • access: public
Boolean deleteElementStruct (String $name)
  • String $name: with the name of the node to delete.
deleteRelation (line 553)

This function deletes a relation between two elements

  • return: true if the relation has been deleted. false if not.
  • access: public
Bool deleteRelation (String $name, [Bool $debug = false])
  • String $name: with the relation name.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
deleteTables (line 772)

This function drop the three tables from the database.

  • return: true if all tables have been dropped. false if one of them has not been dropped.
  • access: public
Bool deleteTables ([Bool $print = false], [ $debug = false])
  • Bool $print: if true all querys will be printed using echo
  • $debug
deleteValue (line 490)

This function deletes a value of an attribute.

If the attribute doesn't exist returns false.

  • return: true if it has been deleted. false if not.
  • access: public
Bool deleteValue (String $path, [Bool $debug = false])
  • String $path: contains the path to the attribute.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
existsElement (line 689)

This function checks if an element exists. It works with type-id.

(to search an element with name, use getId($name,$type)!=-1)

  • return: True if exists. false otherwise.
  • access: public
Bool existsElement ( $elementName, String $name)
  • String $name: element like TYPE-ID
  • $elementName
existsRelation (line 675)

This function checks if a relation exists.

  • return: True if exists. false if not.
  • access: public
Bool existsRelation (String $name)
  • String $name: String with the name of the relation.
getAllNodes (line 702)

This function returns all the nodes below from a given node.

  • return: Array of String with the names of all the nodes.
  • access: public
Array getAllNodes (String $nodeRoot, Bool $completePath)
  • String $nodeRoot: Name of the root node.
  • Bool $completePath: If true, the complete path is returned. Otherwise it returns only the last part of the path.
getAllowedTypes (line 273)

This auxiliar functions returns an array with all allowed node types.

  • return: Array of String with each allowed node type.
Array getAllowedTypes ()
getElementNameFromIds (line 636)

This function transforms an array with ids into an array with the names of the ids.

  • return: Array of String with the names
  • access: public
Array getElementNameFromIds (Array $arrayIDS)
  • Array $arrayIDS: of Integer $arrayIDS Array with the ids of the elements to transform.
getElementsByType (line 607)

This function returns an array containing all the elements of a given type.

  • return: Array of String with the names of the elements of type $nombretipo.
  • access: public
Array getElementsByType (String $nombretipo, [Bool $debug = false])
  • String $nombretipo: name of the type.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE.
getId (line 582)

This function returns the ID of an element specified by $name.

  • return: ID of the element if it exists. -1 if not.
  • access: public
Integer getId (String $name, String $type, [Bool $debug = false])
  • String $name: contains the name of the element.
  • String $type: contains the type of the element.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
getIdsByProperty (line 625)

This function is used to find elements that have common properties.

  • return: Array of Integer with the elements ids if args are ok. NULL if args not are ok.
  • see: class queryHandler (query.php)
  • todo: now, it doesn't work with relations. In future, it will do it.
  • access: public
  • example: example
Array getIdsByProperty (Array $array, [Bool $debug = false])
  • Bool $debug: if true function will throw debug messages as USER_NOTICE.
  • Array $array: of queryHandler $array
getIdStruct (line 594)

This function returns the structure ID of a node specified by $path

  • return: ID of the structure node if it exists. -1 if not.
  • access: public
Integer getIdStruct (String $path)
  • String $path
getInmChildren (line 229)

Function that returns the inmediates children of a node in an array.

  • return: Array of String
Array getInmChildren (String $root, [Bool $completePath = false])
  • String $root
  • Bool $completePath: if true names will be like /PATH_TO_ROOT/CHILDREN_PATH. if false names will be like /CHILDREN_PATH (without root's path).
getNameElementId (line 653)

This function return the name of an element with a given id.

  • return: String with the name of the element.
  • access: public
String getNameElementId (Integer $elementid)
  • Integer $elementid
getNameStructId (line 663)

This function return the name of an node of structure with a given id.

  • return: String with the name of the node.
  • access: public
String getNameStructId (Integer $structid)
  • Integer $structid
getParams (line 418)

This function returns the array "params" that contains all the characters used.

  • return: Array of String with the parameters defined as constants on top.
Array getParams ()
getRelation (line 567)

This function returns relations between elements (fixed or not).

  • return: Array of String with the results
  • access: public
  • example: example
Array getRelation (String $name, [Bool $debug = false])
  • String $name: relation to get.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE.
getTypeStruct (line 264)

Returns the type of a node with name $name in structure.

  • return: String with the node's type if the node exists. -1 if the node doesn't exist.
Mixed getTypeStruct (String $name)
  • String $name
getValue (line 459)

This function return a value of an attribute especified in $path If the attribute doesn't exist returns NULL.

  • return: Stringwith the value, NULL if doesn't exist.
  • access: public
String getValue (String $path, [Bool $debug = false])
  • String $path: contains the path to the attribute.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
getValuesFromPath (line 432)

This function returns all different values from a given path.

  • return: Arraywith the values.
  • example: example
Array getValuesFromPath (String $path, Bool $debug)
  • String $path: String with the path of the data to retrieve.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE.
initializateDB (line 802)

This function builds the three tables with the parameters in $tablesParameters.

  • return: true if all tables and indexes has been created false if one of the querys don't work ok.
  • access: public
Bool initializateDB (TablesParameters $tablesParameters, [Bool $print = false], [ $debug = false])
  • TablesParameters $tablesParameters
  • Bool $print: if true all querys will be printed using echo
  • $debug
initializeStruct (line 744)

This function initializes an empty structure.

This function must be called after construct the tables. The model doesn't work with empty structure table, it need the internal root node.

  • return: true if it has been initialized. false if not.
  • access: public
Bool initializeStruct ([Bool $debug = false])
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
insertElement (line 509)

This function inserts a new element.

  • return: true if it has been inserted. false if not.
  • see: getId($name, $type, $debug=false)
  • todo: now function DOES NOT CHECK IF OTHER ELEMENT WITH SAME NAME AND TYPE EXISTS. IS RECOMENDED CHECK IT BEFORE INSERT WITH (getId($name,type)==-1). IF TWO ELEMENTS HAVE EQUALS NAMES AND TYPES, ONE WILL BE INNACCESIBLE.
  • access: public
Bool insertElement (String $type, String $name, [Bool $debug = false])
  • String $type: contains an element type.
  • String $name: contains the name of the element to insert.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
install (line 894)

This function creates tables in data base with default values

  • return: true if tables and indexes have been created and structure has been initialized. false if not.
  • see: TablesParameters class in this file.
  • access: public
Bool install ()
loadData (line 396)

This function will load the data from the XML into the database.

void loadData ([Bool $debug = false])
  • Bool $debug: if true function will throw debug messages as USER_NOTICE.
loadElements (line 375)

This function will load the elements from the XML into the database

void loadElements ([Bool $debug = false])
  • Bool $debug: if true function will throw debug messages as USER_NOTICE.
loadStructure (line 239)

This function will load the structure from the XML into the database

void loadStructure ([Bool $debug = false])
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
loadXML (line 408)

This function will load the XML structure and generate all the nodes contained in itself.

void loadXML (String $fileName)
  • String $fileName: String with the path to the filename.
printArraysXML (line 441)

This function will print all the nodes from the struct, not from the database but from the

internal structure of the XML

void printArraysXML ()
printList (line 322)

This function prints a node list. Its used in schemeHandler.php.

  • todo: to move this function to schemeHandler.php
  • access: public
void printList (String $elemento, Bool $showtype, Bool $showid, Bool $removeSlash, Bool $showbuttons, Bool $activarResaltado)
  • String $elemento: root's name of the subtree to print.
  • Bool $showtype: if true it prints the node type.
  • Bool $showid: if true it prints the node id.
  • Bool $removeSlash: if true it prints the relatives nodes names.
  • Bool $showbuttons: if true it prints control buttons.
  • Bool $activarResaltado: if true it prints names in differents colors.
printStructure (line 386)

This function prints the structure tree

void printStructure ()
removeFirstRoot (line 295)

This auxiliar function removes the internal root name from a path passed by $string

  • return: String like $string without the internal root name.
  • access: public
String removeFirstRoot (String $string)
  • String $string
removeFirstSlash (line 253)

This auxiliar function removes the first character of a String.

It's used to remove the first slash in some paths.

  • return: String like $string without it first character.
String removeFirstSlash (String $string)
  • String $string
renameElement (line 760)

This function renames an element.

It checks if the new name is correct and doesn't exists another element with same type and same name.

  • return: true if it has been renamed.
  • access: public
Bool renameElement ( $elementId,  $newName, [Bool $debug = false], Integer $elementId:, String $newName:)
  • Integer $elementId:: Id of the element to be renamed.
  • String $newName:: new name.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE.
  • $elementId
  • $newName
setValue (line 475)

This function sets the value of an attribute.

If the attribute doesn't exist returns false.

  • return: true if it has been setted. false if not.
  • access: public
Bool setValue (String $path, String $value, [Bool $debug = false])
  • String $path: contains the path to the attribute.
  • String $value: contains the value to set.
  • Bool $debug: if true function will throw debug messages as USER_NOTICE
validateStructName (line 307)

This auxiliar function checks if $name is a valid node name.

  • return: true if name is valid. false if not.
  • access: public
Boolean validateStructName (String $name)
  • String $name

Documentation generated by phpDocumentor 1.4.3
Modified by Sergio Barja for S2 - Hierarchical Data Model documentation.