aboutsummaryrefslogtreecommitdiff
path: root/views/installation/input
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-06-18 19:56:33 -0400
committerBrett Profitt <brett.profitt@gmail.com>2011-06-18 19:56:33 -0400
commitec7b94a64aef23b85866ecdac8e8acc712d29bb6 (patch)
treea108205c3fa0b694d8ce0ebaafd259480d6b530a /views/installation/input
parentc80ba5aa03264dd64c20ed8ae222e87f9371a44d (diff)
parent2b68a4d217c35a5587c462620789493cf2804ba2 (diff)
downloadelgg-ec7b94a64aef23b85866ecdac8e8acc712d29bb6.tar.gz
elgg-ec7b94a64aef23b85866ecdac8e8acc712d29bb6.tar.bz2
Merge branch 'master' of github.com:Elgg/Elgg
Diffstat (limited to 'views/installation/input')
-rw-r--r--views/installation/input/access.php6
-rw-r--r--views/installation/input/button.php20
-rw-r--r--views/installation/input/checkbox.php37
-rw-r--r--views/installation/input/checkboxes.php82
-rw-r--r--views/installation/input/combo.php19
-rw-r--r--views/installation/input/dropdown.php6
-rw-r--r--views/installation/input/form.php30
-rw-r--r--views/installation/input/hidden.php16
-rw-r--r--views/installation/input/longtext.php22
-rw-r--r--views/installation/input/password.php6
-rw-r--r--views/installation/input/reset.php13
-rw-r--r--views/installation/input/securitytoken.php15
-rw-r--r--views/installation/input/submit.php6
-rw-r--r--views/installation/input/text.php27
14 files changed, 64 insertions, 241 deletions
diff --git a/views/installation/input/access.php b/views/installation/input/access.php
index 3fde7295f..7665d8bca 100644
--- a/views/installation/input/access.php
+++ b/views/installation/input/access.php
@@ -3,11 +3,7 @@
* Elgg access level input
* Displays a dropdown input field
*
- * @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
*
*/
@@ -28,7 +24,7 @@ if (is_array($vars['options']) && sizeof($vars['options']) > 0) {
?>
- <select name="<?php echo $vars['name']; ?>" <?php if (isset($vars['js'])) echo $vars['js']; ?> <?php if ((isset($vars['disabled'])) && ($vars['disabled'])) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
+ <select name="<?php echo $vars['name']; ?>" <?php if ((isset($vars['disabled'])) && ($vars['disabled'])) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
<?php
foreach($vars['options'] as $key => $option) {
diff --git a/views/installation/input/button.php b/views/installation/input/button.php
index a69f7dbfa..29a37dd55 100644
--- a/views/installation/input/button.php
+++ b/views/installation/input/button.php
@@ -1,18 +1,10 @@
<?php
/**
* Create a input button
- * Use this view for forms rather than creating a submit/reset button tag in the wild as it provides
- * extra security which help prevent CSRF attacks.
- *
- * @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
- * @uses $vars['type'] Submit or reset, defaults to submit.
- * @uses $vars['src'] Src of an image
- *
+ * @uses $vars['type'] submit or button.
*/
$class = $vars['class'];
@@ -30,9 +22,6 @@ switch ($type) {
case 'button' :
$type='button';
break;
- case 'reset' :
- $type='reset';
- break;
case 'submit':
default:
$type = 'submit';
@@ -40,10 +29,5 @@ switch ($type) {
$value = htmlentities($vars['value'], ENT_QUOTES, 'UTF-8');
$name = $vars['name'];
-$src = $vars['src'];
-// blank src if trying to access an offsite image.
-if (strpos($src, elgg_get_site_url()) === false) {
- $src = "";
-}
?>
-<input type="<?php echo $type; ?>" <?php if (isset($vars['id'])) echo "id=\"{$vars['id']}\"";?> <?php echo $vars['js']; ?> value="<?php echo $value; ?>" src="<?php echo $src; ?>" class="<?php echo $class; ?>" /> \ No newline at end of file
+<input type="<?php echo $type; ?>" <?php if (isset($vars['id'])) echo "id=\"{$vars['id']}\"";?> value="<?php echo $value; ?>" class="<?php echo $class; ?>" /> \ No newline at end of file
diff --git a/views/installation/input/checkbox.php b/views/installation/input/checkbox.php
index 898fe8458..378eae6fd 100644
--- a/views/installation/input/checkbox.php
+++ b/views/installation/input/checkbox.php
@@ -2,32 +2,29 @@
/**
* 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 mixed $vars['default'] The default value to submit if not checked.
- * Optional, defaults to 0. Set to false for no default.
+ * @uses $var['name']
+ * @uses $vars['value']
+ * @uses $vars['id']
+ * @uses $vars['class']
*/
-$defaults = array(
- 'class' => 'elgg-input-checkbox',
- 'default' => 0,
-);
-
-$vars = array_merge($defaults, $vars);
+if (isset($vars['id'])) {
+ $id = "id=\"{$vars['id']}\"";
+} else {
+ $id = '';
+}
-$default = $vars['default'];
-unset($vars['default']);
+if (isset($vars['class'])) {
+ $id = "class=\"{$vars['class']}\"";
+} else {
+ $id = '';
+}
-if (isset($vars['name']) && $default !== false) {
- echo "<input type=\"hidden\" name=\"{$vars['name']}\" value=\"$default\"/>";
+if (!isset($vars['value'])) {
+ $vars['value'] = $vars['name'];
}
?>
-<input type="checkbox" <?php echo elgg_format_attributes($vars); ?> /> \ No newline at end of file
+<input type="checkbox" <?php echo $id; ?> <?php echo $class; ?> name="<?php echo $vars['name']; ?>" value="<?php echo $vars['value']; ?>" /> \ No newline at end of file
diff --git a/views/installation/input/checkboxes.php b/views/installation/input/checkboxes.php
deleted file mode 100644
index c78fe4db0..000000000
--- a/views/installation/input/checkboxes.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<?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 &#0049;
- *
- * @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'
- *
- */
-
-$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;
-
-$id = (isset($vars['id'])) ? $vars['id'] : '';
-$disabled = (isset($vars['disabled'])) ? $vars['disabled'] : FALSE;
-$js = (isset($vars['js'])) ? $vars['js'] : '';
-
-$class = "elgg-input-checkboxes elgg-$align";
-if ($additional_class) {
- $class = " $additional_class";
-}
-
-if ($options && count($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\" />";
- }
-
- echo "<ul class=\"$class\">";
- foreach ($options as $label => $option) {
- // @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;
- }
-
- $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 = elgg_view('input/checkbox', $input_vars);
-
- echo "<li><label>{$input}{$label}</label></li>";
- }
- echo '</ul>';
-} \ No newline at end of file
diff --git a/views/installation/input/combo.php b/views/installation/input/combo.php
new file mode 100644
index 000000000..508dbcd01
--- /dev/null
+++ b/views/installation/input/combo.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Combination of text box and check box. When the checkbox is checked, the
+ * text field is cleared and disabled.
+ *
+ */
+
+$label = elgg_echo('install:label:combo:' . $vars['name']);
+
+$vars['class'] = "elgg-combo-text";
+echo elgg_view('input/text', $vars);
+
+$vars['class'] = "elgg-combo-checkbox";
+$vars['value'] = "{$vars['name']}-checkbox";
+echo elgg_view('input/checkbox', $vars);
+
+echo "<label class=\"elgg-combo-label\">$label</label>";
+
+echo '<div class="clearfloat"></div>'; \ No newline at end of file
diff --git a/views/installation/input/dropdown.php b/views/installation/input/dropdown.php
index 141ff65b0..46e15c657 100644
--- a/views/installation/input/dropdown.php
+++ b/views/installation/input/dropdown.php
@@ -3,11 +3,7 @@
* Elgg dropdown input
* Displays a dropdown input field
*
- * @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
* @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
@@ -20,7 +16,7 @@ if (!$class) {
$class = "elgg-input-dropdown";
}
?>
-<select name="<?php echo $vars['name']; ?>" <?php echo $vars['js']; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
+<select name="<?php echo $vars['name']; ?>" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
<?php
if ($vars['options_values']) {
foreach($vars['options_values'] as $value => $option) {
diff --git a/views/installation/input/form.php b/views/installation/input/form.php
index b131c9d10..f8730b4f5 100644
--- a/views/installation/input/form.php
+++ b/views/installation/input/form.php
@@ -1,36 +1,26 @@
<?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.
*
- * @package Elgg
- * @subpackage Core
- *
- * @uses $vars['body'] The body of the form (made up of other input/xxx views and html
- * @uses $vars['method'] Method (default POST)
- * @uses $vars['enctype'] How the form is encoded, default blank
+ * @uses $vars['body'] The body of the form (made up of other input/xxx views and html
* @uses $vars['action'] URL of the action being called
- *
+ * @uses $vars['method'] Method (default POST)
+ * @uses $vars['id'] Form id
+ * @uses $vars['name'] Form name
*/
if (isset($vars['id'])) {
- $id = $vars['id'];
+ $id = "id=\"{$vars['id']}\"";
} else {
$id = '';
}
if (isset($vars['name'])) {
- $name = $vars['name'];
+ $name = "name=\"{$vars['name']}\"";
} else {
$name = '';
}
$body = $vars['body'];
$action = $vars['action'];
-if (isset($vars['enctype'])) {
- $enctype = $vars['enctype'];
-} else {
- $enctype = '';
-}
if (isset($vars['method'])) {
$method = $vars['method'];
} else {
@@ -39,13 +29,7 @@ if (isset($vars['method'])) {
$method = strtolower($method);
-// Generate a security header
-$security_header = "";
-if (!isset($vars['disable_security']) || $vars['disable_security'] != true) {
- $security_header = elgg_view('input/securitytoken');
-}
?>
-<form <?php if ($id) { ?>id="<?php echo $id; ?>" <?php } ?> <?php if ($name) { ?>name="<?php echo $name; ?>" <?php } ?> action="<?php echo $action; ?>" method="<?php echo $method; ?>" <?php if ($enctype!="") echo "enctype=\"$enctype\""; ?> <?php echo $vars['js']; ?>>
-<?php echo $security_header; ?>
+<form <?php echo "$id $name"; ?> action="<?php echo $action; ?>" method="<?php echo $method; ?>">
<?php echo $body; ?>
</form> \ No newline at end of file
diff --git a/views/installation/input/hidden.php b/views/installation/input/hidden.php
deleted file mode 100644
index c9800ebbb..000000000
--- a/views/installation/input/hidden.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Create a hidden data field
- * Use this view for forms rather than creating a hidden tag in the wild as it provides
- * extra security which help prevent CSRF attacks.
- *
- * @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
- *
- */
-?>
-<input type="hidden" <?php echo $vars['js']; ?> name="<?php echo $vars['name']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" /> \ No newline at end of file
diff --git a/views/installation/input/longtext.php b/views/installation/input/longtext.php
deleted file mode 100644
index 820a51da4..000000000
--- a/views/installation/input/longtext.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
- * Elgg long text input
- * Displays a long text input field
- *
- * @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
- *
- */
-
-$class = $vars['class'];
-if (!$class) {
- $class = "elgg-input-textarea";
-}
-
-?>
-
-<textarea class="<?php echo $class; ?>" name="<?php echo $vars['name']; ?>" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?>><?php echo $vars['value']; ?></textarea> \ No newline at end of file
diff --git a/views/installation/input/password.php b/views/installation/input/password.php
index 8ba79228d..18811109b 100644
--- a/views/installation/input/password.php
+++ b/views/installation/input/password.php
@@ -3,11 +3,7 @@
* Elgg password input
* Displays a password input field
*
- * @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
*
*/
@@ -18,4 +14,4 @@ if (!$class) {
}
?>
-<input type="password" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['name']; ?>" <?php if (isset($vars['id'])) echo "id=\"{$vars['id']}\""; ?> value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class; ?>" />
+<input type="password" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> name="<?php echo $vars['name']; ?>" <?php if (isset($vars['id'])) echo "id=\"{$vars['id']}\""; ?> value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class; ?>" />
diff --git a/views/installation/input/reset.php b/views/installation/input/reset.php
deleted file mode 100644
index 0c83a92ca..000000000
--- a/views/installation/input/reset.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-/**
- * Create a reset input button
- * Use this view for forms rather than creating a submit/reset button tag in the wild as it provides
- * extra security which help prevent CSRF attacks.
- *
- * @package Elgg
- * @subpackage Core
- */
-
-$vars['type'] = 'reset';
-
-echo elgg_view('input/button', $vars); \ No newline at end of file
diff --git a/views/installation/input/securitytoken.php b/views/installation/input/securitytoken.php
deleted file mode 100644
index 75410848a..000000000
--- a/views/installation/input/securitytoken.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?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/installation/input/submit.php b/views/installation/input/submit.php
index aefb2ada6..5d891c380 100644
--- a/views/installation/input/submit.php
+++ b/views/installation/input/submit.php
@@ -1,11 +1,9 @@
<?php
/**
* Create a submit input button
- * Use this view for forms rather than creating a submit/reset button tag in the wild as it provides
- * extra security which help prevent CSRF attacks.
*
- * @package Elgg
- * @subpackage Core
+ * @uses $vars['value'] The current value, if any
+ * @uses $vars['name'] The name of the input field
*/
$vars['type'] = 'submit';
diff --git a/views/installation/input/text.php b/views/installation/input/text.php
index c59278b40..ec8233461 100644
--- a/views/installation/input/text.php
+++ b/views/installation/input/text.php
@@ -3,22 +3,23 @@
* Elgg text input
* Displays a text input field
*
- * @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
- * @uses $vars['disabled'] If true then control is read-only
- * @uses $vars['class'] Class override
+ * @uses $vars['name'] The name of the input field
+ * @uses $vars['class'] CSS class
+ * @uses $vars['id'] CSS id
*/
-$class = $vars['class'];
-if (!$class) {
- $class = "input-text";
+if (isset($vars['class'])) {
+ $class = "class=\"{$vars['class']}\"";
+} else {
+ $class = "";
+}
+
+if (isset($vars['id'])) {
+ $id = "id=\"{$vars['id']}\"";
+} else {
+ $id = '';
}
?>
-<input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['name']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class ?>"/> \ No newline at end of file
+<input type="text" name="<?php echo $vars['name']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" <?php echo $class; ?> <?php echo $id; ?>/> \ No newline at end of file