diff options
Diffstat (limited to 'views/default/input')
27 files changed, 759 insertions, 199 deletions
diff --git a/views/default/input/access.php b/views/default/input/access.php index 7fa2323bf..137eea288 100644 --- a/views/default/input/access.php +++ b/views/default/input/access.php @@ -3,21 +3,30 @@ * Elgg access level input * Displays a dropdown input field * - * @package Elgg - * @subpackage Core - * - * @uses $vars['value'] The current value, if any - * @uses $vars['options_values'] - * @uses $vars['name'] The name of the input field + * @uses $vars['value'] The current value, if any + * @uses $vars['options_values'] Array of value => label pairs (overrides default) + * @uses $vars['name'] The name of the input field + * @uses $vars['entity'] Optional. The entity for this access control (uses access_id) + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-access {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-access"; +} + $defaults = array( - 'class' => 'elgg-input-access', - 'disabled' => FALSE, + 'disabled' => false, 'value' => get_default_access(), 'options_values' => get_write_access_array(), ); +if (isset($vars['entity'])) { + $defaults['value'] = $vars['entity']->access_id; + unset($vars['entity']); +} + $vars = array_merge($defaults, $vars); if ($vars['value'] == ACCESS_DEFAULT) { @@ -26,4 +35,4 @@ if ($vars['value'] == ACCESS_DEFAULT) { if (is_array($vars['options_values']) && sizeof($vars['options_values']) > 0) { echo elgg_view('input/dropdown', $vars); -}
\ No newline at end of file +} diff --git a/views/default/input/autocomplete.php b/views/default/input/autocomplete.php index 1093de2d3..e58eb1ae8 100644 --- a/views/default/input/autocomplete.php +++ b/views/default/input/autocomplete.php @@ -7,35 +7,43 @@ * * @todo This currently only works for ONE AUTOCOMPLETE TEXT FIELD on a page. * - * @uses $vars['match_on'] Array | str What to match on. all|array(groups|users|friends|subtype) + * @uses $vars['value'] Current value for the text input + * @uses $vars['match_on'] Array | str What to match on. all|array(groups|users|friends) * @uses $vars['match_owner'] Bool. Match only entities that are owned by logged in user. - * + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-autocomplete {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-autocomplete"; +} + $defaults = array( - 'class' => '', 'value' => '', + 'disabled' => false, ); $vars = array_merge($defaults, $vars); -$vars['class'] = trim("elgg-input-autocomplete {$vars['class']}"); - -$ac_url_params = http_build_query(array( - 'match_on' => $vars['match_on'], - 'match_owner' => $vars['match_owner'], -)); +$params = array(); +if (isset($vars['match_on'])) { + $params['match_on'] = $vars['match_on']; + unset($vars['match_on']); +} +if (isset($vars['match_owner'])) { + $params['match_owner'] = $vars['match_owner']; + unset($vars['match_owner']); +} +$ac_url_params = http_build_query($params); -unset($vars['match_on']); -unset($vars['match_owner']); - -elgg_register_js('js/lib/autocomplete.js', 'autocomplete', 'head'); +elgg_load_js('elgg.autocomplete'); +elgg_load_js('jquery.ui.autocomplete.html'); ?> <script type="text/javascript"> elgg.provide('elgg.autocomplete'); -elgg.autocomplete.url = "<?php elgg_get_site_url() . 'pg/livesearch?' . $ac_url_params; ?>"; +elgg.autocomplete.url = "<?php echo elgg_get_site_url() . 'livesearch?' . $ac_url_params; ?>"; </script> <input type="text" <?php echo elgg_format_attributes($vars); ?> /> - diff --git a/views/default/input/button.php b/views/default/input/button.php index 52a85ace6..9957fdc54 100644 --- a/views/default/input/button.php +++ b/views/default/input/button.php @@ -5,12 +5,18 @@ * @package Elgg * @subpackage Core * - * @uses $vars['src'] Src of an image + * @uses $vars['src'] Src of an image + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-button {$vars['class']}"; +} else { + $vars['class'] = "elgg-button"; +} + $defaults = array( 'type' => 'button', - 'class' => 'elgg-button-submit', ); $vars = array_merge($defaults, $vars); @@ -27,8 +33,8 @@ switch ($vars['type']) { } // blank src if trying to access an offsite image. @todo why? -if (strpos($vars['src'], elgg_get_site_url()) === false) { +if (isset($vars['src']) && strpos($vars['src'], elgg_get_site_url()) === false) { $vars['src'] = ""; } ?> -<input <?php echo elgg_format_attributes($vars); ?> />
\ No newline at end of file +<input <?php echo elgg_format_attributes($vars); ?> /> diff --git a/views/default/input/calendar.php b/views/default/input/calendar.php index 553a254ce..52c84ff82 100644 --- a/views/default/input/calendar.php +++ b/views/default/input/calendar.php @@ -1,6 +1,6 @@ <?php -// @deprecated Use datepicker instead. +// @deprecated Use input/date instead. -elgg_deprecated_notice('view: input/calendar is deprecated by input/datepicker', 1.8); +elgg_deprecated_notice('view: input/calendar is deprecated by input/date', 1.8); echo elgg_view('input/datepicker', $vars);
\ No newline at end of file diff --git a/views/default/input/captcha.php b/views/default/input/captcha.php index 210e0f50a..1c2e22aaa 100644 --- a/views/default/input/captcha.php +++ b/views/default/input/captcha.php @@ -1,6 +1,6 @@ <?php /** - * This view provides a hook for third parties to provide captcha behaviour. + * This view provides a hook for third parties to provide a CAPTCHA. * * @package Elgg * @subpackage Core diff --git a/views/default/input/checkbox.php b/views/default/input/checkbox.php index 898fe8458..3dc75c6c3 100644 --- a/views/default/input/checkbox.php +++ b/views/default/input/checkbox.php @@ -10,13 +10,20 @@ * Pass input tag attributes as key value pairs. For a list of allowable * attributes, see http://www.w3schools.com/tags/tag_input.asp * - * @uses mixed $vars['default'] The default value to submit if not checked. - * Optional, defaults to 0. Set to false for no default. + * @uses $vars['default'] The default value to submit if not checked. + * Optional, defaults to 0. Set to false for no default. + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-checkbox {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-checkbox"; +} + $defaults = array( - 'class' => 'elgg-input-checkbox', 'default' => 0, + 'disabled' => false, ); $vars = array_merge($defaults, $vars); @@ -29,5 +36,4 @@ if (isset($vars['name']) && $default !== false) { } ?> - -<input type="checkbox" <?php echo elgg_format_attributes($vars); ?> />
\ No newline at end of file +<input type="checkbox" <?php echo elgg_format_attributes($vars); ?> /> diff --git a/views/default/input/checkboxes.php b/views/default/input/checkboxes.php index c78fe4db0..db4b06949 100644 --- a/views/default/input/checkboxes.php +++ b/views/default/input/checkboxes.php @@ -15,68 +15,76 @@ * @package Elgg * @subpackage Core * - * @uses string $vars['name'] The name of the input fields - * (Forced to an array by appending []) - * @uses array $vars['options'] An array of strings representing the - * label => option for the each checkbox field - * @uses string $vars['id'] The id for each input field. Optional. - * (Only use this with a single value.) - * @uses string $vars['default'] The default value to send if nothing is checked. - * Optional, defaults to 0. Set to FALSE for no default. - * @uses bool $vars['disabled'] Make all input elements disabled. Optional. - * @uses string $vars['value'] The current value. Optional. - * @uses string $vars['class'] Additional class of the list. Optional. - * @uses string $vars['align'] 'horizontal' or 'vertical' Default: 'vertical' + * @uses string $vars['name'] The name of the input fields + * (Forced to an array by appending []) + * @uses array $vars['options'] An array of strings representing the + * label => option for the each checkbox field + * @uses string $vars['default'] The default value to send if nothing is checked. + * Optional, defaults to 0. Set to FALSE for no default. + * @uses bool $vars['disabled'] Make all input elements disabled. Optional. + * @uses string $vars['value'] The current value. Single value or array. Optional. + * @uses string $vars['class'] Additional class of the list. Optional. + * @uses string $vars['align'] 'horizontal' or 'vertical' Default: 'vertical' * */ -$additional_class = elgg_extract('class', $vars); -$align = elgg_extract('align', $vars, 'vertical'); -$value = (isset($vars['value'])) ? $vars['value'] : NULL; -$value_array = (is_array($value)) ? array_map('elgg_strtolower', $value) : array(elgg_strtolower($value)); -$name = (isset($vars['name'])) ? $vars['name'] : ''; -$options = (isset($vars['options']) && is_array($vars['options'])) ? $vars['options'] : array(); -$default = (isset($vars['default'])) ? $vars['default'] : 0; +$defaults = array( + 'align' => 'vertical', + 'value' => array(), + 'default' => 0, + 'disabled' => false, + 'options' => array(), + 'name' => '', +); -$id = (isset($vars['id'])) ? $vars['id'] : ''; -$disabled = (isset($vars['disabled'])) ? $vars['disabled'] : FALSE; -$js = (isset($vars['js'])) ? $vars['js'] : ''; +$vars = array_merge($defaults, $vars); -$class = "elgg-input-checkboxes elgg-$align"; -if ($additional_class) { - $class = " $additional_class"; +$class = "elgg-input-checkboxes elgg-{$vars['align']}"; +if (isset($vars['class'])) { + $class .= " {$vars['class']}"; + unset($vars['class']); } -if ($options && count($options) > 0) { +$id = ''; +if (isset($vars['id'])) { + $id = "id=\"{$vars['id']}\""; + unset($vars['id']); +} + +if (is_array($vars['value'])) { + $values = array_map('elgg_strtolower', $vars['value']); +} else { + $values = array(elgg_strtolower($vars['value'])); +} + +$input_vars = $vars; +$input_vars['default'] = false; +if ($vars['name']) { + $input_vars['name'] = "{$vars['name']}[]"; +} +unset($input_vars['align']); +unset($input_vars['options']); + +if (count($vars['options']) > 0) { // include a default value so if nothing is checked 0 will be passed. - if ($name && $default !== FALSE) { - echo "<input type=\"hidden\" name=\"$name\" value=\"$default\" />"; + if ($vars['name'] && $vars['default'] !== false) { + echo "<input type=\"hidden\" name=\"{$vars['name']}\" value=\"{$vars['default']}\" />"; } - echo "<ul class=\"$class\">"; - foreach ($options as $label => $option) { + echo "<ul class=\"$class\" $id>"; + foreach ($vars['options'] as $label => $value) { // @deprecated 1.8 Remove in 1.9 if (is_integer($label)) { elgg_deprecated_notice('$vars[\'options\'] must be an associative array in input/checkboxes', 1.8); - $label = $option; + $label = $value; } - $input_vars = array( - 'checked' => in_array(elgg_strtolower($option), $value_array), - 'value' => $option, - 'disabled' => $disabled, - 'id' => $id, - 'js' => $js, - 'default' => false, - ); - - if ($name) { - $input_vars['name'] = "{$name}[]"; - } + $input_vars['checked'] = in_array(elgg_strtolower($value), $values); + $input_vars['value'] = $value; $input = elgg_view('input/checkbox', $input_vars); - echo "<li><label>{$input}{$label}</label></li>"; + echo "<li><label>$input$label</label></li>"; } echo '</ul>'; -}
\ No newline at end of file +} diff --git a/views/default/input/date.php b/views/default/input/date.php new file mode 100644 index 000000000..828ce5520 --- /dev/null +++ b/views/default/input/date.php @@ -0,0 +1,56 @@ +<?php +/** + * Elgg date input + * Displays a text field with a popup date picker. + * + * The elgg.ui JavaScript library initializes the jQueryUI datepicker based + * on the CSS class .elgg-input-date. It uses the ISO 8601 standard for date + * representation: yyyy-mm-dd. + * + * Unix timestamps are supported by setting the 'timestamp' parameter to true. + * The date is still displayed to the user in a text format but is submitted as + * a unix timestamp in seconds. + * + * @uses $vars['value'] The current value, if any (as a unix timestamp) + * @uses $vars['class'] Additional CSS class + * @uses $vars['timestamp'] Store as a Unix timestamp in seconds. Default = false + * Note: you cannot use an id with the timestamp option. + */ + +//@todo popup_calendar deprecated in 1.8. Remove in 2.0 +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-date popup_calendar {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-date popup_calendar"; +} + +$defaults = array( + 'value' => '', + 'disabled' => false, + 'timestamp' => false, +); + +$vars = array_merge($defaults, $vars); + +$timestamp = $vars['timestamp']; +unset($vars['timestamp']); + +if ($timestamp) { + echo elgg_view('input/hidden', array( + 'name' => $vars['name'], + 'value' => $vars['value'], + )); + + $vars['class'] = "{$vars['class']} elgg-input-timestamp"; + $vars['id'] = $vars['name']; + unset($vars['name']); + unset($vars['internalname']); +} + +// convert timestamps to text for display +if (is_numeric($vars['value'])) { + $vars['value'] = gmdate('Y-m-d', $vars['value']); +} + +$attributes = elgg_format_attributes($vars); +echo "<input type=\"text\" $attributes />"; diff --git a/views/default/input/datepicker.php b/views/default/input/datepicker.php index 4af54096b..8955e6e53 100644 --- a/views/default/input/datepicker.php +++ b/views/default/input/datepicker.php @@ -1,37 +1,6 @@ <?php /** - * Elgg datepicker input - * Displays a text field with a popup date picker. - * - * @package Elgg - * @subpackage Core - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['name'] The name of the input field - * + * @deprecated use input/date instead */ - -$cal_name = sanitise_string($vars['name']); - -if (isset($vars['class'])) { - $class = "{$vars['class']} popup_calendar"; -} else { - $class = 'popup_calendar'; -} - -if ($vars['value'] > 86400) { - //$val = date("F j, Y", $vars['value']); - $val = date('n/d/Y', $vars['value']); -} else { - $val = $vars['value']; -} - -?> -<input type="text" name="<?php echo $vars['name']; ?>" value="<?php echo $val; ?>" /> -<?php //@todo JS 1.8: no ?> -<script type="text/javascript"> - $(document).ready(function() { - $('input[type=text][name=<?php echo $cal_name; ?>]').datepicker(); - }); -</script> +elgg_deprecated_notice('input/datepicker was deprecated in favor of input/date', 1.8); +echo elgg_view('input/date', $vars);
\ No newline at end of file diff --git a/views/default/input/dropdown.php b/views/default/input/dropdown.php index 6fd97d3b5..9f07874f1 100644 --- a/views/default/input/dropdown.php +++ b/views/default/input/dropdown.php @@ -3,7 +3,7 @@ * Elgg dropdown input * Displays a dropdown (select) input field * - * NB: Default values of FALSE or NULL will match '' (empty string) and not 0. + * @warning Default values of FALSE or NULL will match '' (empty string) but not 0. * * @package Elgg * @subpackage Core @@ -11,16 +11,27 @@ * @uses $vars['value'] The current value, if any * @uses $vars['options'] An array of strings representing the options for the dropdown field * @uses $vars['options_values'] An associative array of "value" => "option" - * where "value" is an internal name and "option" is + * where "value" is the name and "option" is * the value displayed on the button. Replaces * $vars['options'] when defined. + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-dropdown {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-dropdown"; +} + $defaults = array( - 'class' => 'elgg-input-dropdown', - 'disabled' => FALSE, + 'disabled' => false, + 'value' => '', + 'options_values' => array(), + 'options' => array(), ); +$vars = array_merge($defaults, $vars); + $options_values = $vars['options_values']; unset($vars['options_values']); @@ -30,10 +41,8 @@ unset($vars['options']); $value = $vars['value']; unset($vars['value']); -$attrs = array_merge($defaults, $vars); - ?> -<select <?php echo elgg_format_attributes($attrs); ?>> +<select <?php echo elgg_format_attributes($vars); ?>> <?php if ($options_values) { @@ -47,13 +56,15 @@ if ($options_values) { echo "<option $option_attrs>$option</option>"; } } else { - foreach ($options as $option) { + if (is_array($options)) { + foreach ($options as $option) { - $option_attrs = elgg_format_attributes(array( - 'selected' => (string)$option == (string)$value - )); + $option_attrs = elgg_format_attributes(array( + 'selected' => (string)$option == (string)$value + )); - echo "<option $option_attrs>$option</option>"; + echo "<option $option_attrs>$option</option>"; + } } } ?> diff --git a/views/default/input/email.php b/views/default/input/email.php index a6097143a..190fb88c6 100644 --- a/views/default/input/email.php +++ b/views/default/input/email.php @@ -5,11 +5,18 @@ * * @package Elgg * @subpackage Core + * + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-email {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-email"; +} + $defaults = array( - 'class' => 'elgg-input-email', - 'disabled' => FALSE, + 'disabled' => false, ); $vars = array_merge($defaults, $vars); diff --git a/views/default/input/file.php b/views/default/input/file.php index 4c42042e8..452fe72b9 100644 --- a/views/default/input/file.php +++ b/views/default/input/file.php @@ -7,20 +7,25 @@ * @subpackage Core * * @uses $vars['value'] The current value if any - * + * @uses $vars['class'] Additional CSS class */ if (!empty($vars['value'])) { echo elgg_echo('fileexists') . "<br />"; } +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-file {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-file"; +} + $defaults = array( - 'class' => 'elgg-input-file', - 'disabled' => FALSE, - 'size' => 30, + 'disabled' => false, + 'size' => 30, ); $attrs = array_merge($defaults, $vars); ?> -<input type="file" <?php echo elgg_format_attributes($attrs)?> />
\ No newline at end of file +<input type="file" <?php echo elgg_format_attributes($attrs); ?> /> diff --git a/views/default/input/form.php b/views/default/input/form.php index 6d5824cd8..df30133b3 100644 --- a/views/default/input/form.php +++ b/views/default/input/form.php @@ -1,14 +1,17 @@ <?php /** * Create a form for data submission. - * Use this view for forms rather than creating a form tag in the wild as it provides - * extra security which help prevent CSRF attacks. + * Use this view for forms as it provides protection against CSRF attacks. * * @package Elgg * @subpackage Core * * @uses $vars['body'] The body of the form (made up of other input/xxx views and html + * @uses $vars['action'] The action URL of the form + * @uses $vars['method'] The submit method: post (default) or get + * @uses $vars['enctype'] Set to 'multipart/form-data' if uploading a file * @uses $vars['disable_security'] turn off CSRF security by setting to true + * @uses $vars['class'] Additional class for the form */ $defaults = array( @@ -18,6 +21,12 @@ $defaults = array( $vars = array_merge($defaults, $vars); +if (isset($vars['class'])) { + $vars['class'] = "elgg-form {$vars['class']}"; +} else { + $vars['class'] = 'elgg-form'; +} + $vars['action'] = elgg_normalize_url($vars['action']); $vars['method'] = strtolower($vars['method']); @@ -32,4 +41,4 @@ unset($vars['disable_security']); $attributes = elgg_format_attributes($vars); -echo "<form $attributes><fieldset>$body</fieldset></form>";
\ No newline at end of file +echo "<form $attributes><fieldset>$body</fieldset></form>"; diff --git a/views/default/input/friendspicker.php b/views/default/input/friendspicker.php new file mode 100644 index 000000000..40708c890 --- /dev/null +++ b/views/default/input/friendspicker.php @@ -0,0 +1,319 @@ +<?php +/** + * Elgg friends picker + * Lists the friends picker + * + * @warning Below is the ugliest code in Elgg. It needs to be rewritten or removed + * + * @package Elgg + * @subpackage Core + * + * @uses $vars['entities'] The array of ElggUser objects + * @uses $vars['name'] + * @uses $vars['value'] + * @uses $vars['highlight'] + * @uses $vars['callback'] + */ + +elgg_load_js('elgg.friendspicker'); +elgg_load_js('jquery.easing'); + + +$chararray = elgg_echo('friendspicker:chararray'); + +// Initialise name +if (!isset($vars['name'])) { + $name = "friend"; +} else { + $name = $vars['name']; +} + +// Are we highlighting default or all? +if (empty($vars['highlight'])) { + $vars['highlight'] = 'default'; +} +if ($vars['highlight'] != 'all') { + $vars['highlight'] = 'default'; +} + +// Initialise values +if (!isset($vars['value'])) { + $vars['value'] = array(); +} else { + if (!is_array($vars['value'])) { + $vars['value'] = (int) $vars['value']; + $vars['value'] = array($vars['value']); + } +} + +// Initialise whether we're calling back or not +if (isset($vars['callback'])) { + $callback = $vars['callback']; +} else { + $callback = false; +} + +// We need to count the number of friends pickers on the page. +if (!isset($vars['friendspicker'])) { + global $friendspicker; + if (!isset($friendspicker)) { + $friendspicker = 0; + } + $friendspicker++; +} else { + $friendspicker = $vars['friendspicker']; +} + +$users = array(); +$activeletters = array(); + +// Are we displaying form tags and submit buttons? +// (If we've been given a target, then yes! Otherwise, no.) +if (isset($vars['formtarget'])) { + $formtarget = $vars['formtarget']; +} else { + $formtarget = false; +} + +// Sort users by letter +if (is_array($vars['entities']) && sizeof($vars['entities'])) { + foreach($vars['entities'] as $user) { + $letter = elgg_strtoupper(elgg_substr($user->name, 0, 1)); + + if (!elgg_substr_count($chararray, $letter)) { + $letter = "*"; + } + if (!isset($users[$letter])) { + $users[$letter] = array(); + } + $users[$letter][$user->guid] = $user; + } +} + +// sort users in letters alphabetically +foreach ($users as $letter => $letter_users) { + usort($letter_users, create_function('$a, $b', ' + return strcasecmp($a->name, $b->name); + ')); + $users[$letter] = $letter_users; +} + +if (!$callback) { + ?> + + <div class="friends-picker-main-wrapper"> + + <?php + + if (isset($vars['content'])) { + echo $vars['content']; + } + ?> + + <div id="friends-picker_placeholder<?php echo $friendspicker; ?>"> + + <?php +} + +if (!isset($vars['replacement'])) { + if ($formtarget) { +?> +<?php //@todo JS 1.8: no ?> +<script language="text/javascript"> + $(function() { // onload...do + $('#collectionMembersForm<?php echo $friendspicker; ?>').submit(function() { + var inputs = []; + $(':input', this).each(function() { + if (this.type != 'checkbox' || (this.type == 'checkbox' && this.checked != false)) { + inputs.push(this.name + '=' + escape(this.value)); + } + }); + jQuery.ajax({ + type: "POST", + data: inputs.join('&'), + url: this.action, + success: function(){ + $('a.collectionmembers<?php echo $friendspicker; ?>').click(); + } + + }); + return false; + }) + }) + + </script> + +<!-- Collection members form --> +<form id="collectionMembersForm<?php echo $friendspicker; ?>" action="<?php echo $formtarget; ?>" method="post"> <!-- action="" method=""> --> + +<?php + echo elgg_view('input/securitytoken'); + echo elgg_view('input/hidden', array( + 'name' => 'collection_id', + 'value' => $vars['collection_id'], + )); + } +?> + +<div class="friends-picker-wrapper"> +<div id="friends-picker<?php echo $friendspicker; ?>"> + <div class="friends-picker-container"> +<?php + +// Initialise letters + $chararray .= "*"; + $letter = elgg_substr($chararray, 0, 1); + $letpos = 0; + while (1 == 1) { + ?> + <div class="panel" title="<?php echo $letter; ?>"> + <div class="wrapper"> + <h3><?php echo $letter; ?></h3> + <?php + + if (isset($users[$letter])) { + ksort($users[$letter]); + + echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; + $col = 0; + + foreach($users[$letter] as $friend) { + if ($col == 0) { + echo "<tr>"; + } + + //echo "<p>" . $user->name . "</p>"; + $label = elgg_view_entity_icon($friend, 'tiny', array('use_hover' => false)); + $options[$label] = $friend->getGUID(); + + if ($vars['highlight'] == 'all' && !in_array($letter,$activeletters)) { + $activeletters[] = $letter; + } + + + if (in_array($friend->getGUID(),$vars['value'])) { + $checked = "checked = \"checked\""; + if (!in_array($letter,$activeletters) && $vars['highlight'] == 'default') { + $activeletters[] = $letter; + } + } else { + $checked = ""; + } + ?> + + <td> + + <input type="checkbox" <?php echo $checked; ?> name="<?php echo $name; ?>[]" value="<?php echo $options[$label]; ?>" /> + + </td> + + <td> + + <div style="width: 25px; margin-bottom: 15px;"> + <?php + echo $label; + ?> + </div> + </td> + <td style="width: 200px; padding: 5px;"> + <?php echo $friend->name; ?> + </td> + <?php + $col++; + if ($col == 3){ + echo "</tr>"; + $col = 0; + } + } + if ($col < 3) { + echo "</tr>"; + } + + echo "</table>"; + } + +?> + + </div> + </div> +<?php + + $substr = elgg_substr($chararray, elgg_strlen($chararray) - 1, 1); + if ($letter == $substr) { + break; + } + //$letter++; + $letpos++; + $letter = elgg_substr($chararray, $letpos, 1); + } + +?> + </div> + +<?php + +if ($formtarget) { + + if (isset($vars['formcontents'])) + echo $vars['formcontents']; + +?> + <div class="clearfix"></div> + <div class="friendspicker-savebuttons"> + <input type="submit" class="elgg-button elgg-button-submit" value="<?php echo elgg_echo('save'); ?>" /> + <input type="button" class="elgg-button elgg-button-cancel" value="<?php echo elgg_echo('cancel'); ?>" onclick="$('a.collectionmembers<?php echo $friendspicker; ?>').click();" /> + <br /></div> + </form> + +<?php + +} + +?> + +</div> +</div> + +<?php +} else { + echo $vars['replacement']; +} +if (!$callback) { + +?> + +</div> +</div> + + +<?php + +} + +if (!isset($vars['replacement'])) { +?> +<?php //@todo JS 1.8: no ?> +<script type="text/javascript"> + // initialise picker + $("div#friends-picker<?php echo $friendspicker; ?>").friendsPicker(<?php echo $friendspicker; ?>); +</script> +<script type="text/javascript"> +$(document).ready(function () { +// manually add class to corresponding tab for panels that have content +<?php +if (sizeof($activeletters) > 0) + //$chararray = elgg_echo('friendspicker:chararray'); + foreach($activeletters as $letter) { + $tab = elgg_strpos($chararray, $letter) + 1; +?> +$("div#friends-picker-navigation<?php echo $friendspicker; ?> li.tab<?php echo $tab; ?> a").addClass("tabHasContent"); +<?php + } + +?> +}); +</script> + +<?php + +}
\ No newline at end of file diff --git a/views/default/input/location.php b/views/default/input/location.php new file mode 100644 index 000000000..4cf05c72a --- /dev/null +++ b/views/default/input/location.php @@ -0,0 +1,27 @@ +<?php +/** + * Location input field + * + * @uses $vars['entity'] The ElggEntity that has a location + * @uses $vars['value'] The default value for the location + * @uses $vars['class'] Additional CSS class + */ + +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-location {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-location"; +} + +$defaults = array( + 'disabled' => false, +); + +if (isset($vars['entity'])) { + $defaults['value'] = $vars['entity']->location; + unset($vars['entity']); +} + +$vars = array_merge($defaults, $vars); + +echo elgg_view('input/tag', $vars); diff --git a/views/default/input/longtext.php b/views/default/input/longtext.php index 43534eec7..61dc7ca19 100644 --- a/views/default/input/longtext.php +++ b/views/default/input/longtext.php @@ -1,19 +1,42 @@ <?php /** * Elgg long text input - * Displays a long text input field + * Displays a long text input field that can use WYSIWYG editor * * @package Elgg * @subpackage Core * - * @uses $vars['value'] The current value, if any - will be html encoded + * @uses $vars['value'] The current value, if any - will be html encoded * @uses $vars['disabled'] Is the input field disabled? + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-longtext {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-longtext"; +} + $defaults = array( - 'class' => 'elgg-input-longtext', + 'value' => '', + 'rows' => '10', + 'cols' => '50', + 'id' => 'elgg-input-' . rand(), //@todo make this more robust ); $vars = array_merge($defaults, $vars); -echo elgg_view('input/plaintext', $vars); +$value = $vars['value']; +unset($vars['value']); + +echo elgg_view_menu('longtext', array( + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', + 'id' => $vars['id'], +)); + +?> + +<textarea <?php echo elgg_format_attributes($vars); ?>> +<?php echo htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); ?> +</textarea> diff --git a/views/default/input/password.php b/views/default/input/password.php index 62c8fb53d..45f2b20a6 100644 --- a/views/default/input/password.php +++ b/views/default/input/password.php @@ -7,17 +7,22 @@ * @subpackage Core * * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['name'] The name of the input field - * + * @uses $vars['name'] The name of the input field + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-password {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-password"; +} + $defaults = array( - 'class' => 'elgg-input-password', - 'disabled' => FALSE, + 'disabled' => false, + 'value' => '', ); $attrs = array_merge($defaults, $vars); ?> -<input type="password" <?php echo elgg_format_attributes($attrs); ?> />
\ No newline at end of file +<input type="password" <?php echo elgg_format_attributes($attrs); ?> /> diff --git a/views/default/input/plaintext.php b/views/default/input/plaintext.php index 3be9ed0d8..e92c61ced 100644 --- a/views/default/input/plaintext.php +++ b/views/default/input/plaintext.php @@ -6,23 +6,32 @@ * @package Elgg * @subpackage Core * - * @uses $vars['value'] The current value, if any - * @uses $vars['name'] The name of the input field - * @uses $vars['class'] + * @uses $vars['value'] The current value, if any + * @uses $vars['name'] The name of the input field + * @uses $vars['class'] Additional CSS class * @uses $vars['disabled'] */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-plaintext {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-plaintext"; +} + $defaults = array( - 'class' => 'elgg-input-textarea', - 'disabled' => FALSE, + 'value' => '', + 'rows' => '10', + 'cols' => '50', + 'disabled' => false, ); +$vars = array_merge($defaults, $vars); + $value = $vars['value']; unset($vars['value']); -$attrs = array_merge($defaults, $vars); ?> -<textarea <?php echo elgg_format_attributes($attrs); ?>> +<textarea <?php echo elgg_format_attributes($vars); ?>> <?php echo htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); ?> </textarea> diff --git a/views/default/input/pulldown.php b/views/default/input/pulldown.php index 705329691..fc0595300 100644 --- a/views/default/input/pulldown.php +++ b/views/default/input/pulldown.php @@ -5,5 +5,5 @@ * @deprecated 1.8 */ -elgg_deprecated_notice("input/pulldown was deprecated by input/dropdown", 1.8); +elgg_deprecated_notice("input/pulldown was deprecated by input/dropdown", 1.8, 2); echo elgg_view('input/dropdown', $vars); diff --git a/views/default/input/radio.php b/views/default/input/radio.php index 0ad28423f..ef860a773 100644 --- a/views/default/input/radio.php +++ b/views/default/input/radio.php @@ -10,24 +10,42 @@ * @package Elgg * @subpackage Core * - * @uses $vars['value'] The current value, if any - * @uses $vars['name'] The name of the input field - * @uses $vars['options'] An array of strings representing the options for the - * radio field as "label" => option - * @uses $vars['class'] Additional class of the list. Optional. - * @uses $vars['align'] 'horizontal' or 'vertical' Default: 'vertical' + * @uses $vars['value'] The current value, if any + * @uses $vars['name'] The name of the input field + * @uses $vars['options'] An array of strings representing the options for the + * radio field as "label" => option + * @uses $vars['class'] Additional class of the list. Optional. + * @uses $vars['align'] 'horizontal' or 'vertical' Default: 'vertical' */ -$additional_class = elgg_extract('class', $vars); -$align = elgg_extract('align', $vars, 'vertical'); -$class = "elgg-input-radio elgg-$align"; -if ($additional_class) { - $class = " $additional_class"; +$defaults = array( + 'align' => 'vertical', + 'value' => array(), + 'disabled' => false, + 'options' => array(), + 'name' => '', +); + +$vars = array_merge($defaults, $vars); + +$id = ''; +if (isset($vars['id'])) { + $id = "id=\"{$vars['id']}\""; + unset($vars['id']); +} + +$class = "elgg-input-radios elgg-{$vars['align']}"; +if (isset($vars['class'])) { + $class .= " {$vars['class']}"; unset($vars['class']); } +unset($vars['align']); +$vars['class'] = 'elgg-input-radio'; -if (isset($vars['align'])) { - unset($vars['align']); +if (is_array($vars['value'])) { + $vars['value'] = array_map('elgg_strtolower', $vars['value']); +} else { + $vars['value'] = array(elgg_strtolower($vars['value'])); } $options = $vars['options']; @@ -37,10 +55,10 @@ $value = $vars['value']; unset($vars['value']); if ($options && count($options) > 0) { - echo "<ul class=\"$class\">"; + echo "<ul class=\"$class\" $id>"; foreach ($options as $label => $option) { - $vars['checked'] = elgg_strtolower($option) == elgg_strtolower($value); + $vars['checked'] = in_array(elgg_strtolower($option), $value); $vars['value'] = $option; $attributes = elgg_format_attributes($vars); diff --git a/views/default/input/reset.php b/views/default/input/reset.php index 12866421e..082da8669 100644 --- a/views/default/input/reset.php +++ b/views/default/input/reset.php @@ -4,8 +4,11 @@ * * @package Elgg * @subpackage Core + * + * @uses $vars['class'] CSS class that replaces elgg-button-cancel */ $vars['type'] = 'reset'; +$vars['class'] = elgg_extract('class', $vars, 'elgg-button-cancel'); echo elgg_view('input/button', $vars);
\ No newline at end of file diff --git a/views/default/input/submit.php b/views/default/input/submit.php index d09d1db6e..df369b3b4 100644 --- a/views/default/input/submit.php +++ b/views/default/input/submit.php @@ -4,8 +4,11 @@ * * @package Elgg * @subpackage Core + * + * @uses $vars['class'] CSS class that replaces elgg-button-submit */ $vars['type'] = 'submit'; +$vars['class'] = elgg_extract('class', $vars, 'elgg-button-submit'); echo elgg_view('input/button', $vars);
\ No newline at end of file diff --git a/views/default/input/tag.php b/views/default/input/tag.php new file mode 100644 index 000000000..8893a18ff --- /dev/null +++ b/views/default/input/tag.php @@ -0,0 +1,25 @@ +<?php +/** + * Elgg tag input + * + * Accepts a single tag value + * + * @uses $vars['value'] The default value for the tag + * @uses $vars['class'] Additional CSS class + */ + +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-tag {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-tag"; +} + +$defaults = array( + 'value' => '', + 'disabled' => false, +); + +$vars = array_merge($defaults, $vars); +?> + +<input type="text" <?php echo elgg_format_attributes($vars); ?> />
\ No newline at end of file diff --git a/views/default/input/tags.php b/views/default/input/tags.php index 539bbd4db..261cf9f97 100644 --- a/views/default/input/tags.php +++ b/views/default/input/tags.php @@ -3,15 +3,28 @@ * Elgg tag input * Displays a tag input field * - * @package Elgg - * @subpackage Core + * @uses $vars['disabled'] + * @uses $vars['class'] Additional CSS class + * @uses $vars['value'] Array of tags or a string + * @uses $vars['entity'] Optional. Entity whose tags are being displayed (metadata ->tags) */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-tags {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-tags"; +} + $defaults = array( - 'class' => 'elgg-input-tags', - 'disabled' => FALSE, + 'value' => '', + 'disabled' => false, ); +if (isset($vars['entity'])) { + $defaults['value'] = $vars['entity']->tags; + unset($vars['entity']); +} + $vars = array_merge($defaults, $vars); if (is_array($vars['value'])) { diff --git a/views/default/input/text.php b/views/default/input/text.php index e5af723be..07ce5c710 100644 --- a/views/default/input/text.php +++ b/views/default/input/text.php @@ -5,15 +5,22 @@ * * @package Elgg * @subpackage Core + * + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-text {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-text"; +} + $defaults = array( - 'class' => 'elgg-input-text', - 'disabled' => FALSE, + 'value' => '', + 'disabled' => false, ); $vars = array_merge($defaults, $vars); ?> - <input type="text" <?php echo elgg_format_attributes($vars); ?> />
\ No newline at end of file diff --git a/views/default/input/url.php b/views/default/input/url.php index a93db718f..e97a316d8 100644 --- a/views/default/input/url.php +++ b/views/default/input/url.php @@ -5,10 +5,19 @@ * * @package Elgg * @subpackage Core + * + * @uses $vars['class'] Additional CSS class */ +if (isset($vars['class'])) { + $vars['class'] = "elgg-input-url {$vars['class']}"; +} else { + $vars['class'] = "elgg-input-url"; +} + $defaults = array( - 'class' => 'elgg-input-url', + 'value' => '', + 'disabled' => false, ); $vars = array_merge($defaults, $vars); diff --git a/views/default/input/userpicker.php b/views/default/input/userpicker.php index 77a51f37c..8b64d7df5 100644 --- a/views/default/input/userpicker.php +++ b/views/default/input/userpicker.php @@ -5,36 +5,38 @@ * @package Elgg * @subpackage Core * - * @uses $vars['value'] The current value, if any - * @uses $vars['name'] The name of the input field + * @uses $vars['value'] Array of user guids for already selected users or null * + * The name of the hidden fields is members[] * - * pops up defaulted to lazy load friends lists in paginated alphabetical order. - * upon + * @warning Only a single input/userpicker is supported per web page. * - * As users are checked they move down to a "users" box. - * When this happens, a hidden input is created also. - * {$internalnal}[] with the value th GUID. + * Defaults to lazy load user lists in alphabetical order. User needs + * to type two characters before seeing the user popup list. * + * As users are selected they move down to a "users" box. + * When this happens, a hidden input is created with the + * name of members[] and a value of the GUID. */ -elgg_register_js('js/lib/userpicker.js', 'userpicker', 'head'); +elgg_load_js('elgg.userpicker'); +elgg_load_js('jquery.ui.autocomplete.html'); function user_picker_add_user($user_id) { $user = get_entity($user_id); if (!$user || !($user instanceof ElggUser)) { - return FALSE; + return false; } - $icon = $user->getIconURL('tiny'); - - $code = '<li class="elgg-image-block">'; - $code .= "<div class='elgg-image'><img class=\"livesearch_icon\" src=\"$icon\" /></div>"; - $code .= "<div class='elgg-image-alt'><a onclick='elgg.userpicker.removeUser(this, $user_id)'><strong>X</strong></a></div>"; - $code .= "<div class='elgg-body'>"; - $code .= "$user->name - $user->username"; - $code .= "<input type=\"hidden\" name=\"members[]\" value=\"$user_id\">"; + $icon = elgg_view_entity_icon($user, 'tiny', array('use_hover' => false)); + + // this html must be synced with the userpicker.js library + $code = '<li><div class="elgg-image-block">'; + $code .= "<div class='elgg-image'>$icon</div>"; + $code .= "<div class='elgg-image-alt'><a href='#' class='elgg-userpicker-remove'>X</a></div>"; + $code .= "<div class='elgg-body'>" . $user->name . "</div>"; $code .= "</div>"; + $code .= "<input type=\"hidden\" name=\"members[]\" value=\"$user_id\">"; $code .= '</li>'; return $code; @@ -61,10 +63,13 @@ foreach ($vars['value'] as $user_id) { ?> <div class="elgg-user-picker"> <input type="text" class="elgg-input-user-picker" size="30"/> - <label><input type="checkbox" name="match_on" value="true" /><?php echo elgg_echo('userpicker:only_friends'); ?></label> - <ul class="elgg-user-picker-entries"><?php echo $user_list; ?></ul> + <label> + <input type="checkbox" name="match_on" value="true" /> + <?php echo elgg_echo('userpicker:only_friends'); ?> + </label> + <ul class="elgg-user-picker-list"><?php echo $user_list; ?></ul> </div> <script type="text/javascript"> - elgg.provide('elgg.userpicker'); + // @todo grab the values in the init function rather than using inline JS elgg.userpicker.userList = <?php echo $json_values ?>; -</script>
\ No newline at end of file +</script> |
