Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/engine/PhabricatorJumpNavHandler.php
Show All 9 Lines | $patterns = array( | ||||
'/^f$/i' => 'uri:/feed/', | '/^f$/i' => 'uri:/feed/', | ||||
'/^d$/i' => 'uri:/differential/', | '/^d$/i' => 'uri:/differential/', | ||||
'/^r$/i' => 'uri:/diffusion/', | '/^r$/i' => 'uri:/diffusion/', | ||||
'/^t$/i' => 'uri:/maniphest/', | '/^t$/i' => 'uri:/maniphest/', | ||||
'/^p$/i' => 'uri:/project/', | '/^p$/i' => 'uri:/project/', | ||||
'/^u$/i' => 'uri:/people/', | '/^u$/i' => 'uri:/people/', | ||||
'/^p\s+(.+)$/i' => 'project', | '/^p\s+(.+)$/i' => 'project', | ||||
'/^u\s+(\S+)$/i' => 'user', | '/^u\s+(\S+)$/i' => 'user', | ||||
'/^task:\s*(.+)/i' => 'create-task', | |||||
'/^(?:s)\s+(\S+)/i' => 'find-symbol', | '/^(?:s)\s+(\S+)/i' => 'find-symbol', | ||||
'/^r\s+(.+)$/i' => 'find-repository', | '/^r\s+(.+)$/i' => 'find-repository', | ||||
); | ); | ||||
foreach ($patterns as $pattern => $effect) { | foreach ($patterns as $pattern => $effect) { | ||||
$matches = null; | $matches = null; | ||||
if (preg_match($pattern, $jump, $matches)) { | if (preg_match($pattern, $jump, $matches)) { | ||||
if (!strncmp($effect, 'uri:', 4)) { | if (!strncmp($effect, 'uri:', 4)) { | ||||
Show All 32 Lines | foreach ($patterns as $pattern => $effect) { | ||||
if (count($repositories) == 1) { | if (count($repositories) == 1) { | ||||
// Just one match, jump to repository. | // Just one match, jump to repository. | ||||
$uri = '/diffusion/'.head($repositories)->getCallsign().'/'; | $uri = '/diffusion/'.head($repositories)->getCallsign().'/'; | ||||
} else { | } else { | ||||
// More than one match, jump to search. | // More than one match, jump to search. | ||||
$uri = urisprintf('/diffusion/?order=name&name=%s', $name); | $uri = urisprintf('/diffusion/?order=name&name=%s', $name); | ||||
} | } | ||||
return id(new AphrontRedirectResponse())->setURI($uri); | return id(new AphrontRedirectResponse())->setURI($uri); | ||||
case 'create-task': | |||||
return id(new AphrontRedirectResponse()) | |||||
->setURI('/maniphest/editpro/?title=' | |||||
.phutil_escape_uri($matches[1])); | |||||
default: | default: | ||||
throw new Exception(pht("Unknown jump effect '%s'!", $effect)); | throw new Exception(pht("Unknown jump effect '%s'!", $effect)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// If none of the patterns matched, look for an object by name. | // If none of the patterns matched, look for an object by name. | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |