]> git.mxchange.org Git - friendica-addons.git/blob - editplain/editplain.php
Merge remote-tracking branch 'old/master' into mergeto
[friendica-addons.git] / editplain / editplain.php
1 <?php
2 /**
3  * Name: Editplain
4  * Description: Disable richtext (TinyMCE) editor for status posting
5  * Version: 1.0
6  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
7  * 
8  *
9  */
10
11
12 function editplain_install() {
13
14         register_hook('plugin_settings', 'addon/editplain/editplain.php', 'editplain_settings');
15         register_hook('plugin_settings_post', 'addon/editplain/editplain.php', 'editplain_settings_post');
16
17         logger("installed editplain");
18 }
19
20
21 function editplain_uninstall() {
22
23         unregister_hook('post_local',    'addon/editplain/editplain.php', 'editplain_post_hook');
24         unregister_hook('plugin_settings', 'addon/editplain/editplain.php', 'editplain_settings');
25         unregister_hook('plugin_settings_post', 'addon/editplain/editplain.php', 'editplain_settings_post');
26
27
28         logger("removed editplain");
29 }
30
31
32
33 /**
34  *
35  * Callback from the settings post function.
36  * $post contains the $_POST array.
37  * We will make sure we've got a valid user account
38  * and if so set our configuration setting for this person.
39  *
40  */
41
42 function editplain_settings_post($a,$post) {
43         if(! local_user() || (! x($_POST,'editplain-submit')))
44                 return;
45         set_pconfig(local_user(),'system','plaintext',intval($_POST['editplain']));
46
47         info( t('Editplain settings updated.') . EOL);
48 }
49
50
51 /**
52  *
53  * Called from the Plugin Setting form. 
54  * Add our own settings info to the page.
55  *
56  */
57
58
59
60 function editplain_settings(&$a,&$s) {
61
62         if(! local_user())
63                 return;
64
65         /* Add our stylesheet to the page so we can make our settings look nice */
66
67         $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/editplain/editplain.css' . '" media="all" />' . "\r\n";
68
69         /* Get the current state of our config variable */
70
71         $enabled = get_pconfig(local_user(),'system','plaintext');
72         $checked = (($enabled) ? ' checked="checked" ' : '');
73
74         /* Add some HTML to the existing form */
75
76         $s .= '<div class="settings-block">';
77         $s .= '<h3>' . t('Editplain Settings') . '</h3>';
78         $s .= '<div id="editplain-enable-wrapper">';
79         $s .= '<label id="editplain-enable-label" for="editplain-checkbox">' . t('Disable richtext status editor') . '</label>';
80         $s .= '<input id="editplain-checkbox" type="checkbox" name="editplain" value="1" ' . $checked . '/>';
81         $s .= '</div><div class="clear"></div>';
82
83         /* provide a submit button */
84
85         $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="editplain-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
86
87 }