本文整理汇总了PHP中array_select_keys函数的典型用法代码示例。如果您正苦于以下问题:PHP array_select_keys函数的具体用法?PHP array_select_keys怎么用?PHP array_select_keys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_select_keys函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIconMap
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;
}
示例2: getUnresolvedIssues
public function getUnresolvedIssues()
{
$issues = $this->getIssues();
$issues = mpull($issues, null, 'getIssueKey');
$unresolved_keys = PhabricatorSetupCheck::getUnignoredIssueKeys($issues);
return array_select_keys($issues, $unresolved_keys);
}
示例3: render
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>');
}
示例4: renderDashboard
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;
}
示例5: renderCard
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;
}
示例6: buildSearchForm
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)));
}
示例7: sortAndGroupInlines
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;
}
示例8: getColorMap
public static function getColorMap()
{
$shades = PHUITagView::getShadeMap();
$shades = array_select_keys($shades, array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
unset($shades[PHUITagView::COLOR_DISABLED]);
return $shades;
}
示例9: processRequest
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'));
}
示例10: execute
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;
}
示例11: render
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;
}
示例12: getConditionMapForField
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}'.");
}
}
示例13: loadPHIDs
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);
}
示例14: execute
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;
}
示例15: processRequest
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));
}