Skip to content

Commit d377444

Browse files
feat: added possibility to remove bookmarks (#2644)
* feat: added trash-icon for bookmarks * feat: added delete-bookmark request * fix: added class * fix: line length (PHPCS)
1 parent bb0ec6b commit d377444

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

phpmyfaq/api.service.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
const IS_VALID_PHPMYFAQ = null;
1919

20+
use phpMyFAQ\Bookmark;
2021
use phpMyFAQ\Captcha\Captcha;
2122
use phpMyFAQ\Category;
2223
use phpMyFAQ\Comments;
@@ -1005,6 +1006,12 @@
10051006
$response->setData(['error' => Translation::get('err_sendMail')]);
10061007
}
10071008
break;
1009+
1010+
case 'delete-bookmark':
1011+
$id = Filter::filterVar($postData['faqId'], FILTER_VALIDATE_INT);
1012+
$bookmark = new Bookmark($faqConfig, $user);
1013+
$status = $bookmark->remove($id);
1014+
$response->setData(['success' => $status]);
10081015
}
10091016

10101017
$response->send();

phpmyfaq/src/phpMyFAQ/Bookmark.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,15 @@ public function buildBookmarkList(): string
154154
$html .= sprintf(
155155
'<li class="list-group-item d-flex justify-content-between align-items-start">'
156156
. '<div class="ms-2 me-auto">'
157-
. '<div class="fw-bold">%s</div>'
157+
. '<div class="fw-bold"><span onclick="handleDeleteBookmark(%d)">'
158+
. '<i class="fa fa-trash me-5"></i></span>%s</div>'
158159
. '<div class="small">%s</div>'
159160
. '</div>'
160161
. '<span id="viewsPerRecord" class="badge bg-primary rounded-pill">%s</span>'
161162
. '</li>',
163+
$faqData['id'],
162164
$link->toHtmlAnchor(),
163-
strip_tags($faqData['content']),
165+
htmlspecialchars_decode($faqData['content']),
164166
$plurals->getMsg('plmsgViews', $visitsFaq)
165167
);
166168
}

0 commit comments

Comments
 (0)