Ejemplo n.º 1
0
function a_get_stylesheets()
{
    $newStylesheets = array();
    $response = sfContext::getInstance()->getResponse();
    foreach ($response->getStylesheets() as $file => $options) {
        if (preg_match('/\\.less$/', $file)) {
            $absolute = false;
            if (isset($options['absolute']) && $options['absolute']) {
                unset($options['absolute']);
                $absolute = true;
            }
            if (!isset($options['raw_name'])) {
                $file = stylesheet_path($file, $absolute);
                $request = sfContext::getInstance()->getRequest();
                $sf_relative_url_root = $request->getRelativeUrlRoot();
                if (strlen($sf_relative_url_root)) {
                    $file = preg_replace('/^' . preg_quote($sf_relative_url_root, '/') . '/', '', $file);
                }
            }
            $path = sfConfig::get('sf_web_dir') . $file;
            $name = aAssets::getLessBasename($file);
            $compiled = aFiles::getUploadFolder(array('asset-cache')) . '/' . $name;
            aAssets::compileLessIfNeeded($path, $compiled);
            $newStylesheets[sfConfig::get('app_a_assetCacheUrl', '/uploads/asset-cache') . '/' . $name] = $options;
        } else {
            $newStylesheets[$file] = $options;
        }
    }
    return _a_get_assets_body('stylesheets', $newStylesheets);
}