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


PHP phutil_escape_html_newlines函数代码示例

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


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

示例1: markupText

 public function markupText($text, $children)
 {
     $engine = $this->getEngine();
     $text = trim($text);
     $text = $this->applyRules($text);
     if ($engine->isTextMode()) {
         if (!$this->getEngine()->getConfig('preserve-linebreaks')) {
             $text = preg_replace('/ *\\n */', ' ', $text);
         }
         return $text;
     }
     if ($engine->getConfig('preserve-linebreaks')) {
         $text = phutil_escape_html_newlines($text);
     }
     if (!strlen($text)) {
         return null;
     }
     $default_attributes = $engine->getConfig('default.p.attributes');
     if ($default_attributes) {
         $attributes = $default_attributes;
     } else {
         $attributes = array();
     }
     return phutil_tag('p', $attributes, $text);
 }
开发者ID:endlessm,项目名称:libphutil,代码行数:25,代码来源:PhutilRemarkupDefaultBlockRule.php

示例2: renderForMail

 public function renderForMail()
 {
     $diff = $this->buildDiff();
     $old_styles = array('padding: 0 2px;', 'color: #802b2b;', 'background: rgba(251, 175, 175, .7);');
     $old_styles = implode(' ', $old_styles);
     $new_styles = array('padding: 0 2px;', 'color: #3e6d35;', 'background: rgba(151, 234, 151, .6);');
     $new_styles = implode(' ', $new_styles);
     $omit_styles = array('padding: 8px 0;');
     $omit_styles = implode(' ', $omit_styles);
     $result = array();
     foreach ($diff->getSummaryParts() as $part) {
         $type = $part['type'];
         $text = $part['text'];
         switch ($type) {
             case '.':
                 $result[] = phutil_tag('div', array('style' => $omit_styles), pht('...'));
                 break;
             case '-':
                 $result[] = phutil_tag('span', array('style' => $old_styles), $text);
                 break;
             case '+':
                 $result[] = phutil_tag('span', array('style' => $new_styles), $text);
                 break;
             case '=':
                 $result[] = $text;
                 break;
         }
     }
     $styles = array('white-space: pre-wrap;', 'color: #74777D;');
     // Beyond applying "pre-wrap", convert newlines to "<br />" explicitly
     // to improve behavior in clients like Airmail.
     $result = phutil_escape_html_newlines($result);
     return phutil_tag('div', array('style' => implode(' ', $styles)), $result);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:34,代码来源:PhabricatorApplicationTransactionTextDiffDetailView.php

示例3: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $signature = id(new LegalpadDocumentSignatureQuery())->setViewer($viewer)->withIDs(array($this->id))->executeOne();
     if (!$signature) {
         return new Aphront404Response();
     }
     // NOTE: In order to see signature details (which include the relatively
     // internal-feeling "notes" field) you must be able to edit the document.
     // Essentially, this power is for document managers. Notably, this prevents
     // users from seeing notes about their own exemptions by guessing their
     // signature ID. This is purely a policy check.
     $document = id(new LegalpadDocumentQuery())->setViewer($viewer)->withIDs(array($signature->getDocument()->getID()))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$document) {
         return new Aphront404Response();
     }
     $document_id = $signature->getDocument()->getID();
     $next_uri = $this->getApplicationURI('signatures/' . $document_id . '/');
     $data = $signature->getSignatureData();
     $exemption_phid = $signature->getExemptionPHID();
     $actor_phid = idx($data, 'actorPHID');
     $handles = $this->loadViewerHandles(array($exemption_phid, $actor_phid));
     $exemptor_handle = $handles[$exemption_phid];
     $actor_handle = $handles[$actor_phid];
     $form = id(new AphrontFormView())->setUser($viewer);
     if ($signature->getExemptionPHID()) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Exemption By'))->setValue($exemptor_handle->renderLink()))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Notes'))->setValue(idx($data, 'notes')));
     }
     $type_corporation = LegalpadDocument::SIGNATURE_TYPE_CORPORATION;
     if ($signature->getSignatureType() == $type_corporation) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Signing User'))->setValue($actor_handle->renderLink()))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Company Name'))->setValue(idx($data, 'name')))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Address'))->setValue(phutil_escape_html_newlines(idx($data, 'address'))))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Contact Name'))->setValue(idx($data, 'contact.name')))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Contact Email'))->setValue(phutil_tag('a', array('href' => 'mailto:' . idx($data, 'email')), idx($data, 'email'))));
     }
     return $this->newDialog()->setTitle(pht('Signature Details'))->setWidth(AphrontDialogView::WIDTH_FORM)->appendChild($form->buildLayoutView())->addCancelButton($next_uri, pht('Close'));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:LegalpadDocumentSignatureViewController.php

