Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F442508
PhabricatorFileLightboxController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorFileLightboxController.php
View Options
<?php
final
class
PhabricatorFileLightboxController
extends
PhabricatorFileController
{
public
function
shouldAllowPublic
()
{
return
true
;
}
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$phid
=
$request
->
getURIData
(
'phid'
);
$comment
=
$request
->
getStr
(
'comment'
);
$file
=
id
(
new
PhabricatorFileQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$phid
))
->
executeOne
();
if
(!
$file
)
{
return
new
Aphront404Response
();
}
if
(
phutil_nonempty_string
(
$comment
))
{
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhabricatorFileTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_COMMENT
)
->
attachComment
(
id
(
new
PhabricatorFileTransactionComment
())
->
setContent
(
$comment
));
$editor
=
id
(
new
PhabricatorFileEditor
())
->
setActor
(
$viewer
)
->
setContinueOnNoEffect
(
true
)
->
setContentSourceFromRequest
(
$request
);
$editor
->
applyTransactions
(
$file
,
$xactions
);
}
$transactions
=
id
(
new
PhabricatorFileTransactionQuery
())
->
withTransactionTypes
(
array
(
PhabricatorTransactions
::
TYPE_COMMENT
));
$timeline
=
$this
->
buildTransactionTimeline
(
$file
,
$transactions
);
$comment_form
=
$this
->
renderCommentForm
(
$file
);
$info
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'phui-comment-panel-header'
,
),
$file
->
getName
());
require_celerity_resource
(
'phui-comment-panel-css'
);
$content
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'phui-comment-panel'
,
),
array
(
$info
,
$timeline
,
$comment_form
,
));
return
id
(
new
AphrontAjaxResponse
())
->
setContent
(
$content
);
}
private
function
renderCommentForm
(
PhabricatorFile
$file
)
{
$viewer
=
$this
->
getViewer
();
if
(!
$viewer
->
isLoggedIn
())
{
$login_href
=
id
(
new
PhutilURI
(
'/auth/start/'
))
->
replaceQueryParam
(
'next'
,
'/'
.
$file
->
getMonogram
());
return
id
(
new
PHUIFormLayoutView
())
->
addClass
(
'phui-comment-panel-empty'
)
->
appendChild
(
id
(
new
PHUIButtonView
())
->
setTag
(
'a'
)
->
setText
(
pht
(
'Log In to Comment'
))
->
setHref
((
string
)
$login_href
));
}
$draft
=
PhabricatorDraft
::
newFromUserAndKey
(
$viewer
,
$file
->
getPHID
());
$post_uri
=
$this
->
getApplicationURI
(
'thread/'
.
$file
->
getPHID
().
'/'
);
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$viewer
)
->
setAction
(
$post_uri
)
->
addSigil
(
'lightbox-comment-form'
)
->
addClass
(
'lightbox-comment-form'
)
->
setWorkflow
(
true
)
->
appendChild
(
id
(
new
PhabricatorRemarkupControl
())
->
setUser
(
$viewer
)
->
setName
(
'comment'
)
->
setValue
(
$draft
->
getDraft
()))
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
pht
(
'Comment'
)));
$view
=
phutil_tag_div
(
'phui-comment-panel'
,
$form
);
return
$view
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, May 4, 9:02 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
64640
Default Alt Text
PhabricatorFileLightboxController.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment