Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99029519
LegalpadDocumentSearchEngine.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
Sat, Jan 18, 14:30
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Jan 20, 14:30 (2 d)
Engine
blob
Format
Raw Data
Handle
23693677
Attached To
rPH Phabricator
LegalpadDocumentSearchEngine.php
View Options
<?php
/**
* @group legalpad
*/
final
class
LegalpadDocumentSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
buildSavedQueryFromRequest
(
AphrontRequest
$request
)
{
$saved
=
new
PhabricatorSavedQuery
();
$saved
->
setParameter
(
'creatorPHIDs'
,
$this
->
readUsersFromRequest
(
$request
,
'creators'
));
$saved
->
setParameter
(
'contributorPHIDs'
,
$this
->
readUsersFromRequest
(
$request
,
'contributors'
));
$saved
->
setParameter
(
'createdStart'
,
$request
->
getStr
(
'createdStart'
));
$saved
->
setParameter
(
'createdEnd'
,
$request
->
getStr
(
'createdEnd'
));
return
$saved
;
}
public
function
buildQueryFromSavedQuery
(
PhabricatorSavedQuery
$saved
)
{
$query
=
id
(
new
LegalpadDocumentQuery
())
->
withCreatorPHIDs
(
$saved
->
getParameter
(
'creatorPHIDs'
,
array
()))
->
withContributorPHIDs
(
$saved
->
getParameter
(
'contributorPHIDs'
,
array
()));
$start
=
$this
->
parseDateTime
(
$saved
->
getParameter
(
'createdStart'
));
$end
=
$this
->
parseDateTime
(
$saved
->
getParameter
(
'createdEnd'
));
if
(
$start
)
{
$query
->
withDateCreatedAfter
(
$start
);
}
if
(
$end
)
{
$query
->
withDateCreatedBefore
(
$end
);
}
return
$query
;
}
public
function
buildSearchForm
(
AphrontFormView
$form
,
PhabricatorSavedQuery
$saved_query
)
{
$creator_phids
=
$saved_query
->
getParameter
(
'creatorPHIDs'
,
array
());
$contributor_phids
=
$saved_query
->
getParameter
(
'contributorPHIDs'
,
array
());
$phids
=
array_merge
(
$creator_phids
,
$contributor_phids
);
$handles
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$this
->
requireViewer
())
->
withPHIDs
(
$phids
)
->
execute
();
$form
->
appendChild
(
id
(
new
AphrontFormTokenizerControl
())
->
setDatasource
(
'/typeahead/common/users/'
)
->
setName
(
'creators'
)
->
setLabel
(
pht
(
'Creators'
))
->
setValue
(
array_select_keys
(
$handles
,
$creator_phids
)))
->
appendChild
(
id
(
new
AphrontFormTokenizerControl
())
->
setDatasource
(
'/typeahead/common/users/'
)
->
setName
(
'contributors'
)
->
setLabel
(
pht
(
'Contributors'
))
->
setValue
(
array_select_keys
(
$handles
,
$contributor_phids
)));
$this
->
buildDateRange
(
$form
,
$saved_query
,
'createdStart'
,
pht
(
'Created After'
),
'createdEnd'
,
pht
(
'Created Before'
));
}
protected
function
getURI
(
$path
)
{
return
'/legalpad/'
.
$path
;
}
public
function
getBuiltinQueryNames
()
{
$names
=
array
(
'all'
=>
pht
(
'All Documents'
),
);
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
();
$query
->
setQueryKey
(
$query_key
);
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
);
}
}
Event Timeline
Log In to Comment