protected function _writeLink(Document_Word_Writer_Shared_XMLWriter $objWriter = null, Document_Word_Writer_Section_Link $link, $withoutP = false) { $rID = $link->getRelationId(); $linkName = $link->getLinkName(); if (is_null($linkName)) { $linkName = $link->getLinkSrc(); } $styleFont = $link->getFontStyle(); $SfIsObject = $styleFont instanceof Document_Word_Writer_Style_Font ? true : false; if (!$withoutP) { $objWriter->startElement('w:p'); $styleParagraph = $link->getParagraphStyle(); $SpIsObject = $styleParagraph instanceof Document_Word_Writer_Style_Paragraph ? true : false; if ($SpIsObject) { $this->_writeParagraphStyle($objWriter, $styleParagraph); } elseif (!$SpIsObject && !is_null($styleParagraph)) { $objWriter->startElement('w:pPr'); $objWriter->startElement('w:pStyle'); $objWriter->writeAttribute('w:val', $styleParagraph); $objWriter->endElement(); $objWriter->endElement(); } } $objWriter->startElement('w:hyperlink'); $objWriter->writeAttribute('r:id', 'rId' . $rID); $objWriter->writeAttribute('w:history', '1'); $objWriter->startElement('w:r'); if ($SfIsObject) { $this->_writeTextStyle($objWriter, $styleFont); } elseif (!$SfIsObject && !is_null($styleFont)) { $objWriter->startElement('w:rPr'); $objWriter->startElement('w:rStyle'); $objWriter->writeAttribute('w:val', $styleFont); $objWriter->endElement(); $objWriter->endElement(); } $objWriter->startElement('w:t'); $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text $objWriter->text($linkName); $objWriter->endElement(); $objWriter->endElement(); $objWriter->endElement(); if (!$withoutP) { $objWriter->endElement(); // w:p } }
/** * Add a Link Element * * @param string $linkSrc * @param string $linkName * @param mixed $styleFont * @return PHPWord_Section_Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null) { require_once __DIR__ . '/Link.php'; require_once __DIR__ . '/../Media.php'; // $text = @iconv("UTF-8", "UTF-8//IGNORE", $text); // $linkSrc = utf8_encode($linkSrc); if (!is_null($linkName)) { $linkName = @iconv("UTF-8", "UTF-8//IGNORE", $linkName); // $linkName = utf8_encode($linkName); } $link = new Document_Word_Writer_Section_Link($linkSrc, $linkName, $styleFont); $rID = Document_Word_Writer_Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; return $link; }
/** * Add a Link Element * * @param string $linkSrc * @param string $linkName * @param mixed $styleFont * @param mixed $styleParagraph * @return PHPWord_Section_Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) { require_once __DIR__ . '/Media.php'; require_once __DIR__ . '/Section/Link.php'; $linkSrc = utf8_encode($linkSrc); if (!is_null($linkName)) { $linkName = utf8_encode($linkName); } $link = new Document_Word_Writer_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); $rID = Document_Word_Writer_Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; return $link; }
/** * Add a Link Element * * @param string $linkSrc * @param string $linkName * @param mixed $style * @return PHPWord_Section_Link */ public function addLink($linkSrc, $linkName = null, $style = null) { require_once __DIR__ . '/../../Media.php'; require_once __DIR__ . '/../Link.php'; if ($this->_insideOf == 'section') { $linkSrc = utf8_encode($linkSrc); if (!is_null($linkName)) { $linkName = utf8_encode($linkName); } $link = new Document_Word_Writer_Section_Link($linkSrc, $linkName, $style); $rID = Document_Word_Writer_Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; return $link; } else { trigger_error('Unsupported Link header / footer reference'); return false; } }