Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2895561
DivinerBookController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
DivinerBookController.php
View Options
<?php
final
class
DivinerBookController
extends
DivinerController
{
private
$bookName
;
public
function
shouldAllowPublic
(
)
{
return
true
;
}
public
function
willProcessRequest
(
array
$data
)
{
$this
->
bookName
=
$data
[
'book'
]
;
}
public
function
processRequest
(
)
{
$request
=
$this
->
getRequest
(
)
;
$viewer
=
$request
->
getUser
(
)
;
$book
=
id
(
new
DivinerBookQuery
(
)
)
->
setViewer
(
$viewer
)
->
withNames
(
array
(
$this
->
bookName
)
)
->
executeOne
(
)
;
if
(
!
$book
)
{
return
new
Aphront404Response
(
)
;
}
$crumbs
=
$this
->
buildApplicationCrumbs
(
)
;
$crumbs
->
addTextCrumb
(
$book
->
getShortTitle
(
)
,
'/book/'
.
$book
->
getName
(
)
.
'/'
)
;
$header
=
id
(
new
PHUIHeaderView
(
)
)
->
setHeader
(
$book
->
getTitle
(
)
)
->
setUser
(
$viewer
)
->
setPolicyObject
(
$book
)
;
$document
=
new
PHUIDocumentView
(
)
;
$document
->
setHeader
(
$header
)
;
$properties
=
$this
->
buildPropertyList
(
$book
)
;
$atoms
=
id
(
new
DivinerAtomQuery
(
)
)
->
setViewer
(
$viewer
)
->
withBookPHIDs
(
array
(
$book
->
getPHID
(
)
)
)
->
execute
(
)
;
$atoms
=
msort
(
$atoms
,
'getSortKey'
)
;
$group_spec
=
$book
->
getConfig
(
'groups'
)
;
if
(
!
is_array
(
$group_spec
)
)
{
$group_spec
=
array
(
)
;
}
$groups
=
mgroup
(
$atoms
,
'getGroupName'
)
;
$groups
=
array_select_keys
(
$groups
,
array_keys
(
$group_spec
)
)
+
$groups
;
if
(
isset
(
$groups
[
''
]
)
)
{
$no_group
=
$groups
[
''
]
;
unset
(
$groups
[
''
]
)
;
$groups
[
''
]
=
$no_group
;
}
$out
=
array
(
)
;
foreach
(
$groups
as
$group
=>
$atoms
)
{
$group_name
=
$book
->
getGroupName
(
$group
)
;
$section
=
id
(
new
DivinerSectionView
(
)
)
->
setHeader
(
$group_name
)
;
$section
->
addContent
(
$this
->
renderAtomList
(
$atoms
)
)
;
$out
[
]
=
$section
;
}
$document
->
appendChild
(
$properties
)
;
$document
->
appendChild
(
$out
)
;
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$document
,
)
,
array
(
'title'
=>
$book
->
getTitle
(
)
,
'device'
=>
true
,
)
)
;
}
private
function
buildPropertyList
(
DivinerLiveBook
$book
)
{
$viewer
=
$this
->
getRequest
(
)
->
getUser
(
)
;
$view
=
id
(
new
PHUIPropertyListView
(
)
)
->
setUser
(
$viewer
)
;
$policies
=
PhabricatorPolicyQuery
::
renderPolicyDescriptions
(
$viewer
,
$book
)
;
$view
->
addProperty
(
pht
(
'Updated'
)
,
phabricator_datetime
(
$book
->
getDateModified
(
)
,
$viewer
)
)
;
$preface
=
$book
->
getPreface
(
)
;
if
(
strlen
(
$preface
)
)
{
$view
->
addTextContent
(
PhabricatorMarkupEngine
::
renderOneObject
(
id
(
new
PhabricatorMarkupOneOff
(
)
)
->
setContent
(
$preface
)
,
'default'
,
$viewer
)
)
;
}
return
$view
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 21:39 (6 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129033
Default Alt Text
DivinerBookController.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment