Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91424470
ProjectDatasourceEngineExtension.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, Nov 10, 23:45
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Nov 12, 23:45 (2 d)
Engine
blob
Format
Raw Data
Handle
22261308
Attached To
rPH Phabricator
ProjectDatasourceEngineExtension.php
View Options
<?php
final
class
ProjectDatasourceEngineExtension
extends
PhabricatorDatasourceEngineExtension
{
public
function
newQuickSearchDatasources
()
{
return
array
(
new
PhabricatorProjectDatasource
(),
);
}
public
function
newJumpURI
(
$query
)
{
$viewer
=
$this
->
getViewer
();
// Send "p" to Projects.
if
(
preg_match
(
'/^p
\z
/i'
,
$query
))
{
return
'/diffusion/'
;
}
// Send "p <string>" to a search for similar projects.
$matches
=
null
;
if
(
preg_match
(
'/^p
\s
+(.+)
\z
/i'
,
$query
,
$matches
))
{
$raw_query
=
$matches
[
1
];
$engine
=
id
(
new
PhabricatorProject
())
->
newFerretEngine
();
$compiler
=
id
(
new
PhutilSearchQueryCompiler
())
->
setEnableFunctions
(
true
);
$raw_tokens
=
$compiler
->
newTokens
(
$raw_query
);
$fulltext_tokens
=
array
();
foreach
(
$raw_tokens
as
$raw_token
)
{
$fulltext_token
=
id
(
new
PhabricatorFulltextToken
())
->
setToken
(
$raw_token
);
$fulltext_tokens
[]
=
$fulltext_token
;
}
$projects
=
id
(
new
PhabricatorProjectQuery
())
->
setViewer
(
$viewer
)
->
withFerretConstraint
(
$engine
,
$fulltext_tokens
)
->
execute
();
if
(
count
(
$projects
)
==
1
)
{
// Just one match, jump to project.
return
head
(
$projects
)->
getURI
();
}
else
{
// More than one match, jump to search.
return
urisprintf
(
'/project/?order=relevance&query=%s#R'
,
$raw_query
);
}
}
return
null
;
}
}
Event Timeline
Log In to Comment