Exemple #1
0
 /**
  * Create script HTML
  *
  * @param mixed  $item        Item to convert
  * @param string $indent      String to add before the item
  * @param string $escapeStart Starting sequence
  * @param string $escapeEnd   Ending sequence
  *
  * @return string
  */
 public function itemToString($item, $indent, $escapeStart, $escapeEnd)
 {
     // Normalize href to account for themes:
     if (!empty($item->attributes['src'])) {
         $relPath = 'js/' . $item->attributes['src'];
         $currentTheme = ThemeTools::findContainingTheme($relPath);
         if (!empty($currentTheme)) {
             $urlHelper = $this->getView()->plugin('url');
             $item->attributes['src'] = $urlHelper('home') . "themes/{$currentTheme}/" . $relPath;
         }
     }
     return parent::itemToString($item, $indent, $escapeStart, $escapeEnd);
 }
 /**
  * Create script HTML
  *
  * @param  mixed  $item        Item to convert
  * @param  string $indent      String to add before the item
  * @param  string $escapeStart Starting sequence
  * @param  string $escapeEnd   Ending sequence
  * @return string
  */
 public function itemToString($item, $indent, $escapeStart, $escapeEnd)
 {
     if (!empty($item->source)) {
         $config = $this->getServiceLocator()->getServiceLocator()->get('Config');
         $config = $config['TpMinify']['helpers']['headScript'];
         if ($config['enabled']) {
             $result = Minify::serve('Files', array_merge($config, array('quiet' => true, 'encodeOutput' => false, 'files' => new \Minify_Source(array('contentType' => Minify::TYPE_JS, 'content' => $item->source, 'id' => __CLASS__ . hash('crc32', $item->source))))));
             if ($result['success']) {
                 $item->source = $result['content'];
             }
         }
     }
     return parent::itemToString($item, $indent, $escapeStart, $escapeEnd);
 }
Exemple #3
0
 /**
  * Create script HTML
  *
  * @param mixed  $item        Item to convert
  * @param string $indent      String to add before the item
  * @param string $escapeStart Starting sequence
  * @param string $escapeEnd   Ending sequence
  *
  * @return string
  */
 public function itemToString($item, $indent, $escapeStart, $escapeEnd)
 {
     // Normalize href to account for themes:
     if (!empty($item->attributes['src'])) {
         $relPath = 'js/' . $item->attributes['src'];
         $details = $this->themeInfo->findContainingTheme($relPath, ThemeInfo::RETURN_ALL_DETAILS);
         if (!empty($details)) {
             $urlHelper = $this->getView()->plugin('url');
             $url = $urlHelper('home') . "themes/{$details['theme']}/" . $relPath;
             $url .= strstr($url, '?') ? '&_=' : '?_=';
             $url .= filemtime($details['path']);
             $item->attributes['src'] = $url;
         }
     }
     return parent::itemToString($item, $indent, $escapeStart, $escapeEnd);
 }
 /**
  * Create script HTML
  *
  * @param  mixed  $item        Item to convert
  * @param  string $indent      String to add before the item
  * @param  string $escapeStart Starting sequence
  * @param  string $escapeEnd   Ending sequence
  * @return string
  */
 public function itemToString($item, $indent, $escapeStart, $escapeEnd)
 {
     if (isset($item->attributes) && !empty($item->attributes['src'])) {
         $src = $item->attributes['src'];
         $item->attributes['src'] = $this->startsWith($src, '//') || $this->startsWith($src, 'http') || $this->startsWith($src, 'ftp') ? $src : $this->view->mediapath($src);
     }
     return parent::itemToString($item, $indent, $escapeStart, $escapeEnd);
 }