From e7b9401e4e918ec7c4a442e2acb3fb48926e90a9 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 11 Jun 2010 21:57:33 +0000 Subject: Some code cleanup on profile plugin. Added wrapper view for profile content. Added ECML for profile content. Moved profile/profile_content/sidebar to profile/sidebar git-svn-id: http://code.elgg.org/elgg/trunk@6464 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/profile/languages/en.php | 1 + mod/profile/profile_lib.php | 34 +++------ mod/profile/start.php | 20 ++++- .../views/default/profile/profile_content.php | 13 ++++ .../default/profile/profile_contents/activity.php | 48 ++++++------ .../profile/profile_contents/commentwall.php | 9 +-- .../default/profile/profile_contents/details.php | 87 ++++++++++------------ .../default/profile/profile_contents/friends.php | 15 ++-- .../default/profile/profile_contents/sidebar.php | 17 ----- .../default/profile/profile_contents/twitter.php | 10 +-- mod/profile/views/default/profile/sidebar.php | 17 +++++ 11 files changed, 138 insertions(+), 133 deletions(-) create mode 100644 mod/profile/views/default/profile/profile_content.php delete mode 100644 mod/profile/views/default/profile/profile_contents/sidebar.php create mode 100644 mod/profile/views/default/profile/sidebar.php diff --git a/mod/profile/languages/en.php b/mod/profile/languages/en.php index df40854ff..d8f4e1848 100644 --- a/mod/profile/languages/en.php +++ b/mod/profile/languages/en.php @@ -112,6 +112,7 @@ You cannot reply to this email.", * Profile error messages */ + 'profile:no_friends' => 'This person hasn\'t added any friends yet!', 'profile:noaccess' => "You do not have permission to edit this profile.", 'profile:notfound' => "Sorry, we could not find the specified profile.", 'profile:icon:notfound' => "Sorry, there was a problem uploading your profile picture.", diff --git a/mod/profile/profile_lib.php b/mod/profile/profile_lib.php index b38286e1e..909191847 100644 --- a/mod/profile/profile_lib.php +++ b/mod/profile/profile_lib.php @@ -15,38 +15,24 @@ * @param string $username The username of the profile to display * @param string $section Which section is currently selected. * - * return mixed FALSE or html for the profile. + * @todo - This should really use a plugin hook to get the list of plugin tabs + * + * @return mixed FALSE or html for the profile. */ function profile_get_user_profile_html($user, $section = 'activity') { $body = elgg_view('profile/profile_navigation', array('section' => $section, 'entity' => $user)); $view_options = array('entity' => $user); - switch($section){ - case 'friends': - $body .= elgg_view('profile/profile_contents/friends', $view_options); - break; + if ($section == 'commentwall') { + $comments = $user->getAnnotations('commentwall', 200, 0, 'desc'); + $view_options['comments'] = $comments; + } - case 'twitter': - $body .= elgg_view('profile/profile_contents/twitter', $view_options); - break; - case 'feeds': - $body .= elgg_view('profile/profile_contents/feeds', $view_options); - break; - case 'commentwall': - $comments = $user->getAnnotations('commentwall', 200, 0, 'desc'); - $body .= elgg_view('profile/profile_contents/commentwall', array("entity" => $user, "comments" => $comments)); - break; - case 'details': - $body .= elgg_view('profile/profile_contents/details', $view_options); - break; + $content = elgg_view("profile/profile_contents/$section", $view_options); - default: - case 'activity': - $body .= elgg_view('profile/profile_contents/activity', $view_options); - break; - } + $body .= elgg_view('profile/profile_content', array('content' => $content)); - $body .= elgg_view('profile/profile_contents/sidebar', array('section' => $section)); + $body .= elgg_view('profile/sidebar', array('section' => $section)); return $body; } diff --git a/mod/profile/start.php b/mod/profile/start.php index 90caa8f64..17a55e1f9 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -50,7 +50,11 @@ function profile_init() { // Now override icons register_plugin_hook('entity:icon:url', 'user', 'profile_usericon_hook'); - + + // allow ECML in parts of the profile + register_plugin_hook('get_views', 'ecml', 'profile_ecml_views_hook'); + + // default profile fields admin item elgg_add_admin_submenu_item('defaultprofile', elgg_echo('profile:edit:default'), 'appearance'); } @@ -258,6 +262,20 @@ function profile_usericon_hook($hook, $entity_type, $returnvalue, $params){ } } +/** + * Parse ECML on parts of the profile + * + * @param unknown_type $hook + * @param unknown_type $entity_type + * @param unknown_type $return_value + * @param unknown_type $params + */ +function profile_ecml_views_hook($hook, $entity_type, $return_value, $params) { + $return_value['profile/profile_content'] = elgg_echo('profile'); + + return $return_value; +} + // Make sure the profile initialisation function is called on initialisation register_elgg_event_handler('init','system','profile_init',1); register_elgg_event_handler('init','system','profile_fields_setup', 10000); // Ensure this runs after other plugins diff --git a/mod/profile/views/default/profile/profile_content.php b/mod/profile/views/default/profile/profile_content.php new file mode 100644 index 000000000..4fb43e7c9 --- /dev/null +++ b/mod/profile/views/default/profile/profile_content.php @@ -0,0 +1,13 @@ + +
+ +
\ No newline at end of file diff --git a/mod/profile/views/default/profile/profile_contents/activity.php b/mod/profile/views/default/profile/profile_contents/activity.php index 588ed89d1..ccd2a3915 100755 --- a/mod/profile/views/default/profile/profile_contents/activity.php +++ b/mod/profile/views/default/profile/profile_contents/activity.php @@ -2,29 +2,31 @@ /** * Elgg user display (details) * @uses $vars['entity'] The user entity + * + * @todo this needs to recieve a list of activity or HTML in $vars that's generated by a plugin hook. + * None of this logic should be here. */ - $limit = 20; -?> -
- $vars['entity'])); - } - if(is_plugin_enabled('conversations')) { - // users last status msg, if they posted one - echo elgg_view("profile/status", array("entity" => $vars['entity'])); - } - if(is_plugin_enabled('riverdashboard')) { - //select the correct river - if (get_plugin_setting('activitytype', 'riverdashboard') == 'classic') { - echo elgg_view_river_items($vars['entity']->getGuid(), 0, '', '', '', '', $limit,0,0,false,true); - } else { - echo elgg_view_river_items($vars['entity']->getGuid(), 0, '', '', '', '', $limit,0,0,false,false); - echo elgg_view('riverdashboard/js'); - } +$limit = 20; + +if (is_plugin_enabled('thewire')) { + // users last status msg, if they posted one + echo elgg_view("profile/status", array("entity" => $vars['entity'])); +} + +if (is_plugin_enabled('conversations')) { + // users last status msg, if they posted one + echo elgg_view("profile/status", array("entity" => $vars['entity'])); +} + +if (is_plugin_enabled('riverdashboard')) { + //select the correct river + if (get_plugin_setting('activitytype', 'riverdashboard') == 'classic') { + echo elgg_view_river_items($vars['entity']->getGuid(), 0, '', '', '', '', $limit,0,0,false,true); } else { - echo "Riverdashboard not loaded"; + echo elgg_view_river_items($vars['entity']->getGuid(), 0, '', '', '', '', $limit,0,0,false,false); + echo elgg_view('riverdashboard/js'); } - ?> -
+} else { + // @todo this should not be here. + echo "Riverdashboard not loaded"; +} \ No newline at end of file diff --git a/mod/profile/views/default/profile/profile_contents/commentwall.php b/mod/profile/views/default/profile/profile_contents/commentwall.php index f3a2adb1c..7e8a1d97d 100644 --- a/mod/profile/views/default/profile/profile_contents/commentwall.php +++ b/mod/profile/views/default/profile/profile_contents/commentwall.php @@ -2,12 +2,9 @@ /** * Elgg profile comment wall */ -?> -
- $vars['comments'])); -?> -
\ No newline at end of file diff --git a/mod/profile/views/default/profile/profile_contents/details.php b/mod/profile/views/default/profile/profile_contents/details.php index d040cef75..6a214557d 100755 --- a/mod/profile/views/default/profile/profile_contents/details.php +++ b/mod/profile/views/default/profile/profile_contents/details.php @@ -3,54 +3,47 @@ * Elgg user display (details) * @uses $vars['entity'] The user entity */ -?> -
-guid) - $rel = 'me'; - else if (check_entity_relationship(page_owner(), 'friend', $vars['entity']->guid)) - $rel = 'friend'; - $even_odd = null; - if (is_array($vars['config']->profile) && sizeof($vars['config']->profile) > 0) - foreach($vars['config']->profile as $shortname => $valtype) { - if ($shortname != "description") { - $value = $vars['entity']->$shortname; - if (!empty($value)) { - //This function controls the alternating class - $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; -?> -

- : - $vars['entity']->$shortname)); - ?> -

- - -isBanned()) { - echo "
"; - echo elgg_echo('profile:banned'); - echo "
"; - }else{ - if($vars['entity']->description){ - echo "

" . elgg_echo("profile:aboutme") . "

"; - echo "
" .elgg_view('output/longtext', array('value' => $vars['entity']->description))."
"; +// Simple XFN +$rel = ""; +if (page_owner() == $vars['entity']->guid) { + $rel = 'me'; +} else if (check_entity_relationship(page_owner(), 'friend', $vars['entity']->guid)) { + $rel = 'friend'; +} + +$even_odd = null; +if (is_array($vars['config']->profile) && sizeof($vars['config']->profile) > 0) { + foreach($vars['config']->profile as $shortname => $valtype) { + if ($shortname != "description") { + $value = $vars['entity']->$shortname; + if (!empty($value)) { + //This function controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + ?> +

+ : + $vars['entity']->$shortname)); + ?> +

