diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-16 21:05:54 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-16 21:05:54 +0000 |
commit | d46162271a5ca3c3af690173d0abfcd1ab9f69a1 (patch) | |
tree | f291a6780b492e77e4b54c759bb7995bef1cef39 /views/failsafe/input | |
parent | a1abec1d617c9330d9c06bda2f462d213f013f53 (diff) | |
download | elgg-d46162271a5ca3c3af690173d0abfcd1ab9f69a1.tar.gz elgg-d46162271a5ca3c3af690173d0abfcd1ab9f69a1.tar.bz2 |
Standardized views/failsafe/*
git-svn-id: http://code.elgg.org/elgg/trunk@3558 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/failsafe/input')
-rw-r--r-- | views/failsafe/input/access.php | 90 | ||||
-rw-r--r-- | views/failsafe/input/button.php | 82 | ||||
-rw-r--r-- | views/failsafe/input/checkboxes.php | 89 | ||||
-rw-r--r-- | views/failsafe/input/form.php | 62 | ||||
-rw-r--r-- | views/failsafe/input/hidden.php | 32 | ||||
-rw-r--r-- | views/failsafe/input/longtext.php | 39 | ||||
-rw-r--r-- | views/failsafe/input/pulldown.php | 83 | ||||
-rw-r--r-- | views/failsafe/input/reset.php | 47 | ||||
-rw-r--r-- | views/failsafe/input/submit.php | 47 | ||||
-rw-r--r-- | views/failsafe/input/text.php | 41 |
10 files changed, 316 insertions, 296 deletions
diff --git a/views/failsafe/input/access.php b/views/failsafe/input/access.php index 74fc56ddf..c0dabccaf 100644 --- a/views/failsafe/input/access.php +++ b/views/failsafe/input/access.php @@ -1,51 +1,49 @@ <?php - - /** - * Elgg access level input - * Displays a pulldown input field - * - * @package Elgg - * @subpackage Core - - * @author Curverider Ltd - - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * - */ - - if (isset($vars['class'])) $class = $vars['class']; - if (!$class) $class = "input-access"; - - if ((!isset($vars['options'])) || (!is_array($vars['options']))) - { - $vars['options'] = array(); - $vars['options'] = get_write_access_array(); +/** + * Elgg access level input + * Displays a pulldown input field + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * + */ + +if (isset($vars['class'])) { + $class = $vars['class']; +} +if (!$class) { + $class = "input-access"; +} + +if ((!isset($vars['options'])) || (!is_array($vars['options']))) { + $vars['options'] = array(); + $vars['options'] = get_write_access_array(); +} + +if (is_array($vars['options']) && sizeof($vars['options']) > 0) { + + ?> + + <select name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['js'])) echo $vars['js']; ?> <?php if ((isset($vars['disabled'])) && ($vars['disabled'])) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>"> + <?php + + foreach($vars['options'] as $key => $option) { + if ($key != $vars['value']) { + echo "<option value=\"{$key}\">{$option}</option>"; + } else { + echo "<option value=\"{$key}\" selected=\"selected\">{$option}</option>"; + } } - - if (is_array($vars['options']) && sizeof($vars['options']) > 0) { - -?> - -<select name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['js'])) echo $vars['js']; ?> <?php if ((isset($vars['disabled'])) && ($vars['disabled'])) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>"> -<?php - foreach($vars['options'] as $key => $option) { - if ($key != $vars['value']) { - echo "<option value=\"{$key}\">{$option}</option>"; - } else { - echo "<option value=\"{$key}\" selected=\"selected\">{$option}</option>"; - } - } - -?> -</select> - -<?php + ?> + </select> - } + <?php -?>
\ No newline at end of file +}
\ No newline at end of file diff --git a/views/failsafe/input/button.php b/views/failsafe/input/button.php index 0f6fdf6a5..2c36841df 100644 --- a/views/failsafe/input/button.php +++ b/views/failsafe/input/button.php @@ -1,39 +1,53 @@ <?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 - * @author Curverider Ltd - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * @uses $vars['type'] Submit or reset, defaults to submit. - * @uses $vars['src'] Src of an image - * - */ +/** + * 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 + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['type'] Submit or reset, defaults to submit. + * @uses $vars['src'] Src of an image + * + */ - global $CONFIG; - - $class = $vars['class']; - if (!$class) $class = "submit_button"; +global $CONFIG; - if (isset($vars['type'])) { $type = strtolower($vars['type']); } else { $type = 'submit'; } - 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['internalname']; - $src = $vars['src']; - if (strpos($src,$CONFIG->wwwroot)===false) $src = ""; // blank src if trying to access an offsite image. +$class = $vars['class']; +if (!$class) { + $class = "submit_button"; +} + +if (isset($vars['type'])) { + $type = strtolower($vars['type']); +} else { + $type = 'submit'; +} + +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['internalname']; +$src = $vars['src']; +// blank src if trying to access an offsite image. +if (strpos($src,$CONFIG->wwwroot)===false) { + $src = ""; +} ?> <input type="<?php echo $type; ?>" class="<?php echo $type; ?>_button" <?php echo $vars['js']; ?> value="<?php echo $value; ?>" src="<?php echo $src; ?>" class="<?php echo $class; ?>" />
\ No newline at end of file diff --git a/views/failsafe/input/checkboxes.php b/views/failsafe/input/checkboxes.php index 0e394af55..0cc32958f 100644 --- a/views/failsafe/input/checkboxes.php +++ b/views/failsafe/input/checkboxes.php @@ -1,49 +1,48 @@ <?php +/** + * Elgg checkbox input + * Displays a checkbox input field + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['options'] An array of strings representing the options for the checkbox field + * + */ - /** - * Elgg checkbox input - * Displays a checkbox input field - * - * @package Elgg - * @subpackage Core +$class = $vars['class']; +if (!$class) { + $class = "input-checkboxes"; +} - * @author Curverider Ltd +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\""; + } + } + $labelint = (int) $label; + if ("{$label}" == "{$labelint}") { + $label = $option; + } - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] 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 = "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\""; - } - } - $labelint = (int) $label; - if ("{$label}" == "{$labelint}") { - $label = $option; - } - - $disabled = ""; - if ($vars['disabled']) $disabled = ' disabled="yes" '; - echo "<label><input type=\"checkbox\" $disabled {$vars['js']} name=\"{$vars['internalname']}[]\" {$selected} value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />"; - } - -?>
\ No newline at end of file + $disabled = ""; + if ($vars['disabled']) { + $disabled = ' disabled="yes" '; + } + echo "<label><input type=\"checkbox\" $disabled {$vars['js']} name=\"{$vars['internalname']}[]\" {$selected} value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />"; +}
\ No newline at end of file diff --git a/views/failsafe/input/form.php b/views/failsafe/input/form.php index 99b6f9965..10fe89dcf 100644 --- a/views/failsafe/input/form.php +++ b/views/failsafe/input/form.php @@ -1,27 +1,43 @@ <?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 - * @author Curverider Ltd - * @link http://elgg.org/ - * - * @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['action'] URL of the action being called - * - */ - - if (isset($vars['internalid'])) { $id = $vars['internalid']; } else { $id = ''; } - if (isset($vars['internalname'])) { $name = $vars['internalname']; } 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 { $method = 'POST'; } +/** + * 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 + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @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['action'] URL of the action being called + * + */ + +if (isset($vars['internalid'])) { + $id = $vars['internalid']; +} else { + $id = ''; +} +if (isset($vars['internalname'])) { + $name = $vars['internalname']; +} 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 { + $method = 'POST'; +} ?> <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\""; ?>> diff --git a/views/failsafe/input/hidden.php b/views/failsafe/input/hidden.php index 58b86c25e..dd5c8bb98 100644 --- a/views/failsafe/input/hidden.php +++ b/views/failsafe/input/hidden.php @@ -1,18 +1,18 @@ <?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 - * @author Curverider Ltd - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * - */ +/** + * 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 + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * + */ ?> -<input type="hidden" <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" />
\ No newline at end of file +<input type="hidden" <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" />
\ No newline at end of file diff --git a/views/failsafe/input/longtext.php b/views/failsafe/input/longtext.php index c1f38fe69..9c89583de 100644 --- a/views/failsafe/input/longtext.php +++ b/views/failsafe/input/longtext.php @@ -1,25 +1,24 @@ <?php +/** + * Elgg long text input + * Displays a long text input field + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * + */ - /** - * Elgg long text input - * Displays a long text input field - * - * @package Elgg - * @subpackage Core +$class = $vars['class']; +if (!$class) { + $class = "input-textarea"; +} - * @author Curverider Ltd - - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * - */ - - $class = $vars['class']; - if (!$class) $class = "input-textarea"; - ?> -<textarea class="<?php echo $class; ?>" name="<?php echo $vars['internalname']; ?>" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?>><?php echo $vars['value']; ?></textarea>
\ No newline at end of file +<textarea class="<?php echo $class; ?>" name="<?php echo $vars['internalname']; ?>" <?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/failsafe/input/pulldown.php b/views/failsafe/input/pulldown.php index 1adbad099..6ad12eec4 100644 --- a/views/failsafe/input/pulldown.php +++ b/views/failsafe/input/pulldown.php @@ -1,52 +1,45 @@ <?php - - /** - * Elgg pulldown input - * Displays a pulldown input field - * - * @package Elgg - * @subpackage Core - - * @author Curverider Ltd - - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * @uses $vars['options'] An array of strings representing the options for the pulldown 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 = $vars['class']; - if (!$class) $class = "input-pulldown"; - +/** + * Elgg pulldown input + * Displays a pulldown input field + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['options'] An array of strings representing the options for the pulldown 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 = $vars['class']; +if (!$class) { + $class = "input-pulldown"; +} ?> - - <select name="<?php echo $vars['internalname']; ?>" <?php echo $vars['js']; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>"> <?php - if ($vars['options_values']) - { - foreach($vars['options_values'] as $value => $option) { - if ($value != $vars['value']) { - echo "<option value=\"$value\">{$option}</option>"; - } else { - echo "<option value=\"$value\" selected=\"selected\">{$option}</option>"; - } - } +if ($vars['options_values']) { + foreach($vars['options_values'] as $value => $option) { + if ($value != $vars['value']) { + echo "<option value=\"$value\">{$option}</option>"; + } else { + echo "<option value=\"$value\" selected=\"selected\">{$option}</option>"; + } } - else - { - foreach($vars['options'] as $option) { - if ($option != $vars['value']) { - echo "<option>{$option}</option>"; - } else { - echo "<option selected=\"selected\">{$option}</option>"; - } - } +} else { + foreach($vars['options'] as $option) { + if ($option != $vars['value']) { + echo "<option>{$option}</option>"; + } else { + echo "<option selected=\"selected\">{$option}</option>"; + } } -?> +} +?> </select>
\ No newline at end of file diff --git a/views/failsafe/input/reset.php b/views/failsafe/input/reset.php index 96fc57a4f..bb8d278c3 100644 --- a/views/failsafe/input/reset.php +++ b/views/failsafe/input/reset.php @@ -1,25 +1,26 @@ <?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 - * @author Curverider Ltd - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * @uses $vars['type'] Submit or reset, defaults to submit. - * - */ +/** + * 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 + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['type'] Submit or reset, defaults to submit. + * + */ - $vars['type'] = 'reset'; - $class = $vars['class']; - if (!$class) $class = "submit_button"; - $vars['class'] = $class; - - echo elgg_view('input/button', $vars); -?>
\ No newline at end of file +$vars['type'] = 'reset'; +$class = $vars['class']; +if (!$class) { + $class = "submit_button"; +} +$vars['class'] = $class; + +echo elgg_view('input/button', $vars);
\ No newline at end of file diff --git a/views/failsafe/input/submit.php b/views/failsafe/input/submit.php index 79d6522b9..cfa7989d0 100644 --- a/views/failsafe/input/submit.php +++ b/views/failsafe/input/submit.php @@ -1,25 +1,26 @@ <?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 - * @author Curverider Ltd - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * @uses $vars['type'] Submit or reset, defaults to submit. - * - */ +/** + * 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 + * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['type'] Submit or reset, defaults to submit. + * + */ - $vars['type'] = 'submit'; - $class = $vars['class']; - if (!$class) $class = "submit_button"; - $vars['class'] = $class; - - echo elgg_view('input/button', $vars); -?>
\ No newline at end of file +$vars['type'] = 'submit'; +$class = $vars['class']; +if (!$class) { + $class = "submit_button"; +} +$vars['class'] = $class; + +echo elgg_view('input/button', $vars);
\ No newline at end of file diff --git a/views/failsafe/input/text.php b/views/failsafe/input/text.php index 4c37e5219..f94ee0135 100644 --- a/views/failsafe/input/text.php +++ b/views/failsafe/input/text.php @@ -1,27 +1,26 @@ <?php +/** + * Elgg text input + * Displays a text input field + * + * @package Elgg + * @subpackage Core - /** - * Elgg text input - * Displays a text input field - * - * @package Elgg - * @subpackage Core + * @author Curverider Ltd - * @author Curverider Ltd + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['disabled'] If true then control is read-only + * @uses $vars['class'] Class override + */ - * @link http://elgg.org/ - * - * @uses $vars['value'] The current value, if any - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * @uses $vars['disabled'] If true then control is read-only - * @uses $vars['class'] Class override - */ +$class = $vars['class']; +if (!$class) { + $class = "input-text"; +} - - $class = $vars['class']; - if (!$class) $class = "input-text"; - ?> - -<input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class ?>"/>
\ No newline at end of file +<input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class ?>"/>
\ No newline at end of file |