mscherer 2 years ago
parent
commit
6e213de4bd
1 changed files with 51 additions and 34 deletions
  1. 51 34
      src/View/Helper/FormatHelper.php

+ 51 - 34
src/View/Helper/FormatHelper.php

@@ -57,11 +57,14 @@ class FormatHelper extends Helper {
 	}
 	}
 
 
 	/**
 	/**
-	 * jqueryAccess: {id}Pro, {id}Contra
+	 * Make sure to configure these (font) icons in your `Icon.map` app config, e.g.
+	 *   'pro' => 'fa4:thumbs-up',
+	 *   'contra' => 'fa4:thumbs-down',
 	 *
 	 *
 	 * @param mixed $value Boolish value
 	 * @param mixed $value Boolish value
 	 * @param array<string, mixed> $options
 	 * @param array<string, mixed> $options
 	 * @param array<string, mixed> $attributes
 	 * @param array<string, mixed> $attributes
+	 *
 	 * @return string
 	 * @return string
 	 */
 	 */
 	public function thumbs($value, array $options = [], array $attributes = []): string {
 	public function thumbs($value, array $options = [], array $attributes = []): string {
@@ -73,12 +76,17 @@ class FormatHelper extends Helper {
 	/**
 	/**
 	 * Display neighbor quicklinks
 	 * Display neighbor quicklinks
 	 *
 	 *
+	 * Make sure to configure these (font) icons in your `Icon.map` app config, e.g.
+	 *   'prev' => 'fa4:arrow-left',
+	 *   'next' => 'fa4:arrow-right',
+	 *
 	 * @param array $neighbors (containing prev and next)
 	 * @param array $neighbors (containing prev and next)
 	 * @param string $field Field as `Field` or `Model.field` syntax
 	 * @param string $field Field as `Field` or `Model.field` syntax
 	 * @param array<string, mixed> $options :
 	 * @param array<string, mixed> $options :
 	 * - name: title name: next{Record} (if none is provided, "record" is used - not translated!)
 	 * - name: title name: next{Record} (if none is provided, "record" is used - not translated!)
 	 * - slug: true/false (defaults to false)
 	 * - slug: true/false (defaults to false)
 	 * - titleField: field or `Model.field`
 	 * - titleField: field or `Model.field`
+	 *
 	 * @return string
 	 * @return string
 	 */
 	 */
 	public function neighbors(array $neighbors, string $field, array $options = []): string {
 	public function neighbors(array $neighbors, string $field, array $options = []): string {
@@ -154,9 +162,13 @@ class FormatHelper extends Helper {
 	/**
 	/**
 	 * Displays gender icon
 	 * Displays gender icon
 	 *
 	 *
+	 * Make sure to configure these (font) icons in your `Icon.map` app config, if
+	 * you want to have different ones than the default icons.
+	 *
 	 * @param string|int $value
 	 * @param string|int $value
 	 * @param array<string, mixed> $options
 	 * @param array<string, mixed> $options
 	 * @param array<string, mixed> $attributes
 	 * @param array<string, mixed> $attributes
+	 *
 	 * @return string
 	 * @return string
 	 */
 	 */
 	public function genderIcon($value, array $options = [], array $attributes = []): string {
 	public function genderIcon($value, array $options = [], array $attributes = []): string {
@@ -173,41 +185,12 @@ class FormatHelper extends Helper {
 	}
 	}
 
 
 	/**
 	/**
-	 * Img Icons
-	 *
-	 * @param string $icon (constant or filename)
-	 * @param array<string, mixed> $options :
-	 * - translate, title, ...
-	 * @param array<string, mixed> $attributes :
-	 * - class, ...
-	 * @return string
-	 */
-	public function cIcon($icon, array $options = [], array $attributes = []): string {
-		$translate = $options['translate'] ?? true;
-
-		$type = pathinfo($icon, PATHINFO_FILENAME);
-		$title = ucfirst($type);
-		$alt = $this->slug($title);
-		if ($translate !== false) {
-			$title = __($title);
-			$alt = __($alt);
-		}
-		$alt = '[' . $alt . ']';
-
-		$defaults = ['title' => $title, 'alt' => $alt, 'class' => 'icon'];
-
-		$options = $attributes + $options;
-		$options += $defaults;
-		if (substr($icon, 0, 1) !== '/') {
-			$icon = 'icons/' . $icon;
-		}
-
-		return $this->Html->image($icon, $options);
-	}
-
-	/**
 	 * Displays yes/no symbol.
 	 * Displays yes/no symbol.
 	 *
 	 *
+	 * Make sure to configure these (font) icons in your `Icon.map` app config, e.g.
+	 *   'yes' => 'fa4:check',
+	 *   'no' => 'fa4:times',
+	 *
 	 * @param int|bool $value Value
 	 * @param int|bool $value Value
 	 * @param array<string, mixed> $options
 	 * @param array<string, mixed> $options
 	 * - on (defaults to 1/true)
 	 * - on (defaults to 1/true)
@@ -215,6 +198,7 @@ class FormatHelper extends Helper {
 	 * - offTitle
 	 * - offTitle
 	 * @param array<string, mixed> $attributes
 	 * @param array<string, mixed> $attributes
 	 * - title, ...
 	 * - title, ...
+	 *
 	 * @return string HTML icon Yes/No
 	 * @return string HTML icon Yes/No
 	 */
 	 */
 	public function yesNo($value, array $options = [], array $attributes = []): string {
 	public function yesNo($value, array $options = [], array $attributes = []): string {
@@ -239,6 +223,39 @@ class FormatHelper extends Helper {
 	}
 	}
 
 
 	/**
 	/**
+	 * Img Icons
+	 *
+	 * @param string $icon (constant or filename)
+	 * @param array<string, mixed> $options :
+	 * - translate, title, ...
+	 * @param array<string, mixed> $attributes :
+	 * - class, ...
+	 * @return string
+	 */
+	public function cIcon($icon, array $options = [], array $attributes = []): string {
+		$translate = $options['translate'] ?? true;
+
+		$type = pathinfo($icon, PATHINFO_FILENAME);
+		$title = ucfirst($type);
+		$alt = $this->slug($title);
+		if ($translate !== false) {
+			$title = __($title);
+			$alt = __($alt);
+		}
+		$alt = '[' . $alt . ']';
+
+		$defaults = ['title' => $title, 'alt' => $alt, 'class' => 'icon'];
+
+		$options = $attributes + $options;
+		$options += $defaults;
+		if (substr($icon, 0, 1) !== '/') {
+			$icon = 'icons/' . $icon;
+		}
+
+		return $this->Html->image($icon, $options);
+	}
+
+	/**
 	 * Gets URL of a png img of a website (16x16 pixel).
 	 * Gets URL of a png img of a website (16x16 pixel).
 	 *
 	 *
 	 * @param string $domain
 	 * @param string $domain