From 220751fbacd3ea18ace64c4111fb1feb3bbd48bd Mon Sep 17 00:00:00 2001 From: Matthew Juhl <mjuhl24@gmail.com> Date: Tue, 27 Apr 2010 23:53:07 +0000 Subject: [PATCH] Modifications of profile editor. Still a few things to work out in enhanceProfileForm.js. --- .../scripts/JS/enhanceProfileForm.php | 39 +++++------- .../views/default/form/display_field.php | 31 ++++++++++ .../views/default/form/input/shorttext.php | 32 ++++++++++ .../views/default/page_elements/header.php | 16 ----- .../unl_theme/views/default/profile/edit.php | 62 +++++++++++++++++++ 5 files changed, 139 insertions(+), 41 deletions(-) create mode 100644 plugins/unl_theme/views/default/form/display_field.php create mode 100644 plugins/unl_theme/views/default/form/input/shorttext.php create mode 100644 plugins/unl_theme/views/default/profile/edit.php diff --git a/plugins/unl_theme/scripts/JS/enhanceProfileForm.php b/plugins/unl_theme/scripts/JS/enhanceProfileForm.php index 0ea2aec6..437b3954 100644 --- a/plugins/unl_theme/scripts/JS/enhanceProfileForm.php +++ b/plugins/unl_theme/scripts/JS/enhanceProfileForm.php @@ -1,13 +1,18 @@ <script type="text/javascript"> (function(){ + // Edit Profile Stuff + function updateLL () { var city = $("input[name=form_data_profile_city]").val(), state = $("select[name=form_data_profile_state]").val(), country = $("select[name=form_data_profile_country]").val(); + + $.get("<?php echo $vars['url']; ?>mod/unl_theme/scripts/latlon.php",{city:city,state:state,country:country},function(response){ try { var data = eval(response); $("input[name=form_data_latitude]").val(data.latitude); $("input[name=form_data_longitude]").val(data.longitude); + WDN.log("Long/lat: " + data.latitude + "/" + data.longitude); } catch (e) {} }); }; @@ -19,6 +24,7 @@ var data = eval(response); $("input[name=form_data_hometown_latitude]").val(data.latitude); $("input[name=form_data_hometown_longitude]").val(data.longitude); + WDN.log("Long/lat: " + data.latitude + "/" + data.longitude); } catch (e) {} }); }; @@ -40,23 +46,6 @@ $("input[name=form_data_profile_dob_year]").remove(); - - - // wrap the fields in <li>s - $("form.cool label").wrap("<li></li>").addClass("element"); - $("form.cool label br").remove(); - $("form.cool p.form-field-description").each(function(){ - $(this).appendTo($(this).prev())/*.css({ - - fontSize: "75%", - color: "#1091D1" - })*/; - }); - - $("form.cool fieldset input[type!=submit], form.cool fieldset select, form.cool fieldset textarea").wrap('<div class="element"></div>'); - $("form.cool label div").each(function(){ - $(this).insertAfter($(this).parent()); - }); // remove the country input var country_parent = $("input[name=form_data_profile_country]").parent(); @@ -72,9 +61,7 @@ var to_parent = $("input[name=form_data_profile_attended_to]").parent(); $("input[name=form_data_profile_attended_to]").remove(); - $("input[name=form_data_map_explanation]").parent().parent().css("border-bottom","#CCC 1px dotted"); - $("input[name=form_data_profile_city]").parent().parent().prepend('<h6><strong>Your Map Location</strong></h6>' - + '<p>Please enter the location you want to use for yourself on the map.</p>'); + $("input[name=form_data_profile_city]").parent().find("label").html('Your map location <span class="helper">Please enter the location you want to use for yourself on the map</span>'); /* set up various year inputs */ @@ -126,7 +113,7 @@ $(selTo).html(html); from_parent.append(" to "); from_parent.append(selTo); - to_parent.parent().remove(); + //to_parent.parent().remove(); var states = ["AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"]; @@ -394,13 +381,15 @@ $("input[name=form_data_profile_dob_day]").insertBefore($("select[name=form_data_profile_dob_year]")); // don't display the latitude/longitude fields - $("input[name=form_data_latitude],input[name=form_data_longitude]").parent().parent().hide(); + $("input[name=form_data_latitude],input[name=form_data_longitude]").parent().hide(); + // update the lat/long automatically whenever current location is changed $("input[name=form_data_profile_city],select[name=form_data_profile_state],select[name=form_data_profile_country]").change(function(){ updateLL(); }); - $("input[name=form_data_hometown_latitude],input[name=form_data_hometown_longitude]").parent().parent().hide(); + $("input[name=form_data_hometown_latitude],input[name=form_data_hometown_longitude]").parent().hide(); + // update the lat/long automatically whenever current location is changed $("input[name=form_data_profile_homecity],select[name=form_data_profile_homestate],select[name=form_data_profile_homecountry]").change(function(){ updateLLhome(); @@ -484,9 +473,9 @@ $("input[name=form_data_info_alumni_opt_in]").parent().parent().children("label").css("width","350px"); function alumniCheckbox () { if ($("select[name=form_data_profile_role]").val() == "Alumnus") { - $("input[name=form_data_info_alumni_opt_in]").parent().parent().show(); + $("input[name=form_data_info_alumni_opt_in]").parent().show(); } else { - $("input[name=form_data_info_alumni_opt_in]").parent().parent().hide(); + $("input[name=form_data_info_alumni_opt_in]").parent().hide(); } }; diff --git a/plugins/unl_theme/views/default/form/display_field.php b/plugins/unl_theme/views/default/form/display_field.php new file mode 100644 index 00000000..51ba3573 --- /dev/null +++ b/plugins/unl_theme/views/default/form/display_field.php @@ -0,0 +1,31 @@ +<?php + +/** + * Elgg field display + * Displays the specified Elgg title, field and description + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + $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 +<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/unl_theme/views/default/form/input/shorttext.php b/plugins/unl_theme/views/default/form/input/shorttext.php new file mode 100644 index 00000000..3be5c7f8 --- /dev/null +++ b/plugins/unl_theme/views/default/form/input/shorttext.php @@ -0,0 +1,32 @@ +<?php + + /** + * Elgg text input + * Displays a text input field + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['disabled'] If true then control is read-only + * @uses $vars['class'] Class override + */ + + + $class = $vars['class']; + if (!$class) $class = "input-text"; + if (isset($vars['internalid'])) { + $id_bit = ' id = "'.$vars['internalid'].'" '; + } else { + $id_bit = ''; + } + +?> + +<input type="text" <?php echo $id_bit; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" value="<?php echo htmlentities($vars['value'], null, 'UTF-8'); ?>" class="<?php echo $class ?>"/> \ No newline at end of file diff --git a/plugins/unl_theme/views/default/page_elements/header.php b/plugins/unl_theme/views/default/page_elements/header.php index b3afc271..4a99e513 100644 --- a/plugins/unl_theme/views/default/page_elements/header.php +++ b/plugins/unl_theme/views/default/page_elements/header.php @@ -72,22 +72,6 @@ if (preg_match('/friend/', $vars['title'])) { // if on a friends page, interst l ?> <style type="text/css"> - #maincontent form.cool { - display: none; - } - - #maincontent form.cool div.element { - __margin: 0; - } - - #maincontent form.cool label { - vertical-align: inherit !important; - } - - #maincontent form.cool fieldset li { - padding-bottom: 15px; - - } #maincontent form.cool input[name$="city"] { text-transform: capitalize; diff --git a/plugins/unl_theme/views/default/profile/edit.php b/plugins/unl_theme/views/default/profile/edit.php new file mode 100644 index 00000000..f10e367e --- /dev/null +++ b/plugins/unl_theme/views/default/profile/edit.php @@ -0,0 +1,62 @@ +<?php +/** + * Elgg flex profile edit form + * Allows user to edit profile + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +/* copied from flexprofile and modified for UNL */ + + // Load flexprofile model +require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/flexprofile/models/model.php"); +include(dirname(dirname(dirname(dirname(dirname(__FILE__))))).'/unl_theme/scripts/JS/enhanceProfileForm.php'); + + +$user = $vars['entity']; +$form = flexprofile_get_profile_form($user); +if ($form) { + $tab_data = flexprofile_get_data_for_edit_form($form, $user); + +if ($_GET['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> +<?php +} + +//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 cool">'; + +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 +} +echo "</ol></fieldset>"; +?> + + <p> + <input type="hidden" name="username" value="<?php echo page_owner_entity()->username; ?>" /> + <input type="submit" value="<?php echo elgg_echo("save"); ?>" /> + </p> + +<?php +echo '</form>'; +} else { + echo elgg_echo('form:error_no_profile_form'); +} + + +?> \ No newline at end of file -- GitLab