public function exportStyleSheet(DataContainer $dc)
	{
		$objStyleSheet = $this->Database->prepare("SELECT * FROM tl_style_sheet WHERE id=?")
										->limit(1)
										->execute($dc->id);

		if ($objStyleSheet->numRows < 1)
		{
			throw new \Exception("Invalid style sheet ID {$dc->id}");
		}

		$vars = array();

		// Get the global theme variables
		$objTheme = $this->Database->prepare("SELECT vars FROM tl_theme WHERE id=?")
								   ->limit(1)
								   ->execute($objStyleSheet->pid);

		if ($objTheme->vars != '')
		{
			if (\is_array(($tmp = StringUtil::deserialize($objTheme->vars))))
			{
				foreach ($tmp as $v)
				{
					$vars[$v['key']] = $v['value'];
				}
			}
		}

		// Merge the global style sheet variables
		if ($objStyleSheet->vars != '')
		{
			if (\is_array(($tmp = StringUtil::deserialize($objStyleSheet->vars))))
			{
				foreach ($tmp as $v)
				{
					$vars[$v['key']] = $v['value'];
				}
			}
		}

		// Sort by key length (see #3316)
		uksort($vars, 'length_sort_desc');

		// Create the file
		$objFile = new File('system/tmp/' . md5(uniqid(mt_rand(), true)));
		$objFile->write('');

		// Add the media query (see #7560)
		if ($objStyleSheet->mediaQuery != '')
		{
			$objFile->append('@media ' . $objStyleSheet->mediaQuery . ' {');
		}

		$objDefinitions = $this->Database->prepare("SELECT * FROM tl_style WHERE pid=? AND invisible!='1' ORDER BY sorting")
										 ->execute($objStyleSheet->id);

		// Append the definition
		while ($objDefinitions->next())
		{
			$objFile->append($this->compileDefinition($objDefinitions->row(), false, $vars, $objStyleSheet->row(), true), '');
		}

		// Close the media query
		if ($objStyleSheet->mediaQuery != '')
		{
			$objFile->append('}');
		}

		$objFile->close();
		$objFile->sendToBrowser($objStyleSheet->name . '.css');
		$objFile->delete();
	}
public function exportStyleSheet(DataContainer $dc)
	{
		$objStyleSheet = $this->Database->prepare("SELECT * FROM tl_style_sheet WHERE id=?")
										->limit(1)
										->execute($dc->id);

		if ($objStyleSheet->numRows < 1)
		{
			throw new \Exception("Invalid style sheet ID {$dc->id}");
		}

		$vars = array();

		// Get the global theme variables
		$objTheme = $this->Database->prepare("SELECT vars FROM tl_theme WHERE id=?")
								   ->limit(1)
								   ->execute($objStyleSheet->pid);

		if ($objTheme->vars != '')
		{
			if (\is_array(($tmp = StringUtil::deserialize($objTheme->vars))))
			{
				foreach ($tmp as $v)
				{
					$vars[$v['key']] = $v['value'];
				}
			}
		}

		// Merge the global style sheet variables
		if ($objStyleSheet->vars != '')
		{
			if (\is_array(($tmp = StringUtil::deserialize($objStyleSheet->vars))))
			{
				foreach ($tmp as $v)
				{
					$vars[$v['key']] = $v['value'];
				}
			}
		}

		// Sort by key length (see #3316)
		uksort($vars, 'length_sort_desc');

		// Create the file
		$objFile = new File('system/tmp/' . md5(uniqid(mt_rand(), true)));
		$objFile->write('');

		// Add the media query (see #7560)
		if ($objStyleSheet->mediaQuery != '')
		{
			$objFile->append('@media ' . $objStyleSheet->mediaQuery . ' {');
		}

		$objDefinitions = $this->Database->prepare("SELECT * FROM tl_style WHERE pid=? AND invisible!='1' ORDER BY sorting")
										 ->execute($objStyleSheet->id);

		// Append the definition
		while ($objDefinitions->next())
		{
			$objFile->append($this->compileDefinition($objDefinitions->row(), false, $vars, $objStyleSheet->row(), true), '');
		}

		// Close the media query
		if ($objStyleSheet->mediaQuery != '')
		{
			$objFile->append('}');
		}

		$objFile->close();
		$objFile->sendToBrowser($objStyleSheet->name . '.css');
		$objFile->delete();
	}
public function exportStyleSheet ( DataContainer $ dc ) { $ objStyleSheet = $ this -> Database -> prepare ( "SELECT * FROM tl_style_sheet WHERE id=?" ) -> limit ( 1 ) -> execute ( $ dc -> id ) ; if ( $ objStyleSheet -> numRows < 1 ) { throw new \ Exception ( "Invalid style sheet ID {$dc->id}" ) ; } $ vars = array ( ) ; // Get the global theme variables $ objTheme = $ this -> Database -> prepare ( "SELECT vars FROM tl_theme WHERE id=?" ) -> limit ( 1 ) -> execute ( $ objStyleSheet -> pid ) ; if ( $ objTheme -> vars != '' ) { if ( \ is_array ( ( $ tmp = StringUtil :: deserialize ( $ objTheme -> vars ) ) ) ) { foreach ( $ tmp as $ v ) { $ vars [ $ v [ 'key' ] ] = $ v [ 'value' ] ; } } } // Merge the global style sheet variables if ( $ objStyleSheet -> vars != '' ) { if ( \ is_array ( ( $ tmp = StringUtil :: deserialize ( $ objStyleSheet -> vars ) ) ) ) { foreach ( $ tmp as $ v ) { $ vars [ $ v [ 'key' ] ] = $ v [ 'value' ] ; } } } // Sort by key length (see #3316) uksort ( $ vars , 'length_sort_desc' ) ; // Create the file $ objFile = new File ( 'system/tmp/' . md5 ( uniqid ( mt_rand ( ) , true ) ) ) ; $ objFile -> write ( '' ) ; // Add the media query (see #7560) if ( $ objStyleSheet -> mediaQuery != '' ) { $ objFile -> append ( '@media ' . $ objStyleSheet -> mediaQuery . ' {' ) ; } $ objDefinitions = $ this -> Database -> prepare ( "SELECT * FROM tl_style WHERE pid=? AND invisible!='1' ORDER BY sorting" ) -> execute ( $ objStyleSheet -> id ) ; // Append the definition while ( $ objDefinitions -> next ( ) ) { $ objFile -> append ( $ this -> compileDefinition ( $ objDefinitions -> row ( ) , false , $ vars , $ objStyleSheet -> row ( ) , true ) , '' ) ; } // Close the media query if ( $ objStyleSheet -> mediaQuery != '' ) { $ objFile -> append ( '}' ) ; } $ objFile -> close ( ) ; $ objFile -> sendToBrowser ( $ objStyleSheet -> name . '.css' ) ; $ objFile -> delete ( ) ; }
Export a style sheet

@param DataContainer $dc

@throws \Exception
Export a style sheet