diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-27 14:20:22 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-27 14:20:22 +0000 |
commit | 4c94f8809f1131e2d8e073518195b6b65b26aceb (patch) | |
tree | 461af7e0e4414871c519acdef84ce397fa534325 /mod | |
parent | 543e50d2aabfbd3c116cbb670018c66fae535955 (diff) | |
download | elgg-4c94f8809f1131e2d8e073518195b6b65b26aceb.tar.gz elgg-4c94f8809f1131e2d8e073518195b6b65b26aceb.tar.bz2 |
improved menu creation for on demand menus and integrated hover menu items into profile owner block
git-svn-id: http://code.elgg.org/elgg/trunk@7724 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r-- | mod/blog/start.php | 6 | ||||
-rw-r--r-- | mod/bookmarks/start.php | 6 | ||||
-rw-r--r-- | mod/file/start.php | 6 | ||||
-rw-r--r-- | mod/logbrowser/start.php | 6 | ||||
-rw-r--r-- | mod/messages/start.php | 14 | ||||
-rw-r--r-- | mod/pages/start.php | 6 | ||||
-rw-r--r-- | mod/profile/views/default/profile/css.php | 100 | ||||
-rwxr-xr-x | mod/profile/views/default/profile/ownerblock.php | 85 |
8 files changed, 99 insertions, 130 deletions
diff --git a/mod/blog/start.php b/mod/blog/start.php index f3cd31770..1c0cc8b21 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -229,14 +229,16 @@ function blog_owner_block_menu($hook, $type, $return, $params) { if (elgg_instanceof($params['entity'], 'user')) { $url = "pg/blog/owner/{$params['entity']->username}"; $item = new ElggMenuItem('blog', elgg_echo('blog'), $url); - elgg_register_menu_item('owner_block', $item); + $return[] = $item; } else { if ($params['entity']->blog_enable != "no") { $url = "pg/blog/group/{$params['entity']->guid}/owner"; $item = new ElggMenuItem('blog', elgg_echo('blog:group'), $url); - elgg_register_menu_item('owner_block', $item); + $return[] = $item; } } + + return $return; } /** diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php index 062193517..8550878b6 100644 --- a/mod/bookmarks/start.php +++ b/mod/bookmarks/start.php @@ -321,14 +321,16 @@ function bookmarks_owner_block_menu($hook, $type, $return, $params) { if (elgg_instanceof($params['entity'], 'user')) { $url = "pg/bookmarks/owner/{$params['user']->username}"; $item = new ElggMenuItem('bookmarks', elgg_echo('bookmarks'), $url); - elgg_register_menu_item('owner_block', $item); + $return[] = $item; } else { if ($params['entity']->bookmarks_enable != "no") { $url = "pg/bookmarks/owner/{$params['entity']->username}"; $item = new ElggMenuItem('bookmarks', elgg_echo('bookmarks:group'), $url); - elgg_register_menu_item('owner_block', $item); + $return[] = $item; } } + + return $return; } /** diff --git a/mod/file/start.php b/mod/file/start.php index bb291680e..3376befeb 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -147,14 +147,16 @@ function file_owner_block_menu($hook, $type, $return, $params) { if (elgg_instanceof($params['entity'], 'user')) { $url = "pg/file/owner/{$params['entity']->username}"; $item = new ElggMenuItem('file', elgg_echo('file'), $url); - elgg_register_menu_item('owner_block', $item); + $return[] = $item; } else { if ($params['entity']->file_enable != "no") { $url = "pg/file/owner/{$params['entity']->username}"; $item = new ElggMenuItem('file', elgg_echo('file:group'), $url); - elgg_register_menu_item('owner_block', $item); + $return[] = $item; } } + + return $return; } /** diff --git a/mod/logbrowser/start.php b/mod/logbrowser/start.php index 62beafe87..dd3c24bee 100644 --- a/mod/logbrowser/start.php +++ b/mod/logbrowser/start.php @@ -23,10 +23,12 @@ function logbrowser_init() { * Add to the user hover menu */ function logbrowser_user_hover_menu($hook, $type, $return, $params) { - $user = $params['user']; + $user = $params['entity']; $url = "pg/admin/overview/logbrowser/?user_guid={$user->guid}"; $item = new ElggMenuItem('logbrowser', elgg_echo('logbrowser:explore'), $url); $item->setSection('admin'); - elgg_register_menu_item('user_hover', $item); + $return[] = $item; + + return $return; } diff --git a/mod/messages/start.php b/mod/messages/start.php index 861f219b2..e8f5105b2 100644 --- a/mod/messages/start.php +++ b/mod/messages/start.php @@ -311,12 +311,16 @@ function messages_site_notify_handler(ElggEntity $from, ElggUser $to, $subject, * Add to the user hover menu */ function messages_user_hover_menu($hook, $type, $return, $params) { - $user = $params['user']; + $user = $params['entity']; - $url = "mod/messages/send.php?send_to={$user->guid}"; - $item = new ElggMenuItem('logbrowser', elgg_echo('messages:sendmessage'), $url); - $item->setSection('action'); - elgg_register_menu_item('user_hover', $item); + if (isloggedin() && get_loggedin_userid() != $user->guid) { + $url = "mod/messages/send.php?send_to={$user->guid}"; + $item = new ElggMenuItem('send', elgg_echo('messages:sendmessage'), $url); + $item->setSection('action'); + $return[] = $item; + } + + return $return; } diff --git a/mod/pages/start.php b/mod/pages/start.php index ebf102be0..1c8290327 100644 --- a/mod/pages/start.php +++ b/mod/pages/start.php @@ -83,14 +83,16 @@ function pages_owner_block_menu($hook, $type, $return, $params) { if (elgg_instanceof($params['entity'], 'user')) { $url = "pg/pages/owner/{$params['entity']->username}"; $item = new ElggMenuItem('pages', elgg_echo('pages'), $url); - elgg_register_menu_item('owner_block', $item); + $return[] = $item; } else { if ($params['entity']->pages_enable != "no") { $url = "pg/pages/owned/group:{$vars['entity']->guid}"; $item = new ElggMenuItem('pages', elgg_echo('pages:group'), $url); - elgg_register_menu_item('owner_block', $item); + $return[] = $item; } } + + return $return; } /** diff --git a/mod/profile/views/default/profile/css.php b/mod/profile/views/default/profile/css.php index 754276c69..1d1f1ccb1 100644 --- a/mod/profile/views/default/profile/css.php +++ b/mod/profile/views/default/profile/css.php @@ -29,98 +29,60 @@ /* *************************************** ownerblock in sidebar *************************************** */ -#profile-sidebar #owner_block { +#profile-owner-block { background-color: #eeeeee; - padding:15px; + padding: 15px; } -#owner_block .owner_block_icon.large { +.owner_block_icon { overflow: hidden; + margin-bottom: 10px; } -#owner_block .profile_actions { - margin-top:10px; -} -#owner_block .profile_actions a.elgg-action-button { - margin-bottom:4px; +#profile-owner-block a.elgg-action-button { + margin-bottom: 4px; display: table; } -/* ownerblock links to owners tools */ -#owner_block .owners_content_links { - border-top:1px dotted #cccccc; - margin-top:4px; - padding-top:2px; -} -#owner_block .owners_content_links ul { - margin:0; - padding:0; -} -#owner_block .owners_content_links ul li { - display:block; - float:left; - width:95px; - font-size: 90%; -} -/* profile pages - ownerblock links to owners tools */ -.owner_block_links { - margin-top:5px; -} -.owner_block_links ul { - margin:0; - padding:0; - list-style: none; -} -.owner_block_links ul li.selected a { - background: #4690D6; - color:white; -} -.owner_block_links ul li a { - display:block; - -webkit-border-radius: 8px; +.profile-content-menu a { + display: block; + -webkit-border-radius: 8px; -moz-border-radius: 8px; - background-color:white; - margin:3px 0 5px 0; - padding:2px 4px 2px 8px; + background-color: white; + margin: 3px 0 5px 0; + padding: 2px 4px 2px 8px; } -.owner_block_links ul li a:hover { - background:#0054A7; - color:white; - text-decoration:none; +.profile-content-menu a:hover { + background: #0054A7; + color: white; + text-decoration: none; } - /* *************************************** admin menu in sidebar *************************************** */ -.owner_block_links .admin_menu_options { +.profile-admin-menu { display: none; } -.owner_block_links ul.admin_menu { - background-color:white; +.profile-admin-menu-wrapper a { + display: block; -webkit-border-radius: 8px; -moz-border-radius: 8px; - cursor:pointer; -} -.owner_block_links ul.admin_menu li a { background-color: white; - color:red; - margin-bottom:0; + margin: 3px 0 5px 0; + padding: 2px 4px 2px 8px; } -.owner_block_links ul.admin_menu li a:hover { - color:black; +.profile-admin-menu-wrapper { + background-color: white; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; } -.owner_block_links ul.admin_menu li ul.admin_menu_options li a { - color:red; - background-color:white; - display:block; - margin:0px; - padding:2px 4px 2px 13px; +.profile-admin-menu-wrapper li a { + background-color: white; + color: red; + margin-bottom: 0; } -.owner_block_links ul.admin_menu li ul.admin_menu_options li a:hover { - color:black; - background:none; - text-decoration: underline; +.profile-admin-menu-wrapper a:hover { + color: black; } - /* *************************************** full profile info panel *************************************** */ diff --git a/mod/profile/views/default/profile/ownerblock.php b/mod/profile/views/default/profile/ownerblock.php index 2197164cb..ac0cb5b54 100755 --- a/mod/profile/views/default/profile/ownerblock.php +++ b/mod/profile/views/default/profile/ownerblock.php @@ -21,69 +21,62 @@ if (!$user) { $more_info = ''; -$location = elgg_view("output/tags",array('value' => $user->location)); +$location = elgg_view("output/tags", array('value' => $user->location)); -$icon = elgg_view("profile/icon",array('entity' => $user, 'size' => 'large', 'override' => 'true')); +$icon = elgg_view("profile/icon", array( + 'entity' => $user, + 'size' => 'large', + 'override' => 'true' +)); $icon_class = "large"; -// @todo pull out into menu -$profile_actions = ""; -if (isloggedin() && (get_loggedin_userid() == elgg_get_page_owner_guid())) { - $profile_actions = "<div class='clearfix profile_actions'>"; - $profile_actions .= "<a href='".elgg_get_site_url()."pg/profile/{$user->username}/edit/details' class='elgg-action-button'>". elgg_echo('profile:edit') ."</a>"; - $profile_actions .= "<a href='".elgg_get_site_url()."pg/avatar/edit/{$user->username}' class='elgg-action-button'>". elgg_echo('avatar:edit') ."</a>"; - $profile_actions .= "</div>"; -} else { - $profile_actions = "<div class='profile_actions'>"; - if (isloggedin()) { - if (get_loggedin_userid() != $user->getGUID()) { - if ($user->isFriend()) { - $url = elgg_get_site_url()."action/friends/remove?friend={$user->getGUID()}"; - $url = elgg_add_action_tokens_to_url($url); - $profile_actions .= "<a href=\"$url\" class='elgg-action-button'>" . elgg_echo('friend:remove') . "</a>"; - } else { - $url = elgg_get_site_url()."action/friends/add?friend={$user->getGUID()}"; - $url = elgg_add_action_tokens_to_url($url); - $profile_actions .= "<a href=\"$url\" class='elgg-action-button'>" . elgg_echo('friend:add') . "</a>"; - } - } - } - if (is_plugin_enabled('messages') && isloggedin()) { - $profile_actions .= "<a href=\"".elgg_get_site_url()."mod/messages/send.php?send_to={$user->guid}\" class='elgg-action-button'>". elgg_echo('messages:send') ."</a>"; +// grab the actions and admin menu items from user hover +$menu = elgg_trigger_plugin_hook('register', "menu:user_hover", array('entity' => $user), array()); +$builder = new ElggMenuBuilder($menu); +$menu = $builder->getMenu(); +$actions = elgg_get_array_value('action', $menu, array()); +$admin = elgg_get_array_value('admin', $menu, array()); + +$profile_actions = ''; +if (isloggedin() && $actions) { + $profile_actions = '<ul class="elgg-menu">'; + foreach ($actions as $action) { + $profile_actions .= '<li>' . $action->getLink(array('class' => 'elgg-action-button')) . '</li>'; } - $profile_actions .= "</div>"; + $profile_actions .= '</ul>'; } - // if admin, display admin links $admin_links = ''; if (isadminloggedin() && get_loggedin_userid() != elgg_get_page_owner_guid()) { - $params = array( - 'user' => elgg_get_page_owner(), - 'toggle' => true, - 'sort_by' => 'order', - ); - $admin_links = elgg_view_menu('user_admin', $params); - $admin_links = "<div class=\"owner_block_links\">$admin_links</div>"; + $admin_links = '<ul class="profile-admin-menu-wrapper">'; + $admin_links .= '<li><a class="elgg-toggle" id="elgg-toggler-admin-menu">Admin options…</a>'; + $admin_links .= '<ul class="profile-admin-menu" id="elgg-togglee-admin-menu">'; + foreach ($admin as $menu_item) { + $admin_links .= elgg_view('navigation/menu/elements/item', array('item' => $menu_item)); + } + $admin_links .= '</ul>'; + $admin_links .= '</li>'; + $admin_links .= '</ul>'; } // content links -$menu = elgg_view_menu('owner_block', array('entity' => elgg_get_page_owner())); +$content_menu = elgg_view_menu('owner_block', array( + 'entity' => elgg_get_page_owner(), + 'class' => 'profile-content-menu', +)); //contruct the display $display = <<<EOT -<div id="owner_block"> - <div class="owner_block_icon {$icon_class}"> - {$icon} - </div> - {$more_info} - {$profile_actions} - <div class="owner_block_links"> - $menu +<div id="profile-owner-block"> + <div class="owner_block_icon $icon_class"> + $icon </div> - <!-- if admin user --> - {$admin_links} + $more_info + $profile_actions + $content_menu + $admin_links </div> EOT; |