Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2363113
AphrontView.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
AphrontView.php
View Options
<?php
abstract
class
AphrontView
extends
Phobject
{
protected
$user
;
protected
$children
=
array
();
public
function
setUser
(
PhabricatorUser
$user
)
{
$this
->
user
=
$user
;
return
$this
;
}
protected
function
getUser
()
{
return
$this
->
user
;
}
protected
function
canAppendChild
()
{
return
true
;
}
final
public
function
appendChild
(
$child
)
{
if
(!
$this
->
canAppendChild
())
{
$class
=
get_class
(
$this
);
throw
new
Exception
(
"View '{$class}' does not support children."
);
}
$this
->
children
[]
=
$child
;
return
$this
;
}
final
protected
function
renderChildren
()
{
$out
=
array
();
foreach
(
$this
->
children
as
$child
)
{
$out
[]
=
$this
->
renderSingleView
(
$child
);
}
return
implode
(
''
,
$out
);
}
final
protected
function
renderHTMLChildren
()
{
$out
=
array
();
foreach
(
$this
->
children
as
$child
)
{
$out
[]
=
$this
->
renderHTMLView
(
$child
);
}
return
$out
;
}
final
protected
function
renderSingleView
(
$child
)
{
if
(
$child
instanceof
AphrontView
)
{
return
$child
->
render
();
}
else
if
(
is_array
(
$child
))
{
$out
=
array
();
foreach
(
$child
as
$element
)
{
$out
[]
=
$this
->
renderSingleView
(
$element
);
}
return
implode
(
''
,
$out
);
}
else
{
return
$child
;
}
}
final
protected
function
renderHTMLView
(
$child
)
{
if
(
$child
instanceof
AphrontView
)
{
return
phutil_safe_html
(
$child
->
render
());
}
else
if
(
$child
instanceof
PhutilSafeHTML
)
{
return
$child
;
}
else
if
(
is_array
(
$child
))
{
$out
=
array
();
foreach
(
$child
as
$element
)
{
$out
[]
=
$this
->
renderHTMLView
(
$element
);
}
return
phutil_safe_html
(
implode
(
''
,
$out
));
}
else
{
return
phutil_safe_html
(
phutil_escape_html
(
$child
));
}
}
final
protected
function
isEmptyContent
(
$content
)
{
if
(
is_array
(
$content
))
{
foreach
(
$content
as
$element
)
{
if
(!
$this
->
isEmptyContent
(
$element
))
{
return
false
;
}
}
return
true
;
}
else
{
return
!
strlen
((
string
)
$content
);
}
}
abstract
public
function
render
();
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Sep 16, 4:54 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
437921
Default Alt Text
AphrontView.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment