/** * Sets configuration settings or returns a configuration setting. * * @param * mixed array: configuration settings; string: configuration setting to return * @return string configuration setting. Null if setting does not exist. */ public function config($config) { if (is_array($config)) { self::$config = array_merge(self::$defaultConfig, $config); self::setDefaults(); } elseif (is_string($config) && isset(self::$config[$config])) { return self::$config[$config]; } }
private function real_path($image_file) { $path = $image_file->value; # Compute the real path to the image on the file stystem if the images_dir is set. if (SassExtentionsCompassConfig::config('images_path')) { return SassExtentionsCompassConfig::config('images_path') . DIRECTORY_SEPARATOR . $path; } else { return SassExtentionsCompassConfig::config('project_path') . DIRECTORY_SEPARATOR . $path; } }
public function inline_font_files() { if (func_num_args() % 2) { throw new SassScriptFunctionException('An even number of arguments must be passed to inline_font_files()', array(), SassScriptParser::$context->node); } $args = func_get_args(); $files = array(); while ($args) { $path = array_shift($args); $real_path = SassExtentionsCompassConfig::config('fonts_path') . DIRECTORY_SEPARATOR . $path->value; $fp = fopen($real_path, 'rb'); $url = 'url(data:' . self::compute_mime_type($path) . ';base64,' . self::data($real_path) . ')'; $files[] = "{$url} format('" . array_shift($args) . "')"; } return new SassString(join(", ", $files)); }
public function image_url($path, $only_path = null) { $path = $path->value; # get to the string value of the literal. if (preg_match('%^'.preg_quote(SassExtentionsCompassConfig::config('http_images_path'), '%').'/(.*)%',$path, $matches)) # Treat root relative urls (without a protocol) like normal if they start with # the images $path. $path = $matches[1]; elseif (self::is_absolute_path($path)) # Short curcuit if they have provided an absolute url. return new SassString("url('$path')"); # Compute the $path to the image, either root relative or stylesheet relative # or nil if the http_images_path is not set in the configuration. if (SassExtentionsCompassConfig::config('relative_assets')) $http_images_path = self::compute_relative_path(SassExtentionsCompassConfig::config('images_path')); elseif (SassExtentionsCompassConfig::config('http_images_path')) $http_images_path = SassExtentionsCompassConfig::config('http_images_path'); else $http_images_path = SassExtentionsCompassConfig::config('images_dir'); # Compute the real $path to the image on the file stystem if the images_dir is set. if (SassExtentionsCompassConfig::config('images_dir')) $real_path = SassExtentionsCompassConfig::config('project_path'). DIRECTORY_SEPARATOR.SassExtentionsCompassConfig::config('images_dir'). DIRECTORY_SEPARATOR.$path; # prepend the $path to the image if there's one if ($http_images_path) { $http_images_path .= (substr($http_images_path, -1) === '/' ? '' : '/'); $path = $http_images_path.$path; } /* # Compute the asset host unless in relative mode. asset_host = if !(self::relative()) && Compass.configuration.asset_host Compass.configuration.asset_host.call($path) } # Compute and append the cache buster if there is one. if buster = compute_cache_buster($path, real_path) $path += "?#{buster}" } # prepend the asset host if there is one. $path = "#{asset_host}#{'/' unless $path[0..0] == "/"}#{$path}" if asset_host*/ return new SassString(self::clean($path, $only_path)); }