Skip to content

Commit 54d0813

Browse files
author
Till Brehm
committed
Fixed: FS#2962 - APS package update misses latest Joomla version
1 parent 3225c76 commit 54d0813

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

interface/lib/classes/aps_crawler.inc.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,26 @@ public function startCrawler()
288288
$sxe = new SimpleXMLElement($xml);
289289
$namespaces = $sxe->getDocNamespaces(true);
290290
foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url);
291+
292+
//Find highest version
293+
$app_version = "0.0.0";
294+
$entry_pos = 1;
295+
for ($p = 1; ; $p++) {
296+
$app_version_tmp = parent::getXPathValue($sxe, 'entry[position()=' . $p . ']/a:version');
297+
if (strlen($app_version_tmp) < 1) break;
298+
if (version_compare($app_version_tmp, $app_version) >= 0) {
299+
$app_version = $app_version_tmp;
300+
$entry_pos = $p;
301+
}
302+
}
291303

292304
// Fetching values of interest
293-
$app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name');
294-
$app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version');
295-
$app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release');
305+
//$app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name');
306+
//$app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version');
307+
//$app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release');
308+
$app_name = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:name");
309+
$app_version = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:version");
310+
$app_release = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:release");
296311

297312
// Find out a (possibly) existing package version
298313
$ex_ver = '';
@@ -315,9 +330,12 @@ public function startCrawler()
315330
// Check if we already have an old version of this app
316331
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) $apps_updated++;
317332

318-
$app_dl = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@href");
319-
$app_filesize = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@length");
320-
$app_metafile = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='meta']/@href");
333+
//$app_dl = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@href");
334+
//$app_filesize = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@length");
335+
//$app_metafile = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='meta']/@href");
336+
$app_dl = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@href");
337+
$app_filesize = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@length");
338+
$app_metafile = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='meta']/@href");
321339

322340
//$this->app_download_url_list[$app_name.'-'.$new_ver.'.app.zip'] = $app_dl;
323341
// Skip ASP.net packages because they can't be used at all
@@ -365,7 +383,8 @@ public function startCrawler()
365383
}
366384

367385
// Download package license
368-
$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href");
386+
//$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href");
387+
$license = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='eula']/@href");
369388
if($license != '')
370389
{
371390
$local_license = $local_intf_folder.'LICENSE';
@@ -379,7 +398,8 @@ public function startCrawler()
379398
}
380399

381400
// Download package icon
382-
$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href");
401+
//$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href");
402+
$icon = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='icon']/@href");
383403
if($icon != '')
384404
{
385405
$local_icon = $local_intf_folder.basename($icon);
@@ -393,7 +413,8 @@ public function startCrawler()
393413
}
394414

395415
// Download available screenshots
396-
$screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true);
416+
//$screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true);
417+
$screenshots = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='screenshot']", true);
397418
if(!empty($screenshots))
398419
{
399420
foreach($screenshots as $screen)

0 commit comments

Comments
 (0)