Пример #1
0
 /**
  * Returns a <style> tag with the content of all the stylesheets included inline
  * 
  * @param $styles
  * If not empty, this associative array contains styles which will be
  * included at the end of the generated <style> tag.
  * @param string $slot_name
  *  Optional. 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(), $slot_name = null)
 {
     $styles = self::stylesInline($slot_name, false);
     if (empty($styles) and empty(self::$stylesheets)) {
         return '';
     }
     $return = "<style type='text/css'>\n";
     if (!empty(self::$stylesheets)) {
         foreach (self::$stylesheets as $stylesheet) {
             $href = '';
             $media = 'screen, print';
             $type = 'text/css';
             extract($stylesheet, EXTR_IF_EXISTS);
             $ob = new Pie_OutputBuffer();
             if (Pie_Valid::url($href)) {
                 try {
                     include $href;
                 } catch (Exception $e) {
                 }
             } else {
                 list($href, $filename) = Pie_Html::themedUrlAndFilename($href);
                 try {
                     Pie::includeFile($filename);
                 } catch (Exception $e) {
                 }
             }
             $stylesheet = "\n/* Included inline from {$href} */\n" . $ob->getClean();
             $return .= "{$stylesheet}\n";
         }
     }
     $return .= "/* Included inline from Pie_Response::stylesInline() */\n";
     $return .= $styles;
     $return .= "\n</style>";
     return $return;
 }