[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/inc/plugins/ -> hello.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id: hello.php 5754 2012-03-09 14:58:03Z Tomm $
  10   */
  11   
  12  // Disallow direct access to this file for security reasons
  13  if(!defined("IN_MYBB"))
  14  {
  15      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  16  }
  17  
  18  $plugins->add_hook("pre_output_page", "hello_world");
  19  $plugins->add_hook("postbit", "hello_world_postbit");
  20  
  21  function hello_info()
  22  {
  23      /**
  24       * Array of information about the plugin.
  25       * name: The name of the plugin
  26       * description: Description of what the plugin does
  27       * website: The website the plugin is maintained at (Optional)
  28       * author: The name of the author of the plugin
  29       * authorsite: The URL to the website of the author (Optional)
  30       * version: The version number of the plugin
  31       * guid: Unique ID issued by the MyBB Mods site for version checking
  32       * compatibility: A CSV list of MyBB versions supported. Ex, "121,123", "12*". Wildcards supported.
  33       */
  34      return array(
  35          "name"            => "Hello World!",
  36          "description"    => "A sample plugin that prints hello world and prepends the content of each post to 'Hello world!'",
  37          "website"        => "http://mybb.com",
  38          "author"        => "MyBB Group",
  39          "authorsite"    => "http://mybb.com",
  40          "version"        => "1.0",
  41          "guid"             => "",
  42          "compatibility" => "*"
  43      );
  44  }
  45  
  46  /**
  47   * ADDITIONAL PLUGIN INSTALL/UNINSTALL ROUTINES
  48   *
  49   * _install():
  50   *   Called whenever a plugin is installed by clicking the "Install" button in the plugin manager.
  51   *   If no install routine exists, the install button is not shown and it assumed any work will be
  52   *   performed in the _activate() routine.
  53   *
  54   * function hello_install()
  55   * {
  56   * }
  57   *
  58   * _is_installed():
  59   *   Called on the plugin management page to establish if a plugin is already installed or not.
  60   *   This should return TRUE if the plugin is installed (by checking tables, fields etc) or FALSE
  61   *   if the plugin is not installed.
  62   *
  63   * function hello_is_installed()
  64   * {
  65   *        global $db;
  66   *        if($db->table_exists("hello_world"))
  67   *      {
  68   *          return true;
  69   *        }
  70   *        return false;
  71   * }
  72   *
  73   * _uninstall():
  74   *    Called whenever a plugin is to be uninstalled. This should remove ALL traces of the plugin
  75   *    from the installation (tables etc). If it does not exist, uninstall button is not shown.
  76   *
  77   * function hello_uninstall()
  78   * {
  79   * }
  80   *
  81   * _activate():
  82   *    Called whenever a plugin is activated via the Admin CP. This should essentially make a plugin
  83   *    "visible" by adding templates/template changes, language changes etc.
  84   *
  85   * function hello_activate()
  86   * {
  87   * }
  88   *
  89   * _deactivate():
  90   *    Called whenever a plugin is deactivated. This should essentially "hide" the plugin from view
  91   *    by removing templates/template changes etc. It should not, however, remove any information
  92   *    such as tables, fields etc - that should be handled by an _uninstall routine. When a plugin is
  93   *    uninstalled, this routine will also be called before _uninstall() if the plugin is active.
  94   *
  95   * function hello_deactivate()
  96   * {
  97   * }
  98   */
  99  
 100  
 101  function hello_world($page)
 102  {
 103      $page = str_replace("<div id=\"content\">", "<div id=\"content\"><p>Hello World!<br />This is a sample MyBB Plugin (which can be disabled!) that displays this message on all pages.</p>", $page);
 104      return $page;
 105  }
 106  
 107  function hello_world_postbit(&$post)
 108  {
 109      $post['message'] = "<strong>Hello world!</strong><br /><br />{$post['message']}";
 110  }
 111  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1