| 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 | 
            * universe theme.
  | 
        
        
            | 
            | 
           19 | 
            *
  | 
        
        
            | 
            | 
           20 | 
            * @package    theme_universe
  | 
        
        
            | 
            | 
           21 | 
            * @copyright  © 2019-onwards G J Barnard.  Based upon work by Damyon Wiese and G Thomas.
  | 
        
        
            | 
            | 
           22 | 
            * @author     G J Barnard - {@link http://moodle.org/user/profile.php?id=442195}.
  | 
        
        
            | 
            | 
           23 | 
            * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
  | 
        
        
            | 
            | 
           24 | 
            */
  | 
        
        
            | 
            | 
           25 | 
              | 
        
        
            | 
            | 
           26 | 
           namespace theme_universe\output;
  | 
        
        
            | 
            | 
           27 | 
              | 
        
        
            | 
            | 
           28 | 
           class external extends \core\output\external {
  | 
        
        
            | 
            | 
           29 | 
               /**
  | 
        
        
            | 
            | 
           30 | 
                * Returns description of load_icon_map() parameters.
  | 
        
        
            | 
            | 
           31 | 
                *
  | 
        
        
            | 
            | 
           32 | 
                * @return external_function_parameters
  | 
        
        
            | 
            | 
           33 | 
                */
  | 
        
        
            | 
            | 
           34 | 
               public static function load_fontawesome_icon_map_parameters() {
  | 
        
        
            | 
            | 
           35 | 
                   return new \external_function_parameters([]);
  | 
        
        
            | 
            | 
           36 | 
               }
  | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
               /**
  | 
        
        
            | 
            | 
           39 | 
                * Return a mapping of icon names to icons.
  | 
        
        
            | 
            | 
           40 | 
                *
  | 
        
        
            | 
            | 
           41 | 
                * @return array the mapping
  | 
        
        
            | 
            | 
           42 | 
                */
  | 
        
        
            | 
            | 
           43 | 
               public static function load_fontawesome_icon_map() {
  | 
        
        
            | 
            | 
           44 | 
                   $instance = \core\output\icon_system::instance('\\theme_universe\\output\\icon_system_fontawesome');
  | 
        
        
            | 
            | 
           45 | 
              | 
        
        
            | 
            | 
           46 | 
                   $map = $instance->get_icon_name_map();
  | 
        
        
            | 
            | 
           47 | 
                   $result = [];
  | 
        
        
            | 
            | 
           48 | 
              | 
        
        
            | 
            | 
           49 | 
                   foreach ($map as $from => $to) {
  | 
        
        
            | 
            | 
           50 | 
                       list($component, $pix) = explode(':', $from);
  | 
        
        
            | 
            | 
           51 | 
                       $one = [];
  | 
        
        
            | 
            | 
           52 | 
                       $one['component'] = $component;
  | 
        
        
            | 
            | 
           53 | 
                       $one['pix'] = $pix;
  | 
        
        
            | 
            | 
           54 | 
                       $one['to'] = $to;
  | 
        
        
            | 
            | 
           55 | 
                       $result[] = $one;
  | 
        
        
            | 
            | 
           56 | 
                   }
  | 
        
        
            | 
            | 
           57 | 
                   return $result;
  | 
        
        
            | 
            | 
           58 | 
               }
  | 
        
        
            | 
            | 
           59 | 
              | 
        
        
            | 
            | 
           60 | 
               /**
  | 
        
        
            | 
            | 
           61 | 
                * Returns description of load_icon_map() result value.
  | 
        
        
            | 
            | 
           62 | 
                *
  | 
        
        
            | 
            | 
           63 | 
                * @return external_description
  | 
        
        
            | 
            | 
           64 | 
                */
  | 
        
        
            | 
            | 
           65 | 
               public static function load_fontawesome_icon_map_returns() {
  | 
        
        
            | 
            | 
           66 | 
                   return new \external_multiple_structure(new \external_single_structure(
  | 
        
        
            | 
            | 
           67 | 
                       array(
  | 
        
        
            | 
            | 
           68 | 
                           'component' => new \external_value(PARAM_COMPONENT, 'The component for the icon.'),
  | 
        
        
            | 
            | 
           69 | 
                           'pix' => new \external_value(PARAM_RAW, 'Value to map the icon from.'),
  | 
        
        
            | 
            | 
           70 | 
                           'to' => new \external_value(PARAM_RAW, 'Value to map the icon to.')
  | 
        
        
            | 
            | 
           71 | 
                       )
  | 
        
        
            | 
            | 
           72 | 
                   ));
  | 
        
        
            | 
            | 
           73 | 
               }
  | 
        
        
            | 
            | 
           74 | 
           }
  |