-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTextLink.php
More file actions
71 lines (63 loc) · 1.99 KB
/
Copy pathTextLink.php
File metadata and controls
71 lines (63 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace ModStart\Widget;
use ModStart\ModStart;
/**
* Class Label
* @package ModStart\Widget
*
* @method static string primary($text, $link, $attributes = '')
* @method static string muted($text, $link, $attributes = '')
* @method static string warning($text, $link, $attributes = '')
* @method static string danger($text, $link, $attributes = '')
* @method static string success($text, $link, $attributes = '')
*
* @method void text($text)
* @method void type($type)
* @method void link($type)
* @method void attr($type)
* @method void disabled($boolean)
*/
class TextLink extends AbstractWidget
{
public static function getAssets()
{
return [
'style' => '.ub-text-link{display:inline-block;margin-right:0.625rem;}',
];
}
/**
* @param $type string
* @param $text string
* @param $text url
* @return TextDialogRequest
*/
public static function make(...$arguments)
{
$ins = new static();
$ins->type($arguments[0]);
$ins->text($arguments[1]);
$ins->link($arguments[2]);
return $ins;
}
public static function __callStatic($name, $arguments)
{
$methods = ['primary', 'muted', 'warning', 'danger', 'success',];
if (in_array($name, $methods)) {
$ins = new static();
$ins->type($name);
$ins->text($arguments[0]);
$ins->link($arguments[1]);
$ins->attr(empty($arguments[2]) ? '' : $arguments[2]);
return $ins->render();
}
throw new \Exception('TextLink error ' . join(',', $methods) . ' ');
}
public function render()
{
if ($this->disabled) {
return '<a href="javascript:;" class="ub-text-link ub-text-muted">' . $this->text . '</a>';
} else {
return '<a href="' . $this->link . '" class="ub-text-link ub-text-' . ($this->type == 'primary' ? 'link' : $this->type) . '" ' . $this->attr . '>' . $this->text . '</a>';
}
}
}