Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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   * @package   moodlecore
  18   * @subpackage backup-imscc
  19   * @copyright 2009 Mauro Rondinelli (mauro.rondinelli [AT] uvcms.com)
  20   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  21   */
  22  
  23  defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
  24  
  25  class cc_label extends entities {
  26  
  27      public function generate_node () {
  28  
  29          cc2moodle::log_action('Creating Labels mods');
  30  
  31          $response = '';
  32  
  33          $sheet_mod_label = cc2moodle::loadsheet(SHEET_COURSE_SECTIONS_SECTION_MODS_MOD_LABEL);
  34  
  35          if (!empty(cc2moodle::$instances['instances'][MOODLE_TYPE_LABEL])) {
  36              foreach (cc2moodle::$instances['instances'][MOODLE_TYPE_LABEL] as $instance) {
  37                  $response .= $this->create_node_course_modules_mod_label($sheet_mod_label, $instance);
  38              }
  39          }
  40  
  41          return $response;
  42      }
  43  
  44      private function create_node_course_modules_mod_label ($sheet_mod_label, $instance) {
  45          if ($instance['deep'] <= ROOT_DEEP) {
  46              return '';
  47          }
  48  
  49          $find_tags = array('[#mod_instance#]',
  50                             '[#mod_name#]',
  51                             '[#mod_content#]',
  52                             '[#date_now#]');
  53  
  54          $title = isset($instance['title']) && !empty($instance['title']) ? $instance['title'] : 'Untitled';
  55          $content = "<img src=\"$@FILEPHP@$$@SLASH@$"."files.gif\" alt=\"Folder\" title=\"{$title}\" /> {$title}";
  56          $replace_values = array($instance['instance'],
  57                                  self::safexml($title),
  58                                  self::safexml($content),
  59                                  time());
  60  
  61          return str_replace($find_tags, $replace_values, $sheet_mod_label);
  62      }
  63  }