PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Cell / Hyperlink.php

Hyperlink.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Cell/Hyperlink.php

120 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Cell;
4
5 class Hyperlink
6 {
7 /**
8 * URL to link the cell to.
9 */
10 private string $url;
11
12 /**
13 * Tooltip to display on the hyperlink.
14 */
15 private string $tooltip;
16
17 private string $display = '';
18
19 /**
20 * Create a new Hyperlink.
21 *
22 * @param string $url Url to link the cell to
23 * @param string $tooltip Tooltip to display on the hyperlink
24 */
25 public function __construct(string $url = '', string $tooltip = '')
26 {
27 // Initialise member variables
28 $this->url = $url;
29 $this->tooltip = $tooltip;
30 }
31
32 /**
33 * Get URL.
34 */
35 public function getUrl(): string
36 {
37 return $this->url;
38 }
39
40 /**
41 * Set URL.
42 *
43 * @return $this
44 */
45 public function setUrl(string $url)
46 {
47 $this->url = $url;
48
49 return $this;
50 }
51
52 /**
53 * Get tooltip.
54 */
55 public function getTooltip(): string
56 {
57 return $this->tooltip;
58 }
59
60 /**
61 * Set tooltip.
62 *
63 * @return $this
64 */
65 public function setTooltip(string $tooltip)
66 {
67 $this->tooltip = $tooltip;
68
69 return $this;
70 }
71
72 /**
73 * Is this hyperlink internal? (to another worksheet or a cell in this worksheet).
74 */
75 public function isInternal(): bool
76 {
77 return str_starts_with($this->url, 'sheet://') || str_starts_with($this->url, '#');
78 }
79
80 public function getTypeHyperlink(): string
81 {
82 return $this->isInternal() ? '' : 'External';
83 }
84
85 public function getDisplay(): string
86 {
87 return $this->display;
88 }
89
90 /**
91 * This can be displayed in cell rather than actual cell contents.
92 * It seems to be ignored by Excel.
93 * It may be used by Google Sheets.
94 */
95 public function setDisplay(string $display): self
96 {
97 $this->display = $display;
98
99 return $this;
100 }
101
102 /**
103 * Get hash code.
104 *
105 * @return string Hash code
106 */
107 public function getHashCode(): string
108 {
109 return md5(
110 $this->url
111 . ','
112 . $this->tooltip
113 . ','
114 . $this->display
115 . ','
116 . __CLASS__
117 );
118 }
119 }
120