]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2143: DRY up button input views (button, reset, submit). Changed core uses...
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Nov 2010 07:12:04 +0000 (07:12 +0000)
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Nov 2010 07:12:04 +0000 (07:12 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7364 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/blog/views/default/blog/forms/edit.php
mod/diagnostics/index.php
mod/ecml/views/default/embed/web_services/content.php
mod/uservalidationbyemail/views/default/admin/users/unvalidated.php
views/default/admin/plugins/advanced.php
views/default/input/button.php
views/default/input/reset.php
views/default/input/submit.php
views/installation/input/reset.php
views/installation/input/submit.php

index 2b07fae9415c8a9cfa70274e979131a4d7ca9fa3..60012dac6454687a064b9b676cc46f657ccb5c98 100644 (file)
@@ -72,7 +72,7 @@ if (isset ($vars['entity'])) {
        ));
 }
 
-$save_button = elgg_view('input/submit', array('value' => elgg_echo('save'), 'class' => 'submit_button'));
+$save_button = elgg_view('input/submit', array('value' => elgg_echo('save')));
 $action_buttons = $save_button . $delete_link;
 
 $title_label = elgg_echo('title');
index c7a5cd4b19cbae0238d6e88d236e834a71a65e05..ad77b5085ea3959dd0bc8949113ce659912c8173 100644 (file)
@@ -25,7 +25,7 @@ $test_body .= "<p>" . elgg_echo('diagnostics:unittester:warning') . "</p>";
 if (isset($CONFIG->debug)) {
        // create a button to run tests
        $js = "onclick=\"window.location='".elgg_get_site_url()."engine/tests/suite.php'\"";
-       $params = array('type' => 'button', 'value' => elgg_echo('diagnostics:test:executeall'), 'js' => $js);
+       $params = array('value' => elgg_echo('diagnostics:test:executeall'), 'js' => $js);
        $test_body .= elgg_view('input/button', $params);
 } else {
        // no tests when not in debug mode
index 5c46dfad4236da8561cb3475197cf8b043edc144..b609db448ad59cc4cdb06a66f7832d70b6793a95 100644 (file)
@@ -40,7 +40,7 @@ $input = elgg_view('input/text', array(
        'internalid' => 'web_services_resource'
 ));
 
-$embed = elgg_view('input/button', array(
+$embed = elgg_view('input/submit', array(
        'name' => 'buggy',
        'internalid' => 'embed_submit',
        'type' => 'button',
@@ -109,7 +109,7 @@ $(function() {
                
                var value = $(this).val();
                var value_length = value.length;
-                
+               
                if (value_length > 0) {
                        //embed_button.removeAttr('disabled').removeClass('disabled');//.addClass('embed_warning');
                        url_status.removeClass('success').addClass('failure');
index 279c7387fa2febf8fcaa4cf43249d567528b3e3b..332fac3f9c10e66a9ade1863c56e3c984fa95c04 100644 (file)
@@ -58,7 +58,7 @@ $form_body .= elgg_echo('uservalidationbyemail:admin:with_checked') . elgg_view(
        'value' => 'resend_validation',
 ));
 
-$form_body .= '<br />' . elgg_view('input/button', array('value' => elgg_echo('submit')));
+$form_body .= '<br />' . elgg_view('input/submit', array('value' => elgg_echo('submit')));
 
 echo elgg_view('input/form', array(
        'action' => 'action/uservalidationbyemail/bulk_action',
index 306ddfd7f4702fb77921ac87853b564525bed446..dc5846108e75c28e14dfc74b29f01c7643aa738d 100644 (file)
@@ -43,7 +43,7 @@ $category_pulldown = elgg_view('input/pulldown', array(
        'value' => $show_category
 ));
 
-$category_button = elgg_view('input/button', array(
+$category_button = elgg_view('input/submit', array(
        'value' => elgg_echo('filter'),
        'class' => 'action_button'
 ));
index 906e41b4cdb30cbda20fad006891e68baa8d5b96..1be03e3eb59abe7e11c3991a7e3a7927c8660d72 100644 (file)
@@ -5,61 +5,32 @@
  * @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['internalname'] The name of the input field
- * @uses $vars['internalid'] The id of the input field
- * @uses $vars['type'] Submit, button, or reset, defaults to submit.
  * @uses $vars['src'] Src of an image
- *
  */
 
 global $CONFIG;
 
-if (isset($vars['class'])) {
-       $class = $vars['class'];
-} else {
-       $class = "submit_button";
-}
+$defaults = array(
+       'type' => 'button',
+       'class' => 'submit_button',
+);
 
-if (isset($vars['type'])) {
-       $type = strtolower($vars['type']);
-} else {
-       $type = 'button';
-}
+$vars = array_merge($defaults, $vars);
 
-switch ($type) {
-       case 'button' :
-               $type = 'button';
-               break;
-       case 'reset' :
-               $type = 'reset';
-               break;
+switch ($vars['type']) {
+       case 'button':
+       case 'reset':
        case 'submit':
+       case 'image':
+               break;
        default:
-               $type = 'submit';
-}
-
-$value = htmlentities($vars['value'], ENT_QUOTES, 'UTF-8');
-
-$name = '';
-if (isset($vars['internalname'])) {
-       $name = $vars['internalname'];
-}
-
-$src = '';
-if (isset($vars['src'])) {
-       $src = "src=\"{$vars['src']}\"";
-}
-// blank src if trying to access an offsite image.
-if (strpos($src, $CONFIG->wwwroot) === false) {
-       $src = "";
+               $vars['type'] = 'button';
+               break;
 }
 
-$id = '';
-if (isset($vars['internalid'])) {
-       $id = "id=\"{$vars['internalid']}\"";
+// blank src if trying to access an offsite image. @todo why?
+if (strpos($vars['src'], $CONFIG->wwwroot) === false) {
+       $vars['src'] = "";
 }
-
 ?>
-<input name="<?php echo $name; ?>" <?php echo $id; ?> type="<?php echo $type; ?>" class="<?php echo $class; ?>" <?php echo $vars['js']; ?> value="<?php echo $value; ?>" <?php echo $src; ?> />
\ No newline at end of file
+<input <?php echo elgg_format_attributes($vars); ?> />
\ No newline at end of file
index 1d5e47ccb2c57d6e3334f42f871a8b37f96509f0..d1296e4bfe9ddff37fa4644511901a49648e9fc2 100644 (file)
@@ -1,24 +1,15 @@
 <?php
 /**
  * Create a reset input button
+ *
+ * @todo ... huh?
  * 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['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
index 315a70eac1d408ab2d48ab4d82995da7ff3893f3..39734b8072deb2a5b9dc33d174ad88a273b52faf 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 /**
  * Create a submit input button
+ *
+ * @todo ... huh?
  * 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.
  *
@@ -9,8 +11,5 @@
  */
 
 $vars['type'] = 'submit';
-if (!isset($vars['class'])) {
-       $vars['class'] = "submit_button";
-}
 
 echo elgg_view('input/button', $vars);
\ No newline at end of file
index 1d5e47ccb2c57d6e3334f42f871a8b37f96509f0..0c83a92ca5496a16268710af9429cdc172d387ec 100644 (file)
@@ -6,19 +6,8 @@
  *
  * @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['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
index 0a6d2a06d42915101e674dd6b6e8bafeb83813b9..aefb2ada6a012c0fc803a7eb718b42081a5d936e 100644 (file)
@@ -6,19 +6,8 @@
  *
  * @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['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