Link.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /**
  3. * PHPWord
  4. *
  5. * Copyright (c) 2011 PHPWord
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPWord
  22. * @package PHPWord
  23. * @copyright Copyright (c) 010 PHPWord
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version Beta 0.6.3, 08.07.2011
  26. */
  27. /**
  28. * PHPWord_Section_Link
  29. *
  30. * @category PHPWord
  31. * @package PHPWord_Section
  32. * @copyright Copyright (c) 2011 PHPWord
  33. */
  34. class PHPWord_Section_Link {
  35. /**
  36. * Link source
  37. *
  38. * @var string
  39. */
  40. private $_linkSrc;
  41. /**
  42. * Link name
  43. *
  44. * @var string
  45. */
  46. private $_linkName;
  47. /**
  48. * Link Relation ID
  49. *
  50. * @var string
  51. */
  52. private $_rId;
  53. /**
  54. * Link style
  55. *
  56. * @var PHPWord_Style_Font
  57. */
  58. private $_styleFont;
  59. /**
  60. * Paragraph style
  61. *
  62. * @var PHPWord_Style_Font
  63. */
  64. private $_styleParagraph;
  65. /**
  66. * Create a new Link Element
  67. *
  68. * @var string $linkSrc
  69. * @var string $linkName
  70. * @var mixed $styleFont
  71. * @var mixed $styleParagraph
  72. */
  73. public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) {
  74. $this->_linkSrc = $linkSrc;
  75. $this->_linkName = $linkName;
  76. // Set font style
  77. if(is_array($styleFont)) {
  78. $this->_styleFont = new PHPWord_Style_Font('text');
  79. foreach($styleFont as $key => $value) {
  80. if(substr($key, 0, 1) != '_') {
  81. $key = '_'.$key;
  82. }
  83. $this->_styleFont->setStyleValue($key, $value);
  84. }
  85. } else {
  86. $this->_styleFont = $styleFont;
  87. }
  88. // Set paragraph style
  89. if(is_array($styleParagraph)) {
  90. $this->_styleParagraph = new PHPWord_Style_Paragraph();
  91. foreach($styleParagraph as $key => $value) {
  92. if(substr($key, 0, 1) != '_') {
  93. $key = '_'.$key;
  94. }
  95. $this->_styleParagraph->setStyleValue($key, $value);
  96. }
  97. } else {
  98. $this->_styleParagraph = $styleParagraph;
  99. }
  100. return $this;
  101. }
  102. /**
  103. * Get Link Relation ID
  104. *
  105. * @return int
  106. */
  107. public function getRelationId() {
  108. return $this->_rId;
  109. }
  110. /**
  111. * Set Link Relation ID
  112. *
  113. * @param int $rId
  114. */
  115. public function setRelationId($rId) {
  116. $this->_rId = $rId;
  117. }
  118. /**
  119. * Get Link source
  120. *
  121. * @return string
  122. */
  123. public function getLinkSrc() {
  124. return $this->_linkSrc;
  125. }
  126. /**
  127. * Get Link name
  128. *
  129. * @return string
  130. */
  131. public function getLinkName() {
  132. return $this->_linkName;
  133. }
  134. /**
  135. * Get Text style
  136. *
  137. * @return PHPWord_Style_Font
  138. */
  139. public function getFontStyle() {
  140. return $this->_styleFont;
  141. }
  142. /**
  143. * Get Paragraph style
  144. *
  145. * @return PHPWord_Style_Paragraph
  146. */
  147. public function getParagraphStyle() {
  148. return $this->_styleParagraph;
  149. }
  150. }
  151. ?>