/** * Build link tags to one or more stylesheet assets * * @param mixed One or more assets, optionally followed by an * array describing options to apply to the tags * generated for these assets.<br> Each asset is a * string in one of the formats accepted as value * of the $source argument of * {@link stylesheet_path()}.<br> The optional last * argument is an array whose keys are names of * attributes of the link tag and whose corresponding * values are the values assigned to each * attribute. If omitted, options default to: * <ul> * <li>"rel" => "Stylesheet"</li> * <li>"type" => "text/css"</li> * <li>"media" => "screen"</li> * <li>"href" => <i>path-to-source</i></li> * </ul> * @return string A link tag for each asset in the argument list * @uses stylesheet_path() * @uses tag() */ function stylesheet_link_tag() { if (func_num_args() > 0) { $sources = func_get_args(); $options = is_array(end($sources)) ? array_pop($sources) : array(); $contents = array(); foreach ($sources as $source) { $ap = new AssetPipeline(); if ($source == 'application' && $ap->compile()) { $css_files = $ap->files_for_stylesheet_link_tag(); } else { $css_files = array($source); } foreach ($css_files as $css_file) { $source = $this->stylesheet_path($css_file); $contents[] = $this->tag("link", array_merge(array("rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => $source), $options)); } } return implode(" ", $contents); } }