Example #1
0
 public function renderCell(&$ar)
 {
     $media = org_glizycms_mediaArchive_MediaManager::getMediaByRecord($ar);
     $sizes = method_exists($media, 'getOriginalSizes') ? $media->getOriginalSizes() : array('width' => 0, 'height' => 0);
     $thumbnail = $media->getThumbnail(__Config::get('THUMB_WIDTH'), __Config::get('THUMB_HEIGHT'), __Config::get('ADM_THUMBNAIL_CROP'), __Config::get('ADM_THUMBNAIL_CROPPOS'));
     $ar->thumb_filename = $thumbnail['fileName'];
     $ar->thumb_w = $thumbnail['width'];
     $ar->thumb_h = $thumbnail['height'];
     $ar->media_w = $sizes['width'];
     $ar->media_h = $sizes['height'];
     if ($ar->media_title == '') {
         $ar->media_title = $ar->media_originalFileName;
     }
     if (!$ar->media_date) {
         $ar->media_date = '';
     }
     if (!$ar->media_copyright) {
         $ar->media_copyright = '';
     }
     if (!$ar->media_description) {
         $ar->media_description = '';
     }
     $ar->__jsonMedia = org_glizycms_Glizycms::getMediaArchiveBridge()->getJsonFromAr($ar);
     $application = $this->application;
     $user = $application->_user;
     $ar->__url__ = $user->acl($application->getPageId(), 'edit') ? __Routing::makeUrl('actionsMVC', array('action' => 'edit', 'id' => $ar->media_id)) : false;
     $ar->__urlDelete__ = $user->acl($application->getPageId(), 'delete') ? __Routing::makeUrl('actionsMVC', array('action' => 'delete', 'id' => $ar->media_id)) : false;
     $ar->__urlDownload__ = org_glizycms_helpers_Media::getFileUrlById($ar->media_id);
     $ar->__urlPreview__ = org_glizycms_helpers_Media::getImageUrlById($ar->media_id, 800, 600);
 }
Example #2
0
 function _render_html()
 {
     if ($this->_content['mediaId'] > 0) {
         $attributes = $this->_content;
         if (!is_null($this->getAttribute('width')) && !is_null($this->getAttribute('height'))) {
             if ($this->getAttribute('processThumbnail') != 'false') {
                 if ($this->getAttribute('processThumbnail') == 'full') {
                     $thumbnail = $this->media->getResizeImage($this->getAttribute('width'), $this->getAttribute('height'), $this->getAttribute('crop'), $this->getAttribute('cropOffset'));
                 } else {
                     $thumbnail = $this->media->getThumbnail($this->getAttribute('width'), $this->getAttribute('height'), $this->getAttribute('crop'), $this->getAttribute('cropOffset'));
                 }
                 $attributes['src'] = $thumbnail['fileName'];
                 $attributes['width'] = $thumbnail['width'];
                 $attributes['height'] = $thumbnail['height'];
                 $this->_content['src'] = $thumbnail['fileName'];
                 $this->_content['width'] = $thumbnail['width'];
                 $this->_content['height'] = $thumbnail['height'];
             } else {
                 $attributes['src'] = org_glizy_helpers_Media::getImageUrlById($this->_content['mediaId'], $this->getAttribute('width'), $this->getAttribute('height'), $this->getAttribute('crop'));
                 $this->_content['src'] = $attributes['src'];
             }
         }
         $useZoom = $attributes['zoom'];
         unset($attributes['description']);
         unset($attributes['mediaId']);
         unset($attributes['zoom']);
         unset($attributes['size']);
         unset($attributes['mediaType']);
         unset($attributes['originalSrc']);
         unset($attributes['__media__']);
         $this->_content['__html__'] = '<img ' . $this->_renderAttributes($attributes) . '/>';
         if ($this->getAttribute('zoom')) {
             if ($useZoom && $this->getAttribute('superZoom')) {
                 $this->_application->addZoomJsCode();
                 $this->_content['__html__'] .= '<span class="superzoom js-glizySuperZoom" data-mediaid="' . $this->media->id . '" data-mediawatermark="' . ($this->media->watermark ? '1' : '0') . '">' . $this->getAttribute('superZoomLabel') . '</span>';
             }
             $this->_application->addLightboxJsCode();
             $attributes = array();
             $attributes['title'] = $this->_content['title'];
             if ($this->media->type == 'IMAGE') {
                 $attributes['class'] = 'js-lightbox-image';
                 $attributes['href'] = org_glizycms_helpers_Media::getImageUrlById($this->media->id, __Config::get('IMG_WIDTH_ZOOM'), __Config::get('IMG_HEIGHT_ZOOM'));
             } else {
                 $attributes['class'] = 'js-lightbox-inline';
                 $attributes['href'] = org_glizycms_helpers_Media::getFileUrlById($this->media->id);
             }
             $attributes['data-type'] = strtolower($this->media->type);
             $attributes['rel'] = $this->getAttribute('group');
             $this->_content['__html__'] = org_glizy_helpers_Html::renderTag('a', $attributes, true, $this->_content['__html__']);
         }
     } else {
         $this->_content['__html__'] = '';
     }
 }
Example #3
0
 function getThumbnail($width, $height, $crop = false, $cropOffset = 1, $forceSize = false, $useThumbnail = true, $returnResizedDimension = true)
 {
     if ($useThumbnail && !empty($this->ar->media_thumbFileName)) {
         $this->fileName = $this->ar->media_thumbFileName;
         $this->_imageInfo = null;
     }
     $originalSizes = $this->getOriginalSizes();
     if ($width == $originalSizes['width'] && $height == $originalSizes['height']) {
         return array('imageType' => IMG_JPG, 'fileName' => $this->getFileName(), 'width' => $width, 'height' => $height, 'originalWidth' => $width, 'originalHeight' => $height);
     }
     $cacheFileName = $this->_verifyCache($width, $height, $crop, $cropOffset, $forceSize);
     if ($cacheFileName !== false) {
         if ($returnResizedDimension) {
             list($width, $height) = getImageSize($cacheFileName);
         } else {
             $width = NULL;
             $height = NULL;
         }
         return array('imageType' => IMG_JPG, 'fileName' => $cacheFileName, 'width' => $width, 'height' => $height, 'originalWidth' => NULL, 'originalHeight' => NULL);
     }
     if ($returnResizedDimension) {
         $sizes = $this->resizeImageGetFinalSizes($width, $height, $crop, $cropOffset, $forceSize);
         $newWidth = $crop ? min($sizes['width'], $width) : $sizes['width'];
         $newHeight = $crop ? min($sizes['height'], $height) : $sizes['height'];
     } else {
         $newWidth = NULL;
         $newHeight = NULL;
     }
     return array('imageType' => NULL, 'fileName' => org_glizycms_helpers_Media::getImageUrlById($this->id, $width, $height, $crop, $cropOffset, $forceSize, $useThumbnail), 'width' => $newWidth, 'height' => $newHeight, 'originalWidth' => NULL, 'originalHeight' => NULL);
 }