当前位置: 首页>>代码示例>>PHP>>正文


PHP array_fuse函数代码示例

本文整理汇总了PHP中array_fuse函数的典型用法代码示例。如果您正苦于以下问题:PHP array_fuse函数的具体用法?PHP array_fuse怎么用?PHP array_fuse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_fuse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $ids = $args->getArg('id');
     if (!$ids) {
         throw new PhutilArgumentUsageException(pht("Use the '%s' flag to specify one or more SMS messages to show.", '--id'));
     }
     $messages = id(new PhabricatorSMS())->loadAllWhere('id IN (%Ld)', $ids);
     if ($ids) {
         $ids = array_fuse($ids);
         $missing = array_diff_key($ids, $messages);
         if ($missing) {
             throw new PhutilArgumentUsageException(pht('Some specified SMS messages do not exist: %s', implode(', ', array_keys($missing))));
         }
     }
     $last_key = last_key($messages);
     foreach ($messages as $message_key => $message) {
         $info = array();
         $info[] = pht('PROPERTIES');
         $info[] = pht('ID: %d', $message->getID());
         $info[] = pht('Status: %s', $message->getSendStatus());
         $info[] = pht('To: %s', $message->getToNumber());
         $info[] = pht('From: %s', $message->getFromNumber());
         $info[] = null;
         $info[] = pht('BODY');
         $info[] = $message->getBody();
         $info[] = null;
         $console->writeOut('%s', implode("\n", $info));
         if ($message_key != $last_key) {
             $console->writeOut("\n%s\n\n", str_repeat('-', 80));
         }
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:PhabricatorSMSManagementShowOutboundWorkflow.php

示例2: getUsersFromRequest

 protected function getUsersFromRequest(AphrontRequest $request, $key, array $allow_types = array())
 {
     $list = $this->getListFromRequest($request, $key);
     $phids = array();
     $names = array();
     $allow_types = array_fuse($allow_types);
     $user_type = PhabricatorPeopleUserPHIDType::TYPECONST;
     foreach ($list as $item) {
         $type = phid_get_type($item);
         if ($type == $user_type) {
             $phids[] = $item;
         } else {
             if (isset($allow_types[$type])) {
                 $phids[] = $item;
             } else {
                 if (PhabricatorTypeaheadDatasource::isFunctionToken($item)) {
                     // If this is a function, pass it through unchanged; we'll evaluate
                     // it later.
                     $phids[] = $item;
                 } else {
                     $names[] = $item;
                 }
             }
         }
     }
     if ($names) {
         $users = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withUsernames($names)->execute();
         foreach ($users as $user) {
             $phids[] = $user->getPHID();
         }
         $phids = array_unique($phids);
     }
     return $phids;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:34,代码来源:PhabricatorSearchTokenizerField.php

示例3: getValueForTransaction

 public function getValueForTransaction()
 {
     $new = parent::getValueForTransaction();
     if (!$this->getUseEdgeTransactions()) {
         return $new;
     }
     $old = $this->getInitialValue();
     if ($old === null) {
         return array('=' => array_fuse($new));
     }
     // If we're building an edge transaction and the request has data about the
     // original value the user saw when they loaded the form, interpret the
     // edit as a mixture of "+" and "-" operations instead of a single "="
     // operation. This limits our exposure to race conditions by making most
     // concurrent edits merge correctly.
     $add = array_diff($new, $old);
     $rem = array_diff($old, $new);
     $value = array();
     if ($add) {
         $value['+'] = array_fuse($add);
     }
     if ($rem) {
         $value['-'] = array_fuse($rem);
     }
     return $value;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:26,代码来源:PhabricatorPHIDListEditField.php

示例4: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $book_name = $request->getURIData('book');
     $book = id(new DivinerBookQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->needProjectPHIDs(true)->withNames(array($book_name))->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $view_uri = '/book/' . $book->getName() . '/';
     if ($request->isFormPost()) {
         $v_projects = $request->getArr('projectPHIDs');
         $v_view = $request->getStr('viewPolicy');
         $v_edit = $request->getStr('editPolicy');
         $xactions = array();
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($v_projects)));
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($v_view);
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($v_edit);
         id(new DivinerLiveBookEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($book, $xactions);
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Basics'));
     $title = pht('Edit %s', $book->getTitle());
     $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($book)->execute();
     $view_capability = PhabricatorPolicyCapability::CAN_VIEW;
     $edit_capability = PhabricatorPolicyCapability::CAN_EDIT;
     $form = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorProjectDatasource())->setName('projectPHIDs')->setLabel(pht('Projects'))->setValue($book->getProjectPHIDs()))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new DiffusionRepositoryDatasource())->setName('repositoryPHIDs')->setLabel(pht('Repository'))->setDisableBehavior(true)->setLimit(1)->setValue($book->getRepositoryPHID() ? array($book->getRepositoryPHID()) : null))->appendChild(id(new AphrontFormPolicyControl())->setName('viewPolicy')->setPolicyObject($book)->setCapability($view_capability)->setPolicies($policies)->setCaption($book->describeAutomaticCapability($view_capability)))->appendChild(id(new AphrontFormPolicyControl())->setName('editPolicy')->setPolicyObject($book)->setCapability($edit_capability)->setPolicies($policies)->setCaption($book->describeAutomaticCapability($edit_capability)))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($view_uri));
     $object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
     $timeline = $this->buildTransactionTimeline($book, new DivinerLiveBookTransactionQuery());
     $timeline->setShouldTerminate(true);
     return $this->buildApplicationPage(array($crumbs, $object_box, $timeline), array('title' => $title));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:32,代码来源:DivinerBookEditController.php

示例5: getGitResult

 protected function getGitResult(ConduitAPIRequest $request)
 {
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     $commit = $drequest->getSymbolicCommit();
     $commit_filter = null;
     if ($commit) {
         $commit_filter = $this->loadTagNamesForCommit($commit);
     }
     $name_filter = $request->getValue('names', null);
     $all_tags = $this->loadGitTagList();
     $all_tags = mpull($all_tags, null, 'getName');
     if ($name_filter !== null) {
         $all_tags = array_intersect_key($all_tags, array_fuse($name_filter));
     }
     if ($commit_filter !== null) {
         $all_tags = array_intersect_key($all_tags, $commit_filter);
     }
     $tags = array_values($all_tags);
     $offset = $request->getValue('offset');
     $limit = $request->getValue('limit');
     if ($offset) {
         $tags = array_slice($tags, $offset);
     }
     if ($limit) {
         $tags = array_slice($tags, 0, $limit);
     }
     if ($request->getValue('needMessages')) {
         $this->loadMessagesForTags($all_tags);
     }
     return mpull($tags, 'toDictionary');
 }
开发者ID:denghp,项目名称:phabricator,代码行数:32,代码来源:DiffusionTagsQueryConduitAPIMethod.php

示例6: buildNav

 public function buildNav()
 {
     $user = $this->getRequest()->getUser();
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/'));
     $applications = id(new PhabricatorApplicationQuery())->setViewer($user)->withInstalled(true)->withUnlisted(false)->withLaunchable(true)->execute();
     $pinned = $user->loadPreferences()->getPinnedApplications($applications, $user);
     // Force "Applications" to appear at the bottom.
     $meta_app = 'PhabricatorApplicationsApplication';
     $pinned = array_fuse($pinned);
     unset($pinned[$meta_app]);
     $pinned[$meta_app] = $meta_app;
     $applications[$meta_app] = PhabricatorApplication::getByClass($meta_app);
     $tiles = array();
     $home_app = new PhabricatorHomeApplication();
     $tiles[] = id(new PhabricatorApplicationLaunchView())->setApplication($home_app)->setApplicationStatus($home_app->loadStatus($user))->addClass('phabricator-application-launch-phone-only')->setUser($user);
     foreach ($pinned as $pinned_application) {
         if (empty($applications[$pinned_application])) {
             continue;
         }
         $application = $applications[$pinned_application];
         $tile = id(new PhabricatorApplicationLaunchView())->setApplication($application)->setApplicationStatus($application->loadStatus($user))->setUser($user);
         $tiles[] = $tile;
     }
     $nav->addCustomBlock(phutil_tag('div', array('class' => 'application-tile-group'), $tiles));
     $nav->addFilter('', pht('Customize Applications...'), '/settings/panel/home/');
     $nav->addClass('phabricator-side-menu-home');
     $nav->selectFilter(null);
     return $nav;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:30,代码来源:PhabricatorHomeController.php

示例7: generateObject

 public function generateObject()
 {
     $author_phid = $this->loadPhabrictorUserPHID();
     $author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $author_phid);
     $task = ManiphestTask::initializeNewTask($author)->setSubPriority($this->generateTaskSubPriority())->setTitle($this->generateTitle());
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_UNKNOWN, array());
     $template = new ManiphestTransaction();
     // Accumulate Transactions
     $changes = array();
     $changes[ManiphestTransaction::TYPE_TITLE] = $this->generateTitle();
     $changes[ManiphestTransaction::TYPE_DESCRIPTION] = $this->generateDescription();
     $changes[ManiphestTransaction::TYPE_OWNER] = $this->loadOwnerPHID();
     $changes[ManiphestTransaction::TYPE_STATUS] = $this->generateTaskStatus();
     $changes[ManiphestTransaction::TYPE_PRIORITY] = $this->generateTaskPriority();
     $changes[PhabricatorTransactions::TYPE_SUBSCRIBERS] = array('=' => $this->getCCPHIDs());
     $transactions = array();
     foreach ($changes as $type => $value) {
         $transaction = clone $template;
         $transaction->setTransactionType($type);
         $transaction->setNewValue($value);
         $transactions[] = $transaction;
     }
     $transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($this->getProjectPHIDs())));
     // Apply Transactions
     $editor = id(new ManiphestTransactionEditor())->setActor($author)->setContentSource($content_source)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($task, $transactions);
     return $task;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:27,代码来源:PhabricatorManiphestTaskTestDataGenerator.php

