_xml; } /** * Singleton, return instance of class * * @access public * @return CreateText * @static */ public static function getInstance() { if (self::$_instance == NULL) { self::$_instance = new CreateText(); } return self::$_instance; } /** * Create text * * @access public * @param mixed $args[0] * @param array $args[1] */ public function createText() { $this->_xml = ''; $args = func_get_args(); $this->generateP(); if (!is_array($args[0])) { if ( !empty($args[1]['jc']) || !empty($args[1]['pageBreakBefore']) || !empty($args[1]['widowControl']) || !empty($args[1]['wordWrap']) ) { $this->generatePPR(); if (!empty($args[1]['jc'])) $this->generateJC($args[1]['jc']); if (!empty($args[1]['pageBreakBefore'])) $this->generatePAGEBREAKBEFORE($args[1]['pageBreakBefore']); if (!empty($args[1]['widowControl'])) $this->generateWIDOWCONTROL($args[1]['widowControl']); if (!empty($args[1]['wordWrap'])) $this->generateWORDWRAP($args[1]['wordWrap']); } $this->generateR(); if ( $args[1]['b'] != '' || $args[1]['i'] != '' || $args[1]['u'] != '' || $args[1]['sz'] != '' || $args[1]['color'] != '' || $args[1]['font'] != '' || $args[1]['tabs'] != '' ) { $this->generateRPR(); if (isset($args[1]['font']) && $args[1]['font'] != '') { $this->generateRFONTS($args[1]['font']); } if (isset($args[1]['b']) && $args[1]['b'] != '') { $this->generateB($args[1]['b']); } if (isset($args[1]['i']) && $args[1]['i'] != '') { $this->generateI($args[1]['i']); } if (isset($args[1]['u']) && $args[1]['u'] != '') { $this->generateU($args[1]['u']); } if (isset($args[1]['sz']) && $args[1]['sz'] != '') { $this->generateSZ($args[1]['sz']); } if (isset($args[1]['color']) && $args[1]['color'] != '') { $this->generateCOLOR($args[1]['color']); } } $this->generateT($args[0], $args[1]['spaces']); } } /** * Create title * * @access protected * @param string $arrArgs[0] * @param array $arrArgs[1] */ public function createTitle() { $this->_xml = ''; $args = func_get_args(); if (!empty($args[1]['val']) && !empty($args[0])) { $this->generateP(); $this->generatePPR(); if ($args[1]['type'] == 'subtitle') $this->generatePSTYLE('Subttulo' . $args[1]['val']); else $this->generatePSTYLE('Ttulo' . $args[1]['val']); if (!empty($args[1]['pageBreakBefore'])) $this->generatePAGEBREAKBEFORE($args[1]['pageBreakBefore']); if (!empty($args[1]['widowControl'])) $this->generateWIDOWCONTROL($args[1]['widowControl']); if (!empty($args[1]['wordWrap'])) $this->generateWORDWRAP($args[1]['wordWrap']); self::$_idTitle++; $this->generateBOOKMARKSTART( self::$_idTitle, '_Toc' . (self::$_idTitle + self::IDTITLE) ); $this->generateR(); if ( $args[1]['b'] != '' || $args[1]['i'] != '' || $args[1]['u'] != '' || $args[1]['sz'] != '' || $args[1]['color'] != '' || $args[1]['font'] != '' ) { $this->generateRPR(); if ($args[1]['font'] != '') { $this->generateRFONTS($args[1]['font']); } if ($args[1]['b'] != '') { $this->generateB($args[1]['b']); } if ($args[1]['i'] != '') { $this->generateI($args[1]['i']); } if ($args[1]['u'] != '') { $this->generateU($args[1]['u']); } if ($args[1]['sz'] != '') { $this->generateSZ($args[1]['sz']); } if ($args[1]['color'] != '') { $this->generateCOLOR($args[1]['color']); } } $this->generateT($args[0]); $this->generateBOOKMARKEND(self::$_idTitle); $this->cleanTemplate(); } } /** * Generate w:b * * @access protected * @param string $val */ protected function generateB($strVal = 'single') { $element = '<' . CreateElement::NAMESPACEWORD . ':b ' . CreateElement::NAMESPACEWORD . ':val="' . $strVal . '">__GENERATERPR__'; $this->_xml = str_replace('__GENERATERPR__', $element, $this->_xml); } /** * Generate w:color * * @access protected * @param string $val */ protected function generateCOLOR($val = '000000') { $this->_xml = str_replace( '__GENERATERPR__', '<' . CreateElement::NAMESPACEWORD . ':color ' . CreateElement::NAMESPACEWORD . ':val="' . $val . '">__GENERATERPR__', $this->_xml ); } /** * Generate w:jc * * @access protected * @param string $val */ protected function generateJC($val = '') { $this->_xml = str_replace( '__GENERATEPPR__', '<' . CreateElement::NAMESPACEWORD . ':jc ' . CreateElement::NAMESPACEWORD . ':val="' . $val . '">__GENERATESZ__', $this->_xml ); } /** * Generate w:i * * @access protected * @param string $val */ protected function generateI($val = 'single') { $this->_xml = str_replace( '__GENERATERPR__', '<' . CreateElement::NAMESPACEWORD . ':i ' . CreateElement::NAMESPACEWORD . ':val="' . $val . '">__GENERATERPR__', $this->_xml ); } /** * Generate w:sz * * @access protected * @param string $val */ protected function generateSZ($val = '11') { $val *= 2; $this->_xml = str_replace( '__GENERATERPR__', '<' . CreateElement::NAMESPACEWORD . ':sz ' . CreateElement::NAMESPACEWORD . ':val="' . $val . '">__GENERATERPR__', $this->_xml ); } /** * Generate w:u * * @access protected * @param string $val */ protected function generateU($val = 'single') { $this->_xml = str_replace( '__GENERATERPR__', '<' . CreateElement::NAMESPACEWORD . ':u ' . CreateElement::NAMESPACEWORD . ':val="' . $val . '">__GENERATERPR__', $this->_xml ); } /** * Generate w:pstyle * * @access protected * @param string $val */ protected function generatePSTYLE($val = 'Ttulo') { $this->_xml = str_replace( '__GENERATEPPR__', '<' . CreateElement::NAMESPACEWORD . ':pStyle ' . CreateElement::NAMESPACEWORD . ':val="' . $val . '">__GENERATEPPR__', $this->_xml ); } /** * Generate w:pagebreakbefore * * @access protected * @param string $val */ protected function generatePAGEBREAKBEFORE($val = 'on') { $this->_xml = str_replace( '__GENERATEPPR__', '<' . CreateElement::NAMESPACEWORD . ':pageBreakBefore val="' . $val . '">__GENERATEPPR__', $this->_xml ); } /** * Generate w:widowcontrol * * @access protected * @param string $val */ protected function generateWIDOWCONTROL($val = 'on') { $this->_xml = str_replace( '__GENERATEPPR__', '<' . CreateElement::NAMESPACEWORD . ':widowControl val="' . $val . '">__GENERATEPPR__', $this->_xml ); } /** * Generate w:wordwrap * * @access protected * @param string $val */ protected function generateWORDWRAP($val = 'on') { $this->_xml = str_replace( '__GENERATEPPR__', '<' . CreateElement::NAMESPACEWORD . ':wordWrap val="' . $val . '">__GENERATEPPR__', $this->_xml ); } /** * Generate w:bookmarkstart * * @access protected * @param int $id * @param string $name */ protected function generateBOOKMARKSTART($id, $name) { $this->_xml = str_replace( '__GENERATER__', '<' . CreateElement::NAMESPACEWORD . ':bookmarkStart ' . CreateElement::NAMESPACEWORD . ':id="' . $id . '" ' . CreateElement::NAMESPACEWORD . ':name="' . $name . '">__GENERATER____GENERATEBOOKMARKEND__', $this->_xml ); } /** * Generate w:bookmarkend * * @access protected * @param int $id */ protected function generateBOOKMARKEND($id) { $this->_xml = str_replace( '__GENERATEBOOKMARKEND__', '<' . CreateElement::NAMESPACEWORD . ':bookmarkEnd ' . CreateElement::NAMESPACEWORD . ':id="' . $id . '">', $this->_xml ); } }