Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F545798
PhabricatorApplicationDetailViewController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
PhabricatorApplicationDetailViewController.php
View Options
<?php
final
class
PhabricatorApplicationDetailViewController
extends
PhabricatorApplicationsController
{
public
function
shouldAllowPublic
()
{
return
true
;
}
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$this
->
getViewer
();
$application
=
$request
->
getURIData
(
'application'
);
$selected
=
id
(
new
PhabricatorApplicationQuery
())
->
setViewer
(
$viewer
)
->
withClasses
(
array
(
$application
))
->
executeOne
();
if
(!
$selected
)
{
return
new
Aphront404Response
();
}
$title
=
$selected
->
getName
();
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addTextCrumb
(
$selected
->
getName
());
$crumbs
->
setBorder
(
true
);
$header
=
id
(
new
PHUIHeaderView
())
->
setHeader
(
$title
)
->
setUser
(
$viewer
)
->
setPolicyObject
(
$selected
)
->
setHeaderIcon
(
$selected
->
getIcon
());
if
(
$selected
->
isInstalled
())
{
$header
->
setStatus
(
'fa-check'
,
'bluegrey'
,
pht
(
'Installed'
));
}
else
{
$header
->
setStatus
(
'fa-ban'
,
'dark'
,
pht
(
'Uninstalled'
));
}
if
(!
$selected
->
isFirstParty
())
{
$header
->
addTag
(
id
(
new
PHUITagView
())
->
setName
(
'Extension'
)
->
setIcon
(
'fa-plug'
)
->
setColor
(
PHUITagView
::
COLOR_INDIGO
)
->
setType
(
PHUITagView
::
TYPE_SHADE
));
}
if
(
$selected
->
isPrototype
())
{
$header
->
addTag
(
id
(
new
PHUITagView
())
->
setName
(
'Prototype'
)
->
setIcon
(
'fa-exclamation-circle'
)
->
setColor
(
PHUITagView
::
COLOR_ORANGE
)
->
setType
(
PHUITagView
::
TYPE_SHADE
));
}
if
(
$selected
->
isDeprecated
())
{
$header
->
addTag
(
id
(
new
PHUITagView
())
->
setName
(
'Deprecated'
)
->
setIcon
(
'fa-exclamation-triangle'
)
->
setColor
(
PHUITagView
::
COLOR_RED
)
->
setType
(
PHUITagView
::
TYPE_SHADE
));
}
$timeline
=
$this
->
buildTransactionTimeline
(
$selected
,
new
PhabricatorApplicationApplicationTransactionQuery
());
$timeline
->
setShouldTerminate
(
true
);
$curtain
=
$this
->
buildCurtain
(
$selected
);
$details
=
$this
->
buildPropertySectionView
(
$selected
);
$policies
=
$this
->
buildPolicyView
(
$selected
);
$configs
=
PhabricatorApplicationConfigurationPanel
::
loadAllPanelsForApplication
(
$selected
);
$panels
=
array
();
foreach
(
$configs
as
$config
)
{
$config
->
setViewer
(
$viewer
);
$config
->
setApplication
(
$selected
);
$panel
=
$config
->
buildConfigurationPagePanel
();
$panel
->
setBackground
(
PHUIObjectBoxView
::
BLUE_PROPERTY
);
$panels
[]
=
$panel
;
}
$view
=
id
(
new
PHUITwoColumnView
())
->
setHeader
(
$header
)
->
setCurtain
(
$curtain
)
->
setMainColumn
(
array
(
$policies
,
$panels
,
$timeline
,
))
->
addPropertySection
(
pht
(
'Details'
),
$details
);
return
$this
->
newPage
()
->
setTitle
(
$title
)
->
setCrumbs
(
$crumbs
)
->
appendChild
(
array
(
$view
,
));
}
private
function
buildPropertySectionView
(
PhabricatorApplication
$application
)
{
$viewer
=
$this
->
getViewer
();
$properties
=
id
(
new
PHUIPropertyListView
());
$properties
->
addProperty
(
pht
(
'Description'
),
$application
->
getShortDescription
());
if
(
$application
->
getFlavorText
())
{
$properties
->
addProperty
(
null
,
phutil_tag
(
'em'
,
array
(),
$application
->
getFlavorText
()));
}
$phids
=
PhabricatorPHIDType
::
getAllTypesForApplication
(
get_class
(
$application
));
$user_friendly_phids
=
array
();
foreach
(
$phids
as
$phid
=>
$type
)
{
$user_friendly_phids
[]
=
"PHID-{$phid} ({$type->getTypeName()})"
;
}
if
(
$user_friendly_phids
)
{
$properties
->
addProperty
(
'PHIDs'
,
phutil_implode_html
(
phutil_tag
(
'br'
),
$user_friendly_phids
));
}
$monograms
=
$application
->
getMonograms
();
if
(
$monograms
)
{
$properties
->
addProperty
(
'Monograms'
,
phutil_implode_html
(
', '
,
$monograms
));
}
if
(
$application
->
isPrototype
())
{
$proto_href
=
PhabricatorEnv
::
getDoclink
(
'User Guide: Prototype Applications'
);
$learn_more
=
phutil_tag
(
'a'
,
array
(
'href'
=>
$proto_href
,
'target'
=>
'_blank'
,
),
pht
(
'Learn More'
));
$properties
->
addProperty
(
pht
(
'Prototype'
),
pht
(
'This application is a prototype. %s'
,
$learn_more
));
}
$overview
=
$application
->
getOverview
();
if
(
phutil_nonempty_string
(
$overview
))
{
$overview
=
new
PHUIRemarkupView
(
$viewer
,
$overview
);
$properties
->
addSectionHeader
(
pht
(
'Overview'
),
PHUIPropertyListView
::
ICON_SUMMARY
);
$properties
->
addTextContent
(
$overview
);
}
return
$properties
;
}
private
function
buildPolicyView
(
PhabricatorApplication
$application
)
{
$viewer
=
$this
->
getViewer
();
$properties
=
id
(
new
PHUIPropertyListView
());
$header
=
id
(
new
PHUIHeaderView
())
->
setHeader
(
pht
(
'Policies'
));
$descriptions
=
PhabricatorPolicyQuery
::
renderPolicyDescriptions
(
$viewer
,
$application
);
foreach
(
$application
->
getCapabilities
()
as
$capability
)
{
$properties
->
addProperty
(
$application
->
getCapabilityLabel
(
$capability
),
idx
(
$descriptions
,
$capability
));
}
return
id
(
new
PHUIObjectBoxView
())
->
setHeader
(
$header
)
->
setBackground
(
PHUIObjectBoxView
::
BLUE_PROPERTY
)
->
appendChild
(
$properties
);
}
private
function
buildCurtain
(
PhabricatorApplication
$application
)
{
$viewer
=
$this
->
getViewer
();
$can_edit
=
PhabricatorPolicyFilter
::
hasCapability
(
$viewer
,
$application
,
PhabricatorPolicyCapability
::
CAN_EDIT
);
$key
=
get_class
(
$application
);
$edit_uri
=
$this
->
getApplicationURI
(
"edit/{$key}/"
);
$install_uri
=
$this
->
getApplicationURI
(
"{$key}/install/"
);
$uninstall_uri
=
$this
->
getApplicationURI
(
"{$key}/uninstall/"
);
$curtain
=
$this
->
newCurtainView
(
$application
);
$curtain
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Edit Policies'
))
->
setIcon
(
'fa-pencil'
)
->
setDisabled
(!
$can_edit
)
->
setWorkflow
(!
$can_edit
)
->
setHref
(
$edit_uri
));
if
(
$application
->
canUninstall
())
{
if
(
$application
->
isInstalled
())
{
$curtain
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Uninstall'
))
->
setIcon
(
'fa-times'
)
->
setDisabled
(!
$can_edit
)
->
setWorkflow
(
true
)
->
setHref
(
$uninstall_uri
));
}
else
{
$action
=
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Install'
))
->
setIcon
(
'fa-plus'
)
->
setDisabled
(!
$can_edit
)
->
setWorkflow
(
true
)
->
setHref
(
$install_uri
);
$prototypes_enabled
=
PhabricatorEnv
::
getEnvConfig
(
'phabricator.show-prototypes'
);
if
(
$application
->
isPrototype
()
&&
!
$prototypes_enabled
)
{
$action
->
setDisabled
(
true
);
}
$curtain
->
addAction
(
$action
);
}
}
else
{
$curtain
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Uninstall'
))
->
setIcon
(
'fa-times'
)
->
setWorkflow
(
true
)
->
setDisabled
(
true
)
->
setHref
(
$uninstall_uri
));
}
return
$curtain
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:00 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
97811
Default Alt Text
PhabricatorApplicationDetailViewController.php (7 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment