<?php

final class ExtensionStoreHomeController extends ExtensionStoreBaseController {

  public function handleRequest(AphrontRequest $request) {
    $viewer = $request->getViewer();

    $menu = id(new PHUIObjectItemListView())
      ->setViewer($viewer)
      ->setBig(true);

    $menu->addItem(
      id(new PHUIObjectItemView())
        ->setHeader(pht('See the store'))
        ->setHref($this->getApplicationURI('view/'))
        ->setImageIcon('fa-birthday-cake')
        ->setClickable(true)
        ->setDisabled(true)
        ->addAttribute(
          pht(
            'See available extensions while logged-in.')));

    $store_uri = $this->getStoreUri();
    $menu->addItem(
      id(new PHUIObjectItemView())
        ->setHeader(pht('See the guest store'))
        ->setHref($store_uri)
        ->setImageIcon('fa-birthday-cake')
        ->setClickable(true)
        ->setDisabled(true)
        ->addAttribute(
          pht(
            'See available extensions while logged out!')));

    $menu->addItem(
      id(new PHUIObjectItemView())
        ->setHeader(pht('Manage Publishers'))
        ->setHref($this->getApplicationURI('publisher/'))
        ->setImageIcon('fa-university')
        ->setClickable(true)
        ->addAttribute(
          pht(
            'Manage extension publishers.')));

    $menu->addItem(
      id(new PHUIObjectItemView())
        ->setHeader(pht('Manage Extensions'))
        ->setHref($this->getApplicationURI('extension/'))
        ->setImageIcon('fa-gift')
        ->setClickable(true)
        ->addAttribute(
          pht(
            'Create and publish %s Extensions.',
            PlatformSymbols::getPlatformServerName())));


    $crumbs = $this->buildApplicationCrumbs();
    $crumbs->addTextCrumb(pht('Landing Page'));
    $crumbs->setBorder(true);

    $box = id(new PHUIObjectBoxView())
      ->setHeaderText(pht('Extensions Parlor'))
      ->setBackground(PHUIObjectBoxView::WHITE_CONFIG)
      ->appendChild(
        pht(
          "I'm not sure what to actually use this page for. ".
          "Maybe show few extensions?"))
      ->setObjectList($menu);

    $launcher_view = id(new PHUILauncherView())
      ->appendChild($box);

    $view = id(new PHUITwoColumnView())
      ->setFooter($launcher_view);

    return $this->newPage()
      ->setTitle(pht('Extensions'))
      ->setCrumbs($crumbs)
      ->appendChild($view);
  }

}
