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.
20 use Friendica\Core\Addon;
21 use Friendica\Core\L10n;
22 use Friendica\Core\PConfig;
24 function qcomment_install() {
25 Addon::registerHook('addon_settings', 'addon/qcomment/qcomment.php', 'qcomment_addon_settings');
26 Addon::registerHook('addon_settings_post', 'addon/qcomment/qcomment.php', 'qcomment_addon_settings_post');
30 function qcomment_uninstall() {
31 Addon::unregisterHook('addon_settings', 'addon/qcomment/qcomment.php', 'qcomment_addon_settings');
32 Addon::unregisterHook('addon_settings_post', 'addon/qcomment/qcomment.php', 'qcomment_addon_settings_post');
36 function qcomment_addon_settings(&$a, &$s)
42 /* Add our stylesheet to the page so we can make our settings look nice */
44 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/qcomment/qcomment.css' . '" media="all" />' . "\r\n";
46 $words = PConfig::get(local_user(), 'qcomment', 'words', L10n::t(':-)') . "\n" . L10n::t(':-(') . "\n" . L10n::t('lol'));
48 $s .= '<div class="settings-block">';
49 $s .= '<h3>' . L10n::t('Quick Comment Settings') . '</h3>';
50 $s .= '<div id="qcomment-wrapper">';
51 $s .= '<div id="qcomment-desc">' . L10n::t("Quick comments are found near comment boxes, sometimes hidden. Click them to provide simple replies.") . '</div>';
52 $s .= '<label id="qcomment-label" for="qcomment-words">' . L10n::t('Enter quick comments, one per line') . ' </label>';
53 $s .= '<textarea id="qcomment-words" type="text" name="qcomment-words" >' . htmlspecialchars(unxmlify($words)) . '</textarea>';
54 $s .= '</div><div class="clear"></div>';
56 $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="qcomment-submit" name="qcomment-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
62 function qcomment_addon_settings_post(&$a,&$b) {
67 if($_POST['qcomment-submit']) {
68 PConfig::set(local_user(),'qcomment','words',xmlify($_POST['qcomment-words']));
69 info(L10n::t('Quick Comment settings saved.') . EOL);