+ - - "; \ No newline at end of file +if (!get_plugin_setting('user_defined_fields', 'profile')) { + if ($vars['entity']->isBanned()) { + echo "
"; + echo elgg_echo('profile:banned'); + echo "
"; + } else { + if ($vars['entity']->description) { + echo "

" . elgg_echo("profile:aboutme") . "

"; + echo "
" . elgg_view('output/longtext', array('value' => $vars['entity']->description)) . "
"; + } + } +} \ No newline at end of file diff --git a/mod/profile/views/default/profile/profile_contents/friends.php b/mod/profile/views/default/profile/profile_contents/friends.php index a097f3830..9195629e5 100755 --- a/mod/profile/views/default/profile/profile_contents/friends.php +++ b/mod/profile/views/default/profile/profile_contents/friends.php @@ -3,13 +3,10 @@ * Profile friends **/ -$friends = list_entities_from_relationship('friend',$vars['entity']->getGUID(),false,'user','',0,10,false); -if(!$friends) - $friends = "

This user has not made any friends yet.

"; +$friends = list_entities_from_relationship('friend', $vars['entity']->getGUID(), FALSE, 'user', '', 0, 10, FALSE); -?> -
- -
\ No newline at end of file +if(!$friends) { + $friends = '

' . elgg_echo('profile:no_friends') . '

'; +} + +echo $friends; \ No newline at end of file diff --git a/mod/profile/views/default/profile/profile_contents/sidebar.php b/mod/profile/views/default/profile/profile_contents/sidebar.php deleted file mode 100644 index 43e3d1087..000000000 --- a/mod/profile/views/default/profile/profile_contents/sidebar.php +++ /dev/null @@ -1,17 +0,0 @@ - -
- $section)); -?> -
\ No newline at end of file diff --git a/mod/profile/views/default/profile/profile_contents/twitter.php b/mod/profile/views/default/profile/profile_contents/twitter.php index f9b6f5d54..06a0551d4 100755 --- a/mod/profile/views/default/profile/profile_contents/twitter.php +++ b/mod/profile/views/default/profile/profile_contents/twitter.php @@ -8,12 +8,10 @@ $twitter_username = $vars['entity']->twitter; // if the twitter username is empty, then do not show if($twitter_username){ ?> -
-
    -

    - - -
    + +

    + + +
    + $section)); +?> +
    \ No newline at end of file -- cgit v1.2.3