示例8: getValueForTransaction

 protected function getValueForTransaction()
 {
     $new = parent::getValueForTransaction();
     $edge_types = array(PhabricatorTransactions::TYPE_EDGE => true, PhabricatorTransactions::TYPE_SUBSCRIBERS => true);
     if (isset($edge_types[$this->getTransactionType()])) {
         if ($this->originalValue !== null) {
             // If we're building an edge transaction and the request has data
             // about the original value the user saw when they loaded the form,
             // interpret the edit as a mixture of "+" and "-" operations instead
             // of a single "=" operation. This limits our exposure to race
             // conditions by making most concurrent edits merge correctly.
             $new = parent::getValueForTransaction();
             $old = $this->originalValue;
             $add = array_diff($new, $old);
             $rem = array_diff($old, $new);
             $value = array();
             if ($add) {
                 $value['+'] = array_fuse($add);
             }
             if ($rem) {
                 $value['-'] = array_fuse($rem);
             }
             return $value;
         } else {
             if (!is_array($new)) {
                 throw new Exception(print_r($new, true));
             }
             return array('=' => array_fuse($new));
         }
     }
     return $new;
 }
开发者ID:hamilyjing,项目名称:phabricator,代码行数:32,代码来源:PhabricatorTokenizerEditField.php

示例9: loadAffiliatedUserPHIDs

 public static function loadAffiliatedUserPHIDs(array $package_ids)
 {
     if (!$package_ids) {
         return array();
     }
     $owners = id(new PhabricatorOwnersOwner())->loadAllWhere('packageID IN (%Ls)', $package_ids);
     $type_user = PhabricatorPeopleUserPHIDType::TYPECONST;
     $type_project = PhabricatorProjectProjectPHIDType::TYPECONST;
     $user_phids = array();
     $project_phids = array();
     foreach ($owners as $owner) {
         $owner_phid = $owner->getUserPHID();
         switch (phid_get_type($owner_phid)) {
             case PhabricatorPeopleUserPHIDType::TYPECONST:
                 $user_phids[] = $owner_phid;
                 break;
             case PhabricatorProjectProjectPHIDType::TYPECONST:
                 $project_phids[] = $owner_phid;
                 break;
         }
     }
     if ($project_phids) {
         $projects = id(new PhabricatorProjectQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($project_phids)->needMembers(true)->execute();
         foreach ($projects as $project) {
             foreach ($project->getMemberPHIDs() as $member_phid) {
                 $user_phids[] = $member_phid;
             }
         }
     }
     $user_phids = array_fuse($user_phids);
     return array_values($user_phids);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:32,代码来源:PhabricatorOwnersOwner.php

示例10: applyAuditors

 protected function applyAuditors(array $phids, HeraldRule $rule)
 {
     $adapter = $this->getAdapter();
     $object = $adapter->getObject();
     $auditors = $object->getAudits();
     $current = array();
     foreach ($auditors as $auditor) {
         if ($auditor->isInteresting()) {
             $current[] = $auditor->getAuditorPHID();
         }
     }
     $allowed_types = array(PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorOwnersPackagePHIDType::TYPECONST);
     $targets = $this->loadStandardTargets($phids, $allowed_types, $current);
     if (!$targets) {
         return;
     }
     $phids = array_fuse(array_keys($targets));
     // TODO: Convert this to be translatable, structured data eventually.
     $reason_map = array();
     foreach ($phids as $phid) {
         $reason_map[$phid][] = pht('%s Triggered Audit', $rule->getMonogram());
     }
     $xaction = $adapter->newTransaction()->setTransactionType(PhabricatorAuditActionConstants::ADD_AUDITORS)->setNewValue($phids)->setMetadataValue('auditStatus', PhabricatorAuditStatusConstants::AUDIT_REQUIRED)->setMetadataValue('auditReasonMap', $reason_map);
     $adapter->queueTransaction($xaction);
     $this->logEffect(self::DO_ADD_AUDITORS, $phids);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:26,代码来源:DiffusionAuditorsHeraldAction.php

示例11: processRequest

 public function processRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $username = $user->getUsername();
     $pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
     $pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT;
     $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY;
     $preferences = $user->loadPreferences();
     $errors = array();
     if ($request->isFormPost()) {
         $new_timezone = $request->getStr('timezone');
         if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) {
             $user->setTimezoneIdentifier($new_timezone);
         } else {
             $errors[] = pht('The selected timezone is not a valid timezone.');
         }
         $preferences->setPreference($pref_time, $request->getStr($pref_time))->setPreference($pref_date, $request->getStr($pref_date))->setPreference($pref_week_start, $request->getStr($pref_week_start));
         if (!$errors) {
             $preferences->save();
             $user->save();
             return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true'));
         }
     }
     $timezone_ids = DateTimeZone::listIdentifiers();
     $timezone_id_map = array_fuse($timezone_ids);
     $form = new AphrontFormView();
     $form->setUser($user)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Timezone'))->setName('timezone')->setOptions($timezone_id_map)->setValue($user->getTimezoneIdentifier()))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Time-of-Day Format'))->setName($pref_time)->setOptions(array('g:i A' => pht('12-hour (2:34 PM)'), 'H:i' => pht('24-hour (14:34)')))->setCaption(pht('Format used when rendering a time of day.'))->setValue($preferences->getPreference($pref_time)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Date Format'))->setName($pref_date)->setOptions(array('Y-m-d' => pht('ISO 8601 (2000-02-28)'), 'n/j/Y' => pht('US (2/28/2000)'), 'd-m-Y' => pht('European (28-02-2000)')))->setCaption(pht('Format used when rendering a date.'))->setValue($preferences->getPreference($pref_date)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Week Starts On'))->setOptions($this->getWeekDays())->setName($pref_week_start)->setCaption(pht('Calendar weeks will start with this day.'))->setValue($preferences->getPreference($pref_week_start, 0)))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Account Settings')));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Date and Time Settings'))->setFormSaved($request->getStr('saved'))->setFormErrors($errors)->setForm($form);
     return array($form_box);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:30,代码来源:PhabricatorDateTimeSettingsPanel.php

示例12: parseCommit

 protected function parseCommit(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
 {
     // Reload the commit to pull commit data and audit requests.
     $commit = id(new DiffusionCommitQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIDs(array($commit->getID()))->needCommitData(true)->needAuditRequests(true)->executeOne();
     $data = $commit->getCommitData();
     if (!$data) {
         throw new PhabricatorWorkerPermanentFailureException(pht('Unable to load commit data. The data for this task is invalid ' . 'or no longer exists.'));
     }
     $commit->attachRepository($repository);
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_DAEMON, array());
     $committer_phid = $data->getCommitDetail('committerPHID');
     $author_phid = $data->getCommitDetail('authorPHID');
     $acting_as_phid = nonempty($committer_phid, $author_phid, id(new PhabricatorDiffusionApplication())->getPHID());
     $editor = id(new PhabricatorAuditEditor())->setActor(PhabricatorUser::getOmnipotentUser())->setActingAsPHID($acting_as_phid)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true)->setContentSource($content_source);
     $xactions = array();
     $xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorAuditTransaction::TYPE_COMMIT)->setDateCreated($commit->getEpoch())->setNewValue(array('description' => $data->getCommitMessage(), 'summary' => $data->getSummary(), 'authorName' => $data->getAuthorName(), 'authorPHID' => $commit->getAuthorPHID(), 'committerName' => $data->getCommitDetail('committer'), 'committerPHID' => $data->getCommitDetail('committerPHID')));
     $reverts_refs = id(new DifferentialCustomFieldRevertsParser())->parseCorpus($data->getCommitMessage());
     $reverts = array_mergev(ipull($reverts_refs, 'monograms'));
     if ($reverts) {
         $reverted_commits = id(new DiffusionCommitQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withRepository($repository)->withIdentifiers($reverts)->execute();
         $reverted_commit_phids = mpull($reverted_commits, 'getPHID', 'getPHID');
         // NOTE: Skip any write attempts if a user cleverly implies a commit
         // reverts itself.
         unset($reverted_commit_phids[$commit->getPHID()]);
         $reverts_edge = DiffusionCommitRevertsCommitEdgeType::EDGECONST;
         $xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $reverts_edge)->setNewValue(array('+' => array_fuse($reverted_commit_phids)));
     }
     try {
         $raw_patch = $this->loadRawPatchText($repository, $commit);
     } catch (Exception $ex) {
         $raw_patch = pht('Unable to generate patch: %s', $ex->getMessage());
     }
     $editor->setRawPatch($raw_patch);
     return $editor->applyTransactions($commit, $xactions);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:35,代码来源:PhabricatorRepositoryCommitHeraldWorker.php

