4 * Description: Two click comments
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
8 * Provides a set of text "snippets" which can be inserted into a comment window by clicking on them.
9 * First enable the addon in the system admin panel.
10 * Then each person can tailor their choice of words in Settings->Addon Settings in the Qcomment
11 * pane. Initially no qcomments are provided, but on viewing the settings page, a default set of
12 * of words is suggested. These can be accepted (click Submit) or edited first. Each text line represents
13 * a different qcomment.
14 * Many themes will hide the qcomments above or immediately adjacent to the comment input box until
15 * you wish to use them. On some themes they may be visible.
16 * Wave the mouse around near the comment input box and the qcomments will show up. Click on any of
17 * them to open the comment window fully and insert the qcomment. Then "Submit" will submit it.
22 use Friendica\Core\Hook;
23 use Friendica\Core\Renderer;
25 use Friendica\Util\XML;
27 function qcomment_install()
29 Hook::register('addon_settings' , __FILE__, 'qcomment_addon_settings');
30 Hook::register('addon_settings_post', __FILE__, 'qcomment_addon_settings_post');
31 Hook::register('footer' , __FILE__, 'qcomment_footer');
34 function qcomment_footer(App $a, string &$body)
36 DI::page()->registerFooterScript('addon/qcomment/qcomment.js');
39 function qcomment_addon_settings(App &$a, array &$data)
41 if (!DI::userSession()->getLocalUserId()) {
45 $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words', DI::l10n()->t(':-)') . "\n" . DI::l10n()->t(':-(') . "\n" . DI::l10n()->t('lol'));
47 $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/qcomment/');
48 $html = Renderer::replaceMacros($t, [
49 '$description' => DI::l10n()->t('Quick comments are found near comment boxes, sometimes hidden. Click them to provide simple replies.'),
50 '$words' => ['qcomment-words', DI::l10n()->t('Enter quick comments, one per line'), $words, null, ' rows="10"'],
54 'addon' => 'qcomment',
55 'title' => DI::l10n()->t('Quick Comment Settings'),
60 function qcomment_addon_settings_post(App $a, array &$b)
62 if (!DI::userSession()->getLocalUserId()) {
66 if (isset($_POST['qcomment-words'])) {
67 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'qcomment', 'words', XML::escape($_POST['qcomment-words']));