]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Some code cleanup on profile plugin.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 11 Jun 2010 21:57:33 +0000 (21:57 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 11 Jun 2010 21:57:33 +0000 (21:57 +0000)
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
mod/profile/profile_lib.php
mod/profile/start.php
mod/profile/views/default/profile/profile_content.php [new file with mode: 0644]
mod/profile/views/default/profile/profile_contents/activity.php
mod/profile/views/default/profile/profile_contents/commentwall.php
mod/profile/views/default/profile/profile_contents/details.php
mod/profile/views/default/profile/profile_contents/friends.php
mod/profile/views/default/profile/profile_contents/twitter.php
mod/profile/views/default/profile/sidebar.php [moved from mod/profile/views/default/profile/profile_contents/sidebar.php with 100% similarity]

index df40854ffeff8de2fc4548e4fe19755df2783eb3..d8f4e18486680a6e63066b614333ff0eec3ba9da 100644 (file)
@@ -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.",
index b38286e1e29a99d3b238afa4b2583a0de2bafa01..909191847c1764fcab110f5e26806d411bfe2bc2 100644 (file)
  * @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;
 }
 
index 90caa8f64a9e01cf7d2c82389e6c80c0c5d8f49a..17a55e1f9a956a314ded945a7b1d7d846292bce6 100644 (file)
@@ -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 (file)
index 0000000..4fb43e7
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Wrapper for profile content
+ *
+ * @uses string $vars['content'] - Profile body
+ */
+
+$content = elgg_get_array_value('content', $vars, '');
+
+?>
+<div id="profile_content">
+       <?php echo $content; ?>
+</div>
\ No newline at end of file
index 588ed89d16694e0209dde02ba92df4606d4d2cfe..ccd2a39159be8a201903058f7441e436b90e99a0 100755 (executable)
@@ -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;
-?>
-<div id="profile_content">
-       <?php
-       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 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');
        }
-       ?>
-</div>
+} else {
+       // @todo this should not be here.
+       echo "Riverdashboard not loaded";
+}
\ No newline at end of file
index f3a2adb1c25957f353ff75074e6d30e7544a4751..7e8a1d97d7cf41ce936d35177e0b2ea88b5ca0b0 100644 (file)
@@ -2,12 +2,9 @@
 /**
  * Elgg profile comment wall
  */
-?>
-<div id="profile_content">
-<?php
-if(isloggedin()){
+
+if (isloggedin()) {
        echo elgg_view("profile/commentwall/commentwalladd");
 }
+
 echo elgg_view("profile/commentwall/commentwall", array('annotation' => $vars['comments']));
-?>
-</div>
\ No newline at end of file
index d040cef75a257c7b8783f3ad20b581dddf65610b..6a214557dc912e0f3780ba8b845e71441db30d75 100755 (executable)
@@ -3,54 +3,47 @@
  * Elgg user display (details)
  * @uses $vars['entity'] The user entity
  */
-?>
-<div id="profile_content">
-<?php
-       // 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';
-?>
-                                       <p class="<?php echo $even_odd; ?>">
-                                       <b><?php
-                                                       echo elgg_echo("profile:{$shortname}");
-                                       ?>: </b>
-                                       <?php
-                                               echo elgg_view("output/{$valtype}",array('value' => $vars['entity']->$shortname));
-                                       ?>
-                                       </p>
-                                       <?php
-                               }
-                       }
-               }
-?>
-<?php
-       if (!get_plugin_setting('user_defined_fields', 'profile')) {
-?>
-<?php
-               if ($vars['entity']->isBanned()) {
-                       echo "<div class='banned_user'>";
-                       echo elgg_echo('profile:banned');
-                       echo "</div>";
-               }else{
-                       if($vars['entity']->description){
-                               echo "<p class='aboutme_title'><b>" . elgg_echo("profile:aboutme") . "</b></p>";
-                               echo "<div class='aboutme_contents'>" .elgg_view('output/longtext', array('value' => $vars['entity']->description))."</div>";
+// 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';
+                               ?>
+                               <p class="<?php echo $even_odd; ?>">
+                               <b><?php
+                                               echo elgg_echo("profile:{$shortname}");
+                               ?>: </b>
+                               <?php
+                                       echo elgg_view("output/{$valtype}", array('value' => $vars['entity']->$shortname));
+                               ?>
+                               </p>
+                               <?php
                        }
-       ?>
-<?php } ?>
-       <?php
                }
+       }
+}
 
-       echo "</div>";
\ No newline at end of file
+if (!get_plugin_setting('user_defined_fields', 'profile')) {
+       if ($vars['entity']->isBanned()) {
+               echo "<div class='banned_user'>";
+               echo elgg_echo('profile:banned');
+               echo "</div>";
+       } else {
+               if ($vars['entity']->description) {
+                       echo "<p class='aboutme_title'><b>" . elgg_echo("profile:aboutme") . "</b></p>";
+                       echo "<div class='aboutme_contents'>" . elgg_view('output/longtext', array('value' => $vars['entity']->description)) . "</div>";
+               }
+       }
+}
\ No newline at end of file
index a097f3830e7e20f2681b8c4bb60b5f331d8a6410..9195629e55427883d390adeb738ff8bb06d449be 100755 (executable)
@@ -3,13 +3,10 @@
  * Profile friends
  **/
 
-$friends = list_entities_from_relationship('friend',$vars['entity']->getGUID(),false,'user','',0,10,false);
-if(!$friends)
-       $friends = "<p>This user has not made any friends yet.</p>";
+$friends = list_entities_from_relationship('friend', $vars['entity']->getGUID(), FALSE, 'user', '', 0, 10, FALSE);
 
-?>
-<div id="profile_content">
-       <?php
-               echo $friends;
-       ?>
-</div>
\ No newline at end of file
+if(!$friends) {
+       $friends = '<p>' . elgg_echo('profile:no_friends') . '</p>';
+}
+
+echo $friends;
\ No newline at end of file
index f9b6f5d5451bafd1a8a75f85b95a669748737e5b..06a0551d4501e94abdb4c9b84cbe8b2fd8349ff0 100755 (executable)
@@ -8,12 +8,10 @@ $twitter_username = $vars['entity']->twitter;
 // if the twitter username is empty, then do not show
 if($twitter_username){
 ?>
-<div id="profile_content">
-       <ul id="twitter_update_list"></ul>
-       <p class="visit_twitter"><a href="http://twitter.com/<?php echo $twitter_username; ?>" target="_blank"><?php echo elgg_echo("twitter:visit"); ?></a></p>
-       <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
-       <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/<?php echo $twitter_username; ?>.json?callback=twitterCallback2&count=10"></script>
-</div>
+<ul id="twitter_update_list"></ul>
+<p class="visit_twitter"><a href="http://twitter.com/<?php echo $twitter_username; ?>" target="_blank"><?php echo elgg_echo("twitter:visit"); ?></a></p>
+<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
+<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/<?php echo $twitter_username; ?>.json?callback=twitterCallback2&count=10"></script>
 
 <?php
 }
\ No newline at end of file