Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93832251
DivinerAtomSearchEngine.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, Dec 1, 21:01
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Dec 3, 21:01 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22711993
Attached To
rPH Phabricator
DivinerAtomSearchEngine.php
View Options
<?php
final
class
DivinerAtomSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
getApplicationClassName
()
{
return
'PhabricatorApplicationDiviner'
;
}
public
function
buildSavedQueryFromRequest
(
AphrontRequest
$request
)
{
$saved
=
new
PhabricatorSavedQuery
();
$saved
->
setParameter
(
'types'
,
$this
->
readListFromRequest
(
$request
,
'types'
));
$saved
->
setParameter
(
'name'
,
$request
->
getStr
(
'name'
));
return
$saved
;
}
public
function
buildQueryFromSavedQuery
(
PhabricatorSavedQuery
$saved
)
{
$query
=
id
(
new
DivinerAtomQuery
());
$types
=
$saved
->
getParameter
(
'types'
);
if
(
$types
)
{
$query
->
withTypes
(
$types
);
}
$name
=
$saved
->
getParameter
(
'name'
);
if
(
$name
)
{
$query
->
withNameContains
(
$name
);
}
return
$query
;
}
public
function
buildSearchForm
(
AphrontFormView
$form
,
PhabricatorSavedQuery
$saved
)
{
$all_types
=
array
();
foreach
(
DivinerAtom
::
getAllTypes
()
as
$type
)
{
$all_types
[
$type
]
=
DivinerAtom
::
getAtomTypeNameString
(
$type
);
}
asort
(
$all_types
);
$types
=
$saved
->
getParameter
(
'types'
,
array
());
$types
=
array_fuse
(
$types
);
$type_control
=
id
(
new
AphrontFormCheckboxControl
())
->
setLabel
(
pht
(
'Types'
));
foreach
(
$all_types
as
$type
=>
$name
)
{
$type_control
->
addCheckbox
(
'types[]'
,
$type
,
$name
,
isset
(
$types
[
$type
]));
}
$form
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setLabel
(
pht
(
'Name Contains'
))
->
setName
(
'name'
)
->
setValue
(
$saved
->
getParameter
(
'name'
)))
->
appendChild
(
$type_control
);
}
protected
function
getURI
(
$path
)
{
return
'/diviner/'
.
$path
;
}
public
function
getBuiltinQueryNames
()
{
$names
=
array
(
'all'
=>
pht
(
'All'
),
);
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
();
$query
->
setQueryKey
(
$query_key
);
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
);
}
protected
function
renderResultList
(
array
$symbols
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
assert_instances_of
(
$symbols
,
'DivinerLiveSymbol'
);
$viewer
=
$this
->
requireViewer
();
$list
=
id
(
new
PHUIObjectItemListView
())
->
setUser
(
$viewer
);
foreach
(
$symbols
as
$symbol
)
{
$type
=
$symbol
->
getType
();
$type_name
=
DivinerAtom
::
getAtomTypeNameString
(
$type
);
$item
=
id
(
new
PHUIObjectItemView
())
->
setHeader
(
$symbol
->
getTitle
())
->
setHref
(
$symbol
->
getURI
())
->
addAttribute
(
$symbol
->
getSummary
())
->
addIcon
(
'none'
,
$type_name
);
$list
->
addItem
(
$item
);
}
return
$list
;
}
}
Event Timeline
Log In to Comment