diff options
Diffstat (limited to 'views/default/input')
30 files changed, 1301 insertions, 0 deletions
diff --git a/views/default/input/access.php b/views/default/input/access.php new file mode 100644 index 000000000..137eea288 --- /dev/null +++ b/views/default/input/access.php @@ -0,0 +1,38 @@ +<?php +/** + * Elgg access level input + * Displays a dropdown 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( + '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) { + $vars['value'] = get_default_access(); +} + +if (is_array($vars['options_values']) && sizeof($vars['options_values']) > 0) { + echo elgg_view('input/dropdown', $vars); +} diff --git a/views/default/input/autocomplete.php b/views/default/input/autocomplete.php new file mode 100644 index 000000000..e58eb1ae8 --- /dev/null +++ b/views/default/input/autocomplete.php @@ -0,0 +1,49 @@ +<?php +/** + * Displays an autocomplete text input. + * + * @package Elgg + * @subpackage Core + * + * @todo This currently only works for ONE AUTOCOMPLETE TEXT FIELD on a page. + * + * @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( + 'value' => '', + 'disabled' => false, +); + +$vars = array_merge($defaults, $vars); + +$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); + +elgg_load_js('elgg.autocomplete'); +elgg_load_js('jquery.ui.autocomplete.html'); + +?> + +<script type="text/javascript"> +elgg.provide('elgg.autocomplete'); +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 new file mode 100644 index 000000000..9957fdc54 --- /dev/null +++ b/views/default/input/button.php @@ -0,0 +1,40 @@ +<?php +/** + * Create a input button + * + * @package Elgg + * @subpackage Core + * + * @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', +); + +$vars = array_merge($defaults, $vars); + +switch ($vars['type']) { + case 'button': + case 'reset': + case 'submit': + case 'image': + break; + default: + $vars['type'] = 'button'; + break; +} + +// blank src if trying to access an offsite image. @todo why? +if (isset($vars['src']) && strpos($vars['src'], elgg_get_site_url()) === false) { + $vars['src'] = ""; +} +?> +<input <?php echo elgg_format_attributes($vars); ?> /> diff --git a/views/default/input/calendar.php b/views/default/input/calendar.php new file mode 100644 index 000000000..52c84ff82 --- /dev/null +++ b/views/default/input/calendar.php @@ -0,0 +1,6 @@ +<?php +// @deprecated Use input/date instead. + +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 new file mode 100644 index 000000000..1c2e22aaa --- /dev/null +++ b/views/default/input/captcha.php @@ -0,0 +1,8 @@ +<?php +/** + * This view provides a hook for third parties to provide a CAPTCHA. + * + * @package Elgg + * @subpackage Core + */ +?>
\ No newline at end of file diff --git a/views/default/input/checkbox.php b/views/default/input/checkbox.php new file mode 100644 index 000000000..3dc75c6c3 --- /dev/null +++ b/views/default/input/checkbox.php @@ -0,0 +1,39 @@ +<?php +/** + * Elgg checkbox input + * Displays a checkbox input tag + * + * @package Elgg + * @subpackage Core + * + * + * Pass input tag attributes as key value pairs. For a list of allowable + * attributes, see http://www.w3schools.com/tags/tag_input.asp + * + * @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( + 'default' => 0, + 'disabled' => false, +); + +$vars = array_merge($defaults, $vars); + +$default = $vars['default']; +unset($vars['default']); + +if (isset($vars['name']) && $default !== false) { + echo "<input type=\"hidden\" name=\"{$vars['name']}\" value=\"$default\"/>"; +} + +?> +<input type="checkbox" <?php echo elgg_format_attributes($vars); ?> /> diff --git a/views/default/input/checkboxes.php b/views/default/input/checkboxes.php new file mode 100644 index 000000000..db4b06949 --- /dev/null +++ b/views/default/input/checkboxes.php @@ -0,0 +1,90 @@ +<?php +/** + * Elgg checkbox input + * Displays a checkbox input field + * + * @note This also includes a hidden input with the same name as the checkboxes + * to make sure something is sent to the server. The default value is 0. + * If using JS, be specific to avoid selecting the hidden default value: + * $('input[type=checkbox][name=name]') + * + * @warning Passing integers as labels does not currently work due to a + * deprecated hack that will be removed in Elgg 1.9. To use integer labels, + * the labels must be character codes: 1 would be 1 + * + * @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['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' + * + */ + +$defaults = array( + 'align' => 'vertical', + 'value' => array(), + 'default' => 0, + 'disabled' => false, + 'options' => array(), + 'name' => '', +); + +$vars = array_merge($defaults, $vars); + +$class = "elgg-input-checkboxes elgg-{$vars['align']}"; +if (isset($vars['class'])) { + $class .= " {$vars['class']}"; + unset($vars['class']); +} + +$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 ($vars['name'] && $vars['default'] !== false) { + echo "<input type=\"hidden\" name=\"{$vars['name']}\" value=\"{$vars['default']}\" />"; + } + + 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 = $value; + } + + $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 '</ul>'; +} 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 new file mode 100644 index 000000000..8955e6e53 --- /dev/null +++ b/views/default/input/datepicker.php @@ -0,0 +1,6 @@ +<?php +/** + * @deprecated use input/date instead + */ +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 new file mode 100644 index 000000000..9f07874f1 --- /dev/null +++ b/views/default/input/dropdown.php @@ -0,0 +1,71 @@ +<?php +/** + * Elgg dropdown input + * Displays a dropdown (select) input field + * + * @warning Default values of FALSE or NULL will match '' (empty string) but not 0. + * + * @package Elgg + * @subpackage Core + * + * @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 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( + 'disabled' => false, + 'value' => '', + 'options_values' => array(), + 'options' => array(), +); + +$vars = array_merge($defaults, $vars); + +$options_values = $vars['options_values']; +unset($vars['options_values']); + +$options = $vars['options']; +unset($vars['options']); + +$value = $vars['value']; +unset($vars['value']); + +?> +<select <?php echo elgg_format_attributes($vars); ?>> +<?php + +if ($options_values) { + foreach ($options_values as $opt_value => $option) { + + $option_attrs = elgg_format_attributes(array( + 'value' => $opt_value, + 'selected' => (string)$opt_value == (string)$value, + )); + + echo "<option $option_attrs>$option</option>"; + } +} else { + if (is_array($options)) { + foreach ($options as $option) { + + $option_attrs = elgg_format_attributes(array( + 'selected' => (string)$option == (string)$value + )); + + echo "<option $option_attrs>$option</option>"; + } + } +} +?> +</select> diff --git a/views/default/input/email.php b/views/default/input/email.php new file mode 100644 index 000000000..190fb88c6 --- /dev/null +++ b/views/default/input/email.php @@ -0,0 +1,26 @@ +<?php +/** + * Elgg email input + * Displays an email input field + * + * @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( + '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/file.php b/views/default/input/file.php new file mode 100644 index 000000000..452fe72b9 --- /dev/null +++ b/views/default/input/file.php @@ -0,0 +1,31 @@ +<?php +/** + * Elgg file input + * Displays a file input field + * + * @package Elgg + * @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( + 'disabled' => false, + 'size' => 30, +); + +$attrs = array_merge($defaults, $vars); + +?> +<input type="file" <?php echo elgg_format_attributes($attrs); ?> /> diff --git a/views/default/input/form.php b/views/default/input/form.php new file mode 100644 index 000000000..df30133b3 --- /dev/null +++ b/views/default/input/form.php @@ -0,0 +1,44 @@ +<?php +/** + * Create a form for data submission. + * 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( + 'method' => "post", + 'disable_security' => FALSE, +); + +$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']); + +$body = $vars['body']; +unset($vars['body']); + +// Generate a security header +if (!$vars['disable_security']) { + $body = elgg_view('input/securitytoken') . $body; +} +unset($vars['disable_security']); + +$attributes = elgg_format_attributes($vars); + +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/hidden.php b/views/default/input/hidden.php new file mode 100644 index 000000000..9c2fc6c08 --- /dev/null +++ b/views/default/input/hidden.php @@ -0,0 +1,12 @@ +<?php +/** + * Create a hidden data field + * + * @package Elgg + * @subpackage Core + * + * @uses $vars['value'] The current value, if any + */ + +?> +<input type="hidden" <?php echo elgg_format_attributes($vars); ?> />
\ 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 new file mode 100644 index 000000000..61dc7ca19 --- /dev/null +++ b/views/default/input/longtext.php @@ -0,0 +1,42 @@ +<?php +/** + * Elgg long text input + * 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['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( + 'value' => '', + 'rows' => '10', + 'cols' => '50', + 'id' => 'elgg-input-' . rand(), //@todo make this more robust +); + +$vars = array_merge($defaults, $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 new file mode 100644 index 000000000..45f2b20a6 --- /dev/null +++ b/views/default/input/password.php @@ -0,0 +1,28 @@ +<?php +/** + * Elgg password input + * Displays a password input field + * + * @package Elgg + * @subpackage Core + * + * @uses $vars['value'] The current value, if any + * @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( + 'disabled' => false, + 'value' => '', +); + +$attrs = array_merge($defaults, $vars); +?> + +<input type="password" <?php echo elgg_format_attributes($attrs); ?> /> diff --git a/views/default/input/plaintext.php b/views/default/input/plaintext.php new file mode 100644 index 000000000..e92c61ced --- /dev/null +++ b/views/default/input/plaintext.php @@ -0,0 +1,37 @@ +<?php +/** + * Elgg long text input (plaintext) + * Displays a long text input field that should not be overridden by wysiwyg editors. + * + * @package Elgg + * @subpackage Core + * + * @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( + 'value' => '', + 'rows' => '10', + 'cols' => '50', + 'disabled' => false, +); + +$vars = array_merge($defaults, $vars); + +$value = $vars['value']; +unset($vars['value']); + +?> + +<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 new file mode 100644 index 000000000..705329691 --- /dev/null +++ b/views/default/input/pulldown.php @@ -0,0 +1,9 @@ +<?php +/** + * Deprecated pulldown input view - use 'input/dropdown' instead. + * + * @deprecated 1.8 + */ + +elgg_deprecated_notice("input/pulldown was deprecated by input/dropdown", 1.8); +echo elgg_view('input/dropdown', $vars); diff --git a/views/default/input/radio.php b/views/default/input/radio.php new file mode 100644 index 000000000..ef860a773 --- /dev/null +++ b/views/default/input/radio.php @@ -0,0 +1,76 @@ +<?php +/** + * Elgg radio input + * Displays a radio input field + * + * @warning Passing integers as labels does not currently work due to a + * deprecated hack that will be removed in Elgg 1.9. To use integer labels, + * the labels must be character codes: 1 would be 1 + * + * @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' + */ + +$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 (is_array($vars['value'])) { + $vars['value'] = array_map('elgg_strtolower', $vars['value']); +} else { + $vars['value'] = array(elgg_strtolower($vars['value'])); +} + +$options = $vars['options']; +unset($vars['options']); + +$value = $vars['value']; +unset($vars['value']); + +if ($options && count($options) > 0) { + echo "<ul class=\"$class\" $id>"; + foreach ($options as $label => $option) { + + $vars['checked'] = in_array(elgg_strtolower($option), $value); + $vars['value'] = $option; + + $attributes = elgg_format_attributes($vars); + + // handle indexed array where label is not specified + // @deprecated 1.8 Remove in 1.9 + if (is_integer($label)) { + elgg_deprecated_notice('$vars[\'options\'] must be an associative array in input/radio', 1.8); + $label = $option; + } + + echo "<li><label><input type=\"radio\" $attributes />$label</label></li>"; + } + echo '</ul>'; +} diff --git a/views/default/input/reset.php b/views/default/input/reset.php new file mode 100644 index 000000000..082da8669 --- /dev/null +++ b/views/default/input/reset.php @@ -0,0 +1,14 @@ +<?php +/** + * Create a reset input button + * + * @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/securitytoken.php b/views/default/input/securitytoken.php new file mode 100644 index 000000000..75410848a --- /dev/null +++ b/views/default/input/securitytoken.php @@ -0,0 +1,15 @@ +<?php +/** + * CSRF security token view for use with secure forms. + * + * It is still recommended that you use input/form. + * + * @package Elgg + * @subpackage Core + */ + +$ts = time(); +$token = generate_action_token($ts); + +echo elgg_view('input/hidden', array('name' => '__elgg_token', 'value' => $token)); +echo elgg_view('input/hidden', array('name' => '__elgg_ts', 'value' => $ts)); diff --git a/views/default/input/submit.php b/views/default/input/submit.php new file mode 100644 index 000000000..df369b3b4 --- /dev/null +++ b/views/default/input/submit.php @@ -0,0 +1,14 @@ +<?php +/** + * Create a submit input button + * + * @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 new file mode 100644 index 000000000..261cf9f97 --- /dev/null +++ b/views/default/input/tags.php @@ -0,0 +1,45 @@ +<?php +/** + * Elgg tag input + * Displays a tag input field + * + * @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( + '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'])) { + $tags = array(); + + foreach ($vars['value'] as $tag) { + if (is_string($tag)) { + $tags[] = $tag; + } else { + $tags[] = $tag->value; + } + } + + $vars['value'] = implode(", ", $tags); +} + +?> +<input type="text" <?php echo elgg_format_attributes($vars); ?> />
\ No newline at end of file diff --git a/views/default/input/text.php b/views/default/input/text.php new file mode 100644 index 000000000..07ce5c710 --- /dev/null +++ b/views/default/input/text.php @@ -0,0 +1,26 @@ +<?php +/** + * Elgg text input + * Displays a text input field + * + * @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( + '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 new file mode 100644 index 000000000..e97a316d8 --- /dev/null +++ b/views/default/input/url.php @@ -0,0 +1,27 @@ +<?php +/** + * Elgg URL input + * Displays a URL input field + * + * @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( + 'value' => '', + 'disabled' => false, +); + +$vars = array_merge($defaults, $vars); + +?> + +<input type="text" <?php echo elgg_format_attributes($vars); ?> /> diff --git a/views/default/input/urlshortener.php b/views/default/input/urlshortener.php new file mode 100644 index 000000000..ecfb02efa --- /dev/null +++ b/views/default/input/urlshortener.php @@ -0,0 +1,8 @@ +<?php +/** + * This view provides a hook for third parties to provide a URL shortener. + * + * @package Elgg + * @subpackage Core + */ +?>
\ No newline at end of file diff --git a/views/default/input/userpicker.php b/views/default/input/userpicker.php new file mode 100644 index 000000000..91a397e37 --- /dev/null +++ b/views/default/input/userpicker.php @@ -0,0 +1,73 @@ +<?php +/** + * User Picker. Sends an array of user guids. + * + * @package Elgg + * @subpackage Core + * + * @uses $vars['value'] Array of user guids for already selected users or null + * + * The name of the hidden fields is members[] + * + * @warning Only a single input/userpicker is supported per web page. + * + * 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_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; + } + + $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; +} + +// loop over all values and prepare them so that "in" will work in javascript +$values = array(); +if (!is_array($vars['value'])) { + $vars['value'] = array($vars['value']); +} +foreach ($vars['value'] as $value) { + $values[$value] = TRUE; +} + +// convert the values to a json-encoded list +$json_values = json_encode($values); + +// create an HTML list of users +$user_list = ''; +foreach ($vars['value'] as $user_id) { + $user_list .= user_picker_add_user($user_id); +} + +?> +<div class="elgg-user-picker"> + <input type="text" class="elgg-input-user-picker" size="30"/> + <input type="checkbox" name="match_on" value="true" /> + <label><?php echo elgg_echo('userpicker:only_friends'); ?></label> + <ul class="elgg-user-picker-list"><?php echo $user_list; ?></ul> +</div> +<script type="text/javascript"> + // @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 |