Merge branch '3.6-rc'
[friendica-addons.git] / planets / planets.php
index d40e6c61a1b34ba1c92ea390c632e4a1820da122..067db51d6132e2f82d14604282a8e480bf2f314d 100644 (file)
@@ -1,34 +1,36 @@
 <?php
 /**
  * Name: Random Planet, Empirial Version
- * Description: Sample Friendica plugin/addon. Set a random planet from the Emprire when posting.
+ * Description: Sample Friendica addon. Set a random planet from the Emprire when posting.
  * Version: 1.0
  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
  * Author: Tony Baldwin <https://free-haven.org/profile/tony>
  */
-
+use Friendica\Core\Addon;
+use Friendica\Core\L10n;
+use Friendica\Core\PConfig;
 
 function planets_install() {
 
        /**
-        * 
-        * Our demo plugin will attach in three places.
+        *
+        * Our demo addon will attach in three places.
         * The first is just prior to storing a local post.
         *
         */
 
-       register_hook('post_local', 'addon/planets/planets.php', 'planets_post_hook');
+       Addon::registerHook('post_local', 'addon/planets/planets.php', 'planets_post_hook');
 
        /**
         *
-        * Then we'll attach into the plugin settings page, and also the 
+        * Then we'll attach into the addon settings page, and also the
         * settings post hook so that we can create and update
         * user preferences.
         *
         */
 
-       register_hook('plugin_settings', 'addon/planets/planets.php', 'planets_settings');
-       register_hook('plugin_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
+       Addon::registerHook('addon_settings', 'addon/planets/planets.php', 'planets_settings');
+       Addon::registerHook('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
 
        logger("installed planets");
 }
@@ -44,9 +46,9 @@ function planets_uninstall() {
         *
         */
 
-       unregister_hook('post_local',    'addon/planets/planets.php', 'planets_post_hook');
-       unregister_hook('plugin_settings', 'addon/planets/planets.php', 'planets_settings');
-       unregister_hook('plugin_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
+       Addon::unregisterHook('post_local',    'addon/planets/planets.php', 'planets_post_hook');
+       Addon::unregisterHook('addon_settings', 'addon/planets/planets.php', 'planets_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
 
 
        logger("removed planets");
@@ -61,7 +63,7 @@ function planets_post_hook($a, &$item) {
         * An item was posted on the local system.
         * We are going to look for specific items:
         *      - A status post by a profile owner
-        *      - The profile owner must have allowed our plugin
+        *      - The profile owner must have allowed our addon
         *
         */
 
@@ -122,7 +124,7 @@ function planets_settings_post($a,$post) {
 
 /**
  *
- * Called from the Plugin Setting form. 
+ * Called from the Addon Setting form.
  * Add our own settings info to the page.
  *
  */
@@ -147,22 +149,22 @@ function planets_settings(&$a,&$s) {
        /* Add some HTML to the existing form */
 
     $s .= '<span id="settings_planets_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_planets_expanded\'); openClose(\'settings_planets_inflated\');">';
-       $s .= '<h3>' . t('Planets') . '</h3>';
+       $s .= '<h3>' . L10n::t('Planets') . '</h3>';
        $s .= '</span>';
        $s .= '<div id="settings_planets_expanded" class="settings-block" style="display: none;">';
        $s .= '<span class="fakelink" onclick="openClose(\'settings_planets_expanded\'); openClose(\'settings_planets_inflated\');">';
-       $s .= '<h3>' . t('Planets') . '</h3>';
+       $s .= '<h3>' . L10n::t('Planets') . '</h3>';
        $s .= '</span>';
 
     $s .= '<div class="settings-block">';
-       $s .= '<h3>' . t('Planets Settings') . '</h3>';
+       $s .= '<h3>' . L10n::t('Planets Settings') . '</h3>';
        $s .= '<div id="planets-enable-wrapper">';
-       $s .= '<label id="planets-enable-label" for="planets-checkbox">' . t('Enable Planets Plugin') . '</label>';
+       $s .= '<label id="planets-enable-label" for="planets-checkbox">' . L10n::t('Enable Planets Addon') . '</label>';
        $s .= '<input id="planets-checkbox" type="checkbox" name="planets" value="1" ' . $checked . '/>';
        $s .= '</div><div class="clear"></div></div>';
 
        /* provide a submit button */
 
-       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="planets-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="planets-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
 
 }