示例13: buildSearchForm

 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
 {
     $options = array();
     $author_value = null;
     $owner_value = null;
     $subscribers_value = null;
     $project_value = null;
     $author_phids = $saved->getParameter('authorPHIDs', array());
     $owner_phids = $saved->getParameter('ownerPHIDs', array());
     $subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
     $project_phids = $saved->getParameter('projectPHIDs', array());
     $all_phids = array_merge($author_phids, $owner_phids, $subscriber_phids, $project_phids);
     $all_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($all_phids)->execute();
     $author_handles = array_select_keys($all_handles, $author_phids);
     $owner_handles = array_select_keys($all_handles, $owner_phids);
     $subscriber_handles = array_select_keys($all_handles, $subscriber_phids);
     $project_handles = array_select_keys($all_handles, $project_phids);
     $with_unowned = $saved->getParameter('withUnowned', array());
     $status_values = $saved->getParameter('statuses', array());
     $status_values = array_fuse($status_values);
     $statuses = array(PhabricatorSearchRelationship::RELATIONSHIP_OPEN => pht('Open'), PhabricatorSearchRelationship::RELATIONSHIP_CLOSED => pht('Closed'));
     $status_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Document Status'));
     foreach ($statuses as $status => $name) {
         $status_control->addCheckbox('statuses[]', $status, $name, isset($status_values[$status]));
     }
     $type_values = $saved->getParameter('types', array());
     $type_values = array_fuse($type_values);
     $types = self::getIndexableDocumentTypes($this->requireViewer());
     $types_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Document Types'));
     foreach ($types as $type => $name) {
         $types_control->addCheckbox('types[]', $type, $name, isset($type_values[$type]));
     }
     $form->appendChild(phutil_tag('input', array('type' => 'hidden', 'name' => 'jump', 'value' => 'no')))->appendChild(id(new AphrontFormTextControl())->setLabel('Query')->setName('query')->setValue($saved->getParameter('query')))->appendChild($status_control)->appendChild($types_control)->appendChild(id(new AphrontFormTokenizerControl())->setName('authorPHIDs')->setLabel('Authors')->setDatasource(new PhabricatorPeopleDatasource())->setValue($author_handles))->appendChild(id(new AphrontFormTokenizerControl())->setName('ownerPHIDs')->setLabel('Owners')->setDatasource(new PhabricatorTypeaheadOwnerDatasource())->setValue($owner_handles))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('withUnowned', 1, pht('Show only unowned documents.'), $with_unowned))->appendChild(id(new AphrontFormTokenizerControl())->setName('subscriberPHIDs')->setLabel('Subscribers')->setDatasource(new PhabricatorPeopleDatasource())->setValue($subscriber_handles))->appendChild(id(new AphrontFormTokenizerControl())->setName('projectPHIDs')->setLabel('In Any Project')->setDatasource(new PhabricatorProjectDatasource())->setValue($project_handles));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:34,代码来源:PhabricatorSearchApplicationSearchEngine.php

