Example #1
0
function wiki_print_page_content($page, $context, $subwikiid)
{
    global $OUTPUT, $CFG;
    if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
        $content = wiki_refresh_cachedcontent($page);
        $page = $content['page'];
    }
    if (isset($content)) {
        $box = '';
        foreach ($content['sections'] as $s) {
            $box .= '<p>' . get_string('repeatedsection', 'wiki', $s) . '</p>';
        }
        if (!empty($box)) {
            echo $OUTPUT->box($box);
        }
    }
    $html = file_rewrite_pluginfile_urls($page->cachedcontent, 'pluginfile.php', $context->id, 'mod_wiki', 'attachments', $subwikiid);
    $html = format_text($html, FORMAT_MOODLE, array('overflowdiv' => true));
    echo $OUTPUT->box($html);
    if (!empty($CFG->usetags)) {
        $tags = tag_get_tags_array('wiki_pages', $page->id);
        echo $OUTPUT->container_start('wiki-tags');
        echo '<span class="wiki-tags-title">' . get_string('tags') . ': </span>';
        $links = array();
        foreach ($tags as $tagid => $tag) {
            $url = new moodle_url('/tag/index.php', array('tag' => $tag));
            $links[] = html_writer::link($url, $tag, array('title' => get_string('tagtitle', 'wiki', $tag)));
        }
        echo join($links, ", ");
        echo $OUTPUT->container_end();
    }
    wiki_increment_pageviews($page);
}
Example #2
0
function wiki_print_page_content($page, $context, $subwikiid)
{
    global $OUTPUT, $CFG;
    if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
        $content = wiki_refresh_cachedcontent($page);
        $page = $content['page'];
    }
    if (isset($content)) {
        $box = '';
        foreach ($content['sections'] as $s) {
            $box .= '<p>' . get_string('repeatedsection', 'wiki', $s) . '</p>';
        }
        if (!empty($box)) {
            echo $OUTPUT->box($box);
        }
    }
    $html = file_rewrite_pluginfile_urls($page->cachedcontent, 'pluginfile.php', $context->id, 'mod_wiki', 'attachments', $subwikiid);
    $html = format_text($html, FORMAT_MOODLE, array('overflowdiv' => true, 'allowid' => true));
    echo $OUTPUT->box($html);
    echo $OUTPUT->tag_list(core_tag_tag::get_item_tags('mod_wiki', 'wiki_pages', $page->id), null, 'wiki-tags');
    wiki_increment_pageviews($page);
}
Example #3
0
    /**
     * This function will display administration view to users with managewiki capability
     */
    function print_content() {
        //make sure anyone trying to access this page has managewiki capabilities
        require_capability('mod/wiki:managewiki', $this->modcontext, NULL, true, 'noviewpagepermission', 'wiki');

        //update wiki cache if timedout
        $page = $this->page;
        if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
            $fresh = wiki_refresh_cachedcontent($page);
            $page = $fresh['page'];
        }

        //dispaly admin menu
        echo $this->wikioutput->menu_admin($this->page->id, $this->view);

        //Display appropriate admin view
        switch ($this->view) {
            case 1: //delete page view
                $this->print_delete_content($this->listorphan);
                break;
            case 2: //delete version view
                $this->print_delete_version();
                break;
            default: //default is delete view
                $this->print_delete_content($this->listorphan);
                break;
        }
    }
 /**
  * Prints the updated tab content
  *
  * @uses $COURSE, $OUTPUT
  *
  */
 private function print_updated_content()
 {
     global $COURSE, $OUTPUT;
     $page = $this->page;
     if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
         $fresh = wiki_refresh_cachedcontent($page);
         $page = $fresh['page'];
     }
     $swid = $this->subwiki->id;
     $table = new html_table();
     $table->head = array(get_string('updatedpages', 'wiki') . $OUTPUT->help_icon('updatedpages', 'wiki'));
     $table->attributes['class'] = 'wiki_editor generalbox';
     $table->data = array();
     $table->rowclasses = array();
     if ($pages = wiki_get_updated_pages_by_subwiki($swid)) {
         $strdataux = '';
         foreach ($pages as $page) {
             $user = wiki_get_user_info($page->userid);
             $strdata = strftime('%d %b %Y', $page->timemodified);
             if ($strdata != $strdataux) {
                 $table->data[] = array($OUTPUT->heading($strdata, 4));
                 $strdataux = $strdata;
             }
             $link = wiki_parser_link($page->title, array('swid' => $swid));
             $class = $link['new'] ? 'class="wiki_newentry"' : '';
             $linkpage = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>';
             $icon = $OUTPUT->user_picture($user, array($COURSE->id));
             $table->data[] = array("{$icon}&nbsp;{$linkpage}");
         }
     } else {
         $table->data[] = array(get_string('noupdatedpages', 'wiki'));
     }
     echo html_writer::table($table);
 }
Example #5
0
 /**
  * Returns the document for a particular page.
  *
  * @param \stdClass $record A record containing, at least, the indexed document id and a modified timestamp
  * @param array     $options Options for document creation
  * @return \core_search\document
  */
 public function get_document($record, $options = array())
 {
     try {
         $cm = $this->get_cm('wiki', $record->wikiid, $record->courseid);
         $context = \context_module::instance($cm->id);
     } catch (\dml_missing_record_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     } catch (\dml_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Make a page object without extra fields.
     $page = clone $record;
     unset($page->courseid);
     unset($page->wikiid);
     // Conversion based wiki_print_page_content().
     // Check if we have passed the cache time.
     if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
         $content = wiki_refresh_cachedcontent($page);
         $page = $content['page'];
     }
     // Convert to text.
     $content = content_to_text($page->cachedcontent, FORMAT_MOODLE);
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
     $doc->set('title', content_to_text($record->title, false));
     $doc->set('content', $content);
     $doc->set('contextid', $context->id);
     $doc->set('courseid', $record->courseid);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('modified', $record->timemodified);
     // Check if this document should be considered new.
     if (isset($options['lastindexedtime']) && $options['lastindexedtime'] < $record->timecreated) {
         // If the document was created after the last index time, it must be new.
         $doc->set_is_new(true);
     }
     return $doc;
 }
Example #6
0
 /**
  * Get a page contents.
  *
  * @param int $pageid The page ID.
  * @return array of warnings and page data.
  * @since Moodle 3.1
  */
 public static function get_page_contents($pageid)
 {
     $params = self::validate_parameters(self::get_page_contents_parameters(), array('pageid' => $pageid));
     $warnings = array();
     // Get wiki page.
     if (!($page = wiki_get_page($params['pageid']))) {
         throw new moodle_exception('incorrectpageid', 'wiki');
     }
     // Get wiki instance.
     if (!($wiki = wiki_get_wiki_from_pageid($params['pageid']))) {
         throw new moodle_exception('incorrectwikiid', 'wiki');
     }
     // Permission validation.
     $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     // Check if user can view this wiki.
     if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
         throw new moodle_exception('incorrectsubwikiid', 'wiki');
     }
     if (!wiki_user_can_view($subwiki, $wiki)) {
         throw new moodle_exception('cannotviewpage', 'wiki');
     }
     $returnedpage = array();
     $returnedpage['id'] = $page->id;
     $returnedpage['wikiid'] = $wiki->id;
     $returnedpage['subwikiid'] = $page->subwikiid;
     $returnedpage['groupid'] = $subwiki->groupid;
     $returnedpage['userid'] = $subwiki->userid;
     $returnedpage['title'] = $page->title;
     // Refresh page cached content if needed.
     if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
         if ($content = wiki_refresh_cachedcontent($page)) {
             $page = $content['page'];
         }
     }
     list($returnedpage['cachedcontent'], $returnedpage['contentformat']) = external_format_text($page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
     $returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);
     $result = array();
     $result['page'] = $returnedpage;
     $result['warnings'] = $warnings;
     return $result;
 }
Example #7
0
/**
 * This file keeps track of upgrades to the wiki module
 *
 * Sometimes, changes between versions involve
 * alterations to database structures and other
 * major things that may break installations.
 *
 * The upgrade function in this file will attempt
 * to perform all the necessary actions to upgrade
 * your older installation to the current version.
 *
 * @package mod-wiki-2.0
 * @copyrigth 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
 * @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
 *
 * @author Jordi Piguillem
 *
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 *
 */
