Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2895800
SemiStructuredObjectTypeSearchEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
SemiStructuredObjectTypeSearchEngine.php
View Options
<?php
final
class
SemiStructuredObjectTypeSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
getResultTypeDescription
(
)
{
return
pht
(
'Object Types'
)
;
}
public
function
getApplicationClassName
(
)
{
return
'SemiStructuredDataApplication'
;
}
public
function
newQuery
(
)
{
return
id
(
new
SemiStructuredObjectTypeQuery
(
)
)
;
}
protected
function
buildCustomSearchFields
(
)
{
return
array
(
id
(
new
PhabricatorSearchCheckboxesField
(
)
)
->
setKey
(
'statuses'
)
->
setLabel
(
pht
(
'Status'
)
)
->
setOptions
(
PhabricatorDashboard
::
getStatusNameMap
(
)
)
,
id
(
new
PhabricatorSearchCheckboxesField
(
)
)
->
setKey
(
'editable'
)
->
setLabel
(
pht
(
'Editable'
)
)
->
setOptions
(
array
(
'editable'
=>
null
)
)
,
)
;
}
protected
function
getURI
(
$path
)
{
return
'/semistruct/'
.
$path
;
}
protected
function
getBuiltinQueryNames
(
)
{
$names
=
array
(
)
;
$names
[
'all'
]
=
pht
(
'All Types'
)
;
$names
[
'open'
]
=
pht
(
'Active Types'
)
;
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
(
)
;
$query
->
setQueryKey
(
$query_key
)
;
$viewer
=
$this
->
requireViewer
(
)
;
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
case
'open'
:
return
$query
->
setParameter
(
'statuses'
,
array
(
SemiStructuredObjectType
::
STATUS_ACTIVE
,
)
)
;
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
)
;
}
protected
function
buildQueryFromParameters
(
array
$map
)
{
$query
=
$this
->
newQuery
(
)
;
if
(
$map
[
'statuses'
]
)
{
$query
->
withStatuses
(
$map
[
'statuses'
]
)
;
}
if
(
$map
[
'editable'
]
!==
null
)
{
$query
->
withCanEdit
(
$map
[
'editable'
]
)
;
}
return
$query
;
}
protected
function
renderResultList
(
array
$items
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
$viewer
=
$this
->
requireViewer
(
)
;
$phids
=
array
(
)
;
foreach
(
$items
as
$item
)
{
// $author_phid = $dashboard->getAuthorPHID();
// if ($author_phid) {
// $phids[] = $author_phid;
// }
}
$handles
=
$viewer
->
loadHandles
(
$phids
)
;
if
(
$items
)
{
$edge_query
=
id
(
new
PhabricatorEdgeQuery
(
)
)
->
withSourcePHIDs
(
mpull
(
$items
,
'getPHID'
)
)
->
withEdgeTypes
(
array
(
PhabricatorProjectObjectHasProjectEdgeType
::
EDGECONST
,
)
)
;
$edge_query
->
execute
(
)
;
}
$list
=
id
(
new
PHUIObjectItemListView
(
)
)
->
setViewer
(
$viewer
)
;
foreach
(
$items
as
$item
)
{
$item
=
id
(
new
PHUIObjectItemView
(
)
)
->
setViewer
(
$viewer
)
->
setObjectName
(
$item
->
getObjectName
(
)
)
->
setHeader
(
$item
->
getName
(
)
)
->
setHref
(
$item
->
getURI
(
)
)
->
setObject
(
$item
)
;
if
(
$item
->
isArchived
(
)
)
{
$item
->
setDisabled
(
true
)
;
$bg_color
=
'bg-grey'
;
}
else
{
$bg_color
=
'bg-dark'
;
}
$icon
=
id
(
new
PHUIIconView
(
)
)
->
setIcon
(
$item
->
getIcon
(
)
)
->
setBackground
(
$bg_color
)
;
$item
->
setImageIcon
(
$icon
)
;
$item
->
setEpoch
(
$item
->
getDateModified
(
)
)
;
$phid
=
$item
->
getPHID
(
)
;
$project_phids
=
$edge_query
->
getDestinationPHIDs
(
array
(
$phid
)
)
;
$project_handles
=
$viewer
->
loadHandles
(
$project_phids
)
;
$item
->
addAttribute
(
id
(
new
PHUIHandleTagListView
(
)
)
->
setLimit
(
4
)
->
setNoDataString
(
pht
(
'No Tags'
)
)
->
setSlim
(
true
)
->
setHandles
(
$project_handles
)
)
;
$list
->
addItem
(
$item
)
;
}
$result
=
new
PhabricatorApplicationSearchResultView
(
)
;
$result
->
setObjectList
(
$list
)
;
$result
->
setNoDataString
(
pht
(
'No object types found.'
)
)
;
return
$result
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 22:04 (6 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129214
Default Alt Text
SemiStructuredObjectTypeSearchEngine.php (3 KB)
Attached To
Mode
R6 Semi Structured
Attached
Detach File
Event Timeline
Log In to Comment