Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F960286
PHUIRemarkupPreviewPanel.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
PHUIRemarkupPreviewPanel.php
View Options
<?php
/**
* Render a simple preview panel for a bound Remarkup text control.
*/
final
class
PHUIRemarkupPreviewPanel
extends
AphrontTagView
{
private
$header
;
private
$loadingText
;
private
$controlID
;
private
$previewURI
;
private
$previewType
;
const
DOCUMENT
=
'document'
;
protected
function
canAppendChild
()
{
return
false
;
}
public
function
setPreviewURI
(
$preview_uri
)
{
$this
->
previewURI
=
$preview_uri
;
return
$this
;
}
public
function
setControlID
(
$control_id
)
{
$this
->
controlID
=
$control_id
;
return
$this
;
}
public
function
setHeader
(
$header
)
{
$this
->
header
=
$header
;
return
$this
;
}
public
function
setLoadingText
(
$loading_text
)
{
$this
->
loadingText
=
$loading_text
;
return
$this
;
}
public
function
setPreviewType
(
$type
)
{
$this
->
previewType
=
$type
;
return
$this
;
}
protected
function
getTagName
()
{
return
'div'
;
}
protected
function
getTagAttributes
()
{
$classes
=
array
();
$classes
[]
=
'phui-remarkup-preview'
;
return
array
(
'class'
=>
$classes
,
);
}
protected
function
getTagContent
()
{
if
(
$this
->
previewURI
===
null
)
{
throw
new
PhutilInvalidStateException
(
'setPreviewURI'
);
}
if
(
$this
->
controlID
===
null
)
{
throw
new
PhutilInvalidStateException
(
'setControlID'
);
}
$preview_id
=
celerity_generate_unique_node_id
();
require_celerity_resource
(
'phui-remarkup-preview-css'
);
Javelin
::
initBehavior
(
'remarkup-preview'
,
array
(
'previewID'
=>
$preview_id
,
'controlID'
=>
$this
->
controlID
,
'uri'
=>
$this
->
previewURI
,
));
$loading
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'phui-preview-loading-text'
,
),
nonempty
(
$this
->
loadingText
,
pht
(
'Loading preview...'
)));
$preview
=
phutil_tag
(
'div'
,
array
(
'id'
=>
$preview_id
,
'class'
=>
'phabricator-remarkup phui-preview-body'
,
),
$loading
);
if
(!
$this
->
previewType
)
{
$header
=
null
;
if
(
$this
->
header
)
{
$header
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'phui-preview-header'
,
),
$this
->
header
);
}
$content
=
array
(
$header
,
$preview
);
}
else
if
(
$this
->
previewType
==
self
::
DOCUMENT
)
{
$header
=
id
(
new
PHUIHeaderView
())
->
setHeader
(
pht
(
'%s (Preview)'
,
$this
->
header
));
$content
=
id
(
new
PHUIDocumentView
())
->
setHeader
(
$header
)
->
appendChild
(
$preview
);
}
return
id
(
new
PHUIObjectBoxView
())
->
appendChild
(
$content
)
->
setCollapsed
(
true
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jun 17, 10:45 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
224662
Default Alt Text
PHUIRemarkupPreviewPanel.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment