Horde_Config::getVersion PHP Метод

getVersion() публичный Метод

Get the Horde version string for a config file.
public getVersion ( string $text ) : string
$text string The text to parse.
Результат string The version string or false if not found.
    public function getVersion($text)
    {
        // Old CVS tag
        if (preg_match('/\\$.*?conf\\.xml,v .*? .*\\$/', $text, $match) || preg_match('/\\$Id:\\s*[0-9a-f]+\\s*\\$/', $text, $match)) {
            return $match[0];
        }
        return false;
    }

Usage Example

Пример #1
0
        $package = $packageFile->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
        if (!$package instanceof PEAR_Error) {
            $packages[$package->getName()] = $package->getVersion();
        }
    }
    try {
        $versions = $hconfig->checkVersions();
    } catch (Horde_Exception $e) {
        $notification->push(_("Could not contact server. Try again later."), 'horde.error');
    }
}
/* Update configurations if requested. */
if ($vars->action == 'config') {
    foreach ($a as $app) {
        $path = $registry->get('fileroot', $app) . '/config';
        if (!file_exists($path . '/conf.xml') || file_exists($path . '/conf.php') && ($xml_ver = $hconfig->getVersion(@file_get_contents($path . '/conf.xml'))) !== false && ($php_ver = $hconfig->getVersion(@file_get_contents($path . '/conf.php'))) !== false && $xml_ver == $php_ver) {
            continue;
        }
        $vars = new Horde_Variables();
        $form = new Horde_Config_Form($vars, $app, true);
        $form->setSubmitted(true);
        if ($form->validate($vars)) {
            $config = new Horde_Config($app);
            if (!$config->writePHPConfig($vars)) {
                $notification->push(sprintf(_("Could not save the configuration file %s. Use one of the options below to save the code."), Horde_Util::realPath($config->configFile())), 'horde.warning', array('content.raw', 'sticky'));
            }
        } else {
            $notification->push(sprintf(_("The configuration for %s cannot be updated automatically. Please update the configuration manually."), $app), 'horde.error');
        }
    }
}