function MG_albumThumbnail($album_id) { global $_MG_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $LANG_MG03; $sql = "SELECT album_title,album_parent,album_views,enable_album_views," . "media_count,album_desc,album_cover_filename,last_update,tn_attached " . "FROM {$_TABLES['mg_albums']} " . "WHERE album_id=" . intval($album_id); $result = DB_query($sql); $album_data = DB_fetchArray($result); $cover_filename = $album_data['album_cover_filename']; if ($album_data['media_count'] > 0) { if ($cover_filename != '' && $cover_filename != '0') { // Testing! if (strpos($cover_filename, 'tn_') === 0) { $tmpfilename = 'tn/' . $cover_filename[3] . '/' . $cover_filename; } else { $type = $_MG_CONF['gallery_tn_size']; // Root album if ($album_data['album_parent'] > 0) { $type = DB_getItem($_TABLES['mg_albums'], 'tn_size', 'album_id=' . $album_data['album_parent']); } $tmpfilename = 'tn/' . $cover_filename[0] . '/' . $cover_filename; $tmpfilename = MG_getThumbPath($tmpfilename, $type); $tmpfilename = rtrim($tmpfilename, '.'); } list($album_last_image, $mediasize) = MG_getImageUrl($tmpfilename); $album_last_update = MG_getUserDateTimeFormat($album_data['last_update']); if ($mediasize == false) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/empty.png'; $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'empty.png'); } } else { $filename = MG_getAlbumCover($album_id); if ($filename == '' || $filename == NULL || $filename == " ") { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/empty.png'; $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'empty.png'); } else { list($album_last_image, $mediasize) = MG_getImageUrl('tn/' . $filename[0] . '/' . $filename); if ($mediasize == false) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/missing.png'; $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'missing.png'); } } } $album_media_count = $album_data['media_count']; if ($album_data['last_update'] > 0) { $album_last_update = MG_getUserDateTimeFormat($album_data['last_update']); $lang_updated = $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt']; } else { $album_last_update[0] = ''; $lang_updated = ''; } $lang_updated = $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt']; if (isset($_USER['uid']) && $_USER['uid'] > 1) { $lastlogin = DB_getItem($_TABLES['userinfo'], 'lastlogin', "uid = '" . $_USER['uid'] . "'"); if ($album_data['last_update'] > $lastlogin) { $album_last_update[0] = '<span class="mgUpdated">' . $album_last_update[0] . '</span>'; } } } else { // nothing in the album yet... $filename = MG_getAlbumCover($album_id); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/empty.png'; $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'empty.png'); } else { list($album_last_image, $mediasize) = MG_getImageUrl('tn/' . $filename[0] . '/' . $filename); if ($mediasize == false) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/missing.png'; $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'missing.png'); } } $album_last_update[0] = ''; $lang_updated = ''; } if ($album_data['tn_attached'] == 1) { list($album_last_image, $mediasize) = MG_getImageUrl('covers/cover_' . $album_id); if ($mediasize == false) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/missing.png'; $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'missing.png'); } } $children = MG_getAlbumChildren($album_id); $subalbums = count($children); $total_images_subalbums = MG_getMediaCount($album_id); $parent_album = new mgAlbum($album_data['album_parent']); $_MG_USERPREFS = MG_getUserPrefs(); if (isset($_MG_USERPREFS['tn_size']) && $_MG_USERPREFS['tn_size'] != -1) { $tn_size = $_MG_USERPREFS['tn_size']; } else { $tn_size = $parent_album->tn_size; } list($tn_height, $tn_width) = MG_getTNSize($tn_size, $parent_album->tnHeight, $parent_album->tnWidth); list($newwidth, $newheight) = MG_getImageWH_3($mediasize[0], $mediasize[1], $tn_width, $tn_height); $media_item_thumbnail = MG_getFramedImage($parent_album->album_skin, $album_data['album_title'], $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&page=1', $album_last_image, $newwidth, $newheight); $C = COM_newTemplate(MG_getTemplatePath($album_data['album_parent'])); $C->set_file('cell', 'album_page_album_cell.thtml'); $C->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'u_viewalbum' => $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&page=1', 'album_last_image' => $album_last_image, 'album_title' => $album_data['album_title'], 'album_media_count' => $album_data['media_count'], 'subalbum_media_count' => $total_images_subalbums, 'album_desc' => PLG_replaceTags($album_data['album_desc']), 'album_last_update' => $album_last_update[0], 'img_height' => $newheight, 'img_width' => $newwidth, 's_media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'row_height' => $tn_height, 'updated' => $lang_updated, 'lang_album' => $LANG_MG00['album'], 'lang_views' => $LANG_MG03['views'], 'views' => $album_data['album_views'], 'lang_views' => $album_data['enable_album_views'] ? $LANG_MG03['views'] : '', 'views' => $album_data['enable_album_views'] ? $album_data['album_views'] : '', 'subalbumcount' => $subalbums > 0 ? '(' . $subalbums . ')' : '', 'lang_subalbums' => $subalbums > 0 ? $LANG_MG01['subalbums'] : '')); PLG_templateSetVars('mediagallery', $C); $C->parse('output', 'cell'); $celldisplay = $C->finish($C->get_var('output')); return $celldisplay; }
public function displayThumb($opt = array()) { global $_USER, $_CONF, $_MG_CONF, $_TABLES, $LANG_MG03, $LANG_MG01; $sortOrder = isset($opt['sortorder']) ? $opt['sortorder'] : 0; $searchmode = isset($opt['searchmode']) ? $opt['searchmode'] : 0; $album = isset($opt['album_id']) ? $opt['album_id'] : NULL; $mode = isset($opt['imageonly']) ? $opt['imageonly'] : 0; // $mode = 1 return image only if ($album === NULL) { $album = new mgAlbum($this->album_id); } $type = $this->type; $_MG_USERPREFS = MG_getUserPrefs(); // $type == 1 video // $type == 2 audio if (($type == 1 || $type == 2 || $type == 5) && ($album->playback_type == 0 || $album->playback_type == 1) && $_MG_CONF['popup_from_album'] == 1) { if ($album->playback_type == 0) { if ($type == 2) { // determine what type of player we will use (WMP, QT or Flash) $player = $_MG_CONF['mp3_player']; if (isset($_MG_USERPREFS['mp3_player']) && $_MG_USERPREFS['mp3_player'] != -1) { $player = $_MG_USERPREFS['mp3_player']; } switch ($player) { case 0: // WMP $new_y = 260; $new_x = 340; break; case 1: // QT $new_y = 25; $new_x = 350; break; case 2: $new_y = 360; $new_x = 580; break; } if ($this->mime_type == 'audio/mpeg') { $new_y = 360; $new_x = 580; } if ($this->tn_attached == 1 && $player != 2) { $tnsize = $this->media_size; $new_y += $tnsize[0]; if ($tnsize[1] > $new_x) { $new_x = $tnsize[1]; } } if ($album->playback_type == 0) { $url_display_item = self::getHref_showvideo($this->id, $new_y, $new_x); } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id; } $resolution_x = $new_x; $resolution_y = $new_y; } else { // must be a video... $playback_options['height'] = $_MG_CONF['swf_height']; $playback_options['width'] = $_MG_CONF['swf_width']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} " . "WHERE media_id='" . addslashes($this->id) . "'"); while ($poRow = DB_fetchArray($poResult)) { $playback_options[$poRow['option_name']] = $poRow['option_value']; } if ($this->resolution_x > 0) { $resolution_x = $this->resolution_x; $resolution_y = $this->resolution_y; } else { if ($this->resolution_x == 0 && $this->remote_media != 1) { $filepath = self::getFilePath('orig', $this->filename, $this->mime_ext); $size = @filesize($filepath); // skip files over 8M in size.. if ($size < 8388608) { list($resolution_x, $resolution_y) = self::getResolutionID3($filepath); } } else { $resolution_x = $this->resolution_x; $resolution_y = $this->resolution_y; } } $resolution_x = $playback_options['width']; $resolution_y = $playback_options['height']; if ($resolution_x < 1 || $resolution_y < 1) { $resolution_x = 480; $resolution_y = 320; } else { $resolution_x = $resolution_x + 40; $resolution_y = $resolution_y + 40; } if ($this->mime_type == 'video/x-flv' && $_MG_CONF['use_flowplayer'] != 1) { $resolution_x = $resolution_x + 60; if ($resolution_x < 590) { $resolution_x = 590; } $resolution_y = $resolution_y + 80; if ($resolution_y < 500) { $resolution_y = 500; } } if ($type == 5) { $resolution_x = 460; $resolution_y = 380; } $url_display_item = self::getHref_showvideo($this->id, $resolution_y, $resolution_x); } } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id; } } else { if ($album->useAlternate == 1 && $type != 5 && !empty($this->remote_url)) { $url_display_item = $this->remote_url; } else { $url_display_item = $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id; } } $url_media_item = $url_display_item; // -- decide what thumbnail size to use, small, medium, large... if (isset($_MG_USERPREFS['tn_size']) && $_MG_USERPREFS['tn_size'] != -1) { $tn_size = $_MG_USERPREFS['tn_size']; } else { if ($searchmode == 1) { $tn_size = $_MG_CONF['search_tn_size']; } else { $tn_size = $album->tn_size; } } list($tn_width, $tn_height) = self::getTNSize($tn_size, $album->tnWidth, $album->tnHeight); list($newwidth, $newheight) = self::getImageWH($this->media_size[0], $this->media_size[1], $tn_width, $tn_height); if (!isset($resolution_x)) { $resolution_x = $newwidth; } if (!isset($resolution_y)) { $resolution_y = $newheight; } $username = '******'; if ($this->owner_id != '' && $this->owner_id > 1) { $username = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($this->owner_id)); } $filepath = self::getFilePath('orig', $this->filename, $this->mime_ext); $fs_bytes = @filesize($filepath); $fileSize = MG_getSize($fs_bytes); $direct_url = self::getFileUrl('disp', $this->filename, $this->mime_ext); $direct_path = self::getFilePath('disp', $this->filename, $this->mime_ext); if (!file_exists($direct_path)) { $direct_url = self::getFileUrl('disp', $this->filename, 'jpg'); } $edit_item = ''; if ($album->access == 3) { $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $this->album_id . '&mid=' . $this->id . '">' . $LANG_MG01['edit'] . '</a>'; } // build the small rating bar $rating_box = ''; if ($album->enable_rating > 0) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-rating.php'; $starSize = $_MG_CONF['use_large_stars'] == 1 ? '' : 'sm'; $rating_box = MG_getRatingBar($album->enable_rating, $this->owner_id, $this->id, $this->votes, $this->rating, $starSize); } $hrefdirect = ''; if ($this->type == 0) { // standard image if ($this->remote == 1) { $hrefdirect = $this->remote_url; } else { $hrefdirect = $direct_url; } } $caption = PLG_replaceTags(str_replace('$', '$', $this->title)); if ($searchmode == 1) { $templatePath = MG_getTemplatePath_byName($_MG_CONF['search_album_skin']); } else { $templatePath = MG_getTemplatePath($this->album_id); } $L = COM_newTemplate($templatePath); $L->set_file('media_link', 'medialink.thtml'); $L->set_var(array('hrefdirect' => $hrefdirect, 'href' => $url_media_item, 'caption' => $caption, 'id' => 'id' . rand())); $media_start_link = $L->finish($L->parse('media_link_start', 'media_link')); if ($searchmode == 1) { $skin = $_MG_CONF['search_frame_skin']; $info = array('media_type' => $this->type, 'mime_type' => $this->mime_type, 'media_filename' => $this->filename, 'media_mime_ext' => $this->mime_ext, 'remote_media' => $this->remote_url, 'media_tn_attached' => $this->tn_attached); list($media_thumbnail, $media_thumbnail_file, $media_size) = self::getThumbInfo($info, $tn_size); } else { $skin = $album->image_skin; $media_thumbnail = $this->media_thumbnail; } $media_item_thumbnail = MG_getFramedImage($skin, $this->title, $url_media_item, $media_thumbnail, $newwidth, $newheight, $media_start_link); if ($mode == 1) { return $media_item_thumbnail; } $edit_link = ''; if (($type == 1 || $type == 2 || $type == 5) && ($album->playback_type == 0 || $album->playback_type == 1) && $_MG_CONF['popup_from_album'] == 1) { // check to see if comments and rating are enabled, if not, put a link to edit... if ($album->access == 3) { $edit_link = '<br' . XHTML . '><a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $this->album_id . '&mid=' . $this->id . '">' . $LANG_MG01['edit'] . '</a>'; } } if ($_MG_CONF['use_upload_time'] == 1) { $media_time = MG_getUserDateTimeFormat($this->upload_time); } else { $media_time = MG_getUserDateTimeFormat($this->time); } $media_title = !empty($this->title) ? PLG_replaceTags($this->title) : ''; $T = COM_newTemplate($templatePath); $T->set_file(array('media_cell_image' => 'album_page_media_cell.thtml', 'mp3_podcast' => 'mp3_podcast.thtml')); if ($this->mime_type == 'audio/mpeg' && $album->mp3ribbon) { $T->set_var(array('mp3_file' => self::getFileUrl('orig', $this->filename, $this->mime_ext), 'site_url' => $_MG_CONF['site_url'], 'id' => $this->mime_ext . rand())); $T->parse('mp3_podcast', 'mp3_podcast'); } else { $T->set_var('mp3_podcast', ''); } $T->set_var(array('edit_link' => $edit_link, 'play_now' => '', 'download_now' => $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id, 'play_in_popup' => self::getHref_showvideo($this->id, $resolution_y, $resolution_x), 'row_height' => $tn_height, 'media_title' => $media_title, 'media_description' => PLG_replaceTags(nl2br($this->description)), 'media_tag' => strip_tags($this->title), 'media_time' => $media_time[0], 'media_owner' => $username, 'media_item_thumbnail' => $media_item_thumbnail, 'site_url' => $_MG_CONF['site_url'], 'lang_published' => $LANG_MG03['published'], 'lang_on' => $LANG_MG03['on'], 'lang_hyphen' => $this->album == '' ? '' : '-', 'media_link_start' => $media_start_link, 'media_link_end' => '</a>', 'artist' => $this->artist, 'musicalbum' => $this->album != '' ? $this->album : '', 'genre' => $this->genre != '' ? $this->genre : '', 'alt_edit_link' => $edit_item, 'filesize' => $fileSize, 'media_id' => $this->id, 'rating_box' => $rating_box)); if ($album->enable_keywords) { if (!empty($this->keywords)) { $kwText = ''; $keyWords = array(); $keyWords = explode(' ', $this->keywords); $numKeyWords = count($keyWords); for ($i = 0; $i < $numKeyWords; $i++) { $keyWords[$i] = str_replace('"', ' ', $keyWords[$i]); $searchKeyword = $keyWords[$i]; $keyWords[$i] = str_replace('_', ' ', $keyWords[$i]); $kwText .= '<a href="' . $_MG_CONF['site_url'] . '/search.php?mode=search&swhere=1&keywords=' . $searchKeyword . '&keyType=any">' . $keyWords[$i] . '</a>'; } $T->set_var(array('enable_keywords' => 1, 'media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords'])); } else { $T->set_var('lang_keywords', ''); } } else { $T->set_var(array('enable_keywords' => '', 'lang_keywords' => '')); } if ($album->enable_comments) { $link = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id . '">' . $LANG_MG03['comments'] . '</a>'; $cmtLink = $LANG_MG03['comments']; $cmtLink_alt = $link; if ($type == 4 || $type == 1 && $album->playback_type != 2 || $type == 2 && $album->playback_type != 2 || $type == 5 && $album->playback_type != 2) { $cmtLink = $link; $cmtLink_alt = ''; } $T->set_var(array('media_comments_count' => $this->comments, 'lang_comments' => $cmtLink, 'lang_comments_hot' => $cmtLink_alt)); $T->set_var('media_comments', $album->enable_comments); } if ($album->enable_views) { $T->set_var(array('media_views_count' => $this->views, 'lang_views' => $LANG_MG03['views'])); $T->set_var('media_views', $album->enable_views); } PLG_templateSetVars('mediagallery', $T); return $T->finish($T->parse('media_cell', 'media_cell_image')); }
function MG_displayJPG($I, $opt = array()) { global $_CONF, $_MG_CONF, $_USER; $full = !empty($opt['full']) ? $opt['full'] : 0; $media_id = $opt['media_id']; $sortOrder = $opt['sortOrder']; $spage = $opt['spage']; $media_size_disp = false; if ($full == 1) { $u_image = Media::getFileUrl('orig', $I['media_filename'], $I['media_mime_ext']); } else { if ($I['remote_media'] == 1) { if ($I['media_resolution_x'] != 0 && $I['media_resolution_y'] != 0) { $media_size_disp[0] = $I['media_resolution_x']; $media_size_disp[1] = $I['media_resolution_y']; } else { $media_size_disp = @getimagesize($I['remote_url']); } $u_image = $I['remote_url']; } else { $u_image = Media::getFileUrl('disp', $I['media_filename'], $I['media_mime_ext']); $media_size_disp = @getimagesize(Media::getFilePath('disp', $I['media_filename'], $I['media_mime_ext'])); if ($media_size_disp == false) { $u_image = Media::getFileUrl('disp', $I['media_filename'], 'jpg'); $media_size_disp = @getimagesize(Media::getFilePath('disp', $I['media_filename'], 'jpg')); if ($media_size_disp == false) { $fname = 'missing.png'; $u_image = $_MG_CONF['mediaobjects_url'] . '/' . $fname; $p_image = $_MG_CONF['path_mediaobjects'] . $fname; $media_size_disp = @getimagesize($pimage); } } } } if ($media_size_disp == false) { $media_size_disp[0] = 0; $media_size_disp[1] = 0; } $media_link_start = ''; $media_link_end = ''; $media_size_orig = @getimagesize(Media::getFilePath('orig', $I['media_filename'], $I['media_mime_ext'])); if ($media_size_orig == false || $opt['full_display'] == 2 || $_MG_CONF['discard_original'] == 1 || $opt['full_display'] == 1 && (!isset($_USER['uid']) || $_USER['uid'] < 2)) { $u_pic = '#'; $raw_link_url = ''; if ($media_size_orig == false) { $media_size_orig[0] = 200; $media_size_orig[1] = 150; } } else { if ($full == 0 && $_MG_CONF['full_in_popup']) { $popup_x = $media_size_orig[0] + 75; $popup_y = $media_size_orig[1] + 100; $u_pic = 'javascript:showVideo(\'' . $_MG_CONF['site_url'] . '/popup.php?s=' . $media_id . '&sort=' . $sortOrder . '\',' . $popup_y . ',' . $popup_x . ')'; } else { $f = $full ? '0' : '1'; if ($_MG_CONF['click_image_and_go_next']) { $f = $full ? '1' : '0'; } $u_pic = $_MG_CONF['site_url'] . '/media.php?f=' . $f . '&s=' . $media_id . '&p=' . $spage; } $media_link_start = '<a href="' . $u_pic . '">'; $media_link_end = '</a>'; $raw_link_url = $u_pic; } $imageWidth = $full ? $media_size_orig[0] : $media_size_disp[0]; $imageHeight = $full ? $media_size_orig[1] : $media_size_disp[1]; $playback_type = $opt['playback_type']; switch ($playback_type) { case 0: // Popup Window $win_width = $imageWidth + 20; $win_height = $imageHeight + 20; $u_pic = Media::getHref_showvideo($I['media_id'], $win_height, $win_width); $raw_link_url = $u_pic; break; } $retval = MG_getFramedImage($opt['display_skin'], $I['media_title'], $u_pic, $u_image, $imageWidth, $imageHeight, $media_link_start, $media_link_end); return array($retval, $u_image, $imageWidth, $imageHeight, $raw_link_url); }