From d3a3a8ba4f403b2c05c0573ca519b7e349a8c657 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 14 Jul 2009 13:11:58 -0600 Subject: [PATCH] Add Horde_Config::getVersion() --- framework/Core/lib/Horde/Config.php | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/framework/Core/lib/Horde/Config.php b/framework/Core/lib/Horde/Config.php index 2961fc8a3..f1a089044 100644 --- a/framework/Core/lib/Horde/Config.php +++ b/framework/Core/lib/Horde/Config.php @@ -128,17 +128,13 @@ class Horde_Config include_once 'Horde/DOM.php'; $doc = Horde_DOM_Document::factory(array('filename' => $path . '/conf.xml')); - /* Check if there is a CVS version tag and store it. */ + /* Check if there is a CVS/Git version tag and store it. */ $node = $doc->first_child(); while (!empty($node)) { - if ($node->type == XML_COMMENT_NODE) { - // @TODO: Old CVS tag - if (preg_match('/\$.*?conf\.xml,v .*? .*\$/', $node->node_value(), $match) || - // New Git tag - preg_match('/\$Id:\s*[0-9a-f]+\s*\$/', $node->node_value(), $match)) { - $this->_versionTag = $match[0] . "\n"; - break; - } + if (($node->type == XML_COMMENT_NODE) && + ($vers_tag = $this->getVersion($node->node_value()))) { + $this->_versionTag = $vers_tag . "\n"; + break; } $node = $node->next_sibling(); } @@ -154,6 +150,25 @@ class Horde_Config } /** + * Get the Horde version string for a config file. + * + * @param string $text The text to parse. + * + * @return string The version string or false if not found. + */ + static public function getVersion($text) + { + // @TODO: Old CVS tag + if (preg_match('/\$.*?conf\.xml,v .*? .*\$/', $text, $match) || + // New Git tag + preg_match('/\$Id:\s*[0-9a-f]+\s*\$/', $text, $match)) { + return $match[0]; + } + + return false; + } + + /** * Returns the file content of the current configuration file. * * @return string The unparsed configuration file content. -- 2.11.0