Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1171519
PhabricatorFilesComposeAvatarExample.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
PhabricatorFilesComposeAvatarExample.php
View Options
<?php
final
class
PhabricatorFilesComposeAvatarExample
extends
PhabricatorUIExample
{
public
function
getName
()
{
return
pht
(
'Generate Avatar Images'
);
}
public
function
getDescription
()
{
return
pht
(
'Tests various color palettes and sizes.'
);
}
public
function
renderExample
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$colors
=
PhabricatorFilesComposeAvatarBuiltinFile
::
getColorMap
();
$builtins
=
PhabricatorFilesComposeAvatarBuiltinFile
::
getImageMap
();
$borders
=
PhabricatorFilesComposeAvatarBuiltinFile
::
getBorderMap
();
shuffle
(
$colors
);
$images
=
array
();
foreach
(
$builtins
as
$builtin
=>
$raw_file
)
{
$file
=
PhabricatorFile
::
loadBuiltin
(
$viewer
,
$builtin
);
$images
[]
=
$file
->
getBestURI
();
}
$content
=
array
();
foreach
(
$colors
as
$color
)
{
shuffle
(
$borders
);
$border
=
head
(
$borders
);
$styles
=
array
();
$styles
[]
=
'background-color: '
.
$color
.
';'
;
$styles
[]
=
'display: inline-block;'
;
$styles
[]
=
'height: 46px;'
;
$styles
[]
=
'width: 46px;'
;
$styles
[]
=
'border-radius: 3px;'
;
$styles
[]
=
'border: 4px solid '
.
$border
.
';'
;
shuffle
(
$images
);
$png
=
head
(
$images
);
$image
=
phutil_tag
(
'img'
,
array
(
'src'
=>
$png
,
'height'
=>
46
,
'width'
=>
46
,
));
$tag
=
phutil_tag
(
'div'
,
array
(
'style'
=>
implode
(
' '
,
$styles
),
),
$image
);
$content
[]
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'mlr mlb'
,
'style'
=>
'float: left;'
,
),
$tag
);
}
$view
=
phutil_tag_div
(
'ml'
,
$content
);
return
phutil_tag
(
'div'
,
array
(),
array
(
$view
,
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jul 2, 6:00 AM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
289927
Default Alt Text
PhabricatorFilesComposeAvatarExample.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment