Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F108037117
PhragmentBrowseController.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
Sun, Apr 13, 11:31
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Apr 15, 11:31 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25524878
Attached To
rPH Phabricator
PhragmentBrowseController.php
View Options
<?php
final
class
PhragmentBrowseController
extends
PhragmentController
{
private
$dblob
;
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
=
nonempty
(
last
(
$parents
),
null
);
$path
=
''
;
if
(
$current
!==
null
)
{
$path
=
$current
->
getPath
();
}
$crumbs
=
$this
->
buildApplicationCrumbsWithPath
(
$parents
);
$crumbs
->
addAction
(
id
(
new
PHUIListItemView
())
->
setName
(
pht
(
'Create Fragment'
))
->
setHref
(
$this
->
getApplicationURI
(
'/create/'
.
$path
))
->
setIcon
(
'create'
));
$current_box
=
$this
->
createCurrentFragmentView
(
$current
,
false
);
$list
=
id
(
new
PHUIObjectItemListView
())
->
setUser
(
$viewer
);
$fragments
=
null
;
if
(
$current
===
null
)
{
// Find all root fragments.
$fragments
=
id
(
new
PhragmentFragmentQuery
())
->
setViewer
(
$this
->
getRequest
()->
getUser
())
->
needLatestVersion
(
true
)
->
withDepths
(
array
(
1
))
->
execute
();
}
else
{
// Find all child fragments.
$fragments
=
id
(
new
PhragmentFragmentQuery
())
->
setViewer
(
$this
->
getRequest
()->
getUser
())
->
needLatestVersion
(
true
)
->
withLeadingPath
(
$current
->
getPath
().
'/'
)
->
withDepths
(
array
(
$current
->
getDepth
()
+
1
))
->
execute
();
}
foreach
(
$fragments
as
$fragment
)
{
$item
=
id
(
new
PHUIObjectItemView
());
$item
->
setHeader
(
$fragment
->
getName
());
$item
->
setHref
(
$this
->
getApplicationURI
(
'/browse/'
.
$fragment
->
getPath
()));
if
(!
$fragment
->
isDirectory
())
{
$item
->
addAttribute
(
pht
(
'Last Updated %s'
,
phabricator_datetime
(
$fragment
->
getLatestVersion
()->
getDateCreated
(),
$viewer
)));
$item
->
addAttribute
(
pht
(
'Latest Version %s'
,
$fragment
->
getLatestVersion
()->
getSequence
()));
}
else
{
$item
->
addAttribute
(
'Directory'
);
}
$list
->
addItem
(
$item
);
}
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$current_box
,
$list
),
array
(
'title'
=>
pht
(
'Browse Fragments'
),
'device'
=>
true
));
}
}
Event Timeline
Log In to Comment