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