Exemplo n.º 1
0
    $T->set_block('page', 'ImageRow', 'IRow');
    for ($i = 0; $i < $media_per_page; $i += $columns_per_page) {
        $next_columns = $i + $columns_per_page;
        for ($j = $i; $j < $next_columns; $j++) {
            if ($j >= $total_media) {
                $T->parse('IRow', 'ImageRow', true);
                $T->set_var('IColumn', '');
                break 2;
            }
            $T->set_var('clear_float', '');
            if ($col == $columns_per_page) {
                $T->set_var('clear_float', ' clear:both;');
                $col = 0;
            }
            $T->set_var('CELL_DISPLAY_IMAGE', MG_albumThumbnail($sub_album_id[$j]));
            $T->parse('IColumn', 'ImageColumn', true);
            $col++;
        }
        $T->parse('IRow', 'ImageRow', true);
        $T->set_var('IColumn', '');
    }
    $T->set_var('album_body', 1);
} else {
    $T->set_var('lang_no_image', $LANG_MG03['no_media_objects']);
}
$T->parse('output', 'page');
MG_getThemePublicJSandCSS($root_album->skin);
MG_getCSS($root_album->album_skin);
$display = $T->finish($T->get_var('output'));
$display = MG_createHTMLDocument($display);
COM_output($display);
Exemplo n.º 2
0
function MG_displayMedia($id, $full = 0, $sortOrder = 0, $comments = 0, $spage = 0)
{
    global $_TABLES, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG04, $LANG_ACCESS, $_USER;
    $retval = '';
    $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . addslashes($id) . '"');
    require_once $_CONF['path'] . 'plugins/mediagallery/include/classAlbum.php';
    $mg_album = new mgAlbum($aid);
    $root_album = new mgAlbum(0);
    $pid = 0;
    if (isset($mg_album->pid)) {
        $pid = $mg_album->pid;
    }
    $aOffset = -1;
    $aOffset = $mg_album->getOffset();
    if ($aOffset == -1 || $mg_album->access == 0) {
        $retval = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
        return array($LANG_MG00['access_denied_msg'], $retval);
    }
    $sql = MG_buildMediaSql(array('album_id' => $aid, 'sortorder' => $mg_album->enable_sort ? $sortOrder : 0));
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    $total_media = $nRows;
    $media_array = array();
    while ($row = DB_fetchArray($result)) {
        $media_array[] = $row;
        $id_array[] = $row['media_id'];
    }
    $key = array_search($id, $id_array);
    if ($key === false) {
        $retval = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
        return array($LANG_MG00['access_denied_msg'], $retval);
    }
    $media = $media_array[$key];
    if ($mg_album->full == 2 || $_MG_CONF['discard_original'] == 1 || $mg_album->full == 1 && $_USER['uid'] > 1) {
        $full = 0;
    }
    $disp = $full ? 'orig' : 'disp';
    if ($mg_album->enable_comments == 0) {
        $comments = 0;
    }
    $display_skin = $mg_album->display_skin;
    MG_getCSS($display_skin);
    // construct the album jumpbox...
    $album_jumpbox = '';
    if (!$_MG_CONF['hide_jumpbox_on_mediaview']) {
        $album_jumpbox = MG_buildAlbumJumpbox($root_album, $aid, 1, -1);
    }
    // Update the views count... But only for non-admins
    if (!$root_album->owner_id) {
        $media_views = $media['media_views'] + 1;
        DB_change($_TABLES['mg_media'], 'media_views', $media_views, 'media_id', addslashes($media['media_id']));
    }
    $columns_per_page = $mg_album->display_columns == 0 ? $_MG_CONF['ad_display_columns'] : $mg_album->display_columns;
    $rows_per_page = $mg_album->display_rows == 0 ? $_MG_CONF['ad_display_rows'] : $mg_album->display_rows;
    $_MG_USERPREFS = MG_getUserPrefs();
    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_album->albums_first) {
        $childCount = $mg_album->getChildCount();
        $page = intval(($key + $childCount) / $media_per_page) + 1;
    } else {
        $page = intval($key / $media_per_page) + 1;
    }
    /*
     * check to see if the original image exists, if not fall back to full image
     */
    $media_size_orig = @getimagesize(Media::getFilePath('orig', $media['media_filename'], $media['media_mime_ext']));
    if ($media_size_orig == false) {
        $full = 0;
        $disp = 'disp';
    }
    $aPage = intval($aOffset / ($root_album->display_columns * $root_album->display_rows)) + 1;
    $birdseed = MG_getBirdseed($mg_album->id, 1, $sortOrder, $aPage);
    $album_link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '&amp;page=' . $page . '&amp;sort=' . $sortOrder . '">';
    if ($_MG_CONF['usage_tracking']) {
        MG_updateUsage('media_view', $mg_album->title, $media['media_title'], $media['media_id']);
    }
    // hack for tga files...
    if ($media['mime_type'] == 'image/x-targa' || $media['mime_type'] == 'image/tga') {
        $full = 0;
        $disp = 'disp';
    }
    $prevLink = '';
    $nextLink = '';
    $pagination = '';
    $base_url = $_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&amp;sort=" . $sortOrder;
    list($prevLink, $nextLink) = MG_getNextandPrev($base_url, $nRows, $key, $media_array);
    // generate pagination routine
    if (!empty($prevLink)) {
        $pagination .= '<a href="' . $prevLink . '">' . $LANG_MG03['previous'] . '</a>';
    }
    if (!empty($nextLink)) {
        $pagination .= !empty($prevLink) ? '&nbsp;&nbsp;&nbsp;' : '';
        $pagination .= '<a href="' . $nextLink . '">' . $LANG_MG03['next'] . '</a>';
    }
    $pagination .= LB;
    // hack for testing...>>>
    $media_id = $media['media_id'];
    if ($_MG_CONF['click_image_and_go_next'] && !$_MG_CONF['full_in_popup']) {
        $nextkey = MG_getNextitem($nRows, $key);
        if ($nextkey !== '') {
            $media_id = $media_array[$nextkey]['media_id'];
        }
    }
    $vf = $full;
    if ($media['media_type'] == '0') {
        // image
        $switch_size = $_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '0' : '1') . '&amp;sort=' . $sortOrder . '&amp;s=' . $media['media_id'];
        $lang_switch_size = $full ? $LANG_MG03['normal_size'] : $LANG_MG03['full_size'];
        $switch_viewsize_link = '<a href="' . $switch_size . '">' . $lang_switch_size . '</a>';
    }
    // hack for testing...<<<
    $opt = array('full' => $full, 'media_id' => $media_id, 'sortOrder' => $sortOrder, 'spage' => $spage, 'playback_type' => $mg_album->playback_type, 'skin' => $mg_album->skin, 'display_skin' => $mg_album->display_skin, 'allow_download' => $mg_album->allow_download, 'full_display' => $mg_album->full);
    list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_buildContent($media, $opt);
    $mid = $media['media_id'];
    if ($_MG_CONF['use_upload_time'] == 1) {
        $media_date = MG_getUserDateTimeFormat($media['upload_time']);
    } else {
        $media_date = MG_getUserDateTimeFormat($media['media_time']);
    }
    $rating_box = '';
    if ($mg_album->enable_rating > 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-rating.php';
        $rating_box = MG_getRatingBar($mg_album->enable_rating, $media['media_user_id'], $media['media_id'], $media['media_votes'], $media['media_rating'], '');
    }
    $download_link = '';
    $download = '';
    if ($mg_album->allow_download) {
        $download_link = $_MG_CONF['site_url'] . '/download.php?mid=' . $media['media_id'];
        $download = '<a href="' . $download_link . '">' . $LANG_MG01['download'] . '</a>';
    }
    $edit_item_link = '';
    $edit_item = '';
    if ($mg_album->access == 3 || $_MG_CONF['allow_user_edit'] == true && isset($_USER['uid']) && $media['media_user_id'] == $_USER['uid']) {
        $edit_item_link = $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;s=1&amp;album_id=' . $aid . '&amp;mid=' . $mid;
        $edit_item = '<a href="' . $edit_item_link . '">' . $LANG_MG01['edit'] . '</a>';
    }
    $media_desc = PLG_replaceTags(nl2br($media['media_desc']));
    if (strlen($media_desc) > 0) {
        $media_desc = '<p style="margin:5px">' . $media_desc . '</p>';
    }
    $getid3link = '';
    $getid3linkend = '';
    $media_properties = $getid3link != '' ? $LANG_MG03['media_properties'] : '';
    $kwText = '';
    $lang_keywords = '';
    if ($mg_album->enable_keywords == 1 && !empty($media['media_keywords'])) {
        $lang_keywords = $LANG_MG01['keywords'];
        $keyWords = array();
        $keyWords = explode(' ', $media['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&amp;swhere=1&amp;keywords=' . $searchKeyword . '&amp;keyType=any">' . $keyWords[$i] . '</a>';
        }
    }
    $media_user_id = $media['media_user_id'];
    if (empty($media_user_id)) {
        $media_user_id = 0;
    }
    $displayname = $_CONF['show_fullname'] ? 'fullname' : 'username';
    $owner_name = DB_getItem($_TABLES['users'], $displayname, "uid = {$media_user_id}");
    if (empty($owner_name)) {
        $owner_name = DB_getItem($_TABLES['users'], 'username', "uid = {$media_user_id}");
        if (empty($owner_name)) {
            $owner_name = 'unknown';
        }
    }
    $owner_link = $owner_name;
    if ($owner_name != 'unknown') {
        $owner_link = '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $media_user_id . '">' . $owner_name . '</a>';
    }
    $property = '';
    if (($mg_album->exif_display == 2 || $mg_album->exif_display == 3) && $media['media_type'] == 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
        $haveEXIF = MG_haveEXIF($media['media_id']);
        if ($haveEXIF) {
            $property = $_MG_CONF['site_url'] . '/property.php?mid=' . $media['media_id'];
        }
    }
    $media_id = '';
    if ($root_album->owner_id || $_MG_CONF['enable_media_id'] == 1) {
        $media_id = $media['media_id'];
    }
    $exif_info = '';
    if (($mg_album->exif_display == 1 || $mg_album->exif_display == 3) && $media['media_type'] == 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
        $haveEXIF = MG_haveEXIF($media['media_id']);
        if ($haveEXIF) {
            $exif_info = MG_readEXIF($media['media_id'], 2);
        }
    }
    $T = COM_newTemplate(MG_getTemplatePath_byName($mg_album->skin));
    switch ($media['media_type']) {
        case '0':
            // image
            $T->set_file('page', 'view_image.thtml');
            break;
        case '1':
            // video
        // video
        case '5':
            // embedded video
            $T->set_file('page', 'view_video.thtml');
            break;
        case '2':
            // audio
            $T->set_file('page', 'view_audio.thtml');
            break;
        default:
            $T->set_file('page', 'view_image.thtml');
            break;
    }
    $T->set_var(array('header' => $LANG_MG00['plugin'], 'site_url' => $_MG_CONF['site_url'], 'plugin' => 'mediagallery', 'birdseed' => $birdseed, 'lang_slideshow_link' => $LANG_MG03['slide_show'], 'image_detail' => $u_image, 'media_title' => isset($media['media_title']) && $media['media_title'] != ' ' ? PLG_replaceTags($media['media_title']) : '', 'album_title' => $mg_album->title, 'media_desc' => isset($media['media_desc']) && $media['media_desc'] != ' ' ? $media_desc : '', 'media_time' => $media_date[0], 'media_views' => $mg_album->enable_views ? $media['media_views'] : '', 'media_comments' => $mg_album->enable_comments ? $media['media_comments'] : '', 'pagination' => $pagination, 'media_number' => sprintf("%s %d %s %d", $LANG_MG03['image'], $key + 1, $LANG_MG03['of'], $total_media), 'jumpbox' => $album_jumpbox, 'rating_box' => $rating_box, 'download' => $download, 'download_link' => $download_link, 'lang_download' => $LANG_MG01['download'], 'edit_item' => $edit_item, 'edit_item_link' => $edit_item_link, 'lang_edit' => $LANG_MG01['edit'], '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, 'raw_link_url' => $raw_link_url, 'item_number' => $key + 1, 'total_items' => $total_media, 'lang_of' => $LANG_MG03['of'], 'album_link' => $album_link, 'switch_size' => $switch_size, 'lang_switch_size' => $lang_switch_size, 'switch_size_link' => $switch_viewsize_link, 'getid3' => $getid3link, 'getid3end' => $getid3linkend, 'media_properties' => $media_properties, 'media_keywords' => $kwText, 'lang_keywords' => $lang_keywords, 'owner_username' => $owner_link, 'property' => $property, 'lang_property' => $LANG_MG04['exif_header'], 'media_id' => $media_id, 'exif_info' => $exif_info, 'lang_comments' => $mg_album->enable_comments ? $LANG_MG03['comments'] : '', 'lang_views' => $mg_album->enable_views ? $LANG_MG03['views'] : '', 'lang_title' => $LANG_MG01['title'], 'lang_uploaded_by' => $LANG_MG01['uploaded_by'], 'album_id' => $aid, 'lang_search' => $LANG_MG01['search']));
    MG_buildSlideshow($mg_album, $T, $sortOrder);
    PLG_templateSetVars('mediagallery', $T);
    $retval .= $T->finish($T->parse('output', 'page'));
    if ($comments) {
        // Geeklog Comment support
        $sid = $media['media_id'];
        require_once $_CONF['path_system'] . 'lib-comment.php';
        $delete_option = false;
        if ($mg_album->access == 3 || $root_album->owner_id) {
            $delete_option = true;
        }
        $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0;
        $comorder = '';
        if (isset($_POST['order'])) {
            $comorder = COM_applyFilter($_POST['order']);
        } elseif (isset($_GET['order'])) {
            $comorder = COM_applyFilter($_GET['order']);
        }
        $commode = '';
        if (isset($_POST['mode'])) {
            $commode = COM_applyFilter($_POST['mode']);
        } elseif (isset($_GET['mode'])) {
            $commode = COM_applyFilter($_GET['mode']);
        }
        $commentcode = 0;
        // 今のところ無条件にコメント投稿を許可。
        $retval .= CMT_userComments($sid, $media['media_title'], 'mediagallery', $comorder, $commode, 0, $page, false, $delete_option, $commentcode);
    }
    return array(strip_tags($media['media_title']), $retval, $aid);
}
Exemplo n.º 3
0
    $T = COM_newTemplate(MG_getTemplatePath_byName());
    $T->set_file('page', 'search_page.thtml');
    $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => '', 'bottom_pagination' => '', 'page_number' => $page_number, 'lang_search_results' => $LANG_MG03['search_results'], 'lang_return_to_index' => $LANG_MG03['return_to_index'], 'return_url' => $_MG_CONF['site_url'], 'search_keywords' => '', 'lang_search' => $LANG_MG01['search']));
    MG_buildSearchBox($T, $searchinfo);
    $T->set_var('lang_no_image', '');
    return $T->finish($T->parse('output', 'page'));
}
/*
* Main Function
*/
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$root_album = new mgAlbum(0);
$skin = !empty($_MG_CONF['search_album_skin']) ? $_MG_CONF['search_album_skin'] : $root_album->skin;
MG_getThemePublicJSandCSS($skin);
$frame_skin = !empty($_MG_CONF['search_frame_skin']) ? $_MG_CONF['search_frame_skin'] : $root_album->image_skin;
MG_getCSS($frame_skin);
$display = '';
$mode = isset($_REQUEST['mode']) ? COM_applyFilter($_REQUEST['mode']) : '';
$keywords = isset($_REQUEST['keywords']) ? COM_applyFilter($_REQUEST['keywords']) : '';
$stype = isset($_REQUEST['keyType']) ? COM_applyFilter($_REQUEST['keyType']) : 'phrase';
$category = isset($_REQUEST['cat_id']) ? COM_applyFilter($_REQUEST['cat_id']) : 0;
$skeywords = isset($_REQUEST['swhere']) ? COM_applyFilter($_REQUEST['swhere']) : 1;
$numresults = isset($_REQUEST['numresults']) ? COM_applyFilter($_REQUEST['numresults'], true) : 10;
$users = isset($_REQUEST['uid']) ? COM_applyFilter($_REQUEST['uid'], true) : 0;
$sortyby = 'title';
// no use?
$sortdirection = 'DESC';
// no use?
$searchinfo = array('keywords' => $keywords, 'keytype' => $stype, 'cat_id' => $category, 'swhere' => $skeywords, 'numresults' => $numresults, 'uid' => $users);
if ($mode == $LANG_MG01['search'] || $mode == 'search') {
    $f_all = false;
Exemplo n.º 4
0
            } else {
                // regular media type
                $celldisplay = $MG_media[$j]['obj']->displayThumb($opt);
                if ($MG_media[$j]['obj']->type == 1) {
                    $T->set_var('URL', MG_getFilePath('disp', $MG_media[$j]['obj']->filename, 'jpg'));
                }
            }
            $T->set_var('clear_float', '');
            if ($col == $columns_per_page) {
                $T->set_var('clear_float', ' clear:both;');
                $col = 0;
            }
            $T->set_var('CELL_DISPLAY_IMAGE', $celldisplay);
            $T->parse('IColumn', 'ImageColumn', true);
            $col++;
        }
        $T->parse('IRow', 'ImageRow', true);
        $T->set_var('IColumn', '');
    }
    $T->set_var('album_body', 1);
} else {
    $T->set_var('lang_no_image', $LANG_MG03['no_media_objects']);
}
MG_getThemePublicJSandCSS($album->skin);
MG_getCSS($album->image_skin);
if ($album->image_skin != $album->album_skin) {
    MG_getCSS($album->album_skin);
}
$display = $T->finish($T->parse('output', 'page'));
$display = MG_createHTMLDocument($display);
COM_output($display);