Witam mam problem z ktorym nie potrafie sie uborykac.
Mianowicie mam koncowy kod html mojej strony, jako ze strona sklada sie komponentow/plugin-ow/widget-ow nie moge w glownym widoku strony importowac wszyskich plikow .css/.js i do tego kod inline css/js wiec w widokach ktore potrzebuja ten kod postanowilem uzyc tagi typu:

{@ assets type="css" path="sss/ddds/kod.css" @}
{@ assets type="js" path="sss/ddds/kod.js" @}
{@ javascripts @}
	$(document).ready(function() {
		// put all your jQuery goodness in here.
	});
{@ end @}
{@ css @}
	#login{
		width: 100px;
	}
{@ end @}

Ktore ma zostac zamieniony na odpowiednie znaczniki z odpowiednik kodem/plikiem przed render-owaniem strony.
Uzywam do tege event dispatcher i wszystko dziala jesli chodzi o {@ assets ... @}, jednak dla kodu {@ javascripts @}/{@ css @} juz nie dziala prawidlowo.
Probowalem juz na kilka sposobow jesli chodzi o regexp ale jestem w nich slabiutki xD taki jest kod:

<?php 

/**
*Volta framework

*@author marcio <[email protected]>, <[email protected]>
*@copyright Copyright (c) 2012, marcio
*@version 1.0
*/

class Vf_Assets
{
	public function replaceAssets($html)
	{
		preg_match_all('/{@ assets type="(img|css|js)" path="(.*)" @}/', $html, $assets_external);
		preg_match_all('/^{@ (javascripts|css) @}(.*?){@ end @}$/s', $html, $assets_inline);
		print_r($assets_inline);
		$css = array();
		$css_inline = array();
		$js = array();
		$js_inline = array();
		
		if(sizeof($assets_external[1]) > 0)
		{
			foreach($assets_external[1] as $key => $type)
			{
				if($type == 'css')
				{
					$css[] = '<link rel="stylesheet" type="text/css" href="'.$assets_external[2][$key].'" />';
				}
				else if($type == 'js')
				{
					$js[] =  '<script type="text/javascript" src="'.$assets_external[2][$key].'"></script>';
				}
			}
		}
		if(sizeof($assets_inline[1]) > 0)
		{
			foreach($assets_inline[1] as $key => $type)
			{
				if($type == 'css')
				{
					$css_inline[] = '<script type="text/css">'.$assets_inline[2][$key].'</script>';
				}
				else if($type == 'javascripts')
				{
					$js_inline[] =  '<script type="text/javascript">'.$assets_inline[2][$key].'</script>';
				}
			}
		}
		
		$cssString = implode("", array_merge($css, $css_inline));
		$jsString = implode("", array_merge($js, $js_inline));
		$html = str_replace(array('{@ css @}', '{@ javascripts @}'), array($cssString, $jsString), $html);
		$html = preg_replace('/{@ assets type="(img|css|js)" path="(.*)" @}/', '', $html);
		$html = preg_replace('/^{@ (javascripts|css) @}(.*?){@ end @}$/s', '', $html);
	}
}

?>

Jednak nie daje mi rezultatu jaki oczekuje...
Czy ktos z was wie jak to zrobic?

Nie wazne problem rozwiazany, chyba preg_match_all ma jakis bug.

class Vf_Assets
{
	public function replaceAssets($html)
	{
		preg_match_all('/{@ assets type="(css|js)" path="(.*)" @}/', $html, $assets_external);
		$html = preg_replace('/{@ css_inline @}(.*?){@ end @}/s', '<style type="text/css">\\1</style>', $html);
		$html = preg_replace('/{@ js_inline @}(.*?){@ end @}/s', '<script type="text/javascript">\\1</script>', $html);
		preg_match_all('/<script type="text\/javascript">(.*?)<\/script>/s', $html, $assets_inline_js);
		preg_match_all('/<style type="text\/css">(.*?)<\/style>/s', $html, $assets_inline_css);
		$html = preg_replace('/<style type="text\/css">(.*?)<\/style>/s', '', $html);
		$html = preg_replace('/<script type="text\/javascript">(.*?)<\/script>/s', '', $html);
		
		$css_inline = array();
		$js_inline = array();
		$css = array();
		$js = array();
		$inlines = array(
							'css' => $assets_inline_css[1],
							'js' => $assets_inline_js[1]
						);
		
		if(sizeof($assets_external[1]) > 0)
		{
			foreach($assets_external[1] as $key => $type)
			{
				if($type == 'css')
				{
					$css[] = '<link rel="stylesheet" type="text/css" href="'.$assets_external[2][$key].'" />';
				}
				else if($type == 'js')
				{
					$js[] =  '<script type="text/javascript" src="'.$assets_external[2][$key].'"></script>';
				}
			}
		}

		foreach($inlines as $type => $inline)
		{
			if($type == 'css')
			{
				foreach($inline as $code)
				{
					$css_inline[] = "\n<style type=\"text/css\">".$code."</style>\n";
				}
			}
			else if($type == 'js')
			{
				foreach($inline as $code)
				{
					$js_inline[] = "\n<script type=\"text/javascript\">".$code."</script>\n";
				}
			}
		}
		
		$cssString = implode("", array_merge($css, $css_inline));
		$jsString = implode("", array_merge($js, $js_inline));
		$html = str_replace(array('{@ css @}', '{@ javascripts @}'), array($cssString, $jsString), $html);
		$html = preg_replace('/{@ assets type="(img|css|js)" path="(.*)" @}/', '', $html);
	}
}