本文整理汇总了PHP中msort函数的典型用法代码示例。如果您正苦于以下问题:PHP msort函数的具体用法?PHP msort怎么用?PHP msort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
$messages = $this->unitMessages;
$messages = msort($messages, 'getSortKey');
if ($this->limit) {
$messages = array_slice($messages, 0, $this->limit);
}
$rows = array();
$any_duration = false;
foreach ($messages as $message) {
$result = $this->renderResult($message->getResult());
$duration = $message->getDuration();
if ($duration !== null) {
$any_duration = true;
$duration = pht('%s ms', new PhutilNumber((int) (1000 * $duration)));
}
$name = $message->getName();
$namespace = $message->getNamespace();
if (strlen($namespace)) {
$name = $namespace . '::' . $name;
}
$engine = $message->getEngine();
if (strlen($engine)) {
$name = $engine . ' > ' . $name;
}
$rows[] = array($result, $duration, $name);
}
$table = id(new AphrontTableView($rows))->setHeaders(array(pht('Result'), pht('Time'), pht('Test')))->setColumnClasses(array(null, null, 'pri wide'))->setColumnVisibility(array(true, $any_duration));
return $table;
}
示例2: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$xaction = id(new PhabricatorObjectQuery())->withPHIDs(array($this->phid))->setViewer($user)->executeOne();
if (!$xaction) {
return new Aphront404Response();
}
if (!$xaction->getComment()) {
// You can't view history of a transaction with no comments.
return new Aphront404Response();
}
if ($xaction->getComment()->getIsRemoved()) {
// You can't view history of a transaction with a removed comment.
return new Aphront400Response();
}
$comments = id(new PhabricatorApplicationTransactionTemplatedCommentQuery())->setViewer($user)->setTemplate($xaction->getApplicationTransactionCommentObject())->withTransactionPHIDs(array($xaction->getPHID()))->execute();
if (!$comments) {
return new Aphront404Response();
}
$comments = msort($comments, 'getCommentVersion');
$xactions = array();
foreach ($comments as $comment) {
$xactions[] = id(clone $xaction)->makeEphemeral()->setCommentVersion($comment->getCommentVersion())->setContentSource($comment->getContentSource())->setDateCreated($comment->getDateCreated())->attachComment($comment);
}
$obj_phid = $xaction->getObjectPHID();
$obj_handle = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array($obj_phid))->executeOne();
$view = id(new PhabricatorApplicationTransactionView())->setUser($user)->setObjectPHID($obj_phid)->setTransactions($xactions)->setShowEditActions(false)->setHideCommentOptions(true);
$dialog = id(new AphrontDialogView())->setUser($user)->setWidth(AphrontDialogView::WIDTH_FULL)->setFlush(true)->setTitle(pht('Comment History'));
$dialog->appendChild($view);
$dialog->addCancelButton($obj_handle->getURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:33,代码来源:PhabricatorApplicationTransactionCommentHistoryController.php
示例3: renderModuleStatus
public function renderModuleStatus(AphrontRequest $request)
{
$viewer = $request->getViewer();
$types = PhabricatorPHIDType::getAllTypes();
$types = msort($types, 'getTypeConstant');
$rows = array();
foreach ($types as $key => $type) {
$class_name = $type->getPHIDTypeApplicationClass();
if ($class_name !== null) {
$app = PhabricatorApplication::getByClass($class_name);
$app_name = $app->getName();
$icon = $app->getFontIcon();
if ($icon) {
$app_icon = id(new PHUIIconView())->setIcon($icon);
} else {
$app_icon = null;
}
} else {
$app_name = null;
$app_icon = null;
}
$icon = $type->getTypeIcon();
if ($icon) {
$type_icon = id(new PHUIIconView())->setIcon($icon);
} else {
$type_icon = null;
}
$rows[] = array($type->getTypeConstant(), get_class($type), $app_icon, $app_name, $type_icon, $type->getTypeName());
}
$table = id(new AphrontTableView($rows))->setHeaders(array(pht('Constant'), pht('Class'), null, pht('Application'), null, pht('Name')))->setColumnClasses(array(null, 'pri', 'icon', null, 'icon', 'wide'));
return id(new PHUIObjectBoxView())->setHeaderText(pht('PHID Types'))->setTable($table);
}
示例4: handleRequest
public function handleRequest(AphrontRequest $request)
{
$this->requireApplicationCapability(AuthManageProvidersCapability::CAPABILITY);
$request = $this->getRequest();
$viewer = $request->getUser();
$providers = PhabricatorAuthProvider::getAllBaseProviders();
$e_provider = null;
$errors = array();
if ($request->isFormPost()) {
$provider_string = $request->getStr('provider');
if (!strlen($provider_string)) {
$e_provider = pht('Required');
$errors[] = pht('You must select an authentication provider.');
} else {
$found = false;
foreach ($providers as $provider) {
if (get_class($provider) === $provider_string) {
$found = true;
break;
}
}
if (!$found) {
$e_provider = pht('Invalid');
$errors[] = pht('You must select a valid provider.');
}
}
if (!$errors) {
return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI('/config/new/' . $provider_string . '/'));
}
}
$options = id(new AphrontFormRadioButtonControl())->setLabel(pht('Provider'))->setName('provider')->setError($e_provider);
$configured = PhabricatorAuthProvider::getAllProviders();
$configured_classes = array();
foreach ($configured as $configured_provider) {
$configured_classes[get_class($configured_provider)] = true;
}
// Sort providers by login order, and move disabled providers to the
// bottom.
$providers = msort($providers, 'getLoginOrder');
$providers = array_diff_key($providers, $configured_classes) + $providers;
foreach ($providers as $provider) {
if (isset($configured_classes[get_class($provider)])) {
$disabled = true;
$description = pht('This provider is already configured.');
} else {
$disabled = false;
$description = $provider->getDescriptionForCreate();
}
$options->addButton(get_class($provider), $provider->getNameForCreate(), $description, $disabled ? 'disabled' : null, $disabled);
}
$form = id(new AphrontFormView())->setUser($viewer)->appendChild($options)->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($this->getApplicationURI())->setValue(pht('Continue')));
$form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Provider'))->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Add Provider'));
$crumbs->setBorder(true);
$title = pht('Add Auth Provider');
$header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-plus-square');
$view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box));
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
}
示例5: 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'));
}
示例6: processRequest
public function processRequest()
{
$classes = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorUIExample')->loadObjects();
$classes = msort($classes, 'getName');
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
foreach ($classes as $class => $obj) {
$name = $obj->getName();
$nav->addFilter($class, $name);
}
$selected = $nav->selectFilter($this->class, head_key($classes));
$example = $classes[$selected];
$example->setRequest($this->getRequest());
$result = $example->renderExample();
if ($result instanceof AphrontResponse) {
// This allows examples to generate dialogs, etc., for demonstration.
return $result;
}
require_celerity_resource('phabricator-ui-example-css');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($example->getName());
$header = id(new PHUIHeaderView())->setHeader(pht('%s (%s)', $example->getName(), get_class($example)))->setSubheader($example->getDescription())->setNoBackground(true);
$nav->appendChild(array($crumbs, $header, phutil_tag('br'), $result));
return $this->buildApplicationPage($nav, array('title' => $example->getName()));
}
示例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: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$types = PassphraseCredentialType::getAllCreateableTypes();
$types = mpull($types, null, 'getCredentialType');
$types = msort($types, 'getCredentialTypeName');
$errors = array();
$e_type = null;
if ($request->isFormPost()) {
$type = $request->getStr('type');
if (empty($types[$type])) {
$errors[] = pht('You must choose a credential type.');
$e_type = pht('Required');
}
if (!$errors) {
$uri = $this->getApplicationURI('edit/?type=' . $type);
return id(new AphrontRedirectResponse())->setURI($uri);
}
}
$types_control = id(new AphrontFormRadioButtonControl())->setName('type')->setLabel(pht('Credential Type'))->setError($e_type);
foreach ($types as $type) {
$types_control->addButton($type->getCredentialType(), $type->getCredentialTypeName(), $type->getCredentialTypeDescription());
}
$form = id(new AphrontFormView())->setUser($viewer)->appendChild($types_control)->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))->addCancelButton($this->getApplicationURI()));
$title = pht('New Credential');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Create'));
$box = id(new PHUIObjectBoxView())->setHeaderText(pht('Create New Credential'))->setFormErrors($errors)->setForm($form);
return $this->buildApplicationPage(array($crumbs, $box), array('title' => $title));
}
示例9: loadCommands
protected function loadCommands($target_phid)
{
$viewer = $this->getViewer();
$commands = id(new DrydockCommandQuery())->setViewer($viewer)->withTargetPHIDs(array($target_phid))->withConsumed(false)->execute();
$commands = msort($commands, 'getID');
return $commands;
}
示例10: renderConfigurationFooter
public function renderConfigurationFooter()
{
$hashers = PhabricatorPasswordHasher::getAllHashers();
$hashers = msort($hashers, 'getStrength');
$hashers = array_reverse($hashers);
$yes = phutil_tag('strong', array('style' => 'color: #009900'), pht('Yes'));
$no = phutil_tag('strong', array('style' => 'color: #990000'), pht('Not Installed'));
$best_hasher_name = null;
try {
$best_hasher = PhabricatorPasswordHasher::getBestHasher();
$best_hasher_name = $best_hasher->getHashName();
} catch (PhabricatorPasswordHasherUnavailableException $ex) {
// There are no suitable hashers. The user might be able to enable some,
// so we don't want to fatal here. We'll fatal when users try to actually
// use this stuff if it isn't fixed before then. Until then, we just
// don't highlight a row. In practice, at least one hasher should always
// be available.
}
$rows = array();
$rowc = array();
foreach ($hashers as $hasher) {
$is_installed = $hasher->canHashPasswords();
$rows[] = array($hasher->getHumanReadableName(), $hasher->getHashName(), $hasher->getHumanReadableStrength(), $is_installed ? $yes : $no, $is_installed ? null : $hasher->getInstallInstructions());
$rowc[] = $best_hasher_name == $hasher->getHashName() ? 'highlighted' : null;
}
$table = new AphrontTableView($rows);
$table->setRowClasses($rowc);
$table->setHeaders(array(pht('Algorithm'), pht('Name'), pht('Strength'), pht('Installed'), pht('Install Instructions')));
$table->setColumnClasses(array('', '', '', '', 'wide'));
$header = id(new PHUIHeaderView())->setHeader(pht('Password Hash Algorithms'))->setSubheader(pht('Stronger algorithms are listed first. The highlighted algorithm ' . 'will be used when storing new hashes. Older hashes will be ' . 'upgraded to the best algorithm over time.'));
return id(new PHUIObjectBoxView())->setHeader($header)->appendChild($table);
}
示例11: buildPanels
private function buildPanels()
{
$panel_specs = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorSettingsPanel')->setConcreteOnly(true)->selectAndLoadSymbols();
$panels = array();
foreach ($panel_specs as $spec) {
$class = newv($spec['name'], array());
$panels[] = $class->buildPanels();
}
$panels = array_mergev($panels);
$panels = mpull($panels, null, 'getPanelKey');
$result = array();
foreach ($panels as $key => $panel) {
$panel->setUser($this->user);
if (!$panel->isEnabled()) {
continue;
}
if (!$this->isSelf()) {
if (!$panel->isEditableByAdministrators()) {
continue;
}
}
if (!empty($result[$key])) {
throw new Exception(pht("Two settings panels share the same panel key ('%s'): %s, %s.", $key, get_class($panel), get_class($result[$key])));
}
$result[$key] = $panel;
}
$result = msort($result, 'getPanelSortKey');
if (!$result) {
throw new Exception(pht('No settings panels are available.'));
}
return $result;
}
示例12: getTagContent
protected function getTagContent()
{
if (!$this->blankState && empty($this->events)) {
return '';
}
$events = msort($this->events, 'getEpochStart');
$singletons = array();
$allday = false;
foreach ($events as $event) {
$color = $event->getColor();
if ($event->getAllDay()) {
$timelabel = pht('All Day');
} else {
$timelabel = phabricator_time($event->getEpochStart(), $this->getUser());
}
$dot = phutil_tag('span', array('class' => 'phui-calendar-list-dot'), '');
$title = phutil_tag('span', array('class' => 'phui-calendar-list-title'), $this->renderEventLink($event, $allday));
$time = phutil_tag('span', array('class' => 'phui-calendar-list-time'), $timelabel);
$singletons[] = phutil_tag('li', array('class' => 'phui-calendar-list-item phui-calendar-' . $color), array($dot, $title, $time));
}
if (empty($singletons)) {
$singletons[] = phutil_tag('li', array('class' => 'phui-calendar-list-item-empty'), pht('Clear sailing ahead.'));
}
$list = phutil_tag('ul', array('class' => 'phui-calendar-list'), $singletons);
return $list;
}
示例13: buildPanels
private function buildPanels()
{
$panels = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorSettingsPanel')->setExpandMethod('buildPanels')->setUniqueMethod('getPanelKey')->execute();
$result = array();
foreach ($panels as $key => $panel) {
$panel->setUser($this->user);
if (!$panel->isEnabled()) {
continue;
}
if (!$this->isSelf()) {
if (!$panel->isEditableByAdministrators()) {
continue;
}
}
if (!empty($result[$key])) {
throw new Exception(pht("Two settings panels share the same panel key ('%s'): %s, %s.", $key, get_class($panel), get_class($result[$key])));
}
$result[$key] = $panel;
}
$result = msort($result, 'getPanelSortKey');
if (!$result) {
throw new Exception(pht('No settings panels are available.'));
}
return $result;
}
示例14: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$books = id(new DivinerBookQuery())->setViewer($viewer)->execute();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
$crumbs->addTextCrumb(pht('Books'));
$query_button = id(new PHUIButtonView())->setTag('a')->setHref($this->getApplicationURI('query/'))->setText(pht('Advanced Search'))->setIcon('fa-search');
$header = id(new PHUIHeaderView())->setHeader(pht('Documentation Books'))->addActionLink($query_button);
$document = new PHUIDocumentViewPro();
$document->setHeader($header);
$document->addClass('diviner-view');
if ($books) {
$books = msort($books, 'getTitle');
$list = array();
foreach ($books as $book) {
$item = id(new DivinerBookItemView())->setTitle($book->getTitle())->setHref('/book/' . $book->getName() . '/')->setSubtitle($book->getPreface());
$list[] = $item;
}
$list = id(new PHUIBoxView())->addPadding(PHUI::PADDING_MEDIUM_TOP)->appendChild($list);
$document->appendChild($list);
} else {
$text = pht("(NOTE) **Looking for Phabricator documentation?** " . "If you're looking for help and information about Phabricator, " . "you can [[https://secure.phabricator.com/diviner/ | " . "browse the public Phabricator documentation]] on the live site.\n\n" . "Diviner is the documentation generator used to build the " . "Phabricator documentation.\n\n" . "You haven't generated any Diviner documentation books yet, so " . "there's nothing to show here. If you'd like to generate your own " . "local copy of the Phabricator documentation and have it appear " . "here, run this command:\n\n" . " %s\n\n", 'phabricator/ $ ./bin/diviner generate');
$text = new PHUIRemarkupView($viewer, $text);
$document->appendChild($text);
}
return $this->newPage()->setTitle(pht('Documentation Books'))->setCrumbs($crumbs)->appendChild(array($document));
}
示例15: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$books = id(new DivinerBookQuery())->setViewer($viewer)->execute();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Books'));
$search_icon = id(new PHUIIconView())->setIconFont('fa-search');
$query_button = id(new PHUIButtonView())->setTag('a')->setHref($this->getApplicationURI('query/'))->setText(pht('Advanced Search'))->setIcon($search_icon);
$header = id(new PHUIHeaderView())->setHeader(pht('Documentation Books'))->addActionLink($query_button);
$document = new PHUIDocumentView();
$document->setHeader($header);
$document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
$document->addClass('diviner-view');
if ($books) {
$books = msort($books, 'getTitle');
$list = array();
foreach ($books as $book) {
$item = id(new DivinerBookItemView())->setTitle($book->getTitle())->setHref('/book/' . $book->getName() . '/')->setSubtitle($book->getPreface());
$list[] = $item;
}
$list = id(new PHUIBoxView())->addPadding(PHUI::PADDING_LARGE_LEFT)->addPadding(PHUI::PADDING_LARGE_RIGHT)->addPadding(PHUI::PADDING_SMALL_TOP)->addPadding(PHUI::PADDING_SMALL_BOTTOM)->appendChild($list);
$document->appendChild($list);
} else {
$text = pht("(NOTE) **Looking for Phabricator documentation?** If you're looking " . "for help and information about Phabricator, you can " . "[[ https://secure.phabricator.com/diviner/ | browse the public " . "Phabricator documentation ]] on the live site.\n\n" . "Diviner is the documentation generator used to build the Phabricator " . "documentation.\n\n" . "You haven't generated any Diviner documentation books yet, so " . "there's nothing to show here. If you'd like to generate your own " . "local copy of the Phabricator documentation and have it appear " . "here, run this command:\n\n" . " phabricator/ \$ ./bin/diviner generate\n\n" . "Right now, Diviner isn't very useful for generating documentation " . "for projects other than Phabricator. If you're interested in using " . "it in your own projects, leave feedback for us on " . "[[ https://secure.phabricator.com/T4558 | T4558 ]].");
$text = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($text), 'default', $viewer);
$document->appendChild($text);
}
return $this->buildApplicationPage(array($crumbs, $document), array('title' => pht('Documentation Books'), 'fonts' => true));
}