• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mgroup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getQuickMenuItems

 public function getQuickMenuItems()
 {
     $viewer = $this->getViewer();
     $engines = PhabricatorEditEngine::getAllEditEngines();
     foreach ($engines as $key => $engine) {
         if (!$engine->hasQuickCreateActions()) {
             unset($engines[$key]);
         }
     }
     if (!$engines) {
         return array();
     }
     $engine_keys = array_keys($engines);
     $configs = id(new PhabricatorEditEngineConfigurationQuery())->setViewer($viewer)->withEngineKeys($engine_keys)->withIsDefault(true)->withIsDisabled(false)->execute();
     $configs = msort($configs, 'getCreateSortKey');
     $configs = mgroup($configs, 'getEngineKey');
     $items = array();
     foreach ($engines as $key => $engine) {
         $engine_configs = idx($configs, $key, array());
         $engine_items = $engine->newQuickCreateActions($engine_configs);
         foreach ($engine_items as $engine_item) {
             $items[] = $engine_item;
         }
     }
     return $items;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:26,代码来源:PhabricatorEditEngineCreateQuickActions.php


示例2: lookupRepository

 public function lookupRepository()
 {
     $viewer = $this->viewer;
     $diff = $this->diff;
     // Look for a repository UUID.
     if ($diff->getRepositoryUUID()) {
         $repositories = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withUUIDs(array($diff->getRepositoryUUID()))->execute();
         if ($repositories) {
             return head($repositories);
         }
     }
     // Look for the base commit in Git and Mercurial.
     $vcs = $diff->getSourceControlSystem();
     $vcs_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
     $vcs_hg = PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL;
     if ($vcs == $vcs_git || $vcs == $vcs_hg) {
         $base = $diff->getSourceControlBaseRevision();
         if ($base) {
             $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(array($base))->execute();
             $commits = mgroup($commits, 'getRepositoryID');
             if (count($commits) == 1) {
                 $repository_id = key($commits);
                 $repositories = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withIDs(array($repository_id))->execute();
                 if ($repositories) {
                     return head($repositories);
                 }
             }
         }
     }
     // TODO: Compare SVN remote URIs? Compare Git/Hg remote URIs? Add
     // an explicit option to `.arcconfig`?
     return null;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:DifferentialRepositoryLookup.php


示例3: 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));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:29,代码来源:PhabricatorApplicationsListController.php


