public function prepareContent(array $content, array $fetchOptions = array(), $viewingUser = null) { $content = parent::prepareContent($content, $fetchOptions, $viewingUser); if (!empty($content)) { if (!empty($content['photo_exif'])) { if (!is_array($content['photo_exif'])) { $content['photo_exif'] = @unserialize($content['photo_exif']); } if (!empty($content['photo_exif']['ExposureTime'])) { $content['photo_exif']['ExposureTimeOrigin'] = $content['photo_exif']['ExposureTime']; $ele = explode('/', $content['photo_exif']['ExposureTime']); if (!empty($ele[0]) && !empty($ele[1])) { if ($ele[1] > $ele[0]) { $content['photo_exif']['ExposureTime'] = '1/' . floor($ele[1] / $ele[0]); } else { $content['photo_exif']['ExposureTime'] = floor($ele[0] / $ele[1]); } } else { $content['photo_exif']['ExposureTime'] = !empty($ele[0]) ? floor($ele[0]) : (!empty($ele[1]) ? floor($ele[1]) : 0); } $content['photo_exif']['ExposureTime'] .= 's'; } } } return $content; }
protected function _prepareContents(array $widget, array &$contents, sonnb_XenGallery_Model_Content $contentModel) { if ($contents) { foreach ($contents as $contentId => $content) { if (!$contentModel->canViewContentAndContainer($content, $content['album'])) { unset($contents[$contentId]); continue; } } } $contents = array_slice($contents, 0, $widget['options']['limit']); if ($widget['options']['thumbnail_width'] && $widget['options']['thumbnail_height']) { foreach ($contents as &$content) { if (!empty($content['medium_height']) && !empty($content['medium_width'])) { $widthRatio = $content['medium_width'] / $widget['options']['thumbnail_width']; $heightRatio = $content['medium_height'] / $widget['options']['thumbnail_height']; $album['cover']['style'] = ''; if ($widthRatio == $heightRatio) { $content['medium_width'] = $widget['options']['thumbnail_width']; $content['medium_height'] = $widget['options']['thumbnail_height']; $content['style'] = ''; } elseif ($widthRatio < $heightRatio) { $content['medium_height'] = $content['medium_height'] / ($content['medium_width'] / $widget['options']['thumbnail_width']); $content['medium_width'] = $widget['options']['thumbnail_width']; $content['style'] = 'top: -' . ($content['medium_height'] - $widget['options']['thumbnail_height']) / 2 . 'px;'; } else { $content['medium_width'] = $content['medium_width'] / ($content['medium_height'] / $widget['options']['thumbnail_height']); $content['medium_height'] = $widget['options']['thumbnail_height']; $content['style'] = 'left: -' . ($content['medium_width'] - $widget['options']['thumbnail_width']) / 2 . 'px;'; } } } } }