6 * Description: Defines a YourLS url shortener for the Statusnet & Twitter plugins
8 * Author: Keith Fernie <http://friendika.me4.it/profile/keith>
12 function yourls_install() {
13 register_hook('plugin_settings', 'addon/yourls/yourls.php', 'yourls_addon_settings');
14 register_hook('plugin_settings_post', 'addon/yourls/yourls.php', 'yourls_addon_settings_post');
19 function yourls_uninstall() {
20 unregister_hook('plugin_settings', 'addon/yourls/yourls.php', 'yourls_addon_settings');
21 unregister_hook('plugin_settings_post', 'addon/yourls/yourls.php', 'yourls_addon_settings_post');
22 set_config('yourls','url1',trim($_POST['']));
23 set_config('yourls','username1',trim($_POST['']));
24 set_config('yourls','password1',trim($_POST['']));
25 set_config('yourls','ssl1',trim($_POST['']));
33 function yourls_addon_settings(&$a,&$s) {
39 /* Add our stylesheet to the page so we can make our settings look nice */
41 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/yourls/yourls.css' . '" media="all" />' . "\r\n";
44 $yourls_url = get_config('yourls','url1');
45 $yourls_username = get_config('yourls','username1');
46 $yourls_password = get_config('yourls', 'password1');
47 $ssl_enabled = get_config('yourls','ssl1');
48 $ssl_checked = (($ssl_enabled) ? ' checked="checked" ' : '');
52 $yourls_ssl = get_config('yourls', 'ssl1');
54 $s .= '<span id="settings_yourls_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_yourls_expanded\'); openClose(\'settings_yourls_inflated\');">';
55 $s .= '<h3>' . t('YourLS') . '</h3>';
57 $s .= '<div id="settings_yourls_expanded" class="settings-block" style="display: none;">';
58 $s .= '<span class="fakelink" onclick="openClose(\'settings_yourls_expanded\'); openClose(\'settings_yourls_inflated\');">';
59 $s .= '<h3>' . t('YourLS') . '</h3>';
62 $s .= '<div id="yourls-url-wrapper">';
63 $s .= '<label id="yourls-url-label" for="yourls-url">' . t('URL: http://') . '</label>';
64 $s .= '<input id="yourls-url" type="text" name="yourls_url" value="' . $yourls_url .'" />';
65 $s .= '</div><div class="clear"></div>';
67 $s .= '<div id="yourls-username-wrapper">';
68 $s .= '<label id="yourls-username-label" for="yourls-username">' . t('Username:') . '</label>';
69 $s .= '<input id="yourls-username" type="text" name="yourls_username" value="' . $yourls_username .'" />';
70 $s .= '</div><div class="clear"></div>';
72 $s .= '<div id="yourls-password-wrapper">';
73 $s .= '<label id="yourls-password-label" for="yourls-password">' . t('Password:') . '</label>';
74 $s .= '<input id="yourls-password" type="password" name="yourls_password" value="' . $yourls_password .'" />';
75 $s .= '</div><div class="clear"></div>';
77 $s .= '<div id="yourls-ssl-wrapper">';
78 $s .= '<label id="yourls-ssl-label" for="yourls-ssl">' . t('Use SSL ') . '</label>';
79 $s .= '<input id="yourls-ssl" type="checkbox" name="yourls_ssl" value="1" ' . $ssl_checked . ' />';
80 $s .= '</div><div class="clear"></div>';
82 $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="yourls-submit" name="yourls-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
88 function yourls_addon_settings_post(&$a,&$b) {
93 if($_POST['yourls-submit']) {
94 set_config('yourls','url1',trim($_POST['yourls_url']));
95 set_config('yourls','username1',trim($_POST['yourls_username']));
96 set_config('yourls','password1',trim($_POST['yourls_password']));
97 set_config('yourls','ssl1',intval($_POST['yourls_ssl']));
98 info( t('yourls Settings saved.') . EOL);