Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96151698
PhragmentHistoryController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 23, 04:54
Size
3 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 04:54 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23125785
Attached To
rPH Phabricator
PhragmentHistoryController.php
View Options
<?php
final
class
PhragmentHistoryController
extends
PhragmentController
{
private
$dblob
;
public
function
shouldAllowPublic
()
{
return
true
;
}
public
function
willProcessRequest
(
array
$data
)
{
$this
->
dblob
=
idx
(
$data
,
'dblob'
,
''
);
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$parents
=
$this
->
loadParentFragments
(
$this
->
dblob
);
if
(
$parents
===
null
)
{
return
new
Aphront404Response
();
}
$current
=
idx
(
$parents
,
count
(
$parents
)
-
1
,
null
);
$path
=
$current
->
getPath
();
$crumbs
=
$this
->
buildApplicationCrumbsWithPath
(
$parents
);
if
(
$this
->
hasApplicationCapability
(
PhragmentCapabilityCanCreate
::
CAPABILITY
))
{
$crumbs
->
addAction
(
id
(
new
PHUIListItemView
())
->
setName
(
pht
(
'Create Fragment'
))
->
setHref
(
$this
->
getApplicationURI
(
'/create/'
.
$path
))
->
setIcon
(
'fa-plus-square'
));
}
$current_box
=
$this
->
createCurrentFragmentView
(
$current
,
true
);
$versions
=
id
(
new
PhragmentFragmentVersionQuery
())
->
setViewer
(
$viewer
)
->
withFragmentPHIDs
(
array
(
$current
->
getPHID
()))
->
execute
();
$list
=
id
(
new
PHUIObjectItemListView
())
->
setUser
(
$viewer
);
$file_phids
=
mpull
(
$versions
,
'getFilePHID'
);
$files
=
id
(
new
PhabricatorFileQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
$file_phids
)
->
execute
();
$files
=
mpull
(
$files
,
null
,
'getPHID'
);
$can_edit
=
PhabricatorPolicyFilter
::
hasCapability
(
$viewer
,
$current
,
PhabricatorPolicyCapability
::
CAN_EDIT
);
$first
=
true
;
foreach
(
$versions
as
$version
)
{
$item
=
id
(
new
PHUIObjectItemView
());
$item
->
setHeader
(
'Version '
.
$version
->
getSequence
());
$item
->
setHref
(
$version
->
getURI
());
$item
->
addAttribute
(
phabricator_datetime
(
$version
->
getDateCreated
(),
$viewer
));
if
(
$version
->
getFilePHID
()
===
null
)
{
$item
->
setDisabled
(
true
);
$item
->
addAttribute
(
'Deletion'
);
}
if
(!
$first
&&
$can_edit
)
{
$item
->
addAction
(
id
(
new
PHUIListItemView
())
->
setIcon
(
'fa-refresh'
)
->
setRenderNameAsTooltip
(
true
)
->
setWorkflow
(
true
)
->
setName
(
pht
(
'Revert to Here'
))
->
setHref
(
$this
->
getApplicationURI
(
'revert/'
.
$version
->
getID
().
'/'
.
$current
->
getPath
())));
}
$disabled
=
!
isset
(
$files
[
$version
->
getFilePHID
()]);
$action
=
id
(
new
PHUIListItemView
())
->
setIcon
(
'fa-download'
)
->
setDisabled
(
$disabled
||
!
$this
->
isCorrectlyConfigured
())
->
setRenderNameAsTooltip
(
true
)
->
setName
(
pht
(
'Download'
));
if
(!
$disabled
&&
$this
->
isCorrectlyConfigured
())
{
$action
->
setHref
(
$files
[
$version
->
getFilePHID
()]
->
getDownloadURI
(
$version
->
getURI
()));
}
$item
->
addAction
(
$action
);
$list
->
addItem
(
$item
);
$first
=
false
;
}
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$this
->
renderConfigurationWarningIfRequired
(),
$current_box
,
$list
),
array
(
'title'
=>
pht
(
'Fragment History'
),
));
}
}
Event Timeline
Log In to Comment