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

navigation_provider.php

Zuletzt modifiziert: 09.10.2024, 12:55 - Dateigröße: 2.46 KiB


001  <?php
002  /**
003   *
004   * This file is part of the phpBB Forum Software package.
005   *
006   * @copyright (c) phpBB Limited <https://www.phpbb.com>
007   * @license GNU General Public License, version 2 (GPL-2.0)
008   *
009   * For full copyright and license information, please see
010   * the docs/CREDITS.txt file.
011   *
012   */
013   
014  namespace phpbb\install\helper\navigation;
015   
016  use phpbb\di\service_collection;
017   
018  /**
019   * Installers navigation provider
020   */
021  class navigation_provider
022  {
023      /**
024       * @var array
025       */
026      private $menu_collection;
027   
028      /**
029       * Constructor
030       *
031       * @param service_collection        $plugins
032       */
033      public function __construct(service_collection $plugins)
034      {
035          $this->menu_collection    = array();
036   
037          foreach ($plugins as $plugin => $plugin_instance)
038          {
039              $this->register($plugin_instance);
040          }
041      }
042   
043      /**
044       * Returns navigation array
045       *
046       * @return array
047       */
048      public function get()
049      {
050          return $this->menu_collection;
051      }
052   
053      /**
054       * Registers a navigation provider's navigation items
055       *
056       * @param navigation_interface    $navigation
057       */
058      public function register(navigation_interface $navigation)
059      {
060          $nav_arry = $navigation->get();
061          $this->menu_collection = $this->merge($nav_arry, $this->menu_collection);
062      }
063   
064      /**
065       * Set a property in the navigation array
066       *
067       * @param array    $nav_element    Array to the navigation elem
068       * @param array    $property_array    Array with the properties to set
069       */
070      public function set_nav_property($nav_element, $property_array)
071      {
072          $array_pointer = array();
073          $array_root_pointer = &$array_pointer;
074          foreach ($nav_element as $array_path)
075          {
076              $array_pointer[$array_path] = array();
077              $array_pointer = &$array_pointer[$array_path];
078          }
079   
080          $array_pointer = $property_array;
081   
082          $this->menu_collection = $this->merge($array_root_pointer, $this->menu_collection);
083      }
084   
085      /**
086       * Recursive array merge
087       *
088       * This function is necessary to be able to replace the options of
089       * already set navigation items.
090       *
091       * @param array    $array_to_merge
092       * @param array    $array_to_merge_into
093       *
094       * @return array    Merged array
095       */
096      private function merge($array_to_merge, $array_to_merge_into)
097      {
098          $merged_array = $array_to_merge_into;
099   
100          foreach ($array_to_merge as $key => $value)
101          {
102              if (isset($array_to_merge_into[$key]))
103              {
104                  if (is_array($array_to_merge_into[$key]) && is_array($value))
105                  {
106                      $merged_array[$key] = $this->merge($value, $array_to_merge_into[$key]);
107                  }
108                  else
109                  {
110                      $merged_array[$key] = $value;
111                  }
112              }
113              else
114              {
115                  $merged_array[$key] = $value;
116              }
117          }
118   
119          return $merged_array;
120      }
121  }
122