Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96971092
PonderPostBodyView.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, Jan 1, 05:26
Size
3 KB
Mime Type
text/x-php
Expires
Fri, Jan 3, 05:26 (2 d)
Engine
blob
Format
Raw Data
Handle
23301487
Attached To
rPH Phabricator
PonderPostBodyView.php
View Options
<?php
final
class
PonderPostBodyView
extends
AphrontView
{
private
$target
;
private
$question
;
private
$handles
;
private
$preview
;
private
$anchorName
;
private
$action
;
public
function
setQuestion
(
$question
)
{
$this
->
question
=
$question
;
return
$this
;
}
public
function
setTarget
(
$target
)
{
$this
->
target
=
$target
;
return
$this
;
}
public
function
setAction
(
$action
)
{
$this
->
action
=
$action
;
return
$this
;
}
public
function
setHandles
(
array
$handles
)
{
assert_instances_of
(
$handles
,
'PhabricatorObjectHandle'
);
$this
->
handles
=
$handles
;
return
$this
;
}
public
function
setPreview
(
$preview
)
{
$this
->
preview
=
$preview
;
return
$this
;
}
public
function
render
()
{
if
(!
$this
->
user
)
{
throw
new
Exception
(
"Call setUser() before rendering!"
);
}
require_celerity_resource
(
'phabricator-remarkup-css'
);
require_celerity_resource
(
'ponder-post-css'
);
$user
=
$this
->
user
;
$question
=
$this
->
question
;
$target
=
$this
->
target
;
$content
=
$target
->
getContent
();
$info
=
array
();
$content
=
PhabricatorMarkupEngine
::
renderOneObject
(
$target
,
$target
->
getMarkupField
(),
$this
->
user
);
$content
=
'<div class="phabricator-remarkup">'
.
$content
.
'</div>'
;
$author
=
$this
->
handles
[
$target
->
getAuthorPHID
()];
$actions
=
array
(
$author
->
renderLink
().
' '
.
$this
->
action
);
$author_link
=
$author
->
renderLink
();
$xaction_view
=
id
(
new
PhabricatorTransactionView
())
->
setUser
(
$user
)
->
setImageURI
(
$author
->
getImageURI
())
->
setContentSource
(
$target
->
getContentSource
())
->
setActions
(
$actions
);
if
(
$this
->
target
instanceof
PonderAnswer
)
{
$xaction_view
->
addClass
(
"ponder-answer"
);
}
else
{
$xaction_view
->
addClass
(
"ponder-question"
);
}
if
(
$this
->
preview
)
{
$xaction_view
->
setIsPreview
(
$this
->
preview
);
}
else
{
$xaction_view
->
setEpoch
(
$target
->
getDateCreated
());
if
(
$this
->
target
instanceof
PonderAnswer
)
{
$anchor_text
=
'Q'
.
$question
->
getID
().
'#A'
.
$target
->
getID
();
$xaction_view
->
setAnchor
(
'A'
.
$target
->
getID
(),
$anchor_text
);
$xaction_view
->
addClass
(
"ponder-answer"
);
}
}
$xaction_view
->
appendChild
(
'<div class="ponder-post-core">'
.
$content
.
'</div>'
);
$outerview
=
$xaction_view
;
if
(!
$this
->
preview
)
{
$outerview
=
id
(
new
PonderVotableView
())
->
setPHID
(
$target
->
getPHID
())
->
setCount
(
$target
->
getVoteCount
())
->
setVote
(
$target
->
getUserVote
());
if
(
$this
->
target
instanceof
PonderAnswer
)
{
$outerview
->
setURI
(
'/ponder/answer/vote/'
);
}
else
{
$outerview
->
setURI
(
'/ponder/question/vote/'
);
}
$outerview
->
appendChild
(
$xaction_view
);
}
return
$outerview
->
render
();
}
private
function
renderHandleList
(
array
$phids
)
{
$result
=
array
();
foreach
(
$phids
as
$phid
)
{
$result
[]
=
$this
->
handles
[
$phid
]->
renderLink
();
}
return
implode
(
', '
,
$result
);
}
}
Event Timeline
Log In to Comment