Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92648654
PhabricatorAphrontBarUIExample.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
Fri, Nov 22, 09:16
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 09:16 (2 d)
Engine
blob
Format
Raw Data
Handle
22477913
Attached To
rPH Phabricator
PhabricatorAphrontBarUIExample.php
View Options
<?php
final
class
PhabricatorAphrontBarUIExample
extends
PhabricatorUIExample
{
public
function
getName
()
{
return
pht
(
'Bars'
);
}
public
function
getDescription
()
{
return
pht
(
'Like fractions, but more horizontal.'
);
}
public
function
renderExample
()
{
$out
=
array
();
$out
[]
=
$this
->
renderTestThings
(
'AphrontProgressBarView'
,
13
,
10
);
$out
[]
=
$this
->
renderTestThings
(
'AphrontGlyphBarView'
,
13
,
10
);
$out
[]
=
$this
->
renderWeirdOrderGlyphBars
();
$out
[]
=
$this
->
renderAsciiStarBar
();
return
$out
;
}
private
function
wrap
(
$title
,
$thing
)
{
$thing
=
phutil_tag_div
(
'ml grouped'
,
$thing
);
return
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
$title
)
->
appendChild
(
$thing
);
}
private
function
renderTestThings
(
$class
,
$max
,
$incr
)
{
$bars
=
array
();
for
(
$ii
=
0
;
$ii
<=
$max
;
$ii
++)
{
$bars
[]
=
newv
(
$class
,
array
())
->
setValue
(
$ii
*
$incr
)
->
setMax
(
$max
*
$incr
)
->
setCaption
(
"{$ii} outta {$max} ain't bad!"
);
}
return
$this
->
wrap
(
"Test {$class}"
,
$bars
);
}
private
function
renderWeirdOrderGlyphBars
()
{
$views
=
array
();
$indices
=
array
(
1
,
3
,
7
,
4
,
2
,
8
,
9
,
5
,
10
,
6
);
$max
=
count
(
$indices
);
foreach
(
$indices
as
$index
)
{
$views
[]
=
id
(
new
AphrontGlyphBarView
())
->
setValue
(
$index
)
->
setMax
(
$max
)
->
setNumGlyphs
(
5
)
->
setCaption
(
"Lol score is {$index}/{$max}"
)
->
setGlyph
(
hsprintf
(
'%s'
,
'LOL!'
))
->
setBackgroundGlyph
(
hsprintf
(
'%s'
,
'____'
));
$views
[]
=
hsprintf
(
'<div style="clear:both;"></div>'
);
}
return
$this
->
wrap
(
'Glyph bars in weird order'
,
$views
);
}
private
function
renderAsciiStarBar
()
{
$bar
=
id
(
new
AphrontGlyphBarView
())
->
setValue
(
50
)
->
setMax
(
100
)
->
setCaption
(
'Glyphs!'
)
->
setNumGlyphs
(
10
)
->
setGlyph
(
hsprintf
(
'%s'
,
'*'
));
return
$this
->
wrap
(
'Ascii star glyph bar'
,
$bar
);
}
}
Event Timeline
Log In to Comment