Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2892014
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
3 KB
Referenced Files
None
Subscribers
None
PhabricatorRemarkupDiagramRule.php
View Options
<?php
require_celerity_resource
(
'diagram-remarkup-image-js'
,
'diagram-resources'
)
;
require_celerity_resource
(
'diagram-remarkup-image-css'
,
'diagram-resources'
)
;
final
class
PhabricatorRemarkupDiagramRule
extends
PhabricatorObjectRemarkupRule
implements
RemarkupSyntaxDocumentationProvider
{
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
(
)
;
}
// 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'
=>
'data:image/png;base64,'
.
$diagram
->
getBase64Data
(
)
,
'alt'
=>
$alt
,
'data-sigil'
=>
'diagram-remarkup-image'
,
'data-diagram-version'
=>
$diagram
->
getPHID
(
)
,
'data-diagram-id'
=>
$diagram
->
getDiagramID
(
)
,
'title'
=>
'Double click to edit...'
)
)
)
;
return
$output
;
}
public
function
getDocumentation
(
)
{
return
<<<EOT
= Diagrams
Diagrams is a Phorge extension application for
[[ https://www.drawio.com | diagrams.net (previously draw.io)]] by JGraph.
You can create and store diagrams in your Phorge instance.
These diagrams can be referenced by means of the `DIAG` token.
For example: `{DIAG123}`.
When you double click on a diagram, the editor will open the corresponding
diagram in a new browser tab.
You can create diagrams with multiple pages, but only the first one will be
visualized in a referenced diagram.
When you modify an existing diagram, a new version will be created.
You can select older versions in the editor by means of the dropdown in the
topright corner.
If you don't see a dropdown, you diagram has only 1 version.
EOT
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 16:04 (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126308
Default Alt Text
PhabricatorRemarkupDiagramRule.php (3 KB)
Attached To
Mode
R5 Diagrams
Attached
Detach File
Event Timeline
Log In to Comment