Changeset 1512 in ExiteCMS for themes/PLi-Fusion/PLiXmas/php-files/themes/PLiXmas/theme_functions.php
- Timestamp:
- 07/02/08 18:58:52 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
themes/PLi-Fusion/PLiXmas/php-files/themes/PLiXmas/theme_functions.php
r1169 r1512 14 14 // include the menu functions to create the header menu bar 15 15 require_once PATH_INCLUDES."menu_include.php"; 16 17 // include the text image generation function 18 require_once PATH_INCLUDES."font2image.php"; 16 19 17 20 // generate the treelist for items in the header menu bar … … 54 57 +-------------------------------------------------------*/ 55 58 function downloadbars() { 56 global $db_prefix; 57 59 global $db_prefix, $settings; 60 61 // define the download records we want a bar graph from 62 $downloads = array(); 63 64 $total = 0; 65 // get the defined download bars 66 $result = dbquery("SELECT * FROM ".$db_prefix."dlstats_counters ORDER BY dlsc_order"); 67 while ($data = dbarray($result)) { 68 // start with a count of zero 69 $download = array('download_count' => 0); 70 // check if we need to get a local download counter 71 if ($data['dlsc_download_id']) { 72 $result2 = dbquery("SELECT d.*, c.download_cat_access FROM ".$db_prefix."downloads d LEFT JOIN ".$db_prefix."download_cats c ON d.download_cat = c.download_cat_id WHERE d.download_id = '".$data['dlsc_download_id']."'"); 73 if ($data2 = dbarray($result2)) { 74 // check if this user has the right to download it 75 $access = true; 76 $cat_id = $data2['download_cat']; 77 while(true) { 78 // check if the user has access to this download item 79 $data3 = dbarray(dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id = '".$cat_id."'")); 80 if (!checkgroup($data3['download_cat_access'])) { 81 $access = false; 82 break; 83 } 84 // if this was a sub-category, check the parent as well 85 $cat_id = $data3['download_parent']; 86 // if no more parents are present, end the loop 87 if ($cat_id == 0) break; 88 } 89 // if the user has access, add the info from the download record 90 if ($access) { 91 $download = array_merge($download, $data2); 92 } 93 } 94 } 95 // check if we need to add file counters 96 $files = explode("\n", $data['dlsc_files']); 97 foreach($files as $file) { 98 $result2 = dbquery("SELECT * FROM ".$db_prefix."dlstats_files WHERE dlsf_file = '".trim($file)."'"); 99 if ($data2 = dbarray($result2)) { 100 // get the counter 101 $download['download_count'] += $data2['dlsf_counter']; 102 } 103 } 104 // and add some data from the counter definition 105 $download['download_title'] = $data['dlsc_name']; 106 $download['download_description'] = $data['dlsc_description']; 107 // make sure the title is properly formatted and fits 108 if (strlen($download['download_title']) > 6) $download['download_title'] = substr($download['download_title'],0,6); 109 $download['download_title'] = strtoupper(trim($download['download_title'])); 110 $font2png['font_text'] = $download['download_title']; 111 $total += $download['download_count']; 112 $downloads[] = $download; 113 } 114 58 115 // define the max width of a bar in pixels 59 116 $barheight = 65; 60 61 // define the download records we want a bar graph from62 $download = array();63 64 // get the download statistics for the required download records65 $total = 0;66 $result = dbquery("SELECT * FROM ".$db_prefix."downloads WHERE download_bar > '0' ORDER BY download_bar DESC");67 while ($data = dbarray($result)) {68 $access = true;69 $cat_id = $data['download_cat'];70 while(true) {71 // check if the user has access to this download item72 $data2 = dbarray(dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id = '".$cat_id."'"));73 if (!checkgroup($data2['download_cat_access'])) {74 $access = false;75 break;76 }77 // if this was a sub-category, check the parent as well78 $cat_id = $data2['download_parent'];79 // if no more parents are present, end the loop80 if ($cat_id == 0) break;81 82 }83 // if the user has access, add this download to the bar panel84 if ($access) {85 if (strlen($data['download_title']) > 6) $data['download_title'] = substr($data['download_title'],0,6);86 $data['download_title'] = strtoupper(trim($data['download_title']));87 $download[] = $data;88 $total += $data['download_count'];89 }90 }91 117 92 118 // calculate the percentages of the grand total of all the entries listed (in $total) 93 119 $maxperc = 0; 94 foreach ($download as $key => $value) {120 foreach ($downloads as $key => $value) { 95 121 if ($total == 0) 96 $download [$key]['percentage'] = 0;122 $downloads[$key]['percentage'] = 0; 97 123 else 98 $download [$key]['percentage'] = floor($value['download_count'] / $total * 100);124 $downloads[$key]['percentage'] = floor($value['download_count'] / $total * 100); 99 125 // add 1 to make sure 'percentage' is never zero (to work around a Firefox DIV bug) 100 $download [$key]['percentage']++;101 $maxperc = max($maxperc, $download [$key]['percentage']);126 $downloads[$key]['percentage']++; 127 $maxperc = max($maxperc, $downloads[$key]['percentage']); 102 128 } 103 129 // calculate the percentage multiplier to fill out the bars nicely … … 106 132 // display the panel with the download statistics 107 133 $i=1; 108 foreach ($download as $key => $value) { 109 $download[$key]['value'] = floor($value['percentage'] * $multiplier); 110 $download[$key]['baseline'] = 65 - $download[$key]['value']; 134 foreach ($downloads as $key => $value) { 135 $downloads[$key]['value'] = floor($value['percentage'] * $multiplier); 111 136 $i++; 112 137 } 113 return $download; 138 139 return $downloads; 114 140 } 115 141 … … 117 143 | Generate the title for the download bar counter | 118 144 +-------------------------------------------------------*/ 119 function bartitle( ) {120 global $db_prefix ;145 function bartitle($downloads) { 146 global $db_prefix, $settings; 121 147 122 $result = dbquery("SELECT download_cat_name FROM ".$db_prefix."download_cats WHERE download_cat_id = '0'"); 123 if ($data = dbarray($result)) 124 if ($data['download_cat_name'] != "") $bar_title = trim($data['download_cat_name']); 125 if (!isset($bar_title)) $bar_title = "Current Release Downloads"; 148 // calculate the total downloads 149 $total = 0; 150 foreach ($downloads as $download) { 151 $total += $download['download_count']; 152 } 126 153 154 $bar_title = explode("|", $settings['dlstats_title']); 155 $bar_title = sprintf(html_entity_decode(trim($bar_title[0])),$total); 156 157 if (!isset($bar_title)) $bar_title = "Current image downloads "; 158 127 159 return $bar_title; 128 160 }
Note: See TracChangeset
for help on using the changeset viewer.
