From c66831fa5138a277a9729174caf14c7eb323fb07 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 16 Oct 2009 20:26:12 +0000 Subject: Standardizing views.` git-svn-id: http://code.elgg.org/elgg/trunk@3555 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/input/access.php | 102 ++++++++++++++-------------- views/default/input/autocomplete.php | 123 +++++++++++++++++----------------- views/default/input/button.php | 88 ++++++++++++++---------- views/default/input/calendar.php | 66 +++++++++--------- views/default/input/captcha.php | 16 ++--- views/default/input/checkboxes.php | 93 +++++++++++++------------ views/default/input/email.php | 37 +++++----- views/default/input/file.php | 41 ++++++------ views/default/input/form.php | 74 ++++++++++++-------- views/default/input/hidden.php | 32 ++++----- views/default/input/longtext.php | 37 +++++----- views/default/input/password.php | 39 ++++++----- views/default/input/plaintext.php | 39 ++++++----- views/default/input/pulldown.php | 80 ++++++++++------------ views/default/input/radio.php | 73 ++++++++++---------- views/default/input/reset.php | 47 ++++++------- views/default/input/securitytoken.php | 31 +++++---- views/default/input/submit.php | 49 +++++++------- views/default/input/tags.php | 78 ++++++++++----------- views/default/input/text.php | 41 ++++++------ views/default/input/url.php | 39 ++++++----- views/default/input/urlshortener.php | 16 ++--- views/default/input/userpicker.php | 29 ++++---- 23 files changed, 646 insertions(+), 624 deletions(-) (limited to 'views/default/input') diff --git a/views/default/input/access.php b/views/default/input/access.php index 461fbf625..42247af61 100644 --- a/views/default/input/access.php +++ b/views/default/input/access.php @@ -1,55 +1,53 @@ 0) { + ?> + + name="" class=""> - $option) { - if ($key != $vars['value']) { - echo ""; - } else { - echo ""; - } - } - -?> - - - \ No newline at end of file + ?> + + $vars['match_on'], + 'match_owner' => $vars['match_owner'], +)); +$ac_url = $vars['url'] . 'pg/autocomplete?' . $ac_url_params; + +if (!isset($autocomplete_js_loaded)) { + $autocomplete_js_loaded = false; +} - /** - * Displays an autocomplete text input. - * - * @package Elgg - * @subpackage Core - * @author Curverider Ltd - * @link http://elgg.org/ - * - * @TODO: This currently only works for ONE AUTOCOMPLETE TEXT FIELD on a page. - * - * @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['match_on'] Array | str What to match on. all|array(group|user|friend|subtype) - * @uses $vars['match_owner'] Bool. Match only entities that are owned by logged in user. - * - */ - - global $autocomplete_js_loaded; - - $internalname = $vars['internalname']; - $value = $vars['value']; - - if(!$value) - $value= ''; - - if($vars['internal_id']) - $id_autocomplete = $vars['internal_id']; - - $ac_url_params = http_build_query(array( - 'match_on' => $vars['match_on'], - 'match_owner' => $vars['match_owner'], - )); - $ac_url = $vars['url'] . 'pg/autocomplete?' . $ac_url_params; - - if (!isset($autocomplete_js_loaded)) $autocomplete_js_loaded = false; - ?> - - - + + + +if (!$autocomplete_js_loaded) { + ?> - - - + + - - - - + + + wwwroot)===false) $src = ""; // blank src if trying to access an offsite image. +if (isset($vars['class'])) { + $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'); +if (isset($vars['internalname'])) { + $name = $vars['internalname']; +} +if (isset($vars['src'])) { + $src = "src=\"{$vars['src']}\""; +} +// blank src if trying to access an offsite image. +if (strpos($src,$CONFIG->wwwroot)===false) { + $src = ""; +} ?> type="" class="" value="" /> \ No newline at end of file diff --git a/views/default/input/calendar.php b/views/default/input/calendar.php index 9dd5b2dc0..12cbf95ec 100644 --- a/views/default/input/calendar.php +++ b/views/default/input/calendar.php @@ -1,44 +1,40 @@ - - + END; - $calendarjs = 1; - } - $strippedname = sanitise_string($vars['internalname']); - $js = "cal" . $strippedname; + $calendarjs = 1; +} +$strippedname = sanitise_string($vars['internalname']); +$js = "cal" . $strippedname; + +if ($vars['value'] > 86400) { + $val = date("F j, Y",$vars['value']); +} else { + $val = $vars['value']; +} - if ($vars['value'] > 86400) { - $val = date("F j, Y",$vars['value']); - } else { - $val = $vars['value']; - } - ?> name="" id="" value="" /> -select \ No newline at end of file +select \ No newline at end of file diff --git a/views/default/input/captcha.php b/views/default/input/captcha.php index f4ebc218a..d1d780e77 100644 --- a/views/default/input/captcha.php +++ b/views/default/input/captcha.php @@ -1,10 +1,10 @@ \ No newline at end of file diff --git a/views/default/input/checkboxes.php b/views/default/input/checkboxes.php index 4e806bbfc..7d03db257 100644 --- a/views/default/input/checkboxes.php +++ b/views/default/input/checkboxes.php @@ -1,52 +1,49 @@ 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'])) { + $valarray = $vars['value']; + $valarray = array_map('strtolower', $valarray); + if (!in_array(strtolower($option),$valarray)) { + $selected = ""; + } else { + $selected = "checked = \"checked\""; + } + } else { + if (strtolower($option) != strtolower($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 label => 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'])) { - $valarray = $vars['value']; - $valarray = array_map('strtolower', $valarray); - if (!in_array(strtolower($option),$valarray)) { - $selected = ""; - } else { - $selected = "checked = \"checked\""; - } - } else { - if (strtolower($option) != strtolower($vars['value'])) { - $selected = ""; - } else { - $selected = "checked = \"checked\""; - } - } - $labelint = (int) $label; - if ("{$label}" == "{$labelint}") { - $label = $option; - } - - if (isset($vars['internalid'])) $id = "id=\"{$vars['internalid']}\""; - $disabled = ""; - if ($vars['disabled']) $disabled = ' disabled="yes" '; - echo "
"; - } - -?> \ No newline at end of file + if (isset($vars['internalid'])) $id = "id=\"{$vars['internalid']}\""; + $disabled = ""; + if ($vars['disabled']) $disabled = ' disabled="yes" '; + echo "
"; +} \ No newline at end of file diff --git a/views/default/input/email.php b/views/default/input/email.php index e1fb61eab..bd2892e97 100644 --- a/views/default/input/email.php +++ b/views/default/input/email.php @@ -1,24 +1,25 @@ - name="" value="" class=""/> \ No newline at end of file + name="" value="" class=""/> \ No newline at end of file diff --git a/views/default/input/file.php b/views/default/input/file.php index e707e3ee0..15cc011f6 100644 --- a/views/default/input/file.php +++ b/views/default/input/file.php @@ -1,26 +1,25 @@ "; +} - * @author Curverider Ltd - - * @link http://elgg.org/ - * - * @uses $vars['js'] Any Javascript to enter into the input tag - * @uses $vars['internalname'] The name of the input field - * - */ - - if (!empty($vars['value'])) { - echo elgg_echo('fileexists') . "
"; - } - - $class = $vars['class']; - if (!$class) $class = "input-file"; +$class = $vars['class']; +if (!$class) { + $class = "input-file"; +} ?> name="" class="" /> \ No newline at end of file diff --git a/views/default/input/form.php b/views/default/input/form.php index 0a4619ac1..25f140a01 100644 --- a/views/default/input/form.php +++ b/views/default/input/form.php @@ -1,34 +1,50 @@
id="" name="" action="" method="" > diff --git a/views/default/input/hidden.php b/views/default/input/hidden.php index 2338a66bb..e95779367 100644 --- a/views/default/input/hidden.php +++ b/views/default/input/hidden.php @@ -1,18 +1,18 @@ - name="" value="" /> \ No newline at end of file + name="" value="" /> \ No newline at end of file diff --git a/views/default/input/longtext.php b/views/default/input/longtext.php index 86b0f3fc4..f60e29a70 100644 --- a/views/default/input/longtext.php +++ b/views/default/input/longtext.php @@ -1,25 +1,22 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/views/default/input/password.php b/views/default/input/password.php index 8ab0b6935..90ee984d4 100644 --- a/views/default/input/password.php +++ b/views/default/input/password.php @@ -1,24 +1,23 @@ - name="" value="" class="" /> \ No newline at end of file + name="" value="" class="" /> \ No newline at end of file diff --git a/views/default/input/plaintext.php b/views/default/input/plaintext.php index a99084a43..e177f8b3f 100644 --- a/views/default/input/plaintext.php +++ b/views/default/input/plaintext.php @@ -1,25 +1,24 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/views/default/input/pulldown.php b/views/default/input/pulldown.php index 6aa69f428..03143d677 100644 --- a/views/default/input/pulldown.php +++ b/views/default/input/pulldown.php @@ -1,52 +1,46 @@ "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"; +} ?> - \ No newline at end of file diff --git a/views/default/input/radio.php b/views/default/input/radio.php index 12e40ccdd..c6163b141 100644 --- a/views/default/input/radio.php +++ b/views/default/input/radio.php @@ -1,40 +1,41 @@ option + * + */ - /** - * Elgg radio input - * Displays a radio input field - * - * @package Elgg - * @subpackage Core +$class = $vars['class']; +if (!$class) { + $class = "input-radio"; +} - * @author Curverider Ltd +foreach($vars['options'] as $label => $option) { + if (strtolower($option) != strtolower($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 radio field as "label" => option - * - */ - - $class = $vars['class']; - if (!$class) $class = "input-radio"; - - foreach($vars['options'] as $label => $option) { - if (strtolower($option) != strtolower($vars['value'])) { - $selected = ""; - } else { - $selected = "checked = \"checked\""; - } - $labelint = (int) $label; - if ("{$label}" == "{$labelint}") { - $label = $option; - } - - if (isset($vars['internalid'])) $id = "id=\"{$vars['internalid']}\""; - if ($vars['disabled']) $disabled = ' disabled="yes" '; - echo "
"; - } - -?> \ No newline at end of file + if (isset($vars['internalid'])) { + $id = "id=\"{$vars['internalid']}\""; + } + if ($vars['disabled']) { + $disabled = ' disabled="yes" '; + } + echo "
"; +} \ No newline at end of file diff --git a/views/default/input/reset.php b/views/default/input/reset.php index 96fc57a4f..bb8d278c3 100644 --- a/views/default/input/reset.php +++ b/views/default/input/reset.php @@ -1,25 +1,26 @@ \ 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/default/input/securitytoken.php b/views/default/input/securitytoken.php index fa202548e..a2a4a0e01 100644 --- a/views/default/input/securitytoken.php +++ b/views/default/input/securitytoken.php @@ -1,18 +1,17 @@ '__elgg_token', 'value' => $token)); - echo elgg_view('input/hidden', array('internalname' => '__elgg_ts', 'value' => $ts)); -?> +$ts = time(); +$token = generate_action_token($ts); + +echo elgg_view('input/hidden', array('internalname' => '__elgg_token', 'value' => $token)); +echo elgg_view('input/hidden', array('internalname' => '__elgg_ts', 'value' => $ts)); diff --git a/views/default/input/submit.php b/views/default/input/submit.php index 66e5c543b..b0c72791f 100644 --- a/views/default/input/submit.php +++ b/views/default/input/submit.php @@ -1,25 +1,28 @@ \ No newline at end of file +$vars['type'] = 'submit'; +if (isset($vars['class'])) { + $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/default/input/tags.php b/views/default/input/tags.php index 8793756e2..172875004 100644 --- a/views/default/input/tags.php +++ b/views/default/input/tags.php @@ -1,45 +1,45 @@ -value; + } + } + } else { + $tags = $vars['value']; + } +} - $tags = ""; - if (!empty($vars['value'])) { - if (is_array($vars['value'])) { - foreach($vars['value'] as $tag) { - - if (!empty($tags)) { - $tags .= ", "; - } - if (is_string($tag)) { - $tags .= $tag; - } else { - $tags .= $tag->value; - } - - } - } else { - $tags = $vars['value']; - } - } - ?> - name="" value="" class=""/> \ No newline at end of file + name="" value="" class=""/> \ No newline at end of file diff --git a/views/default/input/text.php b/views/default/input/text.php index 2a30ba081..1814e5801 100644 --- a/views/default/input/text.php +++ b/views/default/input/text.php @@ -1,27 +1,28 @@ - name="" value="" class=""/> \ No newline at end of file + name="" value="" class=""/> \ No newline at end of file diff --git a/views/default/input/url.php b/views/default/input/url.php index 82fde938e..6bf19d319 100644 --- a/views/default/input/url.php +++ b/views/default/input/url.php @@ -1,24 +1,23 @@ - name="" value="" class=""/> \ No newline at end of file + name="" value="" class=""/> \ No newline at end of file diff --git a/views/default/input/urlshortener.php b/views/default/input/urlshortener.php index 4707809f5..7a8c2786a 100644 --- a/views/default/input/urlshortener.php +++ b/views/default/input/urlshortener.php @@ -1,10 +1,10 @@ \ No newline at end of file diff --git a/views/default/input/userpicker.php b/views/default/input/userpicker.php index efe83ec14..742554dbd 100644 --- a/views/default/input/userpicker.php +++ b/views/default/input/userpicker.php @@ -1,23 +1,23 @@ -$1"); var desc = info.desc.replace(new RegExp("(" + term + ")", "gi"), "$1"); - + switch (info.type) { case 'user': case 'group': r = info.icon + name + ' - ' + desc; break; - + default: r = name + ' - ' + desc; break; @@ -103,10 +103,10 @@ function userPickerAddUser(event, data, formatted) { var internalName = picker.find('input.internalname').val(); // not sure why formatted isn't. var formatted = userPickerFormatItem(data); - + // add guid as hidden input and to list. var li = formatted + ' X' - + ''; + + ''; $('
  • ').html(li).appendTo(users); $(this).val(''); @@ -137,11 +137,10 @@ $(document).ready(function() { - +
      - -- cgit v1.2.3