diff options
Diffstat (limited to 'views/installation/input')
| -rw-r--r-- | views/installation/input/access.php | 15 | ||||
| -rw-r--r-- | views/installation/input/button.php | 33 | ||||
| -rw-r--r-- | views/installation/input/checkbox.php | 24 | ||||
| -rw-r--r-- | views/installation/input/checkboxes.php | 48 | ||||
| -rw-r--r-- | views/installation/input/combo.php | 19 | ||||
| -rw-r--r-- | views/installation/input/dropdown.php | 19 | ||||
| -rw-r--r-- | views/installation/input/form.php | 33 | ||||
| -rw-r--r-- | views/installation/input/hidden.php | 16 | ||||
| -rw-r--r-- | views/installation/input/longtext.php | 22 | ||||
| -rw-r--r-- | views/installation/input/password.php | 14 | ||||
| -rw-r--r-- | views/installation/input/reset.php | 13 | ||||
| -rw-r--r-- | views/installation/input/securitytoken.php | 15 | ||||
| -rw-r--r-- | views/installation/input/submit.php | 6 | ||||
| -rw-r--r-- | views/installation/input/text.php | 22 |
14 files changed, 86 insertions, 213 deletions
diff --git a/views/installation/input/access.php b/views/installation/input/access.php index 3fde7295f..c3d4713bc 100644 --- a/views/installation/input/access.php +++ b/views/installation/input/access.php @@ -3,21 +3,12 @@ * 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 * */ -if (isset($vars['class'])) { - $class = $vars['class']; -} -if (!$class) { - $class = "elgg-input-access"; -} +$class = "elgg-input-access"; if ((!isset($vars['options'])) || (!is_array($vars['options']))) { $vars['options'] = array(); @@ -28,7 +19,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']; ?>" class="<?php echo $class; ?>"> <?php foreach($vars['options'] as $key => $option) { @@ -44,4 +35,4 @@ if (is_array($vars['options']) && sizeof($vars['options']) > 0) { <?php -}
\ No newline at end of file +} diff --git a/views/installation/input/button.php b/views/installation/input/button.php index a69f7dbfa..ec90fed9d 100644 --- a/views/installation/input/button.php +++ b/views/installation/input/button.php @@ -1,25 +1,24 @@ <?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']; -if (!$class) { +if (isset($vars['class'])) { + $class = $vars['class']; +} else { $class = "elgg-button-submit"; } +if (isset($vars['name'])) { + $name = $vars['name']; +} else { + $name = ''; +} + if (isset($vars['type'])) { $type = strtolower($vars['type']); } else { @@ -30,20 +29,12 @@ switch ($type) { case 'button' : $type='button'; break; - case 'reset' : - $type='reset'; - break; case 'submit': default: $type = 'submit'; } $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; ?>" 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 new file mode 100644 index 000000000..6fbe25169 --- /dev/null +++ b/views/installation/input/checkbox.php @@ -0,0 +1,24 @@ +<?php +/** + * Elgg checkbox input + * Displays a checkbox input tag + * + * @uses $var['name'] + * @uses $vars['value'] + * @uses $vars['class'] + */ + + +if (isset($vars['class'])) { + $id = "class=\"{$vars['class']}\""; +} else { + $id = ''; +} + +if (!isset($vars['value'])) { + $vars['value'] = $vars['name']; +} + +?> + +<input type="checkbox" <?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 164509831..000000000 --- a/views/installation/input/checkboxes.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Elgg checkbox input - * Displays a checkbox 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 checkbox field - * - */ - -$class = $vars['class']; -if (!$class) { - $class = "elgg-input-checkboxes"; -} - -foreach($vars['options'] as $label => $option) { - //if (!in_array($option,$vars['value'])) { - if (is_array($vars['value'])) { - if (!in_array($option,$vars['value'])) { - $selected = ""; - } else { - $selected = "checked = \"checked\""; - } - } else { - if ($option != $vars['value']) { - $selected = ""; - } else { - $selected = "checked = \"checked\""; - } - } - - // handle indexed array where label is not specified - // @todo deprecate in Elgg 1.8 - if (is_integer($label)) { - $label = $option; - } - - $disabled = ""; - if ($vars['disabled']) { - $disabled = ' disabled="yes" '; - } - echo "<label><input type=\"checkbox\" $disabled {$vars['js']} name=\"{$vars['name']}[]\" {$selected} value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />"; -}
\ 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..cf875492e 100644 --- a/views/installation/input/dropdown.php +++ b/views/installation/input/dropdown.php @@ -3,27 +3,20 @@ * 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 * the value displayed on the button. Replaces $vars['options'] when defined. */ +$class = "elgg-input-dropdown"; -$class = $vars['class']; -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']; ?>" class="<?php echo $class; ?>"> <?php -if ($vars['options_values']) { - foreach($vars['options_values'] as $value => $option) { +if (isset($vars['options_values'])) { + foreach ($vars['options_values'] as $value => $option) { if ($value != $vars['value']) { echo "<option value=\"$value\">{$option}</option>"; } else { @@ -31,7 +24,7 @@ if ($vars['options_values']) { } } } else { - foreach($vars['options'] as $option) { + foreach ($vars['options'] as $option) { if ($option != $vars['value']) { echo "<option>{$option}</option>"; } else { @@ -40,4 +33,4 @@ if ($vars['options_values']) { } } ?> -</select>
\ No newline at end of file +</select> diff --git a/views/installation/input/form.php b/views/installation/input/form.php index b131c9d10..3556413a8 100644 --- a/views/installation/input/form.php +++ b/views/installation/input/form.php @@ -1,36 +1,21 @@ <?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['name'] Form name */ -if (isset($vars['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 +24,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 $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..2265ab117 100644 --- a/views/installation/input/password.php +++ b/views/installation/input/password.php @@ -3,19 +3,15 @@ * 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 * */ -$class = $vars['class']; -if (!$class) { - $class = "input-password"; -} +$class = "input-password"; + +$value = htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); + ?> -<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" name="<?php echo $vars['name']; ?>" value="<?php echo $value; ?>" 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..375b91c44 100644 --- a/views/installation/input/text.php +++ b/views/installation/input/text.php @@ -3,22 +3,18 @@ * 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 */ -$class = $vars['class']; -if (!$class) { - $class = "input-text"; +if (isset($vars['class'])) { + $class = "class=\"{$vars['class']}\""; +} else { + $class = "elgg-input-text"; } +$value = htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); + ?> -<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 $value; ?>" <?php echo $class; ?> />
\ No newline at end of file |
