From ea4403c9240c3778cddc90d48d0a59c4d47dd2d8 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 15 Sep 2010 15:40:51 +0000 Subject: Adding documentation and examples. git-svn-id: http://code.elgg.org/elgg/trunk@6933 36083f99-b078-4883-b0ff-0f9b5a30f544 --- documentation/examples/events/advanced.php | 10 +++++++ documentation/examples/events/all.php | 24 +++++++++++++++ documentation/examples/events/basic.php | 13 +++++++++ documentation/examples/events/basic.php.out | 0 documentation/examples/events/emit.php | 7 +++++ documentation/examples/hooks/basic.php | 34 ++++++++++++++++++++++ documentation/examples/hooks/register/advanced.php | 23 +++++++++++++++ documentation/examples/hooks/register/all.php | 8 +++++ documentation/examples/hooks/register/basic.php | 14 +++++++++ .../examples/hooks/register/basic.php.out | 0 documentation/examples/hooks/register/emit.php | 6 ++++ documentation/examples/hooks/trigger/advanced.php | 9 ++++++ documentation/examples/hooks/trigger/basic.php | 9 ++++++ 13 files changed, 157 insertions(+) create mode 100644 documentation/examples/events/advanced.php create mode 100644 documentation/examples/events/all.php create mode 100644 documentation/examples/events/basic.php create mode 100644 documentation/examples/events/basic.php.out create mode 100644 documentation/examples/events/emit.php create mode 100644 documentation/examples/hooks/basic.php create mode 100644 documentation/examples/hooks/register/advanced.php create mode 100644 documentation/examples/hooks/register/all.php create mode 100644 documentation/examples/hooks/register/basic.php create mode 100644 documentation/examples/hooks/register/basic.php.out create mode 100644 documentation/examples/hooks/register/emit.php create mode 100644 documentation/examples/hooks/trigger/advanced.php create mode 100644 documentation/examples/hooks/trigger/basic.php diff --git a/documentation/examples/events/advanced.php b/documentation/examples/events/advanced.php new file mode 100644 index 000000000..c6fc2d0fb --- /dev/null +++ b/documentation/examples/events/advanced.php @@ -0,0 +1,10 @@ +getSubtype(); + + switch($subtype) { + case 'blog': + case 'thewire': + case 'pages': + return false; + default: + return true; + } + + } + + return true; +} + diff --git a/documentation/examples/events/basic.php b/documentation/examples/events/basic.php new file mode 100644 index 000000000..b274137b8 --- /dev/null +++ b/documentation/examples/events/basic.php @@ -0,0 +1,13 @@ + 'Joe'); +$items = trigger_plugin_hook('get_items', 'example', $params, $default); + +var_dump($items); + +function example_plugin_hook($hook, $type, $value, $params) { + if (is_array($value)) { + $value[] = "Hook Value 1"; + $value[] = "Hook Value 2"; + } + + return $value; +} + +function example_plugin_hook($hook, $type, $value, $params) { + $username = isset($params['username']) ? $params['username'] : NULL; + if (is_array($value)) { + switch($username) { + case 'Joe': + $value[] = "Joe's item"; + break; + case 'John': + $value[] = "Joe's item"; + break; + } + } + + return $value; +} diff --git a/documentation/examples/hooks/register/advanced.php b/documentation/examples/hooks/register/advanced.php new file mode 100644 index 000000000..48cddd480 --- /dev/null +++ b/documentation/examples/hooks/register/advanced.php @@ -0,0 +1,23 @@ +