Пример #1
0
 foreach ($userMediaItems as $item) {
     if (!$item['private'] || $admin) {
         $baseId = "{$user['username']}-media-id-{$item['id']}";
         $jsSelectorId = CJSON::encode("#{$baseId}");
         $propertyId = addslashes($baseId);
         $desc = CHtml::encode($item['description']);
         echo '<span class="x2-pillbox media-item">';
         $path = Media::getFilePath($item['uploadedBy'], $item['fileName']);
         $filename = $item['drive'] ? $item['name'] : $item['fileName'];
         if (mb_strlen($filename, 'UTF-8') > 35) {
             $filename = mb_substr($filename, 0, 32, 'UTF-8') . '…';
         }
         echo CHtml::link($filename, array('/media', 'view' => $item['id']), array('class' => 'x2-link media media-library-item' . (Media::isImageExt($item['fileName']) ? ' image-file' : ''), 'id' => $baseId, 'data-url' => Media::model()->findByPk($item['id'])->getPublicUrl()));
         echo '</span>';
         if (Media::isImageExt($item['fileName'])) {
             $imageLink = Media::getFileUrl($path);
             $image = CHtml::image($imageLink, '', array('class' => 'media-hover-image'));
             $imageStr = CJSON::encode($image);
             if ($item['description']) {
                 $content = CJSON::encode("<span style=\"max-width: 200px;\">{$image} {$desc}</span>");
                 $imageTooltips .= "\$({$jsSelectorId}).qtip({content: {$content}, position: {my: 'top right', at: 'bottom left'}});\n";
             } else {
                 $imageTooltips .= "\$({$jsSelectorId}).qtip({content: {$imageStr}, position: {my: 'top right', at: 'bottom left'}});\n";
             }
         } else {
             if ($item['description']) {
                 $content = CJSON::encode($desc);
                 $imageTooltips .= "\$({$jsSelectorId}).qtip({content: {$content}, position: {my: 'top right', at: 'bottom left'}});\n";
             }
         }
     }
Пример #2
0
function MG_imageAdmin($album_id, $page, $actionURL = '')
{
    global $_CONF, $_TABLES, $_USER, $_MG_CONF, $LANG_MG00, $LANG_MG01;
    $album = new mgAlbum($album_id);
    if ($actionURL == '') {
        $actionURL = $_MG_CONF['site_url'] . '/index.php';
    }
    if ($page > 0) {
        $page = $page - 1;
    }
    $begin = $_MG_CONF['mediamanage_items'] * $page;
    $end = $_MG_CONF['mediamanage_items'];
    $retval = '';
    $T = COM_newTemplate(MG_getTemplatePath($album_id));
    $T->set_file(array('admin' => 'mediamanage.thtml', 'media' => 'mediaitems.thtml'));
    // -- Get Album Cover Info..
    if ($album->access != 3) {
        COM_errorLog("Someone has tried to illegally edit media in Media Gallery. " . "User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1);
        return COM_showMessageText($LANG_MG00['access_denied_msg']);
    }
    $album_cover = $album->cover;
    $album_selectbox = '<select name="album">';
    $root_album = new mgAlbum(0);
    $root_album->buildAlbumBox($album_selectbox, $album_id, 3, $album_id, 'manage');
    $album_selectbox .= '</select>';
    $sql = "SELECT * FROM {$_TABLES['mg_category']} ORDER BY cat_id ASC";
    $result = DB_query($sql);
    $nrows = DB_numRows($result);
    for ($i = 0; $i < $nrows; $i++) {
        $catRow[$i] = DB_fetchArray($result);
    }
    $sql = "SELECT COUNT(*) AS totalitems " . "FROM {$_TABLES['mg_media_albums']} " . "WHERE album_id=" . intval($album_id);
    $result = DB_query($sql);
    $row = DB_fetchArray($result);
    $totalAlbumItems = $row['totalitems'];
    $sql = MG_buildMediaSql(array('album_id' => $album_id, 'offset' => $begin, 'limit' => $end));
    $result = DB_query($sql);
    $nrows = DB_numRows($result);
    $batchOptionSelect = '<select name="batchOption">';
    if ($_CONF['image_lib'] == 'gdlib' && !function_exists("imagerotate")) {
        $batchOptionSelect .= '';
    } else {
        $batchOptionSelect .= '<option value="rrt">' . $LANG_MG01['rotate_right'] . '</option>';
        $batchOptionSelect .= '<option value="rlt">' . $LANG_MG01['rotate_left'] . '</option>';
    }
    if ($album->wm_id != 0) {
        $batchOptionSelect .= '<option value="watermark">' . $LANG_MG01['watermark'] . '</option>';
    }
    $batchOptionSelect .= '</select>&nbsp;';
    $T->set_var(array('album_id' => $album_id, 'lang_albumsel' => $LANG_MG01['destination_album'], 'albumselect' => $album_selectbox, 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_move' => $LANG_MG01['move'], 'lang_select' => $LANG_MG01['select'], 'lang_item' => $LANG_MG01['item'], 'lang_order' => $LANG_MG01['order'], 'lang_cover' => $LANG_MG01['cover'], 'lang_title' => $LANG_MG01['title'], 'lang_description' => $LANG_MG01['description'], 'lang_checkall' => $LANG_MG01['check_all'], 'lang_uncheckall' => $LANG_MG01['uncheck_all'], 'lang_rotate_right' => $LANG_MG01['rotate_right'], 'lang_rotate_left' => $LANG_MG01['rotate_left'], 'lang_batch' => $LANG_MG01['batch_process'], 'lang_media_manage_title' => $LANG_MG01['manage_media'], 'lang_media_manage_help' => $LANG_MG01['media_manage_help'], 'lang_reset_cover' => $LANG_MG01['reset_cover'], 'lang_include_ss' => $LANG_MG01['include_ss'], 'lang_watermarked' => $LANG_MG01['watermarked'], 'lang_delete_confirm' => $LANG_MG01['delete_item_confirm'], 'batchoptionselect' => $batchOptionSelect, 'lang_batch_options' => $LANG_MG01['batch_options'], 'lang_keywords' => $LANG_MG01['keywords'], 'albumselect' => $album_selectbox, 'lang_batch' => $LANG_MG01['batch_process'], 'batchoptionselect' => $batchOptionSelect, 'val_reset_cover' => $album_cover == '-1' ? ' checked="checked"' : ''));
    $tn_size = 1;
    // include:150x150
    $rowclass = 0;
    $counter = 0;
    if ($nrows == 0) {
        // we have nothing in the album at this time...
        $T->set_var('lang_no_image', $LANG_MG01['no_media_objects']);
    } else {
        $T->set_block('media', 'ImageColumn', 'IColumn');
        $T->set_block('media', 'ImageRow', 'IRow');
        for ($x = 0; $x < $nrows; $x += 3) {
            $T->set_var('IColumn', '');
            for ($j = $x; $j < $x + 3; $j++) {
                if ($j >= $nrows) {
                    break;
                }
                $row = DB_fetchArray($result);
                $album_cover_check = '';
                $radio_box = '&nbsp;';
                if (($row['media_type'] == 0 || $row['media_tn_attached'] == 1) && $album->tn_attached == 0) {
                    $checked = $album_cover == $row['media_id'] ? ' checked="checked"' : '';
                    $radio_box = '<input type="radio" name="cover" value="' . $row['media_id'] . '"' . $checked . XHTML . '>';
                    $album_cover_check = $checked;
                }
                $include_ss = '&nbsp;';
                if ($row['media_type'] == 0) {
                    $checked = $row['include_ss'] == 1 ? ' checked="checked"' : '';
                    $include_ss = '<input type="checkbox" name="ss[' . $counter . ']" value="1"' . $checked . XHTML . '>';
                }
                switch ($row['media_type']) {
                    case 0:
                        // standard image
                        list($thumbnail, $pThumbnail, $img_size) = Media::getThumbInfo($row, $tn_size);
                        $fname = $row['media_filename'];
                        $ext = $row['media_mime_ext'];
                        $pDisplay = Media::getFilePath('disp', $fname, $ext);
                        $display = Media::getFileUrl('disp', $fname, $ext);
                        break;
                    default:
                        $mediaClass = new Media($row, $album_id);
                        list($thumbnail, $pThumbnail) = $mediaClass->displayRawThumb(1);
                        $img_size = @getimagesize($pThumbnail);
                        break;
                }
                $media_time = MG_getUserDateTimeFormat($row['media_time']);
                if ($img_size != false) {
                    list($width, $height) = Media::getImageWH($img_size[0], $img_size[1], 150, 150);
                } else {
                    //$width = 100;
                    //$height = 75;
                    $width = 150;
                    $height = 112;
                    $thumbnail = $_MG_CONF['mediaobjects_url'] . '/missing.png';
                }
                $cat_select = '<select name="cat_id[]">';
                $cat_select .= '<option value="0">' . $LANG_MG01['no_category'] . '</option>';
                $cRows = count($catRow);
                for ($i = 0; $i < $cRows; $i++) {
                    $cat_select .= '<option value="' . $catRow[$i]['cat_id'] . '" ' . ($catRow[$i]['cat_id'] == $row['media_category'] ? ' selected="selected"' : '') . '>' . $catRow[$i]['cat_name'] . '</option>';
                }
                $cat_select .= '</select>';
                $media_edit = $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;mid=' . $row['media_id'] . '&amp;album_id=' . $album_id . '&amp;t=' . time();
                $opt = array('playback_type' => 0, 'skin' => 'default', 'display_skin' => 'default', 'full_display' => 0);
                $object = MG_buildContent($row, $opt);
                $media_zoom = '<a href="' . $object[4] . '">';
                $T->set_var(array('lang_category' => $LANG_MG01['category'], 'cat_select' => $cat_select, 'row_class' => $rowclass % 2 ? '1' : '2', 'media_id' => $row['media_id'], 'mid' => $row['media_id'], 'order' => $row['media_order'], 'u_thumbnail' => $thumbnail, 'media_title' => $row['media_title'], 'media_desc' => $row['media_desc'], 'media_keywords' => $row['media_keywords'], 'media_time' => $media_time[0], 'media_views' => $row['media_views'], 'radio_box' => $radio_box, 'album_cover_check' => $album_cover_check, 'include_ss' => $include_ss, 'watermarked' => $row['media_watermarked'] ? '*' : '', 'height' => $height, 'width' => $width, 'counter' => $counter, 'media_edit' => $media_edit, 'media_zoom' => $media_zoom, 'lang_edit' => $LANG_MG01['edit']));
                $rowclass++;
                $counter++;
                $T->parse('IColumn', 'ImageColumn', true);
            }
            $T->parse('IRow', 'ImageRow', true);
        }
        $T->parse('mediaitems', 'media');
    }
    $T->set_var(array('album_id' => $album_id, 'url_album' => $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id, 's_mode' => 'cover', 's_form_action' => $actionURL, 'mode' => 'media', 'action' => 'cover', 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_media_manage_help' => $LANG_MG01['media_manage_help'], 'lang_delete_confirm' => $LANG_MG01['delete_item_confirm'], 'albums' => $LANG_MG01['albums'], 'batchoptionselect' => $batchOptionSelect, 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&amp;mode=media', $page + 1, ceil($totalAlbumItems / $_MG_CONF['mediamanage_items']))));
    $retval .= $T->finish($T->parse('output', 'admin'));
    return $retval;
}
Пример #3
0
function MG_displayJPG($I, $opt = array())
{
    global $_CONF, $_MG_CONF, $_USER;
    $full = !empty($opt['full']) ? $opt['full'] : 0;
    $media_id = $opt['media_id'];
    $sortOrder = $opt['sortOrder'];
    $spage = $opt['spage'];
    $media_size_disp = false;
    if ($full == 1) {
        $u_image = Media::getFileUrl('orig', $I['media_filename'], $I['media_mime_ext']);
    } else {
        if ($I['remote_media'] == 1) {
            if ($I['media_resolution_x'] != 0 && $I['media_resolution_y'] != 0) {
                $media_size_disp[0] = $I['media_resolution_x'];
                $media_size_disp[1] = $I['media_resolution_y'];
            } else {
                $media_size_disp = @getimagesize($I['remote_url']);
            }
            $u_image = $I['remote_url'];
        } else {
            $u_image = Media::getFileUrl('disp', $I['media_filename'], $I['media_mime_ext']);
            $media_size_disp = @getimagesize(Media::getFilePath('disp', $I['media_filename'], $I['media_mime_ext']));
            if ($media_size_disp == false) {
                $u_image = Media::getFileUrl('disp', $I['media_filename'], 'jpg');
                $media_size_disp = @getimagesize(Media::getFilePath('disp', $I['media_filename'], 'jpg'));
                if ($media_size_disp == false) {
                    $fname = 'missing.png';
                    $u_image = $_MG_CONF['mediaobjects_url'] . '/' . $fname;
                    $p_image = $_MG_CONF['path_mediaobjects'] . $fname;
                    $media_size_disp = @getimagesize($pimage);
                }
            }
        }
    }
    if ($media_size_disp == false) {
        $media_size_disp[0] = 0;
        $media_size_disp[1] = 0;
    }
    $media_link_start = '';
    $media_link_end = '';
    $media_size_orig = @getimagesize(Media::getFilePath('orig', $I['media_filename'], $I['media_mime_ext']));
    if ($media_size_orig == false || $opt['full_display'] == 2 || $_MG_CONF['discard_original'] == 1 || $opt['full_display'] == 1 && (!isset($_USER['uid']) || $_USER['uid'] < 2)) {
        $u_pic = '#';
        $raw_link_url = '';
        if ($media_size_orig == false) {
            $media_size_orig[0] = 200;
            $media_size_orig[1] = 150;
        }
    } else {
        if ($full == 0 && $_MG_CONF['full_in_popup']) {
            $popup_x = $media_size_orig[0] + 75;
            $popup_y = $media_size_orig[1] + 100;
            $u_pic = 'javascript:showVideo(\'' . $_MG_CONF['site_url'] . '/popup.php?s=' . $media_id . '&amp;sort=' . $sortOrder . '\',' . $popup_y . ',' . $popup_x . ')';
        } else {
            $f = $full ? '0' : '1';
            if ($_MG_CONF['click_image_and_go_next']) {
                $f = $full ? '1' : '0';
            }
            $u_pic = $_MG_CONF['site_url'] . '/media.php?f=' . $f . '&amp;s=' . $media_id . '&amp;p=' . $spage;
        }
        $media_link_start = '<a href="' . $u_pic . '">';
        $media_link_end = '</a>';
        $raw_link_url = $u_pic;
    }
    $imageWidth = $full ? $media_size_orig[0] : $media_size_disp[0];
    $imageHeight = $full ? $media_size_orig[1] : $media_size_disp[1];
    $playback_type = $opt['playback_type'];
    switch ($playback_type) {
        case 0:
            // Popup Window
            $win_width = $imageWidth + 20;
            $win_height = $imageHeight + 20;
            $u_pic = Media::getHref_showvideo($I['media_id'], $win_height, $win_width);
            $raw_link_url = $u_pic;
            break;
    }
    $retval = MG_getFramedImage($opt['display_skin'], $I['media_title'], $u_pic, $u_image, $imageWidth, $imageHeight, $media_link_start, $media_link_end);
    return array($retval, $u_image, $imageWidth, $imageHeight, $raw_link_url);
}