Skip to content

Commit

Permalink
Made inline utility methods to replace it being done in helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindew committed Dec 9, 2010
1 parent 4b2fa05 commit ae62c95
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 43 deletions.
46 changes: 3 additions & 43 deletions lib/helper/sfCombineHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,28 +365,7 @@ function javascript_tag_minified($content = null)
else
{
// minify content
$config = sfConfig::get('app_sfCombinePlugin_js', array());

$combinerClass = isset($config['combiner_class'])
? $config['combiner_class']
: 'sfCombineCombinerJs'
;

$combiner = new $combinerClass(
$config
);

$content = $combiner->minify(
$content,
(isset($config['inline_minify_method'])
? $config['inline_minify_method']
: false
),
(isset($config['inline_minify_method_options'])
? $config['inline_minify_method_options']
: array()
)
);
$content = sfCombineUtility::minifyInlineJs($content);

return javascript_tag($content);
}
Expand Down Expand Up @@ -418,28 +397,9 @@ function style_tag_minified($content = null, array $elementOptions = array())
else
{
// minify content
$config = sfConfig::get('app_sfCombinePlugin_css', array());
$combinerClass = isset($config['combiner_class'])
? $config['combiner_class']
: 'sfCombineCombinerCss';

$combiner = new $combinerClass(
$config
);

$content = $combiner->minify(
$content,
(isset($config['inline_minify_method'])
? $config['inline_minify_method']
: false
),
(isset($config['inline_minify_method_options'])
? $config['inline_minify_method_options']
: array()
)
);
$content = sfCombineUtility::minifyInlineCss($content);

if (!isset($elementOptionsp['type']))
if (!isset($elementOptions['type']))
{
$elementOptions['type'] = 'text/css';
}
Expand Down
75 changes: 75 additions & 0 deletions lib/sfCombineUtility.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,79 @@ static protected function _checkGzipFail()

return $version < 6 || ($version == 6 && strpos($userAgent, 'SV1') === false);
}

/**
*
* @param string $js
* @return string
*/
static public function minifyInlineJs($js)
{
if (!sfConfig::get('app_sfCombinePlugin_enabled', false))
{
return $js;
}

// minify content
$config = sfConfig::get('app_sfCombinePlugin_js', array());

$combinerClass = isset($config['combiner_class'])
? $config['combiner_class']
: 'sfCombineCombinerJs'
;

$combiner = new $combinerClass(
$config
);

$js = $combiner->minify(
$js,
(isset($config['inline_minify_method'])
? $config['inline_minify_method']
: false
),
(isset($config['inline_minify_method_options'])
? $config['inline_minify_method_options']
: array()
)
);

return $js;
}

/**
*
* @param string $css
* @return string
*/
static public function minifyInlineCss($css)
{
if (!sfConfig::get('app_sfCombinePlugin_enabled', false))
{
return $css;
}

$config = sfConfig::get('app_sfCombinePlugin_css', array());
$combinerClass = isset($config['combiner_class'])
? $config['combiner_class']
: 'sfCombineCombinerCss';

$combiner = new $combinerClass(
$config
);

$css = $combiner->minify(
$css,
(isset($config['inline_minify_method'])
? $config['inline_minify_method']
: false
),
(isset($config['inline_minify_method_options'])
? $config['inline_minify_method_options']
: array()
)
);

return $css;
}
}

0 comments on commit ae62c95

Please sign in to comment.