]> git.mxchange.org Git - friendica.git/commitdiff
provide separate plugin settings page, update demo plugin, fix hook_register
authorFriendika <info@friendika.com>
Sat, 25 Dec 2010 07:44:17 +0000 (23:44 -0800)
committerFriendika <info@friendika.com>
Sat, 25 Dec 2010 07:44:17 +0000 (23:44 -0800)
addon/randplace/randplace.php
boot.php
mod/settings.php
util/strings.php
view/en/settings.tpl
view/it/settings.tpl
view/it/strings.php
view/theme/default/style.css

index e14ae74c7c8f0035fa3e0a3a03eb43950a1b3227..6203dab8f122a83f524199df79b8d1f4d797a86e 100644 (file)
@@ -36,13 +36,13 @@ function randplace_install() {
 
        /**
         *
-        * Then we'll attach into the settings page, on both the 
-        * form and post hooks so that we can create and update
+        * Then we'll attach into the plugin settings page, and also the 
+        * settings post hooks so that we can create and update
         * user preferences.
         *
         */
 
-       register_hook('settings_form', 'addon/randplace/randplace.php', 'randplace_settings');
+       register_hook('plugin_settings', 'addon/randplace/randplace.php', 'randplace_settings');
        register_hook('settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
 
        logger("installed randplace");
@@ -60,7 +60,7 @@ function randplace_uninstall() {
         */
 
        unregister_hook('post_local',    'addon/randplace/randplace.php', 'randplace_post_hook');
-       unregister_hook('settings_form', 'addon/randplace/randplace.php', 'randplace_settings');
+       unregister_hook('plugin_settings', 'addon/randplace/randplace.php', 'randplace_settings');
        unregister_hook('settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
 
 
@@ -154,7 +154,7 @@ function randplace_settings(&$a,&$s) {
        if(! local_user())
                return;
 
-       /* Add our stylesheet so we can match the page layout */
+       /* Add our stylesheet so we can make our settings look nice */
 
        $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/randplace/randplace.css' . '" media="all" />' . "\r\n";
 
@@ -164,7 +164,7 @@ function randplace_settings(&$a,&$s) {
 
        $checked = (($enabled) ? ' checked="checked" ' : '');
 
-       /* Add some HTML to the form */
+       /* Add some HTML to the existing form */
 
        $s .= '<h3>' . t('Randplace Settings') . '</h3>';
        $s .= '<div id="randplace-enable-wrapper">';
@@ -172,7 +172,7 @@ function randplace_settings(&$a,&$s) {
        $s .= '<input id="randplace-checkbox" type="checkbox" name="randplace" value="1" ' . $checked . '/>';
        $s .= '</div><div class="clear"></div>';
 
-       /* provide another submit button */
+       /* provide a submit button */
 
        $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
 
index c34002809393e79e1fe51a54ddc71241cfc19d48..7b7adba828133d1df47971a51d658bdbe12e6dda 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2047,7 +2047,7 @@ function profile_sidebar($profile) {
 if(! function_exists('register_hook')) {
 function register_hook($hook,$file,$function) {
 
-       $r = q("SELECT FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1",
+       $r = q("SELECT FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1",
                dbesc($hook),
                dbesc($file),
                dbesc($function)
index b10f9e3fc0bcbf84e2d6adb9802a31cbdaa18834..000258db917cea6ed5230649c838ffbd1d9b0f01 100644 (file)
@@ -17,6 +17,9 @@ function settings_post(&$a) {
 
        call_hooks('settings_post', $_POST);
 
+       if(($a->argc > 1) && ($a->argv[1] == 'addon'))
+               return;
+
        if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
@@ -182,6 +185,21 @@ function settings_content(&$a) {
                return;
        }
 
+       if(($a->argc > 1) && ($a->argv[1] === 'addon')) {
+               $o .= '<h1>' . t('Plugin Settings') . '</h1>';
+               $o .= '<div id="account-settings-link"><a href="settings">' . t('Account Settings') . '</a></div>';
+
+               $o .= '<form action="settings/addon" method="post" >';
+
+               $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
+               if(! count($r))
+                       notice('No Plugin settings configured');
+
+               call_hooks('plugin_settings', $o);
+               $o .= '</form>';
+               return $o;
+       }
+               
        require_once('include/acl_selectors.php');
 
        $p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
index e776d052fb4d3d97066360db5bf33e604eb377c0..f42449690d7dea9a9aa112adfbbaf497fc0d4839 100644 (file)
@@ -328,6 +328,8 @@ $a->strings[' Please use a shorter name.'] = ' Please use a shorter name.';
 $a->strings[' Name too short.'] = ' Name too short.';
 $a->strings[' Not valid email.'] = ' Not valid email.';
 $a->strings['Settings updated.'] = 'Settings updated.';
+$a->strings['Plugin Settings'] = 'Plugin Settings';
+$a->strings['Account Settings'] = 'Account Settings';
 $a->strings['OpenID: '] = 'OpenID: ';
 $a->strings["&nbsp;\x28Optional\x29 Allow this OpenID to login to this account."] = "&nbsp;\x28Optional\x29 Allow this OpenID to login to this account.";
 $a->strings['Profile is <strong>not published</strong>.'] = 'Profile is <strong>not published</strong>.';
index 594ce73fc485cef83d234b9cdacb0058a9d05c79..5e1bfabf4c1876dc159df31fc6c73973c7170366 100644 (file)
@@ -1,5 +1,7 @@
 <h1>Account Settings</h1>
 
+<div id="plugin-settings-link"><a href="settings/addon">Plugin Settings</a></div>
+
 $nickname_block
 
 
index 364fd6ba2f17b12f2a4ef3d7aa640ed5391e678d..365e5cb70958a08e22bb4e76ebac7351f1e6192b 100644 (file)
@@ -1,5 +1,8 @@
 <h1>Impostazioni account</h1>
 
+<div id="plugin-settings-link"><a href="settings/addon">Impostazioni Plugin</a></div>
+
+
 $nickname_block
 
 
index 2b1a3c8301c16fa31e3058464d6e1035fd2ef945..3640997d944011652cd1f697a529f309dd8e8d42 100644 (file)
@@ -324,6 +324,8 @@ $a->strings[' Please use a shorter name.'] = ' Usa un nome pi&ugrave; corto.';
 $a->strings[' Name too short.'] = ' Nome troppo corto.';
 $a->strings[' Not valid email.'] = ' Email non valida.';
 $a->strings['Settings updated.'] = 'Impostazioni aggiornate.';
+$a->strings['Plugin Settings'] = 'Impostazioni Plugin';
+$a->strings['Account Settings'= = 'Impostazioni Account';
 $a->strings['OpenID: '] = 'OpenID: ';
 $a->strings["&nbsp;\x28Optional\x29 Allow this OpenID to login to this account."] = "&nbsp;\x28Opzionale\x29 Permetti a questo OpenID di accedere a questo account.";
 $a->strings['Profile is <strong>not published</strong>.'] = 'Il profilo <strong>non &egrave; pubblicato</strong>.';
index 086f59c30bf157d064619036b3d6df3f34185644..240ace89605a04daa8292b4754a4de71a2424869 100644 (file)
@@ -1952,3 +1952,8 @@ a.mail-list-link {
        margin-top: 50px;
        font-size: 70%;
 }
+
+
+#plugin-settings-link, #account-settings-link {
+       margin-bottom: 25px;
+}