示例#1
0
文件: Header.php 项目: ercuement/ink
 /**
  * Render the given element
  *
  * @return array
  */
 public function renderInternal()
 {
     $headerWrap = MailUtility::breakLinesForEmail(trim($this->contentObject->data['header']), LF, Configuration::getPlainTextWith());
     $subHeaderWrap = MailUtility::breakLinesForEmail(trim($this->contentObject->data['subheader']), LF, Configuration::getPlainTextWith());
     // align
     $header = array_merge(GeneralUtility::trimExplode(LF, $headerWrap, TRUE), GeneralUtility::trimExplode(LF, $subHeaderWrap, TRUE));
     if ($this->contentObject->data['header_position'] == 'right') {
         foreach ($header as $key => $l) {
             $l = trim($l);
             $header[$key] = str_pad(' ', Configuration::getPlainTextWith() - strlen($l), ' ', STR_PAD_LEFT) . $l;
         }
     } elseif ($this->contentObject->data['header_position'] == 'center') {
         foreach ($header as $key => $l) {
             $l = trim($l);
             $header[$key] = str_pad(' ', floor((Configuration::getPlainTextWith() - strlen($l)) / 2), ' ', STR_PAD_LEFT) . $l;
         }
     }
     $header = implode(LF, $header);
     $lines[] = $header;
     return $lines;
 }
示例#2
0
 /**
  * Breaking lines into fixed length lines, using GeneralUtility::breakLinesForEmail()
  *
  * @param string $content The string to break
  * @param array $conf Configuration options: linebreak, charWidth; stdWrap enabled
  *
  * @return string Processed string
  * @see GeneralUtility::breakLinesForEmail()
  */
 public function breakLines($content, array $conf)
 {
     $linebreak = $GLOBALS['TSFE']->cObj->stdWrap($conf['linebreak'] ? $conf['linebreak'] : chr(32) . LF, $conf['linebreak.']);
     $charWidth = $GLOBALS['TSFE']->cObj->stdWrap($conf['charWidth'] ? intval($conf['charWidth']) : 76, $conf['charWidth.']);
     return MailUtility::breakLinesForEmail($content, $linebreak, $charWidth);
 }
示例#3
0
 /**
  * @test
  */
 public function breakLinesForEmailBreaksTextIfLineIsLongerThanTheLineWidth()
 {
     $str = 'Mein Link auf eine News (Link: http://zzzzzzzzzzzzz.xxxxxxxxx.de/index.php?id=10&tx_ttnews%5Btt_news%5D=1&cHash=66f5af320da29b7ae1cda49047ca7358)';
     $returnString = \TYPO3\CMS\Core\Utility\MailUtility::breakLinesForEmail($str);
     $this->assertEquals($returnString, 'Mein Link auf eine News (Link:' . LF . 'http://zzzzzzzzzzzzz.xxxxxxxxx.de/index.php?id=10&tx_ttnews%5Btt_news%5D=1&cHash=66f5af320da29b7ae1cda49047ca7358)');
 }
示例#4
0
 /**
  * Breaking lines into fixed length lines, using GeneralUtility::breakLinesForEmail()
  *
  * @param        string  $str       : The string to break
  * @param        string  $implChar  : Line break character
  * @param        integer $charWidth : Length of lines, default is $this->charWidth
  *
  * @return        string                Processed string
  */
 function breakLines($str, $implChar = LF, $charWidth = FALSE)
 {
     $charWidth = $charWidth === FALSE ? Configuration::getPlainTextWith() : (int) $charWidth;
     return MailUtility::breakLinesForEmail($str, $implChar, $charWidth);
 }
 /**
  * @test
  */
 public function breakLinesForEmailBreaksTextWithNoSpaceFoundBeforeLimit()
 {
     $newlineChar = LF;
     $lineWidth = 10;
     // first space after 20 chars (more than $lineWidth)
     $str = 'abcdefghijklmnopqrst uvwxyz 123456';
     $returnString = \TYPO3\CMS\Core\Utility\MailUtility::breakLinesForEmail($str, $newlineChar, $lineWidth);
     $this->assertEquals($returnString, 'abcdefghijklmnopqrst' . LF . 'uvwxyz' . LF . '123456');
 }
 /**
  * Breaking lines into fixed length lines, using MailUtility::breakLinesForEmail()
  *
  * @param	string		$str: The string to break
  * @param	string		$implChar: Line break character
  * @param	integer		$charWidth: Length of lines, default is $this->charWidth
  * @return	string		Processed string
  * @see MailUtility::breakLinesForEmail()
  */
 function breakLines($str, $implChar, $charWidth = 0)
 {
     $cW = $charWidth ? $charWidth : $this->charWidth;
     $linebreak = $implChar ? $implChar : $this->linebreak;
     return MailUtility::breakLinesForEmail($str, $linebreak, $cW);
 }