Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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

Helper.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.19 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\Console\Helper;
013   
014  use Symfony\Component\Console\Formatter\OutputFormatterInterface;
015   
016  /**
017   * Helper is the base class for all helper classes.
018   *
019   * @author Fabien Potencier <fabien@symfony.com>
020   */
021  abstract class Helper implements HelperInterface
022  {
023      protected $helperSet = null;
024   
025      /**
026       * Sets the helper set associated with this helper.
027       *
028       * @param HelperSet $helperSet A HelperSet instance
029       */
030      public function setHelperSet(HelperSet $helperSet = null)
031      {
032          $this->helperSet = $helperSet;
033      }
034   
035      /**
036       * Gets the helper set associated with this helper.
037       *
038       * @return HelperSet A HelperSet instance
039       */
040      public function getHelperSet()
041      {
042          return $this->helperSet;
043      }
044   
045      /**
046       * Returns the length of a string, using mb_strwidth if it is available.
047       *
048       * @param string $string The string to check its length
049       *
050       * @return int The length of the string
051       */
052      public static function strlen($string)
053      {
054          if (false === $encoding = mb_detect_encoding($string, null, true)) {
055              return strlen($string);
056          }
057   
058          return mb_strwidth($string, $encoding);
059      }
060   
061      public static function formatTime($secs)
062      {
063          static $timeFormats = array(
064              array(0, '< 1 sec'),
065              array(1, '1 sec'),
066              array(2, 'secs', 1),
067              array(60, '1 min'),
068              array(120, 'mins', 60),
069              array(3600, '1 hr'),
070              array(7200, 'hrs', 3600),
071              array(86400, '1 day'),
072              array(172800, 'days', 86400),
073          );
074   
075          foreach ($timeFormats as $index => $format) {
076              if ($secs >= $format[0]) {
077                  if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
078                      || $index == count($timeFormats) - 1
079                  ) {
080                      if (2 == count($format)) {
081                          return $format[1];
082                      }
083   
084                      return floor($secs / $format[2]).' '.$format[1];
085                  }
086              }
087          }
088      }
089   
090      public static function formatMemory($memory)
091      {
092          if ($memory >= 1024 * 1024 * 1024) {
093              return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
094          }
095   
096          if ($memory >= 1024 * 1024) {
097              return sprintf('%.1f MiB', $memory / 1024 / 1024);
098          }
099   
100          if ($memory >= 1024) {
101              return sprintf('%d KiB', $memory / 1024);
102          }
103   
104          return sprintf('%d B', $memory);
105      }
106   
107      public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
108      {
109          $isDecorated = $formatter->isDecorated();
110          $formatter->setDecorated(false);
111          // remove <...> formatting
112          $string = $formatter->format($string);
113          // remove already formatted characters
114          $string = preg_replace("/\033\[[^m]*m/", '', $string);
115          $formatter->setDecorated($isDecorated);
116   
117          return self::strlen($string);
118      }
119  }
120