diff admin/application/libraries/hg_confparser.php @ 0:9124b60de5a6

CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
author joshjcarrier
date Tue, 27 Apr 2010 22:42:57 -0700
parents
children 2d2757428cc6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/admin/application/libraries/hg_confparser.php	Tue Apr 27 22:42:57 2010 -0700
@@ -0,0 +1,91 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * CodeIgniter Mercurial Config Parser Class
+ * 
+ * Scans file system and Mercurial projects directory, allowing
+ * web-based manipulation of the hgweb configuration files.
+ * 
+ * @package        	CodeIgniter
+ * @subpackage    	Libraries
+ * @category    	Libraries
+ * @author 			Josh Carrier
+ * @link			blog.joshjcarrier.com
+ * 
+ */
+class Hg_ConfParser
+{
+	private $_ci;
+	
+	function __construct($config = array())
+	{
+		if(!empty($config))
+		{
+			$this->initialize($config);
+		}
+		
+		$this->_ci =& get_instance();
+		$this->_ci->lang->load('hg_confparser');
+        log_message('debug', 'Hg_ConfParser class Initialized');
+	}
+	
+	function initialize($config = array())
+	{
+		foreach($config as $key=>$val)
+		{
+			$this->{'_'.$key} = $val;
+			//echo $key . "<br\>";
+		}
+	}
+	
+	/*
+	 * Returns a list of available repositories.
+	 * Will show up if: detected in repo directory
+	 * Will have status "enabled" if: detected in hgweb.config
+	 * 
+	 * @return an array of 0 or more detected repositories
+	 */
+	function lsdir()
+	{
+		$realdir = $this->__realdirscan();
+		
+		//$dirs = array_diff($realdir, $hgwebdir);
+		return $realdir;//array('projectx'=>'path', 'projecty'=>'path2');
+	}
+	
+	/*
+	 * Performs a real directory scan where the projects are suppose to reside.
+	 * 
+	 * @return the array containing 0 or more valid directories
+	 */
+	function __realdirscan()
+	{
+		$this->_ci->load->helper('directory');
+		
+		// FIXME this doesn't check if file or directory...
+		$realdir = directory_map($this->_repositories_dir, TRUE);
+		
+		$verifiedrealdir = array();
+		foreach($realdir as $file)
+		{
+			// checks if we detected a folder
+			if(is_dir($this->_repositories_dir . $file))
+			{
+				$verifiedrealdir[] = $file;
+			}
+		}
+		
+		return $verifiedrealdir;
+	}
+	
+	function getProjectParams()
+	{
+		return array('ui'=>array('config1'=>'value'));
+	}
+	
+	function setProjectParams($params)
+	{
+		
+	}
+	
+}