public function writeConstants(array $constants)
	{
		
		//common checks
		if(!file_exists($this->file)){
			throw new tao_install_utils_Exception("Unable to write constants: $this->file don't exists!");
		}
		if(!is_readable($this->file) || !is_writable($this->file)){
			throw new tao_install_utils_Exception("Unable to write constants: $this->file must have read and write permissions!");
		}

		$content = file_get_contents($this->file);
		if(!empty($content)){
			foreach($constants as $name => $val){
				
				if(is_string($val)){
					$val = addslashes((string)$val);
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1,\''.addslashes($val).'\');',$content);
				}
				else if(is_bool($val)){
					($val === true) ? $val = 'true' : $val = 'false';
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1, '.$val.');',$content);
				}
				else if(is_numeric($val)){
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1, '.$val.');',$content);
				}
			}
			file_put_contents($this->file, $content);
		}
	}
public function writeConstants(array $constants)
	{
		
		//common checks
		if(!file_exists($this->file)){
			throw new tao_install_utils_Exception("Unable to write constants: $this->file don't exists!");
		}
		if(!is_readable($this->file) || !is_writable($this->file)){
			throw new tao_install_utils_Exception("Unable to write constants: $this->file must have read and write permissions!");
		}

		$content = file_get_contents($this->file);
		if(!empty($content)){
			foreach($constants as $name => $val){
				
				if(is_string($val)){
					$val = addslashes((string)$val);
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1,\''.addslashes($val).'\');',$content);
				}
				else if(is_bool($val)){
					($val === true) ? $val = 'true' : $val = 'false';
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1, '.$val.');',$content);
				}
				else if(is_numeric($val)){
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1, '.$val.');',$content);
				}
			}
			file_put_contents($this->file, $content);
		}
	}
public function writeConstants ( array $ constants ) { //common checks if ( ! file_exists ( $ this -> file ) ) { throw new tao_install_utils_Exception ( "Unable to write constants: $this->file don't exists!" ) ; } if ( ! is_readable ( $ this -> file ) || ! is_writable ( $ this -> file ) ) { throw new tao_install_utils_Exception ( "Unable to write constants: $this->file must have read and write permissions!" ) ; } $ content = file_get_contents ( $ this -> file ) ; if ( ! empty ( $ content ) ) { foreach ( $ constants as $ name => $ val ) { if ( is_string ( $ val ) ) { $ val = addslashes ( ( string ) $ val ) ; $ content = preg_replace ( '/(\'' . $ name . '\')(.*?)$/ms' , '$1,\'' . addslashes ( $ val ) . '\');' , $ content ) ; } else if ( is_bool ( $ val ) ) { ( $ val === true ) ? $ val = 'true' : $ val = 'false' ; $ content = preg_replace ( '/(\'' . $ name . '\')(.*?)$/ms' , '$1, ' . $ val . ');' , $ content ) ; } else if ( is_numeric ( $ val ) ) { $ content = preg_replace ( '/(\'' . $ name . '\')(.*?)$/ms' , '$1, ' . $ val . ');' , $ content ) ; } } file_put_contents ( $ this -> file , $ content ) ; } }
Write the constants into the config file
@param array $constants the list of constants to write (the key is the name of the constant)
@throws tao_install_utils_Exception
Write the constants into the config file