See Release Notes
Long Term Support Release
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * @package mod_wiki 20 * @subpackage backup-moodle2 21 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 /** 26 * Define all the backup steps that will be used by the backup_wiki_activity_task 27 */ 28 29 /** 30 * Define the complete wiki structure for backup, with file and id annotations 31 */ 32 class backup_wiki_activity_structure_step extends backup_activity_structure_step { 33 34 protected function define_structure() { 35 36 // To know if we are including userinfo 37 $userinfo = $this->get_setting_value('userinfo'); 38 39 // Define each element separated 40 $wiki = new backup_nested_element('wiki', array('id'), array('name', 'intro', 'introformat', 'timecreated', 'timemodified', 'firstpagetitle', 'wikimode', 'defaultformat', 'forceformat', 'editbegin', 'editend')); 41 42 $subwikis = new backup_nested_element('subwikis'); 43 44 $subwiki = new backup_nested_element('subwiki', array('id'), array('groupid', 'userid')); 45 46 $pages = new backup_nested_element('pages'); 47 48 $page = new backup_nested_element('page', array('id'), array('title', 'cachedcontent', 'timecreated', 'timemodified', 'timerendered', 'userid', 'pageviews', 'readonly')); 49 50 $synonyms = new backup_nested_element('synonyms'); 51 52 $synonym = new backup_nested_element('synonym', array('id'), array('pageid', 'pagesynonym')); 53 54 $links = new backup_nested_element('links'); 55 56 $link = new backup_nested_element('link', array('id'), array('frompageid', 'topageid', 'tomissingpage')); 57 58 $versions = new backup_nested_element('versions'); 59 60 $version = new backup_nested_element('version', array('id'), array('content', 'contentformat', 'version', 'timecreated', 'userid')); 61 62 $tags = new backup_nested_element('tags'); 63 64 $tag = new backup_nested_element('tag', array('id'), array('name', 'rawname')); 65 66 // Build the tree 67 $wiki->add_child($subwikis); 68 $subwikis->add_child($subwiki); 69 70 $subwiki->add_child($pages); 71 $pages->add_child($page); 72 73 $subwiki->add_child($synonyms); 74 $synonyms->add_child($synonym); 75 76 $subwiki->add_child($links); 77 $links->add_child($link); 78 79 $page->add_child($versions); 80 $versions->add_child($version); 81 82 $page->add_child($tags); 83 $tags->add_child($tag); 84 85 // Define sources 86 $wiki->set_source_table('wiki', array('id' => backup::VAR_ACTIVITYID)); 87 88 // All these source definitions only happen if we are including user info 89 if ($userinfo) { 90 $subwiki->set_source_sql(' 91 SELECT * 92 FROM {wiki_subwikis} 93 WHERE wikiid = ?', array(backup::VAR_PARENTID)); 94 95 $page->set_source_table('wiki_pages', array('subwikiid' => backup::VAR_PARENTID)); 96 97 $synonym->set_source_table('wiki_synonyms', array('subwikiid' => backup::VAR_PARENTID)); 98 99 $link->set_source_table('wiki_links', array('subwikiid' => backup::VAR_PARENTID)); 100 101 $version->set_source_table('wiki_versions', array('pageid' => backup::VAR_PARENTID)); 102 103 $tag->set_source_sql('SELECT t.id, t.name, t.rawname 104 FROM {tag} t 105 JOIN {tag_instance} ti ON ti.tagid = t.id 106 WHERE ti.itemtype = ? 107 AND ti.component = ? 108 AND ti.itemid = ?', array( 109 backup_helper::is_sqlparam('wiki_pages'), 110 backup_helper::is_sqlparam('mod_wiki'), 111 backup::VAR_PARENTID)); 112 } 113 114 // Define id annotations 115 $subwiki->annotate_ids('group', 'groupid'); 116 117 $subwiki->annotate_ids('user', 'userid'); 118 119 $page->annotate_ids('user', 'userid'); 120 121 $version->annotate_ids('user', 'userid'); 122 123 // Define file annotations 124 $wiki->annotate_files('mod_wiki', 'intro', null); // This file area hasn't itemid 125 $subwiki->annotate_files('mod_wiki', 'attachments', 'id'); // This file area hasn't itemid 126 127 // Return the root element (wiki), wrapped into standard activity structure 128 return $this->prepare_activity_structure($wiki); 129 } 130 131 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body