浏览代码

fix helper

euromark 11 年之前
父节点
当前提交
58216e35b0
共有 2 个文件被更改,包括 10 次插入9 次删除
  1. 1 1
      Test/Case/View/Helper/FormatHelperTest.php
  2. 9 8
      View/Helper/FormatHelper.php

+ 1 - 1
Test/Case/View/Helper/FormatHelperTest.php

@@ -186,7 +186,7 @@ class FormatHelperTest extends MyCakeTestCase {
 			'prev' => 'fa fa-prev',
 			'next' => 'fa fa-next');
 		$result = $this->Format->neighbors($neighbors, 'foo');
-		$expected = '<div class="next-prev-navi nextPrevNavi"><a href="/index/1" title="bar"><i class="fa fa-prev prev" title="Prev" data-placement="bottom" data-toggle="tooltip"></i>&nbsp;prevRecord</a>&nbsp;&nbsp;<a href="/index/2" title="y"><i class="fa fa-next next" title="Next" data-placement="bottom" data-toggle="tooltip"></i>&nbsp;nextRecord</a></div>';
+		$expected = '<div class="next-prev-navi nextPrevNavi"><a href="/index/1" title="bar"><i class="fa fa-prev prev" title="" data-placement="bottom" data-toggle="tooltip"></i>&nbsp;prevRecord</a>&nbsp;&nbsp;<a href="/index/2" title="y"><i class="fa fa-next next" title="" data-placement="bottom" data-toggle="tooltip"></i>&nbsp;nextRecord</a></div>';
 		$this->assertEquals($expected, $result);
 	}
 

+ 9 - 8
View/Helper/FormatHelper.php

@@ -404,15 +404,16 @@ class FormatHelper extends TextHelper {
 		}
 
 		$type = extractPathInfo('filename', $icon);
-		$title = isset($t) ? $t : ucfirst($type);
-		$alt = (isset($a) ? $a : Inflector::slug($title, '-'));
-		if ($translate !== false) {
-			$title = __($title);
-			$alt = __($alt);
-		}
-		$alt = '[' . $alt . ']';
 
 		if (!$this->settings['fontIcons'] || !isset($this->settings['fontIcons'][$type])) {
+			$title = isset($t) ? $t : ucfirst($type);
+			$alt = (isset($a) ? $a : Inflector::slug($title, '-'));
+			if ($translate !== false) {
+				$title = __($title);
+				$alt = __($alt);
+			}
+			$alt = '[' . $alt . ']';
+
 			$defaults = array('title' => $title, 'alt' => $alt, 'class' => 'icon');
 			$options += $defaults;
 			if (substr($icon, 0, 1) !== '/') {
@@ -421,7 +422,7 @@ class FormatHelper extends TextHelper {
 			return $this->Html->image($icon, $options);
 		}
 
-		$options['title'] = $title;
+		$options['title'] = $t;
 		$options['translate'] = $translate;
 		return $this->_fontIcon($type, $options);
 	}