} $configure = optional_param('mappings', '', PARAM_FILE); $basedir = '/theme/' . current_theme() . '/pix/headers'; // english will have all the available ones $endir = $basedir . '/en_utf8/'; $images = get_directory_list($CFG->dirroot . $endir, '', false, false, true); $images = array_flip($images); foreach (array_keys($images) as $i) { $images[$i] = $i; } $thisurl = $CFG->wwwroot . '/local/admin/imagemap.php'; if (empty($configure)) { print_heading(get_string('imagemap', 'local')); echo '<p>' . get_string('imagemapdesc', 'local') . '</p>'; foreach ($images as $image) { echo '<div class="imagemap"><a href="' . $thisurl . '?mappings=' . $image . '"><b>' . $image . '</b><br /><img src="' . tao_header_image_location($image) . '" alt="' . $image . '" border="1" width="400" /></a><div class="imagemapdefault">'; echo $CFG->defaultcustomheader == $image ? ' (' . get_string('default') . ')</div>' : '<a href="' . $thisurl . '?default=' . $image . '">' . get_string('setdefault', 'local') . '</a></div>'; echo '<div class="clearer"></div></div>' . "\n"; } admin_externalpage_print_footer(); exit; } echo ' ' . '<a href="' . $thisurl . '">' . get_string('gobacktolist', 'local') . '</a>'; print_heading(get_string('configuringmappingsfor', 'local', $configure)); echo '<div class="imagemap"><img src="' . $CFG->wwwroot . $endir . $configure . '" alt="' . $configure . '" border="1" width="400" /></div>' . "\n"; if ($configure == $CFG->defaultcustomheader) { notify(get_string('alreadydefault', 'local')); } echo '<p>' . get_string('mappinghelp', 'local') . '</p>'; if (!($mappings = get_records('header_image', 'image', $configure))) { notify(get_string('nomappings', 'local'));
/** * helper function for the theme to figure out what header graphic to use */ function tao_header_image() { global $CFG, $COURSE, $db; // first figure out the url mapping $me = me(); $pathinfo = strstr(substr(strstr($CFG->wwwroot, '//'), 2), '/'); //strip out http://mywebsite.com and https://mywebsite.com $me = str_replace($pathinfo, '', $me); //remove any prepended directories $me = strip_querystring($me); //remove any params! // this is dangerous, so use prepared statements. if (!empty($COURSE->id)) { $coursehdrs = get_records('header_image', 'courseid', $COURSE->id, 'sortorder'); if (!empty($coursehdrs)) { foreach ($coursehdrs as $ch) { if (empty($ch->url)) { //if url is empty then all pages with this id must use this image. return tao_header_image_location($ch->image); } elseif (strpos($me, $ch->url) !== false) { return tao_header_image_location($ch->image); } } } } $sth = $db->prepare("SELECT * FROM " . $CFG->prefix . "header_image WHERE url like ? || '%' ORDER BY sortorder LIMIT 1"); if (!($resultset = $db->execute($sth, array($me)))) { if (isset($CFG->defaultcustomheader)) { return $CFG->defaultcustomheader; } return; } if ($resultset->recordCount() == 1) { $image = $resultset->fields['image']; } else { $image = $CFG->defaultcustomheader; } return tao_header_image_location($image); }