示例4: apply

 public function apply($text)
 {
     if ($this->getEngine()->isTextMode()) {
         return $text;
     }
     return phutil_escape_html_newlines($text);
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:7,代码来源:PhutilRemarkupRuleLinebreaks.php

示例5: getBodyForFeed

 public function getBodyForFeed(PhabricatorFeedStory $story)
 {
     $new = $this->getNewValue();
     $body = null;
     switch ($this->getTransactionType()) {
         case self::TYPE_CONTENT:
             return phutil_escape_html_newlines(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(128)->truncateString($new));
             break;
     }
     return parent::getBodyForFeed($story);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:11,代码来源:PonderAnswerTransaction.php

示例6: getResponseBody

 protected function getResponseBody()
 {
     $ex = $this->exception;
     if ($ex instanceof AphrontUsageException) {
         $title = $ex->getTitle();
     } else {
         $title = get_class($ex);
     }
     $body = $ex->getMessage();
     $body = phutil_escape_html_newlines($body);
     return phutil_tag('div', array('class' => 'unhandled-exception-detail'), array(phutil_tag('h1', array('class' => 'unhandled-exception-title'), $title), phutil_tag('div', array('class' => 'unhandled-exception-body'), $body)));
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:12,代码来源:AphrontUnhandledExceptionResponse.php

示例7: renderHarbormasterStatus

 protected function renderHarbormasterStatus(DifferentialDiff $diff, array $messages)
 {
     $colors = array(DifferentialLintStatus::LINT_NONE => 'grey', DifferentialLintStatus::LINT_OKAY => 'green', DifferentialLintStatus::LINT_WARN => 'yellow', DifferentialLintStatus::LINT_FAIL => 'red', DifferentialLintStatus::LINT_SKIP => 'blue', DifferentialLintStatus::LINT_AUTO_SKIP => 'blue');
     $icon_color = idx($colors, $diff->getLintStatus(), 'grey');
     $message = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff);
     $excuse = $diff->getProperty('arc:lint-excuse');
     if (strlen($excuse)) {
         $excuse = array(phutil_tag('strong', array(), pht('Excuse:')), ' ', phutil_escape_html_newlines($excuse));
     }
     $status = id(new PHUIStatusListView())->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color)->setTarget($message)->setNote($excuse));
     return $status;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:12,代码来源:DifferentialLintField.php

示例8: addTextSection

 /**
  * Add a block of text with a section header. This is rendered like this:
  *
  *    HEADER
  *      Text is indented.
  *
  * @param string Header text.
  * @param string Section text.
  * @return this
  * @task compose
  */
 public function addTextSection($header, $section)
 {
     if ($section instanceof PhabricatorMetaMTAMailSection) {
         $plaintext = $section->getPlaintext();
         $html = $section->getHTML();
     } else {
         $plaintext = $section;
         $html = phutil_escape_html_newlines(phutil_tag('div', array(), $section));
     }
     $this->addPlaintextSection($header, $plaintext);
     $this->addHTMLSection($header, $html);
     return $this;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:24,代码来源:PhabricatorMetaMTAMailBody.php

示例9: processRequest

 public function processRequest()
 {
     try {
         $status = PhabricatorNotificationClient::getServerStatus();
         $status = $this->renderServerStatus($status);
     } catch (Exception $ex) {
         $status = new AphrontErrorView();
         $status->setTitle('Notification Server Issue');
         $status->appendChild(hsprintf('Unable to determine server status. This probably means the server ' . 'is not in great shape. The specific issue encountered was:' . '<br />' . '<br />' . '<strong>%s</strong> %s', get_class($ex), phutil_escape_html_newlines($ex->getMessage())));
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Status'));
     return $this->buildApplicationPage(array($crumbs, $status), array('title' => pht('Notification Server Status'), 'device' => false));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:14,代码来源:PhabricatorNotificationStatusController.php

示例10: markupText

 public function markupText($text)
 {
     $text = trim($text);
     $text = $this->applyRules($text);
     if ($this->getEngine()->isTextMode()) {
         if (!$this->getEngine()->getConfig('preserve-linebreaks')) {
             $text = preg_replace('/ *\\n */', ' ', $text);
         }
         return $text;
     }
     if ($this->getEngine()->getConfig('preserve-linebreaks')) {
         $text = phutil_escape_html_newlines($text);
     }
     return phutil_tag('p', array(), $text);
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:15,代码来源:PhutilRemarkupEngineRemarkupDefaultBlockRule.php

示例11: newTable

 public function newTable()
 {
     $viewer = $this->getViewer();
     $logs = $this->getLogs();
     $show_sources = $this->getShowImportSources();
     $rows = array();
     foreach ($logs as $log) {
         $icon = $log->getDisplayIcon($viewer);
         $color = $log->getDisplayColor($viewer);
         $name = $log->getDisplayType($viewer);
         $description = $log->getDisplayDescription($viewer);
         $rows[] = array($log->getID(), $show_sources ? $viewer->renderHandle($log->getImport()->getPHID()) : null, id(new PHUIIconView())->setIcon($icon, $color), $name, phutil_escape_html_newlines($description), phabricator_datetime($log->getDateCreated(), $viewer));
     }
     $table = id(new AphrontTableView($rows))->setHeaders(array(pht('ID'), pht('Source'), null, pht('Type'), pht('Message'), pht('Date')))->setColumnVisibility(array(true, $show_sources))->setColumnClasses(array('top', 'top', 'top', 'top pri', 'top wide', 'top'));
     return $table;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:16,代码来源:PhabricatorCalendarImportLogView.php

示例12: render

 public function render()
 {
     $readme_path = $this->getPath();
     $readme_name = basename($readme_path);
     $interpreter = $this->getReadmeLanguage($readme_name);
     require_celerity_resource('diffusion-readme-css');
     $content = $this->getContent();
     $class = null;
     switch ($interpreter) {
         case 'remarkup':
             // TODO: This is sketchy, but make sure we hit the markup cache.
             $markup_object = id(new PhabricatorMarkupOneOff())->setEngineRuleset('diffusion-readme')->setContent($content);
             $markup_field = 'default';
             $content = id(new PhabricatorMarkupEngine())->setViewer($this->getUser())->addObject($markup_object, $markup_field)->process()->getOutput($markup_object, $markup_field);
             $engine = $markup_object->newMarkupEngine($markup_field);
             $toc = PhutilRemarkupHeaderBlockRule::renderTableOfContents($engine);
             if ($toc) {
                 $toc = phutil_tag_div('phabricator-remarkup-toc', array(phutil_tag_div('phabricator-remarkup-toc-header', pht('Table of Contents')), $toc));
                 $content = array($toc, $content);
             }
             $readme_content = $content;
             $class = null;
             break;
         case 'rainbow':
             $content = id(new PhutilRainbowSyntaxHighlighter())->getHighlightFuture($content)->resolve();
             $readme_content = phutil_escape_html_newlines($content);
             require_celerity_resource('syntax-highlighting-css');
             $class = 'remarkup-code ml';
             break;
         default:
         case 'text':
             $readme_content = phutil_escape_html_newlines($content);
             $class = 'ml';
             break;
     }
     $readme_content = phutil_tag_div($class, $readme_content);
     $header = id(new PHUIHeaderView())->setHeader($readme_name);
     $document = id(new PHUIDocumentViewPro())->setFluid(true)->appendChild($readme_content);
     return id(new PHUIObjectBoxView())->setHeader($header)->appendChild($document)->addClass('diffusion-readme-view');
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:40,代码来源:DiffusionReadmeView.php

示例13: getResult

 protected function getResult(ConduitAPIRequest $request)
 {
     $drequest = $this->getDiffusionRequest();
     $path_dicts = $request->getValue('paths', array());
     $paths = array();
     foreach ($path_dicts as $dict) {
         $paths[] = DiffusionRepositoryPath::newFromDictionary($dict);
     }
     $best = -1;
     $readme = '';
     $best_render_type = 'plain';
     foreach ($paths as $result_path) {
         $file_type = $result_path->getFileType();
         if ($file_type != ArcanistDiffChangeType::FILE_NORMAL && $file_type != ArcanistDiffChangeType::FILE_TEXT) {
             // Skip directories, etc.
             continue;
         }
         $path = strtolower($result_path->getPath());
         if ($path === 'readme') {
             $path .= '.remarkup';
         }
         if (strncmp($path, 'readme.', 7) !== 0) {
             continue;
         }
         $priority = 0;
         switch (substr($path, 7)) {
             case 'remarkup':
                 $priority = 100;
                 $render_type = 'remarkup';
                 break;
             case 'rainbow':
                 $priority = 90;
                 $render_type = 'rainbow';
                 break;
             case 'md':
                 $priority = 50;
                 $render_type = 'remarkup';
                 break;
             case 'txt':
                 $priority = 10;
                 $render_type = 'plain';
                 break;
             default:
                 $priority = 0;
                 $render_type = 'plain';
                 break;
         }
         if ($priority > $best) {
             $best = $priority;
             $readme = $result_path;
             $best_render_type = $render_type;
         }
     }
     if (!$readme) {
         return '';
     }
     $readme_request = DiffusionRequest::newFromDictionary(array('user' => $request->getUser(), 'repository' => $drequest->getRepository(), 'commit' => $drequest->getStableCommit(), 'path' => $readme->getFullPath()));
     $file_content = DiffusionFileContent::newFromConduit(DiffusionQuery::callConduitWithDiffusionRequest($request->getUser(), $readme_request, 'diffusion.filecontentquery', array('commit' => $drequest->getStableCommit(), 'path' => $readme->getFullPath(), 'needsBlame' => false)));
     $readme_content = $file_content->getCorpus();
     switch ($best_render_type) {
         case 'plain':
             $readme_content = phutil_escape_html_newlines($readme_content);
             $class = null;
             break;
         case 'rainbow':
             $highlighter = new PhutilRainbowSyntaxHighlighter();
             $readme_content = $highlighter->getHighlightFuture($readme_content)->resolve();
             $readme_content = phutil_escape_html_newlines($readme_content);
             require_celerity_resource('syntax-highlighting-css');
             $class = 'remarkup-code';
             break;
         case 'remarkup':
             // TODO: This is sketchy, but make sure we hit the markup cache.
             $markup_object = id(new PhabricatorMarkupOneOff())->setEngineRuleset('diffusion-readme')->setContent($readme_content);
             $markup_field = 'default';
             $readme_content = id(new PhabricatorMarkupEngine())->setViewer($request->getUser())->addObject($markup_object, $markup_field)->process()->getOutput($markup_object, $markup_field);
             $engine = $markup_object->newMarkupEngine($markup_field);
             $toc = PhutilRemarkupHeaderBlockRule::renderTableOfContents($engine);
             if ($toc) {
                 $toc = phutil_tag_div('phabricator-remarkup-toc', array(phutil_tag_div('phabricator-remarkup-toc-header', pht('Table of Contents')), $toc));
                 $readme_content = array($toc, $readme_content);
             }
             $class = 'phabricator-remarkup';
             break;
     }
     $readme_content = phutil_tag('div', array('class' => $class), $readme_content);
     return $readme_content;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:88,代码来源:DiffusionReadmeQueryConduitAPIMethod.php

示例14: getBodyForFeed

 public function getBodyForFeed(PhabricatorFeedStory $story)
 {
     $text = null;
     switch ($this->getTransactionType()) {
         case PholioTransactionType::TYPE_NAME:
             if ($this->getOldValue() === null) {
                 $mock = $story->getPrimaryObject();
                 $text = $mock->getDescription();
             }
             break;
         case PholioTransactionType::TYPE_INLINE:
             $text = $this->getComment()->getContent();
             break;
     }
     if ($text) {
         return phutil_escape_html_newlines(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(128)->truncateString($text));
     }
     return parent::getBodyForFeed($story);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:19,代码来源:PholioTransaction.php

示例15: renderPropertyViewValue

 public function renderPropertyViewValue(array $handles)
 {
     $diff = $this->getObject()->getActiveDiff();
     $ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff);
     $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
     $rows = array();
     $rows[] = array('style' => 'star', 'name' => $ustar, 'value' => $umsg, 'show' => true);
     $excuse = $diff->getProperty('arc:unit-excuse');
     if ($excuse) {
         $rows[] = array('style' => 'excuse', 'name' => 'Excuse', 'value' => phutil_escape_html_newlines($excuse), 'show' => true);
     }
     $show_limit = 10;
     $hidden = array();
     $udata = $diff->getProperty('arc:unit');
     if ($udata) {
         $sort_map = array(ArcanistUnitTestResult::RESULT_BROKEN => 0, ArcanistUnitTestResult::RESULT_FAIL => 1, ArcanistUnitTestResult::RESULT_UNSOUND => 2, ArcanistUnitTestResult::RESULT_SKIP => 3, ArcanistUnitTestResult::RESULT_POSTPONED => 4, ArcanistUnitTestResult::RESULT_PASS => 5);
         foreach ($udata as $key => $test) {
             $udata[$key]['sort'] = idx($sort_map, idx($test, 'result'));
         }
         $udata = isort($udata, 'sort');
         $engine = new PhabricatorMarkupEngine();
         $engine->setViewer($this->getViewer());
         $markup_objects = array();
         foreach ($udata as $key => $test) {
             $userdata = idx($test, 'userdata');
             if ($userdata) {
                 if ($userdata !== false) {
                     $userdata = str_replace("", '', $userdata);
                 }
                 $markup_object = id(new PhabricatorMarkupOneOff())->setContent($userdata)->setPreserveLinebreaks(true);
                 $engine->addObject($markup_object, 'default');
                 $markup_objects[$key] = $markup_object;
             }
         }
         $engine->process();
         foreach ($udata as $key => $test) {
             $result = idx($test, 'result');
             $default_hide = false;
             switch ($result) {
                 case ArcanistUnitTestResult::RESULT_POSTPONED:
                 case ArcanistUnitTestResult::RESULT_PASS:
                     $default_hide = true;
                     break;
             }
             if ($show_limit && !$default_hide) {
                 --$show_limit;
                 $show = true;
             } else {
                 $show = false;
                 if (empty($hidden[$result])) {
                     $hidden[$result] = 0;
                 }
                 $hidden[$result]++;
             }
             $value = idx($test, 'name');
             if (!empty($test['link'])) {
                 $value = phutil_tag('a', array('href' => $test['link'], 'target' => '_blank'), $value);
             }
             $rows[] = array('style' => $this->getResultStyle($result), 'name' => ucwords($result), 'value' => $value, 'show' => $show);
             if (isset($markup_objects[$key])) {
                 $rows[] = array('style' => 'details', 'value' => $engine->getOutput($markup_objects[$key], 'default'), 'show' => false);
                 if (empty($hidden['details'])) {
                     $hidden['details'] = 0;
                 }
                 $hidden['details']++;
             }
         }
     }
     $show_string = $this->renderShowString($hidden);
     $view = new DifferentialResultsTableView();
     $view->setRows($rows);
     $view->setShowMoreString($show_string);
     return $view->render();
 }
开发者ID:denghp,项目名称:phabricator,代码行数:74,代码来源:DifferentialUnitField.php


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