From d2872f1ac425a4e633c378a882a1b3cf7fca4bea Mon Sep 17 00:00:00 2001 From: ucorina Date: Mon, 17 Dec 2012 12:37:22 +0000 Subject: [PATCH] Issue 2759: Update code comments for database classes git-svn-id: http://xe-core.googlecode.com/svn/branches/luminous@12416 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/xml/XmlQueryParser.150.class.php | 195 ++++++++++++----------- 1 file changed, 104 insertions(+), 91 deletions(-) diff --git a/classes/xml/XmlQueryParser.150.class.php b/classes/xml/XmlQueryParser.150.class.php index b0c2087d4..e484f1900 100644 --- a/classes/xml/XmlQueryParser.150.class.php +++ b/classes/xml/XmlQueryParser.150.class.php @@ -1,109 +1,122 @@ - * 2. Check the action
- * 3. Parsing and write a cache file
- * @return QueryParser object - */ - function &parse_xml_query($query_id, $xml_file, $cache_file) + function &getInstance() { - // Read xml file - $xml_obj = $this->getXmlFileContent($xml_file); - - // insert, update, delete, select action - $action = strtolower($xml_obj->query->attrs->action); - if(!$action) return; - - // Write query cache file - $parser = new QueryParser($xml_obj->query); - FileHandler::writeFile($cache_file, $parser->toString()); - - return $parser; - } - - /** - * Query XML file parsing - * @return QueryParser object - */ - function parse($query_id = NULL, $xml_file = NULL, $cache_file = NULL) - { - $this->parse_xml_query($query_id, $xml_file, $cache_file); + static $theInstance = NULL; + if(!isset($theInstance)){ + $theInstance = new XmlQueryParser(); + } + return $theInstance; } - /** - * Return XML file content - * @return array|NULL Returns a resultant data object or NULL in case of error - */ - function getXmlFileContent($xml_file){ - $buff = FileHandler::readFile($xml_file); - $xml_obj = parent::parse($buff); - if(!$xml_obj) return; - unset($buff); - return $xml_obj; - } - } + /** + * Parses an XML query file + * + * 1. Read xml file
+ * 2. Check the action
+ * 3. Parse and write cache file
+ * + * @param $query_id + * @param $xml_file + * @param $cache_file + * + * @return QueryParser object + */ + function &parse_xml_query($query_id, $xml_file, $cache_file) + { + // Read xml file + $xml_obj = $this->getXmlFileContent($xml_file); + + // insert, update, delete, select action + $action = strtolower($xml_obj->query->attrs->action); + if(!$action) return; + + // Write query cache file + $parser = new QueryParser($xml_obj->query); + FileHandler::writeFile($cache_file, $parser->toString()); + + return $parser; + } + + /** + * Override for parent "parse" method + * + * @param null $query_id + * @param null $xml_file + * @param null $cache_file + * + * @return void + */ + function parse($query_id = NULL, $xml_file = NULL, $cache_file = NULL) + { + $this->parse_xml_query($query_id, $xml_file, $cache_file); + } + + /** + * Returns XML file contents as an object + * or NULL in case of error + * + * @param $xml_file + * @return array|NULL + */ + function getXmlFileContent($xml_file) + { + $buff = FileHandler::readFile($xml_file); + $xml_obj = parent::parse($buff); + if(!$xml_obj) return; + unset($buff); + return $xml_obj; + } +} ?>