/** * Internal function - creates htmls structure suitable for YUI tree. */ function imscp_htmllize_item($item, $imscp, $cm) { global $CFG; if ($item['href']) { if (preg_match('|^https?://|', $item['href'])) { $url = $item['href']; } else { $context = context_module::instance($cm->id); $urlbase = "{$CFG->wwwroot}/pluginfile.php"; $path = '/' . $context->id . '/mod_imscp/content/' . $imscp->revision . '/' . $item['href']; $url = file_encode_url($urlbase, $path, false); } $result = "<li><a href=\"{$url}\">" . $item['title'] . '</a>'; } else { $result = '<li>' . $item['title']; } if ($item['subitems']) { $result .= '<ul>'; foreach ($item['subitems'] as $subitem) { $result .= imscp_htmllize_item($subitem, $imscp, $cm); } $result .= '</ul>'; } $result .= '</li>'; return $result; }
/** * Internal function - creates htmls structure suitable for YUI tree. */ function imscp_htmllize_item($item, $imscp, $cm) { global $CFG; $context = get_context_instance(CONTEXT_MODULE, $cm->id); $urlbase = "{$CFG->wwwroot}/pluginfile.php"; $path = '/' . $context->id . '/mod_imscp/content/' . $imscp->revision . '/' . $item['href']; $url = file_encode_url($urlbase, $path, false); $result = "<li><a href=\"{$url}\">" . $item['title'] . '</a>'; if ($item['subitems']) { $result .= '<ul>'; foreach ($item['subitems'] as $subitem) { $result .= imscp_htmllize_item($subitem, $imscp, $cm); } $result .= '</ul>'; } $result .= '</li>'; return $result; }