private function assertMenuKeys(array $expect, PHUIListView $menu) { $items = $menu->getItems(); $keys = mpull($items, 'getKey'); $keys = array_values($keys); $this->assertEqual($expect, $keys); }
public function buildApplicationMenu() { $nav = new PHUIListView(); $nav->newLink(pht('New Room'), $this->getApplicationURI('new/')); $nav->addMenuItem(id(new PHUIListItemView())->setName(pht('Add Participants'))->setType(PHUIListItemView::TYPE_LINK)->setHref('#')->addSigil('conpherence-widget-adder')->setMetadata(array('widget' => 'widgets-people'))); return $nav; }
private function buildMenu($for_devices) { $menu = new PHUIListView(); if ($for_devices) { $menu->newLink(pht('Upload File'), $this->getApplicationURI('/upload/')); } id(new PhabricatorFileSearchEngine())->setViewer($this->getRequest()->getUser())->addNavigationItems($menu); return $menu; }
public function buildMainMenuExtraNodes(PhabricatorUser $viewer, PhabricatorController $controller = null) { $items = $this->loadAllQuickCreateItems($viewer); $view = new PHUIListView(); $view->newLabel(pht('Create New...')); foreach ($items as $item) { $view->addMenuItem($item); } return phutil_tag('div', array('id' => 'phabricator-quick-create-menu', 'class' => 'phabricator-main-menu-dropdown phui-list-sidenav', 'style' => 'display: none'), $view); }
public function buildMainMenuExtraNodes(PhabricatorUser $viewer, PhabricatorController $controller = null) { $application = null; if ($controller) { $application = $controller->getCurrentApplication(); } $view = null; if ($application) { $help_items = $application->getHelpMenuItems($viewer); if ($help_items) { $view = new PHUIListView(); foreach ($help_items as $item) { $view->addMenuItem($item); } } } return phutil_tag('div', array('id' => 'phabricator-help-menu', 'class' => 'phabricator-main-menu-dropdown phui-list-sidenav', 'style' => 'display: none'), $view); }
private function addThreadsToMenu(PHUIListView $menu, array $conpherences) { if ($this->scrollUpParticipant->getID()) { $item = $this->getScrollMenuItem($this->scrollUpParticipant, 'up'); $menu->addMenuItem($item); } foreach ($conpherences as $conpherence) { $item = $this->renderThreadItem($conpherence); $menu->addMenuItem($item); } if (empty($conpherences)) { $menu->addMenuItem($this->getNoConpherencesMenuItem()); } if ($this->scrollDownParticipant->getID()) { $item = $this->getScrollMenuItem($this->scrollDownParticipant, 'down'); $menu->addMenuItem($item); } return $menu; }
private function addThreadsToMenu(PHUIListView $menu, array $threads, array $policy_objects) { // If we have self::SEE_MORE_LIMIT or less, we can just render // all the threads at once. Otherwise, we render a "See more" // UI element, which toggles a show / hide on the remaining rooms $show_threads = $threads; $more_threads = array(); if (count($threads) > self::SEE_MORE_LIMIT) { $show_threads = array_slice($threads, 0, self::SEE_MORE_LIMIT); $more_threads = array_slice($threads, self::SEE_MORE_LIMIT); } foreach ($show_threads as $thread) { $item = $this->renderThreadItem($thread, $policy_objects); $menu->addMenuItem($item); } if ($more_threads) { $search_uri = '/conpherence/search/query/participant/'; $sigil = 'more-room'; $more_item = id(new PHUIListItemView())->setType(PHUIListItemView::TYPE_LINK)->setHref($search_uri)->addSigil('conpherence-menu-see-more')->setMetadata(array('moreSigil' => $sigil))->setName(pht('See More')); $menu->addMenuItem($more_item); $show_more_threads = $more_threads; $even_more_threads = array(); if (count($more_threads) > self::SEE_MORE_LIMIT) { $show_more_threads = array_slice($more_threads, 0, self::SEE_MORE_LIMIT); $even_more_threads = array_slice($more_threads, self::SEE_MORE_LIMIT); } foreach ($show_more_threads as $thread) { $item = $this->renderThreadItem($thread, $policy_objects)->addSigil($sigil)->addClass('hidden'); $menu->addMenuItem($item); } if ($even_more_threads) { // kick them to application search here $even_more_item = id(new PHUIListItemView())->setType(PHUIListItemView::TYPE_LINK)->setHref($search_uri)->addSigil($sigil)->addClass('hidden')->setName(pht('See More')); $menu->addMenuItem($even_more_item); } } return $menu; }
public function buildMainMenus() { $application = $this->getApplication(); if (!$application) { return array(); } $viewer = $this->getViewer(); $help_links = $application->getHelpMenuItems($viewer); if (!$help_links) { return array(); } $help_id = celerity_generate_unique_node_id(); Javelin::initBehavior('aphlict-dropdown', array('bubbleID' => $help_id, 'dropdownID' => 'phabricator-help-menu', 'local' => true, 'desktop' => true, 'right' => true)); $help_name = pht('%s Help', $application->getName()); $help_item = id(new PHUIListItemView())->setIcon('fa-book')->addClass('core-menu-item')->setID($help_id)->setName($help_name)->setHref('/help/documentation/' . get_class($application) . '/')->setAural($help_name); $view = new PHUIListView(); foreach ($help_links as $help_link) { $view->addMenuItem($help_link); } $dropdown_menu = phutil_tag('div', array('id' => 'phabricator-help-menu', 'class' => 'phabricator-main-menu-dropdown phui-list-sidenav', 'style' => 'display: none'), $view); $help_menu = id(new PHUIMainMenuView())->setOrder(200)->setMenuBarItem($help_item)->appendChild($dropdown_menu); return array($help_menu); }
public function buildApplicationMenu() { $nav = new PHUIListView(); $conpherence = $this->conpherence; // Local Links if ($conpherence) { $nav->addMenuItem(id(new PHUIListItemView())->setName(pht('Joined Rooms'))->setType(PHUIListItemView::TYPE_LINK)->setHref($this->getApplicationURI())); $nav->addMenuItem(id(new PHUIListItemView())->setName(pht('Edit Room'))->setType(PHUIListItemView::TYPE_LINK)->setHref($this->getApplicationURI('update/' . $conpherence->getID()) . '/')->setWorkflow(true)); $nav->addMenuItem(id(new PHUIListItemView())->setName(pht('Add Participants'))->setType(PHUIListItemView::TYPE_LINK)->setHref('#')->addSigil('conpherence-widget-adder')->setMetadata(array('widget' => 'widgets-people'))); } // Global Links $nav->newLabel(pht('Conpherence')); $nav->newLink(pht('New Room'), $this->getApplicationURI('new/')); $nav->newLink(pht('Search Rooms'), $this->getApplicationURI('search/')); return $nav; }
public function addNavigationItems(PHUIListView $menu) { $viewer = $this->requireViewer(); $menu->newLabel(pht('Queries')); $named_queries = $this->loadEnabledNamedQueries(); foreach ($named_queries as $query) { $key = $query->getQueryKey(); $uri = $this->getQueryResultsPageURI($key); $menu->newLink($query->getQueryName(), $uri, 'query/' . $key); } if ($viewer->isLoggedIn()) { $manage_uri = $this->getQueryManagementURI(); $menu->newLink(pht('Edit Queries...'), $manage_uri, 'query/edit'); } $menu->newLabel(pht('Search')); $advanced_uri = $this->getQueryResultsPageURI('advanced'); $menu->newLink(pht('Advanced Search'), $advanced_uri, 'query/advanced'); foreach ($this->navigationItems as $extra_item) { $menu->addMenuItem($extra_item); } return $this; }
private function renderPhabricatorSearchMenu() { $view = new PHUIListView(); $view->addClass('phabricator-dark-menu'); $view->addClass('phabricator-search-menu'); $search = $this->renderSearch(); if ($search) { $view->addMenuItem($search); } return $view; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getUser(); $book_name = $request->getURIData('book'); $atom_type = $request->getURIData('type'); $atom_name = $request->getURIData('name'); $atom_context = nonempty($request->getURIData('context'), null); $atom_index = nonempty($request->getURIData('index'), null); require_celerity_resource('diviner-shared-css'); $book = id(new DivinerBookQuery())->setViewer($viewer)->withNames(array($book_name))->executeOne(); if (!$book) { return new Aphront404Response(); } $symbol = id(new DivinerAtomQuery())->setViewer($viewer)->withBookPHIDs(array($book->getPHID()))->withTypes(array($atom_type))->withNames(array($atom_name))->withContexts(array($atom_context))->withIndexes(array($atom_index))->withIsDocumentable(true)->needAtoms(true)->needExtends(true)->needChildren(true)->executeOne(); if (!$symbol) { return new Aphront404Response(); } $atom = $symbol->getAtom(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->setBorder(true); $crumbs->addTextCrumb($book->getShortTitle(), '/book/' . $book->getName() . '/'); $atom_short_title = $atom ? $atom->getDocblockMetaValue('short', $symbol->getTitle()) : $symbol->getTitle(); $crumbs->addTextCrumb($atom_short_title); $header = id(new PHUIHeaderView())->setHeader($this->renderFullSignature($symbol)); $properties = new PHUIPropertyListView(); $group = $atom ? $atom->getProperty('group') : $symbol->getGroupName(); if ($group) { $group_name = $book->getGroupName($group); } else { $group_name = null; } $prop_list = new PHUIPropertyGroupView(); $prop_list->addPropertyList($properties); $document = id(new PHUIDocumentViewPro())->setBook($book->getTitle(), $group_name)->setHeader($header)->addClass('diviner-view'); if ($atom) { $this->buildDefined($properties, $symbol); $this->buildExtendsAndImplements($properties, $symbol); $this->buildRepository($properties, $symbol); $warnings = $atom->getWarnings(); if ($warnings) { $warnings = id(new PHUIInfoView())->setErrors($warnings)->setTitle(pht('Documentation Warnings'))->setSeverity(PHUIInfoView::SEVERITY_WARNING); } $document->appendChild($warnings); } $methods = $this->composeMethods($symbol); $field = 'default'; $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer)->addObject($symbol, $field); foreach ($methods as $method) { foreach ($method['atoms'] as $matom) { $engine->addObject($matom, $field); } } $engine->process(); if ($atom) { $content = $this->renderDocumentationText($symbol, $engine); $document->appendChild($content); } $toc = $engine->getEngineMetadata($symbol, $field, PhutilRemarkupHeaderBlockRule::KEY_HEADER_TOC, array()); if (!$atom) { $document->appendChild(id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('This atom no longer exists.'))); } if ($atom) { $document->appendChild($this->buildParametersAndReturn(array($symbol))); } if ($methods) { $tasks = $this->composeTasks($symbol); if ($tasks) { $methods_by_task = igroup($methods, 'task'); // Add phantom tasks for methods which have a "@task" name that isn't // documented anywhere, or methods that have no "@task" name. foreach ($methods_by_task as $task => $ignored) { if (empty($tasks[$task])) { $tasks[$task] = array('name' => $task, 'title' => $task ? $task : pht('Other Methods'), 'defined' => $symbol); } } $section = id(new DivinerSectionView())->setHeader(pht('Tasks')); foreach ($tasks as $spec) { $section->addContent(id(new PHUIHeaderView())->setNoBackground(true)->setHeader($spec['title'])); $task_methods = idx($methods_by_task, $spec['name'], array()); $box_content = array(); if ($task_methods) { $list_items = array(); foreach ($task_methods as $task_method) { $atom = last($task_method['atoms']); $item = $this->renderFullSignature($atom, true); if (strlen($atom->getSummary())) { $item = array($item, " — ", $atom->getSummary()); } $list_items[] = phutil_tag('li', array(), $item); } $box_content[] = phutil_tag('ul', array('class' => 'diviner-list'), $list_items); } else { $no_methods = pht('No methods for this task.'); $box_content = phutil_tag('em', array(), $no_methods); } $inner_box = phutil_tag_div('diviner-task-items', $box_content); $section->addContent($inner_box); } $document->appendChild($section); } $section = id(new DivinerSectionView())->setHeader(pht('Methods')); foreach ($methods as $spec) { $matom = last($spec['atoms']); $method_header = id(new PHUIHeaderView())->setNoBackground(true); $inherited = $spec['inherited']; if ($inherited) { $method_header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_GREY)->setName(pht('Inherited'))); } $method_header->setHeader($this->renderFullSignature($matom)); $section->addContent(array($method_header, $this->renderMethodDocumentationText($symbol, $spec, $engine), $this->buildParametersAndReturn($spec['atoms']))); } $document->appendChild($section); } if ($toc) { $side = new PHUIListView(); $side->addMenuItem(id(new PHUIListItemView())->setName(pht('Contents'))->setType(PHUIListItemView::TYPE_LABEL)); foreach ($toc as $key => $entry) { $side->addMenuItem(id(new PHUIListItemView())->setName($entry[1])->setHref('#' . $key)); } $document->setToc($side); } $prop_list = phutil_tag_div('phui-document-view-pro-box', $prop_list); return $this->newPage()->setTitle($symbol->getTitle())->setCrumbs($crumbs)->appendChild(array($document, $prop_list)); }
private function buildHeader() { $conpherence = $this->getSelectedConpherence(); if (!$conpherence) { $header = null; $settings_button = null; $settings_menu = null; } else { $bubble_id = celerity_generate_unique_node_id(); $dropdown_id = celerity_generate_unique_node_id(); $settings_list = new PHUIListView(); $header_actions = $this->getHeaderActionsConfig($conpherence); foreach ($header_actions as $action) { $settings_list->addMenuItem(id(new PHUIListItemView())->setHref($action['href'])->setName($action['name'])->setIcon($action['icon'])->setDisabled($action['disabled'])->addSigil('conpherence-durable-column-header-action')->setMetadata(array('action' => $action['key']))); } $settings_menu = phutil_tag('div', array('id' => $dropdown_id, 'class' => 'phabricator-main-menu-dropdown phui-list-sidenav ' . 'conpherence-settings-dropdown', 'sigil' => 'phabricator-notification-menu', 'style' => 'display: none'), $settings_list); Javelin::initBehavior('aphlict-dropdown', array('bubbleID' => $bubble_id, 'dropdownID' => $dropdown_id, 'local' => true, 'containerDivID' => 'conpherence-durable-column')); $item = id(new PHUIListItemView())->setName(pht('Room Actions'))->setIcon('fa-bars')->addClass('core-menu-item')->addSigil('conpherence-settings-menu')->setID($bubble_id)->setHref('#')->setAural(pht('Room Actions'))->setOrder(300); $settings_button = id(new PHUIListView())->addMenuItem($item)->addClass('phabricator-dark-menu')->addClass('phabricator-application-menu'); $data = $conpherence->getDisplayData($this->getUser()); $header = phutil_tag('span', array(), array($this->getPolicyIcon($conpherence, $this->getPolicyObjects()), $data['title'])); } return phutil_tag('div', array('class' => 'conpherence-durable-column-header'), array(javelin_tag('div', array('sigil' => 'conpherence-durable-column-header-text', 'class' => 'conpherence-durable-column-header-text'), $header), $settings_button, $settings_menu)); }
public function setTopNav(PHUIListView $list) { $list->setType(PHUIListView::NAVBAR_LIST); $this->topnav = $list; return $this; }
public function processRequest() { $request = $this->getRequest(); $viewer = $request->getUser(); require_celerity_resource('diviner-shared-css'); $book = id(new DivinerBookQuery())->setViewer($viewer)->withNames(array($this->bookName))->executeOne(); if (!$book) { return new Aphront404Response(); } // TODO: This query won't load ghosts, because they'll fail `needAtoms()`. // Instead, we might want to load ghosts and render a message like // "this thing existed in an older version, but no longer does", especially // if we add content like comments. $symbol = id(new DivinerAtomQuery())->setViewer($viewer)->withBookPHIDs(array($book->getPHID()))->withTypes(array($this->atomType))->withNames(array($this->atomName))->withContexts(array($this->atomContext))->withIndexes(array($this->atomIndex))->needAtoms(true)->needExtends(true)->needChildren(true)->executeOne(); if (!$symbol) { return new Aphront404Response(); } $atom = $symbol->getAtom(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($book->getShortTitle(), '/book/' . $book->getName() . '/'); $atom_short_title = $atom->getDocblockMetaValue('short', $symbol->getTitle()); $crumbs->addTextCrumb($atom_short_title); $header = id(new PHUIHeaderView())->setHeader($this->renderFullSignature($symbol))->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_BLUE)->setName(DivinerAtom::getAtomTypeNameString($atom->getType()))); $properties = id(new PHUIPropertyListView()); $group = $atom->getProperty('group'); if ($group) { $group_name = $book->getGroupName($group); } else { $group_name = null; } $this->buildDefined($properties, $symbol); $this->buildExtendsAndImplements($properties, $symbol); $warnings = $atom->getWarnings(); if ($warnings) { $warnings = id(new AphrontErrorView())->setErrors($warnings)->setTitle(pht('Documentation Warnings'))->setSeverity(AphrontErrorView::SEVERITY_WARNING); } $methods = $this->composeMethods($symbol); $field = 'default'; $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer)->addObject($symbol, $field); foreach ($methods as $method) { foreach ($method['atoms'] as $matom) { $engine->addObject($matom, $field); } } $engine->process(); $content = $this->renderDocumentationText($symbol, $engine); $toc = $engine->getEngineMetadata($symbol, $field, PhutilRemarkupHeaderBlockRule::KEY_HEADER_TOC, array()); $document = id(new PHUIDocumentView())->setBook($book->getTitle(), $group_name)->setHeader($header)->addClass('diviner-view')->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS)->appendChild($properties)->appendChild($warnings)->appendChild($content); $document->appendChild($this->buildParametersAndReturn(array($symbol))); if ($methods) { $tasks = $this->composeTasks($symbol); if ($tasks) { $methods_by_task = igroup($methods, 'task'); // Add phantom tasks for methods which have a "@task" name that isn't // documented anywhere, or methods that have no "@task" name. foreach ($methods_by_task as $task => $ignored) { if (empty($tasks[$task])) { $tasks[$task] = array('name' => $task, 'title' => $task ? $task : pht('Other Methods'), 'defined' => $symbol); } } $section = id(new DivinerSectionView())->setHeader(pht('Tasks')); foreach ($tasks as $spec) { $section->addContent(id(new PHUIHeaderView())->setNoBackground(true)->setHeader($spec['title'])); $task_methods = idx($methods_by_task, $spec['name'], array()); $inner_box = id(new PHUIBoxView())->addPadding(PHUI::PADDING_LARGE_LEFT)->addPadding(PHUI::PADDING_LARGE_RIGHT)->addPadding(PHUI::PADDING_LARGE_BOTTOM); $box_content = array(); if ($task_methods) { $list_items = array(); foreach ($task_methods as $task_method) { $atom = last($task_method['atoms']); $item = $this->renderFullSignature($atom, true); if (strlen($atom->getSummary())) { $item = array($item, " — ", $atom->getSummary()); } $list_items[] = phutil_tag('li', array(), $item); } $box_content[] = phutil_tag('ul', array('class' => 'diviner-list'), $list_items); } else { $no_methods = pht('No methods for this task.'); $box_content = phutil_tag('em', array(), $no_methods); } $inner_box->appendChild($box_content); $section->addContent($inner_box); } $document->appendChild($section); } $section = id(new DivinerSectionView())->setHeader(pht('Methods')); foreach ($methods as $spec) { $matom = last($spec['atoms']); $method_header = id(new PHUIHeaderView())->setNoBackground(true); $inherited = $spec['inherited']; if ($inherited) { $method_header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_GREY)->setName(pht('Inherited'))); } $method_header->setHeader($this->renderFullSignature($matom)); $section->addContent(array($method_header, $this->renderMethodDocumentationText($symbol, $spec, $engine), $this->buildParametersAndReturn($spec['atoms']))); } $document->appendChild($section); } if ($toc) { $side = new PHUIListView(); $side->addMenuItem(id(new PHUIListItemView())->setName(pht('Contents'))->setType(PHUIListItemView::TYPE_LABEL)); foreach ($toc as $key => $entry) { $side->addMenuItem(id(new PHUIListItemView())->setName($entry[1])->setHref('#' . $key)); } $document->setSideNav($side, PHUIDocumentView::NAV_TOP); } return $this->buildApplicationPage(array($crumbs, $document), array('title' => $symbol->getTitle())); }