2012-07-31 01:09:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorMainMenuSearchView extends AphrontView {
|
|
|
|
|
|
|
|
private $scope;
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function setScope($scope) {
|
|
|
|
$this->scope = $scope;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getID() {
|
|
|
|
if (!$this->id) {
|
|
|
|
$this->id = celerity_generate_unique_node_id();
|
|
|
|
}
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$user = $this->user;
|
|
|
|
|
2012-08-01 02:58:21 +02:00
|
|
|
$target_id = celerity_generate_unique_node_id();
|
2012-07-31 01:09:14 +02:00
|
|
|
$search_id = $this->getID();
|
|
|
|
|
2013-01-18 03:39:02 +01:00
|
|
|
$input = phutil_tag(
|
2012-07-31 01:09:14 +02:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'text',
|
|
|
|
'name' => 'query',
|
2012-08-01 02:58:21 +02:00
|
|
|
'id' => $search_id,
|
|
|
|
'autocomplete' => 'off',
|
2012-07-31 01:09:14 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
$scope = $this->scope;
|
|
|
|
|
2013-01-25 21:57:17 +01:00
|
|
|
$target = javelin_tag(
|
2012-08-01 02:58:21 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => $target_id,
|
|
|
|
'class' => 'phabricator-main-menu-search-target',
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
2012-07-31 01:09:14 +02:00
|
|
|
Javelin::initBehavior(
|
2012-08-01 02:58:21 +02:00
|
|
|
'phabricator-search-typeahead',
|
2012-07-31 01:09:14 +02:00
|
|
|
array(
|
2012-08-01 02:58:21 +02:00
|
|
|
'id' => $target_id,
|
|
|
|
'input' => $search_id,
|
|
|
|
'src' => '/typeahead/common/mainsearch/',
|
|
|
|
'limit' => 10,
|
|
|
|
'placeholder' => PhabricatorSearchScope::getScopePlaceholder($scope),
|
2012-07-31 01:09:14 +02:00
|
|
|
));
|
|
|
|
|
2013-01-18 03:39:02 +01:00
|
|
|
$scope_input = phutil_tag(
|
2012-07-31 01:09:14 +02:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'scope',
|
|
|
|
'value' => $scope,
|
|
|
|
));
|
|
|
|
|
|
|
|
$form = phabricator_render_form(
|
|
|
|
$user,
|
|
|
|
array(
|
|
|
|
'action' => '/search/',
|
|
|
|
'method' => 'POST',
|
|
|
|
),
|
|
|
|
'<div class="phabricator-main-menu-search-container">'.
|
|
|
|
$input.
|
|
|
|
'<button>Search</button>'.
|
|
|
|
$scope_input.
|
2012-08-01 02:58:21 +02:00
|
|
|
$target.
|
2012-07-31 01:09:14 +02:00
|
|
|
'</div>');
|
|
|
|
|
2012-12-07 22:33:03 +01:00
|
|
|
return $form;
|
2012-07-31 01:09:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|