示例4: execute

 protected function execute(ConduitAPIRequest $request)
 {
     $results = array();
     $revision_ids = $request->getValue('ids');
     if (!$revision_ids) {
         return $results;
     }
     $comments = id(new DifferentialComment())->loadAllWhere('revisionID IN (%Ld)', $revision_ids);
     $with_inlines = $request->getValue('inlines');
     if ($with_inlines) {
         $inlines = id(new DifferentialInlineComment())->loadAllWhere('revisionID IN (%Ld)', $revision_ids);
         $changesets = array();
         if ($inlines) {
             $changesets = id(new DifferentialChangeset())->loadAllWhere('id IN (%Ld)', array_unique(mpull($inlines, 'getChangesetID')));
             $inlines = mgroup($inlines, 'getCommentID');
         }
     }
     foreach ($comments as $comment) {
         $revision_id = $comment->getRevisionID();
         $result = array('revisionID' => $revision_id, 'action' => $comment->getAction(), 'authorPHID' => $comment->getAuthorPHID(), 'dateCreated' => $comment->getDateCreated(), 'content' => $comment->getContent());
         if ($with_inlines) {
             $result['inlines'] = array();
             foreach (idx($inlines, $comment->getID(), array()) as $inline) {
                 $changeset = idx($changesets, $inline->getChangesetID());
                 $result['inlines'][] = $this->buildInlineInfoDictionary($inline, $changeset);
             }
             // TODO: Put synthetic inlines without an attached comment somewhere.
         }
         $results[$revision_id][] = $result;
     }
     return $results;
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:32,代码来源:ConduitAPI_differential_getrevisioncomments_Method.php


示例5: didFilterPage

 protected function didFilterPage(array $objects)
 {
     $has_properties = head($objects) instanceof AlmanacPropertyInterface;
     if ($has_properties && $this->needProperties) {
         $property_query = id(new AlmanacPropertyQuery())->setViewer($this->getViewer())->setParentQuery($this)->withObjects($objects);
         $properties = $property_query->execute();
         $properties = mgroup($properties, 'getObjectPHID');
         foreach ($objects as $object) {
             $object_properties = idx($properties, $object->getPHID(), array());
             $object_properties = mpull($object_properties, null, 'getFieldName');
             // Create synthetic properties for defaults on the object itself.
             $specs = $object->getAlmanacPropertyFieldSpecifications();
             foreach ($specs as $key => $spec) {
                 if (empty($object_properties[$key])) {
                     $object_properties[$key] = id(new AlmanacProperty())->setObjectPHID($object->getPHID())->setFieldName($key)->setFieldValue($spec->getValueForTransaction());
                 }
             }
             foreach ($object_properties as $property) {
                 $property->attachObject($object);
             }
             $object->attachAlmanacProperties($object_properties);
         }
     }
     return $objects;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:25,代码来源:AlmanacQuery.php


示例6: processRequest

 public function processRequest()
 {
     $items = id(new PhabricatorDirectoryItem())->loadAll();
     $items = msort($items, 'getSortKey');
     $categories = id(new PhabricatorDirectoryCategory())->loadAll();
     $categories = msort($categories, 'getSequence');
     $category_map = mpull($categories, 'getName', 'getID');
     $category_map[0] = 'Free Radicals';
     $items = mgroup($items, 'getCategoryID');
     require_celerity_resource('phabricator-directory-css');
     $content = array();
     foreach ($category_map as $id => $category_name) {
         $category_items = idx($items, $id);
         if (!$category_items) {
             continue;
         }
         $item_markup = array();
         foreach ($category_items as $item) {
             $item_markup[] = '<div>' . '<h2>' . phutil_render_tag('a', array('href' => $item->getHref()), phutil_escape_html($item->getName())) . '</h2>' . '<p>' . phutil_escape_html($item->getDescription()) . '</p>' . '</div>';
         }
         $content[] = '<div class="aphront-directory-category">' . '<h1>' . phutil_escape_html($category_name) . '</h1>' . '<div class="aphront-directory-group">' . implode("\n", $item_markup) . '</div>' . '</div>';
     }
     $content = '<div class="aphront-directory-list">' . implode("\n", $content) . '</div>';
     return $this->buildStandardPageResponse($content, array('title' => 'Directory', 'tab' => 'directory'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:25,代码来源:PhabricatorDirectoryMainController.php


示例7: loadPage

 protected function loadPage()
 {
     $table = new PhortuneProduct();
     $conn = $table->establishConnection('r');
     $rows = queryfx_all($conn, 'SELECT * FROM %T %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn), $this->buildOrderClause($conn), $this->buildLimitClause($conn));
     $page = $table->loadAllFromArray($rows);
     // NOTE: We're loading product implementations here, but also creating any
     // products which do not yet exist.
     $class_map = mgroup($page, 'getProductClass');
     if ($this->refMap) {
         $class_map += array_fill_keys(array_keys($this->refMap), array());
     }
     foreach ($class_map as $class => $products) {
         $refs = mpull($products, null, 'getProductRef');
         if (isset($this->refMap[$class])) {
             $refs += array_fill_keys($this->refMap[$class], null);
         }
         $implementations = newv($class, array())->loadImplementationsForRefs($this->getViewer(), array_keys($refs));
         $implementations = mpull($implementations, null, 'getRef');
         foreach ($implementations as $ref => $implementation) {
             $product = idx($refs, $ref);
             if ($product === null) {
                 // If this product does not exist yet, create it and add it to the
                 // result page.
                 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
                 $product = PhortuneProduct::initializeNewProduct()->setProductClass($class)->setProductRef($ref)->save();
                 unset($unguarded);
                 $page[] = $product;
             }
             $product->attachImplementation($implementation);
         }
     }
     return $page;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:34,代码来源:PhortuneProductQuery.php


示例8: loadAllForProjectPHIDs

 public static function loadAllForProjectPHIDs($phids)
 {
     if (!$phids) {
         return array();
     }
     $default = array_fill_keys($phids, array());
     $affiliations = id(new PhabricatorProjectAffiliation())->loadAllWhere('projectPHID IN (%Ls) ORDER BY IF(status = "former", 1, 0), dateCreated', $phids);
     return mgroup($affiliations, 'getProjectPHID') + $default;
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:9,代码来源:PhabricatorProjectAffiliation.php


示例9: getAllPanelGroupsWithPanels

 public static final function getAllPanelGroupsWithPanels()
 {
     $groups = self::getAllPanelGroups();
     $panels = PhabricatorSettingsPanel::getAllPanels();
     $panels = mgroup($panels, 'getPanelGroupKey');
     foreach ($groups as $key => $group) {
         $group->panels = idx($panels, $key, array());
     }
     return $groups;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:10,代码来源:PhabricatorSettingsPanelGroup.php


示例10: save

 public function save()
 {
     if (!$this->comment) {
         throw new Exception("Must set comment before saving it");
     }
     if (!$this->question) {
         throw new Exception("Must set question before saving comment");
     }
     if (!$this->targetPHID) {
         throw new Exception("Must set target before saving comment");
     }
     if (!$this->viewer) {
         throw new Exception("Must set viewer before saving comment");
     }
     $comment = $this->comment;
     $question = $this->question;
     $target = $this->targetPHID;
     $viewer = $this->viewer;
     $comment->save();
     $question->attachRelated();
     PhabricatorSearchPonderIndexer::indexQuestion($question);
     // subscribe author and @mentions
     $subeditor = id(new PhabricatorSubscriptionsEditor())->setObject($question)->setUser($viewer);
     $subeditor->subscribeExplicit(array($comment->getAuthorPHID()));
     $content = $comment->getContent();
     $at_mention_phids = PhabricatorMarkupEngine::extractPHIDsFromMentions(array($content));
     $subeditor->subscribeImplicit($at_mention_phids);
     $subeditor->save();
     if ($this->shouldEmail) {
         // now load subscribers, including implicitly-added @mention victims
         $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($question->getPHID());
         // @mention emails (but not for anyone who has explicitly unsubscribed)
         if (array_intersect($at_mention_phids, $subscribers)) {
             id(new PonderMentionMail($question, $comment, $viewer))->setToPHIDs($at_mention_phids)->send();
         }
         if ($target === $question->getPHID()) {
             $target = $question;
         } else {
             $answers_by_phid = mgroup($question->getAnswers(), 'getPHID');
             $target = head($answers_by_phid[$target]);
         }
         // only send emails to others in the same thread
         $thread = mpull($target->getComments(), 'getAuthorPHID');
         $thread[] = $target->getAuthorPHID();
         $thread[] = $question->getAuthorPHID();
         $other_subs = array_diff(array_intersect($thread, $subscribers), $at_mention_phids);
         // 'Comment' emails for subscribers who are in the same comment thread,
         // including the author of the parent question and/or answer, excluding
         // @mentions (and excluding the author, depending on their MetaMTA
         // settings).
         if ($other_subs) {
             id(new PonderCommentMail($question, $comment, $viewer))->setToPHIDs($other_subs)->send();
         }
     }
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:55,代码来源:PonderCommentEditor.php


示例11: publishFeedStory

 /**
  * Publishes stories into JIRA using the JIRA API.
  */
 protected function publishFeedStory()
 {
     $story = $this->getFeedStory();
     $viewer = $this->getViewer();
     $provider = $this->getProvider();
     $object = $this->getStoryObject();
     $publisher = $this->getPublisher();
     $jira_issue_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($object->getPHID(), PhabricatorJiraIssueHasObjectEdgeType::EDGECONST);
     if (!$jira_issue_phids) {
         $this->log("%s\n", pht('Story is about an object with no linked JIRA issues.'));
         return;
     }
     $do_anything = $this->shouldPostComment() || $this->shouldPostLink();
     if (!$do_anything) {
         $this->log("%s\n", pht('JIRA integration is configured not to post anything.'));
         return;
     }
     $xobjs = id(new DoorkeeperExternalObjectQuery())->setViewer($viewer)->withPHIDs($jira_issue_phids)->execute();
     if (!$xobjs) {
         $this->log("%s\n", pht('Story object has no corresponding external JIRA objects.'));
         return;
     }
     $try_users = $this->findUsersToPossess();
     if (!$try_users) {
         $this->log("%s\n", pht('No users to act on linked JIRA objects.'));
         return;
     }
     $xobjs = mgroup($xobjs, 'getApplicationDomain');
     foreach ($xobjs as $domain => $xobj_list) {
         $accounts = id(new PhabricatorExternalAccountQuery())->setViewer($viewer)->withUserPHIDs($try_users)->withAccountTypes(array($provider->getProviderType()))->withAccountDomains(array($domain))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
         // Reorder accounts in the original order.
         // TODO: This needs to be adjusted if/when we allow you to link multiple
         // accounts.
         $accounts = mpull($accounts, null, 'getUserPHID');
         $accounts = array_select_keys($accounts, $try_users);
         foreach ($xobj_list as $xobj) {
             foreach ($accounts as $account) {
                 try {
                     $jira_key = $xobj->getObjectID();
                     if ($this->shouldPostComment()) {
                         $this->postComment($account, $jira_key);
                     }
                     if ($this->shouldPostLink()) {
                         $this->postLink($account, $jira_key);
                     }
                     break;
                 } catch (HTTPFutureResponseStatus $ex) {
                     phlog($ex);
                     $this->log("%s\n", pht('Failed to update object %s using user %s.', $xobj->getObjectID(), $account->getUserPHID()));
                 }
             }
         }
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:57,代码来源:DoorkeeperJIRAFeedWorker.php


示例12: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $book_name = $request->getURIData('book');
     $book = id(new DivinerBookQuery())->setViewer($viewer)->withNames(array($book_name))->needRepositories(true)->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $actions = $this->buildActionView($viewer, $book);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setBorder(true);
     $crumbs->addTextCrumb($book->getShortTitle(), '/book/' . $book->getName() . '/');
     $action_button = id(new PHUIButtonView())->setTag('a')->setText(pht('Actions'))->setHref('#')->setIconFont('fa-bars')->addClass('phui-mobile-menu')->setDropdownMenu($actions);
     $header = id(new PHUIHeaderView())->setHeader($book->getTitle())->setUser($viewer)->setPolicyObject($book)->setEpoch($book->getDateModified())->addActionLink($action_button);
     // TODO: This could probably look better.
     if ($book->getRepositoryPHID()) {
         $header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_BLUE)->setName($book->getRepository()->getMonogram()));
     }
     $document = new PHUIDocumentView();
     $document->setHeader($header);
     $document->addClass('diviner-view');
     $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
     $atoms = id(new DivinerAtomQuery())->setViewer($viewer)->withBookPHIDs(array($book->getPHID()))->withGhosts(false)->withIsDocumentable(true)->execute();
     $atoms = msort($atoms, 'getSortKey');
     $group_spec = $book->getConfig('groups');
     if (!is_array($group_spec)) {
         $group_spec = array();
     }
     $groups = mgroup($atoms, 'getGroupName');
     $groups = array_select_keys($groups, array_keys($group_spec)) + $groups;
     if (isset($groups[''])) {
         $no_group = $groups[''];
         unset($groups['']);
         $groups[''] = $no_group;
     }
     $out = array();
     foreach ($groups as $group => $atoms) {
         $group_name = $book->getGroupName($group);
         if (!strlen($group_name)) {
             $group_name = pht('Free Radicals');
         }
         $section = id(new DivinerSectionView())->setHeader($group_name);
         $section->addContent($this->renderAtomList($atoms));
         $out[] = $section;
     }
     $preface = $book->getPreface();
     $preface_view = null;
     if (strlen($preface)) {
         $preface_view = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($preface), 'default', $viewer);
     }
     $document->appendChild($preface_view);
     $document->appendChild($out);
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => $book->getTitle()));
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:54,代码来源:DivinerBookController.php


示例13: didFilterPage

 protected function didFilterPage(array $hunks)
 {
     if ($this->shouldAttachToChangesets) {
         $hunk_groups = mgroup($hunks, 'getChangesetID');
         foreach ($this->changesets as $changeset) {
             $hunks = idx($hunk_groups, $changeset->getID(), array());
             $changeset->attachHunks($hunks);
         }
     }
     return $hunks;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:11,代码来源:DifferentialHunkQuery.php


示例14: handlePropertyEvent

 private function handlePropertyEvent($ui_event)
 {
     $user = $ui_event->getUser();
     $object = $ui_event->getValue('object');
     if (!$object || !$object->getPHID()) {
         // No object, or the object has no PHID yet..
         return;
     }
     if (!$object instanceof PhrequentTrackableInterface) {
         // This object isn't a time trackable object.
         return;
     }
     if (!$this->canUseApplication($ui_event->getUser())) {
         return;
     }
     $events = id(new PhrequentUserTimeQuery())->setViewer($user)->withObjectPHIDs(array($object->getPHID()))->needPreemptingEvents(true)->execute();
     $event_groups = mgroup($events, 'getUserPHID');
     if (!$events) {
         return;
     }
     $handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array_keys($event_groups))->execute();
     $status_view = new PHUIStatusListView();
     foreach ($event_groups as $user_phid => $event_group) {
         $item = new PHUIStatusItemView();
         $item->setTarget($handles[$user_phid]->renderLink());
         $state = 'stopped';
         foreach ($event_group as $event) {
             if ($event->getDateEnded() === null) {
                 if ($event->isPreempted()) {
                     $state = 'suspended';
                 } else {
                     $state = 'active';
                     break;
                 }
             }
         }
         switch ($state) {
             case 'active':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'green', pht('Working Now'));
                 break;
             case 'suspended':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'yellow', pht('Interrupted'));
                 break;
             case 'stopped':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'bluegrey', pht('Not Working Now'));
                 break;
         }
         $block = new PhrequentTimeBlock($event_group);
         $item->setNote(phutil_format_relative_time($block->getTimeSpentOnObject($object->getPHID(), time())));
         $status_view->addItem($item);
     }
     $view = $ui_event->getValue('view');
     $view->addProperty(pht('Time Spent'), $status_view);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:54,代码来源:PhrequentUIEventListener.php


示例15: didFilterPage

 protected function didFilterPage(array $carts)
 {
     if ($this->needPurchases) {
         $purchases = id(new PhortunePurchaseQuery())->setViewer($this->getViewer())->setParentQuery($this)->withCartPHIDs(mpull($carts, 'getPHID'))->execute();
         $purchases = mgroup($purchases, 'getCartPHID');
         foreach ($carts as $cart) {
             $cart->attachPurchases(idx($purchases, $cart->getPHID(), array()));
         }
     }
     return $carts;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:11,代码来源:PhortuneCartQuery.php


示例16: didFilterPage

 protected function didFilterPage(array $leases)
 {
     if ($this->needUnconsumedCommands) {
         $commands = id(new DrydockCommandQuery())->setViewer($this->getViewer())->setParentQuery($this)->withTargetPHIDs(mpull($leases, 'getPHID'))->withConsumed(false)->execute();
         $commands = mgroup($commands, 'getTargetPHID');
         foreach ($leases as $lease) {
             $list = idx($commands, $lease->getPHID(), array());
             $lease->attachUnconsumedCommands($list);
         }
     }
     return $leases;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:12,代码来源:DrydockLeaseQuery.php


示例17: render

 public function render()
 {
     require_celerity_resource('conpherence-menu-css');
     $menu = id(new PHUIListView())->addClass('conpherence-menu')->setID('conpherence-menu');
     $policy_objects = ConpherenceThread::loadPolicyObjects($this->getUser(), $this->threads);
     $grouped = mgroup($this->threads, 'getIsRoom');
     $rooms = idx($grouped, 1, array());
     $this->addRoomsToMenu($menu, $rooms, $policy_objects);
     $messages = idx($grouped, 0, array());
     $this->addMessagesToMenu($menu, $messages);
     return $menu;
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:12,代码来源:ConpherenceThreadListView.php


示例18: render

 public function render()
 {
     require_celerity_resource('harbormaster-css');
     $messages = $this->unitMessages;
     $messages = msort($messages, 'getSortKey');
     $limit = $this->limit;
     if ($this->limit) {
         $display_messages = array_slice($messages, 0, $limit);
     } else {
         $display_messages = $messages;
     }
     $rows = array();
     $any_duration = false;
     foreach ($display_messages as $message) {
         $status = $message->getResult();
         $icon_icon = HarbormasterUnitStatus::getUnitStatusIcon($status);
         $icon_color = HarbormasterUnitStatus::getUnitStatusColor($status);
         $icon_label = HarbormasterUnitStatus::getUnitStatusLabel($status);
         $result_icon = id(new PHUIIconView())->setIcon("{$icon_icon} {$icon_color}")->addSigil('has-tooltip')->setMetadata(array('tip' => $icon_label));
         $duration = $message->getDuration();
         if ($duration !== null) {
             $any_duration = true;
             $duration = pht('%s ms', new PhutilNumber((int) (1000 * $duration)));
         }
         $name = $message->getUnitMessageDisplayName();
         $id = $message->getID();
         if ($id) {
             $name = phutil_tag('a', array('href' => "/harbormaster/unit/view/{$id}/"), $name);
         }
         $details = $message->getUnitMessageDetails();
         if (strlen($details)) {
             $name = array($name, $this->renderUnitTestDetails($details));
         }
         $rows[] = array($result_icon, $duration, $name);
     }
     $full_uri = $this->fullResultsURI;
     if ($full_uri && count($messages) > $limit) {
         $counts = array();
         $groups = mgroup($messages, 'getResult');
         foreach ($groups as $status => $group) {
             $counts[] = HarbormasterUnitStatus::getUnitStatusCountLabel($status, count($group));
         }
         $link_text = pht('View Full Test Results (%s)', implode(" · ", $counts));
         $full_link = phutil_tag('a', array('href' => $full_uri), $link_text);
         $link_icon = id(new PHUIIconView())->setIcon('fa-ellipsis-h lightgreytext');
         $rows[] = array($link_icon, null, $full_link);
     }
     $table = id(new AphrontTableView($rows))->setHeaders(array(null, pht('Time'), pht('Test')))->setColumnClasses(array('top center', 'top right', 'top wide'))->setColumnWidths(array('32px', '64px'))->setColumnVisibility(array(true, $any_duration));
     if ($this->notice) {
         $table->setNotice($this->notice);
     }
     return $table;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:53,代码来源:HarbormasterUnitPropertyView.php


示例19: didFilterPage

 protected function didFilterPage(array $badges)
 {
     if ($this->needRecipients) {
         $query = id(new PhabricatorBadgesAwardQuery())->setViewer($this->getViewer())->withBadgePHIDs(mpull($badges, 'getPHID'))->execute();
         $awards = mgroup($query, 'getBadgePHID');
         foreach ($badges as $badge) {
             $badge_awards = idx($awards, $badge->getPHID(), array());
             $badge->attachAwards($badge_awards);
         }
     }
     return $badges;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:12,代码来源:PhabricatorBadgesQuery.php


示例20: loadHarbormasterData

 protected function loadHarbormasterData(array $diffs)
 {
     $viewer = $this->getViewer();
     $diffs = mpull($diffs, null, 'getPHID');
     $buildables = id(new HarbormasterBuildableQuery())->setViewer($viewer)->withBuildablePHIDs(array_keys($diffs))->withManualBuildables(false)->needBuilds(true)->needTargets(true)->execute();
     $buildables = mpull($buildables, null, 'getBuildablePHID');
     foreach ($diffs as $phid => $diff) {
         $diff->attachBuildable(idx($buildables, $phid));
     }
     $target_map = array();
     foreach ($diffs as $phid => $diff) {
         $target_map[$phid] = $diff->getBuildTargetPHIDs();
     }
     $all_target_phids = array_mergev($target_map);
     if ($all_target_phids) {
         $unit_messages = id(new HarbormasterBuildUnitMessage())->loadAllWhere('buildTargetPHID IN (%Ls)', $all_target_phids);
         $unit_messages = mgroup($unit_messages, 'getBuildTargetPHID');
     } else {
         $unit_messages = array();
     }
     foreach ($diffs as $phid => $diff) {
         $target_phids = idx($target_map, $phid, array());
         $messages = array_select_keys($unit_messages, $target_phids);
         $messages = array_mergev($messages);
         $diff->attachUnitMessages($messages);
     }
     // For diffs with no messages, look for legacy unit messages stored on the
     // diff itself.
     foreach ($diffs as $phid => $diff) {
         if ($diff->getUnitMessages()) {
             continue;
         }
         if (!$diff->hasDiffProperty('arc:unit')) {
             continue;
         }
         $legacy_messages = $diff->getProperty('arc:unit');
         if (!$legacy_messages) {
             continue;
         }
         // Show the top 100 legacy lint messages. Previously, we showed some
         // by default and let the user toggle the rest. With modern messages,
         // we can send the user to the Harbormaster detail page. Just show
         // "a lot" of messages in legacy cases to try to strike a balance
         // between implementation simplicitly and compatibility.
         $legacy_messages = array_slice($legacy_messages, 0, 100);
         $messages = array();
         foreach ($legacy_messages as $message) {
             $messages[] = HarbormasterBuildUnitMessage::newFromDictionary(new HarbormasterBuildTarget(), $this->getModernUnitMessageDictionary($message));
         }
         $diff->attachUnitMessages($messages);
     }
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:52,代码来源:DifferentialController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mhash函数代码示例发布时间:2022-05-15
下一篇:
PHP mgm_stripslashes_deep函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap