Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93298538
PhabricatorProjectWikiView.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
Wed, Nov 27, 17:41
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Nov 29, 17:41 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22610092
Attached To
rPH Phabricator
PhabricatorProjectWikiView.php
View Options
<?php
final
class
PhabricatorProjectWikiView
extends
PhabricatorProjectController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$project
=
id
(
new
PhabricatorProjectQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
needImages
(
true
)
->
executeOne
();
if
(!
$project
)
{
return
new
Aphront404Response
();
}
$this
->
setProject
(
$project
);
$title
=
pht
(
'Wiki pages'
);
$curtain
=
$this
->
buildCurtainView
(
$project
);
$query
=
id
(
new
PhrictionDocumentQuery
())
->
setViewer
(
$viewer
)
->
needContent
(
true
)
->
withStatuses
(
array
(
PhrictionDocumentStatus
::
STATUS_EXISTS
))
->
withSlugPrefix
(
PhabricatorProjectWikiCreate
::
getAllSlugs
(
$project
))
->
setOrder
(
PhrictionDocumentQuery
::
ORDER_HIERARCHY
)
->
execute
();
$wiki_list
=
new
PHUIObjectItemListView
();
foreach
(
$query
as
$w
){
$wiki_list
->
addItem
(
id
(
new
PHUIObjectItemView
())
->
setHeader
(
$w
->
getContent
()->
getTitle
())
->
addAttribute
(
$w
->
getSlug
())
->
setHref
(
$w
->
getSlugURI
(
$w
->
getSlug
())));
}
$nav
=
$this
->
getProfileMenu
();
$nav
->
selectFilter
(
PhabricatorProjectWikiProfileMenuItem
::
MENUITEM_WIKI
);
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addCrumb
(
id
(
new
PHUICrumbView
())
->
setHref
(
"/project/view/${id}"
)
->
setName
(
$project
->
getName
())
);
$crumbs
->
addTextCrumb
(
pht
(
'Wiki'
));
$crumbs
->
setBorder
(
true
);
$header
=
id
(
new
PHUIHeaderView
())
->
setHeader
(
$title
)
->
setHeaderIcon
(
'fa-book'
);
$view
=
id
(
new
PHUITwoColumnView
())
->
setHeader
(
$header
)
->
setCurtain
(
$curtain
)
->
setMainColumn
(
array
(
$wiki_list
,
));
return
$this
->
newPage
()
->
setNavigation
(
$nav
)
->
setCrumbs
(
$crumbs
)
->
setTitle
(
array
(
$project
->
getName
(),
$title
))
->
appendChild
(
$view
);
}
private
function
buildCurtainView
(
PhabricatorProject
$project
)
{
$viewer
=
$this
->
getViewer
();
$id
=
$project
->
getID
();
$curtain
=
$this
->
newCurtainView
(
$project
);
$can_edit
=
PhabricatorPolicyFilter
::
hasCapability
(
$viewer
,
$project
,
PhabricatorPolicyCapability
::
CAN_EDIT
);
if
(
$can_edit
)
{
$curtain
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
'Create wiki page'
)
->
setIcon
(
'fa-plus'
)
->
setHref
(
"/project/wiki/create/{$id}/"
)
->
setWorkflow
(
true
));
}
return
$curtain
;
}
protected
function
buildApplicationCrumbs
()
{
$view
=
new
PHUICrumbsView
();
$view
->
addCrumb
(
id
(
new
PHUICrumbView
())
->
setHref
(
'/project/'
)
->
setName
(
pht
(
'Projects'
))
->
setIcon
(
'fa-briefcase'
)
);
return
$view
;
}
}
Event Timeline
Log In to Comment