. /** * Contains functions used by importppt.php that naturally pertain to importing * powerpoint presentations into the lesson module * * @package lesson * @copyright 2009 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ /** * A recursive function to build a html list * * @param array $matches * @param string $list * @param int $i * @param int $depth * @return string */ function lesson_importppt_build_list(array &$matches, $list, &$i, $depth) { while($i < count($matches[1])) { $class = lesson_importppt_isolate_class($matches[1][$i]); if (strstr($class, 'B')) { // make sure we are still working with bullet classes if ($class == 'B') { $this_depth = 0; // calling class B depth 0 } else { // set the depth number. So B1 is depth 1 and B2 is depth 2 and so on $this_depth = substr($class, 1); if (!is_numeric($this_depth)) { print_error('invalidnum'); } } if ($this_depth < $depth) { // we are moving back a level in the nesting break; } if ($this_depth > $depth) { // we are moving in a lvl in nesting $list .= '
tags around each element and strip out \n which I have found to be uneccessary 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")); } }