Beispiel #1
0
function dlformat(&$T, &$A, $isListing = false, $cid = ROOTID)
{
    global $_CONF, $_TABLES, $LANG01, $_DLM_CONF, $LANG_DLM, $mytree;
    $A['rating'] = number_format($A['rating'], 2);
    $A['title'] = DLM_htmlspecialchars($A['title']);
    $A['project'] = DLM_htmlspecialchars($A['project']);
    $A['url'] = DLM_htmlspecialchars($A['url']);
    $A['homepage'] = DLM_htmlspecialchars($A['homepage']);
    $A['version'] = DLM_htmlspecialchars($A['version']);
    $A['size'] = DLM_htmlspecialchars($A['size']);
    $A['md5'] = DLM_htmlspecialchars($A['md5']);
    $A['logourl'] = DLM_htmlspecialchars($A['logourl']);
    $A['postmode'] = DLM_htmlspecialchars($A['postmode']);
    $A['tags'] = DLM_htmlspecialchars($A['tags']);
    $A['datetime'] = strftime($_DLM_CONF['date_format'], $A['date']);
    if (version_compare(VERSION, '2.1.0') >= 0) {
        require_once $_CONF['path_system'] . 'classes/gltext.class.php';
        $A['description'] = GLText::getDisplayText($A['description'], $A['postmode'], 2);
        $A['detail'] = GLText::getDisplayText($A['detail'], $A['postmode'], 2);
    } else {
        require_once $_CONF['path'] . 'plugins/downloads/include/gltext.class.php';
        $gltext = new GLPText();
        $A['description'] = $gltext->getDisplayText($A['description'], $A['postmode']);
        $A['detail'] = $gltext->getDisplayText($A['detail'], $A['postmode']);
    }
    $filedetail_url = COM_buildURL($_CONF['site_url'] . '/downloads/index.php?id=' . $A['lid']);
    $visitfile_url = COM_buildURL($_CONF['site_url'] . '/downloads/visit.php?id=' . $A['lid']);
    if ($isListing && !empty($A['detail'])) {
        $A['description'] .= '<p class="download-break">' . COM_createLink($LANG_DLM['more'], $filedetail_url) . '</p>';
    }
    $result = DB_query("SELECT username, fullname, photo " . "FROM {$_TABLES['users']} " . "WHERE uid = {$A['owner_id']}");
    $B = DB_fetchArray($result);
    $submitter_name = COM_getDisplayName($A['owner_id'], $B['username'], $B['fullname']);
    if (empty($submitter_name)) {
        $submitter_name = $LANG_DLM['unknown_uid'];
    } else {
        $submitter_name = COM_createLink($submitter_name, $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['owner_id']);
    }
    $path = $mytree->getNicePathFromId($A['cid'], 'title', $_CONF['site_url'] . '/downloads/index.php');
    $temp = $mytree->getSepalator();
    $path = substr($path, 0, strlen($path) - strlen($temp));
    $path = str_replace($temp, ' <img src="' . $_CONF['site_url'] . '/downloads/images/arrow.gif" alt="arrow"' . XHTML . '> ', $path);
    $tags = '-';
    if (!empty($A['tags'])) {
        $tags = getTagList($A['tags']);
        if (empty($tags)) {
            $tags = '-';
        }
    }
    $notags = $tags == '-' ? 'dlm_notags' : '';
    $T->set_var('lang_category', $LANG_DLM['category']);
    $T->set_var('category_path', $path);
    $T->set_var('lang_tags', $LANG_DLM['tags']);
    $T->set_var('tags', $tags);
    $T->set_var('notags', $notags);
    $T->set_var('lang_submitter', $LANG_DLM['submitter']);
    $T->set_var('submitter_name', $submitter_name);
    $T->set_var('lid', $A['lid']);
    $T->set_var('cid', $A['cid']);
    $T->set_var('lang_dlnow', $LANG_DLM['dlnow']);
    $T->set_var('dtitle', $A['title']);
    $T->set_var('filedetail_url', $filedetail_url);
    $T->set_var('visitfile_url', $visitfile_url);
    $T->set_var('listing_cid', $cid);
    $T->set_var('lang_download_button', $LANG_DLM['download_button']);
    $startdate = time() - 60 * 60 * 24 * 7;
    if ($startdate < $A['date']) {
        $image_new = COM_createImage($_CONF['site_url'] . '/downloads/images/newred.gif', $LANG_DLM['newthisweek']);
        $newdownload = '<span class="badgenew">NEW</span>';
    }
    $T->set_var('image_newdownload', $image_new);
    // Image (New)
    $T->set_var('newdownload', $newdownload);
    // Badge (New)
    if ($A['hits'] >= $_DLM_CONF['download_popular']) {
        $image_pop = COM_createImage($_CONF['site_url'] . '/downloads/images/pop.gif', $LANG_DLM['popular']);
        $popdownload = '<span class="badgepop">POP</span>';
    }
    $T->set_var('image_popular', $image_pop);
    // Image (Pop)
    $T->set_var('popdownload', $popdownload);
    // Badge (Pop)
    // category image
    $cat_title = DLM_htmlspecialchars($A['cat_title']);
    if ($_DLM_CONF['download_useshots'] && !empty($A['imgurl'])) {
        $imgurl = $_DLM_CONF['snapcat_url'] . '/' . DLM_htmlspecialchars($A['imgurl']);
    } else {
        $imgurl = $_CONF['site_url'] . '/downloads/images/download.png';
    }
    $category_image = COM_createImage($imgurl, $cat_title, array('width' => $_DLM_CONF['download_shotwidth']));
    $T->set_var('category_image', $category_image);
    $T->set_var('download_title', $LANG_DLM['click2dl'] . ': ' . $A['url']);
    $T->set_var('url', $A['url']);
    $T->set_var('file_description', $A['description']);
    $T->set_var('file_detail', $A['detail']);
    $T->set_var('rating', $A['rating']);
    if ($A['rating'] != "0" || $A['rating'] != "0.00") {
        $votestring = sprintf($LANG_DLM['numvotes'], $A['votes']);
    }
    $T->set_var('votestring', $votestring);
    if (!empty($A['mg_autotag'])) {
        // use the mediagallery autotag as a snapshot.
        $mg_autotag = str_replace(array('[', ']'), '', $A['mg_autotag']);
        $mg_autotag = '[' . $mg_autotag . ' width:' . $_DLM_CONF['max_tnimage_width'] . ' height:' . $_DLM_CONF['max_tnimage_height'] . ' align:left]';
        $T->set_var('mg_autotag', PLG_replaceTags($mg_autotag, 'mediagallery'));
        $T->set_var('snapshot', '');
        $T->set_var('snaplinkicon', '');
    } elseif (!empty($A['logourl'])) {
        $safename = DLM_createSafeFileName($A['logourl']);
        $imgpath = $_DLM_CONF['path_tnstore'] . $safename;
        $imgpath = DLM_modTNPath($imgpath);
        $tnimgurl = $_DLM_CONF['tnstore_url'] . '/' . $safename;
        $tnimgurl = substr($tnimgurl, 0, -3) . substr($imgpath, -3);
        // align the extension
        $sizeattributes = DLM_getImgSizeAttr($imgpath);
        $T->set_var('snapshot_url', $_DLM_CONF['snapstore_url'] . '/' . $safename);
        $T->set_var('thumbnail_url', $tnimgurl);
        $T->set_var('snapshot_sizeattr', $sizeattributes);
        $T->set_var('lang_click2see', $LANG_DLM['click2see']);
        $T->set_var('show_snapshoticon', '');
        $T->set_var('show_snapshoticon_na', 'none');
        $T->set_var('mg_autotag', '');
        if ($_DLM_CONF['show_tn_image']) {
            $T->parse('snapshot', 'tsnapshot');
        } else {
            $T->parse('snaplinkicon', 'tsnaplinkicon');
        }
    } else {
        $tnimgurl = $_CONF['site_url'] . '/downloads/images/blank.png';
        $T->set_var('thumbnail_url', $tnimgurl);
        $T->set_var('snapshot_url', $_CONF['site_url'] . '/downloads/index.php');
        $T->set_var('snapshot_sizeattr', 'width="200" height="200" ');
        $T->set_var('show_snapshoticon', 'none');
        $T->set_var('show_snapshoticon_na', '');
        $T->parse('snapshot', 'tsnapshot');
        $T->set_var('snaplinkicon', '');
        $T->set_var('mg_autotag', '');
    }
    $T->set_var('lang_version', $LANG_DLM['ver']);
    $T->set_var('lang_rating', $LANG_DLM['ratingc']);
    $T->set_var('lang_submitdate', $LANG_DLM['submitdate']);
    $T->set_var('lang_size', $LANG_DLM['size']);
    $T->set_var('datetime', $A['datetime']);
    $T->set_var('version', $A['version']);
    // Check if restricted access has been enabled for download report to admin's only
    if ($A['hits'] > 0 && DLM_hasAccess_history()) {
        $T->set_var('begin_dlreport_link', '<a href="' . COM_buildURL($_CONF['site_url'] . '/downloads/history.php?lid=' . $A['lid']) . '">');
        $T->set_var('end_dlreport_link', '</a>');
    } else {
        $T->set_var('begin_dlreport_link', '');
        $T->set_var('end_dlreport_link', '');
    }
    $T->set_var('download_times', sprintf($LANG_DLM['dltimes'], $A['hits']));
    $T->set_var('download_count', $A['hits']);
    $T->set_var('lang_popularity', $LANG_DLM['popularity']);
    $T->set_var('lang_filesize', $LANG_DLM['filesize']);
    $T->set_var('file_size', DLM_PrettySize($A['size']));
    $T->set_var('homepage_url', $A['homepage']);
    $T->set_var('homepage_link', '-');
    if (!empty($A['homepage'])) {
        $T->set_var('homepage_link', COM_makeClickableLinks($A['homepage']));
    }
    $T->set_var('lang_homepage', $LANG_DLM['homepage']);
    $T->set_var('lang_download', $LANG_DLM['download']);
    $T->set_var('lang_filelink', $LANG_DLM['filelink']);
    $T->set_var('lang_permalink', $LANG_DLM['permalink']);
    $T->set_var('lang_ratethisfile', $LANG_DLM['ratethisfile']);
    $T->set_var('lang_edit', $LANG_DLM['edit']);
    $T->set_var('show_editlink', $_DLM_CONF['has_edit_rights'] ? '' : 'none');
    $T->set_var('lang_md5_checksum', $LANG_DLM['md5_checksum']);
    $T->set_var('md5_checksum', $A['md5']);
    if ($A['commentcode'] == 0) {
        $commentCount = DB_count($_TABLES['comments'], 'sid', addslashes($A['lid']));
        $recentPostMessage = $LANG_DLM['commentswanted'];
        if ($commentCount > 0) {
            $result4 = DB_query("SELECT cid, UNIX_TIMESTAMP(date) AS day, username " . "FROM {$_TABLES['comments']}, {$_TABLES['users']} " . "WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid " . "AND sid = '" . addslashes($A['lid']) . "' " . "ORDER BY date DESC LIMIT 1");
            $C = DB_fetchArray($result4);
            $recentPostMessage = $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . $C['username'];
            $comment_link = COM_createLink($commentCount . '&nbsp;' . $LANG01[3], $filedetail_url, array('title' => $recentPostMessage));
        } else {
            $A['title'] = str_replace('&#039;', "'", $A['title']);
            $A['title'] = str_replace('&amp;', '&', $A['title']);
            $url = $_CONF['site_url'] . '/comment.php?type=downloads&amp;sid=' . $A['lid'] . '&amp;title=' . rawurlencode($A['title']);
            $comment_link = COM_createLink($LANG_DLM['entercomment'], $url, array('title' => $recentPostMessage));
        }
        $T->set_var('comment_link', $comment_link);
        $T->set_var('show_comments', '');
    } else {
        $T->set_var('show_comments', 'none');
    }
}
 function _makeForm_shot()
 {
     global $_CONF, $_DLM_CONF, $LANG_DLM;
     $safename = DLM_createSafeFileName($this->_logourl);
     if (!empty($this->_logourl) && file_exists($_DLM_CONF['path_snapstore'] . $safename)) {
         $imgpath = $_DLM_CONF['path_tnstore'] . $safename;
         $tnimgurl = $_DLM_CONF['tnstore_url'] . '/' . $safename;
         $imgpath = DLM_modTNPath($imgpath);
         $tnimgurl = substr($tnimgurl, 0, -3) . substr($imgpath, -3);
         // Align the extension
         if (file_exists($imgpath)) {
             $dimensions = getimagesize($imgpath);
             if (!empty($dimensions[0]) && !empty($dimensions[1])) {
                 if ($dimensions[0] > $_DLM_CONF['max_tnimage_width']) {
                     $snapwidth = $_DLM_CONF['max_tnimage_width'];
                     $snapheight = intval($dimensions[1] * $_DLM_CONF['max_tnimage_width'] / $dimensions[0]);
                 } else {
                     $snapwidth = $dimensions[0];
                     $snapheight = $dimensions[1];
                 }
             }
         } else {
             $tnimgurl = $_CONF['site_url'] . '/downloads/images/blank.png';
             $snapwidth = $_DLM_CONF['max_tnimage_width'];
             $snapheight = $_DLM_CONF['max_tnimage_height'];
         }
         //            $sizeattributes = 'width="' . $snapwidth . '" height="' . $snapheight . '" ';
         $shot = '<div class="dlm_snap_tn"><a href="' . $_DLM_CONF['snapstore_url'] . '/' . $safename . '" title="">' . '<img src="' . $tnimgurl . '" ' . $sizeattributes . ' alt=""' . XHTML . '></a></div>' . LB . '<input type="checkbox" name="deletesnap"' . XHTML . '>&nbsp;' . $LANG_DLM['delete'] . '<br' . XHTML . '>';
     } else {
         $tnimgurl = $_CONF['site_url'] . '/downloads/images/blank.png';
         $snapwidth = $_DLM_CONF['max_tnimage_width'];
         $snapheight = $_DLM_CONF['max_tnimage_height'];
         //            $sizeattributes = 'width="' . $snapwidth . '" height="' . $snapheight . '" ';
         $shot = '<div class="dlm_snap_tn"><img src="' . $tnimgurl . '" ' . $sizeattributes . ' alt=""' . XHTML . '></div>' . LB;
     }
     return $shot;
 }