function jd_file_fill_downloadok($p_Template, $files, $p_Symbol_Off, $p_DownloadType, $download_allowed) { global $jlistConfigM, $jDFPsfolders, $jDFPrank, $jDFPlive_site, $jDFPplugin_live_site, $jDFPabsolute_path, $cat_link_itemidsPlg, $jDLayoutTitleExists, $root_itemid, $date_format; $db = JFactory::getDBO(); $user = JFactory::getUser(); $jd_user_settings = JDHelper::getUserRules(); $jdlink_author_text = ''; $createdbyname = ''; $modifiedbyname = ''; $l_Template = str_replace("{{{", "[[[", $p_Template); $jdpic_license = ''; $jdpic_date = ''; $jdpic_author = ''; $jdpic_website = ''; $jdpic_system = ''; $jdpic_language = ''; $jdpic_download = ''; $jdpic_hits = ''; $jdpic_size = ''; $jdpic_price = ''; $cat_itemid = 0; if ($p_Symbol_Off == 0) { $msize = $jlistConfigM['info.icons.size']; $jdpic_license = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'license.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LICENCE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LICENCE') . '" /> '; $jdpic_date = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'date.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DATE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DATE') . '" /> '; $jdpic_author = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'contact.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_AUTHOR') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_AUTHOR') . '" /> '; $jdpic_website = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'weblink.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_WEBSITE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_WEBSITE') . '" /> '; $jdpic_system = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'system.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_SYSTEM') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_SYSTEM') . '" /> '; $jdpic_language = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'language.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LANGUAGE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LANGUAGE') . '" /> '; $jdpic_download = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'download.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DOWNLOAD') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DOWNLOAD') . '" /> '; $jdpic_hits = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'download.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DOWNLOAD') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DOWNLOAD_HITS') . '" /> '; $jdpic_size = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'stuff.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_FILESIZE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_FILESIZE') . '" /> '; $jdpic_price = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'currency.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_PRICE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_PRICE') . '" /> '; } // Build a little pic for extern links $jdextern_url_pic = '<img src="' . $jDFPplugin_live_site . 'content/jdownloads/jdownloads/images/link_extern.gif" style="vertical-align:middle;" alt="" title="" />'; $jd_file_pic = '<img src="' . JURI::base() . $jDFPsfolders['file'] . $files->file_pic . '" style="vertical-align:middle;" border="0" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" alt="" title="" />'; // Pics for: new file / hot file /updated $hotpic = '<img src="' . JURI::base() . 'images/jdownloads/hotimages/' . $jlistConfigM['picname.is.file.hot'] . '" alt="" />'; $newpic = '<img src="' . JURI::base() . 'images/jdownloads/newimages/' . $jlistConfigM['picname.is.file.new'] . '" alt="" />'; $updatepic = '<img src="' . JURI::base() . 'images/jdownloads/updimages/' . $jlistConfigM['picname.is.file.updated'] . '" alt="" />'; // Alternate CSS buttons when selected in configuration $status_color_hot = $jlistConfigM['css.button.color.hot']; $status_color_new = $jlistConfigM['css.button.color.new']; $status_color_updated = $jlistConfigM['css.button.color.updated']; $download_color = $jlistConfigM['css.button.color.download']; $download_size = $jlistConfigM['css.button.size.download']; $download_size_mirror = $jlistConfigM['css.button.size.download.mirror']; $download_color_mirror1 = $jlistConfigM['css.button.color.mirror1']; $download_color_mirror2 = $jlistConfigM['css.button.color.mirror2']; $download_size_listings = $jlistConfigM['css.button.size.download.small']; $jd_cat_id = $files->cat_id; $jd_filename = $files->url_download; $jd_file_language = $files->file_language; $jd_system = $files->system; if ($files->category_cat_dir_parent) { $category_dir = $files->category_cat_dir_parent . '/' . $files->category_cat_dir; } else { $category_dir = $files->category_cat_dir; } // Has this Download really a file? if (!$files->url_download && !$files->other_file_id && !$files->extern_file) { // only a document without file $no_file_info = JText::_('COM_JDOWNLOADS_FRONTEND_ONLY_DOCUMENT_USER_INFO'); $download_has_a_file = false; } else { $download_has_a_file = true; $no_file_info = ''; } // Compute the download slugs $files->slug = $files->file_alias ? $files->file_id . ':' . $files->file_alias : $files->file_id; // create all file titles $l_Template = JDHelper::buildFieldTitles($l_Template, $files); // When we have a simple document, view only the info not any buttons. if (!$download_has_a_file) { if (strpos($l_Template, '{url_download}')) { $l_Template = str_replace('{url_download}', $no_file_info, $l_Template); } else { $l_Template = str_replace('{checkbox_list}', $no_file_info, $l_Template); } // Place the images $l_Template = JDHelper::placeThumbs($l_Template, $files->images); if ($jlistConfigM['view.detailsite']) { $title_link = JRoute::_(JDownloadsHelperRoute::getDownloadRoute($files->slug, $files->cat_id, $files->language)); $title_link_text = '<a href="' . $title_link . '">' . $db->escape($files->file_title) . '</a>'; $detail_link_text = '<a href="' . $title_link . '">' . JText::_('COM_JDOWNLOADS_FE_DETAILS_LINK_TEXT_TO_DETAILS') . '</a>'; // Build the file symbol (with link) if ($files->file_pic != '') { $filepic = '<a href="' . $title_link . '">' . '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" /></a> '; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); // link to details view at the end $l_Template = str_replace('{link_to_details}', $detail_link_text, $l_Template); $l_Template = str_replace('{file_title}', $title_link_text, $l_Template); } else { // no links if ($files->file_pic != '') { $filepic = '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" />'; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); // remove link to details view at the end $l_Template = str_replace('{link_to_details}', '', $l_Template); $l_Template = str_replace('{file_title}', $files->file_title, $l_Template); } $l_Template = str_replace('{checkbox_list}', '', $l_Template); $l_Template = str_replace('{mirror_1}', '', $l_Template); $l_Template = str_replace('{mirror_2}', '', $l_Template); $l_Template = str_replace('{hits_value}', '', $l_Template); $l_Template = str_replace('{filesize_value}', '', $l_Template); } // insert rating system if ($jlistConfigM['view.ratings']) { $rating_system = JDHelper::getRatings($files->file_id, $files->rating_count, $files->rating_sum); $l_Template = str_replace('{rating}', $rating_system, $l_Template); } else { $l_Template = str_replace('{rating}', '', $l_Template); } // Build the license info data and build link if ($files->license == '') { $files->license = 0; } $lic_data = ''; if ($files->license_url != '') { $lic_data = $jdpic_license . '<a href="' . $files->license_url . '" target="_blank" rel="nofollow" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LICENCE') . '">' . $files->license_title . '</a> ' . $jdextern_url_pic; } else { if ($files->license_title != '') { if ($files->license_text != '') { $lic_data = $jdpic_license . $files->license_title; $lic_data .= JHtml::_('tooltip', $files->license_text, $files->license_title); } else { $lic_data = $files->license_title; } } else { $lic_data = ''; } } $l_Template = str_replace('{license_text}', $lic_data, $l_Template); $l_Template = str_replace('{license}', $lic_data, $l_Template); // old placeholder // Build the 'files language' data $file_lang_values = explode(',', JDHelper::getOnlyLanguageSubstring($jlistConfigM['language.list'])); if ($jd_file_language == 0) { $jd_showlanguage = ''; } else { $jd_showlanguage = $jdpic_language . $file_lang_values[$jd_file_language]; } $l_Template = str_replace("{language}", $jd_showlanguage, $l_Template); // old placeholder $l_Template = str_replace("{language_text}", $jd_showlanguage, $l_Template); // Build the 'System' data $file_sys_values = explode(',', $jlistConfigM['system.list']); if ($jd_system == 0) { $jd_showsystem = ''; } else { $jd_showsystem = $jdpic_system . $file_sys_values[$jd_system]; } $l_Template = str_replace("{system}", $jd_showsystem, $l_Template); // old placeholder $l_Template = str_replace("{system_text}", $jd_showsystem, $l_Template); // Build hits values $numbers_downloads = JDHelper::strToNumber((int) $files->downloads); $jd_showhits = $jdpic_hits . $numbers_downloads; $l_Template = str_replace("{hits_value}", $jd_showhits, $l_Template); // Build website url if (!$files->url_home == '') { if (strpos($files->url_home, 'http://') !== false) { $l_Template = str_replace('{url_home}', $jdpic_website . '<a href="' . $files->url_home . '" target="_blank" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '</a> ' . $jdextern_url_pic, $l_Template); $l_Template = str_replace('{author_url_text} ', $jdpic_website . '<a href="' . $files->url_home . '" target="_blank" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '</a> ' . $jdextern_url_pic, $l_Template); } else { $l_Template = str_replace('{url_home}', $jdpic_website . '<a href="http://' . $files->url_home . '" target="_blank" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '</a> ' . $jdextern_url_pic, $l_Template); $l_Template = str_replace('{author_url_text}', $jdpic_website . '<a href="http://' . $files->url_home . '" target="_blank" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '</a> ' . $jdextern_url_pic, $l_Template); } } else { $l_Template = str_replace('{url_home}', '', $l_Template); $l_Template = str_replace('{author_url_text}', '', $l_Template); } // Encode is link a mail if (strpos($files->url_author, '@') && $jlistConfigM['mail.cloaking']) { if (!$files->author) { $mail_encode = JHtml::_('email.cloak', $files->url_author); } else { $mail_encode = JHtml::_('email.cloak', $files->url_author, true, $files->author, false); } } // Build author link if ($files->author != '') { if ($files->url_author != '') { if ($mail_encode) { $link_author = $jdpic_author . $mail_encode; } else { if (strpos($files->url_author, 'http://') !== false) { $link_author = $jdpic_author . '<a href="' . $files->url_author . '" target="_blank">' . $files->author . '</a> ' . $extern_url_pic; } else { $link_author = $jdpic_author . '<a href="http://' . $files->url_author . '" target="_blank">' . $files->author . '</a> ' . $extern_url_pic; } } $l_Template = str_replace('{author}', $link_author, $l_Template); $l_Template = str_replace('{author_text}', $link_author, $l_Template); $l_Template = str_replace('{url_author}', '', $l_Template); } else { $link_author = $jdpic_author . $files->author; $l_Template = str_replace('{author}', $link_author, $l_Template); $l_Template = str_replace('{author_text}', $link_author, $l_Template); $l_Template = str_replace('{url_author}', '', $l_Template); } } else { $l_Template = str_replace('{url_author}', $jdpic_author . $files->url_author, $l_Template); $l_Template = str_replace('{author}', '', $l_Template); $l_Template = str_replace('{author_text}', '', $l_Template); } // Place the images $l_Template = JDHelper::placeThumbs($l_Template, $files->images, 'list'); // Compute for HOT symbol if ($jlistConfigM['loads.is.file.hot'] > 0 && $files->downloads >= $jlistConfigM['loads.is.file.hot']) { // Is the old button pic used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $l_Template = str_replace('{pic_is_hot}', $hotpic, $l_Template); } else { // CSS Button is selected $l_Template = str_replace('{pic_is_hot}', '<span class="jdbutton ' . $status_color_hot . ' jstatus">' . JText::_('COM_JDOWNLOADS_HOT') . '</span>', $l_Template); } } else { $l_Template = str_replace('{pic_is_hot}', '', $l_Template); } // Compute for NEW symbol $days_diff = JDHelper::computeDateDifference(date('Y-m-d H:i:s'), $files->date_added); if ($jlistConfigM['days.is.file.new'] > 0 && $days_diff <= $jlistConfigM['days.is.file.new']) { // Is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $l_Template = str_replace('{pic_is_new}', $newpic, $l_Template); } else { // CSS Button is selected $l_Template = str_replace('{pic_is_new}', '<span class="jdbutton ' . $status_color_new . ' jstatus">' . JText::_('COM_JDOWNLOADS_NEW') . '</span>', $l_Template); } } else { $l_Template = str_replace('{pic_is_new}', '', $l_Template); } // Compute for UPDATED symbol // View it only when in the download is activated the 'updated' option if ($files->update_active) { $days_diff = JDHelper::computeDateDifference(date('Y-m-d H:i:s'), $files->modified); if ($jlistConfigM['days.is.file.updated'] > 0 && $days_diff >= 0 && $days_diff <= $jlistConfigM['days.is.file.updated']) { if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $l_Template = str_replace('{pic_is_updated}', $updatepic, $l_Template); } else { // CSS Button is selected $l_Template = str_replace('{pic_is_updated}', '<span class="jdbutton ' . $status_color_updated . ' jstatus">' . JText::_('COM_JDOWNLOADS_UPDATED') . '</span>', $l_Template); } } else { $l_Template = str_replace('{pic_is_updated}', '', $l_Template); } } else { $l_Template = str_replace('{pic_is_updated}', '', $l_Template); } // file size if (!$files->size == '') { $l_Template = str_replace('{size}', $jdpic_size . $files->size, $l_Template); $l_Template = str_replace('{filesize_value}', $jdpic_size . $files->size, $l_Template); } else { $l_Template = str_replace('{size}', '', $l_Template); $l_Template = str_replace('{filesize_value}', '', $l_Template); } // price if ($files->price != '') { $l_Template = str_replace('{price_value}', $jdpic_price . $files->price, $l_Template); } else { $l_Template = str_replace('{price_value}', '', $l_Template); } // file_date if ($files->file_date != '0000-00-00 00:00:00') { if ($files->params->get('show_date') == 0) { $filedate_data = $jdpic_date . JHtml::_('date', $files->file_date, $date_format['long']); $filedate_data_title = JText::_('COM_JDOWNLOADS_EDIT_FILE_FILE_DATE_TITLE'); } else { $filedate_data = $jdpic_date . JHtml::_('date', $files->file_date, $date_format['short']); $filedate_data_title = ''; } } else { $filedate_data = ''; $filedate_data_title = ''; } $l_Template = str_replace('{file_date}', $filedate_data, $l_Template); // date_added if ($files->date_added != '0000-00-00 00:00:00') { if ($files->params->get('show_date') == 0) { // use 'normal' date-time format field $date_data = $jdpic_date . JHtml::_('date', $files->date_added, $date_format['long']); } else { // use 'short' date-time format field $date_data = $jdpic_date . JHtml::_('date', $files->date_added, $date_format['short']); } } else { $date_data = ''; } $l_Template = str_replace('{date_added}', $date_data, $l_Template); $l_Template = str_replace('{created_date_value}', $date_data, $l_Template); if ($files->creator) { $l_Template = str_replace('{created_by_value}', $files->creator, $l_Template); } else { $l_Template = str_replace('{created_by_value}', '', $l_Template); } if ($files->modifier) { $l_Template = str_replace('{modified_by_value}', $files->modifier, $l_Template); } else { $l_Template = str_replace('{modified_by_value}', '', $l_Template); } // modified_date if ($files->modified != '0000-00-00 00:00:00') { if ($files->params->get('show_date') == 0) { $modified_data = $jdpic_date . JHtml::_('date', $files->modified, $date_format['long']); } else { $modified_data = $jdpic_date . JHtml::_('date', $files->modified, $date_format['short']); } } else { $modified_data = ''; } $l_Template = str_replace('{modified_date_value}', $modified_data, $l_Template); if ($files->release == '') { $l_Template = str_replace('{release}', '', $l_Template); } else { $l_Template = str_replace('{release}', $files->release, $l_Template); // with versions text from language file // $l_Template = str_replace('{release}', JText::_('COM_JDOWNLOADS_FRONTEND_VERSION_TITLE').$files->release, $l_Template); } // Create an additional hint for the description footer when this download has a file but user has not the download permissions if ($download_has_a_file) { if ($user->guest) { // when CSS3 buttons are activate, we use it also for the message if ($jlistConfigM['use.css.buttons.instead.icons']) { $first_reg_msg = '<div class="' . $jlistConfigM['css.button.color.download'] . ' ' . $jlistConfigM['css.button.size.download'] . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED') . '</div>'; } else { $first_reg_msg = '<div class="jdpf_not_logged_in">' . JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED') . '</div>'; } } else { // when CSS3 buttons are activate, we use it also for the message if ($jlistConfigM['use.css.buttons.instead.icons']) { $first_reg_msg = '<div class="' . $jlistConfigM['css.button.color.download'] . ' ' . $jlistConfigM['css.button.size.download'] . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED2') . '</div>'; } else { $first_reg_msg = '<div class="jdpf_not_logged_in">' . JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED2') . '</div>'; } } } else { $first_reg_msg = ''; } // Check and build the description text if ($jlistConfigM['plugin.auto.file.short.description'] && $jlistConfigM['plugin.auto.file.short.description.value'] > 0) { if (strlen($files->description) > $jlistConfigM['plugin.auto.file.short.description.value']) { // Cut description text $shorted_text = preg_replace("/[^ ]*\$/", '..', substr($files->description, 0, $jlistConfigM['plugin.auto.file.short.description.value'])); if (!$download_allowed) { //$l_Template = str_replace('{description}', $shorted_text.$first_reg_msg, $l_Template); $l_Template = str_replace('{description}', $shorted_text, $l_Template); } else { $l_Template = str_replace('{description}', $shorted_text, $l_Template); } } else { if (!$download_allowed) { // $l_Template = str_replace('{description}', $files->description.$first_reg_msg, $l_Template); $l_Template = str_replace('{description}', $files->description, $l_Template); } else { $l_Template = str_replace('{description}', $files->description, $l_Template); } } } else { if (!$download_allowed) { //$l_Template = str_replace("{description}",$files->description.$first_reg_msg, $l_Template); $l_Template = str_replace("{description}", $files->description, $l_Template); } else { $l_Template = str_replace("{description}", $files->description, $l_Template); } } // create filename if ($files->url_download) { $l_Template = str_replace('{file_name}', JDHelper::getShorterFilename($files->url_download), $l_Template); } elseif (isset($files->filename_from_other_download) && $files->filename_from_other_download != '') { $l_Template = str_replace('{file_name}', JDHelper::getShorterFilename($files->filename_from_other_download), $l_Template); } else { $l_Template = str_replace('{file_name}', '', $l_Template); } // google adsense if ($jlistConfigM['google.adsense.active']) { $l_Template = str_replace('{google_adsense}', stripslashes($jlistConfigM['google.adsense.code']), $l_Template); } else { $l_Template = str_replace('{google_adsense}', '', $l_Template); } // report download link if ($jd_user_settings->view_report_form) { $report_link = '<a href="' . JRoute::_("index.php?option=com_jdownloads&view=report&id=" . $files->slug . "&catid=" . $files->cat_id . "&Itemid=" . $root_itemid) . '" rel="nofollow">' . JText::_('COM_JDOWNLOADS_FRONTEND_REPORT_FILE_LINK_TEXT') . '</a>'; $l_Template = str_replace('{report_link}', $report_link, $l_Template); } else { $l_Template = str_replace('{report_link}', '', $l_Template); } // media player if ($files->preview_filename) { // we use the preview file when exist $is_preview = true; $files->itemtype = JDHelper::getFileExtension($files->preview_filename); $is_playable = JDHelper::isPlayable($files->preview_filename); $extern_media = false; } else { $is_preview = false; if ($files->extern_file) { $extern_media = true; $files->itemtype = JDHelper::getFileExtension($files->extern_file); $is_playable = JDHelper::isPlayable($files->extern_file); } else { $files->itemtype = JDHelper::getFileExtension($files->url_download); $is_playable = JDHelper::isPlayable($files->url_download); $extern_media = false; } } if (!$jlistConfigM['flowplayer.use'] && $files->itemtype == 'mp3') { // we use only the 'OLD' mp3 player if ($extern_media) { $mp3_path = $files->extern_file; } else { if ($is_preview) { // we need the path to the "previews" folder $mp3_path = JUri::base() . basename($jlistConfigM['files.uploaddir']) . '/' . $jlistConfigM['preview.files.folder.name'] . '/' . $files->preview_filename; } else { // we use the normal download file for the player $mp3_path = JUri::base() . basename($jlistConfigM['files.uploaddir']) . '/' . $category_dir . '/' . $files->url_download; } } $mp3_config = trim($jlistConfigM['mp3.player.config']); $mp3_config = str_replace('', '', $mp3_config); $mp3_config = str_replace(';', '&', $mp3_config); $mp3_player = '<object type="application/x-shockwave-flash" data="components/com_jdownloads/assets/mp3_player_maxi.swf" width="200" height="20"> <param name="movie" value="components/com_jdownloads/assets/mp3_player_maxi.swf" /> <param name="wmode" value="transparent"/> <param name="FlashVars" value="mp3=' . $mp3_path . '&' . $mp3_config . '" /> </object>'; $l_Template = str_replace('{mp3_player}', $mp3_player, $l_Template); } if ($jlistConfigM['flowplayer.use'] && $is_playable) { // we will use the new flowplayer option if ($extern_media) { $media_path = $files->extern_file; } else { if ($is_preview) { // we need the relative path to the "previews" folder $media_path = basename($jlistConfigM['files.uploaddir']) . '/' . $jlistConfigM['preview.files.folder.name'] . '/' . $files->preview_filename; } else { // we use the normal download file for the player $media_path = basename($jlistConfigM['files.uploaddir']) . '/' . $category_dir . '/' . $files->url_download; } } $ipadcode = ''; if ($files->itemtype == 'mp3') { $fullscreen = 'false'; $autohide = 'false'; $playerheight = (int) $jlistConfigM['flowplayer.playerheight.audio']; // we must use also the ipad plugin identifier when required // see http://flowplayer.blacktrash.org/test/ipad-audio.html and http://flash.flowplayer.org/plugins/javascript/ipad.html if ($ipad_user) { $ipadcode = '.ipad();'; } } else { $fullscreen = 'true'; $autohide = 'true'; $playerheight = (int) $jlistConfigM['flowplayer.playerheight']; } $player = '<a href="' . $media_path . '" style="display:block;width:' . $jlistConfigM['flowplayer.playerwidth'] . 'px; height:' . $playerheight . 'px;" class="player" id="player' . $files->file_id . '"></a>'; $player .= '<script language="JavaScript"> // install flowplayer into container flowplayer("player' . $files->file_id . '", "' . JURI::base() . 'components/com_jdownloads/assets/flowplayer/flowplayer-3.2.16.swf", { plugins: { controls: { // insert at first the config settings ' . $jlistConfigM['flowplayer.control.settings'] . ' // and now the basics fullscreen: ' . $fullscreen . ', height: ' . (int) $jlistConfigM['flowplayer.playerheight.audio'] . ', autoHide: ' . $autohide . ', } }, clip: { autoPlay: false, // optional: when playback starts close the first audio playback onBeforeBegin: function() { $f("player' . $files->file_id . '").close(); } } })' . $ipadcode . '; </script>'; // the 'ipad code' above is only required for ipad/iphone users // We will replace at first the old placeholder when exist if (strpos($l_Template, '{mp3_player}')) { $l_Template = str_replace('{mp3_player}', $player, $l_Template); } else { $l_Template = str_replace('{preview_player}', $player, $l_Template); } } if ($jlistConfigM['mp3.view.id3.info'] && $files->itemtype == 'mp3' && !$extern_media) { // read mp3 infos if ($is_preview) { // get the path to the preview file $mp3_path_abs = $jlistConfigM['files.uploaddir'] . '/' . $jlistConfigM['preview.files.folder.name'] . '/' . $files->preview_filename; } else { // get the path to the downloads file $mp3_path_abs = $jlistConfigM['files.uploaddir'] . '/' . $category_dir . '/' . $files->url_download; } $info = JDHelper::getID3v2Tags($mp3_path_abs); if ($info) { // add it $mp3_info = stripslashes($jlistConfigM['mp3.info.layout']); $mp3_info = str_replace('{name_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_TITLE'), $mp3_info); if ($is_preview) { $mp3_info = str_replace('{name}', $files->preview_filename, $mp3_info); } else { $mp3_info = str_replace('{name}', $files->url_download, $mp3_info); } $mp3_info = str_replace('{album_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_ALBUM'), $mp3_info); if (isset($info['TALB'])) { $mp3_info = str_replace('{album}', $info['TALB'], $mp3_info); } else { $mp3_info = str_replace('{album}', '', $mp3_info); } $mp3_info = str_replace('{artist_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_ARTIST'), $mp3_info); if (isset($info['TPE1'])) { $mp3_info = str_replace('{artist}', $info['TPE1'], $mp3_info); } else { $mp3_info = str_replace('{artist}', '', $mp3_info); } $mp3_info = str_replace('{genre_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_GENRE'), $mp3_info); if (isset($info['TCON'])) { $mp3_info = str_replace('{genre}', $info['TCON'], $mp3_info); } else { $mp3_info = str_replace('{genre}', '', $mp3_info); } $mp3_info = str_replace('{year_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_YEAR'), $mp3_info); if (isset($info['TYER'])) { $mp3_info = str_replace('{year}', $info['TYER'], $mp3_info); } else { $mp3_info = str_replace('{year}', '', $mp3_info); } $mp3_info = str_replace('{length_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_LENGTH'), $mp3_info); if (isset($info['TLEN'])) { $mp3_info = str_replace('{length}', $info['TLEN'] . ' ' . JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_MINS'), $mp3_info); } else { $mp3_info = str_replace('{length}', '', $mp3_info); } $l_Template = str_replace('{mp3_id3_tag}', $mp3_info, $l_Template); } } // replace the {preview_url} if ($files->preview_filename) { // we need the relative path to the "previews" folder $media_path = basename($jlistConfigM['files.uploaddir']) . '/' . $jlistConfigM['preview.files.folder.name'] . '/' . $files->preview_filename; $l_Template = str_replace('{preview_url}', $media_path, $l_Template); } else { $l_Template = str_replace('{preview_url}', '', $l_Template); } $user_can_see_download_url = false; // only view download link when user has correct access level if ($files->params->get('access-download') == true) { $user_can_see_download_url = true; $blank_window = ''; $blank_window1 = ''; $blank_window2 = ''; // get file extension $view_types = array(); $view_types = explode(',', $jlistConfigM['file.types.view']); $only_file_name = basename($files->url_download); $filesextension = JDHelper::getFileExtension($only_file_name); if (in_array($filesextension, $view_types)) { $blank_window = 'target="_blank"'; } // check is set link to a new window? if ($files->extern_file && $files->extern_site) { $blank_window = 'target="_blank"'; } // is 'direct download' activated? if ($jlistConfigM['direct.download'] == '0') { // when not, we must link to the summary page $url_task = 'summary'; $blank_window = ''; $download_link = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files->slug, $files->cat_id, $files->language, $url_task)); } else { if ($files->license_agree || $files->password || $jd_user_settings->view_captcha) { // user must agree the license - fill out a password field - or fill out the captcha human check - so we must view the summary page! $url_task = 'summary'; $download_link = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files->slug, $files->cat_id, $files->language, $url_task)); } else { // start the download promptly $url_task = 'download.send'; $download_link = JRoute::_('index.php?option=com_jdownloads&task=download.send&id=' . $files->file_id . '&catid=' . $files->cat_id . '&m=0'); } } if ($url_task == 'download.send') { // is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfigM['download.pic.details'] . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" /></a>'; } else { // we use the new css button $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color . ' ' . $download_size_listings . '">' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '</a>'; } } else { // is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $download_link_text = '<a href="' . $download_link . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfigM['download.pic.details'] . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" title="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" /></a>'; } else { // we use the new css button $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color . ' ' . $download_size_listings . '">' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '</a>'; } } if (strpos($l_Template, '{url_download}')) { $l_Template = str_replace('{url_download}', $download_link_text, $l_Template); } else { $l_Template = str_replace('{checkbox_list}', $download_link_text, $l_Template); } // mirrors if ($files->mirror_1) { if ($files->extern_site_mirror_1 && $url_task == 'download.send') { $blank_window1 = 'target="_blank"'; } $mirror1_link_dum = JRoute::_('index.php?option=com_jdownloads&task=download.send&id=' . $files->file_id . '&catid=' . $files->cat_id . '&m=1'); //$mirror1_link_dum = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files->slug, $files->cat_id, $files->language, $url_task, 1)); // is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $mirror1_link = '<a ' . $blank_window1 . ' href="' . $mirror1_link_dum . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfigM['download.pic.mirror_1'] . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_1') . '" /></a>'; } else { // we use the new css button $mirror1_link = '<a ' . $blank_window1 . ' href="' . $mirror1_link_dum . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color_mirror1 . ' ' . $download_size_mirror . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_1') . '</a>'; } $l_Template = str_replace('{mirror_1}', $mirror1_link, $l_Template); } else { $l_Template = str_replace('{mirror_1}', '', $l_Template); } if ($files->mirror_2) { if ($files->extern_site_mirror_2 && $url_task == 'download.send') { $blank_window2 = 'target="_blank"'; } $mirror2_link_dum = JRoute::_('index.php?option=com_jdownloads&task=download.send&id=' . $files->file_id . '&catid=' . $files->cat_id . '&m=2'); //$mirror2_link_dum = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files->slug, $files->cat_id, $files->language, $url_task, 2)); // is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $mirror2_link = '<a ' . $blank_window2 . ' href="' . $mirror2_link_dum . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfigM['download.pic.mirror_2'] . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_2') . '" /></a>'; } else { // we use the new css button $mirror2_link = '<a ' . $blank_window2 . ' href="' . $mirror2_link_dum . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color_mirror2 . ' ' . $download_size_mirror . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_2') . '</a>'; } $l_Template = str_replace('{mirror_2}', $mirror2_link, $l_Template); } else { $l_Template = str_replace('{mirror_2}', '', $l_Template); } } else { // visitor has not access to download this item - so we will inform him if (strpos($l_Template, '{url_download}')) { $l_Template = str_replace('{url_download}', $first_reg_msg, $l_Template); } else { $l_Template = str_replace('{checkbox_list}', $first_reg_msg, $l_Template); } $l_Template = str_replace('{mirror_1}', '', $l_Template); $l_Template = str_replace('{mirror_2}', '', $l_Template); } if ($jlistConfigM['view.detailsite']) { $title_link = JRoute::_(JDownloadsHelperRoute::getDownloadRoute($files->slug, $files->cat_id, $files->language)); $title_link_text = '<a href="' . $title_link . '">' . $db->escape($files->file_title) . '</a>'; $detail_link_text = '<a href="' . $title_link . '">' . JText::_('COM_JDOWNLOADS_FE_DETAILS_LINK_TEXT_TO_DETAILS') . '</a>'; // Build the file symbol (with link) if ($files->file_pic != '') { $filepic = '<a href="' . $title_link . '">' . '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" /></a> '; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); // link to details view at the end $l_Template = str_replace('{link_to_details}', $detail_link_text, $l_Template); $l_Template = str_replace('{file_title}', $title_link_text, $l_Template); } elseif ($jlistConfigM['use.download.title.as.download.link']) { if ($user_can_see_download_url) { // build title link as download link if ($url_task == 'download.send') { $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" title="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jd_download_url">' . $files->file_title . '</a>'; } else { $download_link_text = '<a href="' . $download_link . '" title="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '">' . $files->file_title . '</a>'; } // View file icon also with link if ($files->file_pic != '') { $filepic = '<a href="' . $download_link . '"><img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" /></a>'; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); $l_Template = str_replace('{link_to_details}', '', $l_Template); $l_Template = str_replace('{file_title}', $download_link_text, $l_Template); } else { // user may not use download link $l_Template = str_replace('{file_title}', $files->file_title, $l_Template); if ($files->file_pic != '') { $filepic = '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" />'; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); } } else { // no links if ($files->file_pic != '') { $filepic = '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" />'; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); // remove link to details view at the end $l_Template = str_replace('{link_to_details}', '', $l_Template); $l_Template = str_replace('{file_title}', $files->file_title, $l_Template); } $l_Template = str_replace('{file_title_only}', $files->file_title, $l_Template); $l_Template = str_replace('{checkbox_list}', '', $l_Template); $l_Template = str_replace('{file_id}', $files->file_id, $l_Template); $l_Template = str_replace('{ordering}', $files->ordering, $l_Template); $l_Template = str_replace('{published}', $files->published, $l_Template); $l_Template = str_replace('{cat_id}', $files->cat_id, $l_Template); $l_Template = str_replace('{rank}', $jDFPrank, $l_Template); $l_Template = str_replace('{mp3_player}', '', $l_Template); $l_Template = str_replace('{mp3_id3_tag}', '', $l_Template); $l_Template = str_replace('{preview_player}', '', $l_Template); $l_Template = str_replace('{report_link}', '', $l_Template); $l_Template = str_replace('{sum_jcomments}', '', $l_Template); $l_Template = str_replace('{rating}', '', $l_Template); // custom fields $custom_fields_arr = existsCustomFieldsTitlesPlg(); $row_custom_values = array('dummy', $files->custom_field_1, $files->custom_field_2, $files->custom_field_3, $files->custom_field_4, $files->custom_field_5, $files->custom_field_6, $files->custom_field_7, $files->custom_field_8, $files->custom_field_9, $files->custom_field_10, $files->custom_field_11, $files->custom_field_12, $files->custom_field_13, $files->custom_field_14); for ($x = 1; $x < 15; $x++) { // replace placeholder with title and value if (in_array($x, $custom_fields_arr[0]) && $row_custom_values[$x] && $row_custom_values[$x] != '0000-00-00') { $l_Template = str_replace("{custom_title_{$x}}", $custom_fields_arr[1][$x - 1], $l_Template); if ($x > 5) { $l_Template = str_replace("{custom_value_{$x}}", stripslashes($row_custom_values[$x]), $l_Template); } else { $l_Template = str_replace("{custom_value_{$x}}", $custom_fields_arr[2][$x - 1][$row_custom_values[$x]], $l_Template); } } else { // remove placeholder if ($jlistConfigM['remove.field.title.when.empty']) { $l_Template = str_replace("{custom_title_{$x}}", '', $l_Template); } else { $l_Template = str_replace("{custom_title_{$x}}", $custom_fields_arr[1][$x - 1], $l_Template); } $l_Template = str_replace("{custom_value_{$x}}", '', $l_Template); } } // insert files title area if (!$jDLayoutTitleExists) { $l_Template = str_replace('{files_title_begin}', '', $l_Template); $l_Template = str_replace('{files_title_end}', '', $l_Template); $l_Template = str_replace('{files_title_text}', JText::_('COM_JDOWNLOADS_FE_FILELIST_TITLE_OVER_FILES_LIST'), $l_Template); $jDLayoutTitleExists = true; } else { if (strpos($l_Template, "{files_title_end}") > 0) { $pos_end = strpos($l_Template, '{files_title_end}'); $pos_beg = strpos($l_Template, '{files_title_begin}'); $l_Template = substr_replace($l_Template, '', $pos_beg, $pos_end - $pos_beg + 17); } } // support for other content plugins // $l_Template = JHTML::_('content.prepare', $l_Template); // remove empty html tags if ($jlistConfigM['remove.empty.tags']) { $l_Template = JDHelper::removeEmptyTags($l_Template); } return str_replace("[[[", "{", $l_Template); }
/** * Get the search result * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if the search it to be restricted to areas, null if search all */ function getSearchResults($text, $phrase = '', $ordering = '', $areas = null) { global $jlistConfig; $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $tag = JFactory::getLanguage()->getTag(); require_once JPATH_SITE . '/components/com_jdownloads/helpers/route.php'; require_once JPATH_SITE . '/components/com_jdownloads/helpers/search.php'; require_once JPATH_SITE . '/components/com_jdownloads/helpers/jdownloadshelper.php'; $user_rules = JDHelper::getUserRules(); $searchText = $text; $limit = $this->state->get('search_limit', 500); $nullDate = $db->getNullDate(); $date = JFactory::getDate(); $now = $date->toSql(); $text = trim($text); if ($text == '') { return array(); } $wheres = array(); switch ($phrase) { case 'exact': $text = $db->Quote('%' . $db->escape($text, true) . '%', false); $wheres2 = array(); if (!$areas || in_array('title', $areas)) { $wheres2[] = 'a.file_title LIKE ' . $text; } if (!$areas || in_array('description', $areas)) { $wheres2[] = 'a.description LIKE ' . $text; $wheres2[] = 'a.description_long LIKE ' . $text; } if (!$areas || in_array('changelog', $areas)) { $wheres2[] = 'a.changelog LIKE ' . $text; } if ($jlistConfig['custom.field.6.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_6 LIKE ' . $text; } } if ($jlistConfig['custom.field.7.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_7 LIKE ' . $text; } } if ($jlistConfig['custom.field.8.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_8 LIKE ' . $text; } } if ($jlistConfig['custom.field.9.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_9 LIKE ' . $text; } } if ($jlistConfig['custom.field.10.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_10 LIKE ' . $text; } } if ($jlistConfig['custom.field.13.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_13 LIKE ' . $text; } } if ($jlistConfig['custom.field.14.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_14 LIKE ' . $text; } } if (!$areas || in_array('author', $areas)) { $wheres2[] = 'a.author LIKE ' . $text; } if (!$areas || in_array('metatags', $areas)) { $wheres2[] = 'a.metakey LIKE ' . $text; $wheres2[] = 'a.metadesc LIKE ' . $text; } $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%' . $db->escape($word, true) . '%', false); $wheres2 = array(); if (!$areas || in_array('title', $areas)) { $wheres2[] = 'a.file_title LIKE ' . $word; } if (!$areas || in_array('description', $areas)) { $wheres2[] = 'a.description LIKE ' . $word; $wheres2[] = 'a.description_long LIKE ' . $word; } if (!$areas || in_array('changelog', $areas)) { $wheres2[] = 'a.changelog LIKE ' . $word; } if ($jlistConfig['custom.field.6.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_6 LIKE ' . $word; } } if ($jlistConfig['custom.field.7.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_7 LIKE ' . $word; } } if ($jlistConfig['custom.field.8.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_8 LIKE ' . $word; } } if ($jlistConfig['custom.field.9.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_9 LIKE ' . $word; } } if ($jlistConfig['custom.field.10.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_10 LIKE ' . $word; } } if ($jlistConfig['custom.field.13.title'] != '') { if (!$areas || in_array('customtext1', $areas)) { $wheres2[] = 'a.custom_field_13 LIKE ' . $word; } } if ($jlistConfig['custom.field.14.title'] != '') { if (!$areas || in_array('customtext2', $areas)) { $wheres2[] = 'a.custom_field_14 LIKE ' . $word; } } if (!$areas || in_array('author', $areas)) { $wheres2[] = 'a.author LIKE ' . $word; } if (!$areas || in_array('metatags', $areas)) { $wheres2[] = 'a.metakey LIKE ' . $word; $wheres2[] = 'a.metadesc LIKE ' . $word; } $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; break; } $morder = ''; switch ($ordering) { case 'oldest': $order = 'a.date_added ASC'; break; case 'popular': $order = 'a.downloads DESC'; break; case 'alpha': $order = 'a.file_title ASC'; break; case 'category': $order = 'c.title ASC, a.file_title ASC'; $morder = 'a.file_title ASC'; break; case 'newest': default: $order = 'a.date_added DESC'; break; } $uncategorised = JText::_('COM_JDOWNLOADS_SELECT_UNCATEGORISED'); $rows = array(); $query = $db->getQuery(true); // search downloads if ($limit > 0) { $query->clear(); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.file_alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.file_id'); $case_when .= $query->concatenate(array($a_id, 'a.file_alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id . ' END as catslug'; $query->select('a.file_title AS title, a.metadesc, a.metakey, a.url_download, a.extern_file, a.other_file_id, a.license_agree, a.password, a.author, a.date_added AS created, a.language, a.custom_field_6, a.custom_field_7, a.custom_field_8, a.custom_field_9, a.custom_field_10'); $query->select($query->concatenate(array('a.description', 'a.description_long', 'a.changelog', 'a.custom_field_13', 'a.custom_field_14')) . ' AS text'); $query->select('CASE c.title WHEN \'root\' THEN ' . $db->Quote($uncategorised) . ' ELSE c.title END AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav'); $query->from('#__jdownloads_files AS a'); $query->innerJoin('#__jdownloads_categories AS c ON c.id = a.cat_id'); $query->where('(' . $where . ')' . 'AND a.published = 1 AND c.published = 1 AND a.access IN (' . $groups . ') ' . 'AND c.access IN (' . $groups . ') ' . 'AND (a.publish_from = ' . $db->Quote($nullDate) . ' OR a.publish_from <= ' . $db->Quote($now) . ') ' . 'AND (a.publish_to = ' . $db->Quote($nullDate) . ' OR a.publish_to >= ' . $db->Quote($now) . ')'); $query->group('a.file_id, a.file_title, a.metadesc, a.metakey, a.author, a.date_added, a.description, a.description_long, a.changelog, a.custom_field_6, a.custom_field_7, a.custom_field_8, a.custom_field_9, a.custom_field_10, a.custom_field_13, a.custom_field_14, c.title, a.file_alias, c.alias, c.id'); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $list = $db->loadObjectList(); $limit -= count($list); if (isset($list)) { foreach ($list as $key => $item) { $direct_download = $jlistConfig['direct.download']; if (!$item->url_download && !$item->extern_file && !$item->other_file_id || $item->password || $item->license_agree || $user_rules->view_captcha) { // this download is a simple document without a file so we can not use 'direct' download option // or we need the summary page for password, captcha or license agree $direct_download = 0; } if ($jlistConfig['view.detailsite']) { // we must link to the details page $list[$key]->href = JDownloadsHelperRoute::getDownloadRoute($item->slug, $item->catslug, $item->language); } else { if ($direct_download) { // we must start the download process directly $list[$key]->href = JRoute::_('index.php?option=com_jdownloads&task=download.send&id=' . (int) $item->slug . '&catid=' . (int) $item->catslug . '&m=0'); } else { if (!$item->url_download && !$item->extern_file && !$item->other_file_id) { // Download is only a simple document without a file so we must link to the details page $list[$key]->href = JDownloadsHelperRoute::getDownloadRoute($item->slug, $item->catslug, $item->language); } else { // we must link to the summary page $list[$key]->href = JRoute::_('index.php?option=com_jdownloads&view=summary&id=' . $item->slug . '&catid=' . (int) $item->catslug); } } } } } $rows[] = $list; } $results = array(); if (count($rows)) { foreach ($rows as $row) { $new_row = array(); foreach ($row as $key => $download) { if (JDSearchHelper::checkNoHTML($download, $searchText, array('text', 'title', 'author', 'metadesc', 'metakey', 'custom_field_6', 'custom_field_7', 'custom_field_8', 'custom_field_9', 'custom_field_10'))) { $new_row[] = $download; } } $results = array_merge($results, (array) $new_row); } } return $results; }
$mirror2_link = '<a ' . $blank_window2 . ' href="' . $mirror2_link_dum . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfig['download.pic.mirror_2'] . '" style="border:0px;" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_2') . '" /></a>'; } else { // we use the new css button $mirror2_link = '<a ' . $blank_window2 . ' href="' . $mirror2_link_dum . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color_mirror2 . ' ' . $download_size_mirror . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_2') . '</a>'; } $html_file = str_replace('{mirror_2}', $mirror2_link, $html_file); } else { $html_file = str_replace('{mirror_2}', '', $html_file); } } else { $html_file = str_replace('{url_download}', '', $html_file); $html_file = str_replace('{mirror_1}', '', $html_file); $html_file = str_replace('{mirror_2}', '', $html_file); } if ($jlistConfig['view.detailsite']) { $title_link = JRoute::_(JDownloadsHelperRoute::getDownloadRoute($files[$i]->slug, $files[$i]->cat_id, $files[$i]->language)); $title_link_text = '<a href="' . $title_link . '">' . $this->escape($files[$i]->file_title) . '</a>'; $detail_link_text = '<a href="' . $title_link . '">' . JText::_('COM_JDOWNLOADS_FE_DETAILS_LINK_TEXT_TO_DETAILS') . '</a>'; // Symbol anzeigen - auch als url if ($files[$i]->file_pic != '') { $filepic = '<a href="' . $title_link . '">' . '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files[$i]->file_pic . '" style="text-align:top;width:' . $jlistConfig['file.pic.size'] . ';height:' . $jlistConfig['file.pic.size.height'] . ';border:0px;" alt="' . $files[$i]->file_pic . '" /></a> '; } else { $filepic = ''; } $html_file = str_replace('{file_pic}', $filepic, $html_file); // link to details view at the end $html_file = str_replace('{link_to_details}', $detail_link_text, $html_file); $html_file = str_replace('{file_title}', $title_link_text . ' ' . $editIcon, $html_file); } elseif ($jlistConfig['use.download.title.as.download.link']) { if ($user_can_see_download_url && !$has_no_file) { // build title link as download link
} // check is set link to a new window? if ($this->item->extern_file && $this->item->extern_site) { $blank_window = 'target="_blank"'; } // is 'direct download' activated? if ($jlistConfig['direct.download'] == '0') { // when not, we must link to the summary page $url_task = 'summary'; $blank_window = ''; $download_link = JRoute::_(JDownloadsHelperRoute::getOtherRoute($this->item->slug, $this->item->cat_id, $this->item->language, $url_task)); } else { if ($this->item->license_agree || $this->item->password || $this->user_rules->view_captcha) { // user must agree the license - fill out a password field - or fill out the captcha human check - so we must view the summary page! $url_task = 'summary'; $download_link = JRoute::_(JDownloadsHelperRoute::getOtherRoute($this->item->slug, $this->item->cat_id, $this->item->language, $url_task)); } else { // start the download promptly $url_task = 'download.send'; $download_link = JRoute::_('index.php?option=com_jdownloads&task=download.send&id=' . $this->item->file_id . '&catid=' . $this->item->cat_id . '&m=0'); } } if ($url_task == 'download.send') { // is the old button used? if ($jlistConfig['use.css.buttons.instead.icons'] == '0') { $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfig['download.pic.details'] . '" style="border:0px;" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" /></a>'; } else { // we use the new css button $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" class="jdbutton ' . $download_color . ' ' . $download_size . '">' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '</a>'; } } else {