diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d62e21041d..b67f2b85ba 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -942,6 +942,7 @@ phutil_register_library_map(array( 'PhabricatorMailImplementationSendGridAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php', 'PhabricatorMailImplementationTestAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationTestAdapter.php', 'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php', + 'PhabricatorMailingListsController' => 'applications/mailinglists/controller/PhabricatorMailingListsController.php', 'PhabricatorMailingListsEditController' => 'applications/mailinglists/controller/PhabricatorMailingListsEditController.php', 'PhabricatorMailingListsListController' => 'applications/mailinglists/controller/PhabricatorMailingListsListController.php', 'PhabricatorMainMenuGroupView' => 'view/page/menu/PhabricatorMainMenuGroupView.php', @@ -2331,8 +2332,9 @@ phutil_register_library_map(array( 'PhabricatorMailImplementationPHPMailerLiteAdapter' => 'PhabricatorMailImplementationAdapter', 'PhabricatorMailImplementationSendGridAdapter' => 'PhabricatorMailImplementationAdapter', 'PhabricatorMailImplementationTestAdapter' => 'PhabricatorMailImplementationAdapter', - 'PhabricatorMailingListsEditController' => 'PhabricatorController', - 'PhabricatorMailingListsListController' => 'PhabricatorController', + 'PhabricatorMailingListsController' => 'PhabricatorController', + 'PhabricatorMailingListsEditController' => 'PhabricatorMailingListsController', + 'PhabricatorMailingListsListController' => 'PhabricatorMailingListsController', 'PhabricatorMainMenuGroupView' => 'AphrontView', 'PhabricatorMainMenuIconView' => 'AphrontView', 'PhabricatorMainMenuSearchView' => 'AphrontView', diff --git a/src/applications/mailinglists/controller/PhabricatorMailingListsController.php b/src/applications/mailinglists/controller/PhabricatorMailingListsController.php new file mode 100644 index 0000000000..31aecb8f6d --- /dev/null +++ b/src/applications/mailinglists/controller/PhabricatorMailingListsController.php @@ -0,0 +1,37 @@ +getRequest()->getUser(); + + $nav = new AphrontSideNavFilterView(); + $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); + + $nav->addLabel(pht('Mailing Lists')); + $nav->addFilter('/', pht('All Lists')); + $nav->selectFilter($filter, '/'); + if ($for_app) { + $nav->addFilter('edit/', pht('Create List')); + } + + return $nav; + } + + public function buildApplicationMenu() { + return $this->buildSideNavView(null, true)->getMenu(); + } + + public function buildApplicationCrumbs() { + $crumbs = parent::buildApplicationCrumbs(); + + $crumbs->addAction( + id(new PhabricatorMenuItemView()) + ->setName(pht('Create List')) + ->setHref($this->getApplicationURI('edit/')) + ->setIcon('create')); + + return $crumbs; + } + +} diff --git a/src/applications/mailinglists/controller/PhabricatorMailingListsEditController.php b/src/applications/mailinglists/controller/PhabricatorMailingListsEditController.php index 1fded3ad11..b47414b242 100644 --- a/src/applications/mailinglists/controller/PhabricatorMailingListsEditController.php +++ b/src/applications/mailinglists/controller/PhabricatorMailingListsEditController.php @@ -1,7 +1,7 @@ buildApplicationCrumbs($this->buildSideNavView()); + $request = $this->getRequest(); if ($request->isFormPost()) { $list->setName($request->getStr('name')); @@ -35,22 +37,22 @@ final class PhabricatorMailingListsEditController $e_name = null; if (!strlen($list->getEmail())) { - $e_email = 'Required'; - $errors[] = 'Email is required.'; + $e_email = pht('Required'); + $errors[] = pht('Email is required.'); } if (!strlen($list->getName())) { - $e_name = 'Required'; - $errors[] = 'Name is required.'; + $e_name = pht('Required'); + $errors[] = pht('Name is required.'); } else if (preg_match('/[ ,]/', $list->getName())) { - $e_name = 'Invalid'; - $errors[] = 'Name must not contain spaces or commas.'; + $e_name = pht('Invalid'); + $errors[] = pht('Name must not contain spaces or commas.'); } if ($list->getURI()) { if (!PhabricatorEnv::isValidWebResource($list->getURI())) { - $e_uri = 'Invalid'; - $errors[] = 'Mailing list URI must point to a valid web page.'; + $e_uri = pht('Invalid'); + $errors[] = pht('Mailing list URI must point to a valid web page.'); } } @@ -60,8 +62,8 @@ final class PhabricatorMailingListsEditController return id(new AphrontRedirectResponse()) ->setURI($this->getApplicationURI()); } catch (AphrontQueryDuplicateKeyException $ex) { - $e_email = 'Duplicate'; - $errors[] = 'Another mailing list already uses that address.'; + $e_email = pht('Duplicate'); + $errors[] = pht('Another mailing list already uses that address.'); } } } @@ -69,7 +71,7 @@ final class PhabricatorMailingListsEditController $error_view = null; if ($errors) { $error_view = id(new AphrontErrorView()) - ->setTitle('Form Errors') + ->setTitle(pht('Form Errors')) ->setErrors($errors); } @@ -84,24 +86,24 @@ final class PhabricatorMailingListsEditController $form ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Email') + ->setLabel(pht('Email')) ->setName('email') ->setValue($list->getEmail()) - ->setCaption('Email will be delivered to this address.') + ->setCaption(pht('Email will be delivered to this address.')) ->setError($e_email)) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Name') + ->setLabel(pht('Name')) ->setName('name') ->setError($e_name) - ->setCaption('Human-readable display and autocomplete name.') + ->setCaption(pht('Human-readable display and autocomplete name.')) ->setValue($list->getName())) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('URI') + ->setLabel(pht('URI')) ->setName('uri') ->setError($e_uri) - ->setCaption('Optional link to mailing list archives or info.') + ->setCaption(pht('Optional link to mailing list archives or info.')) ->setValue($list->getURI())) ->appendChild( id(new AphrontFormStaticControl()) @@ -109,26 +111,39 @@ final class PhabricatorMailingListsEditController ->setValue(nonempty($list->getPHID(), '-'))) ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue('Save') + ->setValue(pht('Save')) ->addCancelButton($this->getApplicationURI())); $panel = new AphrontPanelView(); if ($list->getID()) { - $panel->setHeader('Edit Mailing List'); + $panel->setHeader(pht('Edit Mailing List')); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName(pht('Edit Mailing List')) + ->setHref($this->getApplicationURI('/edit/'.$list->getID().'/')) + ); } else { - $panel->setHeader('Create New Mailing List'); + $panel->setHeader(pht('Create Mailing List')); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName(pht('Create Mailing List')) + ->setHref($this->getApplicationURI('/edit/')) + ); } $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); + $panel->setNoBackground(); return $this->buildApplicationPage( array( + $crumbs, $error_view, $panel, ), array( - 'title' => 'Edit Mailing List', + 'title' => pht('Edit Mailing List'), + 'device' => true, )); } diff --git a/src/applications/mailinglists/controller/PhabricatorMailingListsListController.php b/src/applications/mailinglists/controller/PhabricatorMailingListsListController.php index 3e2281ec87..74f4d75e66 100644 --- a/src/applications/mailinglists/controller/PhabricatorMailingListsListController.php +++ b/src/applications/mailinglists/controller/PhabricatorMailingListsListController.php @@ -1,7 +1,7 @@ getRequest(); @@ -24,6 +24,8 @@ final class PhabricatorMailingListsListController $pager->getOffset(), $pager->getPageSize() + 1); $data = $pager->sliceResults($data); + $nav = $this->buildSideNavView('all'); + $lists = $list->loadAllFromArray($data); $rows = array(); @@ -37,15 +39,15 @@ final class PhabricatorMailingListsListController 'class' => 'button grey small', 'href' => $this->getApplicationURI('/edit/'.$list->getID().'/'), ), - 'Edit'), + pht('Edit')), ); } $table = new AphrontTableView($rows); $table->setHeaders( array( - 'Name', - 'Email', + pht('Name'), + pht('Email'), '', )); $table->setColumnClasses( @@ -55,16 +57,29 @@ final class PhabricatorMailingListsListController 'action', )); + $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName(pht('All Lists')) + ->setHref($this->getApplicationURI()) + ); + $nav->setCrumbs($crumbs); + $panel = new AphrontPanelView(); $panel->appendChild($table); - $panel->setHeader('Mailing Lists'); - $panel->setCreateButton('Add New List', $this->getApplicationURI('/edit/')); + $panel->setHeader(pht('Mailing Lists')); $panel->appendChild($pager); + $panel->setNoBackground(); + + $nav->appendChild($panel); return $this->buildApplicationPage( - $panel, array( - 'title' => 'Mailing Lists', + $nav, + ), + array( + 'title' => pht('Mailing Lists'), + 'device' => true, )); } }