Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F459684
AphrontBarView.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
AphrontBarView.php
View Options
<?php
abstract
class
AphrontBarView
extends
AphrontView
{
private
$color
;
private
$caption
=
''
;
const
COLOR_DEFAULT
=
'default'
;
const
COLOR_WARNING
=
'warning'
;
const
COLOR_DANGER
=
'danger'
;
const
COLOR_AUTO_BADNESS
=
'auto_badness'
;
// more = bad! :(
const
COLOR_AUTO_GOODNESS
=
'auto_goodness'
;
// more = good! :)
const
THRESHOLD_DANGER
=
0.85
;
const
THRESHOLD_WARNING
=
0.75
;
abstract
protected
function
getRatio
();
abstract
protected
function
getDefaultColor
();
final
public
function
setColor
(
$color
)
{
$this
->
color
=
$color
;
return
$this
;
}
final
public
function
setCaption
(
$text
)
{
$this
->
caption
=
$text
;
return
$this
;
}
final
protected
function
getColor
()
{
$color
=
$this
->
color
;
if
(!
$color
)
{
$color
=
$this
->
getDefaultColor
();
}
switch
(
$color
)
{
case
self
::
COLOR_DEFAULT
:
case
self
::
COLOR_WARNING
:
case
self
::
COLOR_DANGER
:
return
$color
;
}
$ratio
=
$this
->
getRatio
();
if
(
$color
===
self
::
COLOR_AUTO_GOODNESS
)
{
$ratio
=
1.0
-
$ratio
;
}
if
(
$ratio
>=
self
::
THRESHOLD_DANGER
)
{
return
self
::
COLOR_DANGER
;
}
else
if
(
$ratio
>=
self
::
THRESHOLD_WARNING
)
{
return
self
::
COLOR_WARNING
;
}
else
{
return
self
::
COLOR_DEFAULT
;
}
}
final
protected
function
getCaption
()
{
return
$this
->
caption
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 5, 2:26 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
71858
Default Alt Text
AphrontBarView.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment