changeset 8:6215bb22f3d3

Refactored config handler functions to new library.
author joshjcarrier
date Thu, 13 May 2010 17:43:10 -0700
parents 9790c4a95b14
children 97bc7635ce3f
files admin/application/controllers/hgdir.php admin/application/libraries/hgconf2ini.php admin/application/libraries/hgphp.php admin/application/views/repo_directory.php
diffstat 4 files changed, 390 insertions(+), 187 deletions(-) [+]
line wrap: on
line diff
--- a/admin/application/controllers/hgdir.php	Wed May 12 23:51:08 2010 -0700
+++ b/admin/application/controllers/hgdir.php	Thu May 13 17:43:10 2010 -0700
@@ -12,6 +12,19 @@
 	
 	function index()
 	{
+		/*
+		 * Action handler
+		 */
+		$form_action = $this->input->post('form_action');
+		if($form_action == 'create_repository')
+		{
+			$this->create();
+		}
+		else if($form_action == 'delete_repository')
+		{
+			$this->delete();
+		}		
+		
 		$this->template->title('Repository Directory', 'Mercurial Repository Manager');
 
 		$lsdir = $this->hgphp->lsdir();
@@ -29,40 +42,29 @@
 		}
 		else
 		{
-			$lsdir = $this->hgphp->lsdir();
-			$existingdir = array_keys($lsdir);
+			$create_status = $this->hgphp->create_repository($new_repo_name);
 			
-			// not registered in hgweb.config
-			if(!isset($lsdir[$new_repo_name]))
-			{
-				// create the repository
-				$create_status = $this->hgphp->create_repository($new_repo_name);
-				
-				if($create_status)
-				{
-					// edit the directory
-					$existingdir[$new_repo_name] = $new_repo_name;
-					$create_status = $this->hgphp->saveconf($existingdir);
-					
-					// success message
+			switch($create_status){
+				case 0:
 					$this->template->inject_partial('user_msg', 'Repository "'. $new_repo_name .'" created successfully.');
-				}
-				else
-				{
-					$this->template->inject_partial('user_err', 'Repository "'. $new_repo_name .'" could not be created; insufficient user or server privileges.');
-				}
-			}
-			else if($lsdir[$new_repo_name]['status'] == 2)
-			{
-				$this->template->inject_partial('user_msg', 'Repository "'. $new_repo_name .'" RESTORE.');
-			}
-			else
-			{
-				$this->template->inject_partial('user_err', 'Repository "'. $new_repo_name .'" could not be created; it already exists.');
+					break;
+				case -1:
+					$this->template->inject_partial('user_err', 'Repository "'. $new_repo_name .'" could not be created; insufficient user privileges.');
+					break;
+				case -2:
+					$this->template->inject_partial('user_err', 'Repository "'. $new_repo_name .'" could not be created; insufficient server privileges.');
+					break;
+				case -3:
+					$this->template->inject_partial('user_msg', 'Repository "'. $new_repo_name .'" RESTORE.');
+					break;
+				case -4:
+					$this->template->inject_partial('user_err', 'Repository "'. $new_repo_name .'" could not be created; it already exists.');
+					break;				
+				default:
+					$this->template->inject_partial('user_err', 'Repository "'. $new_repo_name .'" could not be created; an unknown error has occured.');
+					break;
 			}
 		}
-		
-		$this->index();
 	}
 	
 	function delete()
@@ -76,6 +78,26 @@
 		}
 		else
 		{
+			$del_status = $this->hgphp->delete_repository($del_repo_name);
+			
+			switch($del_status){
+				case 0:
+					$this->template->inject_partial('user_msg', 'Repository "'. $del_repo_name .'" deleted successfully.');
+					break;
+				case -1:
+					$this->template->inject_partial('user_err', 'Repository "'. $del_repo_name .'" could not be deleted; insufficient user or server privileges.');
+					break;
+				case -2:
+					$this->template->inject_partial('user_err', 'Repository "'. $del_repo_name .'" could not be deleted; insufficient server privileges.');
+					break;
+				case -3:
+					$this->template->inject_partial('user_err', 'Repository "'. $del_repo_name .'" could not be deleted; it does not exist or is already deleted.');
+					break;
+				default:
+					$this->template->inject_partial('user_err', 'Repository "'. $del_repo_name .'" could not be deleted; an unknown error has occured.');
+					break;
+			}
+			/*
 			$lsdir = $this->hgphp->lsdir();
 			$existingdir = array_keys($lsdir);
 			$tempexistingdir = array();
@@ -114,8 +136,9 @@
 			{
 				$this->template->inject_partial('user_err', 'Repository "'. $del_repo_name .'" could not be deleted; it does not exist or is already deleted.');
 			}
+			*/
 		}
 		
-		$this->index();
+		//$this->index();
 	}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/admin/application/libraries/hgconf2ini.php	Thu May 13 17:43:10 2010 -0700
@@ -0,0 +1,198 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * CodeIgniter Mercurial Config Parser Class
+ * 
+ * Overcomes general PHP ini parsing limitation due to invalid characters in hgwebdir.conf 'Collection' keys when
+ * generating key-value pairs, and handles concurrency.
+ * 
+ * @package        	CodeIgniter
+ * @subpackage    	Libraries
+ * @category    	Libraries
+ * @author 			Josh Carrier
+ * @link			blog.joshjcarrier.com
+ * 
+ */
+class HgConf2Ini
+{
+	function __construct($config = array())
+	{
+		if(!empty($config))
+		{
+			$this->initialize($config);
+		}
+		else
+		{
+			$ci =& get_instance();
+			$ci->config->load('hgphp', TRUE);
+			$this->initialize($ci->config->item('hgphp'));
+		}
+		
+		//$this->_ci =& get_instance();
+        log_message('debug', 'HgConf2Ini class Initialized');
+	}
+	
+	function initialize($config = array())
+	{
+		foreach($config as $key=>$val)
+		{
+			$this->{'_'.$key} = $val;
+		}
+	}
+	
+	
+	/**
+	 * Scans Mercurial's webconf.config configuration file and returns
+	 * representation in key/value pairs.
+	 */
+	function getHgWebDirConfig($fs_hgwebdir = 'hgwebdir.config')
+	{
+		$hgwebconf_all = $this->__hgwebconf_compat_load();
+		
+		return $hgwebconf_all;
+	}
+	
+	function setHgWebDirConfig($hg_hgwebdirconfig, $fs_hgwebdir = 'hgwebdir.config')
+	{
+		return $this->__hgwebconf_compat_persist($hg_hgwebdirconfig);
+	}
+	
+	function getHgWebDirCollections($fs_hgwebdir = 'hgwebdir.config')
+	{
+		$hgwebconf_all = $this->getHgWebDirConfig($fs_hgwebdir);
+		
+		return $hgwebconf_all['collections'];
+	}
+	
+	/**
+	 * Keys in hg_collections are project names.
+	 */
+	function setHgWebDirCollections($hg_collections, $fs_hgwebdir = 'hgwebdir.config')
+	{
+		$hgwebconf_all = $this->getHgWebDirConfig($fs_hgwebdir);
+		
+//		$hgwebconf_collections = array();
+//		foreach($hg_collections as $hg_collection)
+//		{
+//			$hgwebconf_collections[$hg_collection] = $hg_collection;
+//		}
+		$hgwebconf_all['collections'] = $hg_collections;
+		
+		return $this->setHgWebDirConfig($hgwebconf_all, $fs_hgwebdir);
+	}
+	
+	function getHGRC($fs_collection_path, $r_name)
+	{
+		
+	}
+	
+	function setHGRC()
+	{
+		
+	}
+	
+	function touchHGRC($project_name)
+	{
+		$cd = $this->_repositories_rel_dir . $project_name . '/.hg/';
+		
+		// create file
+		touch($cd . 'hgrc');
+		
+		return true;
+	}
+	
+	/**
+	 * Compatibility layer for Mercurial PHP config files,
+	 * which contain forward slashes '\' as key values.
+	 * 
+	 * @return contents of a php_ini array compatible representation
+	 */
+	function __hgwebconf_compat_load()
+	{
+		$hgwebconf_lock_path = $this->_lock_dir . 'hgweb.config.lock';
+		
+		// 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;
+			$hgwebconf_str = file_get_contents($hgwebconf);
+			
+			// replace all occurances of the forward slash '/'
+			$hgwebconf_str = str_replace('/', $this->_compatability_delimiter, $hgwebconf_str);
+			
+			// write temp compatible ini file
+			file_put_contents($hgwebconf_lock_path, $hgwebconf_str);
+		}
+		
+		// load the new compat ini
+		// FIXME minimize the number of times we need to do this
+		$hgwebconf_all = parse_ini_file($hgwebconf_lock_path, true);
+		
+		$hgwebconf_collections = array();
+		if(isset($hgwebconf_all['collections']))
+		{
+			foreach($hgwebconf_all['collections'] as $path => $name)
+			{
+				$hgwebconf_collections[$name] = $name;
+			}
+		}
+		$hgwebconf_all['collections'] = $hgwebconf_collections;
+		
+		return $hgwebconf_all;
+	}
+	
+	/**
+	 * Takes a PHP-compatable php_ini array and converts it back into the original file.
+	 *  
+	 */
+	function __hgwebconf_compat_persist($hgwebconf_all)
+	{
+		$hgwebconf_new_ini = ';Generated by Hg-PHP Mercurial Repository Manager';
+		// generate ini string
+		foreach($hgwebconf_all as $ini_section_name => $ini_section_items)
+		{
+			// section header
+			$hgwebconf_new_ini .= "\n[".$ini_section_name.']';
+			
+			if($ini_section_name == 'collections')
+			{
+				foreach($ini_section_items as $ini_item_name => $ini_item_value)
+				{
+					$hgwebconf_new_ini .= "\n" . $this->_repositories_abs_dir . $ini_item_value . ' = ' . $ini_item_value;
+				}
+			}
+			
+			else
+			{
+				foreach($ini_section_items as $ini_item_name => $ini_item_value)
+				{
+					$hgwebconf_new_ini .= "\n" . $ini_item_name . ' = ' . $ini_item_value;
+				}	
+			}
+			
+			
+		}
+		$hgwebconf_new_ini .= "\n;End generated file\n";
+		
+		// undo the compatibility to allow Mercurial
+		$hgwebconf_new_ini = str_replace($this->_compatability_delimiter, '/', $hgwebconf_new_ini);
+		
+		// FIXME double declared lock path..
+		$hgwebconf_lock_path = $this->_lock_dir . 'hgweb.config.lock';
+		$hgwebconf_tmp_path = $this->_lock_dir . 'hgweb.config.tmp';
+		
+		// persist to disk in a temporary file
+		file_put_contents($hgwebconf_tmp_path, $hgwebconf_new_ini);
+		
+		// TODO concurrency check
+		// overwrite existing hgweb.conf
+		rename($hgwebconf_tmp_path, $this->_hgwebconf_path);
+		
+		// cleanup 
+		unlink($hgwebconf_lock_path);
+		
+		return true;
+	}
+}
\ No newline at end of file
--- a/admin/application/libraries/hgphp.php	Wed May 12 23:51:08 2010 -0700
+++ b/admin/application/libraries/hgphp.php	Thu May 13 17:43:10 2010 -0700
@@ -1,10 +1,12 @@
 <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
 
 /**
- * CodeIgniter Mercurial Config Parser Class
+ * CodeIgniter Mercurial Repository Management class
  * 
  * Scans file system and Mercurial projects directory, allowing
- * web-based manipulation of the hgweb configuration files.
+ * web-based manipulation of the hgwebdir.config and hgrc configuration files.
+ * 
+ * Depends on the HgConf2Ini library.
  * 
  * @package        	CodeIgniter
  * @subpackage    	Libraries
@@ -26,7 +28,8 @@
 		
 		$this->_ci =& get_instance();
 		$this->_ci->lang->load('hgphp');
-        log_message('debug', 'Hg_ConfParser class Initialized');
+		$this->_ci->load->library('hgconf2ini');
+        log_message('debug', 'HgPHP class Initialized');
 	}
 	
 	function initialize($config = array())
@@ -34,7 +37,6 @@
 		foreach($config as $key=>$val)
 		{
 			$this->{'_'.$key} = $val;
-			//echo $key . "<br\>";
 		}
 	}
 	
@@ -52,7 +54,7 @@
 	function lsdir()
 	{
 		$realdir = $this->__realdirscan();
-		$hgwebdir_compat = $this->__hgwebconfscan();
+		$hgwebdir_compat = $this->_ci->hgconf2ini->getHgWebDirCollections();
 				
 		// FIXME test no directory cases
 		$allrepo = array_merge($realdir, $hgwebdir_compat);
@@ -79,16 +81,122 @@
 		return $hgrepos;
 	}
 	
-	function saveconf($collections)
+	/**
+	 * Create a Hg repository by:
+	 * - adding an entry in hgwebdir if not present
+	 * - creating a bare repository if not present
+	 */
+	function create_repository($new_repo_name)
 	{
-		$this->__hgwebconf_compat_persist($collections);
+		// FIXME constants required
+		$return_code = 0;
+		
+		if(!$this->can_create($new_repo_name))
+		{
+			// FIXME constants required
+			return -1;
+		}
+		
+		$lsdir = $this->lsdir();
+		$existingdir = array_keys($lsdir);
+		
+		// not registered in hgweb.config
+		if(!isset($lsdir[$new_repo_name]))
+		{
+			// create the repository
+			$create_status = $this->create_repository_dir($new_repo_name);
+			
+			if($create_status)
+			{
+				// edit the directory
+				$existingdir[$new_repo_name] = $new_repo_name;
+				$create_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir);
+				
+				// success message
+				//$this->template->inject_partial('user_msg', 'Repository "'. $new_repo_name .'" created successfully.');
+				return 0;
+			}
+			else
+			{
+				return -2;
+				//$this->template->inject_partial('user_err', 'Repository "'. $new_repo_name .'" could not be created; insufficient user or server privileges.');
+			}
+		}
+		// TODO repair missing directory?
+		else if($lsdir[$new_repo_name]['status'] == 2)
+		{
+			return -3;
+			//$this->template->inject_partial('user_msg', 'Repository "'. $new_repo_name .'" RESTORE.');
+		}
+		else
+		{
+			return -4;
+			//$this->template->inject_partial('user_err', 'Repository "'. $new_repo_name .'" could not be created; it already exists.');
+		}
+		
 	}
 	
-	/**
-	 * Public accessors - hgrc
-	 */
+	function update_repository()
+	{}
+	
+	function delete_repository($del_repo_name)
+	{
+		$return_code = 0;
+		
+		if(!$this->can_delete($del_repo_name))
+		{
+			// FIXME constants required
+			return -1;
+		}
+		
+		$lsdir = $this->lsdir();
+		$existingdir = array_keys($lsdir);
+		$tempexistingdir = array();
+		foreach($existingdir as $repo_name)
+		{
+			$tempexistingdir[$repo_name] = $repo_name;
+		}
+		$existingdir = $tempexistingdir;
+		
+		if(isset($lsdir[$del_repo_name]))
+		{
+			$del_status = true;
+			
+			// existing filesystem is not missing, thus needs to be deleted
+			if($lsdir[$del_repo_name]['status'] != 2)
+			{
+				$del_status = $this->delete_repository_dir($del_repo_name);
+			}
+			
+			// remove from hgweb.config
+			if($del_status)
+			{
+				// edit the directory
+				unset($existingdir[$del_repo_name]);
+
+				$this->_ci->hgconf2ini->setHgWebDirCollections($existingdir);
+
+				// success message
+				// FIXME constants required
+				return 0;
+//				$this->template->inject_partial('user_msg', 'Repository "'. $del_repo_name .'" deleted successfully.');
+			}
+			else
+			{
+				// FIXME constants required
+				return -2;
+//				$this->template->inject_partial('user_err', 'Repository "'. $del_repo_name .'" could not be deleted; insufficient user or server privileges.');
+			}
+		}
+		else
+		{
+			// FIXME constants required
+			return -3;
+//			$this->template->inject_partial('user_err', 'Repository "'. $del_repo_name .'" could not be deleted; it does not exist or is already deleted.');
+		}
+	}
+	
 	 
