Skip to content

Commit

Permalink
Homepage|Build Repository: Renamed Package graph property download_ur…
Browse files Browse the repository at this point in the history
…i as direct_download_uri

The old name is now reserved for use with the download redirection
URI used on the homepage itself.
  • Loading branch information
danij-deng committed Mar 13, 2012
1 parent bb2fe17 commit 1aca03a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
16 changes: 8 additions & 8 deletions web/plugins/buildrepository/buildrepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ private function &choosePackage($platformId=PID_ANY, $title="Doomsday",
if($pack->platformId() !== $platformId) continue;
if($matchTitle && strcmp($pack->title(), $title)) continue;
if($unstable != ($pack instanceof AbstractUnstablePackage)) continue;
if($downloadable != ($pack instanceof iDownloadable && $pack->hasDownloadUri())) continue;
if($downloadable != ($pack instanceof iDownloadable && $pack->hasDirectDownloadUri())) continue;

// Found something suitable.
return $pack;
Expand Down Expand Up @@ -948,7 +948,7 @@ private function outputPackageList(&$packages, $notThisPack=NULL,
// Filtered out?
if($pack === $notThisPack) continue;
if($unstable != -1 && (boolean)$unstable != ($pack instanceof AbstractUnstablePackage)) continue;
if($downloadable != -1 && (boolean)$downloadable != ($pack instanceof iDownloadable && $pack->hasDownloadUri())) continue;
if($downloadable != -1 && (boolean)$downloadable != ($pack instanceof iDownloadable && $pack->hasDirectDownloadUri())) continue;
if(!is_null($chosenPlatformId) && $pack->platformId() === $chosenPlatformId) continue;

// Begin the list?
Expand Down Expand Up @@ -992,12 +992,12 @@ private function outputPackageRedirect(&$pack)
$FrontController->beginPage($pageTitle);

// Output the redirect directive.
?><meta http-equiv="REFRESH" content="2;url=<?php echo $pack->downloadUri(); ?>"><?php
?><meta http-equiv="REFRESH" content="2;url=<?php echo $pack->directDownloadUri(); ?>"><?php

// Generate page content.
?><div id="builds"><?php

?><p>Redirecting to the download for <em><?php echo htmlspecialchars($pack->composeFullTitle()); ?></em>. Your package should begin to download automatically within a few seconds, if not please use this <a href="<?php echo $pack->downloadUri(); ?>" title="<?php echo ('Download '. $pack->composeFullTitle()); ?>">direct link</a> instead.</p><?php
?><p>Redirecting to the download for <em><?php echo htmlspecialchars($pack->composeFullTitle()); ?></em>. Your package should begin to download automatically within a few seconds, if not please use this <a href="<?php echo $pack->directDownloadUri(); ?>" title="<?php echo ('Download '. $pack->composeFullTitle()); ?>">direct link</a> instead.</p><?php

?><p>Not what you wanted? Here are some alternatives:</p><?php

Expand Down Expand Up @@ -1081,7 +1081,7 @@ private function countInstallablePackages(&$build)
{
foreach($build->packages as &$pack)
{
if($pack instanceof iDownloadable && $pack->hasDownloadUri())
if($pack instanceof iDownloadable && $pack->hasDirectDownloadUri())
{
$count++;
}
Expand Down Expand Up @@ -1174,7 +1174,7 @@ public function execute($args=NULL)
}

// Determine issue level (think defcon).
if($errors > 0 || !$pack->hasDownloadUri())
if($errors > 0 || !$pack->hasDirectDownloadUri())
$issueLevel = 'major';
else if($warnings > 0)
$issueLevel = 'minor';
Expand All @@ -1187,9 +1187,9 @@ public function execute($args=NULL)
<td><?php

$packTitle = $pack->composeFullTitle(true/*include version*/, false/*do not include the platform name*/, false/*do not include build Id*/);
if($pack instanceof iDownloadable && $pack->hasDownloadUri())
if($pack instanceof iDownloadable && $pack->hasDirectDownloadUri())
{
?><a href="<?php echo $pack->downloadUri(); ?>" title="Download <?php echo $pack->composeFullTitle(); ?>"><?php echo $packTitle; ?></a><?php
?><a href="<?php echo $pack->directDownloadUri(); ?>" title="Download <?php echo $pack->composeFullTitle(); ?>"><?php echo $packTitle; ?></a><?php
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions web/plugins/buildrepository/downloadable.interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

interface iDownloadable
{
public function &downloadUri();
public function hasDownloadUri();
public function &directDownloadUri();
public function hasDirectDownloadUri();
public function genDownloadBadge();
}
20 changes: 10 additions & 10 deletions web/plugins/buildrepository/packagefactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public static function newNullPackage()
return self::$nullPackage;
}

public static function newDistribution($platformId, $name, $version, $downloadUrl)
public static function newDistribution($platformId, $name, $version, $directDownloadUrl)
{
return new DistributionPackage($platformId, $name, $version, $downloadUrl);
return new DistributionPackage($platformId, $name, $version, $directDownloadUrl);
}

public static function newUnstableDistribution($platformId, $name, $version, $downloadUrl)
public static function newUnstableDistribution($platformId, $name, $version, $directDownloadUrl)
{
return new UnstableDistributionPackage($platformId, $name, $version, $downloadUrl);
return new UnstableDistributionPackage($platformId, $name, $version, $directDownloadUrl);
}

/**
Expand All @@ -66,7 +66,7 @@ public static function newFromSimpleXMLElement(&$log_pack, $releaseType='unstabl
throw new Exception('Received invalid log_pack');

$platformId = BuildRepositoryPlugin::parsePlatformId(clean_text($log_pack->platform));
$cleanDownloadUri = safe_url($log_pack->downloadUri);
$cleanDirectDownloadUri = safe_url($log_pack->downloadUri);
$compileLogUri = safe_url($log_pack->compileLogUri);

if(!empty($log_pack->name))
Expand All @@ -76,7 +76,7 @@ public static function newFromSimpleXMLElement(&$log_pack, $releaseType='unstabl
else
{
// We must resort to extracting the name from download Uri.
$filename = basename(substr($cleanDownloadUri, 0, -9/*/download*/));
$filename = basename(substr($cleanDirectDownloadUri, 0, -9/*/download*/));
$filename = preg_replace(array('/-/','/_/'), ' ', $filename);

$words = explode(' ', substr($filename, 0, strrpos($filename, '.')));
Expand All @@ -101,27 +101,27 @@ public static function newFromSimpleXMLElement(&$log_pack, $releaseType='unstabl
case 'plugin':
if($releaseType === RT_STABLE)
{
$pack = new PluginPackage($platformId, $name, $version, $cleanDownloadUri,
$pack = new PluginPackage($platformId, $name, $version, $cleanDirectDownloadUri,
$compileLogUri, (integer)$log_pack->compileWarnCount,
(integer)$log_pack->compileErrorCount);
}
else
{
$pack = new UnstablePluginPackage($platformId, $name, $version, $cleanDownloadUri,
$pack = new UnstablePluginPackage($platformId, $name, $version, $cleanDirectDownloadUri,
$compileLogUri, (integer)$log_pack->compileWarnCount,
(integer)$log_pack->compileErrorCount);
}
break;
default:
if($releaseType === RT_STABLE)
{
$pack = new DistributionPackage($platformId, $name, $version, $cleanDownloadUri,
$pack = new DistributionPackage($platformId, $name, $version, $cleanDirectDownloadUri,
$compileLogUri, (integer)$log_pack->compileWarnCount,
(integer)$log_pack->compileErrorCount);
}
else
{
$pack = new UnstableDistributionPackage($platformId, $name, $version, $cleanDownloadUri,
$pack = new UnstableDistributionPackage($platformId, $name, $version, $cleanDirectDownloadUri,
$compileLogUri, (integer)$log_pack->compileWarnCount,
(integer)$log_pack->compileErrorCount);
}
Expand Down
24 changes: 12 additions & 12 deletions web/plugins/buildrepository/packages/abstractpackage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ abstract class AbstractPackage extends BasePackage implements iDownloadable
{
static protected $emptyString = '';

protected $downloadUri = NULL;
protected $directDownloadUri = NULL;

public function __construct($platformId=PID_ANY, $title=NULL, $version=NULL, $downloadUri=NULL)
public function __construct($platformId=PID_ANY, $title=NULL, $version=NULL, $directDownloadUri=NULL)
{
parent::__construct($platformId, $title, $version);

if(!is_null($downloadUri) && strlen($downloadUri) > 0)
$this->downloadUri = "$downloadUri";
if(!is_null($directDownloadUri) && strlen($directDownloadUri) > 0)
$this->directDownloadUri = "$directDownloadUri";
}

// Extends implementation in AbstractPackage.
Expand All @@ -49,32 +49,32 @@ public function populateGraphTemplate(&$tpl)
throw new Exception('Invalid template argument, array expected');

parent::populateGraphTemplate($tpl);
$tpl['download_uri'] = $this->downloadUri();
$tpl['direct_download_uri'] = $this->directDownloadUri();
}

// Implements iDownloadable
public function &downloadUri()
public function &directDownloadUri()
{
if(!$this->hasDownloadUri())
if(!$this->hasDirectDownloadUri())
{
return $emptyString;
}
return $this->downloadUri;
return $this->directDownloadUri;
}

// Implements iDownloadable
public function hasDownloadUri()
public function hasDirectDownloadUri()
{
return !is_null($this->downloadUri);
return !is_null($this->directDownloadUri);
}

// Implements iDownloadable
public function genDownloadBadge()
{
$fullTitle = $this->composeFullTitle();
if($this->hasDownloadUri())
if($this->hasDirectDownloadUri())
{
$html = '<a href="'. htmlspecialchars($this->downloadUri)
$html = '<a href="'. htmlspecialchars($this->directDownloadUri)
.'" title="'. ("Download $fullTitle")
.'">'. htmlspecialchars($fullTitle) .'</a>';
}
Expand Down

0 comments on commit 1aca03a

Please sign in to comment.