Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91336245
PhabricatorDashboardPanelSearchQueryCustomField.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Nov 10, 02:57
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Nov 12, 02:57 (2 d)
Engine
blob
Format
Raw Data
Handle
22245188
Attached To
rPH Phabricator
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
);
}
}
Event Timeline
Log In to Comment