Skip to content

Commit

Permalink
now creates lesson directory in moddata for the images. also supports…
Browse files Browse the repository at this point in the history
… the different slasharguments for files
  • Loading branch information
michaelpenne committed May 26, 2005
1 parent 3f3e02b commit a2714c1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions mod/lesson/importppt.php
Expand Up @@ -162,23 +162,30 @@ function extract_data($pages, $courseid, $lessonname) {

global $CFG;
global $matches;

$extratedpages = array();

// directory for images
make_mod_upload_directory($courseid); // we store our images in a subfolder in here

$imagedir = $CFG->dataroot.'/'.$courseid.'/moddata';
$imagelink = $CFG->wwwroot.'/file.php/'.$courseid.'/moddata/';
make_mod_upload_directory($courseid); // make sure moddata is made
make_upload_directory($courseid.'/moddata/lesson', false); // we store our images in a subfolder in here

$imagedir = $CFG->dataroot.'/'.$courseid.'/moddata/lesson';

if ($CFG->slasharguments) {
$imagelink = $CFG->wwwroot.'/file.php/'.$courseid.'/moddata/lesson';
} else {
$imagelink = $CFG->wwwroot.'/file.php?file=/'.$courseid.'/moddata/lesson';
}

// try to make a unique subfolder to store the images
$lessonname = str_replace(' ', '_', $lessonname); // get rid of spaces
$i = 0;
while(true) {
if (!file_exists($imagedir.'/'.$lessonname.$i)) {
// ok doesnt exist so make the directory and update our paths
mkdir($imagedir.'/'.$lessonname.$i);
$imagedir = $imagedir.'/'.$lessonname.$i;
$imagelink = $imagelink.$lessonname.$i;
$imagelink = $imagelink.'/'.$lessonname.$i;
break;
}
$i++;
Expand Down

0 comments on commit a2714c1

Please sign in to comment.