1 | <?php |
||
2 | /** |
||
3 | * TDMDownload |
||
4 | * |
||
5 | * You may not change or alter any portion of this comment or credits |
||
6 | * of supporting developers from this source code or any supporting source code |
||
7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | * |
||
12 | * @copyright Gregory Mage (Aka Mage) |
||
13 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
14 | * @author Gregory Mage (Aka Mage) |
||
15 | */ |
||
16 | |||
17 | include_once 'header.php'; |
||
18 | // template d'affichage |
||
19 | $xoopsOption['template_main'] = 'tdmdownloads_index.tpl'; |
||
20 | include_once XOOPS_ROOT_PATH.'/header.php'; |
||
21 | $xoTheme->addStylesheet( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/styles.css', null ); |
||
22 | // pour les permissions |
||
23 | $categories = TDMDownloads_MygetItemIds('tdmdownloads_view', 'TDMDownloads'); |
||
24 | |||
25 | //tableau des t�l�chargements |
||
26 | $criteria = new CriteriaCompo(); |
||
27 | $criteria->add(new Criteria('status', 0, '!=')); |
||
28 | $criteria->add(new Criteria('cid', '(' . implode(',', $categories) . ')','IN')); |
||
29 | $downloads_arr = $downloads_Handler->getall($criteria); |
||
30 | $xoopsTpl->assign('lang_thereare', sprintf(_MD_TDMDOWNLOADS_INDEX_THEREARE, count($downloads_arr))); |
||
31 | |||
32 | //tableau des cat�gories |
||
33 | $criteria = new CriteriaCompo(); |
||
34 | $criteria->setSort('cat_weight ASC, cat_title'); |
||
35 | $criteria->setOrder('ASC'); |
||
36 | $criteria->add(new Criteria('cat_cid', '(' . implode(',', $categories) . ')','IN')); |
||
37 | $downloadscat_arr = $downloadscat_Handler->getall($criteria); |
||
38 | $mytree = new XoopsObjectTree($downloadscat_arr, 'cat_cid', 'cat_pid'); |
||
39 | |||
40 | //affichage des cat�gories |
||
41 | $xoopsTpl->assign('nb_catcol', $xoopsModuleConfig['nb_catcol']); |
||
42 | $count = 1; |
||
43 | $keywords = ''; |
||
44 | foreach (array_keys($downloadscat_arr) as $i) { |
||
45 | if ($downloadscat_arr[$i]->getVar('cat_pid') == 0) { |
||
46 | $totaldownloads = TDMDownloads_NumbersOfEntries($mytree, $categories, $downloads_arr, $downloadscat_arr[$i]->getVar('cat_cid')); |
||
47 | $subcategories_arr = $mytree->getFirstChild($downloadscat_arr[$i]->getVar('cat_cid')); |
||
48 | $chcount = 0; |
||
49 | $subcategories = ''; |
||
50 | //pour les mots clef |
||
51 | $keywords .= $downloadscat_arr[$i]->getVar('cat_title') . ','; |
||
52 | foreach (array_keys($subcategories_arr) as $j) { |
||
53 | if ($chcount>=$xoopsModuleConfig['nbsouscat']) { |
||
54 | $subcategories .= '<li>[<a href="' . XOOPS_URL . '/modules/TDMDownloads/viewcat.php?cid=' . $downloadscat_arr[$i]->getVar('cat_cid') . '">+</a>]</li>'; |
||
55 | break; |
||
56 | } |
||
57 | $subcategories .= '<li><a href="' . XOOPS_URL . '/modules/TDMDownloads/viewcat.php?cid=' . $subcategories_arr[$j]->getVar('cat_cid') . '">' . $subcategories_arr[$j]->getVar('cat_title') . '</a></li>'; |
||
58 | $keywords .= $downloadscat_arr[$i]->getVar('cat_title') . ','; |
||
59 | $chcount++; |
||
60 | } |
||
61 | $xoopsTpl->append('categories', array('image' => $uploadurl . $downloadscat_arr[$i]->getVar('cat_imgurl'), 'id' => $downloadscat_arr[$i]->getVar('cat_cid'), 'title' => $downloadscat_arr[$i]->getVar('cat_title'), 'description_main' => $downloadscat_arr[$i]->getVar('cat_description_main'), 'subcategories' => $subcategories, 'totaldownloads' => $totaldownloads, 'count' => $count)); |
||
62 | $count++; |
||
63 | } |
||
64 | } |
||
65 | |||
66 | //pour afficher les r�sum�s |
||
67 | //---------------------------------------------------------------------------------------------------------------------------------------------------- |
||
68 | //t�l�chargements r�cents |
||
69 | if ($xoopsModuleConfig['bldate']==1) { |
||
70 | $criteria = new CriteriaCompo(); |
||
71 | $criteria->add(new Criteria('status', 0, '!=')); |
||
72 | $criteria->add(new Criteria('cid', '(' . implode(',', $categories) . ')','IN')); |
||
73 | $criteria->setSort('date'); |
||
74 | $criteria->setOrder('DESC'); |
||
75 | $criteria->setLimit($xoopsModuleConfig['nbbl']); |
||
76 | $downloads_arr_date = $downloads_Handler->getall($criteria); |
||
77 | foreach (array_keys($downloads_arr_date) as $i) { |
||
78 | $title = $downloads_arr_date[$i]->getVar('title'); |
||
79 | if (strlen($title) >= $xoopsModuleConfig['longbl']) { |
||
80 | $title = substr($title,0,($xoopsModuleConfig['longbl']))."..."; |
||
81 | } |
||
82 | $date = formatTimestamp($downloads_arr_date[$i]->getVar('date'),"s"); |
||
83 | $xoopsTpl->append('bl_date', array('id' => $downloads_arr_date[$i]->getVar('lid'),'cid' => $downloads_arr_date[$i]->getVar('cid'),'date' => $date,'title' => $title)); |
||
84 | } |
||
85 | } |
||
86 | //plus t�l�charg�s |
||
87 | if ($xoopsModuleConfig['blpop']==1) { |
||
88 | $criteria = new CriteriaCompo(); |
||
89 | $criteria->add(new Criteria('status', 0, '!=')); |
||
90 | $criteria->add(new Criteria('cid', '(' . implode(',', $categories) . ')','IN')); |
||
91 | $criteria->setSort('hits'); |
||
92 | $criteria->setOrder('DESC'); |
||
93 | $criteria->setLimit($xoopsModuleConfig['nbbl']); |
||
94 | $downloads_arr_hits = $downloads_Handler->getall($criteria); |
||
95 | foreach (array_keys($downloads_arr_hits) as $i) { |
||
96 | $title = $downloads_arr_hits[$i]->getVar('title'); |
||
97 | if (strlen($title) >= $xoopsModuleConfig['longbl']) { |
||
98 | $title = substr($title,0,($xoopsModuleConfig['longbl']))."..."; |
||
99 | } |
||
100 | $xoopsTpl->append('bl_pop', array('id' => $downloads_arr_hits[$i]->getVar('lid'),'cid' => $downloads_arr_hits[$i]->getVar('cid'),'hits' => $downloads_arr_hits[$i]->getVar('hits'),'title' => $title)); |
||
101 | } |
||
102 | } |
||
103 | //mieux not�s |
||
104 | if ($xoopsModuleConfig['blrating']==1) { |
||
105 | $criteria = new CriteriaCompo(); |
||
106 | $criteria->add(new Criteria('status', 0, '!=')); |
||
107 | $criteria->add(new Criteria('cid', '(' . implode(',', $categories) . ')','IN')); |
||
108 | $criteria->setSort('rating'); |
||
109 | $criteria->setOrder('DESC'); |
||
110 | $criteria->setLimit($xoopsModuleConfig['nbbl']); |
||
111 | $downloads_arr_rating = $downloads_Handler->getall($criteria); |
||
112 | foreach (array_keys($downloads_arr_rating) as $i) { |
||
113 | $title = $downloads_arr_rating[$i]->getVar('title'); |
||
114 | if (strlen($title) >= $xoopsModuleConfig['longbl']) { |
||
115 | $title = substr($title,0,($xoopsModuleConfig['longbl']))."..."; |
||
116 | } |
||
117 | $rating = number_format($downloads_arr_rating[$i]->getVar('rating'),1); |
||
118 | $xoopsTpl->append('bl_rating', array('id' => $downloads_arr_rating[$i]->getVar('lid'),'cid' => $downloads_arr_rating[$i]->getVar('cid'),'rating' => $rating,'title' => $title)); |
||
119 | } |
||
120 | } |
||
121 | if ($xoopsModuleConfig['bldate']==0 and $xoopsModuleConfig['blpop']==0 and $xoopsModuleConfig['blrating']==0) { |
||
122 | $bl_affichage = 0; |
||
123 | } else { |
||
124 | $bl_affichage = 1; |
||
125 | } |
||
126 | $xoopsTpl->assign('bl_affichage', $bl_affichage); |
||
127 | $xoopsTpl->assign('show_latest_files' , $xoopsModuleConfig['show_latest_files']); |
||
128 | |||
129 | //---------------------------------------------------------------------------------------------------------------------------------------------------- |
||
130 | |||
131 | // affichage des t�l�chargements |
||
132 | if ($xoopsModuleConfig['newdownloads'] > 0) { |
||
133 | $xoopsTpl->assign('nb_dowcol', $xoopsModuleConfig['nb_dowcol']); |
||
134 | //Utilisation d'une copie d'�cran avec la largeur selon les pr�f�rences |
||
135 | if ($xoopsModuleConfig['useshots'] == 1) { |
||
136 | $xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']); |
||
137 | $xoopsTpl->assign('show_screenshot', true); |
||
138 | $xoopsTpl->assign('img_float' , $xoopsModuleConfig['img_float']); |
||
139 | } |
||
140 | $criteria = new CriteriaCompo(); |
||
141 | $criteria->add(new Criteria('status', 0, '!=')); |
||
142 | $criteria->add(new Criteria('cid', '(' . implode(',', $categories) . ')','IN')); |
||
143 | $criteria->setLimit($xoopsModuleConfig['newdownloads']); |
||
144 | $tblsort = array(); |
||
145 | $tblsort[1]='date'; |
||
146 | $tblsort[2]='date'; |
||
147 | $tblsort[3]='hits'; |
||
148 | $tblsort[4]='hits'; |
||
149 | $tblsort[5]='rating'; |
||
150 | $tblsort[6]='rating'; |
||
151 | $tblsort[7]='title'; |
||
152 | $tblsort[8]='title'; |
||
153 | $tblorder = array(); |
||
154 | $tblorder[1]='DESC'; |
||
155 | $tblorder[2]='ASC'; |
||
156 | $tblorder[3]='DESC'; |
||
157 | $tblorder[4]='ASC'; |
||
158 | $tblorder[5]='DESC'; |
||
159 | $tblorder[6]='ASC'; |
||
160 | $tblorder[7]='DESC'; |
||
161 | $tblorder[8]='ASC'; |
||
162 | $sort = isset($xoopsModuleConfig['toporder']) ? $xoopsModuleConfig['toporder'] : 1; |
||
163 | $order = isset($xoopsModuleConfig['toporder']) ? $xoopsModuleConfig['toporder'] : 1; |
||
164 | $criteria->setSort($tblsort[$sort]); |
||
165 | $criteria->setOrder($tblorder[$order]); |
||
166 | $downloads_arr = $downloads_Handler->getall($criteria); |
||
167 | $categories = TDMDownloads_MygetItemIds('tdmdownloads_download', 'TDMDownloads'); |
||
168 | $item = TDMDownloads_MygetItemIds('tdmdownloads_download_item', 'TDMDownloads'); |
||
169 | $count = 1; |
||
170 | foreach (array_keys($downloads_arr) as $i) { |
||
171 | if ($downloads_arr[$i]->getVar('logourl') == 'blank.gif') { |
||
172 | $logourl = ''; |
||
173 | } else { |
||
174 | $logourl = $downloads_arr[$i]->getVar('logourl'); |
||
175 | $logourl = $uploadurl_shots . $logourl; |
||
176 | } |
||
177 | $datetime = formatTimestamp($downloads_arr[$i]->getVar('date'),'s'); |
||
178 | $submitter = XoopsUser::getUnameFromId($downloads_arr[$i]->getVar('submitter')); |
||
179 | $description = $downloads_arr[$i]->getVar('description'); |
||
180 | //permet d'afficher uniquement la description courte |
||
181 | if (strpos($description,'[pagebreak]')==false) { |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
182 | $description_short = $description; |
||
183 | } else { |
||
184 | $description_short = substr($description,0,strpos($description,'[pagebreak]')); |
||
185 | } |
||
186 | // pour les vignettes "new" et "mis � jour" |
||
187 | $new = TDMDownloads_Thumbnail($downloads_arr[$i]->getVar('date'), $downloads_arr[$i]->getVar('status')); |
||
188 | $pop = TDMDownloads_Popular($downloads_arr[$i]->getVar('hits')); |
||
189 | |||
190 | // D�fini si la personne est un admin |
||
191 | if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { |
||
192 | $adminlink = '<a href="' . XOOPS_URL . '/modules/TDMDownloads/admin/downloads.php?op=view_downloads&downloads_lid=' . $downloads_arr[$i]->getVar('lid') . '" title="' . _MD_TDMDOWNLOADS_EDITTHISDL . '"><img src="' . XOOPS_URL . '/modules/TDMDownloads/images/icon/edit.png" width="16px" height="16px" border="0" alt="' . _MD_TDMDOWNLOADS_EDITTHISDL . '" /></a>'; |
||
193 | } else { |
||
194 | $adminlink = ''; |
||
195 | } |
||
196 | //permission de t�l�charger |
||
197 | if ($xoopsModuleConfig['permission_download'] == 1) { |
||
198 | if (!in_array($downloads_arr[$i]->getVar('cid'), $categories)) { |
||
199 | $perm_download = false; |
||
200 | } else { |
||
201 | $perm_download = true; |
||
202 | } |
||
203 | } else { |
||
204 | if (!in_array($downloads_arr[$i]->getVar('lid'), $item)) { |
||
205 | $perm_download = false; |
||
206 | } else { |
||
207 | $perm_download = true; |
||
208 | } |
||
209 | } |
||
210 | $xoopsTpl->append('file', array('id' => $downloads_arr[$i]->getVar('lid'),'cid'=>$downloads_arr[$i]->getVar('cid'), 'title' => $downloads_arr[$i]->getVar('title'), 'new' => $new, 'pop' => $pop,'logourl' => $logourl,'updated' => $datetime,'description_short' => $description_short, |
||
211 | 'adminlink' => $adminlink, 'submitter' => $submitter, 'perm_download' => $perm_download, 'count' => $count)); |
||
212 | //pour les mots clef |
||
213 | $keywords .= $downloads_arr[$i]->getVar('title') . ','; |
||
214 | $count++; |
||
215 | } |
||
216 | } |
||
217 | // r�f�rencement |
||
218 | //description |
||
219 | $xoTheme->addMeta('meta', 'description', strip_tags($xoopsModule->name())); |
||
220 | //keywords |
||
221 | $keywords = substr($keywords,0,-1); |
||
222 | $xoTheme->addMeta('meta', 'keywords', $keywords); |
||
223 | |||
224 | include XOOPS_ROOT_PATH.'/footer.php'; |
||
225 |