/** * Returns a <style> tag with the content of all the stylesheets included inline * @method stylesheetsInline * @static * @param {array} [$styles=array()] If not empty, this associative array contains styles which will be * included at the end of the generated <style> tag. * @param {string} [$slotName=null] If provided, returns only the stylesheets added while filling this slot. * @return {string} the style tags and their contents inline */ static function stylesheetsInline($styles = array(), $slotName = null) { if (empty(self::$stylesheets)) { return ''; } $sheets = self::stylesheetsArray($slotName, false); $sheets_for_slots = array(); if (!empty($sheets)) { foreach ($sheets as $stylesheet) { $href = ''; $media = 'screen, print'; $type = 'text/css'; extract($stylesheet, EXTR_IF_EXISTS); $ob = new Q_OutputBuffer(); if (Q_Valid::url($href)) { try { include $href; } catch (Exception $e) { } } else { list($href, $filename) = Q_Html::themedUrlAndFilename($href); try { Q::includeFile($filename); } catch (Exception $e) { } } $sheets_for_slots[$stylesheet['slot']][] = "\n/* Included inline from {$href} */\n" . $ob->getClean(); } } $parts = array(); foreach ($sheets_for_slots as $slot => $texts) { $parts[] = Q_Html::tag('style', array('data-slot' => $slot), implode("\n\n", $texts)); } return implode("", $parts); }