]> git.mxchange.org Git - friendica-addons.git/blob - editplain/editplain.php
3aa2149153be6ed1151a1fa9f510ab61cc1b3a59
[friendica-addons.git] / editplain / editplain.php
1 <?php
2 /**
3  * Name: Editplain
4  * Description: This addon is deprecated and has been replaced with the "Advanced Features" setting.  Admins should remove this addon when their core code is updated to include advanced feature settings.
5  * Version: 1.0
6  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
7  * Status: Unsupported
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('plugin_settings', 'addon/editplain/editplain.php', 'editplain_settings');
24         unregister_hook('plugin_settings_post', 'addon/editplain/editplain.php', 'editplain_settings_post');
25
26
27         logger("removed editplain");
28 }
29
30
31
32 /**
33  *
34  * Callback from the settings post function.
35  * $post contains the $_POST array.
36  * We will make sure we've got a valid user account
37  * and if so set our configuration setting for this person.
38  *
39  */
40
41 function editplain_settings_post($a,$post) {
42         if(! local_user() || (! x($_POST,'editplain-submit')))
43                 return;
44         set_pconfig(local_user(),'system','plaintext',intval($_POST['editplain']));
45
46         info( t('Editplain settings updated.') . EOL);
47 }
48
49
50 /**
51  *
52  * Called from the Plugin Setting form. 
53  * Add our own settings info to the page.
54  *
55  */
56
57
58
59 function editplain_settings(&$a,&$s) {
60
61         if(! local_user())
62                 return;
63
64         /* Add our stylesheet to the page so we can make our settings look nice */
65
66         $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/editplain/editplain.css' . '" media="all" />' . "\r\n";
67
68         /* Get the current state of our config variable */
69
70         $enabled = get_pconfig(local_user(),'system','plaintext');
71         $checked = (($enabled) ? ' checked="checked" ' : '');
72
73         /* Add some HTML to the existing form */
74
75         $s .= '<div class="settings-block">';
76         $s .= '<h3>' . t('Editplain Settings') . '</h3>';
77         $s .= '<div id="editplain-enable-wrapper">';
78         $s .= '<label id="editplain-enable-label" for="editplain-checkbox">' . t('Disable richtext status editor') . '</label>';
79         $s .= '<input id="editplain-checkbox" type="checkbox" name="editplain" value="1" ' . $checked . '/>';
80         $s .= '</div><div class="clear"></div>';
81
82         /* provide a submit button */
83
84         $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="editplain-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
85
86 }