Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F8736706
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Paladox
Jul 13 2017, 7:58 PM
2017-07-13 19:58:10 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
<?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
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4774892
Default Alt Text
(1 KB)
Attached To
Mode
P5745 (An Untitled Masterwork)
Attached
Detach File
Event Timeline
Log In to Comment