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


PHP nonempty函数代码示例

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


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

示例1: render

 public function render()
 {
     $application = $this->application;
     require_celerity_resource('phabricator-application-launch-view-css');
     $content = array();
     $content[] = phutil_render_tag('span', array('class' => 'phabricator-application-launch-name'), phutil_escape_html($application->getName()));
     $content[] = phutil_render_tag('span', array('class' => 'phabricator-application-launch-description'), phutil_escape_html($application->getShortDescription()));
     $count = 0;
     if ($this->status) {
         $content[] = '<span class="phabricator-application-status-block">';
         foreach ($this->status as $status) {
             $count += $status->getCount();
             $content[] = $status;
         }
         $content[] = '</span>';
     }
     if ($count) {
         $content[] = phutil_render_tag('span', array('class' => 'phabricator-application-launch-attention'), phutil_escape_html($count));
     }
     $classes = array();
     $classes[] = 'phabricator-application-launch-icon';
     $styles = array();
     if ($application->getIconURI()) {
         $styles[] = 'background-image: url(' . $application->getIconURI() . ')';
     } else {
         $autosprite = $application->getAutospriteName();
         $classes[] = 'autosprite';
         $classes[] = 'app-' . $autosprite . '-full';
     }
     $icon = phutil_render_tag('span', array('class' => implode(' ', $classes), 'style' => nonempty(implode('; ', $styles), null)), '');
     return phutil_render_tag('a', array('class' => 'phabricator-application-launch-container', 'href' => $application->getBaseURI()), $icon . $this->renderSingleView($content));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:32,代码来源:PhabricatorApplicationLaunchView.php

示例2: getLog

 public static function getLog()
 {
     if (!self::$log) {
         $path = PhabricatorEnv::getEnvConfig('log.ssh.path');
         $format = PhabricatorEnv::getEnvConfig('log.ssh.format');
         $format = nonempty($format, "[%D]\t%p\t%h\t%r\t%s\t%S\t%u\t%C\t%U\t%c\t%T\t%i\t%o");
         // NOTE: Path may be null. We still create the log, it just won't write
         // anywhere.
         $data = array('D' => date('r'), 'h' => php_uname('n'), 'p' => getmypid(), 'e' => time());
         $sudo_user = PhabricatorEnv::getEnvConfig('phd.user');
         if (strlen($sudo_user)) {
             $data['S'] = $sudo_user;
         }
         if (function_exists('posix_geteuid')) {
             $system_uid = posix_geteuid();
             $system_info = posix_getpwuid($system_uid);
             $data['s'] = idx($system_info, 'name');
         }
         $client = getenv('SSH_CLIENT');
         if (strlen($client)) {
             $remote_address = head(explode(' ', $client));
             $data['r'] = $remote_address;
         }
         $log = id(new PhutilDeferredLog($path, $format))->setFailQuietly(true)->setData($data);
         self::$log = $log;
     }
     return self::$log;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:28,代码来源:PhabricatorSSHLog.php

示例3: 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

示例4: validateTransaction

 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhortuneAccountTransaction::TYPE_NAME:
             $missing = $this->validateIsEmptyTextField($object->getName(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('Account name is required.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
         case PhabricatorTransactions::TYPE_EDGE:
             foreach ($xactions as $xaction) {
                 switch ($xaction->getMetadataValue('edge:type')) {
                     case PhortuneAccountHasMemberEdgeType::EDGECONST:
                         // TODO: This is a bit cumbersome, but validation happens before
                         // transaction normalization. Maybe provide a cleaner attack on
                         // this eventually? There's no way to generate "+" or "-"
                         // transactions right now.
                         $new = $xaction->getNewValue();
                         $set = idx($new, '=', array());
                         if (empty($set[$this->requireActor()->getPHID()])) {
                             $error = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('You can not remove yourself as an account member.'), $xaction);
                             $errors[] = $error;
                         }
                         break;
                 }
             }
             break;
     }
     return $errors;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:PhortuneAccountEditor.php

示例5: getTagContent

 protected function getTagContent()
 {
     if ($this->previewURI === null) {
         throw new PhutilInvalidStateException('setPreviewURI');
     }
     if ($this->controlID === null) {
         throw new PhutilInvalidStateException('setControlID');
     }
     $preview_id = celerity_generate_unique_node_id();
     require_celerity_resource('phui-remarkup-preview-css');
     Javelin::initBehavior('remarkup-preview', array('previewID' => $preview_id, 'controlID' => $this->controlID, 'uri' => $this->previewURI));
     $loading = phutil_tag('div', array('class' => 'phui-preview-loading-text'), nonempty($this->loadingText, pht('Loading preview...')));
     $header = null;
     if ($this->header) {
         $header = phutil_tag('div', array('class' => 'phui-preview-header'), $this->header);
     }
     $preview = phutil_tag('div', array('id' => $preview_id, 'class' => 'phabricator-remarkup'), $loading);
     $content = array($header, $preview);
     switch ($this->skin) {
         case 'document':
             $content = id(new PHUIDocumentView())->appendChild($content)->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
             break;
         default:
             $content = id(new PHUIBoxView())->appendChild($content)->setBorder(true)->addMargin(PHUI::MARGIN_LARGE)->addPadding(PHUI::PADDING_LARGE)->addClass('phui-panel-preview');
             break;
     }
     return $content;
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:28,代码来源:PHUIRemarkupPreviewPanel.php

示例6: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $query = $request->getStr('q');
     // Default this to the query string to make debugging a little bit easier.
     $raw_query = nonempty($request->getStr('raw'), $query);
     // This makes form submission easier in the debug view.
     $this->class = nonempty($request->getStr('class'), $this->class);
     $sources = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorTypeaheadDatasource')->loadObjects();
     if (isset($sources[$this->class])) {
         $source = $sources[$this->class];
         $source->setParameters($request->getRequestData());
         $composite = new PhabricatorTypeaheadRuntimeCompositeDatasource();
         $composite->addDatasource($source);
         $composite->setViewer($viewer)->setQuery($query)->setRawQuery($raw_query);
         $results = $composite->loadResults();
     } else {
         $results = array();
     }
     $content = mpull($results, 'getWireFormat');
     if ($request->isAjax()) {
         return id(new AphrontAjaxResponse())->setContent($content);
     }
     // If there's a non-Ajax request to this endpoint, show results in a tabular
     // format to make it easier to debug typeahead output.
     $options = array_fuse(array_keys($sources));
     asort($options);
     $form = id(new AphrontFormView())->setUser($viewer)->setAction('/typeahead/class/')->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Source Class'))->setName('class')->setValue($this->class)->setOptions($options))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Query'))->setName('q')->setValue($request->getStr('q')))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Raw Query'))->setName('raw')->setValue($request->getStr('raw')))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Query')));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Token Query'))->setForm($form);
     $table = new AphrontTableView($content);
     $table->setHeaders(array(pht('Name'), pht('URI'), pht('PHID'), pht('Priority'), pht('Display Name'), pht('Display Type'), pht('Image URI'), pht('Priority Type'), pht('Icon'), pht('Closed'), pht('Sprite')));
     $result_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Token Results (%s)', $this->class))->appendChild($table);
     return $this->buildApplicationPage(array($form_box, $result_box), array('title' => pht('Typeahead Results'), 'device' => false));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:PhabricatorTypeaheadModularDatasourceController.php

