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 / Calculation / LookupRef / Hyperlink.php

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

53 lines 1.6 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\Calculation\LookupRef;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Functions;
6 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
7 use TablePress\PhpOffice\PhpSpreadsheet\Cell\Cell;
8 use TablePress\PhpOffice\PhpSpreadsheet\Shared\StringHelper;
9
10 class Hyperlink
11 {
12 /**
13 * HYPERLINK.
14 *
15 * Excel Function:
16 * =HYPERLINK(linkURL, [displayName])
17 *
18 * @param mixed $linkURL Expect string. Value to check, is also the value returned when no error
19 * @param mixed $displayName Expect string. Value to return when testValue is an error condition
20 * @param ?Cell $cell The cell to set the hyperlink in
21 *
22 * @return string The value of $displayName (or $linkURL if $displayName was blank)
23 */
24 public static function set($linkURL = '', $displayName = null, ?Cell $cell = null): string
25 {
26 $worksheet = null;
27 $coordinate = '';
28 if ($cell !== null) {
29 $coordinate = $cell->getCoordinate();
30 $worksheet = $cell->getWorksheetOrNull();
31 }
32
33 $linkURL = ($linkURL === null) ? '' : StringHelper::convertToString(Functions::flattenSingleValue($linkURL));
34 $displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName);
35
36 if ((!is_object($cell)) || (trim($linkURL) == '')) {
37 return ExcelError::REF();
38 }
39
40 $displayName = StringHelper::convertToString($displayName, false);
41 if (trim($displayName) === '') {
42 $displayName = $linkURL;
43 }
44
45 (($nullsafeVariable1 = $worksheet) ? $nullsafeVariable1->getCell($coordinate)->getHyperlink() : null)
46 ->setUrl($linkURL)
47 ->setTooltip($displayName)
48 ->setDisplay('');
49
50 return $displayName;
51 }
52 }
53