Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2896249
PhabricatorRemarkupDiagramRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorRemarkupDiagramRule.php
View Options
<?php
final
class
PhabricatorRemarkupDiagramRule
extends
PhabricatorObjectRemarkupRule
{
protected
function
getObjectNamePrefix
(
)
{
return
'DIAG'
;
}
public
function
getRuleVersion
(
)
{
return
'1.0'
;
}
protected
function
loadObjects
(
array
$ids
)
{
$viewer
=
$this
->
getEngine
(
)
->
getConfig
(
'viewer'
)
;
$objects
=
id
(
new
PhabricatorDiagramVersionQuery
(
)
)
->
setViewer
(
$viewer
)
->
withDiagramIDs
(
$ids
)
->
execute
(
)
;
return
$objects
;
}
protected
function
renderObjectEmbed
(
$diagram
,
PhabricatorObjectHandle
$handle
,
$options
)
{
if
(
$options
)
{
$params
=
explode
(
','
,
$options
)
;
$params
=
array_map
(
'trim'
,
$params
)
;
}
else
{
$params
=
array
(
)
;
}
// Get the file PHID for the Diagram object.
$file_phid
=
$diagram
->
getPHID
(
)
;
// Generate the appropriate HTML using the data from the Diagram and
// file objects.
$style
=
''
;
$class
=
'diagram-content'
;
$alt
=
''
;
$has_layout
=
false
;
foreach
(
$params
as
$param
)
{
if
(
strpos
(
$param
,
'='
)
!==
false
)
{
list
(
$key
,
$value
)
=
explode
(
'='
,
$param
,
2
)
;
}
else
{
$key
=
$param
;
$value
=
null
;
}
switch
(
$key
)
{
case
'layout'
:
$has_layout
=
true
;
if
(
$value
===
'left'
)
{
$class
.=
' phabricator-remarkup-embed-layout-left'
;
}
else
if
(
$value
===
'right'
)
{
$class
.=
' phabricator-remarkup-embed-layout-right'
;
}
break
;
case
'float'
:
$class
.=
' phabricator-remarkup-embed-float-left'
;
break
;
case
'size'
:
if
(
$value
===
'full'
)
{
$style
.=
'width: 100%;'
;
}
break
;
case
'alt'
:
$alt
=
phutil_escape_html
(
$value
)
;
break
;
}
}
if
(
$has_layout
==
false
)
{
$class
.=
' phabricator-remarkup-embed-layout-left'
;
}
$output
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'diagram-container'
,
)
,
phutil_tag
(
'img'
,
array
(
'style'
=>
$style
,
'class'
=>
$class
,
'src'
=>
$diagram
->
getViewURI
(
)
,
'alt'
=>
$alt
,
'ondblclick'
=>
'window.open("/diagram/DIAG'
.
$diagram
->
getDiagramID
(
)
.
'", "_blank")'
,
)
)
)
;
return
$output
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 22:49 (6 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129551
Default Alt Text
PhabricatorRemarkupDiagramRule.php (2 KB)
Attached To
Mode
R5 Diagrams
Attached
Detach File
Event Timeline
Log In to Comment