Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99055960
PhabricatorFileInfoController.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
Sat, Jan 18, 18:43
Size
4 KB
Mime Type
text/x-php
Expires
Mon, Jan 20, 18:43 (2 d)
Engine
blob
Format
Raw Data
Handle
23697116
Attached To
rPH Phabricator
PhabricatorFileInfoController.php
View Options
<?php
final
class
PhabricatorFileInfoController
extends
PhabricatorFileController
{
private
$phid
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
phid
=
$data
[
'phid'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$file
=
id
(
new
PhabricatorFileQuery
())
->
setViewer
(
$user
)
->
withPHIDs
(
array
(
$this
->
phid
))
->
executeOne
();
if
(!
$file
)
{
return
new
Aphront404Response
();
}
$this
->
loadHandles
(
array
(
$file
->
getAuthorPHID
()));
$phid
=
$file
->
getPHID
();
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addCrumb
(
id
(
new
PhabricatorCrumbView
())
->
setName
(
'F'
.
$file
->
getID
())
->
setHref
(
$this
->
getApplicationURI
(
"/info/{$phid}/"
)));
$header
=
id
(
new
PhabricatorHeaderView
())
->
setObjectName
(
'F'
.
$file
->
getID
())
->
setHeader
(
$file
->
getName
());
$ttl
=
$file
->
getTTL
();
if
(
$ttl
!==
null
)
{
$ttl_tag
=
id
(
new
PhabricatorTagView
())
->
setType
(
PhabricatorTagView
::
TYPE_OBJECT
)
->
setName
(
pht
(
"Temporary"
));
$header
->
addTag
(
$ttl_tag
);
}
$actions
=
$this
->
buildActionView
(
$file
);
$properties
=
$this
->
buildPropertyView
(
$file
);
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$header
,
$actions
,
$properties
,
),
array
(
'title'
=>
$file
->
getName
(),
'device'
=>
true
,
));
}
private
function
buildActionView
(
PhabricatorFile
$file
)
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$id
=
$file
->
getID
();
$view
=
id
(
new
PhabricatorActionListView
())
->
setUser
(
$user
)
->
setObject
(
$file
);
if
(
$file
->
isViewableInBrowser
())
{
$view
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'View File'
))
->
setIcon
(
'preview'
)
->
setHref
(
$file
->
getViewURI
()));
}
else
{
$view
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setUser
(
$user
)
->
setRenderAsForm
(
true
)
->
setDownload
(
true
)
->
setName
(
pht
(
'Download File'
))
->
setIcon
(
'download'
)
->
setHref
(
$file
->
getViewURI
()));
}
$view
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Delete File'
))
->
setIcon
(
'delete'
)
->
setHref
(
$this
->
getApplicationURI
(
"/delete/{$id}/"
))
->
setWorkflow
(
true
));
return
$view
;
}
private
function
buildPropertyView
(
PhabricatorFile
$file
)
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$view
=
id
(
new
PhabricatorPropertyListView
());
if
(
$file
->
getAuthorPHID
())
{
$view
->
addProperty
(
pht
(
'Author'
),
$this
->
getHandle
(
$file
->
getAuthorPHID
())->
renderLink
());
}
$view
->
addProperty
(
pht
(
'Created'
),
phabricator_datetime
(
$file
->
getDateCreated
(),
$user
));
$view
->
addProperty
(
pht
(
'Size'
),
phabricator_format_bytes
(
$file
->
getByteSize
()));
$view
->
addSectionHeader
(
pht
(
'Technical Details'
));
$view
->
addProperty
(
pht
(
'Mime Type'
),
$file
->
getMimeType
());
$view
->
addProperty
(
pht
(
'Engine'
),
$file
->
getStorageEngine
());
$view
->
addProperty
(
pht
(
'Format'
),
$file
->
getStorageFormat
());
$view
->
addProperty
(
pht
(
'Handle'
),
$file
->
getStorageHandle
());
$metadata
=
$file
->
getMetadata
();
if
(!
empty
(
$metadata
))
{
$view
->
addSectionHeader
(
pht
(
'Metadata'
));
foreach
(
$metadata
as
$key
=>
$value
)
{
$view
->
addProperty
(
PhabricatorFile
::
getMetadataName
(
$key
),
$value
);
}
}
if
(
$file
->
isViewableImage
())
{
// TODO: Clean this up after Pholio (dark backgrounds, standardization,
// etc.)
$image
=
phutil_tag
(
'img'
,
array
(
'src'
=>
$file
->
getViewURI
(),
'class'
=>
'phabricator-property-list-image'
,
));
$linked_image
=
phutil_tag
(
'a'
,
array
(
'href'
=>
$file
->
getViewURI
(),
),
$image
);
$view
->
addTextContent
(
$linked_image
);
}
return
$view
;
}
}
Event Timeline
Log In to Comment