Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2355535
PholioInlineEditController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PholioInlineEditController.php
View Options
<?php
/**
* @group pholio
*/
final
class
PholioInlineEditController
extends
PholioController
{
private
$id
;
private
$operation
;
public
function
getOperation
()
{
return
$this
->
operation
;
}
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$this
->
operation
=
$request
->
getBool
(
'op'
);
$inline_comment
=
id
(
new
PholioTransactionComment
())->
loadOneWhere
(
'id = %d AND authorphid = %s AND transactionphid IS NULL'
,
$this
->
id
,
$user
->
getPHID
());
if
(
$inline_comment
==
null
)
{
return
new
Aphront404Response
();
}
switch
(
$this
->
getOperation
())
{
case
'update'
:
$new_content
=
$request
->
getStr
(
'content'
);
if
(
strlen
(
trim
(
$new_content
))
==
0
)
{
return
id
(
new
AphrontAjaxResponse
())
->
setContent
(
array
(
'success'
=>
false
))
->
setError
(
pht
(
'Empty comment'
));
}
$inline_comment
->
setContent
(
$request
->
getStr
(
'content'
));
$inline_comment
->
save
();
return
id
(
new
AphrontAjaxResponse
())
->
setContent
(
array
(
'success'
=>
true
));
default
:
$dialog
=
new
PholioInlineCommentEditView
();
$dialog
->
setInlineComment
(
$inline_comment
);
$dialog
->
setUser
(
$user
);
$dialog
->
setSubmitURI
(
$request
->
getRequestURI
());
$dialog
->
setTitle
(
pht
(
'Edit inline comment'
));
$dialog
->
addHiddenInput
(
'id'
,
$this
->
id
);
$dialog
->
addHiddenInput
(
'op'
,
'edit'
);
$dialog
->
appendChild
(
$this
->
renderTextArea
(
$inline_comment
->
getContent
()));
return
id
(
new
AphrontAjaxResponse
())->
setContent
(
$dialog
->
render
());
}
}
private
function
renderTextArea
(
$text
)
{
return
javelin_tag
(
'textarea'
,
array
(
'class'
=>
'pholio-inline-comment-dialog-textarea'
,
'name'
=>
'text'
,
),
$text
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Sep 16, 1:44 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
382818
Default Alt Text
PholioInlineEditController.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment