Remove product literal strings in "pht()", part 12
[phabricator.git] / src / applications / auth / controller / config / PhabricatorAuthListController.php
blob690aa4e57c6adad59c651a58740861a3b83f8c53
1 <?php
3 final class PhabricatorAuthListController
4 extends PhabricatorAuthProviderConfigController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
9 $configs = id(new PhabricatorAuthProviderConfigQuery())
10 ->setViewer($viewer)
11 ->execute();
13 $list = new PHUIObjectItemListView();
14 $can_manage = $this->hasApplicationCapability(
15 AuthManageProvidersCapability::CAPABILITY);
16 $is_locked = PhabricatorEnv::getEnvConfig('auth.lock-config');
18 foreach ($configs as $config) {
19 $item = new PHUIObjectItemView();
21 $id = $config->getID();
23 $view_uri = $config->getURI();
25 $provider = $config->getProvider();
26 $name = $provider->getProviderName();
28 $item
29 ->setHeader($name)
30 ->setHref($view_uri);
32 $domain = $provider->getProviderDomain();
33 if ($domain !== 'self') {
34 $item->addAttribute($domain);
37 if ($config->getShouldAllowRegistration()) {
38 $item->addAttribute(pht('Allows Registration'));
39 } else {
40 $item->addAttribute(pht('Does Not Allow Registration'));
43 if ($config->getIsEnabled()) {
44 $item->setStatusIcon('fa-check-circle green');
45 } else {
46 $item->setStatusIcon('fa-ban red');
47 $item->addIcon('fa-ban grey', pht('Disabled'));
50 $list->addItem($item);
53 $list->setNoDataString(
54 pht(
55 '%s You have not added authentication providers yet. Use "%s" to add '.
56 'a provider, which will let users register new accounts and log in.',
57 phutil_tag(
58 'strong',
59 array(),
60 pht('No Providers Configured:')),
61 phutil_tag(
62 'a',
63 array(
64 'href' => $this->getApplicationURI('config/new/'),
66 pht('Add Provider'))));
68 $crumbs = $this->buildApplicationCrumbs();
69 $crumbs->addTextCrumb(pht('Login and Registration'));
70 $crumbs->setBorder(true);
72 $guidance_context = id(new PhabricatorAuthProvidersGuidanceContext())
73 ->setCanManage($can_manage);
75 $guidance = id(new PhabricatorGuidanceEngine())
76 ->setViewer($viewer)
77 ->setGuidanceContext($guidance_context)
78 ->newInfoView();
80 $is_disabled = (!$can_manage || $is_locked);
81 $button = id(new PHUIButtonView())
82 ->setTag('a')
83 ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
84 ->setIcon('fa-plus')
85 ->setDisabled($is_disabled)
86 ->setWorkflow($is_disabled)
87 ->setHref($this->getApplicationURI('config/new/'))
88 ->setText(pht('Add Provider'));
90 $list->setFlush(true);
91 $list = id(new PHUIObjectBoxView())
92 ->setHeaderText(pht('Providers'))
93 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
94 ->appendChild($list);
96 $title = pht('Login and Registration Providers');
97 $header = id(new PHUIHeaderView())
98 ->setHeader($title)
99 ->setHeaderIcon('fa-key')
100 ->addActionLink($button);
102 $view = id(new PHUITwoColumnView())
103 ->setHeader($header)
104 ->setFooter(
105 array(
106 $guidance,
107 $list,
110 $nav = $this->newNavigation()
111 ->setCrumbs($crumbs)
112 ->appendChild($view);
114 $nav->selectFilter('login');
116 return $this->newPage()
117 ->setTitle($title)
118 ->appendChild($nav);