diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-11 11:53:44 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-11 11:53:44 +0000 |
commit | b2bd57356c051608f81c71fe99e78170e56ce264 (patch) | |
tree | 06eaf429b89351c6d2b5e4dffa1fb26cd9e71f99 /engine/lib/elgglib.php | |
parent | 2506daa080f44cca1d62efe5d2c2b68e0fe9c284 (diff) | |
download | elgg-b2bd57356c051608f81c71fe99e78170e56ce264.tar.gz elgg-b2bd57356c051608f81c71fe99e78170e56ce264.tar.bz2 |
Registers and menu items
git-svn-id: https://code.elgg.org/elgg/trunk@154 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r-- | engine/lib/elgglib.php | 100 |
1 files changed, 99 insertions, 1 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 8c187ef8b..06a687363 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -187,7 +187,6 @@ * @param unknown_type $body
* @return unknown
*/
-
function page_draw($title, $body) {
return elgg_view('pageshells/pageshell', array(
'title' => $title,
@@ -199,6 +198,105 @@ }
/**
+ * Adds an array with a name to a given generic array register.
+ * For example, these are used for menus.
+ *
+ * @param string $register_name The name of the top-level register
+ * @param string $subregister_name The name of the subregister
+ * @param mixed $subregister_value The value of the subregister
+ * @param array $children_array Optionally, an array of children
+ * @return true|false Depending on success
+ */
+ function add_to_register($register_name, $subregister_name, $subregister_value, $children_array = array()) {
+
+ global $CONFIG;
+
+ if (empty($register_name) || empty($subregister_name) || empty($register_array))
+ return false;
+
+ if (!isset($CONFIG->registers))
+ $CONFIG->registers = array();
+
+ if (!isset($CONFIG->registers[$register_name]))
+ $CONFIG->registers[$register_name] = array();
+
+ if (is_array($register_array)) {
+ $subregister = new stdClass;
+ $subregister->name = $subregister_name;
+ $subregister->value = $subregister_value;
+ $subregister->children = $children_array;
+ $CONFIG->registers[$register_name][$subregister_name] = $subregister;
+ return true;
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Returns a register object
+ *
+ * @param string $register_name The name of the register
+ * @param mixed $register_value The value of the register
+ * @param array $children_array Optionally, an array of children
+ * @return false|stdClass Depending on success
+ */
+
+ function make_register_object($register_name, $register_value, $children_array = array()) {
+
+ if (empty($register_name) || empty($subregister_name) || empty($register_array))
+ return false;
+
+ $register = new stdClass;
+ $register->name = $register_name;
+ $register->value = $register_value;
+ $register->children = $children_array;
+
+ return $register;
+
+ }
+
+ /**
+ * If it exists, returns a particular register as an array
+ *
+ * @param string $register_name The name of the register
+ * @return array|false Depending on success
+ */
+ function get_register($register_name) {
+
+ global $CONFIG;
+
+ if (isset($CONFIG->registers[$register_name]))
+ return $CONFIG->registers[$register_name];
+
+ return false;
+
+ }
+
+ /**
+ * Adds an item to the menu register
+ *
+ * @param string $menu_name The name of the top-level menu
+ * @param string $menu_url The URL of the page
+ * @param array $menu_children Optionally, an array of submenu items
+ * @return true|false Depending on success
+ */
+ function add_menu($menu_name, $menu_url, $menu_children = array()) {
+ return add_to_register('menu',$menu_name,$menu_url, $menu_children);
+ }
+
+ /**
+ * Returns a menu item for use in the children section of add_menu()
+ *
+ * @param string $menu_name The name of the menu item
+ * @param string $menu_url Its URL
+ * @return stdClass|false Depending on success
+ */
+ function menu_item($menu_name, $menu_url) {
+ return make_register_object($menu_name, $menu_url);
+ }
+
+ /**
* Library loading and handling
*/
|