diff options
-rw-r--r-- | actions/profile/fields/add.php | 2 | ||||
-rw-r--r-- | actions/profile/fields/edit.php | 20 | ||||
-rw-r--r-- | engine/lib/admin.php | 4 | ||||
-rw-r--r-- | views/default/admin/appearance/profile_fields/list.php | 78 | ||||
-rw-r--r-- | views/default/css/admin.php | 69 | ||||
-rw-r--r-- | views/default/js/admin.php | 53 |
6 files changed, 167 insertions, 59 deletions
diff --git a/actions/profile/fields/add.php b/actions/profile/fields/add.php index 15bd7024a..b35df1549 100644 --- a/actions/profile/fields/add.php +++ b/actions/profile/fields/add.php @@ -20,7 +20,7 @@ if (!$fieldlist) { $id = max($fieldlistarray) + 1; } -if (($label) && ($type)){ +if (($label) && ($type)) { if (!empty($fieldlist)) { $fieldlist .= ','; } diff --git a/actions/profile/fields/edit.php b/actions/profile/fields/edit.php new file mode 100644 index 000000000..5fc84ff11 --- /dev/null +++ b/actions/profile/fields/edit.php @@ -0,0 +1,20 @@ +<?php +/** + * Edit a custom profile field + */ + +$id = get_input('id'); +$label = get_input('label'); + +if (!elgg_get_config("admin_defined_profile_$id")) { + register_error(elgg_echo('profile:editdefault:fail')); + forward(REFERER); +} + +if (elgg_save_config("admin_defined_profile_$id", $label)) { + system_message(elgg_echo('profile:editdefault:success')); +} else { + register_error(elgg_echo('profile:editdefault:fail')); +} + +forward(REFERER);
\ No newline at end of file diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 98247c962..cab6fe4e5 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -94,6 +94,7 @@ function admin_init() { elgg_register_action('profile/fields/reset', '', 'admin'); elgg_register_action('profile/fields/add', '', 'admin'); + elgg_register_action('profile/fields/edit', '', 'admin'); elgg_register_action('profile/fields/delete', '', 'admin'); elgg_register_action('profile/fields/reorder', '', 'admin'); @@ -180,6 +181,9 @@ function admin_settings_page_handler($page) { $url = elgg_view_get_simplecache_url('js', 'admin'); elgg_register_js($url, 'admin'); + $url = elgg_get_site_url() . 'vendors/jquery/jquery.jeditable.mini.js'; + elgg_register_js($url); + // default to dashboard if (!isset($page[0]) || empty($page[0])) { $page = array('dashboard'); diff --git a/views/default/admin/appearance/profile_fields/list.php b/views/default/admin/appearance/profile_fields/list.php index d14452f47..0b27da3ed 100644 --- a/views/default/admin/appearance/profile_fields/list.php +++ b/views/default/admin/appearance/profile_fields/list.php @@ -1,5 +1,7 @@ <?php - +/** + * Profile fields. + */ // List form elements $n = 0; @@ -19,70 +21,30 @@ if ($fieldlist = elgg_get_config('profile_custom_fields')) { } } ?> - -<script language="javascript" type="text/javascript" src="<?php echo elgg_get_site_url()?>vendors/jquery/jquery.jeditable.mini.js"></script> -<script language="javascript" type="text/javascript"> -var reorderURL = '<?php echo elgg_add_action_tokens_to_url(elgg_get_site_url() . 'action/profile/fields/reorder', FALSE); ?>'; -function sortCallback(event, ui) { - var orderArr = $('#sortable_profile_fields').sortable('toArray'); - var orderStr = orderArr.join(','); - jQuery.post(reorderURL, {'fieldorder': orderStr}); -} - -$(document).ready(function() { - $('#sortable_profile_fields').sortable({ - items: 'li', - handle: '.handle', - stop: sortCallback - }); -}); - -</script> - <div id="list"> <ul id="sortable_profile_fields"> <?php - $save = elgg_echo('save'); - $cancel = elgg_echo('cancel'); - $edit_url = elgg_add_action_tokens_to_url(elgg_get_site_url()."action/profile/editdefault/editfield", FALSE); - - foreach($items as $item) { - echo <<< END - -<script language="javascript" type="text/javascript"> - - $(function() { - $(".{$item->shortname}_editable").editable("$edit_url ", { - type : 'text', - submitdata: { _method: "post", 'field': '{$item->shortname}' }, - onblur: 'submit', - width:'300px', - height:'none', - style:'display:inline;', - tooltip:'Click to edit label' - }); - }); - -</script> - -END; - - echo elgg_view("profile/", array('value' => $item->translation)); - - //$even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; - $url = elgg_add_action_tokens_to_url(elgg_get_site_url()."action/profile/fields/delete?id={$item->shortname}"); - echo "<li id=\"{$item->shortname}\"><div class='delete-button'><a href=\"$url\">" . elgg_echo('delete') . "</a></div>"; - echo "<img width='16' height='16' class='handle' alt='move' title='Drag here to reorder this item' src='".elgg_get_site_url()."mod/profile/graphics/drag-handle.png'/>"; - echo "<b class=\"profile_field_editable\"><span class=\"{$item->shortname}_editable\">$item->translation</span></b>: [".elgg_echo($item->type)."]"; - echo "</li>"; - - } +$save = elgg_echo('save'); +$cancel = elgg_echo('cancel'); + +foreach ($items as $item) { + echo elgg_view("profile/", array('value' => $item->translation)); + + //$even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + $url = elgg_add_action_tokens_to_url(elgg_get_site_url() . "action/profile/fields/delete?id={$item->shortname}"); + $type = elgg_echo($item->type); + echo <<<HTML +<li id="$item->shortname" class="clearfix"><span class="elgg-icon elgg-icon-dragger elgg-state-draggable"></span> +<b><span id="elgg-profile-field-{$item->shortname}" class="elgg-state-editable">$item->translation</span></b> [$type] +<a href="$url"><span class="elgg-icon elgg-icon-delete"></a></span> +</li> +HTML; +} ?> </ul> </div> <div id="tempList"></div> -<input name="sortableListOrder" type="hidden" id="sortableListOrder" value="<?php echo $fieldlist; ?>" /> - +<input name="sortableListOrder" type="hidden" id="sortableListOrder" value="<?php echo $fieldlist; ?>" />
\ No newline at end of file diff --git a/views/default/css/admin.php b/views/default/css/admin.php index 9d1c5d23c..39fce2928 100644 --- a/views/default/css/admin.php +++ b/views/default/css/admin.php @@ -1120,3 +1120,72 @@ ul.admin_plugins { .elgg-col-5of6 { width: 83.33%; } + +/* *************************************** + Icons +*************************************** */ +.elgg-icon { + background: transparent url(<?php echo elgg_get_site_url(); ?>_graphics/elgg_sprites.png) no-repeat left; + width: 16px; + height: 16px; + display: block; + float: left; + margin: 0 2px; +} +.elgg-icon-settings { + background-position: -302px -44px; +} +.elgg-icon-friends { + background-position: 0 -300px; + width: 36px; +} +.elgg-icon-friends:hover { + background-position: 0 -340px; +} +.elgg-icon-help { + background-position: -302px -136px; +} +.elgg-icon-delete { + background-position: -199px 1px; +} +.elgg-icon-delete:hover { + background-position: -199px -15px; +} +.elgg-icon-likes { + background-position: 0px -101px; + width: 20px; + height: 20px; +} +.elgg-icon-likes:hover { + background-position: 0px -131px; +} +.elgg-icon-liked { + background-position: 0px -131px; + width: 20px; + height: 20px; +} +.elgg-icon-arrow-s { + background-position: -146px -56px; +} +.elgg-icon-arrow-s:hover { + background-position: -146px -76px; +} +.elgg-icon-following { + background-position: -35px -100px; + width: 22px; + height: 20px; +} +.elgg-icon-rss { + background-position: -249px 1px; +} +.elgg-icon-hover-menu { + background-position: -150px 0; +} +.elgg-icon-hover-menu:hover { + background-position: -150px -32px; +} +.elgg-icon-dragger { + background-position: -302px -186px; + width: 21px; + height: 21px; +}
\ No newline at end of file diff --git a/views/default/js/admin.php b/views/default/js/admin.php index 46e82c71b..ca690c876 100644 --- a/views/default/js/admin.php +++ b/views/default/js/admin.php @@ -13,6 +13,7 @@ elgg.admin.init = function () { elgg_slide_toggle($(this), '.plugin_details', '.manifest_file'); }); + // plugin screenshot modal $('.elgg-plugin-screenshot a').click(elgg.admin.displayPluginScreenshot); // draggable plugin reordering @@ -25,6 +26,22 @@ elgg.admin.init = function () { revert: 500, stop: elgg.admin.movePlugin }); + + // in-line editing for custom profile fields. + $(".elgg-state-editable").editable(elgg.admin.editProfileField, { + type: 'text', + onblur: 'submit', + width: '300px', + height: 'none', + style: 'display:inline;' + }); + + // draggable profile field reordering. + $('#sortable_profile_fields').sortable({ + items: 'li', + handle: 'span.elgg-state-draggable', + stop: elgg.admin.moveProfileField + }); } /** @@ -90,4 +107,40 @@ elgg.admin.displayPluginScreenshot = function(e) { lb.css('top', top_pos).css('left', left_pos).show(); }; +/** + * In-line editing for custom profile fields + * + * @param string value The new value + * @param {Object} settings The settings used for editable + * @return void + */ +elgg.admin.editProfileField = function(value, settings) { + var id = $(this).attr('id'); + id = id.replace('elgg-profile-field-', ''); + + var data = { + id: id, + label: value + }; + + elgg.action('profile/fields/edit', data); + return value; +} + +/** + * Save the plugin profile order after a move event. + * + * @param {Object} e Event object. + * @param {Object} ui jQueryUI object + * @return void + */ +elgg.admin.moveProfileField = function(e, ui) { + var orderArr = $('#sortable_profile_fields').sortable('toArray'); + var orderStr = orderArr.join(','); + + elgg.action('profile/fields/reorder', { + fieldorder: orderStr + }); +} + elgg.register_event_handler('init', 'system', elgg.admin.init);
\ No newline at end of file |