示例7: render

 public final function render()
 {
     require_celerity_resource('aphront-error-view-css');
     $errors = $this->errors;
     if ($errors) {
         $list = array();
         foreach ($errors as $error) {
             $list[] = phutil_render_tag('li', array(), phutil_escape_html($error));
         }
         $list = '<ul>' . implode("\n", $list) . '</ul>';
     } else {
         $list = null;
     }
     $title = $this->title;
     if (strlen($title)) {
         $title = '<h1>' . phutil_escape_html($title) . '</h1>';
     } else {
         $title = null;
     }
     $this->severity = nonempty($this->severity, self::SEVERITY_ERROR);
     $this->width = nonempty($this->width, self::WIDTH_DEFAULT);
     $more_classes = array();
     $more_classes[] = 'aphront-error-severity-' . $this->severity;
     $more_classes[] = 'aphront-error-width-' . $this->width;
     $more_classes = implode(' ', $more_classes);
     return phutil_render_tag('div', array('id' => $this->id, 'class' => 'aphront-error-view ' . $more_classes), $title . $this->renderChildren() . $list);
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:27,代码来源:AphrontErrorView.php

示例8: processRequest

 public function processRequest()
 {
     if (!PhabricatorEnv::getEnvConfig('files.enable-proxy')) {
         return new Aphront400Response();
     }
     $request = $this->getRequest();
     $uri = $request->getStr('uri');
     $proxy = id(new PhabricatorFileProxyImage())->loadOneWhere('uri = %s', $uri);
     if (!$proxy) {
         // This write is fine to skip CSRF checks for, we're just building a
         // cache of some remote image.
         $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
         $file = PhabricatorFile::newFromFileDownload($uri, nonempty(basename($uri), 'proxied-file'));
         if ($file) {
             $proxy = new PhabricatorFileProxyImage();
             $proxy->setURI($uri);
             $proxy->setFilePHID($file->getPHID());
             $proxy->save();
         }
         unset($unguarded);
     }
     if ($proxy) {
         $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $proxy->getFilePHID());
         if ($file) {
             $view_uri = $file->getBestURI();
         } else {
             $bad_phid = $proxy->getFilePHID();
             throw new Exception("Unable to load file with phid {$bad_phid}.");
         }
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
     return new Aphront400Response();
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:33,代码来源:PhabricatorFileProxyController.php

示例9: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = $this->buildSideNav('resource');
     $pager = new AphrontPagerView();
     $pager->setURI(new PhutilURI('/drydock/resource/'), 'page');
     $data = id(new DrydockResource())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $data = $pager->sliceResults($data);
     $phids = mpull($data, 'getOwnerPHID');
     $handles = $this->loadViewerHandles($phids);
     $rows = array();
     foreach ($data as $resource) {
         $rows[] = array($resource->getID(), $resource->getOwnerPHID() ? $handles[$resource->getOwnerPHID()]->renderLink() : null, phutil_escape_html($resource->getType()), DrydockResourceStatus::getNameForStatus($resource->getStatus()), phutil_escape_html(nonempty($resource->getName(), 'Unnamed')), phabricator_datetime($resource->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Owner', 'Type', 'Status', 'Resource', 'Created'));
     $table->setColumnClasses(array('', '', '', '', 'pri wide', 'right'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Drydock Resources');
     $panel->addButton(phutil_render_tag('a', array('href' => '/drydock/resource/allocate/', 'class' => 'green button'), 'Allocate Resource'));
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Resources'));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:26,代码来源:DrydockResourceListController.php

示例10: validateTransaction

 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case AlmanacBindingTransaction::TYPE_INTERFACE:
             $missing = $this->validateIsEmptyTextField($object->getInterfacePHID(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('Bindings must specify an interface.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             } else {
                 if ($xactions) {
                     foreach ($xactions as $xaction) {
                         $interfaces = id(new AlmanacInterfaceQuery())->setViewer($this->requireActor())->withPHIDs(array($xaction->getNewValue()))->execute();
                         if (!$interfaces) {
                             $error = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('You can not bind a service to an invalid or restricted ' . 'interface.'), $xaction);
                             $errors[] = $error;
                         }
                     }
                     $final_value = last($xactions)->getNewValue();
                     $binding = id(new AlmanacBindingQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withServicePHIDs(array($object->getServicePHID()))->withInterfacePHIDs(array($final_value))->executeOne();
                     if ($binding && $binding->getID() != $object->getID()) {
                         $error = new PhabricatorApplicationTransactionValidationError($type, pht('Already Bound'), pht('You can not bind a service to the same interface multiple ' . 'times.'), last($xactions));
                         $errors[] = $error;
                     }
                 }
             }
             break;
     }
     return $errors;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:AlmanacBindingEditor.php

示例11: receiveMessage

 public function receiveMessage(PhabricatorBotMessage $message)
 {
     switch ($message->getCommand()) {
         case 'MESSAGE':
             $text = $message->getBody();
             $matches = null;
             if (!preg_match('/where(?: in the world)? is (\\S+?)\\?/i', $text, $matches)) {
                 break;
             }
             $symbol = $matches[1];
             $results = $this->getConduit()->callMethodSynchronous('diffusion.findsymbols', array('name' => $symbol));
             $default_uri = $this->getURI('/diffusion/symbol/' . $symbol . '/');
             if (count($results) > 1) {
                 $response = "Multiple symbols named '{$symbol}': {$default_uri}";
             } else {
                 if (count($results) == 1) {
                     $result = head($results);
                     $response = $result['type'] . ' ' . $result['name'] . ' ' . '(' . $result['language'] . '): ' . nonempty($result['uri'], $default_uri);
                 } else {
                     $response = "No symbol '{$symbol}' found anywhere.";
                 }
             }
             $this->replyTo($message, $response);
             break;
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:26,代码来源:PhabricatorBotSymbolHandler.php

示例12: render

 public function render()
 {
     require_celerity_resource('aphront-tokenizer-control-css');
     $id = $this->id;
     $name = $this->getName();
     $tokens = nonempty($this->getValue(), array());
     $input = javelin_tag('input', array('mustcapture' => true, 'name' => $name, 'class' => 'jx-tokenizer-input', 'sigil' => 'tokenizer-input', 'style' => 'width: 0px;', 'disabled' => 'disabled', 'type' => 'text'));
     $content = $tokens;
     $content[] = $input;
     $content[] = phutil_tag('div', array('style' => 'clear: both;'), '');
     $container = javelin_tag('div', array('id' => $id, 'class' => 'jx-tokenizer-container', 'sigil' => 'tokenizer-container'), $content);
     $icon = id(new PHUIIconView())->setIcon('fa-search');
     $browse = id(new PHUIButtonView())->setTag('a')->setIcon($icon)->addClass('tokenizer-browse-button')->setColor(PHUIButtonView::GREY)->addSigil('tokenizer-browse');
     $classes = array();
     $classes[] = 'jx-tokenizer-frame';
     if ($this->browseURI) {
         $classes[] = 'has-browse';
     }
     $initial = array();
     $initial_value = $this->getInitialValue();
     if ($initial_value) {
         foreach ($this->getInitialValue() as $value) {
             $initial[] = phutil_tag('input', array('type' => 'hidden', 'name' => $name . '.initial[]', 'value' => $value));
         }
     }
     $frame = javelin_tag('div', array('class' => implode(' ', $classes), 'sigil' => 'tokenizer-frame'), array($container, $browse, $initial));
     return $frame;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:28,代码来源:AphrontTokenizerTemplateView.php

示例13: validateTransaction

 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhabricatorCountdownTransaction::TYPE_TITLE:
             $missing = $this->validateIsEmptyTextField($object->getTitle(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('You must give the countdown a name.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
         case PhabricatorCountdownTransaction::TYPE_EPOCH:
             if (!$object->getEpoch() && !$xactions) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('You must give the countdown an end date.'), null);
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             foreach ($xactions as $xaction) {
                 $value = $xaction->getNewValue();
                 if (!$value->isValid()) {
                     $error = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('You must give the countdown a valid end date.'), $xaction);
                     $errors[] = $error;
                 }
             }
             break;
     }
     return $errors;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:29,代码来源:PhabricatorCountdownEditor.php

示例14: validateTransaction

 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhabricatorOAuthServerTransaction::TYPE_NAME:
             $missing = $this->validateIsEmptyTextField($object->getName(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('OAuth applications must have a name.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
         case PhabricatorOAuthServerTransaction::TYPE_REDIRECT_URI:
             $missing = $this->validateIsEmptyTextField($object->getRedirectURI(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('OAuth applications must have a valid redirect URI.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             } else {
                 foreach ($xactions as $xaction) {
                     $redirect_uri = $xaction->getNewValue();
                     try {
                         $server = new PhabricatorOAuthServer();
                         $server->assertValidRedirectURI($redirect_uri);
                     } catch (Exception $ex) {
                         $errors[] = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), $ex->getMessage(), $xaction);
                     }
                 }
             }
             break;
     }
     return $errors;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:33,代码来源:PhabricatorOAuthServerEditor.php

示例15: __toString

 public function __toString()
 {
     $prefix = null;
     if ($this->protocol || $this->domain || $this->port) {
         $protocol = nonempty($this->protocol, 'http');
         $auth = '';
         if (strlen($this->user) && strlen($this->pass)) {
             $auth = phutil_escape_uri($this->user) . ':' . phutil_escape_uri($this->pass) . '@';
         } else {
             if (strlen($this->user)) {
                 $auth = phutil_escape_uri($this->user) . '@';
             }
         }
         $prefix = $protocol . '://' . $auth . $this->domain;
         if ($this->port) {
             $prefix .= ':' . $this->port;
         }
     }
     if ($this->query) {
         $query = '?' . http_build_query($this->query);
     } else {
         $query = null;
     }
     if (strlen($this->getFragment())) {
         $fragment = '#' . $this->getFragment();
     } else {
         $fragment = null;
     }
     return $prefix . $this->getPath() . $query . $fragment;
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:30,代码来源:PhutilURI.php


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