Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/files/controller/PhabricatorFileListController.php b/src/applications/files/controller/PhabricatorFileListController.php
index d3c1322607..3f307569b8 100644
--- a/src/applications/files/controller/PhabricatorFileListController.php
+++ b/src/applications/files/controller/PhabricatorFileListController.php
@@ -1,83 +1,83 @@
<?php
final class PhabricatorFileListController extends PhabricatorFileController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $key;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
- $this->key = idx($data, 'key', 'authored');
+ $this->key = idx($data, 'key');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->key)
->setSearchEngine(new PhabricatorFileSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(array $files) {
assert_instances_of($files, 'PhabricatorFile');
$request = $this->getRequest();
$user = $request->getUser();
$highlighted_ids = $request->getStrList('h');
$this->loadHandles(mpull($files, 'getAuthorPHID'));
$request = $this->getRequest();
$user = $request->getUser();
$highlighted_ids = array_fill_keys($highlighted_ids, true);
$list_view = id(new PhabricatorObjectItemListView())
->setUser($user);
foreach ($files as $file) {
$id = $file->getID();
$phid = $file->getPHID();
$name = $file->getName();
$file_uri = $this->getApplicationURI("/info/{$phid}/");
$date_created = phabricator_date($file->getDateCreated(), $user);
$author_phid = $file->getAuthorPHID();
if ($author_phid) {
$author_link = $this->getHandle($author_phid)->renderLink();
$uploaded = pht('Uploaded by %s on %s', $author_link, $date_created);
} else {
$uploaded = pht('Uploaded on %s', $date_created);
}
$item = id(new PhabricatorObjectItemView())
->setObject($file)
->setObjectName("F{$id}")
->setHeader($name)
->setHref($file_uri)
->addAttribute($uploaded)
->addIcon('none', phabricator_format_bytes($file->getByteSize()));
$ttl = $file->getTTL();
if ($ttl !== null) {
$item->addIcon('blame', pht('Temporary'));
}
if (isset($highlighted_ids[$id])) {
$item->setEffect('highlighted');
}
$list_view->addItem($item);
}
$list_view->appendChild(new PhabricatorGlobalUploadTargetView());
return $list_view;
}
}
diff --git a/src/applications/macro/controller/PhabricatorMacroListController.php b/src/applications/macro/controller/PhabricatorMacroListController.php
index 95a0ab1f41..e1f03fd574 100644
--- a/src/applications/macro/controller/PhabricatorMacroListController.php
+++ b/src/applications/macro/controller/PhabricatorMacroListController.php
@@ -1,83 +1,83 @@
<?php
final class PhabricatorMacroListController extends PhabricatorMacroController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $key;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
- $this->key = idx($data, 'key', 'active');
+ $this->key = idx($data, 'key');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->key)
->setSearchEngine(new PhabricatorMacroSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(array $macros) {
assert_instances_of($macros, 'PhabricatorFileImageMacro');
$viewer = $this->getRequest()->getUser();
$author_phids = mpull($macros, 'getAuthorPHID', 'getAuthorPHID');
$this->loadHandles($author_phids);
$author_handles = array_select_keys(
$this->getLoadedHandles(),
$author_phids);
$pinboard = new PhabricatorPinboardView();
foreach ($macros as $macro) {
$file = $macro->getFile();
$item = new PhabricatorPinboardItemView();
if ($file) {
$item->setImageURI($file->getThumb280x210URI());
$item->setImageSize(280, 210);
}
if ($macro->getDateCreated()) {
$datetime = phabricator_date($macro->getDateCreated(), $viewer);
$item->appendChild(
phutil_tag(
'div',
array(),
pht('Created on %s', $datetime)));
} else {
// Very old macros don't have a creation date. Rendering something
// keeps all the pins at the same height and avoids flow issues.
$item->appendChild(
phutil_tag(
'div',
array(),
pht('Created in ages long past')));
}
if ($macro->getAuthorPHID()) {
$author_handle = $this->getHandle($macro->getAuthorPHID());
$item->appendChild(
pht('Created by %s', $author_handle->renderLink()));
}
$item->setURI($this->getApplicationURI('/view/'.$macro->getID().'/'));
$name = $macro->getName();
if ($macro->getIsDisabled()) {
$name = pht('%s (Disabled)', $name);
}
$item->setHeader($name);
$pinboard->addItem($item);
}
return $pinboard;
}
}
diff --git a/src/applications/paste/controller/PhabricatorPasteListController.php b/src/applications/paste/controller/PhabricatorPasteListController.php
index 385e0ecc8c..7e4f972490 100644
--- a/src/applications/paste/controller/PhabricatorPasteListController.php
+++ b/src/applications/paste/controller/PhabricatorPasteListController.php
@@ -1,77 +1,77 @@
<?php
final class PhabricatorPasteListController extends PhabricatorPasteController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
- $this->queryKey = idx($data, 'queryKey', 'all');
+ $this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new PhabricatorPasteSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(array $pastes) {
assert_instances_of($pastes, 'PhabricatorPaste');
$user = $this->getRequest()->getUser();
$this->loadHandles(mpull($pastes, 'getAuthorPHID'));
$lang_map = PhabricatorEnv::getEnvConfig('pygments.dropdown-choices');
$list = new PhabricatorObjectItemListView();
$list->setUser($user);
foreach ($pastes as $paste) {
$created = phabricator_date($paste->getDateCreated(), $user);
$author = $this->getHandle($paste->getAuthorPHID())->renderLink();
$source_code = $this->buildSourceCodeView($paste, 5)->render();
$source_code = phutil_tag(
'div',
array(
'class' => 'phabricator-source-code-summary',
),
$source_code);
$line_count = count(explode("\n", $paste->getContent()));
$line_count = pht(
'%s Line(s)',
new PhutilNumber($line_count));
$title = nonempty($paste->getTitle(), pht('(An Untitled Masterwork)'));
$item = id(new PhabricatorObjectItemView())
->setObjectName('P'.$paste->getID())
->setHeader($title)
->setHref('/P'.$paste->getID())
->setObject($paste)
->addByline(pht('Author: %s', $author))
->addIcon('none', $line_count)
->appendChild($source_code);
$lang_name = $paste->getLanguage();
if ($lang_name) {
$lang_name = idx($lang_map, $lang_name, $lang_name);
$item->addIcon('none', $lang_name);
}
$list->addItem($item);
}
return $list;
}
}
diff --git a/src/applications/people/controller/PhabricatorPeopleListController.php b/src/applications/people/controller/PhabricatorPeopleListController.php
index beda82486d..b81397003c 100644
--- a/src/applications/people/controller/PhabricatorPeopleListController.php
+++ b/src/applications/people/controller/PhabricatorPeopleListController.php
@@ -1,82 +1,82 @@
<?php
final class PhabricatorPeopleListController extends PhabricatorPeopleController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $key;
public function shouldAllowPublic() {
return true;
}
public function shouldRequireAdmin() {
return false;
}
public function willProcessRequest(array $data) {
- $this->key = idx($data, 'key', 'all');
+ $this->key = idx($data, 'key');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->key)
->setSearchEngine(new PhabricatorPeopleSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(array $users) {
assert_instances_of($users, 'PhabricatorUser');
$request = $this->getRequest();
$viewer = $request->getUser();
$list = new PhabricatorObjectItemListView();
foreach ($users as $user) {
$primary_email = $user->loadPrimaryEmail();
if ($primary_email && $primary_email->getIsVerified()) {
$email = pht('Verified');
} else {
$email = pht('Unverified');
}
$user_handle = new PhabricatorObjectHandle();
$user_handle->setImageURI($user->loadProfileImageURI());
$item = new PhabricatorObjectItemView();
$item->setHeader($user->getFullName())
->setHref('/p/'.$user->getUsername().'/')
->addAttribute(hsprintf('%s %s',
phabricator_date($user->getDateCreated(), $viewer),
phabricator_time($user->getDateCreated(), $viewer)))
->addAttribute($email);
if ($user->getIsDisabled()) {
$item->addIcon('disable', pht('Disabled'));
}
if ($user->getIsAdmin()) {
$item->addIcon('highlight', pht('Admin'));
}
if ($user->getIsSystemAgent()) {
$item->addIcon('computer', pht('System Agent'));
}
if ($viewer->getIsAdmin()) {
$uid = $user->getID();
$item->addAction(
id(new PHUIListItemView())
->setIcon('edit')
->setHref($this->getApplicationURI('edit/'.$uid.'/')));
}
$list->addItem($item);
}
return $list;
}
}
diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php
index 814595593c..40ad447857 100644
--- a/src/applications/search/controller/PhabricatorApplicationSearchController.php
+++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php
@@ -1,326 +1,323 @@
<?php
final class PhabricatorApplicationSearchController
extends PhabricatorSearchBaseController {
private $searchEngine;
private $navigation;
private $queryKey;
public function setQueryKey($query_key) {
$this->queryKey = $query_key;
return $this;
}
protected function getQueryKey() {
return $this->queryKey;
}
public function setNavigation(AphrontSideNavFilterView $navigation) {
$this->navigation = $navigation;
return $this;
}
protected function getNavigation() {
return $this->navigation;
}
public function setSearchEngine(
PhabricatorApplicationSearchEngine $search_engine) {
$this->searchEngine = $search_engine;
return $this;
}
protected function getSearchEngine() {
return $this->searchEngine;
}
protected function validateDelegatingController() {
$parent = $this->getDelegatingController();
if (!$parent) {
throw new Exception(
"You must delegate to this controller, not invoke it directly.");
}
$engine = $this->getSearchEngine();
if (!$engine) {
throw new Exception(
"Call setEngine() before delegating to this controller!");
}
$nav = $this->getNavigation();
if (!$nav) {
throw new Exception(
"Call setNavigation() before delegating to this controller!");
}
$engine->setViewer($this->getRequest()->getUser());
$parent = $this->getDelegatingController();
$interface = 'PhabricatorApplicationSearchResultsControllerInterface';
if (!$parent instanceof $interface) {
throw new Exception(
"Delegating controller must implement '{$interface}'.");
}
}
public function processRequest() {
$this->validateDelegatingController();
$key = $this->getQueryKey();
if ($key == 'edit') {
return $this->processEditRequest();
} else {
return $this->processSearchRequest();
}
}
private function processSearchRequest() {
$parent = $this->getDelegatingController();
$request = $this->getRequest();
$user = $request->getUser();
$engine = $this->getSearchEngine();
$nav = $this->getNavigation();
if ($request->isFormPost()) {
$saved_query = $engine->buildSavedQueryFromRequest($request);
$this->saveQuery($saved_query);
return id(new AphrontRedirectResponse())->setURI(
$engine->getQueryResultsPageURI($saved_query->getQueryKey()));
}
$named_query = null;
$run_query = true;
$query_key = $this->queryKey;
if ($this->queryKey == 'advanced') {
$run_query = false;
$query_key = $request->getStr('query');
+ } else if (!strlen($this->queryKey)) {
+ $query_key = head_key($engine->loadEnabledNamedQueries());
}
if ($engine->isBuiltinQuery($query_key)) {
$saved_query = $engine->buildSavedQueryFromBuiltin($query_key);
- $named_query = $engine->getBuiltinQuery($query_key);
+ $named_query = idx($engine->loadEnabledNamedQueries(), $query_key);
} else if ($query_key) {
$saved_query = id(new PhabricatorSavedQueryQuery())
->setViewer($user)
->withQueryKeys(array($query_key))
->executeOne();
if (!$saved_query) {
return new Aphront404Response();
}
- $named_query = id(new PhabricatorNamedQueryQuery())
- ->setViewer($user)
- ->withQueryKeys(array($saved_query->getQueryKey()))
- ->withEngineClassNames(array(get_class($engine)))
- ->withUserPHIDs(array($user->getPHID()))
- ->executeOne();
+ $named_query = idx($engine->loadEnabledNamedQueries(), $query_key);
} else {
$saved_query = $engine->buildSavedQueryFromRequest($request);
}
$nav->selectFilter(
'query/'.$saved_query->getQueryKey(),
'query/advanced');
$form = id(new AphrontFormView())
->setNoShading(true)
->setUser($user);
$engine->buildSearchForm($form, $saved_query);
$errors = $engine->getErrors();
if ($errors) {
$run_query = false;
$errors = id(new AphrontErrorView())
->setTitle(pht('Query Errors'))
->setErrors($errors);
}
$submit = id(new AphrontFormSubmitControl())
->setValue(pht('Execute Query'));
if ($run_query && !$named_query && $user->isLoggedIn()) {
$submit->addCancelButton(
'/search/edit/'.$saved_query->getQueryKey().'/',
pht('Save Custom Query...'));
}
$form->appendChild($submit);
$filter_view = id(new AphrontListFilterView())->appendChild($form);
if ($run_query && $named_query) {
if ($named_query->getIsBuiltin()) {
$description = pht(
'Showing results for query "%s".',
$named_query->getQueryName());
} else {
$description = pht(
'Showing results for saved query "%s".',
$named_query->getQueryName());
}
$filter_view->setCollapsed(
pht('Edit Query...'),
pht('Hide Query'),
$description,
$this->getApplicationURI('query/advanced/?query='.$query_key));
}
$nav->appendChild($filter_view);
if ($run_query) {
$query = $engine->buildQueryFromSavedQuery($saved_query);
$pager = new AphrontCursorPagerView();
$pager->readFromRequest($request);
$objects = $query->setViewer($request->getUser())
->executeWithCursorPager($pager);
$list = $parent->renderResultsList($objects);
$list->setNoDataString(pht("No results found for this query."));
$nav->appendChild($list);
// TODO: This is a bit hacky.
if ($list instanceof PhabricatorObjectItemListView) {
$list->setPager($pager);
} else {
$nav->appendChild($pager);
}
}
if ($errors) {
$nav->appendChild($errors);
}
if ($named_query) {
$title = pht('Query: %s', $named_query->getQueryName());
} else {
$title = pht('Advanced Search');
}
$crumbs = $parent
->buildApplicationCrumbs()
->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht("Search")));
$nav->setCrumbs($crumbs);
return $this->buildApplicationPage(
$nav,
array(
'title' => $title,
'device' => true,
'dust' => true,
));
}
private function processEditRequest() {
$parent = $this->getDelegatingController();
$request = $this->getRequest();
$user = $request->getUser();
$engine = $this->getSearchEngine();
$nav = $this->getNavigation();
$named_queries = $engine->loadAllNamedQueries();
$list_id = celerity_generate_unique_node_id();
$list = new PhabricatorObjectItemListView();
$list->setUser($user);
$list->setID($list_id);
Javelin::initBehavior(
'search-reorder-queries',
array(
'listID' => $list_id,
'orderURI' => '/search/order/'.get_class($engine).'/',
));
foreach ($named_queries as $named_query) {
$class = get_class($engine);
$key = $named_query->getQueryKey();
$item = id(new PhabricatorObjectItemView())
->setHeader($named_query->getQueryName())
->setHref($engine->getQueryResultsPageURI($key));
if ($named_query->getIsBuiltin() && $named_query->getIsDisabled()) {
$icon = 'new';
} else {
$icon = 'delete';
}
$item->addAction(
id(new PHUIListItemView())
->setIcon($icon)
->setHref('/search/delete/'.$key.'/'.$class.'/')
->setWorkflow(true));
if ($named_query->getIsBuiltin()) {
if ($named_query->getIsDisabled()) {
$item->addIcon('delete-grey', pht('Disabled'));
} else {
$item->addIcon('lock-grey', pht('Builtin'));
}
$item->setBarColor('grey');
} else {
$item->addAction(
id(new PHUIListItemView())
->setIcon('edit')
->setHref('/search/edit/'.$key.'/'));
}
$item->setGrippable(true);
$item->addSigil('named-query');
$item->setMetadata(
array(
'queryKey' => $named_query->getQueryKey(),
));
$list->addItem($item);
}
$list->setNoDataString(pht('No saved queries.'));
$crumbs = $parent
->buildApplicationCrumbs()
->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht("Saved Queries"))
->setHref($engine->getQueryManagementURI()));
$nav->selectFilter('query/edit');
$nav->setCrumbs($crumbs);
$nav->appendChild($list);
return $parent->buildApplicationPage(
$nav,
array(
'title' => pht("Saved Queries"),
'device' => true,
'dust' => true,
));
}
private function saveQuery(PhabricatorSavedQuery $query) {
$query->setEngineClassName(get_class($this->getSearchEngine()));
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
try {
$query->save();
} catch (AphrontQueryDuplicateKeyException $ex) {
// Ignore, this is just a repeated search.
}
unset($unguarded);
}
protected function buildApplicationMenu() {
return $this->getDelegatingController()->buildApplicationMenu();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Jul 2, 8:02 AM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
164782
Default Alt Text
(20 KB)

Event Timeline