コード例 #1
0
ファイル: String.php プロジェクト: tmlsoft/main
 /**
  * Get whether iconv extension is available
  *
  * @return boolean
  */
 public static function getIsIconvEnabled()
 {
     if (isset(self::$_isIconvEnabled)) {
         return self::$_isIconvEnabled;
     }
     self::$_isIconvEnabled = function_exists('iconv') ? true : false;
     return self::$_isIconvEnabled;
 }
コード例 #2
0
 /**
  * Add a Text Element
  *
  * @var string $text
  * @var mixed $styleFont
  * @return PHPWord_Section_Text
  */
 public function addText($text = null, $styleFont = null)
 {
     if (!PHPWord_Shared_String::IsUTF8($text)) {
         $text = utf8_encode($text);
     }
     $text = new PHPWord_Section_Text($text, $styleFont);
     $this->_elementCollection[] = $text;
     return $text;
 }
コード例 #3
0
ファイル: Base.php プロジェクト: heruprambadi/sim_penyuratan
 protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title)
 {
     $text = htmlspecialchars($title->getText());
     $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text);
     $anchor = $title->getAnchor();
     $bookmarkId = $title->getBookmarkId();
     $style = $title->getStyle();
     $objWriter->startElement('w:p');
     if (!empty($style)) {
         $objWriter->startElement('w:pPr');
         $objWriter->startElement('w:pStyle');
         $objWriter->writeAttribute('w:val', $style);
         $objWriter->endElement();
         $objWriter->endElement();
     }
     $objWriter->startElement('w:r');
     $objWriter->startElement('w:fldChar');
     $objWriter->writeAttribute('w:fldCharType', 'end');
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->startElement('w:bookmarkStart');
     $objWriter->writeAttribute('w:id', $bookmarkId);
     $objWriter->writeAttribute('w:name', $anchor);
     $objWriter->endElement();
     $objWriter->startElement('w:r');
     $objWriter->startElement('w:t');
     $objWriter->writeRaw($text);
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->startElement('w:bookmarkEnd');
     $objWriter->writeAttribute('w:id', $bookmarkId);
     $objWriter->endElement();
     $objWriter->endElement();
 }
コード例 #4
0
 /**
  * Add a PreserveText Element
  *
  * @param string $text
  * @param mixed $styleFont
  * @param mixed $styleParagraph
  * @return PHPWord_Section_Footer_PreserveText
  */
 public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
 {
     if (!PHPWord_Shared_String::IsUTF8($text)) {
         $text = utf8_encode($text);
     }
     $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
     $this->_elementCollection[] = $ptext;
     return $ptext;
 }
コード例 #5
0
 /**
  * Set a Template value
  *
  * @param mixed $search
  * @param mixed $replace
  */
 public function setValue($search, $replace)
 {
     $pattern = '|\\$\\{([^\\}]+)\\}|U';
     preg_match_all($pattern, $this->_documentXML, $matches);
     foreach ($matches[0] as $value) {
         $valueCleaned = preg_replace('/<[^>]+>/', '', $value);
         $valueCleaned = preg_replace('/<\\/[^>]+>/', '', $valueCleaned);
         $this->_documentXML = str_replace($value, $valueCleaned, $this->_documentXML);
     }
     if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
         $search = '${' . $search . '}';
     }
     if (!is_array($replace)) {
         if (!PHPWord_Shared_String::IsUTF8($replace)) {
             $replace = utf8_encode($replace);
         }
     }
     $this->_documentXML = str_replace($search, $replace, $this->_documentXML);
 }
コード例 #6
0
 /**
  * Add a Title Element
  *
  * @param string $text
  * @param int $depth
  * @return PHPWord_Section_Title
  */
 public function addTitle($text, $depth = 1)
 {
     if (!PHPWord_Shared_String::IsUTF8($text)) {
         $text = utf8_encode($text);
     }
     $styles = PHPWord_Style::getStyles();
     if (array_key_exists('Heading_' . $depth, $styles)) {
         $style = 'Heading' . $depth;
     } else {
         $style = null;
     }
     $title = new PHPWord_Section_Title($text, $depth, $style);
     $data = PHPWord_TOC::addTitle($text, $depth);
     $anchor = $data[0];
     $bookmarkId = $data[1];
     $title->setAnchor($anchor);
     $title->setBookmarkId($bookmarkId);
     $this->_elementCollection[] = $title;
     return $title;
 }
コード例 #7
0
ファイル: Cell.php プロジェクト: heruprambadi/sim_penyuratan
 /**
  * Add a PreserveText Element
  *
  * @param string $text
  * @param mixed $styleFont
  * @param mixed $styleParagraph
  * @return PHPWord_Section_Footer_PreserveText
  */
 public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
 {
     if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') {
         if (!PHPWord_Shared_String::IsUTF8($text)) {
             $text = utf8_encode($text);
         }
         $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
         $this->_elementCollection[] = $ptext;
         return $ptext;
     } else {
         trigger_error('addPreserveText only supported in footer/header.');
     }
 }