Skip to content

Commit

Permalink
~ Better download URLs in XML update streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas K. Dionysopoulos committed Jul 22, 2019
1 parent 0757f7d commit b0ec6ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 4.2.2

**Other changes**

* Better download URLs in XML update streams

**Bug fixes**

* [HIGH] Cannot change the update stream of an item through the UI
Expand Down
35 changes: 28 additions & 7 deletions component/frontend/View/Update/tmpl/stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

use Akeeba\ReleaseSystem\Site\Helper\Router;
use Akeeba\ReleaseSystem\Site\Helper\Filter;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Factory;

$rootURL = rtrim(JURI::base(), '/');
$subpathURL = JURI::base(true);
Expand Down Expand Up @@ -60,8 +62,8 @@
JFactory::getApplication()->setHeader('X-Akeeba-Expire-After', 300);

require_once JPATH_SITE . '/components/com_ars/router.php';
ComArsRouter::$routeRaw = false;
ComArsRouter::$routeHtml = false;
//ComArsRouter::$routeRaw = false;
//ComArsRouter::$routeHtml = false;

$jVersion = new JVersion;

Expand Down Expand Up @@ -115,12 +117,27 @@
}
else
{
$format = 'UNSUPPORTED';
$fileNameParts = explode('.', $basename);
$format = array_pop($fileNameParts);
}

if (($format != 'UNSUPPORTED') && ($item->itemtype == 'file'))
if ($item->itemtype == 'file')
{
$downloadURL .= '&dummy=my.' . $format;
$dlUri = Uri::getInstance($downloadURL);

if (Factory::getConfig()->get('sef_suffix', 0) == 1)
{
$pathParts = explode('.', $dlUri->getPath());

if ((count($pathParts) > 1) && (array_pop($pathParts) == 'raw'))
{
$dlUri->setPath(implode('.', $pathParts));
}
}

$dlUri->setVar('format', 'raw');
$dlUri->setVar('dummy', 'my.' . $format);
$downloadURL = $dlUri->toString();
}

if (!empty($item->environments) && is_array($item->environments))
Expand Down Expand Up @@ -194,10 +211,14 @@
<type><?php echo $streamTypeMap[ $item->type ]; ?></type>
<version><?php echo $item->version ?></version>
<infourl
title="<?php echo $item->cat_title . ' ' . $item->version ?>"><?php echo $rootURL . Router::_('index.php?option=com_ars&view=Items&release_id=' . $item->release_id) ?></infourl>
title="<?php echo $item->cat_title . ' ' . $item->version ?>">
<![CDATA[<?php echo $rootURL . Router::_('index.php?option=com_ars&view=Items&release_id=' . $item->release_id) ?>
]]>
</infourl>
<downloads>
<downloadurl type="full"
format="<?php echo $format ?>"><?php echo $downloadURL ?></downloadurl>
format="<?php echo $format ?>"><![CDATA[<?php echo $downloadURL ?>]]>
</downloadurl>
</downloads>
<tags>
<tag><?php echo $item->maturity ?></tag>
Expand Down

0 comments on commit b0ec6ca

Please sign in to comment.