Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F109915411
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
Wed, Apr 23, 23:21
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Apr 25, 23:21 (2 d)
Engine
blob
Format
Raw Data
Handle
25757374
Attached To
rPH Phabricator
PhamePostPublishController.php
View Options
<?php
final
class
PhamePostPublishController
extends
PhamePostController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$post
=
id
(
new
PhamePostQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$post
)
{
return
new
Aphront404Response
();
}
$view_uri
=
$this
->
getApplicationURI
(
'/post/view/'
.
$post
->
getID
().
'/'
);
if
(
$request
->
isFormPost
())
{
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhamePostTransaction
())
->
setTransactionType
(
PhamePostTransaction
::
TYPE_TITLE
)
->
setNewValue
(
$post
->
getTitle
());
$xactions
[]
=
id
(
new
PhamePostTransaction
())
->
setTransactionType
(
PhamePostTransaction
::
TYPE_PHAME_TITLE
)
->
setNewValue
(
$post
->
getPhameTitle
());
$xactions
[]
=
id
(
new
PhamePostTransaction
())
->
setTransactionType
(
PhamePostTransaction
::
TYPE_VISIBILITY
)
->
setNewValue
(
PhameConstants
::
VISIBILITY_PUBLISHED
);
id
(
new
PhamePostEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
applyTransactions
(
$post
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$view_uri
);
}
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$viewer
)
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
pht
(
'Publish Post'
))
->
addCancelButton
(
$view_uri
));
$frame
=
$this
->
renderPreviewFrame
(
$post
);
$form_box
=
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
pht
(
'Preview Post'
))
->
setForm
(
$form
);
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addTextCrumb
(
pht
(
'Preview'
),
$view_uri
);
return
$this
->
newPage
()
->
setTitle
(
pht
(
'Preview Post'
))
->
setCrumbs
(
$crumbs
)
->
appendChild
(
array
(
$form_box
,
$frame
,
));
}
private
function
renderPreviewFrame
(
PhamePost
$post
)
{
return
phutil_tag
(
'div'
,
array
(
'style'
=>
'text-align: center; padding: 16px;'
,
),
phutil_tag
(
'iframe'
,
array
(
'style'
=>
'width: 100%; height: 600px; '
.
'border: 1px solid #BFCFDA; '
.
'background-color: #fff; '
.
'border-radius: 3px; '
,
'src'
=>
$this
->
getApplicationURI
(
'/post/framed/'
.
$post
->
getID
().
'/'
),
),
''
));
}
}
Event Timeline
Log In to Comment