Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

avatar.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 1.85 KiB


01  <?php
02  /**
03   *
04   * This file is part of the phpBB Forum Software package.
05   *
06   * @copyright (c) phpBB Limited <https://www.phpbb.com>
07   * @license GNU General Public License, version 2 (GPL-2.0)
08   *
09   * For full copyright and license information, please see
10   * the docs/CREDITS.txt file.
11   *
12   */
13   
14  namespace phpbb\template\twig\extension;
15   
16  class avatar extends \Twig_Extension
17  {
18      /**
19       * Get the name of this extension
20       *
21       * @return string
22       */
23      public function getName()
24      {
25          return 'avatar';
26      }
27   
28      /**
29       * Returns a list of global functions to add to the existing list.
30       *
31       * @return array An array of global functions
32       */
33      public function getFunctions()
34      {
35          return array(
36              new \Twig\TwigFunction('avatar', array($this, 'get_avatar')),
37          );
38      }
39   
40      /**
41       * Get avatar for placing into templates.
42       *
43       * How to use in a template:
44       * - {{ avatar('mode', row, alt, ignore_config, lazy) }}
45       *
46       * The mode and row (group_row or user_row) are required.
47       * The other fields (alt|ignore_config|lazy) are optional.
48       *
49       * @uses \phpbb_get_group_avatar()
50       * @uses \phpbb_get_user_avatar()
51       *
52       * @return string    The avatar HTML for the specified mode
53       */
54      public function get_avatar()
55      {
56          $args = func_get_args();
57   
58          $mode = (string) $args[0];
59          $row = (array) $args[1];
60          $alt = isset($args[2]) ? (string) $args[2] : false;
61          $ignore_config = isset($args[3]) ? (bool) $args[3] : false;
62          $lazy = isset($args[4]) ? (bool) $args[4] : false;
63   
64          // To prevent having to redefine alt attribute ('USER_AVATAR'|'GROUP_AVATAR'), we check if an alternative has been provided
65          switch ($mode)
66          {
67              case 'group':
68                  return $alt ? phpbb_get_group_avatar($row, $alt, $ignore_config, $lazy) : phpbb_get_group_avatar($row);
69              break;
70   
71              case 'user':
72                  return $alt ? phpbb_get_user_avatar($row, $alt, $ignore_config, $lazy) : phpbb_get_user_avatar($row);
73              break;
74   
75              default:
76                  return '';
77              break;
78          }
79      }
80  }
81