|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Mylinks\Providers; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* You may not change or alter any portion of this comment or credits |
|
7
|
|
|
* of supporting developers from this source code or any supporting source code |
|
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
* This program is distributed in the hope that it will be useful, |
|
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
12
|
|
|
* |
|
13
|
|
|
* to use the provider: |
|
14
|
|
|
* $shot = new MylinksThumbshots(); |
|
15
|
|
|
* $shot->setProviderPrivateKey(my_key); |
|
16
|
|
|
* $shot->setShotSize(array('width'=>120)); |
|
17
|
|
|
* $shot->setSiteUrl("http://site_to_capture"); |
|
18
|
|
|
* $mylinks_shotprovider = $shot->getProviderUrl(); |
|
19
|
|
|
* |
|
20
|
|
|
* Then in the template use something like: |
|
21
|
|
|
* <img src='<{$mylinks_shotprovider}>' target='_blank' alt='' style='margin: 3px 7px;'> |
|
22
|
|
|
* and at the bottom of the page show the attribution |
|
23
|
|
|
* echo $shot->getAttribution(); |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* MyLinks category.php |
|
28
|
|
|
* |
|
29
|
|
|
* Xoops mylinks - a multicategory links module |
|
30
|
|
|
* |
|
31
|
|
|
* @copyright :: {@link http://www.zyspec.com ZySpec Incorporated} |
|
32
|
|
|
* @license :: {@link https://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
|
33
|
|
|
* @package :: mylinks |
|
34
|
|
|
* @subpackage:: class |
|
35
|
|
|
* @since :: 3.11 |
|
36
|
|
|
* @author :: zyspec <[email protected]> |
|
37
|
|
|
*/ |
|
38
|
|
|
|
|
39
|
|
|
use XoopsModules\Mylinks; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Class MylinksHeartrails |
|
43
|
|
|
*/ |
|
44
|
|
|
class Heartrails implements Mylinks\ThumbPlugin |
|
45
|
|
|
{ |
|
46
|
|
|
private $image_width = 0; |
|
47
|
|
|
private $image_height = 0; |
|
48
|
|
|
protected $image_ratio = 1.33; // (4:3) |
|
49
|
|
|
private $site_url = null; |
|
50
|
|
|
private $key = null; |
|
|
|
|
|
|
51
|
|
|
private $attribution = ''; |
|
52
|
|
|
private $provider_url = 'http://capture.heartrails.com'; |
|
53
|
|
|
private $provider_name = 'Heartrails'; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* MylinksHeartrails constructor. |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __construct() |
|
59
|
|
|
{ |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getProviderUrl() |
|
66
|
|
|
{ |
|
67
|
|
|
$query = '/' . $this->image_width . 'x' . $this->image_height . '/cool?' . $this->getSiteUrl(); |
|
68
|
|
|
$providerUrl = $this->provider_url . $query; |
|
69
|
|
|
|
|
70
|
|
|
return $providerUrl; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getProviderName() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->provider_name; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param $sz |
|
83
|
|
|
* @return mixed|void |
|
84
|
|
|
*/ |
|
85
|
|
|
public function setShotSize($sz) |
|
86
|
|
|
{ |
|
87
|
|
|
if (isset($sz)) { |
|
88
|
|
|
if (is_array($sz)) { |
|
89
|
|
|
if (array_key_exists('width', $sz)) { |
|
90
|
|
|
$this->image_width = (int)$sz['width']; |
|
91
|
|
|
if (array_key_exists('height', $sz)) { |
|
92
|
|
|
$this->image_height = (int)$sz['height']; |
|
93
|
|
|
} else { |
|
94
|
|
|
$this->image_height = (int)($this->image_width / $this->image_ratio); |
|
95
|
|
|
} |
|
96
|
|
|
} else { |
|
97
|
|
|
$this->image_width = (int)$sz; |
|
98
|
|
|
$this->image_height = (int)($sz / $this->image_ratio); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @return array |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getShotSize() |
|
108
|
|
|
{ |
|
109
|
|
|
return ['width' => $this->image_width, 'height' => $this->image_height]; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @param $url |
|
114
|
|
|
* @return mixed|void |
|
115
|
|
|
*/ |
|
116
|
|
|
public function setSiteUrl($url) |
|
117
|
|
|
{ |
|
118
|
|
|
//@todo: sanitize url; |
|
119
|
|
|
$this->site_url = formatURL($url); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return string |
|
124
|
|
|
*/ |
|
125
|
|
|
public function getSiteUrl() |
|
126
|
|
|
{ |
|
127
|
|
|
return urlencode($this->site_url); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param null $attr |
|
|
|
|
|
|
132
|
|
|
*/ |
|
133
|
|
|
public function setAttribution($attr = null) |
|
134
|
|
|
{ |
|
135
|
|
|
$this->attribution = $attr; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @param int $allowhtml |
|
140
|
|
|
* @return string |
|
141
|
|
|
*/ |
|
142
|
|
|
public function getAttribution($allowhtml = 0) |
|
143
|
|
|
{ |
|
144
|
|
|
if ($allowhtml) { |
|
145
|
|
|
return $this->attribution; |
|
146
|
|
|
} |
|
147
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
148
|
|
|
|
|
149
|
|
|
return $myts->htmlSpecialChars($this->attribution); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* @param $key |
|
154
|
|
|
* @return bool |
|
155
|
|
|
*/ |
|
156
|
|
|
public function setProviderPublicKey($key) |
|
157
|
|
|
{ |
|
158
|
|
|
return false; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @return bool |
|
163
|
|
|
*/ |
|
164
|
|
|
public function getProviderPublicKey() |
|
165
|
|
|
{ |
|
166
|
|
|
return false; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @param $key |
|
171
|
|
|
* @return bool |
|
172
|
|
|
*/ |
|
173
|
|
|
public function setProviderPrivateKey($key) |
|
174
|
|
|
{ |
|
175
|
|
|
return false; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @return bool |
|
180
|
|
|
*/ |
|
181
|
|
|
public function getProviderPrivateKey() |
|
182
|
|
|
{ |
|
183
|
|
|
return false; |
|
184
|
|
|
} |
|
185
|
|
|
} |
|
186
|
|
|
|