Пример #1
0
 /**
  * Set up header items based on contents of theme resource container.
  *
  * @return void
  */
 public function __invoke()
 {
     $resourceContainer = ThemeTools::getResourceContainer();
     // Set up encoding:
     $headMeta = $this->getView()->plugin('headmeta');
     $headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=' . $resourceContainer->getEncoding());
     // Load CSS (make sure we prepend them in the appropriate order; theme
     // resources should load before extras added by individual templates):
     $headLink = $this->getView()->plugin('headlink');
     foreach (array_reverse($resourceContainer->getCss()) as $current) {
         $parts = explode(':', $current);
         $headLink()->prependStylesheet(trim($parts[0]), isset($parts[1]) ? trim($parts[1]) : 'all', isset($parts[2]) ? trim($parts[2]) : false);
     }
     // Load Javascript (same ordering considerations as CSS, above):
     $headScript = $this->getView()->plugin('headscript');
     foreach (array_reverse($resourceContainer->getJs()) as $current) {
         $parts = explode(':', $current);
         $headScript()->prependFile(trim($parts[0]), 'text/javascript', isset($parts[1]) ? array('conditional' => trim($parts[1])) : array());
     }
     // If we have a favicon, load it now:
     $favicon = $resourceContainer->getFavicon();
     if (!empty($favicon)) {
         $imageLink = $this->getView()->plugin('imagelink');
         $headLink(array('href' => $imageLink($favicon), 'type' => 'image/x-icon', 'rel' => 'shortcut icon'));
     }
 }