aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/bookmark/LinkUtils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2019-05-25 15:46:47 +0200
committerArthurHoaro <arthur@hoa.ro>2020-01-17 18:42:11 +0100
commit336a28fa4a09b968ce4705900bf57693e672f0bf (patch)
treeb3773e674a59c441270a56441fbadfa619527940 /application/bookmark/LinkUtils.php
parent796c4c57d085ae4589b53dfe8369ae9ba30ffdaf (diff)
downloadShaarli-336a28fa4a09b968ce4705900bf57693e672f0bf.tar.gz
Shaarli-336a28fa4a09b968ce4705900bf57693e672f0bf.tar.zst
Shaarli-336a28fa4a09b968ce4705900bf57693e672f0bf.zip
Introduce Bookmark object and Service layer to retrieve them
See https://github.com/shaarli/Shaarli/issues/1307 for details
Diffstat (limited to 'application/bookmark/LinkUtils.php')
-rw-r--r--application/bookmark/LinkUtils.php27
1 files changed, 4 insertions, 23 deletions
diff --git a/application/bookmark/LinkUtils.php b/application/bookmark/LinkUtils.php
index 77eb2d95..88379430 100644
--- a/application/bookmark/LinkUtils.php
+++ b/application/bookmark/LinkUtils.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3use Shaarli\Bookmark\LinkDB; 3use Shaarli\Bookmark\Bookmark;
4 4
5/** 5/**
6 * Get cURL callback function for CURLOPT_WRITEFUNCTION 6 * Get cURL callback function for CURLOPT_WRITEFUNCTION
@@ -188,30 +188,11 @@ function html_extract_tag($tag, $html)
188} 188}
189 189
190/** 190/**
191 * Count private links in given linklist. 191 * In a string, converts URLs to clickable bookmarks.
192 *
193 * @param array|Countable $links Linklist.
194 *
195 * @return int Number of private links.
196 */
197function count_private($links)
198{
199 $cpt = 0;
200 foreach ($links as $link) {
201 if ($link['private']) {
202 $cpt += 1;
203 }
204 }
205
206 return $cpt;
207}
208
209/**
210 * In a string, converts URLs to clickable links.
211 * 192 *
212 * @param string $text input string. 193 * @param string $text input string.
213 * 194 *
214 * @return string returns $text with all links converted to HTML links. 195 * @return string returns $text with all bookmarks converted to HTML bookmarks.
215 * 196 *
216 * @see Function inspired from http://www.php.net/manual/en/function.preg-replace.php#85722 197 * @see Function inspired from http://www.php.net/manual/en/function.preg-replace.php#85722
217 */ 198 */
@@ -279,7 +260,7 @@ function format_description($description, $indexUrl = '')
279 */ 260 */
280function link_small_hash($date, $id) 261function link_small_hash($date, $id)
281{ 262{
282 return smallHash($date->format(LinkDB::LINK_DATE_FORMAT) . $id); 263 return smallHash($date->format(Bookmark::LINK_DATE_FORMAT) . $id);
283} 264}
284 265
285/** 266/**