Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F430355
PhabricatorAphrontBarUIExample.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
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
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 3, 10:23 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
59810
Default Alt Text
PhabricatorAphrontBarUIExample.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment