Hyperlink.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * PHPExcel_Cell_Hyperlink
  4. *
  5. * Copyright (c) 2006 - 2015 PHPExcel
  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 PHPExcel
  22. * @package PHPExcel_Cell
  23. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. class PHPExcel_Cell_Hyperlink
  28. {
  29. /**
  30. * URL to link the cell to
  31. *
  32. * @var string
  33. */
  34. private $url;
  35. /**
  36. * Tooltip to display on the hyperlink
  37. *
  38. * @var string
  39. */
  40. private $tooltip;
  41. /**
  42. * Create a new PHPExcel_Cell_Hyperlink
  43. *
  44. * @param string $pUrl Url to link the cell to
  45. * @param string $pTooltip Tooltip to display on the hyperlink
  46. */
  47. public function __construct($pUrl = '', $pTooltip = '')
  48. {
  49. // Initialise member variables
  50. $this->url = $pUrl;
  51. $this->tooltip = $pTooltip;
  52. }
  53. /**
  54. * Get URL
  55. *
  56. * @return string
  57. */
  58. public function getUrl()
  59. {
  60. return $this->url;
  61. }
  62. /**
  63. * Set URL
  64. *
  65. * @param string $value
  66. * @return PHPExcel_Cell_Hyperlink
  67. */
  68. public function setUrl($value = '')
  69. {
  70. $this->url = $value;
  71. return $this;
  72. }
  73. /**
  74. * Get tooltip
  75. *
  76. * @return string
  77. */
  78. public function getTooltip()
  79. {
  80. return $this->tooltip;
  81. }
  82. /**
  83. * Set tooltip
  84. *
  85. * @param string $value
  86. * @return PHPExcel_Cell_Hyperlink
  87. */
  88. public function setTooltip($value = '')
  89. {
  90. $this->tooltip = $value;
  91. return $this;
  92. }
  93. /**
  94. * Is this hyperlink internal? (to another worksheet)
  95. *
  96. * @return boolean
  97. */
  98. public function isInternal()
  99. {
  100. return strpos($this->url, 'sheet://') !== false;
  101. }
  102. /**
  103. * Get hash code
  104. *
  105. * @return string Hash code
  106. */
  107. public function getHashCode()
  108. {
  109. return md5(
  110. $this->url .
  111. $this->tooltip .
  112. __CLASS__
  113. );
  114. }
  115. }