0x1998 - MANAGER
Edit File: default.php
<?php /** * @version $Id: mod_jdownloads_rated.php * @package mod_jdownloads_rated * @copyright (C) 2020 Arno Betz * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @author Arno Betz http://www.jDownloads.com * modified ColinM November 2020 * This module shows you the most rated Downloads from the jDownloads component. * It is only for jDownloads 3.9 and later (Support: www.jDownloads.com) */ defined('_JEXEC') or die; // Path to the mime type image folder (for file symbols) $file_pic_folder = JDHelper::getFileTypeIconPath($jdparams->get('selected_file_type_icon_set')); $html = '<div style="100%;" class="moduletable'.$moduleclass_sfx.'" style="float:'.$alignment.';">'; if ($files){ if ($text_before <> ''){ $html .= '<div class="jd_module_before" style="text-align:'.$alignment.';">'.$text_before.'</div>'; } for ($i=0; $i<count($files); $i++) { $html .= '<div style="clear:both;"></div>'; $has_no_file = false; if (!$files[$i]->url_download && !$files[$i]->other_file_id && !$files[$i]->extern_file){ // only a document without file $has_no_file = true; } $version = $short_version; if ($sum_char > 0){ $total = strlen($files[$i]->title) + strlen($files[$i]->release) + strlen($short_version) +1; if ($total > $sum_char){ $files[$i]->title = \Joomla\String\StringHelper::substr($files[$i]->title, 0, $sum_char).$short_char; $files[$i]->release = ''; } } $db->setQuery("SELECT id from #__menu WHERE link = 'index.php?option=com_jdownloads&view=category&catid=".$files[$i]->catid."' and published = 1"); $Itemid = $db->loadResult(); if (!$Itemid){ $Itemid = $root_itemid; } // create the link if ($files[$i]->link == '-'){ // the user has access to view this item if ($detail_view == '1'){ if ($detail_view_config == 0){ // the details view is deactivated in jD config so the // link must start directly the download process if ($direct_download_config == 1){ if (!$has_no_file){ $link = JRoute::_('index.php?option='.$option.'&task=download.send&id='.$files[$i]->slug.'&catid='.$files[$i]->catid.'&m=0'); } else { // create a link to the Downloads category as this download has not a file if ($files[$i]->menu_cat_itemid){ $link = JRoute::_('index.php?option='.$option.'&view=category&catid='.$files[$i]->catid.'&Itemid='.$files[$i]->menu_cat_itemid); } else { $link = JRoute::_('index.php?option='.$option.'&view=category&catid='.$files[$i]->catid.'&Itemid='.$Itemid); } } } else { // link to the summary page if (!$has_no_file){ $link = JRoute::_('index.php?option='.$option.'&view=summary&id='.$files[$i]->slug.'&catid='.$files[$i]->catid); } else { // create a link to the Downloads category as this download has not a file if ($files[$i]->menu_cat_itemid){ $link = JRoute::_('index.php?option='.$option.'&view=category&catid='.$files[$i]->catid.'&Itemid='.$files[$i]->menu_cat_itemid); } else { $link = JRoute::_('index.php?option='.$option.'&view=category&catid='.$files[$i]->catid.'&Itemid='.$Itemid); } } } } else { // create a link to the details view if ($files[$i]->menu_itemid){ $link = JRoute::_('index.php?option='.$option.'&view=download&id='.$files[$i]->slug.'&catid='.$files[$i]->catid.'&Itemid='.$files[$i]->menu_itemid); } else { if ($files[$i]->menu_cat_itemid){ $link = JRoute::_('index.php?option='.$option.'&view=download&id='.$files[$i]->slug.'&catid='.$files[$i]->catid.'&Itemid='.$files[$i]->menu_cat_itemid); } else { $link = JRoute::_('index.php?option='.$option.'&view=download&id='.$files[$i]->slug.'&catid='.$files[$i]->catid.'&Itemid='.$Itemid); } } } } else { // create a link to the Downloads category if ($files[$i]->menu_cat_itemid){ $link = JRoute::_('index.php?option='.$option.'&view=category&catid='.$files[$i]->catid.'&Itemid='.$files[$i]->menu_cat_itemid); } else { $link = JRoute::_('index.php?option='.$option.'&view=category&catid='.$files[$i]->catid.'&Itemid='.$Itemid); } } } else { $link = $files[$i]->link; } if (!$files[$i]->release) $version = ''; // build file pic $size = 0; $files_pic = ''; $number = ''; if ($view_pics){ if ($view_pics_link) { $pic_link = '<a href="'.$link.'">'; $pic_end = '</a>'; } else { $pic_link = ''; $pic_end = ''; } $size = (int)$view_pics_size; $files_pic = $pic_link.'<img src="'.$file_pic_folder.$files[$i]->file_pic.'" align="top" width="'.$size.'" height="'.$size.'" border="0" style="margin:2px 0;" alt="'.substr($files[$i]->file_pic, 0, -4).'-'.$i.'"/>'.$pic_end; } // build number list if ($view_numerical_list){ $num = $i+1; $number = "$num. "; } $link_text = '<a href="'.$link.'">'.$files[$i]->title.'</a> '.$version.$files[$i]->release; // determine which stars pic to show $num_stars = (int)(($files[$i]->ratenum *1.0)/20.0); //compute number of stars (ratenum is a percentage) $rating_stars = '<scan><img src="'.$image_dir.'star'.$num_stars.'.png" align="top" width="70" height="14" border="0" alt="star'.$num_stars.'-'.$i.'"/></scan>'; // $view_votes = $view_stars_rating_count; if ($view_votes){ $rating_votes = '<scan style="margin-top:-2px; font-size:95%;"> '.$files[$i]->rating_count.' '; if ($files[$i]->rating_count != 1) { $rating_votes .= JText::_('MOD_JDOWNLOADS_RATED_JDVOTE_VOTES').'</scan>'; } else { $rating_votes .= JText::_('MOD_JDOWNLOADS_RATED_JDVOTE_VOTE').'</scan>'; } } //add stars if ($view_stars && $view_votes){ $rating = $rating_stars.$rating_votes; } if ($view_stars && !$view_votes){ $rating = $rating_stars; } if (!$view_stars && $view_votes){ $rating = $rating_votes; } if (!$view_stars && !$view_votes){ $rating = ''; } // now do hits and date setup $hits_date_msg = '<div style="clear:both;"></div><div>'; $hits_date_end = '</div>'; // make hits msg if ($view_hits) { $hits_msg = $view_hits_label.modJdownloadsRatedHelper::strToNumber($files[$i]->downloads); if ($files[$i]->downloads){ if ($view_hits_same_line){ $hits_same_line = '<scan class="jd_module_hits_sameline" style="text-align:'.$date_hits_alignment.';"> '.$hits_msg.'</scan>'; // add space before msg } else { $hits_own_line = '<scan class="jd_module_hits_newline" style="text-align:'.$date_hits_alignment.';">'.$hits_msg.'</scan>'; } } } else { $hits_same_line = ''; //when hits not shown $hits_own_line = ''; } // make date msg if ($view_date) { if ($files[$i]->created){ if ($view_date_same_line){ $date_same_line = '<scan class="jd_module_date_sameline" style="text-align:'.$alignment.';"> '.$view_date_label.substr(JHTML::Date($files[$i]->created,$date_format),0,10).'</scan>'; } else { $date_own_line= '<scan class="jd_module_date_newline" style="text-align:'.$alignment.';">'.$view_date_label.substr(JHTML::Date($files[$i]->created,$date_format),0,10).'</scan>'; } } } else { $date_same_line = ''; //when date not shown $date_own_line = ''; } // now make the html - needs updating to if else or case structure $div_start = '<div style="display:block; float:'.$alignment.'; text-align:'.$alignment.';">'.$number.$files_pic.$link_text; $div_end = '</div>'; if ($view_stars_votes_same_line && $view_date_same_line && $view_hits_same_line){ $html .= $div_start.' '.$rating.$date_same_line.$hits_same_line.$div_end; //all on same line } if ($view_stars_votes_same_line && $view_date_same_line && !$view_hits_same_line){ $html .= $div_start.' '.$rating.$date_same_line.$div_end; //all on same line $html .= '<div style="clear:both;"></div><div style="display:block; text-align:'.$alignment.';">'.$hits_own_line.'</div>'; } if ($view_stars_votes_same_line && !$view_date_same_line && $view_hits_same_line){ $html .= $div_start.' '.$rating.$date_same_line.$hits_same_line.$div_end; //all on same line $html .= '<div style="clear:both;"></div><div style="display:block; text-align:'.$alignment.';">'.$date_own_line.'</div>'; } if ($view_stars_votes_same_line && !$view_date_same_line && !$view_hits_same_line){ $html .= $div_start.' '.$rating.$div_end; //all on same line $html .= '<div style="clear:both;"></div><div style="display:block; text-align:'.$alignment.';">'.$date_own_line.' '.$hits_own_line.'</div>'; } if (!$view_stars_votes_same_line && $view_date_same_line && $view_hits_same_line){ $html .= $div_start.' '.$date_same_line.$hits_same_line.$div_end; //all on same line $html .= '<div style="clear:both;"></div><div style="display:block; text-align:'.$alignment.';">'.$rating.'</div>'; } if (!$view_stars_votes_same_line && $view_date_same_line && !$view_hits_same_line){ $html .= $div_start.' '.$date_same_line.$div_end; //all on same line $html .= '<div style="clear:both;"></div><div style="display:block; text-align:'.$alignment.';">'.$rating.$hits_own_line.'</div>'; } if (!$view_stars_votes_same_line && !$view_date_same_line && $view_hits_same_line){ $html .= $div_start.' '.$hits_same_line.$div_end; //all on same line $html .= '<div style="clear:both;"></div><div style="display:block; text-align:'.$alignment.';">'.$rating.$date_own_line.'</div>'; } if (!$view_stars_votes_same_line && !$view_date_same_line && !$view_hits_same_line){ $html .= $div_start.$div_end; //all on same line $html .= '<div style="clear:both;"></div><div style="display:block; text-align:'.$alignment.';">'.$rating.' '.$date_own_line.' '.$hits_own_line.'</div>'; } } $html .= '<div style="clear:both;"></div>'; if ($text_after <> ''){ $html .= '<div class="jd_module_after" style="text-align:'.$alignment.';">'.$text_after.'</div>'; } } echo $html.'</div>'; ?>