Page MenuHomePhabricator
Authored By
Paladox
Jul 13 2017, 7:58 PM
Size
1 KB
Referenced Files
None
Subscribers
None
<?php
class CustomGithubDownloadLinks {
static function getMirrorURI($repo) {
$uris = $repo->getURIs();
foreach ($uris as $uri) {
if ($uri->getIsDisabled()) {
continue;
}
if ($uri->getEffectiveIoType() == PhabricatorRepositoryURI::IO_MIRROR &&
strpos($uri->getDisplayURI(), 'github') !== false) {
return $uri;
}
}
return false;
}
static function AddActionLinksToTop($repository, $identifier) {
global $github_download_zip_button, $github_download_tar_button;
$uri = self::getMirrorURI($repository);
if (!$uri) {
return;
}
$uri = $uri->getURI();
$github_download_zip_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('Download zip (from Github)'))
->setColor(PHUIButtonView::GREEN)
->setIcon('fa-download')
->setHref($uri.'/archive/'.$identifier.'.zip');
$github_download_tar_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('Download gz (from Github)'))
->setColor(PHUIButtonView::GREEN)
->setIcon('fa-download')
->setHref($uri.'/archive/'.$identifier.'.tar.gz');
}
static function addActionsToTop($drequest) {
$repository = $drequest->getRepository();
try {
if ($drequest->getSymbolicType() == 'tag') {
$download = $drequest->getSymbolicCommit();
} elseif ($drequest->getSymbolicType() == 'commit') {
$download = $drequest->getStableCommit();
} else {
$download = $drequest->getBranch();
}
} catch(Exception $e) {
return '';
}
return self::AddActionLinksToTop($repository, $download);
}
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4774892
Default Alt Text
(1 KB)

Event Timeline