Example #1
0
 /**
  * Breaks content lines into a bullet list
  *
  * @param ContentObjectRenderer $contentObject
  * @param string                $str Content string to make into a bullet list
  *
  * @return string Processed value
  */
 function breakBulletList($contentObject, $str)
 {
     $type = $contentObject->data['layout'];
     $type = MathUtility::forceIntegerInRange($type, 0, 3);
     $tConf = $this->configuration['bulletlist.'][$type . '.'];
     $cParts = explode(chr(10), $str);
     $lines = array();
     $c = 0;
     foreach ($cParts as $substrs) {
         if (!strlen($substrs)) {
             continue;
         }
         $c++;
         $bullet = $tConf['bullet'] ? $tConf['bullet'] : ' - ';
         $bLen = strlen($bullet);
         $bullet = substr(str_replace('#', $c, $bullet), 0, $bLen);
         $secondRow = substr($tConf['secondRow'] ? $tConf['secondRow'] : str_pad('', strlen($bullet), ' '), 0, $bLen);
         $lines[] = $bullet . $this->breakLines($substrs, chr(10) . $secondRow, Configuration::getPlainTextWith() - $bLen);
         $blanks = MathUtility::forceIntegerInRange($tConf['blanks'], 0, 1000);
         if ($blanks) {
             $lines[] = str_pad('', $blanks - 1, chr(10));
         }
     }
     return implode(chr(10), $lines);
 }
Example #2
0
 /**
  * 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;
 }
Example #3
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);
 }
Example #4
0
 /**
  * @param $lengths
  *
  * @return mixed
  */
 protected function increaseLengthToo100Percent($lengths)
 {
     if (!Configuration::isPlainTable100()) {
         return $lengths;
     }
     $fullWidth = Configuration::getPlainTextWith();
     // Calc
     $rowCount = sizeof($lengths) + 1;
     $yCount = $rowCount - 2;
     $currentWidth = array_sum($lengths);
     if ($this->tableSettings[$this->renderMode]['outerLeft']) {
         $yCount++;
     }
     if ($this->tableSettings[$this->renderMode]['outerRight']) {
         $yCount++;
     }
     $currentWidth += strlen($this->tableSettings[$this->renderMode]['yChar']) * $yCount;
     $currentWidth += $this->tableSettings[$this->renderMode]['xSpace'] * $rowCount;
     if ($fullWidth < $currentWidth) {
         return $lengths;
     }
     $moreChars = $fullWidth - $currentWidth;
     while ($moreChars > 0) {
         foreach ($lengths as $key => $value) {
             if ($moreChars <= 0) {
                 break;
             }
             $lengths[$key]++;
             $moreChars--;
         }
     }
     return $lengths;
 }