Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112210283
PhameBlogViewController.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
Thu, May 8, 22:54
Size
4 KB
Mime Type
text/x-php
Expires
Sat, May 10, 22:54 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
26048269
Attached To
rPH Phabricator
PhameBlogViewController.php
View Options
<?php
final
class
PhameBlogViewController
extends
PhameBlogController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$blog
=
id
(
new
PhameBlogQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
executeOne
();
if
(!
$blog
)
{
return
new
Aphront404Response
();
}
$pager
=
id
(
new
AphrontCursorPagerView
())
->
readFromRequest
(
$request
);
$posts
=
id
(
new
PhamePostQuery
())
->
setViewer
(
$viewer
)
->
withBlogPHIDs
(
array
(
$blog
->
getPHID
()))
->
executeWithCursorPager
(
$pager
);
$header
=
id
(
new
PHUIHeaderView
())
->
setHeader
(
$blog
->
getName
())
->
setUser
(
$viewer
)
->
setPolicyObject
(
$blog
);
$actions
=
$this
->
renderActions
(
$blog
,
$viewer
);
$properties
=
$this
->
renderProperties
(
$blog
,
$viewer
,
$actions
);
$post_list
=
$this
->
renderPostList
(
$posts
,
$viewer
,
pht
(
'This blog has no visible posts.'
));
$post_list
=
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
pht
(
'Latest Posts'
))
->
appendChild
(
$post_list
);
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addTextCrumb
(
pht
(
'Blogs'
),
$this
->
getApplicationURI
(
'blog/'
));
$crumbs
->
addTextCrumb
(
$blog
->
getName
(),
$this
->
getApplicationURI
());
$object_box
=
id
(
new
PHUIObjectBoxView
())
->
setHeader
(
$header
)
->
addPropertyList
(
$properties
);
return
$this
->
newPage
()
->
setTitle
(
$blog
->
getName
())
->
setCrumbs
(
$crumbs
)
->
appendChild
(
array
(
$object_box
,
$post_list
,
));
}
private
function
renderProperties
(
PhameBlog
$blog
,
PhabricatorUser
$viewer
,
PhabricatorActionListView
$actions
)
{
require_celerity_resource
(
'aphront-tooltip-css'
);
Javelin
::
initBehavior
(
'phabricator-tooltips'
);
$properties
=
id
(
new
PHUIPropertyListView
())
->
setUser
(
$viewer
)
->
setObject
(
$blog
)
->
setActionList
(
$actions
);
$properties
->
addProperty
(
pht
(
'Skin'
),
$blog
->
getSkin
());
$properties
->
addProperty
(
pht
(
'Domain'
),
$blog
->
getDomain
());
$feed_uri
=
PhabricatorEnv
::
getProductionURI
(
$this
->
getApplicationURI
(
'blog/feed/'
.
$blog
->
getID
().
'/'
));
$properties
->
addProperty
(
pht
(
'Atom URI'
),
javelin_tag
(
'a'
,
array
(
'href'
=>
$feed_uri
,
'sigil'
=>
'has-tooltip'
,
'meta'
=>
array
(
'tip'
=>
pht
(
'Atom URI does not support custom domains.'
),
'size'
=>
320
,
),
),
$feed_uri
));
$descriptions
=
PhabricatorPolicyQuery
::
renderPolicyDescriptions
(
$viewer
,
$blog
);
$properties
->
addProperty
(
pht
(
'Editable By'
),
$descriptions
[
PhabricatorPolicyCapability
::
CAN_EDIT
]);
$properties
->
addProperty
(
pht
(
'Joinable By'
),
$descriptions
[
PhabricatorPolicyCapability
::
CAN_JOIN
]);
$engine
=
id
(
new
PhabricatorMarkupEngine
())
->
setViewer
(
$viewer
)
->
addObject
(
$blog
,
PhameBlog
::
MARKUP_FIELD_DESCRIPTION
)
->
process
();
$properties
->
invokeWillRenderEvent
();
if
(
strlen
(
$blog
->
getDescription
()))
{
$description
=
PhabricatorMarkupEngine
::
renderOneObject
(
id
(
new
PhabricatorMarkupOneOff
())->
setContent
(
$blog
->
getDescription
()),
'default'
,
$viewer
);
$properties
->
addSectionHeader
(
pht
(
'Description'
),
PHUIPropertyListView
::
ICON_SUMMARY
);
$properties
->
addTextContent
(
$description
);
}
return
$properties
;
}
private
function
renderActions
(
PhameBlog
$blog
,
PhabricatorUser
$viewer
)
{
$actions
=
id
(
new
PhabricatorActionListView
())
->
setObject
(
$blog
)
->
setObjectURI
(
$this
->
getRequest
()->
getRequestURI
())
->
setUser
(
$viewer
);
$can_edit
=
PhabricatorPolicyFilter
::
hasCapability
(
$viewer
,
$blog
,
PhabricatorPolicyCapability
::
CAN_EDIT
);
$can_join
=
PhabricatorPolicyFilter
::
hasCapability
(
$viewer
,
$blog
,
PhabricatorPolicyCapability
::
CAN_JOIN
);
$actions
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setIcon
(
'fa-plus'
)
->
setHref
(
$this
->
getApplicationURI
(
'post/edit/?blog='
.
$blog
->
getID
()))
->
setName
(
pht
(
'Write Post'
))
->
setDisabled
(!
$can_join
)
->
setWorkflow
(!
$can_join
));
$actions
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setUser
(
$viewer
)
->
setIcon
(
'fa-globe'
)
->
setHref
(
$blog
->
getLiveURI
())
->
setName
(
pht
(
'View Live'
)));
$actions
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setIcon
(
'fa-pencil'
)
->
setHref
(
$this
->
getApplicationURI
(
'blog/edit/'
.
$blog
->
getID
().
'/'
))
->
setName
(
pht
(
'Edit Blog'
))
->
setDisabled
(!
$can_edit
)
->
setWorkflow
(!
$can_edit
));
$actions
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setIcon
(
'fa-times'
)
->
setHref
(
$this
->
getApplicationURI
(
'blog/delete/'
.
$blog
->
getID
().
'/'
))
->
setName
(
pht
(
'Delete Blog'
))
->
setDisabled
(!
$can_edit
)
->
setWorkflow
(
true
));
return
$actions
;
}
}
Event Timeline
Log In to Comment