Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F111803133
PhamePostPublishController.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
Mon, May 5, 03:49
Size
2 KB
Mime Type
text/x-php
Expires
Wed, May 7, 03:49 (2 d)
Engine
blob
Format
Raw Data
Handle
25976300
Attached To
rPH Phabricator
PhamePostPublishController.php
View Options
<?php
/**
* @group phame
*/
final
class
PhamePostPublishController
extends
PhameController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$post
=
id
(
new
PhamePostQuery
())
->
setViewer
(
$user
)
->
withIDs
(
array
(
$this
->
id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$post
)
{
return
new
Aphront404Response
();
}
$view_uri
=
$this
->
getApplicationURI
(
'/post/view/'
.
$post
->
getID
().
'/'
);
if
(
$request
->
isFormPost
())
{
$post
->
setVisibility
(
PhamePost
::
VISIBILITY_PUBLISHED
);
$post
->
setDatePublished
(
time
());
$post
->
save
();
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$view_uri
);
}
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$user
)
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
pht
(
'Publish Post'
))
->
addCancelButton
(
$view_uri
));
$frame
=
$this
->
renderPreviewFrame
(
$post
);
$form_box
=
id
(
new
PHUIFormBoxView
())
->
setHeaderText
(
pht
(
'Preview Post'
))
->
setForm
(
$form
);
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addCrumb
(
id
(
new
PhabricatorCrumbView
())
->
setName
(
pht
(
'Preview'
))
->
setHref
(
$view_uri
));
$nav
=
$this
->
renderSideNavFilterView
(
null
);
$nav
->
appendChild
(
array
(
$crumbs
,
$form_box
,
$frame
,
));
return
$this
->
buildApplicationPage
(
$nav
,
array
(
'title'
=>
pht
(
'Preview Post'
),
'device'
=>
true
,
));
}
private
function
renderPreviewFrame
(
PhamePost
$post
)
{
// TODO: Clean up this CSS.
return
phutil_tag
(
'div'
,
array
(
'style'
=>
'text-align: center; padding: 1em;'
,
),
phutil_tag
(
'iframe'
,
array
(
'style'
=>
'width: 100%; height: 600px; '
.
'border: 1px solid #303030;'
,
'src'
=>
$this
->
getApplicationURI
(
'/post/framed/'
.
$post
->
getID
().
'/'
),
),
''
));
}
}
Event Timeline
Log In to Comment