Пример #1
0
 /**
  * Returns an image path according the configured theme
  *
  * @param string $image image name/path
  *
  * @return string path, null if image not found
  */
 public function __invoke($image)
 {
     // Normalize href to account for themes:
     $relPath = 'images/' . $image;
     $currentTheme = ThemeTools::findContainingTheme($relPath);
     if (is_null($currentTheme)) {
         return null;
     }
     $urlHelper = $this->getView()->plugin('url');
     return $urlHelper('home') . "themes/{$currentTheme}/" . $relPath;
 }
Пример #2
0
 /**
  * Create HTML link element from data item
  *
  * @param stdClass $item data item
  *
  * @return string
  */
 public function itemToString(\stdClass $item)
 {
     // Normalize href to account for themes, then call the parent class:
     $relPath = 'css/' . $item->href;
     $currentTheme = ThemeTools::findContainingTheme($relPath);
     if (!empty($currentTheme)) {
         $urlHelper = $this->getView()->plugin('url');
         $item->href = $urlHelper('home') . "themes/{$currentTheme}/" . $relPath;
     }
     return parent::itemToString($item);
 }
Пример #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'];
         $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);
 }
Пример #4
0
 /**
  * Find a file in the themes (return false if no file exists).
  *
  * @param string $path    Relative path of file to find.
  * @param array  $formats Optional array of suffixes to add to $path while
  * searching theme (used to check multiple extensions in each theme).
  *
  * @return string|bool
  */
 protected function searchTheme($path, $formats = array(''))
 {
     // Check all supported image formats:
     $filenames = array();
     foreach ($formats as $format) {
         $filenames[] = $path . $format;
     }
     $fileMatch = ThemeTools::findContainingTheme($filenames, true);
     return empty($fileMatch) ? false : $fileMatch;
 }