Completed
Branch develop (0b02b4)
by
unknown
23:29
created
htdocs/admin/remotestore/class/externalModules.class.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
 		$this->url       = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace';
140 140
 
141 141
 		// For dolistore modules
142
-		$this->dolistore_api_url = getDolGlobalString('MAIN_MODULE_DOLISTORE_API_SRV', 'https://www.dolistore.com/api/');	// 'https://www.dolistore.com/api/', 'https://admin2.dolibarr.org/api/index.php/marketplace/'
142
+		$this->dolistore_api_url = getDolGlobalString('MAIN_MODULE_DOLISTORE_API_SRV', 'https://www.dolistore.com/api/'); // 'https://www.dolistore.com/api/', 'https://admin2.dolibarr.org/api/index.php/marketplace/'
143 143
 		$this->dolistore_api_key = getDolGlobalString('MAIN_MODULE_DOLISTORE_API_KEY', 'dolistorepublicapi');
144
-		$this->shop_url  = getDolGlobalString('MAIN_MODULE_DOLISTORE_SHOP_URL', 'https://www.dolistore.com');
144
+		$this->shop_url = getDolGlobalString('MAIN_MODULE_DOLISTORE_SHOP_URL', 'https://www.dolistore.com');
145 145
 
146 146
 		// For community modules
147 147
 		$this->file_source_url = "https://raw.githubusercontent.com/Dolibarr/dolibarr-community-modules/refs/heads/main/index.yaml";
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 			$httpheader[] = 'Authorization: Basic '.base64_encode($basicAuthLogin.':'.$basicAuthPassword);
205 205
 		}
206 206
 
207
-		$url = $this->dolistore_api_url . (preg_match('/\/$/', $this->dolistore_api_url) ? '' : '/') . $resource;
207
+		$url = $this->dolistore_api_url.(preg_match('/\/$/', $this->dolistore_api_url) ? '' : '/').$resource;
208 208
 
209 209
 		$options['apikey'] = $this->dolistore_api_key;
210 210
 
211 211
 		if ($options) {
212
-			$url .= '?' . http_build_query($options);
212
+			$url .= '?'.http_build_query($options);
213 213
 		}
214 214
 
215 215
 		$url .= (preg_match('/\?/', $url) ? '&' : '?').'apikey='.$this->dolistore_api_key;
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 		$modules = array();
238 238
 
239 239
 		if (!empty($this->cache_file) && file_exists($this->cache_file)) {
240
-			dol_syslog(__METHOD__ . " - Loading cache file: " . $this->cache_file, LOG_DEBUG);
240
+			dol_syslog(__METHOD__." - Loading cache file: ".$this->cache_file, LOG_DEBUG);
241 241
 
242 242
 			$content = file_get_contents($this->cache_file);
243 243
 			if ($content !== false) {
244 244
 				$modules = $this->readYaml($content);
245 245
 			} else {
246
-				dol_syslog(__METHOD__ . " - Error reading cache file", LOG_ERR);
246
+				dol_syslog(__METHOD__." - Error reading cache file", LOG_ERR);
247 247
 			}
248 248
 		}
249 249
 
@@ -271,20 +271,20 @@  discard block
 block discarded – undo
271 271
 		if (isset($resCategories['response']) && is_array($resCategories['response'])) {
272 272
 			$organized_tree = $resCategories['response'];
273 273
 		} else {
274
-			return $html ;
274
+			return $html;
275 275
 		}
276 276
 
277 277
 		$html = '';
