From 8dd29e227f44e2379a0a72a4f60130b24e54a14b Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sun, 21 Sep 2008 13:12:41 -0400
Subject: [PATCH] Added a function to merge language files.

---
 interface/lib/classes/ini_parser.inc.php |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/interface/lib/classes/ini_parser.inc.php b/interface/lib/classes/ini_parser.inc.php
index 349990f..67e6542 100644
--- a/interface/lib/classes/ini_parser.inc.php
+++ b/interface/lib/classes/ini_parser.inc.php
@@ -1,4 +1,12 @@
 <?php
+/**
+ * ini parser 
+ * 
+ * @author Till Brehm
+ * @copyright  2005, Till Brehm, projektfarm Gmbh
+ * @version 0.1
+ * @package ISPConfig
+ */
 
 /*
 Copyright (c) 2006, Till Brehm, projektfarm Gmbh
@@ -28,18 +36,17 @@
 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-class ini_parser {
+class ini_parser{
 
-	var $config;
-
-	function parse_ini_string($ini) {
-		$ini = str_replace("\r\n","\n",$ini);
-		$lines = explode("\n",$ini);
-		
+	private $config;
+	
+	//* Converts a ini string to array
+	public function parse_ini_string($ini) {
+		$ini = str_replace("\r\n", "\n", $ini);
+		$lines = explode("\n", $ini);
 		foreach($lines as $line) {
-			
+            $line = trim($line);                
 			if($line != '') {
-				$line = trim($line);
 				if(preg_match("/^\[([\w\d_]+)\]$/", $line, $matches)) {
 					$section = strtolower($matches[1]);
 				} elseif(preg_match("/^([\w\d_]+)=(.*)$/", $line, $matches) && $section != null) {
@@ -50,20 +57,27 @@
 		}
 		return $this->config;
 	}
-
-
-
-	function get_ini_string($file) {
+	
+	
+	//* Converts a config array to a string
+	public function get_ini_string($config_array = '') {
+		if($config_array == '') $config_array = $this->config;
 		$content = '';
-		foreach($this->config as $section => $data) {
+		foreach($config_array as $section => $data) {
 			$content .= "[$section]\n";
 			foreach($data as $item => $value) {
-				if($value != '') $content .= "$item=$value\n";
+				if($item != ''){
+                    $content .= "$item=$value\n";
+                }
 			}
+			$content .= "\n";
 		}
 		return $content;
 	}
-
+	
+	
+	
+	
 }
 
 ?>
\ No newline at end of file

--
Gitblit v1.9.1