From eaf761f717ef56545ae4c4c69948ddd6f272c74e Mon Sep 17 00:00:00 2001
From: Matthew Juhl <mjuhl24@gmail.com>
Date: Tue, 4 May 2010 16:49:32 +0000
Subject: [PATCH] Get edit profile working on mobile!!

---
 .../views/mobile/form/display_field.php       | 13 ++--
 .../form/forms/display_form_content.php       |  6 ++
 .../mobile_unl/views/mobile/profile/edit.php  | 61 +++++--------------
 3 files changed, 31 insertions(+), 49 deletions(-)

diff --git a/plugins/mobile_unl/views/mobile/form/display_field.php b/plugins/mobile_unl/views/mobile/form/display_field.php
index 8e3085ec..51ba3573 100755
--- a/plugins/mobile_unl/views/mobile/form/display_field.php
+++ b/plugins/mobile_unl/views/mobile/form/display_field.php
@@ -15,12 +15,17 @@
 	 $field = $vars['field'];
 	 $title = $vars['title'];
 	 $description = $vars['description'];
+	 $internalname = preg_replace('/\<[\w\W]+name="/i','',$vars['field']);
+	 $internalname = trim(preg_replace('/"[\W\w]*\>/i','',$internalname));
 	 
 	 $body = <<<END
-<label>$title<br />
-$field
-</label>
-<p class="form-field-description">$description</p>
+<li>
+	<label for="$internalname">
+	 	$title
+	 	<span class="helper">$description</span>
+	 </label>
+	$field
+</li>
 END;
     print $body;
 ?>
\ No newline at end of file
diff --git a/plugins/mobile_unl/views/mobile/form/forms/display_form_content.php b/plugins/mobile_unl/views/mobile/form/forms/display_form_content.php
index 1960df38..a0b900ed 100644
--- a/plugins/mobile_unl/views/mobile/form/forms/display_form_content.php
+++ b/plugins/mobile_unl/views/mobile/form/forms/display_form_content.php
@@ -33,6 +33,8 @@ $body .= elgg_view('input/hidden',array('internalname'=>'preview', 'value'=>$pre
 $body .= elgg_view('input/hidden',array('internalname'=>'form_data_id', 'value'=>$form_data_id));
 $body .= "<p class=\"form-description\">$description</p>";
 
+/*
+
 if (count($tab_data) > 1) {
 	$body .= <<<END
 	<script type="text/javascript" src="{$CONFIG->wwwroot}mod/form/tabber/tabber.js"></script>
@@ -53,5 +55,9 @@ END;
 		$body .= $html;
 	}
 }
+
+*/
+$body .= $tab_data['main']["Basic"];
+
 echo $body;
 ?>
\ No newline at end of file
diff --git a/plugins/mobile_unl/views/mobile/profile/edit.php b/plugins/mobile_unl/views/mobile/profile/edit.php
index 62593b96..6cd800d7 100644
--- a/plugins/mobile_unl/views/mobile/profile/edit.php
+++ b/plugins/mobile_unl/views/mobile/profile/edit.php
@@ -1,7 +1,6 @@
 <?php
 /**
 	 * Elgg flex profile edit form
-	 * Modified for UNL mobile planetred
 	 * Allows user to edit profile
 	 * 
 	 * @package Elgg
@@ -13,72 +12,44 @@
 	 */
 
 	 // Load flexprofile model
-	 
 require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/flexprofile/models/model.php");
 
 $user = $vars['entity'];
 $form = flexprofile_get_profile_form($user);
 if ($form) {
 	$tab_data = flexprofile_get_data_for_edit_form($form, $user);
-/* mjuhl: begin modification for UNL */
-// nope, remove this:
-//echo '<div class="contentWrapper">';
-if ($_GET['firstlogin'] == 'yes'){
+
+if (get_input('firstlogin') == 'yes') {
 ?>
 <div class="zenbox soothing">
 	<h3>Thanks for joining Planet Red!</h3>
 	<p>You're just a few quick steps from putting yourself on the map. Start by filling out your profile information.</p>
-</div>
+</div><br /><br />
 <?php 
 }
-/* import forms css */
-//////////echo '<style type="text/css">@IMPORT url("/wdn/templates_3.0/css/content/forms.css");</style>';
-/* add 'cool' class to form */
-//////////echo '<div id="formloading"><img src="/wdn/templates_3.0/css/header/images/colorbox/loading.gif" alt="Loading Form" /><noscript>Please enable JavaScript to use the profile editor.</noscript></div>';
-echo '<form style="margin-top: 24px" action="'.$vars['url'].'action/flexprofile/edit" method="post" enctype="multipart/form-data" class="cool">';
-/* add fieldset and legend */
-echo '<fieldset><legend>Edit Information</legend><ol>';
+//echo '<div id="formloading"><img src="/wdn/templates_3.0/css/header/images/colorbox/loading.gif" alt="Loading Form" /><noscript>Please enable JavaScript to use the profile editor.</noscript></div>';
+echo '<form action="'.$vars['url'].'action/flexprofile/edit" method="post" enctype="multipart/form-data" class="zenform primary" id="profileEditor" >';
 
+echo elgg_view('input/securitytoken');
+echo '<fieldset><ol>';
 echo elgg_view('form/forms/display_form_content',array('tab_data'=>$tab_data,'description'=>'','preview'=>0,'form'=>$form,'form_data_id'=>0));
 
-if ($_GET['firstlogin'] == 'yes'){
-?>
-<input type="hidden" name="firstlogin" value="yes" />
-<?php 
+if (get_input('firstlogin') == 'yes') {
+    echo '<input type="hidden" name="firstlogin" value="yes" />';
 }
+echo '</ol></fieldset>';
 ?>
-<input type="hidden"  name="form_id"  value="104" /> <input type="hidden"  name="preview"  value="0" /> <input type="hidden"  name="form_data_id"  value="0" />
-<input type="hidden" name="username" value="<?php echo page_owner_entity()->username; ?>" />
-</fieldset>
-<?php 
 
-?>
-	<p class="submit">
-		
+	<p>
+		<input type="hidden" name="username" value="<?php echo page_owner_entity()->username; ?>" />
 		<input type="submit" value="<?php echo elgg_echo("save"); ?>" />
-		
-		
 	</p>
-	
-	
-	</ol>
-</form>	
-<script type="text/javascript" src="/wdn/templates_3.0/scripts/jquery.js"></script>
-<script type="text/javascript" src="http://ucommjuhl.unl.edu/planetred/elgg/mod/unl_theme/scripts/JS/enhanceProfileForm.php"></script>
-<script type="text/javascript">$("p.form-field-description").css({"margin-top": "1px", "margin-left": "1px", "margin": "0px"});</script>
-<noscript>
-<p>Sorry, the profile editor requires JavaScript. Please enable JavaScript in your browser, or sign in to Planet Red with a browser that supports JavaScript.</p>
-<style type="text/css">
-form.cool {
-	display: none;
-}
-</style>
-</noscript>
+
 <?php
+echo '</form>';
 } else {
 	echo elgg_echo('form:error_no_profile_form');
 }
-// once again, nope:
-//echo '</div>';
-/* mjuhl: end modification */
+
+require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/unl_theme/scripts/JS/enhanceProfileForm.php');
 ?>
\ No newline at end of file
-- 
GitLab