|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00023 require_once 'cc_converters.php'; 00024 require_once 'cc_general.php'; 00025 require_once 'cc_page.php'; 00026 00027 class cc_converter_page extends cc_converter { 00028 public function __construct(cc_i_item &$item, cc_i_manifest &$manifest, $rootpath, $path){ 00029 $this->cc_type = cc_version11::webcontent; 00030 $this->defaultfile = 'page.xml'; 00031 $this->defaultname = uniqid().'.html'; 00032 parent::__construct($item, $manifest, $rootpath, $path); 00033 } 00034 00035 public function convert($outdir) { 00036 $rt = new page11_resurce_file(); 00037 $title = $this->doc->nodeValue('/activity/page/name'); 00038 $intro = $this->doc->nodeValue('/activity/page/intro'); 00039 $contextid = $this->doc->nodeValue('/activity/@contextid'); 00040 $pagecontent = $this->doc->nodeValue('/activity/page/content'); 00041 $rt->set_title($title); 00042 $rawname = str_replace(' ', '_', strtolower(trim(clean_param($title, PARAM_FILE)))); 00043 if (!empty($rawname)) { 00044 $this->defaultname = $rawname.".html"; 00045 } 00046 00047 $result = cc_helpers::process_linked_files( $pagecontent, 00048 $this->manifest, 00049 $this->rootpath, 00050 $contextid, 00051 $outdir, 00052 true); 00053 $rt->set_content($result[0]); 00054 $rt->set_intro($intro); 00055 //store everything 00056 $this->store($rt, $outdir, $title, $result[1]); 00057 return true; 00058 } 00059 }