示例#1
0
function get_online_display_content($format, $pageversion, $context, $subwiki, $cm, $index, $fs, &$files)
{
    $markup = '';
    $visibletitle = $pageversion->title === '' ? get_string('startpage', 'ouwiki') : $pageversion->title;
    if ($format != OUWIKI_FORMAT_TEMPLATE) {
        $pageversion->xhtml = file_rewrite_pluginfile_urls($pageversion->xhtml, 'pluginfile.php', $context->id, 'mod_ouwiki', 'content', $pageversion->versionid);
    }
    switch ($format) {
        case OUWIKI_FORMAT_TEMPLATE:
            // Print template wiki page.
            $markup .= '<page>';
            if ($pageversion->title !== '') {
                $markup .= '<title>' . htmlspecialchars($pageversion->title) . '</title>';
            }
            $markup .= '<versionid>' . $pageversion->versionid . '</versionid>';
            // Copy images found in content.
            preg_match_all('#<img.*?src="@@PLUGINFILE@@/(.*?)".*?/>#', $pageversion->xhtml, $matches);
            if (!empty($matches)) {
                // Extract the file names from the matches.
                foreach ($matches[1] as $key => $match) {
                    // Get file name and copy to zip.
                    $match = urldecode($match);
                    // Copy image - on fail swap tag with string.
                    if ($file = $fs->get_file($context->id, 'mod_ouwiki', 'content', $pageversion->versionid, '/', $match)) {
                        $files["/{$pageversion->versionid}/{$match}/"] = $file;
                    } else {
                        $pageversion->xhtml = str_replace($matches[0][$key], $brokenimagestr, $pageversion->xhtml);
                    }
                }
            }
            $markup .= '<xhtml>' . htmlspecialchars($pageversion->xhtml) . '</xhtml>';
            // Add attachments.
            if ($attachments = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $pageversion->versionid, 'itemid', false)) {
                // We have attachements.
                $markup .= '<attachments>';
                $attachmentsarray = array();
                foreach ($attachments as $attachment) {
                    $filename = $attachment->get_filename();
                    array_push($attachmentsarray, $filename);
                    $files["/{$pageversion->versionid}/{$filename}/"] = $attachment;
                }
                $markup .= implode('|', $attachmentsarray);
                $markup .= '</attachments>';
            }
            $markup .= '</page>';
            break;
        case OUWIKI_FORMAT_RTF:
            $markup .= '<h1>' . htmlspecialchars($visibletitle) . '</h1>';
            $markup .= trim($pageversion->xhtml);
            $markup .= '<br /><br /><hr />';
            break;
        case OUWIKI_FORMAT_HTML:
            print '<div class="ouw_entry"><a name="' . $pageversion->pageid . '"></a><h1 class="ouw_entry_heading">' . '<a href="view.php?' . ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm) . '">' . htmlspecialchars($visibletitle) . '</a></h1>';
            print ouwiki_convert_content($pageversion->xhtml, $subwiki, $cm, $index, $pageversion->xhtmlformat);
            print '</div>';
            break;
    }
    return $markup;
}
示例#2
0
        case OUWIKI_FORMAT_TEMPLATE:
            print '<page>';
            if ($pageversion->title !== '') {
                print '<title>' . htmlspecialchars($pageversion->title) . '</title>';
            }
            print '<xhtml>' . htmlspecialchars($pageversion->xhtml) . '</xhtml>';
            print '</page>';
            break;
        case OUWIKI_FORMAT_RTF:
            $html .= '<h1>' . htmlspecialchars($visibletitle) . '</h1>';
            $html .= trim($pageversion->xhtml);
            $html .= '<br /><br /><hr />';
            break;
        case OUWIKI_FORMAT_HTML:
            print '<div class="ouw_entry"><a name="' . $pageversion->pageid . '"></a><h1 class="ouw_entry_heading"><a href="view.php?' . ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm) . '">' . htmlspecialchars($visibletitle) . '</a></h1>';
            print ouwiki_convert_content($pageversion->xhtml, $subwiki, $cm, $index, $pageversion->xhtmlformat);
            print '</div>';
            break;
    }
    if ($first) {
        $first = false;
    }
}
switch ($format) {
    case OUWIKI_FORMAT_TEMPLATE:
        print '</wiki>';
        break;
    case OUWIKI_FORMAT_RTF:
        $html .= '</root>';
        rtf_from_html($filename . '.rtf', $html);
        break;
示例#3
0
 public function ouwiki_print_preview($content, $page, $subwiki, $cm, $contentformat)
 {
     global $CFG;
     // Convert content.
     $content = ouwiki_convert_content($content, $subwiki, $cm, null, $contentformat);
     // Need to replace brokenfile.php with draftfile.php since switching off filters
     // will switch off all filter.
     $content = str_replace("\"{$CFG->httpswwwroot}/brokenfile.php#", "\"{$CFG->httpswwwroot}/draftfile.php", $content);
     // Create output to be returned for printing.
     $output = html_writer::tag('p', get_string('previewwarning', 'ouwiki'), array('class' => 'ouw_warning'));
     $output .= html_writer::start_tag('div', array('class' => 'ouw_preview'));
     $output .= $this->output->box_start("generalbox boxaligncenter");
     // Title & content of page.
     $title = $page !== null && $page !== '' ? htmlspecialchars($page) : get_string('startpage', 'ouwiki');
     $output .= html_writer::tag('h1', $title);
     $output .= $content;
     $output .= html_writer::end_tag('div');
     $output .= $this->output->box_end();
     return $output;
 }
示例#4
0
}
if ($save) {
    if (!$newsection) {
        // Check we started editing the right version
        $startversionid = required_param('startversionid', PARAM_INT);
        $versionok = $startversionid == $pageversion->versionid;
    } else {
        $versionok = true;
    }
    // If we either don't have a lock or are editing the wrong version...
    if (!$versionok || !$lockok) {
        $savefailtitle = get_string('savefailtitle', 'ouwiki');
        $specificmessage = get_string(!$versionok ? 'savefaildesynch' : 'savefaillocked', 'ouwiki');
        $returntoview = get_string('returntoview', 'ouwiki');
        $savefailcontent = get_string('savefailcontent', 'ouwiki');
        $actualcontent = ouwiki_convert_content($content, $subwiki, $cm, null, $pageversion->xhtmlformat);
        // we are either returning to an existing page or a "new" one that ws
        // simultaneously created by someone else at the same time
        $returnpage = $addpage ? $frompage : $pagename;
        ouwiki_release_lock($pageversion->pageid);
        echo $OUTPUT->header();
        $pagefield = '';
        if ($returnpage !== '') {
            $pagefield = html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'page', 'value' => $returnpage));
        }
        print '<div id="ouwiki_savefail">' . '<h2>' . $savefailtitle . '</h2>' . '<p>' . $specificmessage . '</p>' . '<form action="view.php" method="get">' . '<input type="hidden" name="id" value="' . $cm->id . '" />' . $pagefield . '<input type="submit" value="' . $returntoview . '" />' . '</form>' . '<p>' . $savefailcontent . '</p>' . '<div class="ouwiki_savefailcontent">' . $actualcontent . '</div>' . '</div><div>';
        ouwiki_print_footer($course, $cm, $subwiki, $pagename);
        exit;
    }
    $event = null;
    if ($section) {
function ouwiki_display_preview($content, $page, $subwiki, $cm)
{
    // Title
    $title = $page !== null && $page !== '' ? htmlspecialchars($page) : get_string('startpage', 'ouwiki');
    $result = '<h1>' . $title . '</h1>';
    // Content of page
    $result .= ouwiki_convert_content($content, $subwiki, $cm);
    return $result;
}
function ouwiki_display_entirewiki_page_in_index($pageinfo, $subwiki, $cm, $index, $context)
{
    global $ouwiki;
    // Get page details.
    $pageversion = ouwiki_get_current_page($subwiki, $pageinfo->title);
    // If the page hasn't really been created yet, skip it.
    if (is_null($pageversion->xhtml)) {
        return '';
    }
    $visibletitle = $pageversion->title === '' ? get_string('startpage', 'ouwiki') : $pageversion->title;
    $pageversion->xhtml = file_rewrite_pluginfile_urls($pageversion->xhtml, 'pluginfile.php', $context->id, 'mod_ouwiki', 'content', $pageversion->versionid);
    $pageversion->xhtml = ouwiki_convert_content($pageversion->xhtml, $subwiki, $cm, $index, $pageversion->xhtmlformat);
    $output = '<div class="ouw_entry"><a name="' . $pageversion->pageid . '"></a><h1 class="ouw_entry_heading"><a href="view.php?' . ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm) . '">' . htmlspecialchars($visibletitle) . '</a></h1>';
    $output .= $pageversion->xhtml;
    $output .= '</div>';
    return $output;
}
 if (!$addnewsection) {
     // Check we started editing the right version
     $startversionid = required_param('startversionid', PARAM_INT);
     $versionok = $startversionid == $pageversion->versionid;
 } else {
     $versionok = true;
 }
 // If we either don't have a lock or are editing the wrong version...
 if (!$versionok || !$lockok) {
     ouwiki_release_lock($pageversion->pageid);
     ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context);
     $savefailtitle = get_string('savefailtitle', 'ouwiki');
     $specificmessage = get_string(!$versionok ? 'savefaildesynch' : 'savefaillocked', 'ouwiki');
     $returntoview = get_string('returntoview', 'ouwiki');
     $savefailcontent = get_string('savefailcontent', 'ouwiki');
     $actualcontent = ouwiki_convert_content($content, $subwiki, $cm);
     print "\n<div id='ouwiki_savefail'>\n  <h2>{$savefailtitle}</h2>\n  <p>{$specificmessage}</p>\n  <form action='view.php' method='get'>\n    {$wikiformfields}\n    <input type='submit' value='{$returntoview}' />\n  </form>\n  <p>{$savefailcontent}</p>\n  <div class='ouwiki_savefailcontent'>\n    {$actualcontent}\n  </div>\n</div>";
     print_footer($course);
     exit;
 }
 $section = optional_param('section', null, PARAM_RAW);
 if ($section) {
     ouwiki_save_new_version_section($course, $cm, $ouwiki, $subwiki, $pagename, $pageversion->xhtml, $content, $sectiondetails);
 } else {
     if ($createnewpage) {
         ouwiki_create_new_page($course, $cm, $ouwiki, $subwiki, $originalpagename, $pagename, $content);
     } else {
         if ($addnewsection) {
             ouwiki_create_new_section($course, $cm, $ouwiki, $subwiki, $pagename, $content, $sectionheader);
         } else {
             // do normal save