@@ 161-173 (lines=13) @@ | ||
158 | * |
|
159 | * @return string with modified text. |
|
160 | */ |
|
161 | public function addBaseurlToRelativeLinks($text, $baseurl, $callback) |
|
162 | { |
|
163 | $pattern = "#<a(.+?)href=\"([^\"]*)\"([.^>]*)>#"; |
|
164 | ||
165 | return preg_replace_callback( |
|
166 | $pattern, |
|
167 | function ($matches) use ($baseurl, $callback) { |
|
168 | $url = $callback($matches[2], $baseurl); |
|
169 | return "<a${matches[1]}href=\"$url\"${matches[3]}>"; |
|
170 | }, |
|
171 | $text |
|
172 | ); |
|
173 | } |
|
174 | ||
175 | ||
176 | ||
@@ 186-198 (lines=13) @@ | ||
183 | * |
|
184 | * @return string with modified text. |
|
185 | */ |
|
186 | public function addBaseurlToImageSource($text, $baseurl, $callback) |
|
187 | { |
|
188 | $pattern = "#<img(.+?)src=\"([^\"]*)\"(.*?)>#"; |
|
189 | ||
190 | return preg_replace_callback( |
|
191 | $pattern, |
|
192 | function ($matches) use ($baseurl, $callback) { |
|
193 | $url = $callback($matches[2], $baseurl); |
|
194 | return "<img${matches[1]}src=\"$url\"${matches[3]}>"; |
|
195 | }, |
|
196 | $text |
|
197 | ); |
|
198 | } |
|
199 | ||
200 | ||
201 |