Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F441957
PonderPostBodyView.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
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
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, May 4, 7:59 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
64537
Default Alt Text
PonderPostBodyView.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment