|
|
@@ -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 array<string, mixed> $options
|
|
|
* @param array<string, mixed> $attributes
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function thumbs($value, array $options = [], array $attributes = []): string {
|
|
|
@@ -73,12 +76,17 @@ class FormatHelper extends Helper {
|
|
|
/**
|
|
|
* 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 string $field Field as `Field` or `Model.field` syntax
|
|
|
* @param array<string, mixed> $options :
|
|
|
* - name: title name: next{Record} (if none is provided, "record" is used - not translated!)
|
|
|
* - slug: true/false (defaults to false)
|
|
|
* - titleField: field or `Model.field`
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function neighbors(array $neighbors, string $field, array $options = []): string {
|
|
|
@@ -154,9 +162,13 @@ class FormatHelper extends Helper {
|
|
|
/**
|
|
|
* 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 array<string, mixed> $options
|
|
|
* @param array<string, mixed> $attributes
|
|
|
+ *
|
|
|
* @return 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.
|
|
|
*
|
|
|
+ * 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 array<string, mixed> $options
|
|
|
* - on (defaults to 1/true)
|
|
|
@@ -215,6 +198,7 @@ class FormatHelper extends Helper {
|
|
|
* - offTitle
|
|
|
* @param array<string, mixed> $attributes
|
|
|
* - title, ...
|
|
|
+ *
|
|
|
* @return string HTML icon Yes/No
|
|
|
*/
|
|
|
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).
|
|
|
*
|
|
|
* @param string $domain
|