quoteRtfCode() public static méthode

quotes rtf code
public static quoteRtfCode ( string $text, boolean $convertNewlines = true ) : string
$text string
$convertNewlines boolean
Résultat string
Exemple #1
0
 /**
  * renders footnote/endnote
  *
  * @return string
  */
 public function getContent()
 {
     $content = '\\chftn ' . '{\\footnote' . ($this->isFootnote() ? '' : '\\ftnalt') . '\\pard\\plain \\lin283\\fi-283 ';
     if ($this->_parFormat) {
         $content .= $this->_parFormat->getContent($this->_rtf);
     }
     $content .= $this->_font->getContent($this->_rtf);
     $content .= '{\\up6\\chftn}' . "\r\n" . PHPRtfLite::quoteRtfCode($this->_text) . '} ';
     return $content;
 }
Exemple #2
0
 /**
  * gets opening token
  *
  * @return string
  */
 protected function getOpeningToken()
 {
     $hyperlink = PHPRtfLite::quoteRtfCode($this->_hyperlink);
     return '{\\field {\\*\\fldinst {HYPERLINK "' . $hyperlink . '"}}{\\fldrslt {';
 }
Exemple #3
0
 /**
  * renders footnote/endnote
  */
 public function render()
 {
     $stream = $this->_rtf->getWriter();
     $typeSetting = $this->_typeSettingType != self::TYPE_NORMAL ? '\\' . $this->_typeSettingType : '';
     $stream->write('{' . $typeSetting . '\\chftn}' . '{' . $this->getTypeAsRtfCode() . '\\pard\\plain\\lin283\\fi-283 ');
     if ($this->_parFormat) {
         $stream->write($this->_parFormat->getContent());
     }
     if ($this->_font) {
         $stream->write($this->_font->getContent());
     }
     $stream->write('{\\up6\\chftn}' . "\r\n" . PHPRtfLite::quoteRtfCode($this->_text) . '} ');
 }
Exemple #4
0
 /**
  * renders the element
  */
 public function render()
 {
     $stream = $this->_rtf->getWriter();
     $text = $this->_text;
     if (!$this->_isRtfCode) {
         $charset = $this->_rtf->getCharset();
         $text = PHPRtfLite::quoteRtfCode($text);
         if ($this->_convertTagsToRtf) {
             $text = self::convertTagsToRtf($text, $charset);
         }
         $text = PHPRtfLite_Utf8::getUnicodeEntities($text, $charset);
     }
     $stream->write($this->getOpeningToken());
     if ($this->_font) {
         $stream->write($this->_font->getContent());
     }
     if ($this->isEmptyParagraph() && !$this->_isRtfCode) {
         $stream->write('\\par');
     } else {
         $stream->write($text);
     }
     $stream->write($this->getClosingToken() . "\r\n");
 }
Exemple #5
0
 /**
  * Writes text to container.
  * 
  * @param string $text Text. Also you can use html style tags. Possible tags:<br>
  *   strong, b- bold; <br>
  *   em - ; <br>
  *   i - italic; <br>
  *   u - underline; <br>
  *   br - line break; <br>
  *   chdate - current date; <br>
  *   chdpl - current date in long format; <br>
  *   chdpa - current date in abbreviated format; <br>
  *   chtime - current time; <br>
  *   chpgn, pagenum - page number ; <br>
  *   tab - tab
  *   sectnum - section number; <br>
  *   line - line break; <br>
  *   page - page break; <br>
  *   sect - section break; <br>
  * @param PHPRtfLite_Font       $font           font of text
  * @param PHPRtfLite_ParFormat  $parFormat      paragraph format, if null, text is written in the same paragraph.
  * @param boolean               $replaceTags    if false, then html style tags are not replaced with rtf code
  * @todo Documentation
  */
 public function writeText($text, PHPRtfLite_Font $font = null, PHPRtfLite_ParFormat $parFormat = null, $replaceTags = true)
 {
     $text = PHPRtfLite::quoteRtfCode($text);
     if ($replaceTags) {
         //bold
         $text = preg_replace('/<STRONG[ ]*>(.*?)<\\/STRONG[ ]*>/smi', '\\b \\1\\b0 ', $text);
         $text = preg_replace('/<B[ ]*>(.*?)<\\/B[ ]*>/smi', '\\b \\1\\b0 ', $text);
         //italic
         $text = preg_replace('/<EM[ ]*>(.*?)<\\/EM[ ]*>/smi', '\\i \\1\\i0 ', $text);
         $text = preg_replace('/<I[ ]*>(.*?)<\\/I[ ]*>/smi', '\\i \\1\\i0 ', $text);
         //underline
         $text = preg_replace('/<U[ ]*>(.*?)<\\/U[ ]*>/smi', '\\ul \\1\\ul0 ', $text);
         //break
         $text = preg_replace('/<BR[ ]*(\\/)?[ ]*>/smi', '\\line ', $text);
         //horizontal rule
         $text = preg_replace('/<HR[ ]*(\\/)?[ ]*>/smi', '{\\pard \\brdrb \\brdrs \\brdrw10 \\brsp20 \\par}', $text);
         $text = preg_replace('/<CHDATE[ ]*(\\/)?[ ]*>/smi', '\\chdate ', $text);
         $text = preg_replace('/<CHDPL[ ]*(\\/)?[ ]*>/smi', '\\\\chdpl ', $text);
         $text = preg_replace('/<CHDPA[ ]*(\\/)?[ ]*>/smi', '\\chdpa ', $text);
         $text = preg_replace('/<CHTIME[ ]*(\\/)?[ ]*>/smi', '\\chtime ', $text);
         $text = preg_replace('/<CHPGN[ ]*(\\/)?[ ]*>/smi', '\\chpgn ', $text);
         $text = preg_replace('/<TAB[ ]*(\\/)?[ ]*>/smi', '\\tab ', $text);
         $text = preg_replace('/<BULLET[ ]*(\\/)?[ ]*>/smi', '\\bullet ', $text);
         $text = preg_replace('/<PAGENUM[ ]*(\\/)?[ ]*>/smi', '\\chpgn ', $text);
         $text = preg_replace('/<SECTNUM[ ]*(\\/)?[ ]*>/smi', '\\sectnum ', $text);
         $text = preg_replace('/<LINE[ ]*(\\/)?[ ]*>/smi', '\\line ', $text);
         //$text = preg_replace('/<PAGE[ ]*(\/)?[ ]*>/smi', '\\page ', $text);
         //$text = preg_replace('/<SECT[ ]*(\/)?[ ]*>/smi', '\\sect', $text);
     }
     $text = PHPRtfLite_Utf8::getUnicodeEntities($text);
     //content formating
     $content = $parFormat && count($this->_elements) != 0 && !$this->_emptyPar ? '\\par ' : '';
     $this->_emptyPar = false;
     $content .= $parFormat ? $this->_pard . $parFormat->getContent($this->_rtf) : '';
     $content .= '{';
     if ($font) {
         $content .= $font->getContent($this->_rtf);
     }
     $content .= $text . '}' . "\r\n";
     $this->_elements[] = $content;
 }
Exemple #6
0
 /**
  * gets list character
  *
  * @param  integer $number
  * @return string
  */
 protected function getListCharacter($number)
 {
     $listCharacter = $this->_prefix . $this->getNumber($number) . $this->_suffix;
     return PHPRtfLite::quoteRtfCode($listCharacter);
 }
 /**
  * @dataProvider provideQuoteRtfCode()
  */
 public function testQuoteRtfCode($testString, $resultString)
 {
     $this->assertEquals($resultString, PHPRtfLite::quoteRtfCode($testString));
 }