-	 /* TODO */
 	 
 	 /**
 	  * Public accessors - permissions
@@ -108,7 +216,7 @@
 	 * Public helpers - filesystem
 	 */
 	 
-	function create_repository($repository_name)
+	function create_repository_dir($repository_name)
 	{
 		if(!$this->can_create($repository_name))
 		{
@@ -116,14 +224,13 @@
 		}
 		
 		$cd = $this->_repositories_rel_dir;
-		mkdir($cd . $repository_name);
 		mkdir($cd . $repository_name . '/.hg/store/data/', 755, TRUE);
 		
 		// create hgrc
-		return $this->__hgrc_persist($repository_name);
+		return $this->_ci->hgconf2ini->touchHGRC($repository_name);
 	}
 	
-	function delete_repository($repository_name)
+	function delete_repository_dir($repository_name)
 	{
 		if(!$this->can_delete($repository_name))
 		{
@@ -165,123 +272,6 @@
 		return $verifiedrealdir;
 	}
 	
-	/**
-	 * Scans Mercurial's webconf.config configuration file, detecting
-	 * registered repositories.
-	 */
-	function __hgwebconfscan()
-	{
-		$hgwebconf_all = $this->__hgwebconf_compat_load();
-		
-		$hgwebconf_collections = array();
-		if(isset($hgwebconf_all['collections']))
-		{
-			foreach($hgwebconf_all['collections'] as $path => $name)
-			{
-				$hgwebconf_collections[$name] = $name;
-			}
-		}
-		
-		return $hgwebconf_collections;
-	}
-	
-	/**
-	 * Compatibility layer for Mercurial PHP config files,
-	 * which contain forward slashes '\' as key values.
-	 * 
-	 * @return contents of a php_ini array compatible representation
-	 */
-	function __hgwebconf_compat_load()
-	{
-		$hgwebconf_lock_path = $this->_lock_dir . 'hgweb.config.lock';
-		
-		// 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
-		// FIXME minimize the number of times we need to do this
-		$hgwebconf_all = parse_ini_file($hgwebconf_lock_path, true);
-		
-		return $hgwebconf_all;
-	}
-	
-	/**
-	 * Takes a PHP-compatable php_ini array and converts it back into the original file.
-	 *  
-	 */
-	function __hgwebconf_compat_persist($hgwebconf_collections)
-	{
-		$hgwebconf_all = $this->__hgwebconf_compat_load();
-		
-		// replace the 'collections' section with the new one
-		$hgwebconf_all['collections'] = $hgwebconf_collections;
-		
-		$hgwebconf_new_ini = ';Generated by Mercurial Repository Manager';
-		// generate ini string
-		foreach($hgwebconf_all as $ini_section_name => $ini_section_items)
-		{
-			// section header
-			$hgwebconf_new_ini .= "\n[".$ini_section_name.']';
-			
-			if($ini_section_name == 'collections')
-			{
-				foreach($ini_section_items as $ini_item_name => $ini_item_value)
-				{
-					$hgwebconf_new_ini .= "\n" . $this->_repositories_abs_dir . $ini_item_value . ' = ' . $ini_item_value;
-				}
-			}
-			
-			else
-			{
-				foreach($ini_section_items as $ini_item_name => $ini_item_value)
-				{
-					$hgwebconf_new_ini .= "\n" . $ini_item_name . ' = ' . $ini_item_value;
-				}	
-			}
-			
-			
-		}
-		$hgwebconf_new_ini .= "\n;End generated file\n";
-		
-		// undo the compatibility to allow Mercurial
-		$hgwebconf_new_ini = str_replace($this->_compatability_delimiter, '/', $hgwebconf_new_ini);
-		
-		// FIXME double declared lock path..
-		$hgwebconf_lock_path = $this->_lock_dir . 'hgweb.config.lock';
-		$hgwebconf_tmp_path = $this->_lock_dir . 'hgweb.config.tmp';
-		
-		// persist to disk in a temporary file
-		file_put_contents($hgwebconf_tmp_path, $hgwebconf_new_ini);
-		
-		// TODO concurrency check
-		// overwrite existing hgweb.conf
-		rename($hgwebconf_tmp_path, $this->_hgwebconf_path);
-		
-		// cleanup 
-		unlink($hgwebconf_lock_path);
-		
-		return true;
-	}
-	
-	
-	
 	
 	
 	function getProjectParams()
@@ -289,20 +279,7 @@
 		return array('ui'=>array('config1'=>'value'));
 	}
 	
