src/FS/File/CSS/Combiner.php
public function combineString( $path, $content, $throwException = FALSE )
	{
		$listLines	= array();
		$listImport	= array();
		$this->statistics['sizeOriginal']	= 0;
		$this->statistics['sizeCombined']	= 0;
		$this->statistics['sizeCompressed']	= 0;
		$this->statistics['numberFiles']	= 0;
		$this->statistics['filesFound']		= array();
		$this->statistics['filesSkipped']	= array();
		$content	= preg_replace( '/\/\*.+\*\//sU', '', $content );
		$lines		= explode( "\n", $content );
		foreach( $lines as $line )
		{
			$line	= trim( $line );
			if( !$line )
				continue;
			if( preg_match( $this->importPattern, $line ) )
			{
				preg_match_all( $this->importPattern, $line, $matches );
				$fileName	= $matches[2][0];
				$this->statistics['filesFound'][]	= $fileName;

				if( !file_exists( $path.$fileName ) )
				{
					if( $throwException )
						throw new RuntimeException( 'CSS File "'.$fileName.'" is not existing.' );
					$this->statistics['filesSkipped'][] = $fileName;
					continue;
				}

				$content	= file_get_contents( $path.$fileName );
				$content	= $this->reviseStyle( $content );
				$this->statistics['numberFiles']	++;
				$this->statistics['sizeOriginal']	+= strlen( $content );
//			$depth	= substr
				if( substr_count( $fileName, "/" ) )
					$content	= preg_replace( "@(\.\./){1}([^\.])@i", "\\2", $content );
				$listImport[]	= "/*  --  ".$fileName."  --  */";
				$listImport[]	= $content."\n";
			}
			else
				$listLines[]	= $line;
		}
		$content	= implode( "\n", $listImport ).implode( "\n", $listLines );
		$this->statistics['sizeCombined']	= strlen( $content );
		return $content;
	}
public function combineString( $path, $content, $throwException = FALSE )
	{
		$listLines	= array();
		$listImport	= array();
		$this->statistics['sizeOriginal']	= 0;
		$this->statistics['sizeCombined']	= 0;
		$this->statistics['sizeCompressed']	= 0;
		$this->statistics['numberFiles']	= 0;
		$this->statistics['filesFound']		= array();
		$this->statistics['filesSkipped']	= array();
		$content	= preg_replace( '/\/\*.+\*\//sU', '', $content );
		$lines		= explode( "\n", $content );
		foreach( $lines as $line )
		{
			$line	= trim( $line );
			if( !$line )
				continue;
			if( preg_match( $this->importPattern, $line ) )
			{
				preg_match_all( $this->importPattern, $line, $matches );
				$fileName	= $matches[2][0];
				$this->statistics['filesFound'][]	= $fileName;

				if( !file_exists( $path.$fileName ) )
				{
					if( $throwException )
						throw new RuntimeException( 'CSS File "'.$fileName.'" is not existing.' );
					$this->statistics['filesSkipped'][] = $fileName;
					continue;
				}

				$content	= file_get_contents( $path.$fileName );
				$content	= $this->reviseStyle( $content );
				$this->statistics['numberFiles']	++;
				$this->statistics['sizeOriginal']	+= strlen( $content );
//			$depth	= substr
				if( substr_count( $fileName, "/" ) )
					$content	= preg_replace( "@(\.\./){1}([^\.])@i", "\\2", $content );
				$listImport[]	= "/*  --  ".$fileName."  --  */";
				$listImport[]	= $content."\n";
			}
			else
				$listLines[]	= $line;
		}
		$content	= implode( "\n", $listImport ).implode( "\n", $listLines );
		$this->statistics['sizeCombined']	= strlen( $content );
		return $content;
	}
public function combineString ( $ path , $ content , $ throwException = FALSE ) { $ listLines = array ( ) ; $ listImport = array ( ) ; $ this -> statistics [ 'sizeOriginal' ] = 0 ; $ this -> statistics [ 'sizeCombined' ] = 0 ; $ this -> statistics [ 'sizeCompressed' ] = 0 ; $ this -> statistics [ 'numberFiles' ] = 0 ; $ this -> statistics [ 'filesFound' ] = array ( ) ; $ this -> statistics [ 'filesSkipped' ] = array ( ) ; $ content = preg_replace ( '/\/\*.+\*\//sU' , '' , $ content ) ; $ lines = explode ( "\n" , $ content ) ; foreach ( $ lines as $ line ) { $ line = trim ( $ line ) ; if ( ! $ line ) continue ; if ( preg_match ( $ this -> importPattern , $ line ) ) { preg_match_all ( $ this -> importPattern , $ line , $ matches ) ; $ fileName = $ matches [ 2 ] [ 0 ] ; $ this -> statistics [ 'filesFound' ] [ ] = $ fileName ; if ( ! file_exists ( $ path . $ fileName ) ) { if ( $ throwException ) throw new RuntimeException ( 'CSS File "' . $ fileName . '" is not existing.' ) ; $ this -> statistics [ 'filesSkipped' ] [ ] = $ fileName ; continue ; } $ content = file_get_contents ( $ path . $ fileName ) ; $ content = $ this -> reviseStyle ( $ content ) ; $ this -> statistics [ 'numberFiles' ] ++ ; $ this -> statistics [ 'sizeOriginal' ] += strlen ( $ content ) ; //			$depth	= substr if ( substr_count ( $ fileName , "/" ) ) $ content = preg_replace ( "@(\.\./){1}([^\.])@i" , "\\2" , $ content ) ; $ listImport [ ] = "/*  --  " . $ fileName . "  --  */" ; $ listImport [ ] = $ content . "\n" ; } else $ listLines [ ] = $ line ; } $ content = implode ( "\n" , $ listImport ) . implode ( "\n" , $ listLines ) ; $ this -> statistics [ 'sizeCombined' ] = strlen ( $ content ) ; return $ content ; }
Combines all CSS Files imported in CSS String and returns Combination String;
@access		public
@param		string		$path			Style Path
@param		string		$styleFile		File Name of Style without Extension (iE. style.css,import.css,default.css)
@return		string
Combines all CSS Files imported in CSS String and returns Combination String ;