~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to phabricator/src/applications/files/query/PhabricatorFileSearchEngine.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-06-13 10:52:10 UTC
  • mfrom: (0.30.1) (0.29.1) (0.17.4) (2.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20150613105210-5uirr7tvnk0n6e6y
Tags: 0~git20150613-1
* New snapshot release (closes: #787805)
* fixed typo in logrotate script (closes: #787645)

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    return 'PhabricatorFilesApplication';
12
12
  }
13
13
 
14
 
  public function buildSavedQueryFromRequest(AphrontRequest $request) {
15
 
    $saved = new PhabricatorSavedQuery();
16
 
    $saved->setParameter(
17
 
      'authorPHIDs',
18
 
      $this->readUsersFromRequest($request, 'authors'));
19
 
 
20
 
    $saved->setParameter('explicit', $request->getBool('explicit'));
21
 
    $saved->setParameter('createdStart', $request->getStr('createdStart'));
22
 
    $saved->setParameter('createdEnd', $request->getStr('createdEnd'));
23
 
 
24
 
    return $saved;
25
 
  }
26
 
 
27
 
  public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
28
 
    $query = id(new PhabricatorFileQuery());
29
 
 
30
 
    $author_phids = $saved->getParameter('authorPHIDs', array());
31
 
    if ($author_phids) {
32
 
      $query->withAuthorPHIDs($author_phids);
33
 
    }
34
 
 
35
 
    if ($saved->getParameter('explicit')) {
36
 
      $query->showOnlyExplicitUploads(true);
37
 
    }
38
 
 
39
 
    $start = $this->parseDateTime($saved->getParameter('createdStart'));
40
 
    $end = $this->parseDateTime($saved->getParameter('createdEnd'));
41
 
 
42
 
    if ($start) {
43
 
      $query->withDateCreatedAfter($start);
44
 
    }
45
 
 
46
 
    if ($end) {
47
 
      $query->withDateCreatedBefore($end);
48
 
    }
49
 
 
50
 
    return $query;
51
 
  }
52
 
 
53
 
  public function buildSearchForm(
54
 
    AphrontFormView $form,
55
 
    PhabricatorSavedQuery $saved_query) {
56
 
 
57
 
    $author_phids = $saved_query->getParameter('authorPHIDs', array());
58
 
    $explicit = $saved_query->getParameter('explicit');
59
 
 
60
 
    $form
61
 
      ->appendControl(
62
 
        id(new AphrontFormTokenizerControl())
63
 
          ->setDatasource(new PhabricatorPeopleDatasource())
64
 
          ->setName('authors')
65
 
          ->setLabel(pht('Authors'))
66
 
          ->setValue($author_phids))
67
 
      ->appendChild(
68
 
        id(new AphrontFormCheckboxControl())
69
 
          ->addCheckbox(
70
 
            'explicit',
71
 
            1,
72
 
            pht('Show only manually uploaded files.'),
73
 
            $explicit));
74
 
 
75
 
    $this->buildDateRange(
76
 
      $form,
77
 
      $saved_query,
 
14
  public function newQuery() {
 
15
    return new PhabricatorFileQuery();
 
16
  }
 
17
 
 
18
  protected function buildCustomSearchFields() {
 
19
    return array(
 
20
      id(new PhabricatorSearchUsersField())
 
21
        ->setKey('authorPHIDs')
 
22
        ->setAliases(array('author', 'authors'))
 
23
        ->setLabel(pht('Authors')),
 
24
      id(new PhabricatorSearchThreeStateField())
 
25
        ->setKey('explicit')
 
26
        ->setLabel(pht('Upload Source'))
 
27
        ->setOptions(
 
28
          pht('(Show All)'),
 
29
          pht('Show Only Manually Uploaded Files'),
 
30
          pht('Hide Manually Uploaded Files')),
 
31
      id(new PhabricatorSearchDateField())
 
32
        ->setKey('createdStart')
 
33
        ->setLabel(pht('Created After')),
 
34
      id(new PhabricatorSearchDateField())
 
35
        ->setKey('createdEnd')
 
36
        ->setLabel(pht('Created Before')),
 
37
    );
 
38
  }
 
39
 
 
40
  protected function getDefaultFieldOrder() {
 
41
    return array(
 
42
      '...',
78
43
      'createdStart',
79
 
      pht('Created After'),
80
44
      'createdEnd',
81
 
      pht('Created Before'));
 
45
    );
 
46
  }
 
47
 
 
48
  protected function buildQueryFromParameters(array $map) {
 
49
    $query = $this->newQuery();
 
50
 
 
51
    if ($map['authorPHIDs']) {
 
52
      $query->withAuthorPHIDs($map['authorPHIDs']);
 
53
    }
 
54
 
 
55
    if ($map['explicit'] !== null) {
 
56
      $query->showOnlyExplicitUploads($map['explicit']);
 
57
    }
 
58
 
 
59
    if ($map['createdStart']) {
 
60
      $query->withDateCreatedAfter($map['createdStart']);
 
61
    }
 
62
 
 
63
    if ($map['createdEnd']) {
 
64
      $query->withDateCreatedBefore($map['createdEnd']);
 
65
    }
 
66
 
 
67
    return $query;
82
68
  }
83
69
 
84
70
  protected function getURI($path) {