Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F76850434
PhabricatorDashboardPanelTypeQuery.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
Sat, Aug 10, 18:34
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Aug 12, 18:34 (2 d)
Engine
blob
Format
Raw Data
Handle
19779980
Attached To
rPH Phabricator
PhabricatorDashboardPanelTypeQuery.php
View Options
<?php
final
class
PhabricatorDashboardPanelTypeQuery
extends
PhabricatorDashboardPanelType
{
public
function
getPanelTypeKey
()
{
return
'query'
;
}
public
function
getPanelTypeName
()
{
return
pht
(
'Query Panel'
);
}
public
function
getPanelTypeDescription
()
{
return
pht
(
'Show results of a search query, like the most recently filed tasks or '
.
'revisions you need to review.'
);
}
public
function
getFieldSpecifications
()
{
return
array
(
'class'
=>
array
(
'name'
=>
pht
(
'ApplicationSearch Class'
),
'type'
=>
'text'
,
),
'key'
=>
array
(
'name'
=>
pht
(
'ApplicationSearch Key'
),
'type'
=>
'text'
,
),
);
}
protected
function
renderPanelContent
(
PhabricatorUser
$viewer
,
PhabricatorDashboardPanel
$panel
)
{
$class
=
$panel
->
getProperty
(
'class'
);
$engine
=
PhabricatorApplicationSearchEngine
::
getEngineByClassName
(
$class
);
if
(!
$engine
)
{
throw
new
Exception
(
pht
(
'The application search engine "%s" is not known to Phabricator!'
,
$class
));
}
$engine
->
setViewer
(
$viewer
);
$key
=
$panel
->
getProperty
(
'key'
);
if
(
$engine
->
isBuiltinQuery
(
$key
))
{
$saved
=
$engine
->
buildSavedQueryFromBuiltin
(
$key
);
}
else
{
$saved
=
id
(
new
PhabricatorSavedQueryQuery
())
->
setViewer
(
$viewer
)
->
withEngineClassNames
(
array
(
$class
))
->
withQueryKeys
(
array
(
$key
))
->
executeOne
();
}
if
(!
$saved
)
{
throw
new
Exception
(
pht
(
'Query "%s" is unknown to application search engine "%s"!'
,
$key
,
$class
));
}
$query
=
$engine
->
buildQueryFromSavedQuery
(
$saved
);
$results
=
$query
->
setViewer
(
$viewer
)
->
execute
();
$out
=
array
();
foreach
(
$results
as
$result
)
{
$out
[]
=
phutil_tag
(
'div'
,
array
(),
$result
->
getPHID
());
}
return
$out
;
}
}
Event Timeline
Log In to Comment