Beispiel #1
0
 /**
  * Gets the media item file in the correct format and passes it through PHP
  *
  * @param array $item
  * @param string $format
  * @return bool
  */
 protected function displayFormat(array $item, $format)
 {
     if ($format == 'thumb') {
         $file = $item['path_fs'] . '/' . $item['thumbnail'];
     } else {
         if ($item['type'] == 'image') {
             /**
              * Get either full or medium sized image, however no large than
              * the specified max width.
              */
             $imgPath = $item['path_fs'] . '/' . $item['filename'];
             if (is_file($imgPath)) {
                 list($imgWidth) = getimagesize($imgPath);
                 $maxWidth = $this->_config->get('media/max_image_width');
                 if ($format == 'medium') {
                     // Display the medium size image no wider than the themes content
                     try {
                         $contentWidth = $this->_theme->getDetail('contentWidth');
                     } catch (Theme_DetailNoExist $e) {
                         $contentWidth = 500;
                     }
                     if ($contentWidth < $maxWidth) {
                         $maxWidth = $contentWidth;
                     }
                 }
                 // Resize and add watermark if needed
                 $wmPath = $this->_zula->getDir('uploads') . '/media/wm.png';
                 if ($imgWidth <= $maxWidth && !is_file($wmPath)) {
                     $file = $imgPath;
                 } else {
                     $file = $this->_zula->getDir('tmp') . "/media/max{$maxWidth}-" . pathinfo($item['filename'], PATHINFO_BASENAME);
                     if (!is_file($file)) {
                         $image = new Image($imgPath);
                         $image->resize($maxWidth, null, false);
                         if (is_file($wmPath)) {
                             $image->watermark($wmPath, $this->_config->get('media/wm_position'));
                         }
                         $image->save($file);
                     }
                 }
             }
         } else {
             if ($format == 'stream' && $item['type'] == 'audio' || $item['type'] == 'video') {
                 $file = $item['path_fs'] . '/' . $item['filename'];
             }
         }
     }
     if (isset($file) && is_file($file)) {
         zula_readfile($file);
         return false;
     } else {
         if ($format == 'thumb') {
             zula_readfile(zula_get_icon('misc/missing_' . $item['type'], null, false));
             return false;
         } else {
             if ($item['type'] == 'image') {
                 // Display default icon
                 zula_readfile(zula_get_icon('misc/no_file', null, false));
                 return false;
             } else {
                 throw new Module_ControllerNoExist();
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Allows easier access to icons for modules, as it will add
  * in the correct directory prefix to use as well
  *
  * @param string $icon
  * @param bool $forHtml
  * @return string
  */
 protected function getIcon($icon, $forHtml = true)
 {
     return zula_get_icon($icon, $this->module, $forHtml);
 }