[Shuttlebb-svn] SF.net SVN: shuttlebb: [70] branch
Brought to you by:
afterlife69,
danb00
|
From: <aft...@us...> - 2006-12-04 03:52:41
|
Revision: 70
http://svn.sourceforge.net/shuttlebb/?rev=70&view=rev
Author: afterlife69
Date: 2006-12-03 19:52:36 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
Example module and hook added with intense documentation.
Modified Paths:
--------------
branch/module/module_main.php
Added Paths:
-----------
branch/plugins/
branch/plugins/Hello_World.php
branch/plugins/index.html
Modified: branch/module/module_main.php
===================================================================
--- branch/module/module_main.php 2006-12-04 03:31:14 UTC (rev 69)
+++ branch/module/module_main.php 2006-12-04 03:52:36 UTC (rev 70)
@@ -1,21 +1,104 @@
<?php
/**
+ * ShuttleBB "Hello World" Module.
+ *
* $Id$
* $Date$
* $Rev$
*/
+/**
+ * Standard security
+ *
+ * This prevents the module from being executed directly.
+ */
+if ( ! defined ( 'IN_SBB' ) )
+{
+ return;
+}
+
+/**
+ * C/C++ Programmers will pick up the module system very fast, it is based on filename
+ * and gos as followed: module_x.php becomes class:module_x and is constructed on init
+ * the constructor (function with the same name as the class) is called when the object
+ * is constructed (go figure).
+ *
+ * Just like C/C++, the default module is "main" or module_main, this is called when a
+ * module is not found, or there is no module defined. All module authors are expected
+ * to use the phpDoc syntax when packing their modules, and if they require external
+ * sources, the sources should be stored in a directory inside the modules folder with
+ * the same name as the module itself (ie, module_main would have the directory "main").
+ *
+ * When external sources are used, their package must be the same as the "subpackage"
+ * name used on the base module (in this case "main") and the subpackage would be their
+ * actual package name.
+ *
+ * @package shuttlebb
+ * @subpackage main
+ * @author Dean Newman <web...@au...>
+ */
class module_main
{
+ /**
+ *
+ */
function module_main()
{
- global $user, $ses;
-
- // construct the user object
- $user = new user();
+ // All pre-init sources
+ global $session;
+ global $user;
+ global $module;
+ global $language;
+ global $auth;
+ global $template;
+ // Start module proper
echo 'Hello World!';
+
+ // Init another class in this module
+ new module_main_required();
+
+ // Call a function
+ random_function();
+
+ return;
}
}
+/**
+ * Is it possible to execute commands outside of the module class
+ * however this is not permitted by the module coding standards
+ * which are provided with the documents in the package you downloaded
+ */
+echo 'This is not permitted!';
+
+/**
+ * However, you may include other classes or functions in your module.
+ */
+class module_main_required
+{
+ function module_main_required()
+ {
+ echo 'This is permitted';
+ }
+}
+
+function random_function()
+{
+ echo 'Wow, A function!';
+}
+
+/**
+ * Also, constants can also be added to your module, however you must
+ * follow the coding standards to ensure the constant is uppercase with
+ * underscores to seperate words.
+ */
+define('MY_CONSTANT', 'value!');
+
+/**
+ * As a final note, these rules only apply if you are planning to release
+ * your module to the shuttlebb community.
+ */
+return;
+
?>
\ No newline at end of file
Added: branch/plugins/Hello_World.php
===================================================================
--- branch/plugins/Hello_World.php (rev 0)
+++ branch/plugins/Hello_World.php 2006-12-04 03:52:36 UTC (rev 70)
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Basic "Hello World" Plugin that hooks the index.
+ *
+ * $Id$
+ * $Rev$
+ * $Date$
+ */
+
+/**
+ * This is a basic "Hello World" function that the hooks system will execute.
+ */
+function hello_world($date = 0)
+{
+ echo 'Hello World, The current date is ' . ($date) ? date('d-m-Y', $date) : date('d-m-Y') . '.';
+}
+
+/**
+ * The "register" method requires 2 parameters ($handle, $function) and everything after
+ * that is used as a parameter for the function call.
+ * For a full list of hooks, see {@link http://shuttlebb.com/coming_soon}
+ */
+hooks::register('index/login', 'hello_world'); // This hook does not call the parameter
+hooks::register('index/statistics', 'hello_world', time()); // This hook does call the parameter
+
+?>
\ No newline at end of file
Property changes on: branch/plugins/Hello_World.php
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: branch/plugins/index.html
===================================================================
Property changes on: branch/plugins/index.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|