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

manager.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 3.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\textreparser;
015   
016  class manager
017  {
018      /**
019       * @var \phpbb\config\config
020       */
021      protected $config;
022   
023      /**
024       * @var \phpbb\config\db_text
025       */
026      protected $config_text;
027   
028      /**
029       * @var \phpbb\di\service_collection
030       */
031      protected $reparsers;
032   
033      /**
034       * @var array
035       */
036      protected $resume_data;
037   
038      /**
039       * Constructor
040       *
041       * @param \phpbb\config\config            $config
042       * @param \phpbb\config\db_text            $config_text
043       * @param \phpbb\di\service_collection    $reparsers
044       */
045      public function __construct(\phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\di\service_collection $reparsers)
046      {
047          $this->config = $config;
048          $this->config_text = $config_text;
049          $this->reparsers = $reparsers;
050      }
051   
052      /**
053       * Loads resume data from the database
054       *
055       * @param string    $name    Name of the reparser to which the resume data belongs
056       *
057       * @return array
058       */
059      public function get_resume_data($name)
060      {
061          if ($this->resume_data === null)
062          {
063              $resume_data = $this->config_text->get('reparser_resume');
064              $this->resume_data = !empty($resume_data) ? unserialize($resume_data) : array();
065          }
066   
067          return isset($this->resume_data[$name]) ? $this->resume_data[$name] : array();
068      }
069   
070      /**
071       * Updates the resume data in the database
072       *
073       * @param string    $name        Name of the reparser to which the resume data belongs
074       * @param int        $min        Lowest record ID
075       * @param int        $current    Current record ID
076       * @param int        $size        Number of records to process at a time
077       * @param bool        $update_db    True if the resume data should be written to the database, false if not. (default: true)
078       */
079      public function update_resume_data($name, $min, $current, $size, $update_db = true)
080      {
081          // Prevent overwriting the old, stored array
082          if ($this->resume_data === null)
083          {
084              $this->get_resume_data('');
085          }
086   
087          $this->resume_data[$name] = array(
088              'range-min'        => $min,
089              'range-max'        => $current,
090              'range-size'    => $size,
091          );
092   
093          if ($update_db)
094          {
095              $this->config_text->set('reparser_resume', serialize($this->resume_data));
096          }
097      }
098   
099      /**
100       * Sets the interval for a text_reparser cron task
101       *
102       * @param string    $name        Name of the reparser to schedule
103       * @param int        $interval    Interval in seconds, 0 to disable the cron task
104       */
105      public function schedule($name, $interval)
106      {
107          if (isset($this->reparsers[$name]) && isset($this->config[$name . '_cron_interval']))
108          {
109              $this->config->set($name . '_cron_interval', $interval);
110          }
111      }
112   
113      /**
114       * Sets the interval for all text_reparser cron tasks
115       *
116       * @param int    $interval    Interval in seconds, 0 to disable the cron task
117       */
118      public function schedule_all($interval)
119      {
120          // This way we don't construct every registered reparser
121          $reparser_array = array_keys($this->reparsers->getArrayCopy());
122   
123          foreach ($reparser_array as $reparser)
124          {
125              $this->schedule($reparser, $interval);
126          }
127      }
128   
129      /**
130       * Finds a reparser by name.
131       *
132       * If there is no reparser with the specified name, null is returned.
133       *
134       * @param string $name Name of the reparser to look up.
135       * @return string A reparser service name, or null.
136       */
137      public function find_reparser($name)
138      {
139          foreach ($this->reparsers as $service => $reparser)
140          {
141              if ($reparser->get_name() == $name)
142              {
143                  return $service;
144              }
145          }
146          return null;
147      }
148  }
149