示例14: loadForRevision

 public static function loadForRevision($revision)
 {
     $app_legalpad = 'PhabricatorLegalpadApplication';
     if (!PhabricatorApplication::isClassInstalled($app_legalpad)) {
         return array();
     }
     if (!$revision->getPHID()) {
         return array();
     }
     $phids = PhabricatorEdgeQuery::loadDestinationPHIDs($revision->getPHID(), LegalpadObjectNeedsSignatureEdgeType::EDGECONST);
     if ($phids) {
         // NOTE: We're bypassing permissions to pull these. We have to expose
         // some information about signature status in order to implement this
         // field meaningfully (otherwise, we could not tell reviewers that they
         // can't accept the revision yet), but that's OK because the only way to
         // require signatures is with a "Global" Herald rule, which requires a
         // high level of access.
         $signatures = id(new LegalpadDocumentSignatureQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withDocumentPHIDs($phids)->withSignerPHIDs(array($revision->getAuthorPHID()))->execute();
         $signatures = mpull($signatures, null, 'getDocumentPHID');
         $phids = array_fuse($phids);
         foreach ($phids as $phid) {
             $phids[$phid] = isset($signatures[$phid]);
         }
     }
     return $phids;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:26,代码来源:DifferentialRequiredSignaturesField.php

示例15: renderOptions

 private static function renderOptions($selected, array $options, array $disabled = array())
 {
     $disabled = array_fuse($disabled);
     $tags = array();
     $already_selected = false;
     foreach ($options as $value => $thing) {
         if (is_array($thing)) {
             $tags[] = phutil_tag('optgroup', array('label' => $value), self::renderOptions($selected, $thing));
         } else {
             // When there are a list of options including similar values like
             // "0" and "" (the empty string), only select the first matching
             // value. Ideally this should be more precise about matching, but we
             // have 2,000 of these controls at this point so hold that for a
             // broader rewrite.
             if (!$already_selected && $value == $selected) {
                 $is_selected = 'selected';
                 $already_selected = true;
             } else {
                 $is_selected = null;
             }
             $tags[] = phutil_tag('option', array('selected' => $is_selected, 'value' => $value, 'disabled' => isset($disabled[$value]) ? 'disabled' : null), $thing);
         }
     }
     return $tags;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:25,代码来源:AphrontFormSelectControl.php


注:本文中的array_fuse函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。