These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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_liste.html'; |
||
20 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
21 | $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/styles.css', null); |
||
22 | |||
23 | $categories = TDMDownloads_MygetItemIds('tdmdownloads_view', 'TDMDownloads'); |
||
24 | |||
25 | View Code Duplication | if (isset($_REQUEST['title'])) { |
|
0 ignored issues
–
show
|
|||
26 | $_REQUEST['title'] != '' ? $title = $_REQUEST['title'] : $title = ''; |
||
27 | } else { |
||
28 | $title = ''; |
||
29 | } |
||
30 | |||
31 | View Code Duplication | if (isset($_REQUEST['cat'])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
32 | $_REQUEST['cat'] != 0 ? $cat = $_REQUEST['cat'] : $cat = 0; |
||
33 | } else { |
||
34 | $cat = 0; |
||
35 | } |
||
36 | // tableau ------ |
||
37 | $criteria_2 = new CriteriaCompo(); |
||
38 | $criteria_2->add(new Criteria('status', 0, '!=')); |
||
39 | $criteria_2->add(new Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); |
||
40 | // ------ |
||
41 | //formulaire de recherche |
||
42 | $form = new XoopsThemeForm(_MD_TDMDOWNLOADS_SEARCH, "search", "search.php", 'post'); |
||
43 | $form->setExtra('enctype="multipart/form-data"'); |
||
44 | //recherche par titre |
||
45 | $form->addElement(new XoopsFormText(_MD_TDMDOWNLOADS_SEARCH_TITLE, 'title', 25, 255, $title)); |
||
46 | //recherche par cat�gorie |
||
47 | $criteria = new CriteriaCompo(); |
||
48 | $criteria->setSort('cat_weight ASC, cat_title'); |
||
49 | $criteria->setOrder('ASC'); |
||
50 | $criteria->add(new Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); |
||
51 | /*$cat_select = new XoopsFormSelect(_MD_TDMDOWNLOADS_SEARCH_CATEGORIES . ' ', 'cat', $cat); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
63% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
52 | $cat_select->addOption(0,_MD_TDMDOWNLOADS_SEARCH_ALL2); |
||
53 | $cat_select->addOptionArray($downloadscat_Handler->getList($criteria )); |
||
54 | $form->addElement($cat_select);*/ |
||
55 | $downloadscat_arr = $downloadscat_Handler->getall($criteria); |
||
56 | $mytree = new XoopsObjectTree($downloadscat_arr, 'cat_cid', 'cat_pid'); |
||
57 | $form->addElement(new XoopsFormLabel(_AM_TDMDOWNLOADS_FORMINCAT, $mytree->makeSelBox('cat', 'cat_title', '--', $cat, true))); |
||
58 | |||
59 | //recherche champ sup. |
||
60 | $downloadsfield_Handler =& xoops_getModuleHandler('tdmdownloads_field', 'TDMDownloads'); |
||
61 | $criteria = new CriteriaCompo(); |
||
62 | $criteria->add(new Criteria('search', 1)); |
||
63 | $criteria->add(new Criteria('status', 1)); |
||
64 | $criteria->setSort('weight ASC, title'); |
||
65 | $criteria->setOrder('ASC'); |
||
66 | $downloads_field = $downloadsfield_Handler->getall($criteria); |
||
67 | |||
68 | $arguments = ''; |
||
69 | foreach (array_keys($downloads_field) as $i) { |
||
70 | $title_sup = ''; |
||
71 | $contenu_arr = array(); |
||
72 | $lid_arr = array(); |
||
73 | $nom_champ = 'champ' . $downloads_field[$i]->getVar('fid'); |
||
74 | $criteria = new CriteriaCompo(); |
||
75 | if (isset($_REQUEST[$nom_champ])) { |
||
76 | $_REQUEST[$nom_champ] |
||
77 | != 999 ? $champ_contenu[$downloads_field[$i]->getVar('fid')] = $_REQUEST[$nom_champ] : $champ_contenu[$downloads_field[$i]->getVar('fid')] = 999; |
||
78 | $arguments .= $nom_champ . '=' . $_REQUEST[$nom_champ] . '&'; |
||
79 | } else { |
||
80 | $champ_contenu[$downloads_field[$i]->getVar('fid')] = 999; |
||
81 | $arguments .= $nom_champ . '=&'; |
||
82 | } |
||
83 | if ($downloads_field[$i]->getVar('status_def') == 1) { |
||
84 | $criteria->add(new Criteria('status', 0, '!=')); |
||
85 | if ($downloads_field[$i]->getVar('fid') == 1) { |
||
86 | //page d'accueil |
||
87 | $title_sup = _AM_TDMDOWNLOADS_FORMHOMEPAGE; |
||
88 | $criteria->setSort('homepage'); |
||
89 | $nom_champ_base = 'homepage'; |
||
90 | } |
||
91 | View Code Duplication | if ($downloads_field[$i]->getVar('fid') == 2) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
92 | //version |
||
93 | $title_sup = _AM_TDMDOWNLOADS_FORMVERSION; |
||
94 | $criteria->setSort('version'); |
||
95 | $nom_champ_base = 'version'; |
||
96 | } |
||
97 | View Code Duplication | if ($downloads_field[$i]->getVar('fid') == 3) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
98 | //taille du fichier |
||
99 | $title_sup = _AM_TDMDOWNLOADS_FORMSIZE; |
||
100 | $criteria->setSort('size'); |
||
101 | $nom_champ_base = 'size'; |
||
102 | } |
||
103 | if ($downloads_field[$i]->getVar('fid') == 4) { |
||
104 | //platform |
||
105 | $title_sup = _AM_TDMDOWNLOADS_FORMPLATFORM; |
||
106 | $platform_array = explode('|', $xoopsModuleConfig['plateform']); |
||
107 | foreach ($platform_array as $platform) { |
||
108 | $contenu_arr[$platform] = $platform; |
||
109 | } |
||
110 | if ($champ_contenu[$downloads_field[$i]->getVar('fid')] != 999) { |
||
111 | $criteria_2->add( |
||
112 | new Criteria('platform', '%' . $champ_contenu[$downloads_field[$i]->getVar('fid')] . '%', 'LIKE') |
||
113 | ); |
||
114 | } |
||
115 | } else { |
||
116 | $criteria->setOrder('ASC'); |
||
117 | $tdmdownloads_arr = $downloads_Handler->getall($criteria); |
||
118 | View Code Duplication | foreach (array_keys($tdmdownloads_arr) as $j) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
119 | $contenu_arr[$tdmdownloads_arr[$j]->getVar($nom_champ_base)] = $tdmdownloads_arr[$j]->getVar($nom_champ_base); |
||
120 | } |
||
121 | if ($champ_contenu[$downloads_field[$i]->getVar('fid')] != 999) { |
||
122 | $criteria_2->add(new Criteria($nom_champ_base, $champ_contenu[$downloads_field[$i]->getVar('fid')])); |
||
123 | } |
||
124 | } |
||
125 | |||
126 | View Code Duplication | } else { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
127 | $title_sup = $downloads_field[$i]->getVar('title'); |
||
128 | $criteria->add(new Criteria('fid', $downloads_field[$i]->getVar('fid'))); |
||
129 | $criteria->setSort('data'); |
||
130 | $criteria->setOrder('ASC'); |
||
131 | $tdmdownloads_arr = $downloadsfielddata_Handler->getall($criteria); |
||
132 | foreach (array_keys($tdmdownloads_arr) as $j) { |
||
133 | $contenu_arr[$tdmdownloads_arr[$j]->getVar('data', 'n')] = $tdmdownloads_arr[$j]->getVar('data'); |
||
134 | } |
||
135 | if ($champ_contenu[$downloads_field[$i]->getVar('fid')] != '') { |
||
136 | $criteria_1 = new CriteriaCompo(); |
||
137 | $criteria_1->add(new Criteria('data', $champ_contenu[$downloads_field[$i]->getVar('fid')])); |
||
138 | $data_arr = $downloadsfielddata_Handler->getall($criteria_1); |
||
139 | foreach (array_keys($data_arr) as $k) { |
||
140 | $lid_arr[] = $data_arr[$k]->getVar('lid'); |
||
141 | } |
||
142 | |||
143 | } |
||
144 | $form->addElement($select_sup); |
||
145 | } |
||
146 | if (count($lid_arr) > 0) { |
||
147 | $criteria_2->add(new Criteria('lid', '(' . implode(',', $lid_arr) . ')', 'IN')); |
||
148 | } |
||
149 | $select_sup = new XoopsFormSelect($title_sup, $nom_champ, $champ_contenu[$downloads_field[$i]->getVar('fid')]); |
||
150 | $select_sup->addOption(999, _MD_TDMDOWNLOADS_SEARCH_ALL1); |
||
151 | $select_sup->addOptionArray($contenu_arr); |
||
152 | $form->addElement($select_sup); |
||
153 | unset ($select_sup); |
||
154 | $xoopsTpl->append('field', $downloads_field[$i]->getVar('title')); |
||
155 | } |
||
156 | |||
157 | //bouton validation |
||
158 | $button_tray = new XoopsFormElementTray('', ''); |
||
159 | $button_tray->addElement(new XoopsFormButton('', 'submit', _MD_TDMDOWNLOADS_SEARCH_BT, 'submit')); |
||
160 | $form->addElement($button_tray); |
||
161 | |||
162 | if ($title != '') { |
||
163 | $criteria_2->add(new Criteria('title', '%' . $title . '%', 'LIKE')); |
||
164 | $arguments .= 'title=' . $title . '&'; |
||
165 | } |
||
166 | if ($cat != 0) { |
||
167 | $criteria_2->add(new Criteria('cid', $cat)); |
||
168 | $arguments .= 'cat=' . $cat . '&'; |
||
169 | } |
||
170 | $tblsort = array(); |
||
171 | $tblsort[1] = 'date'; |
||
172 | $tblsort[2] = 'date'; |
||
173 | $tblsort[3] = 'hits'; |
||
174 | $tblsort[4] = 'hits'; |
||
175 | $tblsort[5] = 'rating'; |
||
176 | $tblsort[6] = 'rating'; |
||
177 | $tblsort[7] = 'title'; |
||
178 | $tblsort[8] = 'title'; |
||
179 | $tblorder = array(); |
||
180 | $tblorder[1] = 'DESC'; |
||
181 | $tblorder[2] = 'ASC'; |
||
182 | $tblorder[3] = 'DESC'; |
||
183 | $tblorder[4] = 'ASC'; |
||
184 | $tblorder[5] = 'DESC'; |
||
185 | $tblorder[6] = 'ASC'; |
||
186 | $tblorder[7] = 'DESC'; |
||
187 | $tblorder[8] = 'ASC'; |
||
188 | $sort = isset($xoopsModuleConfig['searchorder']) ? $xoopsModuleConfig['searchorder'] : 1; |
||
189 | $order = isset($xoopsModuleConfig['searchorder']) ? $xoopsModuleConfig['searchorder'] : 1; |
||
190 | $criteria_2->setSort($tblsort[$sort]); |
||
191 | $criteria_2->setOrder($tblorder[$order]); |
||
192 | $numrows = $downloads_Handler->getCount($criteria_2); |
||
193 | View Code Duplication | if (isset($_REQUEST['limit'])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
194 | $criteria_2->setLimit($_REQUEST['limit']); |
||
195 | $limit = $_REQUEST['limit']; |
||
196 | } else { |
||
197 | $criteria_2->setLimit($xoopsModuleConfig['perpageliste']); |
||
198 | $limit = $xoopsModuleConfig['perpageliste']; |
||
199 | } |
||
200 | View Code Duplication | if (isset($_REQUEST['start'])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
201 | $criteria_2->setStart($_REQUEST['start']); |
||
202 | $start = $_REQUEST['start']; |
||
203 | } else { |
||
204 | $criteria_2->setStart(0); |
||
205 | $start = 0; |
||
206 | } |
||
207 | //pour faire une jointure de table |
||
208 | $downloads_Handler->table_link = $downloads_Handler->db->prefix("tdmdownloads_cat"); // Nom de la table en jointure |
||
209 | $downloads_Handler->field_link = "cat_cid"; // champ de la table en jointure |
||
210 | $downloads_Handler->field_object = "cid"; // champ de la table courante |
||
211 | $tdmdownloads_arr = $downloads_Handler->getByLink($criteria_2); |
||
212 | View Code Duplication | if ($numrows > $limit) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
213 | $pagenav = new XoopsPageNav($numrows, $limit, $start, 'start', $arguments); |
||
214 | $pagenav = $pagenav->renderNav(4); |
||
215 | } else { |
||
216 | $pagenav = ''; |
||
217 | } |
||
218 | $xoopsTpl->assign('lang_thereare', sprintf(_MD_TDMDOWNLOADS_SEARCH_THEREARE, $downloads_Handler->getCount($criteria_2))); |
||
219 | $xoopsTpl->assign('pagenav', $pagenav); |
||
220 | $keywords = ''; |
||
221 | foreach (array_keys($tdmdownloads_arr) as $i) { |
||
222 | $tdmdownloads_tab['lid'] = $tdmdownloads_arr[$i]->getVar('lid'); |
||
223 | $tdmdownloads_tab['cid'] = $tdmdownloads_arr[$i]->getVar('cid'); |
||
224 | $tdmdownloads_tab['title'] = $tdmdownloads_arr[$i]->getVar('title'); |
||
225 | $tdmdownloads_tab['cat'] = $tdmdownloads_arr[$i]->getVar('cat_title'); |
||
226 | $tdmdownloads_tab['imgurl'] = $uploadurl . $tdmdownloads_arr[$i]->getVar('cat_imgurl'); |
||
227 | $tdmdownloads_tab['date'] = formatTimeStamp($tdmdownloads_arr[$i]->getVar('date'), 'd/m/Y'); |
||
228 | $tdmdownloads_tab['rating'] = number_format($tdmdownloads_arr[$i]->getVar('rating'), 0); |
||
229 | $tdmdownloads_tab['hits'] = $tdmdownloads_arr[$i]->getVar('hits'); |
||
230 | $contenu = ''; |
||
231 | foreach (array_keys($downloads_field) as $j) { |
||
232 | if ($downloads_field[$j]->getVar('status_def') == 1) { |
||
233 | if ($downloads_field[$j]->getVar('fid') == 1) { |
||
234 | //page d'accueil |
||
235 | $contenu = $tdmdownloads_arr[$i]->getVar('homepage'); |
||
236 | } |
||
237 | if ($downloads_field[$j]->getVar('fid') == 2) { |
||
238 | //version |
||
239 | $contenu = $tdmdownloads_arr[$i]->getVar('version'); |
||
240 | } |
||
241 | if ($downloads_field[$j]->getVar('fid') == 3) { |
||
242 | //taille du fichier |
||
243 | //mb $contenu = trans_size($tdmdownloads_arr[$i]->getVar('size')); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
244 | $contenu = $tdmdownloads_arr[$i]->getVar('size'); |
||
245 | } |
||
246 | if ($downloads_field[$j]->getVar('fid') == 4) { |
||
247 | //plateforme |
||
248 | $contenu = $tdmdownloads_arr[$i]->getVar('platform'); |
||
249 | } |
||
250 | } else { |
||
251 | $criteria = new CriteriaCompo(); |
||
252 | $criteria->add(new Criteria('lid', $tdmdownloads_arr[$i]->getVar('lid'))); |
||
253 | $criteria->add(new Criteria('fid', $downloads_field[$j]->getVar('fid'))); |
||
254 | $downloadsfielddata = $downloadsfielddata_Handler->getall($criteria); |
||
255 | if (count($downloadsfielddata) > 0) { |
||
256 | foreach (array_keys($downloadsfielddata) as $k) { |
||
257 | $contenu = $downloadsfielddata[$k]->getVar('data', 'n'); |
||
258 | } |
||
259 | } else { |
||
260 | $contenu = ''; |
||
261 | } |
||
262 | } |
||
263 | $tdmdownloads_tab['fielddata'][$j] = $contenu; |
||
264 | unset($contenu); |
||
265 | |||
266 | } |
||
267 | $xoopsTpl->clear_assign('downloads'); |
||
268 | $xoopsTpl->append('downloads', $tdmdownloads_tab); |
||
269 | |||
270 | $keywords .= $tdmdownloads_arr[$i]->getVar('title') . ','; |
||
271 | } |
||
272 | |||
273 | $xoopsTpl->assign('searchForm', $form->render()); |
||
274 | // r�f�rencement |
||
275 | // titre de la page |
||
276 | $titre = _MD_TDMDOWNLOADS_SEARCH_PAGETITLE . ' - ' . $xoopsModule->name(); |
||
277 | $xoopsTpl->assign('xoops_pagetitle', $titre); |
||
278 | //description |
||
279 | $xoTheme->addMeta('meta', 'description', strip_tags($xoopsModule->name())); |
||
280 | //keywords |
||
281 | $keywords = substr($keywords, 0, -1); |
||
282 | $xoTheme->addMeta('meta', 'keywords', strip_tags($keywords)); |
||
283 | |||
284 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
285 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.