Moodle release 2.8.8
[moodle.git] / backup / cc / entity.label.class.php
blobe8dfe82efcb14ef8cf77c2ade4aed039987bc653
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.
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
23 defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
25 class cc_label extends entities {
27 public function generate_node () {
29 cc2moodle::log_action('Creating Labels mods');
31 $response = '';
33 $sheet_mod_label = cc2moodle::loadsheet(SHEET_COURSE_SECTIONS_SECTION_MODS_MOD_LABEL);
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);
41 return $response;
44 private function create_node_course_modules_mod_label ($sheet_mod_label, $instance) {
45 if ($instance['deep'] <= ROOT_DEEP) {
46 return '';
49 $find_tags = array('[#mod_instance#]',
50 '[#mod_name#]',
51 '[#mod_content#]',
52 '[#date_now#]');
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());
61 return str_replace($find_tags, $replace_values, $sheet_mod_label);