aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-06-26 15:13:50 -0400
committercash <cash.costello@gmail.com>2011-06-26 15:13:50 -0400
commit3c34ddf59804767e6a7deea3e3ee6c81d4a09601 (patch)
tree48e5e16f0ef73cf306feaab1953d2f2286bd4311 /engine
parent33f5c59d5318bc1e9a607215a31e48c6f7ab5b29 (diff)
downloadelgg-3c34ddf59804767e6a7deea3e3ee6c81d4a09601.tar.gz
elgg-3c34ddf59804767e6a7deea3e3ee6c81d4a09601.tar.bz2
removed buttons logic from content header view, created convenience function rather than copying and pasting, and updated the blog plugin
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/navigation.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 4b2c998a2..1cb289654 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -154,6 +154,41 @@ function elgg_is_menu_item_registered($menu_name, $item_name) {
}
/**
+ * Convenience function for registering an add content button to title menu
+ *
+ * The add URL must be $handler/add/$guid where $guid is the guid of the page owner.
+ * The label of the button is "$handler:add" so that must be defined in a
+ * language file.
+ *
+ * @param string $handler The handler to use or null to autodetect from context
+ * @return void
+ * @since 1.8.0
+ */
+function elgg_register_add_button($handler = null) {
+ if (elgg_is_logged_in()) {
+
+ if (!$handler) {
+ $handler = elgg_get_context();
+ }
+
+ $owner = elgg_get_page_owner_entity();
+ if (!$owner) {
+ // no owns the page so this is probably an all site list page
+ $owner = elgg_get_logged_in_user_entity();
+ }
+ if ($owner && $owner->canWriteToContainer()) {
+ $guid = $owner->getGUID();
+ elgg_register_menu_item('title', array(
+ 'name' => 'add',
+ 'href' => "$handler/add/$guid",
+ 'text' => elgg_echo("$handler:add"),
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+ }
+ }
+}
+
+/**
* Adds a breadcrumb to the breadcrumbs stack.
*
* @param string $title The title to display