aboutsummaryrefslogtreecommitdiff
path: root/views/default/input
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-08-25 10:00:38 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-08-25 10:00:38 -0700
commitdccc333c765bb28da55b4a55d9c916acdb88413a (patch)
treebdd26a0b4cd85241a19b7fcb2c0770f0ac3eb9f0 /views/default/input
parentec7b94a64aef23b85866ecdac8e8acc712d29bb6 (diff)
parent003cb81c7888f4d2fd763e5814027c6f8d71186f (diff)
downloadelgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.gz
elgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.bz2
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'views/default/input')
-rw-r--r--views/default/input/access.php18
-rw-r--r--views/default/input/autocomplete.php16
-rw-r--r--views/default/input/button.php15
-rw-r--r--views/default/input/calendar.php4
-rw-r--r--views/default/input/captcha.php2
-rw-r--r--views/default/input/checkbox.php16
-rw-r--r--views/default/input/checkboxes.php99
-rw-r--r--views/default/input/date.php48
-rw-r--r--views/default/input/dropdown.php21
-rw-r--r--views/default/input/email.php11
-rw-r--r--views/default/input/file.php15
-rw-r--r--views/default/input/form.php15
-rw-r--r--views/default/input/location.php10
-rw-r--r--views/default/input/longtext.php27
-rw-r--r--views/default/input/password.php17
-rw-r--r--views/default/input/plaintext.php21
-rw-r--r--views/default/input/radio.php49
-rw-r--r--views/default/input/tag.php14
-rw-r--r--views/default/input/tags.php12
-rw-r--r--views/default/input/text.php12
-rw-r--r--views/default/input/url.php11
21 files changed, 307 insertions, 146 deletions
diff --git a/views/default/input/access.php b/views/default/input/access.php
index 40a93aaa4..137eea288 100644
--- a/views/default/input/access.php
+++ b/views/default/input/access.php
@@ -3,15 +3,21 @@
* Elgg access level input
* Displays a dropdown input field
*
- * @uses $vars['value'] The current value, if any
- * @uses $vars['options_values']
- * @uses $vars['name'] The name of the input field
- * @uses $vars['entity'] Optional. The entity for this access control (uses access_id)
+ * @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(),
);
diff --git a/views/default/input/autocomplete.php b/views/default/input/autocomplete.php
index 0a4057ddf..421541e24 100644
--- a/views/default/input/autocomplete.php
+++ b/views/default/input/autocomplete.php
@@ -7,20 +7,25 @@
*
* @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|subtype)
* @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'],
@@ -38,4 +43,3 @@ 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
index 3122068ca..c21989919 100644
--- a/views/default/input/button.php
+++ b/views/default/input/button.php
@@ -6,20 +6,21 @@
* @subpackage Core
*
* @uses $vars['src'] Src of an image
- * @uses $vars['class'] Class to add to elgg-button
- *
- * @todo Handle classes better
+ * @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' => '',
);
$vars = array_merge($defaults, $vars);
-$vars['class'] = trim("elgg-button {$vars['class']}");
-
switch ($vars['type']) {
case 'button':
case 'reset':
@@ -36,4 +37,4 @@ if (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..985858b85 100644
--- a/views/default/input/checkboxes.php
+++ b/views/default/input/checkboxes.php
@@ -15,68 +15,77 @@
* @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']);
+ unset($vars['internalid']);
+}
+
+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
index afc40e899..ceeb2105c 100644
--- a/views/default/input/date.php
+++ b/views/default/input/date.php
@@ -3,28 +3,54 @@
* Elgg date input
* Displays a text field with a popup date picker.
*
- * @package Elgg
- * @subpackage Core
+ * 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.
*
- * @uses $vars['value'] The current value, if any (as a unix timestamp)
+ * 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' => '',
- 'class' => '',
+ 'disabled' => false,
+ 'timestamp' => false,
);
$vars = array_merge($defaults, $vars);
-//@todo popup_calendar deprecated in 1.8. Remove in 2.0
-$vars['class'] = trim("elgg-input-date popup_calendar {$vars['class']}");
+$timestamp = $vars['timestamp'];
+unset($vars['timestamp']);
-if ($vars['value'] > 86400) {
- $vars['value'] = date('n/d/Y', $vars['value']);
+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']);
}
-$attributes = elgg_format_attributes($vars);
+// convert timestamps to text for display
+if (is_numeric($vars['value'])) {
+ $vars['value'] = gmdate('Y/m/d', $vars['value']);
+}
-?>
-<input type="text" <?php echo $attributes; ?> /> \ No newline at end of file
+$attributes = elgg_format_attributes($vars);
+echo "<input type=\"text\" $attributes />";
diff --git a/views/default/input/dropdown.php b/views/default/input/dropdown.php
index fccccb888..4673a9301 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
*
- * @warning 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
@@ -14,13 +14,24 @@
* where "value" is an internal 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) {
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/location.php b/views/default/input/location.php
index d7ae2bbbd..4cf05c72a 100644
--- a/views/default/input/location.php
+++ b/views/default/input/location.php
@@ -4,11 +4,17 @@
*
* @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(
- 'class' => 'elgg-input-location',
- 'disabled' => FALSE,
+ 'disabled' => false,
);
if (isset($vars['entity'])) {
diff --git a/views/default/input/longtext.php b/views/default/input/longtext.php
index bd61b86ce..2b1462635 100644
--- a/views/default/input/longtext.php
+++ b/views/default/input/longtext.php
@@ -1,29 +1,40 @@
<?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' => '',
'id' => 'elgg-input-' . rand(), //@todo make this more robust
);
-// work around for deprecation code in elgg_views()
-unset($vars['internalname']);
-unset($vars['internalid']);
-
$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'],
));
-echo elgg_view('input/plaintext', $vars);
+
+?>
+
+<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..cd0aaafcf 100644
--- a/views/default/input/plaintext.php
+++ b/views/default/input/plaintext.php
@@ -6,23 +6,30 @@
* @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' => '',
+ '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/radio.php b/views/default/input/radio.php
index 0ad28423f..a8b278efd 100644
--- a/views/default/input/radio.php
+++ b/views/default/input/radio.php
@@ -10,24 +10,43 @@
* @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']);
+ unset($vars['internalid']);
+}
+
+$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 +56,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/tag.php b/views/default/input/tag.php
index a78ec3163..8893a18ff 100644
--- a/views/default/input/tag.php
+++ b/views/default/input/tag.php
@@ -5,13 +5,21 @@
* 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(
- 'class' => 'elgg-input-tag',
- 'disabled' => FALSE,
+ 'value' => '',
+ 'disabled' => false,
);
$vars = array_merge($defaults, $vars);
+?>
-echo elgg_view('input/text', $vars); \ No newline at end of file
+<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 7cda958aa..261cf9f97 100644
--- a/views/default/input/tags.php
+++ b/views/default/input/tags.php
@@ -4,14 +4,20 @@
* Displays a tag input field
*
* @uses $vars['disabled']
- * @uses $vars['class']
+ * @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'])) {
diff --git a/views/default/input/text.php b/views/default/input/text.php
index e5af723be..707a50179 100644
--- a/views/default/input/text.php
+++ b/views/default/input/text.php
@@ -5,11 +5,19 @@
*
* @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);
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);