Skip to content
This repository
Browse code

Remove duplicate methods.

Fix regression where #1345 was re-introduced.
Fixes #2434
  • Loading branch information...
commit 3e1c567f083f22b2beed15f61347ad41e6eca2ab 1 parent c43b099
Mark Story authored January 03, 2012
4  lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
@@ -1521,6 +1521,10 @@ public function testParseAttributeCompact() {
1521 1521
 		}
1522 1522
 		$this->assertEquals($helper->parseAttributes(array('compact')), ' compact="compact"');
1523 1523
 
  1524
+		$attrs = array('class' => array('foo', 'bar'));
  1525
+		$expected = ' class="foo bar"';
  1526
+		$this->assertEquals(' class="foo bar"', $helper->parseAttributes($attrs));
  1527
+
1524 1528
 		$helper = new Html5TestHelper($this->View);
1525 1529
 		$expected = ' require';
1526 1530
 		$this->assertEquals($helper->parseAttributes(array('require')), $expected);
6  lib/Cake/View/Helper.php
@@ -356,7 +356,7 @@ public function clean($output) {
356 356
  * @param string $insertBefore String to be inserted before options.
357 357
  * @param string $insertAfter String to be inserted after options.
358 358
  * @return string Composed attributes.
359  
- * @deprecated This method has been moved to HtmlHelper
  359
+ * @deprecated This method will be moved to HtmlHelper in 3.0
360 360
  */
361 361
 	protected function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
362 362
 		if (!is_string($options)) {
@@ -390,12 +390,12 @@ protected function _parseAttributes($options, $exclude = null, $insertBefore = '
390 390
  * @param string $value The value of the attribute to create.
391 391
  * @param boolean $escape Define if the value must be escaped
392 392
  * @return string The composed attribute.
393  
- * @deprecated This method has been moved to HtmlHelper
  393
+ * @deprecated This method will be moved to HtmlHelper in 3.0
394 394
  */
395 395
 	protected function _formatAttribute($key, $value, $escape = true) {
396 396
 		$attribute = '';
397 397
 		if (is_array($value)) {
398  
-			$value = '';
  398
+			$value = implode(' ' , $value);
399 399
 		}
400 400
 
401 401
 		if (is_numeric($key)) {
89  lib/Cake/View/Helper/HtmlHelper.php
@@ -1029,93 +1029,4 @@ public function loadConfig($configFile, $path = null) {
1029 1029
 		return $configs;
1030 1030
 	}
1031 1031
 
1032  
-/**
1033  
- * Returns a space-delimited string with items of the $options array. If a
1034  
- * key of $options array happens to be one of:
1035  
- *
1036  
- * - 'compact'
1037  
- * - 'checked'
1038  
- * - 'declare'
1039  
- * - 'readonly'
1040  
- * - 'disabled'
1041  
- * - 'selected'
1042  
- * - 'defer'
1043  
- * - 'ismap'
1044  
- * - 'nohref'
1045  
- * - 'noshade'
1046  
- * - 'nowrap'
1047  
- * - 'multiple'
1048  
- * - 'noresize'
1049  
- *
1050  
- * And its value is one of:
1051  
- *
1052  
- * - '1' (string)
1053  
- * - 1 (integer)
1054  
- * - true (boolean)
1055  
- * - 'true' (string)
1056  
- *
1057  
- * Then the value will be reset to be identical with key's name.
1058  
- * If the value is not one of these 3, the parameter is not output.
1059  
- *
1060  
- * 'escape' is a special option in that it controls the conversion of
1061  
- *  attributes to their html-entity encoded equivalents.  Set to false to disable html-encoding.
1062  
- *
1063  
- * If value for any option key is set to `null` or `false`, that option will be excluded from output.
1064  
- *
1065  
- * @param array $options Array of options.
1066  
- * @param array $exclude Array of options to be excluded, the options here will not be part of the return.
1067  
- * @param string $insertBefore String to be inserted before options.
1068  
- * @param string $insertAfter String to be inserted after options.
1069  
- * @return string Composed attributes.
1070  
- */
1071  
-	protected function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
1072  
-		if (is_array($options)) {
1073  
-			$options = array_merge(array('escape' => true), $options);
1074  
-
1075  
-			if (!is_array($exclude)) {
1076  
-				$exclude = array();
1077  
-			}
1078  
-			$filtered = array_diff_key($options, array_merge(array_flip($exclude), array('escape' => true)));
1079  
-			$escape = $options['escape'];
1080  
-			$attributes = array();
1081  
-
1082  
-			foreach ($filtered as $key => $value) {
1083  
-				if ($value !== false && $value !== null) {
1084  
-					$attributes[] = $this->_formatAttribute($key, $value, $escape);
1085  
-				}
1086  
-			}
1087  
-			$out = implode(' ', $attributes);
1088  
-		} else {
1089  
-			$out = $options;
1090  
-		}
1091  
-		return $out ? $insertBefore . $out . $insertAfter : '';
1092  
-	}
1093  
-
1094  
-/**
1095  
- * Formats an individual attribute, and returns the string value of the composed attribute.
1096  
- * Works with minimized attributes that have the same value as their name such as 'disabled' and 'checked'
1097  
- *
1098  
- * @param string $key The name of the attribute to create
1099  
- * @param string $value The value of the attribute to create.
1100  
- * @param boolean $escape Define if the value must be escaped
1101  
- * @return string The composed attribute.
1102  
- */
1103  
-	protected function _formatAttribute($key, $value, $escape = true) {
1104  
-		$attribute = '';
1105  
-		if (is_array($value)) {
1106  
-			$value = '';
1107  
-		}
1108  
-
1109  
-		if (is_numeric($key)) {
1110  
-			$attribute = sprintf($this->_minimizedAttributeFormat, $value, $value);
1111  
-		} elseif (in_array($key, $this->_minimizedAttributes)) {
1112  
-			if ($value === 1 || $value === true || $value === 'true' || $value === '1' || $value == $key) {
1113  
-				$attribute = sprintf($this->_minimizedAttributeFormat, $key, $key);
1114  
-			}
1115  
-		} else {
1116  
-			$attribute = sprintf($this->_attributeFormat, $key, ($escape ? h($value) : $value));
1117  
-		}
1118  
-		return $attribute;
1119  
-	}
1120  
-
1121 1032
 }

0 notes on commit 3e1c567

Please sign in to comment.
Something went wrong with that request. Please try again.