/** * Generate toc structure and titles * * @param array $chapters * @param stdClass $giportfolio * @param stdClass $cm * @return array */ function giportfoliotool_print_get_toc($chapters, $giportfolio, $cm) { $first = true; $titles = array(); $context = context_module::instance($cm->id); $toc = ''; // Representation of toc (HTML). switch ($giportfolio->numbering) { case PORTFOLIO_NUM_NONE: $toc .= '<div class="giportfolio_toc_none">'; break; case PORTFOLIO_NUM_NUMBERS: $toc .= '<div class="giportfolio_toc_numbered">'; break; case PORTFOLIO_NUM_BULLETS: $toc .= '<div class="giportfolio_toc_bullets">'; break; case PORTFOLIO_NUM_INDENTED: $toc .= '<div class="giportfolio_toc_indented">'; break; } $toc .= '<a name="toc"></a>'; // Representation of toc (HTML). if ($giportfolio->customtitles) { $toc .= '<h1>' . get_string('toc', 'mod_giportfolio') . '</h1>'; } else { $toc .= '<p class="giportfolio_chapter_title">' . get_string('toc', 'mod_giportfolio') . '</p>'; } $toc .= '<ul>'; foreach ($chapters as $ch) { if (!$ch->hidden) { $title = giportfolio_get_chapter_title($ch->id, $chapters, $giportfolio, $context); if (!$ch->subchapter) { $toc .= $first ? '<li>' : '</ul></li><li>'; } else { $toc .= $first ? '<li><ul><li>' : '<li>'; } $titles[$ch->id] = $title; $toc .= '<a title="' . s($title) . '" href="#ch' . $ch->id . '">' . $title . '</a>'; $toc .= !$ch->subchapter ? '<ul>' : '</li>'; $first = false; } } $toc .= '</ul></li></ul>'; $toc .= '</div>'; $toc = str_replace('<ul></ul>', '', $toc); // Cleanup of invalid structures. return array($toc, $titles); }
echo s(format_string($giportfolio->name, true, array('context' => $context))); ?> "/> <link rel="stylesheet" type="text/css" href="print.css"/> </head> <body> <a name="top"></a> <div class="chapter"> <?php if (!$giportfolio->customtitles) { if (!$chapter->subchapter) { $currtitle = giportfolio_get_chapter_title($chapter->id, $chapters, $giportfolio, $context); echo '<p class="giportfolio_chapter_title">' . $currtitle . '</p>'; } else { $currtitle = giportfolio_get_chapter_title($chapters[$chapter->id]->parent, $chapters, $giportfolio, $context); $currsubtitle = giportfolio_get_chapter_title($chapter->id, $chapters, $giportfolio, $context); echo '<p class="giportfolio_chapter_title">' . $currtitle . '<br />' . $currsubtitle . '</p>'; } } $chaptertext = file_rewrite_pluginfile_urls($chapter->content, 'pluginfile.php', $context->id, 'mod_giportfolio', 'chapter', $chapter->id); echo format_text($chaptertext, $chapter->contentformat, array('noclean' => true, 'context' => $context)); $contriblist = giportfolio_get_user_contributions($chapter->id, $chapter->giportfolioid, $USER->id); if ($contriblist) { foreach ($contriblist as $contrib) { $contribtitle = file_rewrite_pluginfile_urls($contrib->title, 'pluginfile.php', $context->id, 'mod_giportfolio', 'contribution', $contrib->id); echo '<strong>' . $contribtitle . '</strong></br>'; echo date('l jS F Y', $contrib->timemodified); echo '</br></br>'; $contribtext = file_rewrite_pluginfile_urls($contrib->content, 'pluginfile.php', $context->id, 'mod_giportfolio', 'contribution', $contrib->id); echo format_text($contribtext, $contrib->contentformat, array('noclean' => true, 'context' => $context)); echo '</br>';