Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/view/PhabricatorMetaMTAMailBody.php
Show All 37 Lines | if (strlen($text)) { | ||||
$text = rtrim($text); | $text = rtrim($text); | ||||
$this->sections[] = $text; | $this->sections[] = $text; | ||||
$this->htmlSections[] = phutil_escape_html_newlines( | $this->htmlSections[] = phutil_escape_html_newlines( | ||||
phutil_tag('div', array(), $text)); | phutil_tag('div', array(), $text)); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addRemarkupSection($text) { | public function addRemarkupSection($header, $text) { | ||||
try { | try { | ||||
$engine = PhabricatorMarkupEngine::newMarkupEngine(array()); | $engine = PhabricatorMarkupEngine::newMarkupEngine(array()); | ||||
$engine->setConfig('viewer', $this->getViewer()); | $engine->setConfig('viewer', $this->getViewer()); | ||||
$engine->setMode(PhutilRemarkupEngine::MODE_TEXT); | $engine->setMode(PhutilRemarkupEngine::MODE_TEXT); | ||||
epriestley: I think we can actually toss this.. | |||||
$styled_text = $engine->markupText($text); | $styled_text = $engine->markupText($text); | ||||
$this->sections[] = $styled_text; | $this->addPlaintextSection($header, $styled_text); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
Not Done Inline Actions...and do addPlaintextSection() here. As written, this isn't correct -- it adds HTML to the "plaintext" sections. epriestley: ...and do `addPlaintextSection()` here. As written, this isn't correct -- it adds HTML to the… | |||||
Not Done Inline ActionsBut it previously added "styled_text"? Seems counterintuitive to add plaintext by default in a remarkup section? lpriestley: But it previously added "styled_text"? Seems counterintuitive to add plaintext by default in a… | |||||
phlog($ex); | phlog($ex); | ||||
$this->sections[] = $text; | $this->addTextSection($header, $text); | ||||
} | } | ||||
try { | try { | ||||
$mail_engine = PhabricatorMarkupEngine::newMarkupEngine(array()); | $mail_engine = PhabricatorMarkupEngine::newMarkupEngine(array()); | ||||
$mail_engine->setConfig('viewer', $this->getViewer()); | $mail_engine->setConfig('viewer', $this->getViewer()); | ||||
$mail_engine->setMode(PhutilRemarkupEngine::MODE_HTML_MAIL); | $mail_engine->setMode(PhutilRemarkupEngine::MODE_HTML_MAIL); | ||||
$mail_engine->setConfig( | $mail_engine->setConfig( | ||||
'uri.base', | 'uri.base', | ||||
PhabricatorEnv::getProductionURI('/')); | PhabricatorEnv::getProductionURI('/')); | ||||
$html = $mail_engine->markupText($text); | $html = $mail_engine->markupText($text); | ||||
$this->htmlSections[] = $html; | $this->addHTMLSection($header, $html); | ||||
Not Done Inline Actions..and addHTMLSection(...) here. epriestley: ..and `addHTMLSection(...)` here. | |||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
phlog($ex); | phlog($ex); | ||||
$this->htmlSections[] = phutil_escape_html_newlines( | $this->addHTMLSection($header, $text); | ||||
Not Done Inline Actions...and addHTMLSection() here too. epriestley: ...and addHTMLSection() here too. | |||||
phutil_tag( | |||||
'div', | |||||
array(), | |||||
$text)); | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addRawPlaintextSection($text) { | public function addRawPlaintextSection($text) { | ||||
if (strlen($text)) { | if (strlen($text)) { | ||||
$text = rtrim($text); | $text = rtrim($text); | ||||
Show All 34 Lines | /* -( Composition )-------------------------------------------------------- */ | ||||
} | } | ||||
public function addPlaintextSection($header, $text) { | public function addPlaintextSection($header, $text) { | ||||
$this->sections[] = $header."\n".$this->indent($text); | $this->sections[] = $header."\n".$this->indent($text); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addHTMLSection($header, $html_fragment) { | public function addHTMLSection($header, $html_fragment) { | ||||
if ($header !== null) { | |||||
Not Done Inline ActionsThen this can be left as-is.. epriestley: Then this can be left as-is.. | |||||
$header = phutil_tag('strong', array(), $header); | |||||
} | |||||
$this->htmlSections[] = array( | $this->htmlSections[] = array( | ||||
phutil_tag( | phutil_tag( | ||||
'div', | 'div', | ||||
array(), | array(), | ||||
array( | array( | ||||
phutil_tag('strong', array(), $header), | $header, | ||||
Not Done Inline ActionsIt looks like we lost the bold here? epriestley: It looks like we lost the bold here? | |||||
Not Done Inline ActionsTrying to recall why I removed the phutil_tag. I think this was intentional. What's the right way to make this bold without a phutil_tag? lpriestley: Trying to recall why I removed the phutil_tag. I think this was intentional. What's the right… | |||||
phutil_tag('div', array(), $html_fragment), | phutil_tag('div', array(), $html_fragment), | ||||
)), | )), | ||||
); | ); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addLinkSection($header, $link) { | public function addLinkSection($header, $link) { | ||||
$html = phutil_tag('a', array('href' => $link), $link); | $html = phutil_tag('a', array('href' => $link), $link); | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | /* -( Rendering )---------------------------------------------------------- */ | ||||
* | * | ||||
* @param string Text to indent. | * @param string Text to indent. | ||||
* @return string Indented text. | * @return string Indented text. | ||||
* @task render | * @task render | ||||
*/ | */ | ||||
private function indent($text) { | private function indent($text) { | ||||
return rtrim(" ".str_replace("\n", "\n ", $text)); | return rtrim(" ".str_replace("\n", "\n ", $text)); | ||||
} | } | ||||
} | } | ||||
Not Done Inline ActionsAnd this can be removed. epriestley: And this can be removed. |
I think we can actually toss this..