function MG_searchDisplayThumb($M, $sortOrder, $id, $page, $force = 0) { global $_CONF, $_USER, $_MG_CONF, $MG_albums, $_TABLES, $_MG_USERPREFS, $LANG_MG03, $LANG_MG01, $ratedIds; $playback_type = $_MG_CONF['search_playback_type']; $retval = ''; $nFrame = new mgFrame(); $nFrame->constructor('mgShadow'); $imageFrameTemplate = $nFrame->getTemplate(); $frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; $T = new Template(MG_getTemplatePath(0)); $T->set_file(array('media_cell_image' => 'album_page_body_media_cell.thtml', 'media_rate_results' => 'album_page_body_media_cell_rating.thtml', 'media_comments' => 'album_page_body_media_cell_comment.thtml', 'media_views' => 'album_page_body_media_cell_view.thtml', 'media_cell_keywords' => 'album_page_body_media_cell_keywords.thtml', 'mp3_podcast' => 'mp3_podcast.thtml')); $F = new Template($_MG_CONF['template_path']); $F->set_var('media_frame', $imageFrameTemplate); //$MG_albums[0]->imageFrameTemplate); // --- set the default thumbnail $default_thumbnail = 'generic.png'; switch ($M['media_type']) { case 0: // standard image foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $ext)) { $default_thumbnail = 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $ext; break; } } break; case 1: // video file switch ($M['mime_type']) { case 'video/x-flv': $default_thumbnail = 'flv.png'; break; case 'application/x-shockwave-flash': $default_thumbnail = 'flash.png'; break; case 'video/mpeg': case 'video/x-mpeg': case 'video/x-mpeq2a': if ($_MG_CONF['use_wmp_mpeg'] == 1) { $default_thumbnail = 'wmp.png'; break; } case 'video/x-motion-jpeg': case 'video/quicktime': case 'video/x-qtc': case 'audio/mpeg': $default_thumbnail = 'quicktime.png'; break; case 'asf': case 'video/x-ms-asf': case 'video/x-ms-asf-plugin': case 'video/avi': case 'video/msvideo': case 'video/x-msvideo': case 'video/avs-video': case 'video/x-ms-wmv': case 'video/x-ms-wvx': case 'video/x-ms-wm': case 'application/x-troff-msvideo': case 'application/x-ms-wmz': case 'application/x-ms-wmd': $default_thumbnail = 'wmp.png'; break; default: $default_thumbnail = 'video.png'; break; } break; case 2: // music file $default_thumbnail = 'audio.png'; break; case 4: // other files switch ($M['mime_type']) { case 'application/zip': case 'zip': case 'arj': case 'rar': case 'gz': $default_thumbnail = 'zip.png'; break; case 'pdf': case 'application/pdf': $default_thumbnail = 'pdf.png'; break; default: switch ($M['media_mime_ext']) { case 'pdf': $default_thumbnail = 'pdf.png'; break; case 'arj': $default_thumbnail = 'zip.png'; break; case 'gz': $default_thumbnail = 'zip.png'; break; default: $default_thumbnail = 'generic.png'; break; } break; } break; case 5: case 'embed': if (preg_match("/youtube/i", $M['remote_url'])) { $default_thumbnail = 'youtube.png'; } else { if (preg_match("/google/i", $M['remote_url'])) { $default_thumbnail = 'googlevideo.png'; } else { $default_thumbnail = 'remote.png'; } } break; } if ($M['media_tn_attached'] == 1) { $media_thumbnail_file = ''; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext)) { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext; break; } } if ($media_thumbnail_file == '') { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; } } else { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; } $resolution_x = 0; $resolution_y = 0; // type == 1 video // type == 2 audio if (($M['media_type'] == 1 || $M['media_type'] == 2 || $M['media_type'] == 5) && ($playback_type == 0 || $playback_type == 1)) { if ($playback_type == 0 || $playback_type == 1) { if ($M['media_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 = 60; $new_x = 350; break; case 1: // QT $new_y = 25; $new_x = 350; break; case 2: $new_y = 360; $new_x = 580; break; } if ($M['media_tn_attached'] == 1 && $player != 2) { $tnsize = @getimagesize($media_thumbnail_file); $new_y += $tnsize[0]; if ($tnsize[1] > $new_x) { $new_x = $tnsize[1]; } } if ($playback_type == 0) { $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $new_y . ',' . $new_x . ')'; } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $MG_media->id; } $resolution_x = $new_x; $resolution_y = $new_y; } else { // must be a video... // set the default playback options... $playback_options['play'] = $_MG_CONF['swf_play']; $playback_options['menu'] = $_MG_CONF['swf_menu']; $playback_options['quality'] = $_MG_CONF['swf_quality']; $playback_options['height'] = $_MG_CONF['swf_height']; $playback_options['width'] = $_MG_CONF['swf_width']; $playback_options['loop'] = $_MG_CONF['swf_loop']; $playback_options['scale'] = $_MG_CONF['swf_scale']; $playback_options['wmode'] = $_MG_CONF['swf_wmode']; $playback_options['allowscriptaccess'] = $_MG_CONF['swf_allowscriptaccess']; $playback_options['bgcolor'] = $_MG_CONF['swf_bgcolor']; $playback_options['swf_version'] = $_MG_CONF['swf_version']; $playback_options['flashvars'] = $_MG_CONF['swf_flashvars']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($M['media_id']) . "'"); while ($poRow = DB_fetchArray($poResult)) { $playback_options[$poRow['option_name']] = $poRow['option_value']; } if (isset($M['media_resolution_x']) && $M['media_resolution_x'] > 0) { $resolution_x = $M['media_resolution_x']; $resolution_y = $M['media_resolution_y']; } else { if ($M['media_resolution_x'] == 0 && $M['remote_media'] != 1) { require_once $_CONF['path'] . '/lib/getid3/getid3.php'; // Needed for windows only define('GETID3_HELPERAPPSDIR', 'C:/helperapps/'); $getID3 = new getID3(); // Analyze file and store returned data in $MG_mediaFileInfo $MG_mediaFileInfo = $getID3->analyze($_MG_CONF['path_mediaobjects'] . 'orig/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext']); getid3_lib::CopyTagsToComments($MG_mediaFileInfo); if ($MG_mediaFileInfo['video']['resolution_x'] < 1 || $MG_mediaFileInfo['video']['resolution_y'] < 1) { if (isset($MG_mediaFileInfo['meta']['onMetaData']['width']) && isset($MG_mediaFileInfo['meta']['onMetaData']['height'])) { $resolution_x = $MG_mediaFileInfo['meta']['onMetaData']['width']; $resolution_y = $MG_mediaFileInfo['meta']['onMetaData']['height']; } else { $resolution_x = -1; $resolution_y = -1; } } else { $resolution_x = $MG_mediaFileInfo['video']['resolution_x']; $resolution_y = $MG_mediaFileInfo['video']['resolution_y']; } if ($resolution_x != 0) { $sql = "UPDATE " . $_TABLES['mg_media'] . " SET media_resolution_x=" . $resolution_x . ",media_resolution_y=" . $resolution_y . " WHERE media_id='" . DB_escapeString($M['media_id']) . "'"; DB_query($sql, 1); } } else { $resolution_x = $M['media_resolution_x']; $resolution_y = $M['media_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 ($M['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 ($M['media_type'] == 5) { $resolution_x = 460; $resolution_y = 380; } $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $resolution_y . ',' . $resolution_x . ')'; } } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id']; } // check to see if comments and rating are enabled, if not, put a link to edit... if ($MG_albums[0]->access == 3) { $T->set_var(array('edit_link' => '<br/><a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $M['album_id'] . '&mid=' . $M['media_id'] . '">' . $LANG_MG01['edit'] . '</a>')); } else { $T->set_var(array('edit_link' => '')); } } else { $url_display_item = $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $M['media_id'] . '&i=' . $id . '&p=' . $page; } if ($M['media_type'] == 4) { // other $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id']; } $media_size = @getimagesize($media_thumbnail_file); if ($media_size == false) { $default_thumbnail = 'missing.png'; $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; $media_size = @getimagesize($media_thumbnail_file); } if ($_MG_CONF['use_upload_time'] == 1) { $media_time = MG_getUserDateTimeFormat($M['media_upload_time']); } else { $media_time = MG_getUserDateTimeFormat($M['media_time']); } $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 { $tn_size = $_MG_CONF['gallery_tn_size']; } switch ($tn_size) { case '0': //small $tn_height = 100; break; case '1': //medium $tn_height = 150; break; case '2': $tn_height = 200; break; case '3': $tn_height = 200; break; default: $tn_height = 150; break; } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / $tn_height; $newwidth = $tn_height; $newheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; $newheight = $tn_height; $newwidth = round($media_size[0] / $ratio); } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / 50; $smallwidth = 50; $smallheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / 50; $smallheight = 50; $smallwidth = round($media_size[0] / $ratio); } if ($M['media_user_id'] != "" && $M['media_user_id'] > 1) { $username = DB_getItem($_TABLES['users'], 'username', "uid=" . $M['media_user_id']); } else { $username = '******'; } if ($M['mime_type'] == 'audio/mpeg') { $T->set_var(array('play_now' => '', 'download_now' => $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id'], 'play_in_popup' => "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $resolution_y . ',' . $resolution_x . ')', 'mp3_file' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext'], 'site_url' => $_MG_CONF['site_url'], 'id' => $M['media_mime_ext'] . rand())); $T->parse('mp3_podcast', 'mp3_podcast'); } else { $T->set_var(array('mp3_podcast' => '')); } /* * build the small rating bar * */ if ($MG_albums[$M['album_id']]->enable_rating > 0) { $ip = $_SERVER['REMOTE_ADDR']; $uid = COM_isAnonUser() ? 1 : $_USER['uid']; $static = false; // check to see if we are the owner, if so, no rating for us... if (isset($_USER['uid']) && $_USER['uid'] == $M['media_user_id']) { $static = true; } else { if (in_array($M['media_id'], $ratedIds)) { $static = true; } else { $static = ''; } } if ($MG_albums[$M['album_id']]->enable_rating == 1 && COM_isAnonUser()) { $static = 'static'; } $rating_box = RATING_ratingBar('mediagallery', $M['media_id'], $M['media_votes'], $M['media_rating'], $static, 5, '', 'sm'); } else { $rating_box = ''; } $T->set_var('rating_box', $rating_box); if ($M['media_type'] == 0) { $direct_url = 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext']; if (!file_exists($_MG_CONF['path_mediaobjects'] . $direct_url)) { $direct_url = $_MG_CONF['mediaobjects_url'] . '/' . 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg'; } else { $direct_url = $_MG_CONF['mediaobjects_url'] . '/' . $direct_url; } } else { $direct_url = $media_thumbnail; } if ($MG_albums[$M['album_id']]->access == 3) { $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $M['album_id'] . '&mid=' . $M['media_id'] . '">' . $LANG_MG01['edit'] . '</a>'; } else { $edit_item = ''; } $L = new Template(MG_getTemplatePath(0)); $L->set_file('media_link', 'medialink.thtml'); $L->set_var('href', $url_media_item); $L->set_var('hrefdirect', $direct_url); $L->set_var('caption', PLG_replaceTags($M['media_title'], 'mediagallery', 'media_title')); $L->set_var('id', 'id' . rand()); $L->parse('media_link_start', 'media_link'); $media_start_link = $L->finish($L->get_var('media_link_start')); $T->set_var(array('row_height' => $tn_height + 40, 'media_title' => isset($M['media_title']) && $M['media_title'] != '' && $M['media_title'] != ' ' ? PLG_replaceTags($M['media_title'], 'mediagallery', 'media_title') : '', 'media_description' => isset($M['media_desc']) && $M['media_desc'] != '' && $M['media_desc'] != ' ' ? PLG_replaceTags($M['media_desc'], 'mediagallery', 'media_title') : '', 'media_tag' => isset($M['media_title']) && $M['media_title'] != '' && $M['media_title'] != ' ' ? strip_tags($M['media_title']) : '', 'media_time' => $media_time[0], 'media_owner' => $username, 'site_url' => $_MG_CONF['site_url'], 'lang_published' => $LANG_MG03['published'], 'lang_on' => $LANG_MG03['on'], 'media_link_start' => '<a href="' . $url_media_item . '">', 'media_link_end' => '</a>', 'artist' => isset($M['artist']) && $M['artist'] != ' ' ? $M['artist'] : '', 'musicalbum' => isset($M['album']) && $M['album'] != ' ' ? $M['album'] : '', 'genre' => isset($M['genre']) && $M['genre'] != ' ' ? $M['genre'] : '', 'search_album' => $LANG_MG01['album'] . ': <a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $M['album_id'] . '">' . $MG_albums[$M['album_id']]->title . '</a>')); // frame template variables $F->set_var(array('media_link_start' => $media_start_link, 'media_link_end' => '</a>', 'url_media_item' => $url_media_item, 'url_display_item' => $url_display_item, 'media_thumbnail' => $media_thumbnail, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'border_width' => $newwidth + 15, 'border_height' => $newheight + 15, 'row_height' => $tn_height + 40, 'frWidth' => $newwidth - $frWidth, 'frHeight' => $newheight - $frHeight, 'media_tag' => strip_tags($M['media_desc']), 'search_album' => $LANG_MG01['album'] . ': <a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $M['album_id'] . '">' . $MG_albums[$M['album_id']]->title . '</a>')); $F->parse('media', 'media_frame'); $media_item_thumbnail = $F->finish($F->get_var('media')); $T->set_var('media_item_thumbnail', $media_item_thumbnail); if (!empty($M['media_keywords'])) { $kwText = ''; $keyWords = array(); $keyWords = explode(' ', $M['media_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 .= $keyWords[$i] . ' '; } $T->set_var(array('media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords'])); $T->parse('media_cell_keywords', 'media_cell_keywords'); } else { $T->set_var('lang_keywords', ''); } if ($_MG_CONF['search_enable_rating']) { if ($M['media_type'] == 4 || $M['media_type'] == 1 && $playback_type != 2 || $M['media_type'] == 2 && $playback_type != 2 || $M['media_type'] == 5 && $playback_type != 2) { $rateLink = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $M['media_id'] . '">' . $LANG_MG03['rating'] . '</a>'; } else { $rateLink = $LANG_MG03['rating']; } $rating = $rateLink . ': <strong> ' . $M['media_rating'] / 2 . '</strong>/5 (' . $M['media_votes'] . ' ' . $LANG_MG03['votes'] . ')'; $T->set_var(array('media_rating' => $rating)); $T->parse('media_rate_results', 'media_rate_results'); } if ($_MG_CONF['search_enable_views']) { $T->set_var(array('media_views_count' => $M['media_views'], 'lang_views' => $LANG_MG03['views'])); $T->parse('media_views', 'media_views'); } $T->parse('media_cell', 'media_cell_image'); $retval = $T->finish($T->get_var('media_cell')); return $retval; }
function MG_index() { global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle; $display = ''; $media_size = false; $page = 0; if (isset($_GET['page'])) { $page = COM_applyFilter($_GET['page'], true); } if ($page != 0) { $page = $page - 1; } $themeStyle = MG_getThemeCSS(0); if (!isset($_MG_CONF['album_display_columns']) || $_MG_CONF['album_display_columns'] < 1) { $_MG_CONF['album_display_columns'] = 1; } switch ($_MG_CONF['album_display_columns']) { case 1: $albumListTemplate = 'gallery_page_body_1.thtml'; $albumColumnWidth = "100%"; break; case 2: $albumListTemplate = 'gallery_page_body_2.thtml'; $albumColumnWidth = "50%"; break; default: $albumListTemplate = 'gallery_page_body_3.thtml'; $albumColumnWidth = @intval(100 / $_MG_CONF['album_display_columns']) . '%'; if ($albumColumnWidth == 0) { $albumColumnWidth = "25%"; } break; } $T = new Template(MG_getTemplatePath(0)); $T->set_file(array('page' => 'gallery_page.thtml', 'body' => $albumListTemplate, 'noitems' => 'gallery_page_noitems.thtml')); $T->set_var(array('lang_menulabel' => $_MG_CONF['menulabel'], 'lang_search' => $LANG_MG01['search'], 'site_url' => $_MG_CONF['site_url'])); if ($_MG_CONF['rss_full_enabled']) { $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'); $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">'; $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>'; $T->set_var('rsslink', $rsslink); $T->set_var('rsslink_url', $feedUrl); } else { $T->set_var('rsslink', ''); } $nFrame = new mgFrame(); $nFrame->constructor($_MG_CONF['indexskin']); $MG_albums[0]->albumFrameTemplate = $nFrame->getTemplate(); $MG_albums[0]->afrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $MG_albums[0]->afrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; // Let's build our admin menu options $showAdminBox = 0; $admin_box_item = ''; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB; $admin_box .= '<div>'; $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB; $admin_box_item .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) { $admin_box_item .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB; $showAdminBox = 1; } if ($MG_albums[0]->owner_id) { $admin_box_item .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB; $admin_box_item .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB; $admin_box_item .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_box_item .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB; $admin_box_item .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB; $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($MG_albums[0]->access == 3) { $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } $admin_box .= $admin_box_item; $admin_box .= '</select>' . LB; $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB; $admin_box .= '</div>'; $admin_box .= '</form>'; // build ul $admin_menu = ''; $showAdminMenu = 0; $admin_url = $_MG_CONF['site_url'] . '/admin.php?album_id=0'; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=upload">' . $LANG_MG01['add_media'] . '</a></li>'; $showAdminMenu = 1; } if ($MG_albums[0]->owner_id) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=albumsort">' . $LANG_MG01['sort_albums'] . '</a></li>'; $admin_menu .= '<li><a href="' . $admin_url . '&mode=globalattr">' . $LANG_MG01['globalattr'] . '</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=globalperm">' . $LANG_MG01['globalperm'] . '</a></li>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_menu .= '<li><a href="' . $admin_url . '&mode=moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=wmmanage">' . $LANG_MG01['wm_management'] . '</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } elseif ($MG_albums[0]->access == 3) { $admin_Menu .= '<li><a href="' . $abmin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } // end of ul if ($showAdminBox == 0) { $admin_box = ''; $admin_box_item = ''; } if ($showAdminMenu == 1) { $T->set_var('admin_menu', $admin_menu); } $T->set_var('select_adminbox', $admin_box); $T->set_var('select_box_items', $admin_box_item); $album_count = 0; $width = intval(100 / $_MG_CONF['album_display_columns']); $rowcounter = 0; $albumCount = 0; $indexCounter = 0; if (COM_isAnonUser()) { $lastlogin = time(); } else { if (!COM_isAnonUser()) { $lastlogin = $_USER['lastlogin']; } else { $lastlogin = time(); } } $children = $MG_albums[0]->getChildren(); $nrows = count($children); $checkCounter = 0; $aCount = 0; $achild = array(); for ($i = 0; $i < $nrows; $i++) { $access = $MG_albums[$children[$i]]->access; if ($access == 0 || $MG_albums[$children[$i]]->hidden == 1 && $access != 3) { // no op } else { $achild[] = $MG_albums[$children[$i]]->id; $aCount++; } } if ($_MG_CONF['album_display_rows'] < 1) { $_MG_CONF['album_display_rows'] = 9; } $items_per_page = $_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows']; $begin = $items_per_page * $page; $end = $items_per_page; $nrows = count($achild); $indexCounter = $begin; $noParse = 0; $needFinalParse = 0; if ($nrows > 0) { $k = 0; $T->set_block('body', 'AlbumColumn', 'AColumn'); $T->set_block('body', 'AlbumRow', 'ARow'); for ($i = $begin; $i < $begin + $items_per_page; $i += $_MG_CONF['album_display_columns']) { for ($j = $i; $j < $i + $_MG_CONF['album_display_columns']; $j++) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; if ($j >= $nrows) { $k = $i + $_MG_CONF['album_display_columns'] - $j; $m = $k % $_MG_CONF['album_display_columns']; for ($z = $m; $z > 0; $z--) { $needFinalParse = 1; } if ($needFinalParse == 1) { $T->parse('ARow', 'AlbumRow', true); $T->set_var('AColumn', ''); } $noParse = 1; break; } $access = $MG_albums[$achild[$indexCounter]]->access; if ($access == 0 || $MG_albums[$achild[$indexCounter]]->hidden == 1 && $access != 3) { $j--; $indexCounter++; continue; } $albumCount++; if ($MG_albums[$achild[$indexCounter]]->media_count > 0) { if ($MG_albums[$achild[$indexCounter]]->cover_filename != '' && $MG_albums[$achild[$indexCounter]]->cover_filename != '0') { $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update); if (substr($MG_albums[$achild[$indexCounter]]->cover_filename, 0, 3) == 'tn_') { $offset = 3; } else { $offset = 0; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext); break; } } $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count; if (!COM_isAnonUser()) { if ($MG_albums[$achild[$indexCounter]]->last_update > $lastlogin) { $album_last_update[0] = '<font color="red">' . $album_last_update[0] . '</font>'; } } $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'])); } else { $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count; $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update); $filename = $MG_albums[$achild[$indexCounter]]->findCover(); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } else { if (substr($filename, 0, 3) == 'tn_') { $offset = 3; } else { $offset = 0; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[$offset] . '/' . $filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext); break; } } } $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'])); } } else { // nothing in the album yet... // here we need to search the sub-albums if any and see if we can find a picture.... $album_media_count = 0; $album_last_update[0] = ""; $filename = $MG_albums[$achild[$indexCounter]]->findCover(); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } else { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext); break; } } } $T->set_var('updated_prompt', ''); } $T->clear_var(array('lang_views', 'views')); if ($MG_albums[$achild[$indexCounter]]->enable_album_views) { $T->set_var(array('lang_views' => $LANG_MG03['views'], 'views' => $MG_albums[$achild[$indexCounter]]->views)); } if ($MG_albums[$achild[$indexCounter]]->tn_attached == 1) { $media_size = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext); break; } } } // a little fail safe here to make sure we don't show empty boxes... if ($media_size === false || $media_size[0] == 0 || $media_size[1] == 0) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } // set the image size here... switch ($_MG_CONF['gallery_tn_size']) { case '0': //small $tn_height = 100; $tn_width = 100; break; case '1': //medium $tn_height = 150; $tn_width = 150; break; case '2': $tn_height = 200; $tn_width = 200; break; case '3': $tn_height = $_MG_CONF['gallery_tn_height']; $tn_width = $_MG_CONF['gallery_tn_width']; break; default: $tn_height = 200; $tn_width = 200; break; } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / $tn_height; $newwidth = $tn_height; $newheight = @round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; $newheight = $tn_height; $newwidth = @round($media_size[0] / $ratio); } // pull the sub-album info here $subAlbumDisplay = ''; if (isset($_MG_CONF['subalbum_select']) && $_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay = '<form name="subalbums' . $MG_albums[$achild[$indexCounter]]->id . '" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0">'; $subAlbumDisplay .= '<select name="aid" onchange="forms[\'subalbums' . $MG_albums[$achild[$indexCounter]]->id . '\'].submit()">'; $subAlbumDisplay .= '<optgroup label="' . $LANG_MG01['select_subalbum'] . '">' . LB; } $saRows = 0; $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist')); if (!empty($MG_albums[$achild[$indexCounter]]->children)) { $SAchildren = $MG_albums[$achild[$indexCounter]]->getChildren(); foreach ($SAchildren as $SAchild) { if ($MG_albums[$SAchild]->access > 0) { if ($MG_albums[$SAchild]->hidden) { if ($MG_albums[$SAchild]->access == 3) { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } else { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } } if ($_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay .= '</optgroup></select>'; $subAlbumDisplay .= ' <input type="submit" value="' . $LANG_MG03['go'] . '" />'; $subAlbumDisplay .= '<input type="hidden" name="page" value="1"/>'; $subAlbumDisplay .= '</form>'; } if ($_MG_CONF['album_display_columns'] > 1 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('subalbumlist' => '<span style="font-weight:bold;">' . $LANG_MG01['subalbums'] . '</span> (' . $saRows . ')')); } else { $T->set_var(array('lang_subalbums' => $LANG_MG01['subalbums'], 'subalbumcount' => '(' . $saRows . ')', 'subalbumlist' => $subAlbumDisplay)); } } if ($saRows == 0) { $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist')); } $T->clear_var(array('saulstart', 'saulend')); if ($saRows > 0 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('saulstart' => '<ul>', 'saulend' => '</ul>')); } // now pull the total image count for all sub albums... $total_images_subalbums = $MG_albums[$achild[$indexCounter]]->getMediaCount(); $owner_id = $MG_albums[$achild[$indexCounter]]->owner_id; if ($owner_id == '' || !isset($MG_albums[$achild[$indexCounter]]->owner_id)) { $owner_id = 0; } $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($owner_id)); $F = new Template($_MG_CONF['template_path']); $F->set_var('media_frame', $MG_albums[0]->albumFrameTemplate); $F->set_var(array('border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight)); $F->parse('media', 'media_frame'); $media_item_thumbnail = $F->finish($F->get_var('media')); $T->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'class' => $rowcounter % 2, 'table_column_width' => 'width="' . $width . '%"', 'album_id' => $MG_albums[$achild[$indexCounter]]->id, 'album_title' => PLG_replaceTags($MG_albums[$achild[$indexCounter]]->title, 'mediagallery', 'album_title'), 'album_desc' => $MG_albums[$achild[$indexCounter]]->description == '' ? '' : PLG_replaceTags($MG_albums[$achild[$indexCounter]]->description, 'mediagallery', 'album_description'), 'album_media_count' => $album_media_count, 'subalbum_media_count' => $total_images_subalbums, 'album_owner' => $ownername, 'album_last_update' => $album_last_update[0], 'column_width' => $albumColumnWidth, 'column_width2' => $tn_height + 35 . 'px', 'lang_album' => $LANG_MG00['album'], 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight)); $T->parse('AColumn', 'AlbumColumn', true); $indexCounter++; } if ($noParse == 1) { break; } else { $T->parse('ARow', 'AlbumRow', true); $T->set_var('AColumn', ''); } } } $T->set_var(array('bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, ceil($aCount / $items_per_page)), 'table_columns' => $_MG_CONF['album_display_columns'])); if ($albumCount == 0) { $T->set_var(array('noitems' => $LANG_MG03['no_album_objects'])); $T->parse('gallery_noitems', 'noitems'); } else { $T->parse('gallery_body', 'body'); } $T->parse('output', 'page'); $nCSS = $nFrame->getCSS(); if ($nCSS != '') { $outputHandle = outputHandler::getInstance(); $outputHandle->addStyle($nCSS); } $display .= MG_siteHeader($LANG_MG00['plugin']); $display .= $T->finish($T->get_var('output')); $display .= MG_siteFooter(); echo $display; exit; }
if (isset($_MG_USERPREFS['display_rows']) && $_MG_USERPREFS['display_rows'] > 0) { $rows_per_page = $_MG_USERPREFS['display_rows']; } if (isset($_MG_USERPREFS['display_columns']) && $_MG_USERPREFS['display_columns'] > 0) { $columns_per_page = $_MG_USERPREFS['display_columns']; } $media_per_page = $columns_per_page * $rows_per_page; // image frame setup $nFrame = new mgFrame(); $nFrame->constructor($MG_albums[$album_id]->image_skin); $MG_albums[$album_id]->imageFrameTemplate = $nFrame->getTemplate(); $MG_albums[$album_id]->frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $MG_albums[$album_id]->frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; $aFrame = new mgFrame(); $aFrame->constructor($MG_albums[$album_id]->album_skin); $MG_albums[$album_id]->albumFrameTemplate = $aFrame->getTemplate(); $MG_albums[$album_id]->afrWidth = $aFrame->frame['wHL'] + $aFrame->frame['wHR']; $MG_albums[$album_id]->afrHeight = $aFrame->frame['hVT'] + $aFrame->frame['hVB']; // construct the album jumpbox... $level = 0; $MG_albums[0]->buildJumpBox($album_id); $album_jumpbox_raw = $album_jumpbox; $level = 0; $album_jumpbox = '<form name="jumpbox" id="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>'; $album_jumpbox .= $LANG_MG03['jump_to'] . ': <select name="aid" onchange="forms[\'jumpbox\'].submit()">'; $MG_albums[0]->buildJumpBox($album_id); $album_jumpbox .= '</select>'; $album_jumpbox .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>'; $album_jumpbox .= '<input type="hidden" name="page" value="1"/>'; $album_jumpbox .= '</div></form>'; // initialize our variables
function MG_indexAll() { global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle, $ImageSkin, $sortOrder, $displayColumns, $displayRows, $tnSize, $level, $album_jumpbox; $album_id = 0; if (isset($_GET['aid'])) { $album_id = (int) COM_applyFilter($_GET['aid'], true); } $page = 0; if (isset($_GET['page'])) { $page = (int) COM_applyFilter($_GET['page'], true); } if ($page != 0) { $page = $page - 1; } $lbSlideShow = ''; $errorMessage = ''; $columns_per_page = $displayColumns; $rows_per_page = $displayRows; $media_per_page = $columns_per_page * $rows_per_page; // image frame setup $nFrame = new mgFrame(); $nFrame->constructor($ImageSkin); $imageFrameTemplate = $nFrame->getTemplate(); $frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; $fCSS = $nFrame->getCSS(); // Let's build our admin menu options $showAdminBox = 0; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB; $admin_box .= '<div>'; $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB; $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && (isset($_USER['uid']) && $_USER['uid'] > 1)) { $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB; $showAdminBox = 1; } if ($MG_albums[0]->owner_id) { $admin_box .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB; $admin_box .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB; $admin_box .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB; $admin_box .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB; $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($MG_albums[0]->access == 3) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($_MG_CONF['member_albums'] == 1 && (isset($_USER['uid']) && $_USER['uid'] > 1) && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } $admin_box .= '</select>' . LB; $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB; $admin_box .= '</div>'; $admin_box .= '</form>'; if ($showAdminBox == 0) { $admin_box = ''; } // construct the album jumpbox... $level = 0; $album_jumpbox = '<form name="jumpbox" id="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>'; $album_jumpbox .= $LANG_MG03['jump_to'] . ': <select name="aid" onchange="forms[\'jumpbox\'].submit()">'; $MG_albums[0]->buildJumpBox(0); $album_jumpbox .= '</select>'; $album_jumpbox .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>'; $album_jumpbox .= '<input type="hidden" name="page" value="1"/>'; $album_jumpbox .= '</div></form>'; // initialize our variables $total_media = 0; $arrayCounter = 0; $total_object_count = 0; $mediaObject = array(); $begin = $media_per_page * $page; $end = $media_per_page; $MG_media = array(); // loop thru all the albums and build a list of valid albums that the user can see $first = 0; $albumList = getAlbumList($album_id, $first); $orderBy = ' ORDER BY m.media_upload_time ' . $sortOrder; if ($albumList != '') { $sql = "SELECT COUNT(*) AS total FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id IN (" . $albumList . ") " . $orderBy; $result = DB_query($sql); $row = DB_fetchArray($result); $cCount = $row['total']; } else { $cCount = 0; } if ($albumList != '') { $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id IN (" . $albumList . ") " . $orderBy; $sql .= ' LIMIT ' . $begin . ',' . $end; $result = DB_query($sql); $nRows = DB_numRows($result); } else { $nRows = 0; } $mediaRows = 0; $lbss_count = 0; $posCount = 0; if ($nRows > 0) { while ($row = DB_fetchArray($result)) { $media = new MediaItem(); $media->constructor($row, $row['album_id']); $MG_media[$arrayCounter] = $media; $MG_albums[$row['album_id']]->imageFrameTemplate = $imageFrameTemplate; $arrayCounter++; $mediaRows++; } } $total_media = $total_media + $mediaRows; $total_items_in_album = $cCount; $total_pages = ceil($total_items_in_album / $media_per_page); if ($page >= $total_pages) { $page = $total_pages - 1; } $start = $page * $media_per_page; $current_print_page = floor($start / $media_per_page) + 1; $total_print_pages = ceil($total_items_in_album / $media_per_page); if ($current_print_page == 0) { $current_print_page = 1; } if ($total_print_pages == 0) { $total_print_pages = 1; } // now build the admin select... $admin_box = ''; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0">'; $admin_box .= '<div><input type="hidden" name="album_id" value="' . $album_id . '"/>'; $admin_box .= '<select name="mode" onchange="forms[\'adminbox\'].submit()">'; $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>'; $admin_box .= '<option value="search">' . $LANG_MG01['search'] . '</option>'; $uploadMenu = 0; $adminMenu = 0; if ($MG_albums[0]->owner_id) { $uploadMenu = 1; $adminMenu = 1; } else { if ($MG_albums[$album_id]->access == 3) { $uploadMenu = 1; $adminMenu = 1; if ($_MG_CONF['member_albums']) { if ($_MG_USERPREFS['active'] != 1) { $uploadMenu = 0; $adminMenu = 0; } else { $uploadMenu = 1; $adminMenu = 1; } } } else { if ($MG_albums[$album_id]->member_uploads == 1 && isset($_USER['uid']) && $_USER['uid'] >= 2) { $uploadMenu = 1; $adminMenu = 0; } } } if ($uploadMenu == 1) { $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>'; } if ($adminMenu == 1) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>'; } elseif ($_MG_CONF['member_albums'] == 1 && !empty($_USER['username']) && $_MG_CONF['member_create_new'] == 1 && $_MG_USERPREFS['active'] == 1 && $album_id == $_MG_CONF['member_album_root']) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>'; $adminMenu = 1; } // now check for moderation capabilities.... if ($MG_albums[$album_id]->member_uploads == 1 && $MG_albums[$album_id]->moderate == 1) { // check to see if we are in the album_mod_group if (SEC_inGroup($MG_albums[$album_id]->mod_group_id) || $MG_albums[0]->owner_id) { $queue_count = DB_count($_TABLES['mg_media_album_queue'], 'album_id', $album_id); $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>'; $adminMenu = 1; } } $admin_box .= '</select>'; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '" style="padding:0px;margin:0px;"/>'; $admin_box .= '</div></form>'; if ($uploadMenu == 0 && $adminMenu == 0) { $admin_box = ''; } if ($MG_albums[$album_id]->enable_sort == 1) { $sort_box = '<form name="sortbox" id="sortbox" action="' . $_MG_CONF['site_url'] . '/album.php" method="get" style="margin:0;padding:0"><div>'; $sort_box .= '<input type="hidden" name="aid" value="' . $album_id . '"/>'; $sort_box .= '<input type="hidden" name="page" value="' . $page . '"/>'; $sort_box .= $LANG_MG03['sort_by'] . ' <select name="sort" onchange="forms[\'sortbox\'].submit()">'; $sort_box .= '<option value="0" ' . ($sortOrder == 0 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default'] . '</option>'; $sort_box .= '<option value="1" ' . ($sortOrder == 1 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default_asc'] . '</option>'; $sort_box .= '<option value="2" ' . ($sortOrder == 2 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload'] . '</option>'; $sort_box .= '<option value="3" ' . ($sortOrder == 3 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload_asc'] . '</option>'; $sort_box .= '<option value="4" ' . ($sortOrder == 4 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture'] . '</option>'; $sort_box .= '<option value="5" ' . ($sortOrder == 5 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture_asc'] . '</option>'; $sort_box .= '<option value="6" ' . ($sortOrder == 6 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating'] . '</option>'; $sort_box .= '<option value="7" ' . ($sortOrder == 7 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating_asc'] . '</option>'; $sort_box .= '<option value="8" ' . ($sortOrder == 8 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views'] . '</option>'; $sort_box .= '<option value="9" ' . ($sortOrder == 9 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views_asc'] . '</option>'; $sort_box .= '<option value="10" ' . ($sortOrder == 10 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha'] . '</option>'; $sort_box .= '<option value="11" ' . ($sortOrder == 11 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha_asc'] . '</option>'; $sort_box .= '</select>'; $sort_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>'; $sort_box .= '</div></form>'; } else { $sort_box = ''; } $owner_id = $MG_albums[$album_id]->owner_id; if ($owner_id == '' || !isset($MG_albums[$album_id]->owner_id)) { $owner_id = 0; } $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . (int) $owner_id); $album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update); $T = new Template($_MG_CONF['template_path']); $T->set_file(array('page' => 'index-all.thtml')); //@TODO fix language tag $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'album_title' => "All Photos - Sorted by Post Date", 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => $album_jumpbox, 'album_id' => $album_id, 'lbslideshow' => $lbSlideShow, 'album_description' => $MG_albums[$album_id]->display_album_desc ? PLG_replaceTags($MG_albums[$album_id]->description) : '', 'album_id_display' => $MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => $admin_box, 'select_sortbox' => $sort_box, 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $MG_albums[$album_id]->getMediaCount(), 'lang_search' => $LANG_MG01['search'], 'table_columns' => $displayColumns)); $T->set_var('select_adminbox', $admin_box); if ($_MG_CONF['rss_full_enabled']) { $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'); $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">'; $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>'; $T->set_var('rsslink', $rsslink); } else { $T->set_var('rsslink', ''); } // completed setting header / footer vars, parse them PLG_templateSetVars('mediagallery', $T); if ($total_media == 0) { $T->set_var(array('lang_no_image' => $LANG_MG03['no_media_objects'])); } // // main processing of the album contents. // $noParse = 0; $needFinalParse = 0; if ($total_media > 0) { $k = 0; $T->set_block('page', 'ImageColumn', 'IColumn'); $T->set_block('page', 'ImageRow', 'IRow'); for ($i = 0; $i < $media_per_page; $i += $columns_per_page) { for ($j = $i; $j < $i + $columns_per_page; $j++) { if ($j >= $total_media) { $k = $i + $columns_per_page - $j; $m = $k % $columns_per_page; for ($z = $m; $z > 0; $z--) { $T->set_var(array('CELL_DISPLAY_IMAGE' => '')); $T->parse('IColumn', 'ImageColumn', true); $needFinalParse = 1; } if ($needFinalParse == 1) { $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); } $noParse = 1; break; } $previous_image = $i - 1; if ($previous_image < 0) { $previous_image = -1; } $next_image = $i + 1; if ($next_image >= $total_media - 1) { $next_image = -1; } $z = $j + $start; $celldisplay = $MG_media[$j]->displayThumb($z, 0, $imageFrameTemplate); if ($MG_media[$j]->type == 1) { $PhotoURL = $_MG_CONF['mediaobjects_url'] . '/disp/' . $MG_media[$j]->filename[0] . '/' . $MG_media[$j]->filename . '.jpg'; $T->set_var(array('URL' => $PhotoURL)); } $T->set_var(array('CELL_DISPLAY_IMAGE' => $celldisplay)); $T->parse('IColumn', 'ImageColumn', true); } if ($noParse == 1) { break; } $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); } } $T->parse('output', 'page'); $fCSS = $nFrame->getCSS(); if ($fCSS != '') { $outputHandle = outputHandler::getInstance(); $outputHandle->addStyle($fCSS); } $display = MG_siteHeader(strip_tags($MG_albums[$album_id]->title)); $display .= $T->finish($T->get_var('output')); $display .= MG_siteFooter(); echo $display; }
function MG_displayMediaImage($mediaObject, $full, $sortOrder, $comments, $sortID = 0, $spage = 0) { global $MG_albums, $_TABLES, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG04, $LANG_ACCESS, $LANG01, $album_jumpbox, $glversion, $_USER, $_MG_USERPREFS; global $_DB_dbms, $LANG04, $ratedIds; $retval = ''; $media_link_start = ''; $media_link_end = ''; $srcID = $mediaObject; $outputHandle = outputHandler::getInstance(); $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($mediaObject) . '"'); if (isset($MG_albums[$aid]->pid)) { $pid = $MG_albums[$aid]->pid; } else { $pid = 0; } if (@method_exists($MG_albums[$aid], 'getOffset')) { $aOffset = $MG_albums[$aid]->getOffset(); } else { $aOffset = -1; } if ($aOffset == -1 || $MG_albums[$aid]->access == 0) { $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true); return array($LANG_MG00['access_denied_msg'], $retval); } $mid = $mediaObject; $orderBy = MG_getSortOrder($aid, $sortOrder); $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma LEFT JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id=" . $aid . $orderBy; $result = DB_query($sql); $nRows = DB_numRows($result); $total_media = $nRows; $media = array(); while ($row = DB_fetchArray($result)) { $media[] = $row; $ids[] = $row['media_id']; } $key = array_search($mid, $ids); if ($key === false) { $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true); return array($LANG_MG00['access_denited_msg'], $retval); } $mediaObject = $key; if ($MG_albums[$aid]->full == 2 || $_MG_CONF['discard_original'] == 1 || $MG_albums[$aid]->full == 1 && COM_isAnonUser()) { $full = 0; } if ($full) { $disp = 'orig'; } else { $disp = 'disp'; } if ($MG_albums[$aid]->enable_comments == 0) { $comments = 0; } if ($sortID > 0) { $MG_albums[$aid]->enable_slideshow = 0; } $themeCSS = ''; $nFrame = new mgFrame(); $nFrame->constructor($MG_albums[$aid]->display_skin); $MG_albums[$aid]->displayFrameTemplate = $nFrame->getTemplate(); $MG_albums[$aid]->dfrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $MG_albums[$aid]->dfrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; $themeCSS = $nFrame->getCSS(); if ($themeCSS != '') { $outputHandle->addStyle($themeCSS); $themeCSS = ''; } $T = new Template(MG_getTemplatePath($aid)); switch ($media[$mediaObject]['media_type']) { case '0': // image $T->set_file('page', 'view_image.thtml'); $ogType = 'article'; break; case '1': // video // video case '5': // embedded video $meta_file_name = $_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext']; COM_errorLog("DEBUG: Video File: " . $meta_file_name); $meta = IMG_getMediaMetaData($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext']); COM_errorLog("DEBUG: Video Meta Type: " . $meta['mime_type']); if ($meta['mime_type'] == 'video/quicktime') { if ($meta['fileformat'] == 'mp4') { $media[$mediaObject]['mime_type'] = 'video/mp4'; } } $T->set_file('page', 'view_video.thtml'); $ogType = 'video.movie'; break; case '2': // audio $T->set_file('page', 'view_audio.thtml'); $ogType = 'music.song'; break; default: $T->set_file('page', 'view_image.thtml'); $ogType = 'article'; break; } $ptitle = isset($media[$mediaObject]['media_title']) && $media[$mediaObject]['media_title'] != ' ' ? PLG_replaceTags($media[$mediaObject]['media_title'], 'mediagallery', 'media_title') : ''; $permalink = COM_buildUrl($_MG_CONF['site_url'] . '/media.php?s=' . $srcID); $outputHandle->addLink("canonical", $permalink); $outputHandle->addMeta('property', 'og:title', $ptitle); $outputHandle->addMeta('property', 'og:type', $ogType); $outputHandle->addMeta('property', 'og:url', $permalink); $T->set_var('permalink', $permalink); $T->set_file(array('shutterfly' => 'digibug.thtml')); $T->set_var('header', $LANG_MG00['plugin']); $T->set_var('site_url', $_MG_CONF['site_url']); $T->set_var('plugin', 'mediagallery'); // construct the album jumpbox... $level = 0; $album_jumpbox = '<form name="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>'; $album_jumpbox .= $LANG_MG03['jump_to'] . ': <select name="aid" onchange="forms[\'jumpbox\'].submit()">'; $MG_albums[0]->buildJumpBox($aid); $album_jumpbox .= '</select>'; $album_jumpbox .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>'; $album_jumpbox .= '<input type="hidden" name="page" value="1"/>'; $album_jumpbox .= '</div></form>'; // Update the views count... But only for non-admins if (!$MG_albums[0]->owner_id) { $media_views = $media[$mediaObject]['media_views'] + 1; DB_query("UPDATE " . $_TABLES['mg_media'] . " SET media_views=" . $media_views . " WHERE media_id='" . DB_escapeString($media[$mediaObject]['media_id']) . "'"); } $columns_per_page = $MG_albums[$aid]->display_columns == 0 ? $_MG_CONF['ad_display_columns'] : $MG_albums[$aid]->display_columns; $rows_per_page = $MG_albums[$aid]->display_rows == 0 ? $_MG_CONF['ad_display_rows'] : $MG_albums[$aid]->display_rows; if (isset($_MG_USERPREFS['display_rows']) && $_MG_USERPREFS['display_rows'] > 0) { $rows_per_page = $_MG_USERPREFS['display_rows']; } if (isset($_MG_USERPREFS['display_columns']) && $_MG_USERPREFS['display_columns'] > 0) { $columns_per_page = $_MG_USERPREFS['display_columns']; } $media_per_page = $columns_per_page * $rows_per_page; if ($MG_albums[$aid]->albums_first) { $childCount = $MG_albums[$aid]->getChildCount(); $page = intval(($mediaObject + $childCount) / $media_per_page) + 1; } else { $page = intval($mediaObject / $media_per_page) + 1; } /* * check to see if the original image exists, if not fall back to full image */ $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext']); if ($media_size_orig == false) { $full = 0; $disp = 'disp'; } $aPage = intval($aOffset / ($_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows'])) + 1; if ($sortID > 0) { $birdseed = '<a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a> ' . ($_MG_CONF['gallery_only'] == 1 ? '' : $_MG_CONF['seperator'] . ' <a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a> ') . $_MG_CONF['seperator'] . '<a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&page=' . $spage . '">' . $LANG_MG03['search_results'] . '</a>'; $MG_albums[$aid]->getPath(1, $sortOrder, $page) . '</a>'; $birdseed_ul = '<li><a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&page=' . $spage . '">' . $LANG_MG03['search_results'] . '</a></li>' . $MG_albums[$aid]->getPath_ul(1, $sortOrder, $page) . '</a>'; $album_link = '<a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&page=' . $spage . '">'; } else { $birdseed = '<a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a> ' . ($_MG_CONF['gallery_only'] == 1 ? '' : $_MG_CONF['seperator'] . ' <a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a> ') . $MG_albums[$aid]->getPath(1, $sortOrder, $page) . '</a>'; $birdseed_ul = '<li><a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a></li>' . $MG_albums[$aid]->getPath_ul(1, $sortOrder, $page) . '</a>'; $album_link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '&page=' . $page . '&sort=' . $sortOrder . '">'; } mg_usage('media_view', $MG_albums[$aid]->title, $media[$mediaObject]['media_title'], $media[$mediaObject]['media_id']); // hack for tga files... if ($media[$mediaObject]['mime_type'] == 'image/x-targa' || $media[$mediaObject]['mime_type'] == 'image/tga') { $full = 0; $disp = 'disp'; } switch ($media[$mediaObject]['mime_type']) { case 'video/x-ms-asf': case 'video/x-ms-asf-plugin': case 'video/avi': case 'video/msvideo': case 'video/x-msvideo': case 'video/avs-video': case 'video/x-ms-wmv': case 'video/x-ms-wvx': case 'video/x-ms-wm': case 'application/x-troff-msvideo': case 'application/x-ms-wmz': case 'application/x-ms-wmd': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full); break; case 'audio/x-ms-wma': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP3($aid, $media[$mediaObject], $full); break; case 'video/mp4': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP4($aid, $media[$mediaObject], $full); break; case 'video/mpeg': case 'video/x-mpeg': case 'video/x-mpeq2a': if ($_MG_CONF['use_wmp_mpeg'] == 1) { list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full); break; } case 'video/x-motion-jpeg': case 'video/quicktime': case 'video/x-qtc': case 'video/x-m4v': if ($media[$mediaObject]['media_mime_ext'] == 'mp4' && isset($_MG_CONF['play_mp4_flv']) && $_MG_CONF['play_mp4_flv'] == true) { list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayFLV($aid, $media[$mediaObject], $full); } else { list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMOV($aid, $media[$mediaObject], $full); } break; case 'embed': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayEmbed($aid, $media[$mediaObject], $full, $mediaObject); break; case 'application/x-shockwave-flash': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displaySWF($aid, $media[$mediaObject], $full); break; case 'video/x-flv': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayFLV($aid, $media[$mediaObject], $full); break; case 'audio/mpeg': case 'audio/x-mpeg': case 'audio/mpeg3': case 'audio/x-mpeg-3': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP3($aid, $media[$mediaObject], $full); break; case 'application/ogg': case 'application/x-ogg': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayOGG($aid, $media[$mediaObject], $full); break; case 'image/x-targa': case 'image/tga': case 'image/tiff': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayTGA($aid, $media[$mediaObject], $full, $mediaObject); break; case 'image/photoshop': case 'image/x-photoshop': case 'image/psd': case 'application/photoshop': case 'application/psd': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayPSD($aid, $media[$mediaObject], $full, $mediaObject); break; case 'image/gif': case 'image/jpeg': case 'image/jpg': case 'image/png': case 'image/bmp': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url, $media_link_start, $media_link_end) = MG_displayJPG($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder, $sortID, $spage); break; default: switch ($media[$mediaObject]['media_mime_ext']) { case 'jpg': case 'gif': case 'png': case 'bmp': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url, $media_link_start, $media_link_end) = MG_displayJPG($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder, $sortID, $spage); break; case 'asf': list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full); break; default: list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayGeneric($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder); break; } } $mid = $media[$mediaObject]['media_id']; $media_date = MG_getUserDateTimeFormat($media[$mediaObject]['media_time']); $upload_date = MG_getUserDateTimeFormat($media[$mediaObject]['media_upload_time']); // build the rating bar if rating is enabled. if ($MG_albums[$aid]->enable_rating > 0) { $uid = COM_isAnonUser() ? 1 : $_USER['uid']; $static = false; $voted = 0; // check to see if we are the owner, if so, no rating for us... if (isset($_USER['uid']) && $_USER['uid'] == $media[$mediaObject]['media_user_id']) { $static = true; $voted = 0; } else { if (in_array($media[$mediaObject]['media_id'], $ratedIds)) { $static = true; $voted = 1; } else { $static = 0; $voted = 0; } } if ($MG_albums[$aid]->enable_rating == 1 && COM_isAnonUser()) { $static = true; $voted = 0; } $rating_box = RATING_ratingBar('mediagallery', $media[$mediaObject]['media_id'], $media[$mediaObject]['media_votes'], $media[$mediaObject]['media_rating'], $voted, 5, $static, ''); } else { $rating_box = ''; } $T->set_var('rating_box', $rating_box); if ($MG_albums[$aid]->allow_download) { $T->set_var(array('download' => '<a href="' . $_MG_CONF['site_url'] . '/download.php?mid=' . $media[$mediaObject]['media_id'] . '">' . $LANG_MG01['download'] . '</a>')); } if ($media[$mediaObject]['media_type'] == 0 && $MG_albums[$aid]->enable_shutterfly) { $media_size_orig = false; $media_size_tn = false; if ($_MG_CONF['discard_original'] == 1) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) { $sf_picture = $_MG_CONF['mediaobjects_url'] . '/disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext; $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext); break; } } } else { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) { $sf_picture = $_MG_CONF['mediaobjects_url'] . '/orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext; $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext); break; } } } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) { $tnImage = $_MG_CONF['mediaobjects_url'] . '/tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext; $media_size_tn = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext); break; } } $outputHandle->addMeta('property', 'og:image', $tnImage); if ($media_size_orig != false && $media_size_tn != false) { $T->set_var(array('sf_height' => $media_size_orig[1], 'sf_width' => $media_size_orig[0], 'sf_tn_height' => $media_size_tn[1], 'sf_tn_width' => $media_size_tn[0], 'sf_thumbnail' => $tnImage, 'sf_picture' => $sf_picture, 'sf_title' => $media[$mediaObject]['media_title'], 'lang_print_digibug' => $LANG_MG03['print_digibug'], 'lang_print_shutterfly' => $LANG_MG03['print_shutterfly'])); $T->parse('shutterfly_submit', 'shutterfly'); } } if ($MG_albums[$aid]->access == 3 || $_MG_CONF['allow_user_edit'] == true && isset($_USER['uid']) && $media[$mediaObject]['media_user_id'] == $_USER['uid']) { $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $aid . '&mid=' . $mid . '">' . $LANG_MG01['edit'] . '</a>'; } else { $edit_item = ''; } $media_desc = PLG_replaceTags(nl2br($media[$mediaObject]['media_desc']), 'mediagallery', 'media_description'); if (strlen($media_desc) > 0) { USES_lib_html2text(); $metaDesc = $media_desc; $metaDesc = strip_tags($metaDesc); $html2txt = new html2text($metaDesc, false); $metaDesc = trim($html2txt->get_text()); $shortComment = ''; $metaArray = explode(' ', $metaDesc); $wordCount = count($metaArray); $lengthCount = 0; $tailString = ''; foreach ($metaArray as $word) { $lengthCount = $lengthCount + strlen($word); $shortComment .= $word . ' '; if ($lengthCount >= 100) { $tailString = '...'; break; } } $metaDesc = trim($shortComment) . $tailString; $outputHandle->addMeta('name', 'description', htmlspecialchars($metaDesc, ENT_QUOTES, COM_getEncodingt())); $media_desc .= '<br/><br/>'; } // start of the lightbox slideshow code if ($MG_albums[$aid]->enable_slideshow == 2) { $lbSlideShow = '<noscript><div class="pluginAlert">' . $LANG04[150] . '</div></noscript>' . LB; $lbSlideShow .= '<script type="text/javascript">' . LB; $lbSlideShow .= 'function openGallery1() {' . LB; $lbSlideShow .= ' return loadXMLDoc("' . $_MG_CONF['site_url'] . '/lightbox.php?aid=' . $aid . '");'; $lbSlideShow .= '}' . LB; $lbSlideShow .= '</script>' . LB; $T->set_var('lbslideshow', $lbSlideShow); } else { $T->set_var('lbslideshow', ''); } // end of the lightbox slideshow code switch ($MG_albums[$aid]->enable_slideshow) { case 0: $url_slideshow = ''; break; case 1: $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/slideshow.php?aid=' . $aid . '&sort=' . $sortOrder . '"><b>' . $LANG_MG03['slide_show'] . '</b></a>'; break; case 2: $lbss_count = DB_count($_TABLES['mg_media'], 'media_type', 0); $sql = "SELECT COUNT(m.media_id) as lbss_count FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE m.media_type = 0 AND ma.album_id=" . $aid; $res = DB_query($sql); list($lbss_count) = DB_fetchArray($res); if ($lbss_count != 0) { $url_slideshow = '<span id="mgslideshow" class="jsenabled_show" style="display:none"><a href="#" onclick="return openGallery1()"><b>' . $LANG_MG03['slide_show'] . '</b></a></span>'; } else { $MG_albums[$aid]->enable_slideshow = 0; } break; case 3: $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/fslideshow.php?aid=' . $aid . '&src=disp"><b>' . $LANG_MG03['slide_show'] . '</b></a>'; break; case 4: $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/fslideshow.php?aid=' . $aid . '&src=orig"><b>' . $LANG_MG03['slide_show'] . '</b></a>'; break; } $prevLink = ''; $nextLink = ''; list($prevLink, $nextLink) = $sortID > 0 ? array('', '') : MG_getNextandPrev($_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&sort=" . $sortOrder, $nRows, 1, $mediaObject, $media, TRUE); $T->set_var(array('birdseed' => $birdseed, 'birdseed_ul' => $birdseed_ul, 'slide_show' => isset($url_slideshow) ? $url_slideshow : '', 'image_detail' => $u_image, 'border_height' => $raw_image_height + 30, 'border_width' => $raw_image_width + 30, 'media_title' => isset($media[$mediaObject]['media_title']) && $media[$mediaObject]['media_title'] != ' ' ? PLG_replaceTags($media[$mediaObject]['media_title'], 'mediagallery', 'media_title') : '', 'album_title' => $sortID > 0 ? $LANG_MG03['search_results'] : $MG_albums[$aid]->title, 'media_desc' => isset($media[$mediaObject]['media_desc']) && $media[$mediaObject]['media_desc'] != ' ' ? $media_desc : '', 'artist' => isset($media[$mediaObject]['artist']) ? $media[$mediaObject]['artist'] : '', 'media_time' => $media_date[0], 'upload_time' => $upload_date[0], 'media_views' => $MG_albums[$aid]->enable_views ? $media[$mediaObject]['media_views'] : '', 'media_comments' => $MG_albums[$aid]->enable_comments ? $media[$mediaObject]['media_comments'] . '<br />' : '', 'pagination' => $sortID > 0 ? '' : generate_pic_pagination($_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&sort=" . $sortOrder, $nRows, 1, $mediaObject, $media, TRUE), 'media_number' => sprintf("%s %d %s %d", $LANG_MG03['image'], $mediaObject + 1, $LANG_MG03['of'], $total_media), 'jumpbox' => $album_jumpbox, 'edit_item' => $edit_item, 'site_url' => $_MG_CONF['site_url'], 'lang_prev' => $LANG_MG03['previous'], 'lang_next' => $LANG_MG03['next'], 'next_link' => $nextLink, 'prev_link' => $prevLink, 'image_height' => $raw_image_height, 'image_width' => $raw_image_width, 'left_side' => intval($raw_image_width / 2) - 1, 'right_side' => intval($raw_image_width / 2), 'raw_image' => $raw_image, 'media_link_start' => $media_link_start, 'media_link_end' => $media_link_end, 'raw_link_url' => $raw_link_url, 'album_link' => $MG_albums[$aid]->getPath(1, $sortOrder, $page), 'item_number' => $mediaObject + 1, 'total_items' => $total_media, 'lang_of' => $LANG_MG03['of'], 'album_link' => $album_link)); $getid3link = ''; $getid3linkend = ''; $T->set_var(array('getid3' => $getid3link, 'getid3end' => $getid3linkend)); if ($getid3link != '') { $T->set_var('media_properties', $LANG_MG03['media_properties']); } else { $T->set_var('media_properties', ''); } if ($MG_albums[$aid]->enable_keywords == 1 && !empty($media[$mediaObject]['media_keywords'])) { $kwText = ''; $keyWords = array(); $keyWords = explode(' ', $media[$mediaObject]['media_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('media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords'])); } else { $T->set_var(array('media_keywords' => '', 'lang_keywords' => '')); } if ($media[$mediaObject]['media_user_id'] == '' || !isset($media[$mediaObject]['media_user_id'])) { $media[$mediaObject]['media_user_id'] = 0; } if ($_CONF['show_fullname']) { $displayname = 'fullname'; } else { $displayname = 'username'; } $owner_name = DB_getItem($_TABLES['users'], $displayname, "uid = {$media[$mediaObject]['media_user_id']}"); if (empty($owner_name) || $owner_name == '') { $owner_name = DB_getItem($_TABLES['users'], 'username', "uid = {$media[$mediaObject]['media_user_id']}"); if (empty($owner_name) || $owner_name == '') { $owner_name = 'unknown'; } } if ($owner_name != 'unknown') { $owner_link = '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $media[$mediaObject]['media_user_id'] . '">' . $owner_name . '</a>'; } else { $owner_link = $owner_name; } $T->set_var('owner_username', $owner_link); if (($MG_albums[$aid]->exif_display == 2 || $MG_albums[$aid]->exif_display == 3) && $media[$mediaObject]['media_type'] == 0) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php'; $haveEXIF = MG_haveEXIF($media[$mediaObject]['media_id']); if ($haveEXIF) { $T->set_var(array('property' => $_MG_CONF['site_url'] . '/property.php?mid=' . $media[$mediaObject]['media_id'], 'lang_property' => $LANG_MG04['exif_header'])); } } if ($MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1) { $T->set_var(array('media_id' => $media[$mediaObject]['media_id'])); } // Language specific vars $T->set_var(array('lang_comments' => $MG_albums[$aid]->enable_comments ? $LANG_MG03['comments'] : '', 'lang_views' => $MG_albums[$aid]->enable_views ? $LANG_MG03['views'] : '', 'lang_title' => $LANG_MG01['title'], 'print_shutterfly' => $LANG_MG03['print_shutterfly'], 'lang_uploaded_by' => $LANG_MG01['uploaded_by'], 'album_id' => $aid, 'lang_search' => $LANG_MG01['search'])); if (($MG_albums[$aid]->exif_display == 1 || $MG_albums[$aid]->exif_display == 3) && $media[$mediaObject]['media_type'] == 0) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php'; $haveEXIF = MG_haveEXIF($media[$mediaObject]['media_id']); if ($haveEXIF) { $exifData = MG_readEXIF($media[$mediaObject]['media_id'], 2); $T->set_var(array('exif_info' => $exifData)); } } if ($sortID == 0) { if ($MG_albums[$aid]->enable_postcard == 1 && !COM_isAnonUser() || $MG_albums[$aid]->enable_postcard == 2) { if ($media[$mediaObject]['media_type'] == 0) { $postcard_link = '<a href="' . $_MG_CONF['site_url'] . '/postcard.php?mode=edit&mid=' . $media[$mediaObject]['media_id'] . '"><img src="' . MG_getImageFile('icon_envelopeSmall.gif') . '" alt="' . $LANG_MG03['send_postcard'] . '" style="border:none;"/></a>'; $T->set_var('postcard_link', $postcard_link); } } } PLG_templateSetVars('mediagallery', $T); $T->parse('output', 'page'); $retval .= $T->finish($T->get_var('output')); if ($comments) { // glFusion Comment support $mid = $media[$mediaObject]['media_id']; if ($MG_albums[$aid]->enable_comments == 1) { USES_lib_comment(); if ($MG_albums[$aid]->access == 3 || $MG_albums[0]->owner_id) { $delete_option = true; } else { $delete_option = false; } if (DB_count($_TABLES['comments'], 'sid', $mid) > 0 || $_MG_CONF['commentbar']) { $cid = $mid; $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0; if (isset($_POST['order'])) { $comorder = $_POST['order'] == 'ASC' ? 'ASC' : 'DESC'; } elseif (isset($_GET['order'])) { $comorder = $_GET['order'] == 'ASC' ? 'ASC' : 'DESC'; } else { $comorder = ''; } if (isset($_POST['mode'])) { $commode = COM_applyFilter($_POST['mode']); } elseif (isset($_GET['mode'])) { $commode = COM_applyFilter($_GET['mode']); } else { $commode = ''; } $valid_cmt_modes = array('flat', 'nested', 'nocomment', 'nobar'); if (!in_array($commode, $valid_cmt_modes)) { $commode = 'nested'; } $commentbar = CMT_userComments($cid, $media[$mediaObject]['media_title'], 'mediagallery', $comorder, $commode, 0, $page, false, $delete_option, 0, $media[$mediaObject]['media_user_id']); $retval .= $commentbar; } else { $retval .= ' <center><a href="' . $_CONF['site_url'] . '/comment.php?sid=' . $mid . '&title=' . $title . '&pid=0&type=mediagallery' . '">' . $LANG01[60] . '</a></center>'; } } } return array(strip_tags($media[$mediaObject]['media_title']), $retval, '', $aid); }