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


PHP idx函数代码示例

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


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

示例1: buildCurtainView

 private function buildCurtainView(PhortuneAccount $account, $invoices)
 {
     $viewer = $this->getViewer();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $account, PhabricatorPolicyCapability::CAN_EDIT);
     $edit_uri = $this->getApplicationURI('account/edit/' . $account->getID() . '/');
     $curtain = $this->newCurtainView($account);
     $curtain->addAction(id(new PhabricatorActionView())->setName(pht('Edit Account'))->setIcon('fa-pencil')->setHref($edit_uri)->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $status_items = $this->getStatusItemsForAccount($account, $invoices);
     $status_view = new PHUIStatusListView();
     foreach ($status_items as $item) {
         $status_view->addItem(id(new PHUIStatusItemView())->setIcon(idx($item, 'icon'), idx($item, 'color'), idx($item, 'label'))->setTarget(idx($item, 'target'))->setNote(idx($item, 'note')));
     }
     $member_phids = $account->getMemberPHIDs();
     $handles = $viewer->loadHandles($member_phids);
     $member_list = id(new PHUIObjectItemListView())->setSimple(true);
     foreach ($member_phids as $member_phid) {
         $image_uri = $handles[$member_phid]->getImageURI();
         $image_href = $handles[$member_phid]->getURI();
         $person = $handles[$member_phid];
         $member = id(new PHUIObjectItemView())->setImageURI($image_uri)->setHref($image_href)->setHeader($person->getFullName());
         $member_list->addItem($member);
     }
     $curtain->newPanel()->setHeaderText(pht('Status'))->appendChild($status_view);
     $curtain->newPanel()->setHeaderText(pht('Members'))->appendChild($member_list);
     return $curtain;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:26,代码来源:PhortuneAccountViewController.php

示例2: execute

 public function execute(HarbormasterBuild $build, HarbormasterBuildTarget $build_target)
 {
     $viewer = PhabricatorUser::getOmnipotentUser();
     $settings = $this->getSettings();
     $variables = $build_target->getVariables();
     $uri = $this->mergeVariables('vurisprintf', $settings['uri'], $variables);
     $method = nonempty(idx($settings, 'method'), 'POST');
     $future = id(new HTTPSFuture($uri))->setMethod($method)->setTimeout(60);
     $credential_phid = $this->getSetting('credential');
     if ($credential_phid) {
         $key = PassphrasePasswordKey::loadFromPHID($credential_phid, $viewer);
         $future->setHTTPBasicAuthCredentials($key->getUsernameEnvelope()->openEnvelope(), $key->getPasswordEnvelope());
     }
     $this->resolveFutures($build, $build_target, array($future));
     list($status, $body, $headers) = $future->resolve();
     $header_lines = array();
     // TODO: We don't currently preserve the entire "HTTP" response header, but
     // should. Once we do, reproduce it here faithfully.
     $status_code = $status->getStatusCode();
     $header_lines[] = "HTTP {$status_code}";
     foreach ($headers as $header) {
         list($head, $tail) = $header;
         $header_lines[] = "{$head}: {$tail}";
     }
     $header_lines = implode("\n", $header_lines);
     $build_target->newLog($uri, 'http.head')->append($header_lines);
     $build_target->newLog($uri, 'http.body')->append($body);
     if ($status->isError()) {
         throw new HarbormasterBuildFailureException();
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:31,代码来源:HarbormasterHTTPRequestBuildStepImplementation.php

示例3: render

 public function render()
 {
     $rows = array();
     $any_hidden = false;
     foreach ($this->rows as $row) {
         $style = idx($row, 'style');
         switch ($style) {
             case 'section':
                 $cells = phutil_render_tag('th', array('colspan' => 2), idx($row, 'name'));
                 break;
             default:
                 $name = phutil_render_tag('th', array(), idx($row, 'name'));
                 $value = phutil_render_tag('td', array(), idx($row, 'value'));
                 $cells = $name . $value;
                 break;
         }
         $show = idx($row, 'show');
         $rows[] = javelin_render_tag('tr', array('style' => $show ? null : 'display: none', 'sigil' => $show ? null : 'differential-results-row-toggle', 'class' => 'differential-results-row-' . $style), $cells);
         if (!$show) {
             $any_hidden = true;
         }
     }
     if ($any_hidden) {
         $show_more = javelin_render_tag('a', array('href' => '#', 'mustcapture' => true), $this->showMoreString);
         $hide_more = javelin_render_tag('a', array('href' => '#', 'mustcapture' => true), 'Hide');
         $rows[] = javelin_render_tag('tr', array('class' => 'differential-results-row-show', 'sigil' => 'differential-results-row-show'), '<th colspan="2">' . $show_more . '</td>');
         $rows[] = javelin_render_tag('tr', array('class' => 'differential-results-row-show', 'sigil' => 'differential-results-row-hide', 'style' => 'display: none'), '<th colspan="2">' . $hide_more . '</th>');
         Javelin::initBehavior('differential-show-field-details');
     }
     require_celerity_resource('differential-results-table-css');
     return javelin_render_tag('table', array('class' => 'differential-results-table', 'sigil' => 'differential-results-table'), implode("\n", $rows));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:32,代码来源:DifferentialResultsTableView.php

示例4: newFromString

 public static function newFromString($string, $default = null)
 {
     $matches = null;
     $ok = preg_match('/^([-$]*(?:\\d+)?(?:[.]\\d{0,2})?)(?:\\s+([A-Z]+))?$/', trim($string), $matches);
     if (!$ok) {
         self::throwFormatException($string);
     }
     $value = $matches[1];
     if (substr_count($value, '-') > 1) {
         self::throwFormatException($string);
     }
     if (substr_count($value, '$') > 1) {
         self::throwFormatException($string);
     }
     $value = str_replace('$', '', $value);
     $value = (double) $value;
     $value = (int) round(100 * $value);
     $currency = idx($matches, 2, $default);
     switch ($currency) {
         case 'USD':
             break;
         default:
             throw new Exception(pht("Unsupported currency '%s'!", $currency));
     }
     return self::newFromValueAndCurrency($value, $currency);
 }
开发者ID:truSense,项目名称:phabricator,代码行数:26,代码来源:PhortuneCurrency.php

示例5: buildQueryFromParameters

 protected function buildQueryFromParameters(array $map)
 {
     $query = $this->newQuery();
     if ($map['callsigns']) {
         $query->withCallsigns($map['callsigns']);
     }
     if ($map['status']) {
         $status = idx($this->getStatusValues(), $map['status']);
         if ($status) {
             $query->withStatus($status);
         }
     }
     if ($map['hosted']) {
         $hosted = idx($this->getHostedValues(), $map['hosted']);
         if ($hosted) {
             $query->withHosted($hosted);
         }
     }
     if ($map['types']) {
         $query->withTypes($map['types']);
     }
     if (strlen($map['name'])) {
         $query->withNameContains($map['name']);
     }
     return $query;
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:26,代码来源:PhabricatorRepositorySearchEngine.php

示例6: doWork

 protected function doWork()
 {
     $data = $this->getTaskData();
     $viewer = PhabricatorUser::getOmnipotentUser();
     $address = idx($data, 'address');
     $author_phid = idx($data, 'authorPHID');
     $author = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withPHIDs(array($author_phid))->executeOne();
     if (!$author) {
         throw new PhabricatorWorkerPermanentFailureException(pht('Invite has invalid author PHID ("%s").', $author_phid));
     }
     $invite = id(new PhabricatorAuthInviteQuery())->setViewer($viewer)->withEmailAddresses(array($address))->executeOne();
     if ($invite) {
         // If we're inviting a user who has already been invited, we just
         // regenerate their invite code.
         $invite->regenerateVerificationCode();
     } else {
         // Otherwise, we're creating a new invite.
         $invite = id(new PhabricatorAuthInvite())->setEmailAddress($address);
     }
     // Whether this is a new invite or not, tag this most recent author as
     // the invite author.
     $invite->setAuthorPHID($author_phid);
     $code = $invite->getVerificationCode();
     $invite_uri = '/auth/invite/' . $code . '/';
     $invite_uri = PhabricatorEnv::getProductionURI($invite_uri);
     $template = idx($data, 'template');
     $template = str_replace('{$INVITE_URI}', $invite_uri, $template);
     $invite->save();
     $mail = id(new PhabricatorMetaMTAMail())->addRawTos(array($invite->getEmailAddress()))->setForceDelivery(true)->setSubject(pht('[Phabricator] %s has invited you to join Phabricator', $author->getFullName()))->setBody($template)->saveAndSend();
 }
开发者ID:truSense,项目名称:phabricator,代码行数:30,代码来源:PhabricatorAuthInviteWorker.php

示例7: renderValueForRevisionView

 public function renderValueForRevisionView()
 {
     $diff = $this->getDiff();
     $ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff);
     $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
     $postponed_count = 0;
     $udata = $this->getDiffProperty('arc:unit');
     $utail = null;
     if ($udata) {
         $unit_messages = array();
         foreach ($udata as $test) {
             $name = idx($test, 'name');
             $result = idx($test, 'result');
             if ($result != DifferentialUnitTestResult::RESULT_POSTPONED && $result != DifferentialUnitTestResult::RESULT_PASS) {
                 $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
                 $userdata = phutil_utf8_shorten(idx($test, 'userdata'), 512);
                 $userdata = $engine->markupText($userdata);
                 $unit_messages[] = '<li>' . '<span class="unit-result-' . phutil_escape_html($result) . '">' . phutil_escape_html(ucwords($result)) . '</span>' . ' ' . phutil_escape_html($name) . '<p>' . $userdata . '</p>' . '</li>';
             } else {
                 if ($result == DifferentialUnitTestResult::RESULT_POSTPONED) {
                     $postponed_count++;
                 }
             }
         }
         $uexcuse = $this->getUnitExcuse();
         if ($unit_messages) {
             $utail = '<div class="differential-unit-block">' . $uexcuse . '<ul>' . implode("\n", $unit_messages) . '</ul>' . '</div>';
         }
     }
     if ($postponed_count > 0 && $diff->getUnitStatus() == DifferentialUnitStatus::UNIT_POSTPONED) {
         $umsg = $postponed_count . ' ' . $umsg;
     }
     return $ustar . ' ' . $umsg . $utail;
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:34,代码来源:DifferentialUnitFieldSpecification.php

示例8: resolveBaseCommit

 public function resolveBaseCommit(array $specs)
 {
     $specs += array('args' => '', 'local' => '', 'project' => '', 'global' => '', 'system' => '');
     foreach ($specs as $source => $spec) {
         $specs[$source] = self::tokenizeBaseCommitSpecification($spec);
     }
     $this->try = array('args', 'local', 'project', 'global', 'system');
     while ($this->try) {
         $source = head($this->try);
         if (!idx($specs, $source)) {
             $this->log("No rules left from source '{$source}'.");
             array_shift($this->try);
             continue;
         }
         $this->log("Trying rules from source '{$source}'.");
         $rules =& $specs[$source];
         while ($rule = array_shift($rules)) {
             $this->log("Trying rule '{$rule}'.");
             $commit = $this->resolveRule($rule, $source);
             if ($commit === false) {
                 // If a rule returns false, it means to go to the next ruleset.
                 break;
             } else {
                 if ($commit !== null) {
                     $this->log("Resolved commit '{$commit}' from rule '{$rule}'.");
                     return $commit;
                 }
             }
         }
     }
     return null;
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:32,代码来源:ArcanistBaseCommitParser.php

示例9: willLintPaths

 public function willLintPaths(array $paths)
 {
     // Cleanup previous runs.
     $this->localExecx("rm -rf _build/_lint");
     // Build compilation database.
     $lintable_paths = $this->getLintablePaths($paths);
     $interesting_paths = $this->getInterestingPaths($lintable_paths);
     if (!$lintable_paths) {
         return;
     }
     // Run lint.
     try {
         $this->localExecx("%C %C -p _build/dev/ %Ls", $this->getBinaryPath(), $this->getFilteredIssues(), $lintable_paths);
     } catch (CommandException $exception) {
         PhutilConsole::getConsole()->writeErr($exception->getMessage());
     }
     // Load results.
     $result = id(new SQLite3($this->getProjectRoot() . '/_build/_lint/lint.db', SQLITE3_OPEN_READONLY))->query("SELECT * FROM raised_issues");
     while ($issue = $result->fetchArray(SQLITE3_ASSOC)) {
         // Skip issues not part of the linted file.
         if (in_array($issue['file'], $interesting_paths)) {
             $this->addLintMessage(id(new ArcanistLintMessage())->setPath($issue['file'])->setLine($issue['line'])->setChar($issue['column'])->setCode('Howtoeven')->setSeverity($this->getSeverity($issue['severity']))->setName('Hte-' . $issue['name'])->setDescription(sprintf("%s\n\n%s", $issue['message'] ? $issue['message'] : $issue['description'], $issue['explanation']))->setOriginalText(idx($issue, 'original', ''))->setReplacementText(idx($issue, 'replacement', '')));
         }
     }
 }
开发者ID:mopsled,项目名称:rocksdb,代码行数:25,代码来源:FacebookHowtoevenLinter.php

示例10: testFields

 function testFields()
 {
     $dir = PhutilDirectoryFixture::newEmptyFixture();
     $root = realpath($dir->getPath());
     $watch = $this->watch($root);
     $this->assertFileList($root, array());
     $this->watchmanCommand('log', 'debug', 'XXX: touch a');
     touch("{$root}/a");
     $this->assertFileList($root, array('a'));
     $query = $this->watchmanCommand('query', $root, array('fields' => array('name', 'exists', 'new', 'size', 'mode', 'uid', 'gid', 'mtime', 'mtime_ms', 'mtime_us', 'mtime_ns', 'mtime_f', 'ctime', 'ctime_ms', 'ctime_us', 'ctime_ns', 'ctime_f', 'ino', 'dev', 'nlink', 'oclock', 'cclock'), 'since' => 'n:foo'));
     $this->assertEqual(null, idx($query, 'error'));
     $this->assertEqual(1, count($query['files']));
     $file = $query['files'][0];
     $this->assertEqual('a', $file['name']);
     $this->assertEqual(true, $file['exists']);
     $this->assertEqual(true, $file['new']);
     $stat = stat("{$root}/a");
     $compare_fields = array('size', 'mode', 'uid', 'gid', 'ino', 'dev', 'nlink');
     foreach ($compare_fields as $field) {
         $this->assertEqual($stat[$field], $file[$field], $field);
     }
     $time_fields = array('mtime', 'ctime');
     foreach ($time_fields as $field) {
         $this->assertTimeEqual($stat[$field], $file[$field], $file[$field . '_ms'], $file[$field . '_us'], $file[$field . '_ns'], $file[$field . '_f']);
     }
     $this->assertRegex('/^c:\\d+:\\d+:\\d+:\\d+$/', $file['cclock'], "cclock looks clocky");
     $this->assertRegex('/^c:\\d+:\\d+:\\d+:\\d+$/', $file['oclock'], "oclock looks clocky");
 }
开发者ID:rogerwangzy,项目名称:watchman,代码行数:28,代码来源:fields.php

示例11: renderSeverity

 private function renderSeverity($severity)
 {
     $names = ArcanistLintSeverity::getLintSeverities();
     $name = idx($names, $severity, $severity);
     // TODO: Add some color here?
     return $name;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:HarbormasterLintPropertyView.php

示例12: markupText

 public function markupText($text, $children)
 {
     $matches = array();
     preg_match($this->getRegEx(), $text, $matches);
     if (idx($matches, 'showword')) {
         $word = $matches['showword'];
         $show = true;
     } else {
         $word = $matches['hideword'];
         $show = false;
     }
     $class_suffix = phutil_utf8_strtolower($word);
     // This is the "(IMPORTANT)" or "NOTE:" part.
     $word_part = rtrim(substr($text, 0, strlen($matches[0])));
     // This is the actual text.
     $text_part = substr($text, strlen($matches[0]));
     $text_part = $this->applyRules(rtrim($text_part));
     $text_mode = $this->getEngine()->isTextMode();
     if ($text_mode) {
         return $word_part . ' ' . $text_part;
     }
     if ($show) {
         $content = array(phutil_tag('span', array('class' => 'remarkup-note-word'), $word_part), ' ', $text_part);
     } else {
         $content = $text_part;
     }
     return phutil_tag('div', array('class' => 'remarkup-' . $class_suffix), $content);
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:28,代码来源:PhutilRemarkupEngineRemarkupNoteBlockRule.php

示例13: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $keys = $request->getStr('keys');
     try {
         $keys = phutil_json_decode($keys);
     } catch (PhutilJSONParserException $ex) {
         return new Aphront400Response();
     }
     // There have been at least two users asking for a keyboard shortcut to
     // close the dialog, so be explicit that escape works since it isn't
     // terribly discoverable.
     $keys[] = array('keys' => array('esc'), 'description' => pht('Close any dialog, including this one.'));
     $stroke_map = array('left' => "←", 'right' => "→", 'up' => "↑", 'down' => "↓", 'return' => "⏎", 'tab' => "⇥", 'delete' => "⌫");
     $rows = array();
     foreach ($keys as $shortcut) {
         $keystrokes = array();
         foreach ($shortcut['keys'] as $stroke) {
             $stroke = idx($stroke_map, $stroke, $stroke);
             $keystrokes[] = phutil_tag('kbd', array(), $stroke);
         }
         $keystrokes = phutil_implode_html(' or ', $keystrokes);
         $rows[] = phutil_tag('tr', array(), array(phutil_tag('th', array(), $keystrokes), phutil_tag('td', array(), $shortcut['description'])));
     }
     $table = phutil_tag('table', array('class' => 'keyboard-shortcut-help'), $rows);
     return $this->newDialog()->setTitle(pht('Keyboard Shortcuts'))->appendChild($table)->addCancelButton('#', pht('Close'));
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:27,代码来源:PhabricatorHelpKeyboardShortcutController.php

示例14: dispatchEvent

 public static function dispatchEvent(PhutilEvent $event)
 {
     $instance = self::getInstance();
     $listeners = idx($instance->listeners, $event->getType(), array());
     $global_listeners = idx($instance->listeners, PhutilEventType::TYPE_ALL, array());
     // Merge and deduplicate listeners (we want to send the event to each
     // listener only once, even if it satisfies multiple criteria for the
     // event).
     $listeners = array_merge($listeners, $global_listeners);
     $listeners = mpull($listeners, null, 'getListenerID');
     $profiler = PhutilServiceProfiler::getInstance();
     $profiler_id = $profiler->beginServiceCall(array('type' => 'event', 'kind' => $event->getType(), 'count' => count($listeners)));
     $caught = null;
     try {
         foreach ($listeners as $listener) {
             if ($event->isStopped()) {
                 // Do this first so if someone tries to dispatch a stopped event it
                 // doesn't go anywhere. Silly but less surprising.
                 break;
             }
             $listener->handleEvent($event);
         }
     } catch (Exception $ex) {
         $profiler->endServiceCall($profiler_id, array());
         throw $ex;
     }
     $profiler->endServiceCall($profiler_id, array());
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:28,代码来源:PhutilEventEngine.php

示例15: phabricator_form

function phabricator_form(PhabricatorUser $user, $attributes, $content)
{
    $body = array();
    $http_method = idx($attributes, 'method');
    $is_post = strcasecmp($http_method, 'POST') === 0;
    $http_action = idx($attributes, 'action');
    $is_absolute_uri = preg_match('#^(https?:|//)#', $http_action);
    if ($is_post) {
        // NOTE: We only include CSRF tokens if a URI is a local URI on the same
        // domain. This is an important security feature and prevents forms which
        // submit to foreign sites from leaking CSRF tokens.
        // In some cases, we may construct a fully-qualified local URI. For example,
        // we can construct these for download links, depending on configuration.
        // These forms do not receive CSRF tokens, even though they safely could.
        // This can be confusing, if you're developing for Phabricator and
        // manage to construct a local form with a fully-qualified URI, since it
        // won't get CSRF tokens and you'll get an exception at the other end of
        // the request which is a bit disconnected from the actual root cause.
        // However, this is rare, and there are reasonable cases where this
        // construction occurs legitimately, and the simplest fix is to omit CSRF
        // tokens for these URIs in all cases. The error message you receive also
        // gives you some hints as to this potential source of error.
        if (!$is_absolute_uri) {
            $body[] = phutil_tag('input', array('type' => 'hidden', 'name' => AphrontRequest::getCSRFTokenName(), 'value' => $user->getCSRFToken()));
            $body[] = phutil_tag('input', array('type' => 'hidden', 'name' => '__form__', 'value' => true));
        }
    }
    if (is_array($content)) {
        $body = array_merge($body, $content);
    } else {
        $body[] = $content;
    }
    return javelin_tag('form', $attributes, $body);
}
开发者ID:pugong,项目名称:phabricator,代码行数:34,代码来源:markup.php


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