Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97596120
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, Jan 5, 14:09
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jan 7, 14:09 (2 d)
Engine
blob
Format
Raw Data
Handle
23359160
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
PhutilSymbolLoader
())
->
setAncestorClass
(
'PhabricatorApplicationSearchEngine'
)
->
loadObjects
();
$value
=
$this
->
getFieldValue
();
$queries
=
array
();
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