protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) { $rID = $link->getRelationId(); $linkName = $link->getLinkName(); if (is_null($linkName)) { $linkName = $link->getLinkSrc(); } $styleFont = $link->getFontStyle(); $SfIsObject = $styleFont instanceof PHPWord_Style_Font ? true : false; if (!$withoutP) { $objWriter->startElement('w:p'); $styleParagraph = $link->getParagraphStyle(); $SpIsObject = $styleParagraph instanceof PHPWord_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->writeRaw($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 * @param mixed $styleParagraph * @return PHPWord_Section_Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) { $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); $rID = PHPWord_Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; return $link; }
/** * 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) { $linkSrc = utf8_encode($linkSrc); if (!is_null($linkName)) { $linkName = utf8_encode($linkName); } $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont); $rID = PHPWord_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) { if ($this->_insideOf == 'section') { $linkSrc = utf8_encode($linkSrc); if (!is_null($linkName)) { $linkName = utf8_encode($linkName); } $link = new PHPWord_Section_Link($linkSrc, $linkName, $style); $rID = PHPWord_Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; return $link; } else { trigger_error('Unsupported Link header / footer reference'); return false; } }
/** * 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) { $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont); $rID = PHPWord_Footnote::addFootnoteLinkElement($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) { if (!PHPWord_Shared_String::IsUTF8($linkSrc)) { $linkSrc = utf8_encode($linkSrc); } if (!is_null($linkName)) { if (!PHPWord_Shared_String::IsUTF8($linkName)) { $linkName = utf8_encode($linkName); } } $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); $rID = PHPWord_Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; return $link; }