Mercurial > public > src > phphgadmin
diff admin/application/libraries/hg_confparser.php @ 2:492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
author | joshjcarrier |
---|---|
date | Wed, 28 Apr 2010 02:07:10 -0700 |
parents | 2d2757428cc6 |
children | 53341b414217 |
line wrap: on
line diff
--- a/admin/application/libraries/hg_confparser.php Wed Apr 28 00:24:40 2010 -0700 +++ b/admin/application/libraries/hg_confparser.php Wed Apr 28 02:07:10 2010 -0700 @@ -49,24 +49,24 @@ { $realdir = $this->__realdirscan(); $hgwebdir_compat = $this->__hgwebconfscan(); - + // FIXME test no directory cases - $allrepo = array_merge($realdir, array_keys($hgwebdir_compat['collections'])); + $allrepo = array_merge($realdir, $hgwebdir_compat); $hgrepos = array(); foreach($allrepo as $repo) { $hgrepos[$repo]['name'] = $repo; - if(isset($realdir[$repo]) && isset($hgwebdir_compat['collections'][$repo])) + if(isset($realdir[$repo]) && isset($hgwebdir_compat[$repo])) { $hgrepos[$repo]['status'] = 1; } - else if(isset($realdir[$repo]) && !isset($hgwebdir_compat['collections'][$repo])) + else if(isset($realdir[$repo]) && !isset($hgwebdir_compat[$repo])) { $hgrepos[$repo]['status'] = 0; } - else if(!isset($realdir[$repo]) && isset($hgwebdir_compat['collections'][$repo])) + else if(!isset($realdir[$repo]) && isset($hgwebdir_compat[$repo])) { $hgrepos[$repo]['status'] = 2; } @@ -119,22 +119,42 @@ */ function __hgwebconf_compat_load() { - // load the PHP to file - $hgwebconf = $this->_hgwebconf_path; - $fh = fopen($hgwebconf, 'r'); - $hgwebconf_str = fread($fh, filesize($hgwebconf)); - fclose($fh); + $hgwebconf_lock_path = $this->_lock_dir . 'hgweb.config.lock'; - // replace all occurances of the forward slash '/' - $hgwebconf_str = str_replace('/', $this->_compatability_delimiter, $hgwebconf_str); + // need to regenerate lock? (a php ini-parseable file) + // FIXME also compare timestamps, block other user access? + if(!is_readable($hgwebconf_lock_path)) + { + // load the PHP to file + $hgwebconf = $this->_hgwebconf_path; + //$fh = fopen($hgwebconf, 'r'); + $hgwebconf_str = file_get_contents($hgwebconf);//fread($fh, filesize($hgwebconf)); + //fclose($fh); + + // replace all occurances of the forward slash '/' + $hgwebconf_str = str_replace('/', $this->_compatability_delimiter, $hgwebconf_str); + + // write temp compatible ini file + //$fh = fopen($hgwebconf_lock_path, 'w+'); + //fwrite($fh, $hgwebconf_str); + //fclose($fh); + file_put_contents($hgwebconf_lock_path, $hgwebconf_str); + } // load the new compat ini - $hgwebconf = parse_ini_string($hgwebconf_str, TRUE); + // FIXME minimize the number of times we need to do this + $hgwebconf_all = parse_ini_file($hgwebconf_lock_path, true); - // orients the collections properly - $hgwebconf['collections'] = array_flip($hgwebconf['collections']); + $hgwebconf_collections = array(); + if(isset($hgwebconf_all['collections'])) + { + foreach($hgwebconf_all['collections'] as $path => $name) + { + $hgwebconf_collections[$name] = $name; + } + } - return $hgwebconf; + return $hgwebconf_collections; } /**