示例#1
0
 /**
  * Adds a linked stylesheet from a component to the page
  *
  * @param   string  $component   Component name
  * @param   string  $stylesheet  Stylesheet name (optional, uses component name if left blank)
  * @param   string  $dir         Asset directory to look in
  * @return  void
  */
 public static function addComponentStylesheet($component, $stylesheet = '', $dir = 'css')
 {
     if ($dir != 'css') {
         $stylesheet = $dir . '/' . $stylesheet;
     }
     $asset = new Stylesheet($component, $stylesheet);
     if (defined('JPATH_GROUPCOMPONENT')) {
         $base = substr(JPATH_GROUPCOMPONENT, strlen(PATH_ROOT));
         $asset->setPath('source', $base . DS . 'assets' . DS . 'css' . DS . $asset->file());
         $asset->setPath('override', $base . DS . 'assets' . DS . 'css' . DS . $asset->file());
     }
     if ($asset->exists()) {
         if ($document = self::app('document')) {
             $document->addStyleSheet($asset->link());
         }
     }
 }