Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100491156
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
Fri, Jan 31, 05:31
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 2, 05:31 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23979367
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