Update t() calls
[friendica-addons.git] / notimeline / notimeline.php
1 <?php
2 /**
3  * Name: Notimeline
4  * Description: Disable "Archives" widget on profile page
5  * Version: 1.0
6  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
7  *
8  */
9 use Friendica\Core\Addon;
10 use Friendica\Core\L10n;
11 use Friendica\Core\PConfig;
12
13 function notimeline_install()
14 {
15         Addon::registerHook('addon_settings', 'addon/notimeline/notimeline.php', 'notimeline_settings');
16         Addon::registerHook('addon_settings_post', 'addon/notimeline/notimeline.php', 'notimeline_settings_post');
17 }
18
19 function notimeline_uninstall()
20 {
21         Addon::unregisterHook('addon_settings', 'addon/notimeline/notimeline.php', 'notimeline_settings');
22         Addon::unregisterHook('addon_settings_post', 'addon/notimeline/notimeline.php', 'notimeline_settings_post');
23 }
24
25 function notimeline_settings_post($a, $post)
26 {
27         if (!local_user() || (!x($_POST, 'notimeline-submit'))) {
28                 return;
29         }
30
31         PConfig::set(local_user(), 'system', 'no_wall_archive_widget', intval($_POST['notimeline']));
32         info(L10n::t('No Timeline settings updated.') . EOL);
33 }
34
35 function notimeline_settings(&$a, &$s)
36 {
37         if (! local_user()) {
38                 return;
39         }
40
41         /* Add our stylesheet to the page so we can make our settings look nice */
42
43         $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/notimeline/notimeline.css' . '" media="all" />' . "\r\n";
44
45         /* Get the current state of our config variable */
46
47         $notimeline = PConfig::get(local_user(), 'system', 'no_wall_archive_widget', false);
48
49         $notimeline_checked = (($notimeline) ? ' checked="checked" ' : '');
50
51         
52         /* Add some HTML to the existing form */
53
54         $s .= '<div class="settings-block">';
55         $s .= '<h3>' . L10n::t('No Timeline Settings') . '</h3>';
56         $s .= '<div id="notimeline-wrapper">';
57         $s .= '<label id="notimeline-label" for="notimeline-checkbox">' . L10n::t('Disable Archive selector on profile wall') . '</label>';
58         $s .= '<input id="notimeline-checkbox" type="checkbox" name="notimeline" value="1" ' . $notimeline_checked . '/>';
59         $s .= '</div><div class="clear"></div>';
60
61         /* provide a submit button */
62
63         $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="notimeline-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
64 }