private function getIconMap() { $icon_map = PhabricatorFilesComposeIconBuiltinFile::getAllIcons(); $first = array('fa-briefcase', 'fa-tags', 'fa-folder', 'fa-group', 'fa-bug', 'fa-trash-o', 'fa-calendar', 'fa-flag-checkered', 'fa-envelope', 'fa-truck', 'fa-lock', 'fa-umbrella', 'fa-cloud', 'fa-building', 'fa-credit-card', 'fa-flask'); $icon_map = array_select_keys($icon_map, $first) + $icon_map; return $icon_map; }
public function getUnresolvedIssues() { $issues = $this->getIssues(); $issues = mpull($issues, null, 'getIssueKey'); $unresolved_keys = PhabricatorSetupCheck::getUnignoredIssueKeys($issues); return array_select_keys($issues, $unresolved_keys); }
public function render() { if (!$this->user) { throw new Exception("Call setUser() before rendering!"); } $task = $this->task; $handles = $this->handles; require_celerity_resource('maniphest-task-summary-css'); $pri_class = self::getPriorityClass($task->getPriority()); $status_map = ManiphestTaskStatus::getTaskStatusMap(); $batch = null; if ($this->showBatchControls) { $batch = '<td class="maniphest-task-batch">' . javelin_render_tag('input', array('type' => 'checkbox', 'name' => 'batch[]', 'value' => $task->getID(), 'sigil' => 'maniphest-batch'), null) . '</td>'; } $projects_view = new ManiphestTaskProjectsView(); $projects_view->setHandles(array_select_keys($this->handles, $task->getProjectPHIDs())); $control_class = null; $control_sigil = null; if ($this->showSubpriorityControls) { $control_class = 'maniphest-active-handle'; $control_sigil = 'maniphest-task-handle'; } $handle = javelin_render_tag('td', array('class' => 'maniphest-task-handle ' . $pri_class . ' ' . $control_class, 'sigil' => $control_sigil), ''); return javelin_render_tag('table', array('class' => 'maniphest-task-summary', 'sigil' => 'maniphest-task', 'meta' => array('taskID' => $task->getID())), '<tr>' . $handle . $batch . '<td class="maniphest-task-number">' . 'T' . $task->getID() . '</td>' . '<td class="maniphest-task-status">' . idx($status_map, $task->getStatus(), 'Unknown') . '</td>' . '<td class="maniphest-task-owner">' . ($task->getOwnerPHID() ? $handles[$task->getOwnerPHID()]->renderLink() : '<em>None</em>') . '</td>' . '<td class="maniphest-task-name">' . phutil_render_tag('a', array('href' => '/T' . $task->getID()), phutil_escape_html($task->getTitle())) . '</td>' . '<td class="maniphest-task-projects">' . $projects_view->render() . '</td>' . '<td class="maniphest-task-updated">' . phabricator_date($task->getDateModified(), $this->user) . '</td>' . '</tr>'); }
public function renderDashboard() { require_celerity_resource('phabricator-dashboard-css'); $dashboard = $this->dashboard; $viewer = $this->viewer; $layout_config = $dashboard->getLayoutConfigObject(); $panel_grid_locations = $layout_config->getPanelLocations(); $panels = mpull($dashboard->getPanels(), null, 'getPHID'); $dashboard_id = celerity_generate_unique_node_id(); $result = id(new AphrontMultiColumnView())->setID($dashboard_id)->setFluidlayout(true)->setGutter(AphrontMultiColumnView::GUTTER_LARGE); if ($this->arrangeMode) { $h_mode = PhabricatorDashboardPanelRenderingEngine::HEADER_MODE_EDIT; } else { $h_mode = PhabricatorDashboardPanelRenderingEngine::HEADER_MODE_NORMAL; } foreach ($panel_grid_locations as $column => $panel_column_locations) { $panel_phids = $panel_column_locations; $column_panels = array_select_keys($panels, $panel_phids); $column_result = array(); foreach ($column_panels as $panel) { $column_result[] = id(new PhabricatorDashboardPanelRenderingEngine())->setViewer($viewer)->setPanel($panel)->setDashboardID($dashboard->getID())->setEnableAsyncRendering(true)->setParentPanelPHIDs(array())->setHeaderMode($h_mode)->renderPanel(); } $column_class = $layout_config->getColumnClass($column, $this->arrangeMode); if ($this->arrangeMode) { $column_result[] = $this->renderAddPanelPlaceHolder($column); $column_result[] = $this->renderAddPanelUI($column); } $result->addColumn($column_result, $column_class, $sigil = 'dashboard-column', $metadata = array('columnID' => $column)); } if ($this->arrangeMode) { Javelin::initBehavior('dashboard-move-panels', array('dashboardID' => $dashboard_id, 'moveURI' => '/dashboard/movepanel/' . $dashboard->getID() . '/')); } $view = id(new PHUIBoxView())->addClass('dashboard-view')->appendChild($result); return $view; }
public function renderCard($phid) { $this->willRender(); $viewer = $this->getViewer(); $object = idx($this->getObjects(), $phid); $card = id(new ProjectBoardTaskCard())->setViewer($viewer)->setTask($object)->setCanEdit($this->getCanEdit($phid)); $owner_phid = $object->getOwnerPHID(); if ($owner_phid) { $owner_handle = $this->handles[$owner_phid]; $card->setOwner($owner_handle); } $project_phids = $object->getProjectPHIDs(); $project_handles = array_select_keys($this->handles, $project_phids); if ($project_handles) { $card->setProjectHandles($project_handles); } $cover_phid = $object->getCoverImageThumbnailPHID(); if ($cover_phid) { $cover_file = idx($this->coverFiles, $cover_phid); if ($cover_file) { $card->setCoverImageFile($cover_file); } } return $card; }
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved) { $backer_phids = $saved->getParameter('backerPHIDs', array()); $all_phids = array_mergev(array($backer_phids)); $handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($all_phids)->execute(); $form->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Backers'))->setName('backers')->setDatasource(new PhabricatorPeopleDatasource())->setValue(array_select_keys($handles, $backer_phids))); }
public static function sortAndGroupInlines(array $inlines, array $changesets) { assert_instances_of($inlines, 'DifferentialTransaction'); assert_instances_of($changesets, 'DifferentialChangeset'); $changesets = mpull($changesets, null, 'getID'); $changesets = msort($changesets, 'getFilename'); // Group the changesets by file and reorder them by display order. $inline_groups = array(); foreach ($inlines as $inline) { $changeset_id = $inline->getComment()->getChangesetID(); $inline_groups[$changeset_id][] = $inline; } $inline_groups = array_select_keys($inline_groups, array_keys($changesets)); foreach ($inline_groups as $changeset_id => $group) { // Sort the group of inlines by line number. $items = array(); foreach ($group as $inline) { $comment = $inline->getComment(); $num = $comment->getLineNumber(); $len = $comment->getLineLength(); $id = $comment->getID(); $items[] = array('inline' => $inline, 'sort' => sprintf('~%010d%010d%010d', $num, $len, $id)); } $items = isort($items, 'sort'); $items = ipull($items, 'inline'); $inline_groups[$changeset_id] = $items; } return $inline_groups; }
public static function getColorMap() { $shades = PHUITagView::getShadeMap(); $shades = array_select_keys($shades, array(PhabricatorProject::DEFAULT_COLOR)) + $shades; unset($shades[PHUITagView::COLOR_DISABLED]); return $shades; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $content_type_map = HeraldContentTypeConfig::getContentTypeMap(); if (empty($content_type_map[$this->contentType])) { $this->contentType = head_key($content_type_map); } $rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap(); if (empty($rule_type_map[$this->ruleType])) { $this->ruleType = HeraldRuleTypeConfig::RULE_TYPE_PERSONAL; } // Reorder array to put "personal" first. $rule_type_map = array_select_keys($rule_type_map, array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL)) + $rule_type_map; $captions = array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL => 'Personal rules notify you about events. You own them, but they can ' . 'only affect you.', HeraldRuleTypeConfig::RULE_TYPE_GLOBAL => 'Global rules notify anyone about events. No one owns them, and ' . 'anyone can edit them. Usually, Global rules are used to notify ' . 'mailing lists.'); $radio = id(new AphrontFormRadioButtonControl())->setLabel('Type')->setName('rule_type')->setValue($this->ruleType); foreach ($rule_type_map as $value => $name) { $radio->addButton($value, $name, idx($captions, $value)); } $form = id(new AphrontFormView())->setUser($user)->setAction('/herald/rule/')->appendChild(id(new AphrontFormSelectControl())->setLabel('New rule for')->setName('content_type')->setValue($this->contentType)->setOptions($content_type_map))->appendChild($radio)->appendChild(id(new AphrontFormSubmitControl())->setValue('Create Rule')->addCancelButton('/herald/view/' . $this->contentType . '/')); $panel = new AphrontPanelView(); $panel->setHeader('Create New Herald Rule'); $panel->setWidth(AphrontPanelView::WIDTH_FULL); $panel->appendChild($form); $nav = $this->renderNav(); $nav->selectFilter('new'); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Create Herald Rule')); }
protected function execute(ConduitAPIRequest $request) { $user = $request->getUser(); $ids = $request->getValue('ids', array()); $phids = $request->getValue('phids', array()); $limit = $request->getValue('limit'); $offset = $request->getValue('offset'); $query = id(new ConpherenceThreadQuery())->setViewer($user)->needParticipantCache(true)->needFilePHIDs(true); if ($ids) { $conpherences = $query->withIDs($ids)->setLimit($limit)->setOffset($offset)->execute(); } else { if ($phids) { $conpherences = $query->withPHIDs($phids)->setLimit($limit)->setOffset($offset)->execute(); } else { $participation = id(new ConpherenceParticipantQuery())->withParticipantPHIDs(array($user->getPHID()))->setLimit($limit)->setOffset($offset)->execute(); $conpherence_phids = array_keys($participation); $query->withPHIDs($conpherence_phids); $conpherences = $query->execute(); $conpherences = array_select_keys($conpherences, $conpherence_phids); } } $data = array(); foreach ($conpherences as $conpherence) { $id = $conpherence->getID(); $data[$id] = array('conpherenceID' => $id, 'conpherencePHID' => $conpherence->getPHID(), 'conpherenceTitle' => $conpherence->getTitle(), 'messageCount' => $conpherence->getMessageCount(), 'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(), 'filePHIDs' => $conpherence->getFilePHIDs(), 'conpherenceURI' => $this->getConpherenceURI($conpherence)); } return $data; }
public function render() { $conpherence = $this->getConpherence(); $widget_data = $conpherence->getWidgetData(); $viewer = $this->getUser(); $participants = $conpherence->getParticipants(); $handles = $conpherence->getHandles(); $head_handles = array_select_keys($handles, array($viewer->getPHID())); $handle_list = mpull($handles, 'getName'); natcasesort($handle_list); $handles = mpull($handles, null, 'getName'); $handles = array_select_keys($handles, $handle_list); $head_handles = mpull($head_handles, null, 'getName'); $handles = $head_handles + $handles; $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_EDIT); $body = array(); foreach ($handles as $handle) { $user_phid = $handle->getPHID(); if ($user_phid == $viewer->getPHID() || $can_edit) { $icon = id(new PHUIIconView())->setIcon('fa-times lightbluetext'); $remove_html = javelin_tag('a', array('class' => 'remove', 'sigil' => 'remove-person', 'meta' => array('remove_person' => $user_phid, 'action' => 'remove_person')), $icon); } else { $remove_html = null; } $body[] = phutil_tag('div', array('class' => 'person-entry grouped'), array(phutil_tag('a', array('class' => 'pic', 'href' => $handle->getURI()), phutil_tag('img', array('src' => $handle->getImageURI()), '')), $handle->renderLink(), $remove_html)); } return $body; }
public static function getConditionMapForField($field) { $map = self::getConditionMap(); switch ($field) { case HeraldFieldConfig::FIELD_TITLE: case HeraldFieldConfig::FIELD_BODY: return array_select_keys($map, array(self::CONDITION_CONTAINS, self::CONDITION_NOT_CONTAINS, self::CONDITION_IS, self::CONDITION_IS_NOT, self::CONDITION_REGEXP)); case HeraldFieldConfig::FIELD_AUTHOR: case HeraldFieldConfig::FIELD_REPOSITORY: case HeraldFieldConfig::FIELD_REVIEWER: case HeraldFieldConfig::FIELD_MERGE_REQUESTER: return array_select_keys($map, array(self::CONDITION_IS_ANY, self::CONDITION_IS_NOT_ANY)); case HeraldFieldConfig::FIELD_TAGS: case HeraldFieldConfig::FIELD_REVIEWERS: case HeraldFieldConfig::FIELD_CC: case HeraldFieldConfig::FIELD_DIFFERENTIAL_REVIEWERS: case HeraldFieldConfig::FIELD_DIFFERENTIAL_CCS: return array_select_keys($map, array(self::CONDITION_INCLUDE_ALL, self::CONDITION_INCLUDE_ANY, self::CONDITION_INCLUDE_NONE)); case HeraldFieldConfig::FIELD_DIFF_FILE: return array_select_keys($map, array(self::CONDITION_CONTAINS, self::CONDITION_REGEXP)); case HeraldFieldConfig::FIELD_DIFF_CONTENT: return array_select_keys($map, array(self::CONDITION_CONTAINS, self::CONDITION_REGEXP, self::CONDITION_REGEXP_PAIR)); case HeraldFieldConfig::FIELD_RULE: return array_select_keys($map, array(self::CONDITION_RULE, self::CONDITION_NOT_RULE)); case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE: case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE_OWNER: case HeraldFieldConfig::FIELD_NEED_AUDIT_FOR_PACKAGE: return array_select_keys($map, array(self::CONDITION_INCLUDE_ANY, self::CONDITION_INCLUDE_NONE)); case HeraldFieldConfig::FIELD_DIFFERENTIAL_REVISION: return array_select_keys($map, array(self::CONDITION_EXISTS, self::CONDITION_NOT_EXISTS)); default: throw new Exception("Unknown field type '{$field}'."); } }
public function loadPHIDs(array $phids) { $need = array(); foreach ($phids as $phid) { if (empty($this->handles[$phid])) { $need[$phid] = true; } } foreach ($need as $phid => $ignored) { if (empty($this->unloadedPHIDs[$phid])) { throw new Exception(pht('Attempting to load PHID "%s", but it was not requested by any ' . 'handle list.', $phid)); } } // If we need any handles, bulk load everything in the queue. if ($need) { // Clear the list of PHIDs that need to be loaded before performing the // actual fetch. This prevents us from looping if we need to reenter the // HandlePool while loading handles. $fetch_phids = array_keys($this->unloadedPHIDs); $this->unloadedPHIDs = array(); $handles = id(new PhabricatorHandleQuery())->setViewer($this->getViewer())->withPHIDs($fetch_phids)->execute(); $this->handles += $handles; } return array_select_keys($this->handles, $phids); }
public function execute(PhutilArgumentParser $args) { $source = $this->loadSource($args, 'source'); $definition = $source->getDefinition()->setViewer($this->getViewer())->setSource($source); if (!$definition->hasImportCursors()) { throw new PhutilArgumentUsageException(pht('This source ("%s") does not expose import cursors.', $source->getName())); } $cursors = $definition->getImportCursors(); if (!$cursors) { throw new PhutilArgumentUsageException(pht('This source ("%s") does not have any import cursors.', $source->getName())); } $select = $args->getArg('cursor'); if (strlen($select)) { if (empty($cursors[$select])) { throw new PhutilArgumentUsageException(pht('This source ("%s") does not have a "%s" cursor. Available ' . 'cursors: %s.', $source->getName(), $select, implode(', ', array_keys($cursors)))); } else { echo tsprintf("%s\n", pht('Importing cursor "%s" only.', $select)); $cursors = array_select_keys($cursors, array($select)); } } else { echo tsprintf("%s\n", pht('Importing all cursors: %s.', implode(', ', array_keys($cursors)))); echo tsprintf("%s\n", pht('(Use --cursor to import only a particular cursor.)')); } foreach ($cursors as $cursor) { $cursor->importFromSource(); } return 0; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $applications = PhabricatorApplication::getAllInstalledApplications(); foreach ($applications as $key => $application) { if (!$application->shouldAppearInLaunchView()) { unset($applications[$key]); } } $groups = PhabricatorApplication::getApplicationGroups(); $applications = msort($applications, 'getApplicationOrder'); $applications = mgroup($applications, 'getApplicationGroup'); $applications = array_select_keys($applications, array_keys($groups)); $view = array(); foreach ($applications as $group => $application_list) { $status = array(); foreach ($application_list as $key => $application) { $status[$key] = $application->loadStatus($user); } $views = array(); foreach ($application_list as $key => $application) { $views[] = id(new PhabricatorApplicationLaunchView())->setApplication($application)->setApplicationStatus(idx($status, $key, array()))->setUser($user); } $view[] = id(new PhabricatorHeaderView())->setHeader($groups[$group]); $view[] = phutil_render_tag('div', array('class' => 'phabricator-application-list'), id(new AphrontNullView())->appendChild($views)->render()); } return $this->buildApplicationPage($view, array('title' => 'Applications', 'device' => true)); }
protected function didFilterPage(array $dashboards) { $phids = mpull($dashboards, 'getPHID'); if ($this->needPanels) { $edge_query = id(new PhabricatorEdgeQuery())->withSourcePHIDs($phids)->withEdgeTypes(array(PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)); $edge_query->execute(); $panel_phids = $edge_query->getDestinationPHIDs(); if ($panel_phids) { $panels = id(new PhabricatorDashboardPanelQuery())->setParentQuery($this)->setViewer($this->getViewer())->withPHIDs($panel_phids)->execute(); $panels = mpull($panels, null, 'getPHID'); } else { $panels = array(); } foreach ($dashboards as $dashboard) { $dashboard_phids = $edge_query->getDestinationPHIDs(array($dashboard->getPHID())); $dashboard_panels = array_select_keys($panels, $dashboard_phids); $dashboard->attachPanelPHIDs($dashboard_phids); $dashboard->attachPanels($dashboard_panels); } } if ($this->needProjects) { $edge_query = id(new PhabricatorEdgeQuery())->withSourcePHIDs($phids)->withEdgeTypes(array(PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)); $edge_query->execute(); foreach ($dashboards as $dashboard) { $project_phids = $edge_query->getDestinationPHIDs(array($dashboard->getPHID())); $dashboard->attachProjectPHIDs($project_phids); } } return $dashboards; }
public static function newFromDictionary(HarbormasterBuildTarget $build_target, array $dict) { $obj = self::initializeNewUnitMessage($build_target); $spec = self::getParameterSpec(); $spec = ipull($spec, 'type'); // We're just going to ignore extra keys for now, to make it easier to // add stuff here later on. $dict = array_select_keys($dict, array_keys($spec)); PhutilTypeSpec::checkMap($dict, $spec); $obj->setEngine(idx($dict, 'engine', '')); $obj->setNamespace(idx($dict, 'namespace', '')); $obj->setName($dict['name']); $obj->setResult($dict['result']); $obj->setDuration((double) idx($dict, 'duration')); $path = idx($dict, 'path'); if (strlen($path)) { $obj->setProperty('path', $path); } $coverage = idx($dict, 'coverage'); if ($coverage) { $obj->setProperty('coverage', $coverage); } $details = idx($dict, 'details'); if ($details) { $obj->setProperty('details', $details); } return $obj; }
protected final function loadCommitsByIdentifiers(array $identifiers) { if (!$identifiers) { return array(); } $commits = array(); $commit_data = array(); $drequest = $this->getRequest(); $repository = $drequest->getRepository(); $commits = id(new PhabricatorRepositoryCommit())->loadAllWhere('repositoryID = %d AND commitIdentifier IN (%Ls)', $repository->getID(), $identifiers); $commits = mpull($commits, null, 'getCommitIdentifier'); // Reorder the commits in identifier order so we preserve nth-parent // relationships when the identifiers are the parents of a merge commit. $commits = array_select_keys($commits, $identifiers); if (!$commits) { return array(); } $commit_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere('commitID in (%Ld)', mpull($commits, 'getID')); $commit_data = mpull($commit_data, null, 'getCommitID'); foreach ($commits as $commit) { if (idx($commit_data, $commit->getID())) { $commit->attachCommitData($commit_data[$commit->getID()]); } } return $commits; }
protected function willFilterPage(array $phids) { $objects = id(new PhabricatorObjectQuery())->setViewer($this->getViewer())->withPHIDs($phids)->execute(); // Reorder the objects in the input order. $objects = array_select_keys($objects, $phids); return $objects; }
public function render() { $conpherence = $this->conpherence; $viewer = $this->getViewer(); $participants = $conpherence->getParticipants(); $count = new PhutilNumber(count($participants)); $handles = $conpherence->getHandles(); $handles = array_intersect_key($handles, $participants); $head_handles = array_select_keys($handles, array($viewer->getPHID())); $handle_list = mpull($handles, 'getName'); natcasesort($handle_list); $handles = mpull($handles, null, 'getName'); $handles = array_select_keys($handles, $handle_list); $head_handles = mpull($head_handles, null, 'getName'); $handles = $head_handles + $handles; $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_EDIT); $body = array(); foreach ($handles as $handle) { $user_phid = $handle->getPHID(); if ($user_phid == $viewer->getPHID() || $can_edit) { $icon = id(new PHUIIconView())->setIcon('fa-times')->addClass('lightbluetext'); $remove_html = javelin_tag('a', array('class' => 'remove', 'sigil' => 'remove-person', 'meta' => array('remove_person' => $user_phid, 'action' => 'remove_person')), $icon); } else { $remove_html = null; } $body[] = phutil_tag('div', array('class' => 'person-entry grouped'), array(phutil_tag('a', array('class' => 'pic', 'href' => $handle->getURI()), phutil_tag('img', array('src' => $handle->getImageURI()), '')), $handle->renderLink(), $remove_html)); } $new_icon = id(new PHUIIconView())->setIcon('fa-plus-square')->setHref($this->updateURI)->setMetadata(array('widget' => null))->addSigil('conpherence-widget-adder'); $header = id(new PHUIHeaderView())->setHeader(pht('Participants (%d)', $count))->addClass('widgets-header')->addActionItem($new_icon); $content = javelin_tag('div', array('class' => 'widgets-body', 'id' => 'widgets-people', 'sigil' => 'widgets-people'), array($header, $body)); return $content; }
protected function renderOwnersSection() { $section = array(); $add_owners = $this->addOwners; $remove_owners = $this->removeOwners; $handles = $this->getHandles(); if ($add_owners) { $add_owners = array_select_keys($handles, $add_owners); $add_owners = mpull($add_owners, 'getName'); $section[] = 'ADDED OWNERS'; $section[] = ' ' . implode(', ', $add_owners); } if ($remove_owners) { if ($add_owners) { $section[] = ''; } $remove_owners = array_select_keys($handles, $remove_owners); $remove_owners = mpull($remove_owners, 'getName'); $section[] = 'REMOVED OWNERS'; $section[] = ' ' . implode(', ', $remove_owners); } if ($section) { return implode("\n", $section); } else { return null; } }
protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $phid = $request->getValue('objectPHID'); // NOTE: We use withNames() to let monograms like "D123" work, which makes // this a little easier to test. Real PHIDs will still work as expected. $object = id(new PhabricatorObjectQuery())->setViewer($viewer)->withNames(array($phid))->executeOne(); if (!$object) { throw new Exception(pht('No such object "%s" exists.', $phid)); } if (!$object instanceof HarbormasterBuildableInterface) { throw new Exception(pht('Object "%s" does not implement interface "%s". Autotargets may ' . 'only be queried for buildable objects.', $phid, 'HarbormasterBuildableInterface')); } $autotargets = $request->getValue('targetKeys', array()); if ($autotargets) { $targets = id(new HarbormasterTargetEngine())->setViewer($viewer)->setObject($object)->setAutoTargetKeys($autotargets)->buildTargets(); } else { $targets = array(); } // Reorder the results according to the request order so we can make test // assertions that subsequent calls return the same results. $map = mpull($targets, 'getPHID'); $map = array_select_keys($map, $autotargets); return array('targetMap' => $map); }
protected function loadPage() { $phids = $this->loadDocumentPHIDsWithoutPolicyChecks(); $handles = id(new PhabricatorHandleQuery())->setViewer($this->getViewer())->requireObjectCapabilities($this->getRequiredObjectCapabilities())->withPHIDs($phids)->execute(); // Retain engine order. $handles = array_select_keys($handles, $phids); return $handles; }
private function getTopographicSort(array $graph, $seed = 'A') { $detector = new TestAbstractDirectedGraph(); $detector->setTestData($graph); $detector->addNodes(array_select_keys($graph, array($seed))); $detector->loadGraph(); return $detector->getTopographicallySortedNodes(); }
private function findGraphCycle(array $graph, $seed = 'A', $search = 'A') { $detector = new TestAbstractDirectedGraph(); $detector->setTestData($graph); $detector->addNodes(array_select_keys($graph, array($seed))); $detector->loadGraph(); return $detector->detectCycles($search); }
protected function loadPage() { $engines = PhabricatorEditEngine::getAllEditEngines(); if ($this->engineKeys !== null) { $engines = array_select_keys($engines, $this->engineKeys); } return $engines; }
public function execute(PhutilArgumentParser $args) { $console = PhutilConsole::getConsole(); $repos = id(new PhabricatorRepositoryQuery())->setViewer($this->getViewer())->execute(); if (!$repos) { $console->writeErr("%s\n", pht('There are no repositories.')); return 0; } $from = $args->getArg('from'); if (!strlen($from)) { throw new Exception(pht('You must specify a path prefix to move from with --from.')); } $to = $args->getArg('to'); if (!strlen($to)) { throw new Exception(pht('You must specify a path prefix to move to with --to.')); } $rows = array(); $any_changes = false; foreach ($repos as $repo) { $src = $repo->getLocalPath(); $row = array('repository' => $repo, 'move' => false, 'monogram' => $repo->getMonogram(), 'src' => $src, 'dst' => ''); if (strncmp($src, $from, strlen($from))) { $row['action'] = pht('Ignore'); } else { $dst = $to . substr($src, strlen($from)); $row['action'] = phutil_console_format('**%s**', pht('Move')); $row['dst'] = $dst; $row['move'] = true; $any_changes = true; } $rows[] = $row; } $table = id(new PhutilConsoleTable())->addColumn('action', array('title' => pht('Action')))->addColumn('monogram', array('title' => pht('Repository')))->addColumn('src', array('title' => pht('Src')))->addColumn('dst', array('title' => pht('dst')))->setBorders(true); foreach ($rows as $row) { $display = array_select_keys($row, array('action', 'monogram', 'src', 'dst')); $table->addRow($display); } $table->draw(); if (!$any_changes) { $console->writeOut(pht('No matching repositories.') . "\n"); return 0; } $prompt = pht('Apply these changes?'); if (!phutil_console_confirm($prompt)) { throw new Exception(pht('Declining to apply changes.')); } foreach ($rows as $row) { if (empty($row['move'])) { continue; } $repo = $row['repository']; $details = $repo->getDetails(); $details['local-path'] = $row['dst']; queryfx($repo->establishConnection('w'), 'UPDATE %T SET details = %s WHERE id = %d', $repo->getTableName(), phutil_json_encode($details), $repo->getID()); } $console->writeOut(pht('Applied changes.') . "\n"); return 0; }
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query) { $author_phids = $saved_query->getParameter('authorPHIDs', array()); $answerer_phids = $saved_query->getParameter('answererPHIDs', array()); $status = $saved_query->getParameter('status', PonderQuestionStatus::STATUS_OPEN); $phids = array_merge($author_phids, $answerer_phids); $handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute(); $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue(array_select_keys($handles, $author_phids)))->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('answerers')->setLabel(pht('Answered By'))->setValue(array_select_keys($handles, $answerer_phids)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setValue($status)->setOptions(PonderQuestionStatus::getQuestionStatusMap())); }
public function renderEditControl(array $handles) { if ($this->getValue()) { $control_value = array_select_keys($handles, array($this->getValue())); } else { $control_value = array(); } return id(new AphrontFormTokenizerControl())->setName($this->getFieldKey())->setDatasource(new DiffusionRepositoryDatasource())->setValue($control_value)->setError($this->getFieldError())->setLabel($this->getFieldName())->setLimit(1); }
protected function buildFutures(array $paths) { foreach ($paths as $path) { if (!isset($this->futures[$path])) { $this->futures[$path] = xhpast_get_parser_future($this->getData($path)); } } return array_select_keys($this->futures, $paths); }