Cytat
Ale coś jest nie tak na końcu, w ostatnich linijkach
Dokladnie.
Nie wiem czy problem nie lezy po stronie html choc w to watpie probowalem tez tresc puszczac przez htmlspecialchars i potem na samym koncu robic html_entity_decode czy jakos tak ale w sumie tez nie dzialalo.
EDIT:
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);
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>';
}
}
}
$html = preg_replace('/{@ assets type="(img|css|js)" path="(.*)" @}/', '', $html); }
}
Taki kod zalatwia sprawe, preg_match_all ma chyba jakis bug...ogolnie rzecz biorac bede musial sie pobawic z preg_replace_callback zeby wsadzilo mi podmieniony kod w znaczniki <head></head>
Tylko jak?
Nie wazne problem rozwiazany chyba preg_match_all ma jakis bug albo ja cos robilem zle, troche na okolo ale dziala:
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' => $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";
}
}
}
$html = preg_replace('/{@ assets type="(img|css|js)" path="(.*)" @}/', '', $html); }
}