-	function setProjectParams($params)
-	{
-		
-	}
-	
-	function __hgrc_persist($project_name, $config = null)
-	{
-		$cd = $this->_repositories_rel_dir . $project_name . '/.hg/';
-		
-		// create file
-		touch($cd . 'hgrc');
-		
-		return true;
-	}
+
 	
 	
 	/**
--- a/admin/application/views/repo_directory.php	Wed May 12 23:51:08 2010 -0700
+++ b/admin/application/views/repo_directory.php	Thu May 13 17:43:10 2010 -0700
@@ -83,14 +83,14 @@
 	</tr>
     <tr> 
         <th></th> 
-        <th><?php echo lang('hg_configparser_title_repo'); ?></th> 
+        <th width="100%"><?php echo lang('hg_configparser_title_repo'); ?></th> 
         <th><?php echo lang('hg_configparser_title_status'); ?></th> 
         <th></th> 
     </tr> 
 <?php $parity=0; if(isset($lsdir)): foreach($lsdir as $repo): ?>
 	<tr class="parity<?php echo $parity; $parity=($parity+1)%2;?>">
 	  <td>
-		<input type="checkbox"/>
+		<input type="checkbox" disabled="disabled"/>
 	  </td>
 	  <td>
 	    <a href="<?php echo site_url('hgrepo/manage/'.$repo['name']); ?>"><?php echo $repo['name']; ?></a>
@@ -105,26 +105,25 @@
 	  	<?php if($repo['status'] == 1): ?>
 	  	<a href="/<?php echo $repo['name']; ?>" target="_blank" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon ui-icon-newwin"></span>Browse</a>
 	  	<?php endif; ?>
-	  	<a href="/<?php echo $repo['name']; ?>" target="_blank" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon"></span><?php print lang('hg_configparser_action_disable'); ?></a>
-	  	<a href="/<?php echo $repo['name']; ?>" target="_blank" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon"></span><?php print lang('hg_configparser_action_delete'); ?></a>
 	  </td>
 	</tr>
 <?php endforeach; endif; ?>
 	<tr>
 	  <td colspan="4">
-		<p><a href="#" id="dialog_link_create" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon ui-icon-newwin"></span><?php print lang('hg_configparser_action_create'); ?></a>
-	  	<a href="#" id="dialog_link_disable" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon ui-icon-newwin"></span><?php print lang('hg_configparser_action_disable'); ?></a>
-		<a href="#" id="dialog_link_delete" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon ui-icon-newwin"></span><?php print lang('hg_configparser_action_delete'); ?></a></p>
+		<p><a href="#" id="dialog_link2_create" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon ui-icon-newwin"></span><?php print lang('hg_configparser_action_create'); ?></a>
+	  	<a href="#" id="dialog_link2_disable" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon ui-icon-newwin"></span><?php print lang('hg_configparser_action_disable'); ?></a>
+		<a href="#" id="dialog_link2_delete" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon ui-icon-newwin"></span><?php print lang('hg_configparser_action_delete'); ?></a></p>
 	  </td>
 	</tr>
 </table>
 
 <!-- ui-dialog -->
 		<div id="dialog_create" class="dialog" title="<?php echo lang('hg_configparser_action_create'); ?>">
-			<form action="/admin/hgdir/create" method="post" id="form_create">
+			<form action="/admin/hgdir" method="post" id="form_create" name="form_create">
 			<table style="width: 100%">
 				<tr>
 					<td>
+						<input type="hidden" name="form_action" value="create_repository" />
 						<input type="text" style="width:100%" name="form_create_name" id="form_create_name"/>
 					</td>
 				</tr>
@@ -135,13 +134,19 @@
 			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
 		</div>
 		<div id="dialog_delete" class="dialog" title="<?php echo lang('hg_configparser_action_delete'); ?>">
-			<form action="/admin/hgdir/delete" method="post" id="form_delete">
+			<form action="/admin/hgdir" method="post" id="form_delete" name="form_delete">
 			<table style="width: 100%">
 				<tr>
 					<td>
-						<input type="text" style="width:100%" name="form_delete_name" id="form_delete_name"/>
+					<input type="hidden" name="form_action" value="delete_repository" />
 						Deleting a repository cannot be undone. The following repositories will be removed:
 						<br />
+						<select style="width:100%" name="form_delete_name" id="form_delete_name">
+							<option selected="selected" value=""></option>
+							<?php if(isset($lsdir)): foreach($lsdir as $repo): ?>
+							<option value="<?php echo $repo['name']; ?>"><?php echo $repo['name']; ?></option>
+							<?php endforeach; endif; ?>
+						</select>
 						<br />
 						Continue and delete specified?
 					</td>