function xmldb_wiki_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    $dbman = $DB->get_manager();
    // Step 0: Add new fields to main wiki table
    if ($oldversion < 2010040100) {
        require_once dirname(__FILE__) . '/upgradelib.php';
        echo $OUTPUT->notification('Adding new fields to wiki table', 'notifysuccess');
        wiki_add_wiki_fields();
        upgrade_mod_savepoint(true, 2010040100, 'wiki');
    }
    // Step 1: Rename old tables
    if ($oldversion < 2010040101) {
        $tables = array('wiki_pages', 'wiki_locks', 'wiki_entries');
        echo $OUTPUT->notification('Renaming old wiki module tables', 'notifysuccess');
        foreach ($tables as $tablename) {
            $table = new xmldb_table($tablename);
            if ($dbman->table_exists($table)) {
                if ($dbman->table_exists($table)) {
                    $dbman->rename_table($table, $tablename . '_old');
                }
            }
        }
        upgrade_mod_savepoint(true, 2010040101, 'wiki');
    }
    // Step 2: Creating new tables
    if ($oldversion < 2010040102) {
        require_once dirname(__FILE__) . '/upgradelib.php';
        echo $OUTPUT->notification('Installing new wiki module tables', 'notifysuccess');
        wiki_upgrade_install_20_tables();
        upgrade_mod_savepoint(true, 2010040102, 'wiki');
    }
    // Step 3: migrating wiki instances
    if ($oldversion < 2010040103) {
        upgrade_set_timeout();
        // Setting up wiki configuration
        $sql = "UPDATE {wiki}\n                    SET intro = summary,\n                    firstpagetitle = pagename,\n                    defaultformat = ?";
        $DB->execute($sql, array('html'));
        $sql = "UPDATE {wiki}\n                    SET wikimode = ?\n                    WHERE wtype = ?";
        $DB->execute($sql, array('collaborative', 'group'));
        $sql = "UPDATE {wiki}\n                    SET wikimode = ?\n                    WHERE wtype != ?";
        $DB->execute($sql, array('individual', 'group'));
        // Removing edit & create capability to students in old teacher wikis
        $studentroles = $DB->get_records('role', array('archetype' => 'student'));
        $wikis = $DB->get_records('wiki');
        foreach ($wikis as $wiki) {
            echo $OUTPUT->notification('Migrating ' . $wiki->wtype . ' type wiki instance: ' . $wiki->name, 'notifysuccess');
            if ($wiki->wtype == 'teacher') {
                $cm = get_coursemodule_from_instance('wiki', $wiki->id);
                $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                foreach ($studentroles as $studentrole) {
                    role_change_permission($studentrole->id, $context, 'mod/wiki:editpage', CAP_PROHIBIT);
                    role_change_permission($studentrole->id, $context, 'mod/wiki:createpage', CAP_PROHIBIT);
                }
            }
        }
        echo $OUTPUT->notification('Migrating old wikis to new wikis', 'notifysuccess');
        upgrade_mod_savepoint(true, 2010040103, 'wiki');
    }
    // Step 4: migrating wiki entries to new subwikis
    if ($oldversion < 2010040104) {
        /**
         * Migrating wiki entries to new subwikis
         */
        $sql = "INSERT INTO {wiki_subwikis} (wikiid, groupid, userid)\n                SELECT DISTINCT e.wikiid, e.groupid, e.userid\n                  FROM {wiki_entries_old} e";
        echo $OUTPUT->notification('Migrating old entries to new subwikis', 'notifysuccess');
        $DB->execute($sql, array());
        upgrade_mod_savepoint(true, 2010040104, 'wiki');
    }
    // Step 5: Migrating pages
    if ($oldversion < 2010040105) {
        // select all wiki pages
        $sql = "SELECT s.id, p.pagename, p.created, p.lastmodified, p.userid, p.hits\n                  FROM {wiki_pages_old} p\n                  LEFT OUTER JOIN {wiki_entries_old} e ON e.id = p.wiki\n                  LEFT OUTER JOIN {wiki_subwikis} s ON s.wikiid = e.wikiid AND s.groupid = e.groupid AND s.userid = e.userid\n                 WHERE p.version = (SELECT max(po.version)\n                                      FROM {wiki_pages_old} po\n                                     WHERE p.pagename = po.pagename AND p.wiki = po.wiki)";
        echo $OUTPUT->notification('Migrating old pages to new pages', 'notifysuccess');
        $records = $DB->get_recordset_sql($sql);
        foreach ($records as $record) {
            $page = new stdclass();
            $page->subwikiid = $record->id;
            $page->title = $record->pagename;
            $page->cachedcontent = '**reparse needed**';
            $page->timecreated = $record->created;
            $page->timemodified = $record->lastmodified;
            $page->userid = $record->userid;
            $page->pageviews = $record->hits;
            try {
                // make sure there is no duplicated records exist
                if (!$DB->record_exists('wiki_pages', array('subwikiid' => $record->id, 'userid' => $record->userid, 'title' => $record->pagename))) {
                    $DB->insert_record('wiki_pages', $page);
                }
            } catch (dml_exception $e) {
                // catch possible insert exception
                debugging($e->getMessage());
                continue;
            }
        }
        $records->close();
        upgrade_mod_savepoint(true, 2010040105, 'wiki');
    }
    // Step 6: Migrating versions
    if ($oldversion < 2010040106) {
        require_once dirname(__FILE__) . '/upgradelib.php';
        echo $OUTPUT->notification('Migrating old history to new history', 'notifysuccess');
        wiki_upgrade_migrate_versions();
        upgrade_mod_savepoint(true, 2010040106, 'wiki');
    }
    // Step 7: refresh cachedcontent and fill wiki links table
    if ($oldversion < 2010040107) {
        require_once $CFG->dirroot . '/mod/wiki/locallib.php';
        upgrade_set_timeout();
        $pages = $DB->get_recordset('wiki_pages');
        foreach ($pages as $page) {
            wiki_refresh_cachedcontent($page);
        }
        $pages->close();
        echo $OUTPUT->notification('Caching content', 'notifysuccess');
        upgrade_mod_savepoint(true, 2010040107, 'wiki');
    }
    // Step 8, migrating files
    if ($oldversion < 2010040108) {
        $fs = get_file_storage();
        $sql = "SELECT files.*, po.meta AS filemeta FROM {wiki_pages_old} po JOIN (\n                    SELECT DISTINCT po.id, po.pagename, w.id AS wikiid, po.userid,\n                        eo.id AS entryid, eo.groupid, s.id AS subwiki,\n                        w.course AS courseid, cm.id AS cmid\n                        FROM {wiki_pages_old} po\n                        LEFT OUTER JOIN {wiki_entries_old} eo\n                        ON eo.id=po.wiki\n                        LEFT OUTER JOIN {wiki} w\n                        ON w.id = eo.wikiid\n                        LEFT OUTER JOIN {wiki_subwikis} s\n                        ON s.groupid = eo.groupid AND s.wikiid = eo.wikiid AND eo.userid = s.userid\n                        JOIN {modules} m ON m.name = 'wiki'\n                        JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = w.id)\n                ) files ON files.id = po.id";
        $rs = $DB->get_recordset_sql($sql);
        foreach ($rs as $r) {
            if (strpos($r->pagename, 'internal://') !== false) {
                // Found a file resource!
                $pattern = 'internal://';
                $matches = array();
                $filename = str_replace($pattern, '', $r->pagename);
                $orgifilename = $filename = clean_param($filename, PARAM_FILE);
                $context = get_context_instance(CONTEXT_MODULE, $r->cmid);
                $filemeta = unserialize($r->filemeta);
                $filesection = $filemeta['section'];
                // When attach a file to wiki page, user can customize the file name instead of original file name
                // if user did, old wiki will create two pages, internal://original_pagename and internal://renamed_pagename
                // internal://original_pagename record has renamed pagename in meta field
                // but all file have this field
                // old wiki will rename file names to filter space and special character
                if (!empty($filemeta['Content-Location'])) {
                    $orgifilename = urldecode($filemeta['Content-Location']);
                    $orgifilename = str_replace(' ', '_', $orgifilename);
                }
                $thefile = $CFG->dataroot . '/' . $r->courseid . '/moddata/wiki/' . $r->wikiid . '/' . $r->entryid . '/' . $filesection . '/' . $filename;
                if (is_file($thefile) && is_readable($thefile)) {
                    $filerecord = array('contextid' => $context->id, 'component' => 'mod_wiki', 'filearea' => 'attachments', 'itemid' => $r->subwiki, 'filepath' => '/', 'filename' => $orgifilename, 'userid' => $r->userid);
                    if (!$fs->file_exists($context->id, 'mod_wiki', 'attachments', $r->subwiki, '/', $orgifilename)) {
                        //echo $OUTPUT->notification('Migrating file '.$orgifilename, 'notifysuccess');
                        $storedfile = $fs->create_file_from_pathname($filerecord, $thefile);
                    }
                    // we have to create another file here to make sure interlinks work
                    if (!$fs->file_exists($context->id, 'mod_wiki', 'attachments', $r->subwiki, '/', $filename)) {
                        $filerecord['filename'] = $filename;
                        //echo $OUTPUT->notification('Migrating file '.$filename, 'notifysuccess');
                        $storedfile = $fs->create_file_from_pathname($filerecord, $thefile);
                    }
                } else {
                    echo $OUTPUT->notification("Bad data found: {$r->pagename} <br/> Expected file path: {$thefile} Please fix the bad file path manually.");
                }
            }
        }
        $rs->close();
        upgrade_mod_savepoint(true, 2010040108, 'wiki');
    }
    // Step 9: clean wiki table
    if ($oldversion < 2010040109) {
        $fields = array('summary', 'pagename', 'wtype', 'ewikiprinttitle', 'htmlmode', 'ewikiacceptbinary', 'disablecamelcase', 'setpageflags', 'strippages', 'removepages', 'revertchanges', 'initialcontent');
        $table = new xmldb_table('wiki');
        foreach ($fields as $fieldname) {
            $field = new xmldb_field($fieldname);
            if ($dbman->field_exists($table, $field)) {
                $dbman->drop_field($table, $field);
            }
        }
        echo $OUTPUT->notification('Cleaning wiki table', 'notifysuccess');
        upgrade_mod_savepoint(true, 2010040109, 'wiki');
    }
    if ($oldversion < 2010080201) {
        $sql = "UPDATE {comments}\n                SET commentarea = 'wiki_page'\n                WHERE commentarea = 'wiki_comment_section'";
        $DB->execute($sql);
        $sql = "UPDATE {tag_instance}\n                SET itemtype = 'wiki_page'\n                WHERE itemtype = 'wiki'";
        $DB->execute($sql);
        echo $OUTPUT->notification('Updating comments and tags', 'notifysuccess');
        upgrade_mod_savepoint(true, 2010080201, 'wiki');
    }
    if ($oldversion < 2010102500) {
        // Define key subwikifk (foreign) to be added to wiki_pages
        $table = new xmldb_table('wiki_pages');
        $key = new xmldb_key('subwikifk', XMLDB_KEY_FOREIGN, array('subwikiid'), 'wiki_subwikis', array('id'));
        // Launch add key subwikifk
        $dbman->add_key($table, $key);
        // Define key subwikifk (foreign) to be added to wiki_links
        $table = new xmldb_table('wiki_links');
        $key = new xmldb_key('subwikifk', XMLDB_KEY_FOREIGN, array('subwikiid'), 'wiki_subwikis', array('id'));
        // Launch add key subwikifk
        $dbman->add_key($table, $key);
        // wiki savepoint reached
        upgrade_mod_savepoint(true, 2010102500, 'wiki');
    }
    if ($oldversion < 2010102800) {
        $sql = "UPDATE {tag_instance}\n                SET itemtype = 'wiki_pages'\n                WHERE itemtype = 'wiki_page'";
        $DB->execute($sql);
        echo $OUTPUT->notification('Updating tags itemtype', 'notifysuccess');
        upgrade_mod_savepoint(true, 2010102800, 'wiki');
    }
    if ($oldversion < 2011011000) {
        // Fix wiki in the post table after upgrade from 1.9
        $table = new xmldb_table('wiki');
        // name should default to Wiki
        $field = new xmldb_field('name', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL, null, 'Wiki', 'course');
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_default($table, $field);
        }
        // timecreated field is missing after 1.9 upgrade
        $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'introformat');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // timemodified field is missing after 1.9 upgrade
        $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'timecreated');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // scaleid is not there any more
        $field = new xmldb_field('scaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
        if ($dbman->field_exists($table, $field)) {
            $dbman->drop_field($table, $field);
        }
        upgrade_mod_savepoint(true, 2011011000, 'wiki');
    }
    // TODO: Will hold the old tables so we will have chance to fix problems
    // Will remove old tables once migrating 100% stable
    // Step 10: delete old tables
    //if ($oldversion < 2011060300) {
    //$tables = array('wiki_pages', 'wiki_locks', 'wiki_entries');
    //foreach ($tables as $tablename) {
    //$table = new xmldb_table($tablename . '_old');
    //if ($dbman->table_exists($table)) {
    //$dbman->drop_table($table);
    //}
    //}
    //echo $OUTPUT->notification('Droping old tables', 'notifysuccess');
    //upgrade_mod_savepoint(true, 2011060300, 'wiki');
    //}
    return true;
}
Example #8
0
function wiki_print_page_content($page, $context, $subwikiid)
{
    global $OUTPUT, $CFG;
    if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
        $content = wiki_refresh_cachedcontent($page);
        $page = $content['page'];
    }
    if (isset($content)) {
        $box = '';
        foreach ($content['sections'] as $s) {
            $box .= '<p>' . get_string('repeatedsection', 'wiki', $s) . '</p>';
        }
        if (!empty($box)) {
            echo $OUTPUT->box($box);
        }
    }
    $html = file_rewrite_pluginfile_urls($page->cachedcontent, 'pluginfile.php', $context->id, 'mod_wiki', 'attachments', $subwikiid);
    $html = format_text($html, FORMAT_MOODLE, array('overflowdiv' => true));
    echo $OUTPUT->box($html);
    if (!empty($CFG->usetags)) {
        $tags = tag_get_tags_array('wiki_pages', $page->id);
        echo '<p class="wiki-tags"><span>Tags: </span>' . join($tags, ", ") . '</p>';
    }
    wiki_increment_pageviews($page);
}