| 1 | efrain | 1 | <?php
 | 
        
           |  |  | 2 | // This file is part of Moodle - http://moodle.org/
 | 
        
           |  |  | 3 | //
 | 
        
           |  |  | 4 | // Moodle is free software: you can redistribute it and/or modify
 | 
        
           |  |  | 5 | // it under the terms of the GNU General Public License as published by
 | 
        
           |  |  | 6 | // the Free Software Foundation, either version 3 of the License, or
 | 
        
           |  |  | 7 | // (at your option) any later version.
 | 
        
           |  |  | 8 | //
 | 
        
           |  |  | 9 | // Moodle is distributed in the hope that it will be useful,
 | 
        
           |  |  | 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
        
           |  |  | 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
        
           |  |  | 12 | // GNU General Public License for more details.
 | 
        
           |  |  | 13 | //
 | 
        
           |  |  | 14 | // You should have received a copy of the GNU General Public License
 | 
        
           |  |  | 15 | // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 | 
        
           |  |  | 16 |   | 
        
           |  |  | 17 | /**
 | 
        
           |  |  | 18 |  * Language string based on David Mudrak langstring from local_amos.
 | 
        
           |  |  | 19 |  *
 | 
        
           |  |  | 20 |  * @package    tool_customlang
 | 
        
           |  |  | 21 |  * @copyright  2020 Ferran Recio <ferran@moodle.com>
 | 
        
           |  |  | 22 |  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 
        
           |  |  | 23 |  */
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 | namespace tool_customlang\local\mlang;
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 | use moodle_exception;
 | 
        
           |  |  | 28 | use stdclass;
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 | /**
 | 
        
           |  |  | 31 |  * Class containing a lang string cleaned.
 | 
        
           |  |  | 32 |  *
 | 
        
           |  |  | 33 |  * @package    tool_customlang
 | 
        
           |  |  | 34 |  * @copyright  2020 Ferran Recio <ferran@moodle.com>
 | 
        
           |  |  | 35 |  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 
        
           |  |  | 36 |  */
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 | /**
 | 
        
           |  |  | 39 |  * Represents a single string
 | 
        
           |  |  | 40 |  */
 | 
        
           |  |  | 41 | class logstatus {
 | 
        
           |  |  | 42 |   | 
        
           |  |  | 43 |     /** @var langstring the current string */
 | 
        
           |  |  | 44 |     public $langstring = null;
 | 
        
           |  |  | 45 |   | 
        
           |  |  | 46 |     /** @var string the component */
 | 
        
           |  |  | 47 |     public $component = null;
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 |     /** @var string the string ID */
 | 
        
           |  |  | 50 |     public $stringid = null;
 | 
        
           |  |  | 51 |   | 
        
           |  |  | 52 |     /** @var string the original filename */
 | 
        
           |  |  | 53 |     public $filename = null;
 | 
        
           |  |  | 54 |   | 
        
           |  |  | 55 |     /** @var int the error level */
 | 
        
           |  |  | 56 |     public $errorlevel = null;
 | 
        
           |  |  | 57 |   | 
        
           |  |  | 58 |     /** @var string the message identifier */
 | 
        
           |  |  | 59 |     private $message;
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 |     /**
 | 
        
           |  |  | 62 |      * Class creator.
 | 
        
           |  |  | 63 |      *
 | 
        
           |  |  | 64 |      * @param string $message the message identifier to display
 | 
        
           |  |  | 65 |      * @param string $errorlevel the notice level
 | 
        
           |  |  | 66 |      * @param string|null $filename the filename of this log
 | 
        
           |  |  | 67 |      * @param string|null $component the component of this log
 | 
        
           |  |  | 68 |      * @param langstring|null $langstring the langstring of this log
 | 
        
           |  |  | 69 |      */
 | 
        
           |  |  | 70 |     public function __construct(string $message, string $errorlevel, ?string $filename = null,
 | 
        
           |  |  | 71 |             ?string $component = null, ?langstring $langstring = null) {
 | 
        
           |  |  | 72 |   | 
        
           |  |  | 73 |         $this->filename = $filename;
 | 
        
           |  |  | 74 |         $this->component = $component;
 | 
        
           |  |  | 75 |         $this->langstring = $langstring;
 | 
        
           |  |  | 76 |         $this->message = $message;
 | 
        
           |  |  | 77 |         $this->errorlevel = $errorlevel;
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 |         if ($langstring) {
 | 
        
           |  |  | 80 |             $this->stringid = $langstring->id;
 | 
        
           |  |  | 81 |         }
 | 
        
           |  |  | 82 |     }
 | 
        
           |  |  | 83 |   | 
        
           |  |  | 84 |     /**
 | 
        
           |  |  | 85 |      * Get the log message.
 | 
        
           |  |  | 86 |      *
 | 
        
           |  |  | 87 |      * @return string the log message.
 | 
        
           |  |  | 88 |      */
 | 
        
           |  |  | 89 |     public function get_message(): string {
 | 
        
           |  |  | 90 |         return get_string($this->message, 'tool_customlang', $this);
 | 
        
           |  |  | 91 |     }
 | 
        
           |  |  | 92 | }
 |