PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/default/mainpage_modules/fdm_new_popular_lister.php

https://github.com/vaughnpaul/NOS
PHP | 82 lines | 67 code | 4 blank | 11 comment | 11 complexity | 58ce1ce366b4c21c8db50c1dccfb2de3 MD5 | raw file
  1. <?php
  2. /*
  3. $Id: fdm_new_popular_lister.php,v 1.0.0.0 2008/01/24 13:41:11 Eversun Exp $
  4. CRE Loaded, Open Source E-Commerce Solutions
  5. http://www.creloaded.com
  6. Copyright (c) 2007 CRE Loaded
  7. Copyright (c) 2003 osCommerce
  8. Released under the GNU General Public License
  9. */
  10. ?>
  11. <!-- new_popular_lister_bof //-->
  12. <?php
  13. $list_box_contents = array();
  14. $column_list = array('FILE_LIST_NEW_DOWNLOADS', 'FILE_LIST_POPULAR_DOWNLOADS');
  15. for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  16. switch ($column_list[$col]) {
  17. case 'FILE_LIST_NEW_DOWNLOADS':
  18. $lc_text = TABLE_HEADING_NEW_DOWNLOADS;
  19. $lc_align = 'center';
  20. break;
  21. case 'FILE_LIST_POPULAR_DOWNLOADS':
  22. $lc_text = TABLE_HEADING_POPULAR_DOWNLOADS;
  23. $lc_align = 'center';
  24. break;
  25. }
  26. $list_box_contents[0][] = array('align' => $lc_align,
  27. 'params' => 'class="productListing-heading"',
  28. 'text' => '&nbsp;' . $lc_text . '&nbsp;');
  29. }
  30. $rows = 0;
  31. $listing_query = tep_db_query("select lf.files_id, lf.files_name, lfd.files_description, lfd.files_descriptive_name, fi.icon_large from " . TABLE_LIBRARY_FILES . " lf, " . TABLE_LIBRARY_FILES_DESCRIPTION . " lfd, " . TABLE_FILE_ICONS . " fi where lf.files_id = lfd.files_id and lfd.language_id = '" . $languages_id . "' and fi.icon_id = lf.files_icon order by lf.files_date_added desc limit 5");
  32. $no_listing1 = tep_db_num_rows($listing_query);
  33. while ($_listing = tep_db_fetch_array($listing_query)) {
  34. $listing1[] = $_listing;
  35. }
  36. $month_ago = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 30, date('Y')));
  37. $listing_query = tep_db_query("select files_id, count(*) as number from " . TABLE_LIBRARY_FILES_DOWNLOAD . " where download_time between '" . $month_ago . "' and '" . date('Y-m-d') . "' group by files_id order by number desc limit 5");
  38. $files_ids = '';
  39. while ($_listing = tep_db_fetch_array($listing_query)) {
  40. $files_ids .= $_listing['files_id'] . ', ';
  41. }
  42. $files_ids .= "''";
  43. $listing_query = tep_db_query("select lf.files_id, lf.files_name, lfd.files_description, lfd.files_descriptive_name, fi.icon_large from " . TABLE_LIBRARY_FILES . " lf, " . TABLE_LIBRARY_FILES_DESCRIPTION . " lfd, " . TABLE_FILE_ICONS . " fi where lf.files_id = lfd.files_id and lfd.language_id = '" . $languages_id . "' and fi.icon_id = lf.files_icon and lf.files_id in (" . $files_ids . ")");
  44. $no_listing2 = tep_db_num_rows($listing_query);
  45. while ($_listing = tep_db_fetch_array($listing_query)) {
  46. $listing2[] = $_listing;
  47. }
  48. for ($x = 0; $x < max($no_listing1, $no_listing2); $x++) {
  49. $rows++;
  50. if (($rows/2) == floor($rows/2)) {
  51. $list_box_contents[] = array('params' => 'class="productListing-even"');
  52. } else {
  53. $list_box_contents[] = array('params' => 'class="productListing-odd"');
  54. }
  55. $cur_row = sizeof($list_box_contents) - 1;
  56. for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  57. $lc_align = '';
  58. switch ($column_list[$col]) {
  59. case 'FILE_LIST_NEW_DOWNLOADS':
  60. $lc_align = 'center';
  61. $lc_text = '<a href="' . tep_href_link(FILENAME_FILE_DETAIL, 'file_id=' . $listing1[$x]['files_id']) . '">' . tep_image(DIR_WS_IMAGES . 'file_icons/' . $listing1[$x]['icon_large'], $listing1[$x]['files_descriptive_name'], FDM_LARGE_ICON_IMAGE_WIDTH, FDM_LARGE_ICON_IMAGE_HEIGHT) . '</a><br>&nbsp;<a href="' . tep_href_link(FILENAME_FILE_DETAIL, 'file_id=' . $listing1[$x]['files_id']) . '">' . $listing1[$x]['files_descriptive_name'] . '</a>';
  62. break;
  63. case 'FILE_LIST_POPULAR_DOWNLOADS':
  64. $lc_align = 'center';
  65. $lc_text = '<a href="' . tep_href_link(FILENAME_FILE_DETAIL, 'file_id=' . $listing2[$x]['files_id']) . '">' . tep_image(DIR_WS_IMAGES . 'file_icons/' . $listing2[$x]['icon_large'], $listing2[$x]['files_descriptive_name'], FDM_LARGE_ICON_IMAGE_WIDTH, FDM_LARGE_ICON_IMAGE_HEIGHT) . '</a><br>&nbsp;<a href="' . tep_href_link(FILENAME_FILE_DETAIL, 'file_id=' . $listing2[$x]['files_id']) . '">' . $listing2[$x]['files_descriptive_name'] . '</a>';
  66. break;
  67. }
  68. $list_box_contents[$cur_row][] = array('align' => $lc_align,
  69. 'params' => 'class="productListing-data"',
  70. 'text' => $lc_text);
  71. }
  72. }
  73. new productListingBox($list_box_contents);
  74. ?>
  75. <!-- new_popular_lister_eof //-->