Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100745815
PhabricatorPhurlURLSearchEngine.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, Feb 2, 09:57
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Feb 4, 09:57 (2 d)
Engine
blob
Format
Raw Data
Handle
24023675
Attached To
rPH Phabricator
PhabricatorPhurlURLSearchEngine.php
View Options
<?php
final
class
PhabricatorPhurlURLSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
getResultTypeDescription
()
{
return
pht
(
'Shortened URLs'
);
}
public
function
getApplicationClassName
()
{
return
'PhabricatorPhurlApplication'
;
}
public
function
newQuery
()
{
return
new
PhabricatorPhurlURLQuery
();
}
protected
function
shouldShowOrderField
()
{
return
true
;
}
protected
function
buildCustomSearchFields
()
{
return
array
(
id
(
new
PhabricatorSearchDatasourceField
())
->
setLabel
(
pht
(
'Created By'
))
->
setKey
(
'authorPHIDs'
)
->
setDatasource
(
new
PhabricatorPeopleUserFunctionDatasource
()),
);
}
protected
function
buildQueryFromParameters
(
array
$map
)
{
$query
=
$this
->
newQuery
();
if
(
$map
[
'authorPHIDs'
])
{
$query
->
withAuthorPHIDs
(
$map
[
'authorPHIDs'
]);
}
return
$query
;
}
protected
function
getURI
(
$path
)
{
return
'/phurl/'
.
$path
;
}
protected
function
getBuiltinQueryNames
()
{
$names
=
array
(
'authored'
=>
pht
(
'Authored'
),
'all'
=>
pht
(
'All URLs'
),
);
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
();
$query
->
setQueryKey
(
$query_key
);
$viewer
=
$this
->
requireViewer
();
switch
(
$query_key
)
{
case
'authored'
:
return
$query
->
setParameter
(
'authorPHIDs'
,
array
(
$viewer
->
getPHID
()));
case
'all'
:
return
$query
;
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
);
}
protected
function
renderResultList
(
array
$urls
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
assert_instances_of
(
$urls
,
'PhabricatorPhurlURL'
);
$viewer
=
$this
->
requireViewer
();
$list
=
new
PHUIObjectItemListView
();
$handles
=
$viewer
->
loadHandles
(
mpull
(
$urls
,
'getAuthorPHID'
));
foreach
(
$urls
as
$url
)
{
$item
=
id
(
new
PHUIObjectItemView
())
->
setUser
(
$viewer
)
->
setObject
(
$url
)
->
setHeader
(
$viewer
->
renderHandle
(
$url
->
getPHID
()));
$list
->
addItem
(
$item
);
}
$result
=
new
PhabricatorApplicationSearchResultView
();
$result
->
setObjectList
(
$list
);
$result
->
setNoDataString
(
pht
(
'No URLs found.'
));
return
$result
;
}
}
Event Timeline
Log In to Comment