Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F936445
PhabricatorDashboardPanelSearchQueryCustomField.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
PhabricatorDashboardPanelSearchQueryCustomField.php
View Options
<?php
final
class
PhabricatorDashboardPanelSearchQueryCustomField
extends
PhabricatorStandardCustomField
{
public
function
getFieldType
()
{
return
'search.query'
;
}
public
function
shouldAppearInApplicationSearch
()
{
return
false
;
}
public
function
renderEditControl
(
array
$handles
)
{
$engines
=
id
(
new
PhutilClassMapQuery
())
->
setAncestorClass
(
'PhabricatorApplicationSearchEngine'
)
->
setFilterMethod
(
'canUseInPanelContext'
)
->
execute
();
$value
=
$this
->
getFieldValue
();
$queries
=
array
();
$seen
=
false
;
foreach
(
$engines
as
$engine_class
=>
$engine
)
{
$engine
->
setViewer
(
$this
->
getViewer
());
$engine_queries
=
$engine
->
loadEnabledNamedQueries
();
$query_map
=
mpull
(
$engine_queries
,
'getQueryName'
,
'getQueryKey'
);
asort
(
$query_map
);
foreach
(
$query_map
as
$key
=>
$name
)
{
$queries
[
$engine_class
][]
=
array
(
'key'
=>
$key
,
'name'
=>
$name
);
if
(
$key
==
$value
)
{
$seen
=
true
;
}
}
}
if
(
strlen
(
$value
)
&&
!
$seen
)
{
$name
=
pht
(
'Custom Query ("%s")'
,
$value
);
}
else
{
$name
=
pht
(
'(None)'
);
}
$options
=
array
(
$value
=>
$name
);
$app_control_key
=
$this
->
getFieldConfigValue
(
'control.application'
);
Javelin
::
initBehavior
(
'dashboard-query-panel-select'
,
array
(
'applicationID'
=>
$this
->
getFieldControlID
(
$app_control_key
),
'queryID'
=>
$this
->
getFieldControlID
(),
'options'
=>
$queries
,
'value'
=>
array
(
'key'
=>
strlen
(
$value
)
?
$value
:
null
,
'name'
=>
$name
,
),
));
return
id
(
new
AphrontFormSelectControl
())
->
setID
(
$this
->
getFieldControlID
())
->
setLabel
(
$this
->
getFieldName
())
->
setCaption
(
$this
->
getCaption
())
->
setName
(
$this
->
getFieldKey
())
->
setValue
(
$this
->
getFieldValue
())
->
setOptions
(
$options
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jun 17, 1:32 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
221052
Default Alt Text
PhabricatorDashboardPanelSearchQueryCustomField.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment