euromark 11 年 前
コミット
7589b40b28
2 ファイル変更16 行追加19 行削除
  1. 1 1
      Test/Case/View/Helper/FormatHelperTest.php
  2. 15 18
      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="" 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>';
+		$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>';
 		$this->assertEquals($expected, $result);
 	}
 

+ 15 - 18
View/Helper/FormatHelper.php

@@ -336,6 +336,8 @@ class FormatHelper extends TextHelper {
 	/**
 	 * Quick way of printing default icons
 	 *
+	 * @todo refactor to $type, $options, $attributes
+	 *
 	 * @param type
 	 * @param title
 	 * @param alt (set to FALSE if no alt is supposed to be shown)
@@ -346,8 +348,6 @@ class FormatHelper extends TextHelper {
 	public function icon($type, $t = null, $a = null, $translate = null, $options = array()) {
 		if (isset($t) && $t === false) {
 			$title = '';
-		} elseif (empty($t)) {
-
 		} else {
 			$title = $t;
 		}
@@ -360,22 +360,19 @@ class FormatHelper extends TextHelper {
 			$alt = $a;
 		}
 
-		if (array_key_exists($type, $this->icons)) {
-			$pic = $this->icons[$type]['pic'];
-			$title = (isset($title) ? $title : $this->icons[$type]['title']);
-			$alt = (isset($alt) ? $alt : preg_replace('/[^a-zA-Z0-9]/', '', $this->icons[$type]['title']));
-			if ($translate !== false) {
-				$title = __($title);
-				$alt = __($alt);
-			}
-			$alt = '[' . $alt . ']';
-		} else {
-			$pic = 'pixelspace.gif';
-			$title = '';
-			$alt = '';
-		}
-
 		if (!$this->settings['fontIcons'] || !isset($this->settings['fontIcons'][$type])) {
+			if (array_key_exists($type, $this->icons)) {
+				$pic = $this->icons[$type]['pic'];
+				$title = (isset($title) ? $title : $this->icons[$type]['title']);
+				$alt = (isset($alt) ? $alt : preg_replace('/[^a-zA-Z0-9]/', '', $this->icons[$type]['title']));
+				if ($translate !== false) {
+					$title = __($title);
+					$alt = __($alt);
+				}
+				$alt = '[' . $alt . ']';
+			} else {
+				$pic = 'pixelspace.gif';
+			}
 			$defaults = array('title' => $title, 'alt' => $alt, 'class' => 'icon');
 			$newOptions = $options + $defaults;
 
@@ -445,7 +442,7 @@ class FormatHelper extends TextHelper {
 		$options += $defaults;
 
 		if (!isset($options['title'])) {
-			$options['title'] = ucfirst($options['title']);
+			$options['title'] = ucfirst($type);
 			if ($options['translate'] !== false) {
 				$options['title'] = __($options['title']);
 			}