| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- /**
- * Class callout
- *
- * Cette classe génère des callouts Bootstrap personnalisés.
- * Un callout est un composant d'interface qui permet de mettre en avant des informations importantes.
- *
- * @method static string get(array $_array) Renvoie le HTML du callout.
- * @method static void print(array $_array) Affiche le callout directement.
- */
- class callout {
- /**
- * Construit le HTML d'un callout en fonction des paramètres fournis.
- *
- * @param array $_array Les paramètres du callout (type, class, h4, p).
- * @return string Le HTML du callout.
- */
- static private function construct(array $_array) {
- $type = $_array['type'] ?? 'default';
- $allowedTypes = ['success', 'primary', 'danger', 'warning', 'info'];
- $type = !in_array($type, $allowedTypes) ? 'default' : $type;
- $size = $_array['size'] ?? '';
- $allowedSizes = ['tiny'];
- $size = in_array($size, $allowedSizes) ? "bd-callout-" . $size : NULL;
- $class = $_array['class'] ?? '';
- $style = $_array['style'] ?? '';
- $h4 = $_array['h4'] ?? '';
- $p = $_array['p'] ?? '';
- return '<div class="bd-callout bd-callout-' . $type . ($size ? ' ' . $size : '') . ($class ? ' ' . $class : '') . '"' . ($style ? ' style="' . $style . '"' : '') . '>' .
- ($h4 ? '<h4>' . $h4 . '</h4>' : '') .
- ($p ? '<p>' . $p . '</p>' : '') .
- '</div>';
- }
- /**
- * Renvoie le HTML d'un callout.
- *
- * @param array $_array Les paramètres du callout.
- * @return string Le HTML du callout.
- */
- static public function get(array $_array) {
- return self::construct($_array);
- }
- /**
- * Affiche directement le callout.
- *
- * @param array $_array Les paramètres du callout.
- * @return void
- */
- static public function print(array $_array) {
- echo self::construct($_array);
- }
- }
|