Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93461535
PhabricatorPropertyListView.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
Thu, Nov 28, 23:08
Size
3 KB
Mime Type
text/x-php
Expires
Sat, Nov 30, 23:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22644742
Attached To
rPH Phabricator
PhabricatorPropertyListView.php
View Options
<?php
final
class
PhabricatorPropertyListView
extends
AphrontView
{
private
$parts
=
array
();
private
$hasKeyboardShortcuts
;
protected
function
canAppendChild
()
{
return
false
;
}
public
function
setHasKeyboardShortcuts
(
$has_keyboard_shortcuts
)
{
$this
->
hasKeyboardShortcuts
=
$has_keyboard_shortcuts
;
return
$this
;
}
public
function
addProperty
(
$key
,
$value
)
{
$current
=
array_pop
(
$this
->
parts
);
if
(!
$current
||
$current
[
'type'
]
!=
'property'
)
{
if
(
$current
)
{
$this
->
parts
[]
=
$current
;
}
$current
=
array
(
'type'
=>
'property'
,
'list'
=>
array
(),
);
}
$current
[
'list'
][]
=
array
(
'key'
=>
$key
,
'value'
=>
$value
,
);
$this
->
parts
[]
=
$current
;
return
$this
;
}
public
function
addSectionHeader
(
$name
)
{
$this
->
parts
[]
=
array
(
'type'
=>
'section'
,
'name'
=>
$name
,
);
return
$this
;
}
public
function
addTextContent
(
$content
)
{
$this
->
parts
[]
=
array
(
'type'
=>
'text'
,
'content'
=>
$content
,
);
return
$this
;
}
public
function
render
()
{
require_celerity_resource
(
'phabricator-property-list-view-css'
);
$items
=
array
();
foreach
(
$this
->
parts
as
$part
)
{
$type
=
$part
[
'type'
];
switch
(
$type
)
{
case
'property'
:
$items
[]
=
$this
->
renderPropertyPart
(
$part
);
break
;
case
'section'
:
$items
[]
=
$this
->
renderSectionPart
(
$part
);
break
;
case
'text'
:
$items
[]
=
$this
->
renderTextPart
(
$part
);
break
;
default
:
throw
new
Exception
(
"Unknown part type '{$type}'!"
);
}
}
return
phutil_tag
(
'div'
,
array
(
'class'
=>
'phabricator-property-list-view'
,
),
$this
->
renderSingleView
(
$items
));
}
private
function
renderPropertyPart
(
array
$part
)
{
$items
=
array
();
foreach
(
$part
[
'list'
]
as
$spec
)
{
$key
=
$spec
[
'key'
];
$value
=
$spec
[
'value'
];
$items
[]
=
phutil_tag
(
'dt'
,
array
(
'class'
=>
'phabricator-property-list-key'
,
),
$key
);
$items
[]
=
phutil_tag
(
'dd'
,
array
(
'class'
=>
'phabricator-property-list-value'
,
),
$this
->
renderSingleView
(
$value
));
}
$list
=
phutil_tag
(
'dl'
,
array
(
'class'
=>
'phabricator-property-list-properties'
,
),
$this
->
renderSingleView
(
$items
));
$shortcuts
=
null
;
if
(
$this
->
hasKeyboardShortcuts
)
{
$shortcuts
=
id
(
new
AphrontKeyboardShortcutsAvailableView
())->
render
();
}
return
array
(
$shortcuts
,
phutil_tag
(
'div'
,
array
(
'class'
=>
'phabricator-property-list-container'
,
),
array
(
$list
,
phutil_tag
(
'div'
,
array
(
'class'
=>
'phabriator-property-list-view-end'
),
''
),
)));
}
private
function
renderSectionPart
(
array
$part
)
{
return
phutil_tag
(
'div'
,
array
(
'class'
=>
'phabricator-property-list-section-header'
,
),
$part
[
'name'
]);
}
private
function
renderTextPart
(
array
$part
)
{
return
phutil_tag
(
'div'
,
array
(
'class'
=>
'phabricator-property-list-text-content'
,
),
$part
[
'content'
]);
}
}
Event Timeline
Log In to Comment