diff --git a/mod/lesson/importppt.php b/mod/lesson/importppt.php deleted file mode 100644 index 243ff3de324..00000000000 --- a/mod/lesson/importppt.php +++ /dev/null @@ -1,211 +0,0 @@ -. - -/** - * This is a very rough importer for powerpoint slides - * Export a powerpoint presentation with powerpoint as html pages - * Do it with office 2002 (I think?) and no special settings - * Then zip the directory with all of the html pages - * and the zip file is what you want to upload - * - * The script supports book and lesson. - * - * @package mod - * @subpackage lesson - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - **/ - -/** include required files */ -require_once("../../config.php"); -require_once($CFG->dirroot.'/mod/lesson/locallib.php'); -require_once($CFG->dirroot.'/mod/lesson/importpptlib.php'); - -$id = required_param('id', PARAM_INT); // Course Module ID -$pageid = optional_param('pageid', '', PARAM_INT); // Page ID - -$url = new moodle_url('/mod/lesson/importppt.php', array('id'=>$id)); -if ($pageid !== '') { - $url->param('pageid', $pageid); -} -$PAGE->set_url($url); - -$cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);; -$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); - -$modname = 'lesson'; -$mod = $cm; -require_login($course, false, $cm); - -require_login($course->id, false, $cm); -$context = get_context_instance(CONTEXT_MODULE, $cm->id); -require_capability('mod/lesson:edit', $context); - -$strimportppt = get_string("importppt", "lesson"); -$strlessons = get_string("modulenameplural", "lesson"); - -$data = new stdClass; -$data->id = $cm->id; -$data->pageid = $pageid; -$mform = new lesson_importppt_form(); -$mform->set_data($data); - -if ($data = $mform->get_data()) { - $manager = lesson_page_type_manager::get($lesson); - if (!$filename = $mform->get_new_filename('pptzip')) { - print_error('invalidfile', 'lesson'); - } - if (!$package = $mform->save_stored_file('pptzip', $context->id, 'mod_lesson', 'ppt_imports', $lesson->id, '/', $filename, true)) { - print_error('unabletosavefile', 'lesson'); - } - // extract package content - $packer = get_file_packer('application/zip'); - $package->extract_to_storage($packer, $context->id, 'mod_lesson', 'imported_files', $lesson->id, '/'); - - $fs = get_file_storage(); - if ($files = $fs->get_area_files($context->id, 'mod_lesson', 'imported_files', $lesson->id)) { - - $pages = array(); - foreach ($files as $key=>$file) { - if ($file->get_mimetype() != 'text/html') { - continue; - } - $filenameinfo = pathinfo($file->get_filepath().$file->get_filename()); - - $page = new stdClass; - $page->title = ''; - $page->contents = array(); - $page->images = array(); - $page->source = $filenameinfo['basename']; - - $string = strip_tags($file->get_content(),'
tags around each element and strip out \n which I have found to be unneccessary - foreach ($pageobject->contents as $content) { - $content = str_replace("\n", '', $content); - $content = str_replace("\r", '', $content); - $content = str_replace(' ', '', $content); // puts in returns? - $content = '
'.$content.'
'; - $page->contents .= $content; - } - - $branchtable->page = clone($page); // add the page - $branchtables[] = clone($branchtable); // add it all to our array - $i++; - } - - return $branchtables; -} - -/** - * Form displayed to the user asking them to select a file to upload - * - * @copyright 2009 Sam Hemelryk - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class lesson_importppt_form extends moodleform { - - public function definition() { - global $COURSE; - - $mform = $this->_form; - - $mform->addElement('hidden', 'id'); - $mform->setType('id', PARAM_INT); - - $mform->addElement('hidden', 'pageid'); - $mform->setType('pageid', PARAM_INT); - - $filepickeroptions = array(); - $filepickeroptions['filetypes'] = array('*.zip'); - $filepickeroptions['maxbytes'] = $COURSE->maxbytes; - $mform->addElement('filepicker', 'pptzip', get_string('upload'), null, $filepickeroptions); - $mform->addRule('pptzip', null, 'required', null, 'client'); - - $this->add_action_buttons(null, get_string("uploadthisfile")); - } - -} \ No newline at end of file diff --git a/mod/lesson/renderer.php b/mod/lesson/renderer.php index 765b7ca6e07..a37f40b160f 100644 --- a/mod/lesson/renderer.php +++ b/mod/lesson/renderer.php @@ -364,9 +364,6 @@ class mod_lesson_renderer extends plugin_renderer_base { $importquestionsurl = new moodle_url('/mod/lesson/import.php',array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid)); $links[] = html_writer::link($importquestionsurl, get_string('importquestions', 'lesson')); - $importppturl = new moodle_url('/mod/lesson/importppt.php',array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid)); - $links[] = html_writer::link($importppturl, get_string('importppt', 'lesson')); - $manager = lesson_page_type_manager::get($lesson); foreach ($manager->get_add_page_type_links($prevpageid) as $link) { $link['addurl']->param('firstpage', 1);