278 278
 		foreach ($organized_tree as $key => $value) {
279 279
 			if ($value['label'] != "Versions" && $value['label'] != "Specials") {
280
-				$html .= '<li' . ($current == $value['rowid'] ? ' class="active"' : '') . '>';
281
-				$html .= '<a href="?mode=marketplace&categorie=' . $value['rowid'] . '">' . $value['label'] . '</a>';
280
+				$html .= '<li'.($current == $value['rowid'] ? ' class="active"' : '').'>';
281
+				$html .= '<a href="?mode=marketplace&categorie='.$value['rowid'].'">'.$value['label'].'</a>';
282 282
 				if (isset($value['children'])) {
283 283
 					$html .= '<ul>';
284 284
 					usort($value['children'], $this->buildSorter('position'));
285 285
 					foreach ($value['children'] as $key_children => $value_children) {
286
-						$html .= '<li' . ($current == $value_children['rowid'] ? ' class="active"' : '') . '>';
287
-						$html .= '<a href="?mode=marketplace&categorie=' . $value_children['rowid'] . '" title="' . dol_escape_htmltag(strip_tags($value_children['description'])) . '">' . $value_children['label'] . '</a>';
286
+						$html .= '<li'.($current == $value_children['rowid'] ? ' class="active"' : '').'>';
287
+						$html .= '<a href="?mode=marketplace&categorie='.$value_children['rowid'].'" title="'.dol_escape_htmltag(strip_tags($value_children['description'])).'">'.$value_children['label'].'</a>';
288 288
 						$html .= '</li>';
289 289
 					}
290 290
 					$html .= '</ul>';
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 
308 308
 		$html       = "";
309 309
 		$last_month = dol_now() - (30 * 24 * 60 * 60);
310
-		$dolibarrversiontouse = DOL_VERSION;	// full string with version
310
+		$dolibarrversiontouse = DOL_VERSION; // full string with version
311 311
 
312 312
 		$this->products = array();
313 313
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		$this->no_page  = $options['no_page'] ?? 1;
317 317
 		$this->search    = $options['search'] ?? '';
318 318
 
319
-		$this->per_page = 11;	// We fix number of products per page to 11
319
+		$this->per_page = 11; // We fix number of products per page to 11
320 320
 
321 321
 		// Length of $search must be at least 2 characters
322 322
 		if (!empty($this->search) && strlen(str_replace(' ', '', (string) $this->search)) < 2) {
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 		$fileProducts = array();
358 358
 		$fileProductsTotal = 0;
359 359
 		if (!empty($this->githubFileStatus) && getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_COMMUNITY')) {
360
-			$fileProducts = $this->fetchModulesFromFile($data);			// Return an array with all modules from the cache filecontent in $data
360
+			$fileProducts = $this->fetchModulesFromFile($data); // Return an array with all modules from the cache filecontent in $data
361 361
 
362 362
 			$fileProducts = $this->adaptData($fileProducts, 'githubcommunity');
363 363
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 				if ($product['source'] === 'githubcommunity') {
411 411
 					$download_link = '<a class="paddingleft paddingright" target="_blank" href="'.$product["link"].'"><img width="32" src="'.DOL_URL_ROOT.'/admin/remotestore/img/follow.png" /></a>';
412 412
 					if (!empty($product['direct-download']) && $product['direct-download'] == 'yes') {
413
-						$urldownload = $product["dolistore-download"];		// In a future, we will have the download to the zip file
413
+						$urldownload = $product["dolistore-download"]; // In a future, we will have the download to the zip file
414 414
 						$reg = array();
415 415
 						if (preg_match('/https:.*\?id=(\d+)$/', $urldownload, $reg)) {
416 416
 							$urldownload = 'https://www.dolistore.com/_service_download.php?t=free&p='.$reg[1];
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 				}
421 421
 
422 422
 				if ($product['source'] === 'dolistore') {
423
-					$urldownload = 'https://www.dolistore.com/_service_download.php?t=free&p=' . $product['id'];
423
+					$urldownload = 'https://www.dolistore.com/_service_download.php?t=free&p='.$product['id'];
424 424
 					$download_link = '<a class="paddingleft paddingright" target="_blank" href="'.$this->shop_url.'/product.php?id='.((int) $product["id"]).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/remotestore/img/follow.png" /></a>';
425 425
 					$download_link .= '<a class="paddingleft paddingright" target="_blank" href="'.$urldownload.'" rel="noopener noreferrer"><img width="32" src="'.DOL_URL_ROOT.'/admin/remotestore/img/Download-128.png" /></a>';
426 426
 				}
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 			// Output the line
474 474
 			$html .= '<tr class="app oddeven nohover '.dol_escape_htmltag($compatible).'">';
475 475
 			$html .= '<td class="center width150"><div class="newAppParent">';
476
-			$html .= $newapp.$images;	// No dol_escape_htmltag, it is already escape html
476
+			$html .= $newapp.$images; // No dol_escape_htmltag, it is already escape html
477 477
 			$html .= '</div></td>';
478 478
 			$html .= '<td class="margeCote"><h2 class="appTitle">';
479 479
 			$html .= dol_escape_htmltag(dol_string_nohtmltag($product["label"]));
480 480
 			$html .= '<br><small>';
481
-			$html .= $version;			// No dol_escape_htmltag, it is already escape html
481
+			$html .= $version; // No dol_escape_htmltag, it is already escape html
482 482
 			$html .= '</small></h2>';
483 483
 			$html .= '<small> ';
484 484
 			if (empty($product['tms'])) {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 
512 512
 		$this->numberOfProducts = count($this->products);
513 513
 
514
-		return $html ;
514
+		return $html;
515 515
 	}
516 516
 
517 517
 	/**
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		 * @param array<string, mixed> $b
529 529
 		 * @return int
530 530
 		 */
531
-		function (array $a, array $b) use ($key) {
531
+		function(array $a, array $b) use ($key) {
532 532
 			$valA = isset($a[$key]) && is_scalar($a[$key]) ? (string) $a[$key] : '';
533 533
 			$valB = isset($b[$key]) && is_scalar($b[$key]) ? (string) $b[$key] : '';
534 534
 
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 				$pagelist .= '<li class="pagination">';
688 688
 				$pagelist .= '<label for="page_input">Page </label>';
689 689
 				if ($this->categorie != 0) {
690
-					$pagelist .= '<input type="hidden" name="categorie" value="' . $this->categorie . '">';
690
+					$pagelist .= '<input type="hidden" name="categorie" value="'.$this->categorie.'">';
691 691
 				}
692 692
 				$pagelist .= '<input type="text" id="page_input" name="no_page" value="'.($page).'" min="1" max="'.$nbpages.'" class="width40 page_input" oninput="if(this.value > '.$nbpages.') this.value='.$nbpages.'">';
693 693
 				$pagelist .= ' / '.$nbpages;
@@ -737,12 +737,12 @@  discard block
 block discarded – undo
737 737
 		}
738 738
 
739 739
 		// Get the predefined error message or use a default one
740
-		$error_message = $error_messages[$request['status_code']] ?? 'Unexpected HTTP status: ' . $request['status_code'];
740
+		$error_message = $error_messages[$request['status_code']] ?? 'Unexpected HTTP status: '.$request['status_code'];
741 741
 
742 742
 		// Append error details if available
743 743
 		if (!empty($request['response']) && isset($request['response']['errors']) && is_array($request['response']['errors'])) {
744 744
 			foreach ($request['response']['errors'] as $error) {
745
-				$error_message .= ' - (Code ' . $error['code'] . '): ' . $error['message'];
745
+				$error_message .= ' - (Code '.$error['code'].'): '.$error['message'];
746 746
 			}
747 747
 		}
748 748
 
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		if (!file_exists($cache_file) || filemtime($cache_file) < (dol_now() - $cache_time)) {
772 772
 			// We get remote url
773 773
 			$addheaders = array();
774
-			$result = getURLContent($file_source_url, 'GET', '', 1, $addheaders);	// TODO Force timeout to 5 s on both connect and response.
774
+			$result = getURLContent($file_source_url, 'GET', '', 1, $addheaders); // TODO Force timeout to 5 s on both connect and response.
775 775
 			if (!empty($result) && $result['http_code'] == 200) {
776 776
 				$yaml = $result['content'];
777 777
 				file_put_contents($cache_file, $yaml);
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 			 *
981 981
 			 * @return int
982 982
 			 */
983
-			static function ($a, $b) {
983
+			static function($a, $b) {
984 984
 				return strtotime($b['datec'] ?? '0') - strtotime($a['datec'] ?? '0');
985 985
 			}
986 986
 		);
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 				 *
996 996
 				 * @return bool
997 997
 				 */
998
-				static function ($package) use ($options) {
998
+				static function($package) use ($options) {
999 999
 					return stripos($package['label'], $options['search']) !== false || stripos($package['description'], $options['search']) !== false;
1000 1000
 				}
1001 1001
 			);
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 				 *
1012 1012
 				 * @return bool
1013 1013
 				 */
1014
-				static function ($package) use ($options) {
1014
+				static function($package) use ($options) {
1015 1015
 					return in_array($options['categorieid'], $package['category']);
1016 1016
 				}
1017 1017
 			);
Please login to merge, or discard this patch.