} else {
         displaydir($wdir);
     }
     html_footer();
     break;
 case "listzip":
     html_header($course, $wdir);
     if (!empty($file) and confirm_sesskey()) {
         $strname = get_string("name");
         $strsize = get_string("size");
         $strmodified = get_string("modified");
         $strok = get_string("ok");
         $strlistfiles = get_string("listfiles", "", $file);
         $prop = null;
         $prop->class = "textcenter";
         wiki_div($strlistfiles . ":", $prop);
         wiki_br();
         $file = basename($file);
         include_once "{$CFG->libdir}/pclzip/pclzip.lib.php";
         $archive = new PclZip(cleardoubleslashes("{$basedir}/{$wdir}/{$file}"));
         if (!($list = $archive->listContent(cleardoubleslashes("{$basedir}/{$wdir}")))) {
             notify($archive->errorInfo(true));
         } else {
             $prop = null;
             $prop->border = "0";
             $prop->spacing = "2";
             $prop->padding = "4";
             $prop->width = "640";
             $prop->class = "files";
             $prop->header = true;
             $prop->alignth = "left";
print_header("{$course->shortname}: {$dfwiki->name}", "{$course->fullname}", "{$navigation} <a href=\"index.php?id={$course->id}\">{$strwikis}</a> -> {$dfwiki->name}", "", "", true);
//Check if either we're comming from the form or this is the first time
if (optional_param('sure', NULL, PARAM_ALPHA) == get_string('yes')) {
    //Form has already been visited
    if (wiki_convert_all_dfwikis($course)) {
        wiki_br();
        print_simple_box_start();
        $prop = null;
        $prop->class = "textcenter";
        wiki_size_text(get_string("convertdfwikicorrectly", "wiki"), 2, $prop);
        print_continue("view.php?id={$cm->id}");
        wiki_br();
        print_simple_box_end();
    } else {
        //there aren't dfwikis to convert
        wiki_div('&nbsp;');
        print_simple_box_start();
        $prop = null;
        $prop->class = "textcenter";
        wiki_paragraph(get_string('nodfwikistoconvert', 'wiki'), $prop);
        $prop = null;
        $prop->id = "form";
        $prop->method = "post";
        $prop->action = 'view.php?id=' . $cm->id;
        wiki_form_start($prop);
        $prop = null;
        $prop->class = "textcenter";
        wiki_div_start($prop);
        $prop = null;
        $prop->name = "continue";
        $prop->value = get_string('continue');
function wiki_import_wiki(&$WS)
{
    global $file;
    //if the form is complete
    $sure = optional_param('dfformsure', NULL, PARAM_ALPHA);
    if (isset($sure)) {
        //import to xml
        wiki_import_wiki_XML($WS);
        $prop = null;
        $prop->class = 'textcenter';
        $info = wiki_size_text(get_string("importcorrectly", 'wiki'), 2, '', true);
        wiki_div($info, $prop);
        $prop = null;
        $prop->action = '../view.php?id=' . $WS->cm->id;
        $prop->method = 'post';
        $prop->id = 'form';
        wiki_form_start($prop);
        $prop = null;
        $prop->border = '0';
        $prop->class = 'boxaligncenter';
        $prop->classtd = 'nwikileftnow';
        wiki_table_start($prop);
        $prop = null;
        $prop->name = 'dfformcontinue';
        $prop->value = get_string('continue');
        $input = wiki_input_submit($prop, true);
        wiki_div($input);
        wiki_table_end();
        wiki_form_end();
    } else {
        if (isset($WS->dfform['import'])) {
            $extension = explode("/", $WS->path);
            $num = count($extension) - 1;
            $name = $extension[$num];
            $info = wiki_b(get_string("importcheckwarning", 'wiki'), '', true);
            $info .= '    ' . $name;
            $prop = null;
            $prop->class = 'textcenter';
            wiki_paragraph($info, $prop);
            switch ($WS->dfform['incase']) {
                case 0:
                    $name = get_string("always", 'diki');
                    break;
                case 1:
                    $name = get_string("never", 'wiki');
                    break;
                case 2:
                    $name = get_string("before", 'wiki');
                    break;
                case 3:
                    $name = get_string("after", 'wiki');
                    break;
                default:
                    break;
            }
            $info = wiki_b(get_string("incase", 'wiki'), '', true);
            $info .= '  ' . $name;
            $prop = null;
            $prop->class = 'textcenter';
            wiki_paragraph($info, $prop);
            switch ($WS->dfform['incaseatach']) {
                case 0:
                    $name = get_string("alwaysatach", 'wiki');
                    break;
                case 1:
                    $name = get_string("neveratach", 'wiki');
                    break;
                case 2:
                    $name = get_string("beforeatach", 'wiki');
                    break;
                case 3:
                    $name = get_string("afteratach", 'wiki');
                    break;
                case 4:
                    $name = get_string("bigeratach", 'wiki');
                    break;
                case 5:
                    $name = get_string("smalleratach", 'wiki');
                    break;
                default:
                    break;
            }
            $info = wiki_b(get_string("incaseatach", 'wiki'), '', true);
            $info .= '  ' . $name;
            $prop = null;
            $prop->class = 'textcenter';
            wiki_paragraph($info, $prop);
            wiki_br();
            $prop = null;
            $prop->class = 'textcenter';
            wiki_paragraph(get_string("importcheckfiles", 'wiki'), $prop);
            $prop = null;
            $prop->class = 'boxaligncenter';
            wiki_table_start($prop);
            $prop = null;
            $prop->action = 'exportxml.php?id=' . $WS->cm->id . '&amp;pageaction=importxml&amp;path=' . $WS->path;
            $prop->method = 'post';
            $prop->id = 'form1';
            wiki_form_start($prop);
            $prop = null;
            $prop->name = 'dfformincase';
            $prop->value = $WS->dfform['incase'];
            wiki_input_hidden($prop);
            $prop = null;
            $prop->name = 'dfformincaseatach';
            $prop->value = $WS->dfform['incaseatach'];
            wiki_input_hidden($prop);
            $prop = null;
            $prop->name = 'dfformsure';
            $prop->value = get_string('yes');
            wiki_input_submit($prop);
            wiki_form_end();
            wiki_change_column();
            $prop = null;
            $prop->action = 'exportxml.php?id=' . $WS->cm->id . '&amp;pageaction=importewiki&amp;path=' . $WS->path . '&amp;file=' . $file;
            $prop->method = 'post';
            $prop->id = 'form2';
            wiki_form_start($prop);
            $prop = null;
            $prop->name = 'dfformcancel';
            $prop->value = get_string('no');
            wiki_input_submit($prop);
            wiki_form_end();
            wiki_table_end();
        } else {
            //create the form to import
            $prop = null;
            $prop->action = 'exportxml.php?id=' . $WS->cm->id . '&amp;pageaction=importewiki&amp;type=' . $WS->type . '&amp;path=' . $WS->path . '&amp;file=' . $file;
            $prop->method = 'post';
            $prop->id = 'form';
            wiki_form_start($prop);
            $prop = null;
            $prop->border = '0';
            $prop->class = 'boxaligncenter';
            $prop->classtd = 'nwikileftnow';
            wiki_table_start($prop);
            wiki_b(get_string('incase', 'wiki'));
            wiki_table_start();
            $prop = null;
            $prop->name = 'dfformincase';
            $prop->value = '0';
            $prop->checked = 'checked';
            wiki_input_radio($prop);
            print_string('always', 'wiki');
            wiki_change_row();
            $prop = null;
            $prop->name = 'dfformincase';
            $prop->value = '1';
            wiki_input_radio($prop);
            print_string('never', 'wiki');
            wiki_change_row();
            $prop = null;
            $prop->name = 'dfformincase';
            $prop->value = '2';
            wiki_input_radio($prop);
            print_string('before', 'wiki');
            wiki_change_row();
            $prop = null;
            $prop->name = 'dfformincase';
            $prop->value = '3';
            wiki_input_radio($prop);
            print_string('after', 'wiki');
            wiki_table_end();
            wiki_br(2);
            $prop = null;
            $prop->class = "nwikileftnow";
            wiki_change_row($prop);
            wiki_b(get_string('incaseatach', 'wiki'));
            wiki_table_start();
            $prop = null;
            $prop->name = 'dfformincaseatach';
            $prop->value = '0';
            $prop->checked = 'checked';
            wiki_input_radio($prop);
            print_string('alwaysatach', 'wiki');
            wiki_change_row();
            $prop = null;
            $prop->name = 'dfformincaseatach';
            $prop->value = '1';
            wiki_input_radio($prop);
            print_string('neveratach', 'wiki');
            wiki_change_row();
            $prop = null;
            $prop->name = 'dfformincaseatach';
            $prop->value = '2';
            wiki_input_radio($prop);
            print_string('beforeatach', 'wiki');
            wiki_change_row();
            $prop = null;
            $prop->name = 'dfformincaseatach';
            $prop->value = '3';
            wiki_input_radio($prop);
            print_string('afteratach', 'wiki');
            wiki_change_row();
            $prop = null;
            $prop->name = 'dfformincaseatach';
            $prop->value = '4';
            wiki_input_radio($prop);
            print_string('bigeratach', 'wiki');
            wiki_change_row();
            $prop = null;
            $prop->name = 'dfformincaseatach';
            $prop->value = '5';
            wiki_input_radio($prop);
            print_string('smalleratach', 'wiki');
            wiki_table_end();
            wiki_br(2);
            $prop = null;
            $prop->class = "nwikicenternow";
            wiki_change_row($prop);
            $prop = null;
            $prop->name = 'dfformimport';
            $prop->value = get_string('import', 'wiki');
            wiki_input_submit($prop);
            wiki_table_end();
            wiki_form_end();
        }
    }
}
/**
 * Display History tab content with page versions
 */
function wiki_info_content(&$WS)
{
    global $CFG, $COURSE, $USER;
    //generate a list with all versions
    $vers = wiki_get_all_page_versions($CFG->prefix, $WS->page, $WS->dfwiki->id, $WS->groupmember->groupid, $WS->member->id);
    if ($vers) {
        $countver = count($vers);
        if ($countver > 1) {
            echo '<script type="text/javascript" src="wiki/hist.js"></script>';
            echo '<form id="historyform" method="post" ' . 'action="view.php?id=' . $WS->linkid . '&amp;page=' . urlencode('diff/' . $WS->page) . "&amp;gid={$WS->groupmember->groupid}&amp;uid={$WS->member->id}" . '">';
            echo '<input type="submit" name="' . get_string('compareversions', 'wiki') . '" value="' . get_string('compareversions', 'wiki') . '"/>';
            echo '<br/><br/>';
        }
        //print table with the page versions
        $prop = null;
        $prop->id = 'historytable';
        $prop->width = "100%";
        $prop->border = "1";
        $prop->padding = "5";
        $prop->spacing = "1";
        $prop->class = "generaltable boxalignleft";
        $prop->header = "true";
        $prop->valignth = "top";
        $prop->classth = 'header c0 nwikileftnow';
        wiki_table_start($prop);
        if ($countver > 1) {
            echo '';
            $prop = null;
            $prop->header = "true";
            $prop->valign = "top";
            $prop->class = "nwikileftnow header c1";
            wiki_change_column($prop);
        }
        echo get_string('version');
        $prop = null;
        $prop->header = "true";
        $prop->valign = "top";
        $prop->class = "nwikileftnow header c1";
        wiki_change_column($prop);
        echo get_string('user');
        $prop = null;
        $prop->header = "true";
        $prop->valign = "top";
        $prop->class = "nwikileftnow header c2";
        wiki_change_column($prop);
        echo get_string('lastmodified');
        if (wiki_grade_got_permission($WS)) {
            $prop = null;
            $prop->header = "true";
            $prop->valign = "top";
            $prop->class = "nwikileftnow header c3";
            wiki_change_column($prop);
            echo get_string('eval_editions_quality', 'wiki');
        }
        $prop = null;
        $prop->header = "true";
        //print content
        $i = 0;
        foreach ($vers as $ver) {
            if ($ver->highlight) {
                $class = "textcenter nwikihighlight";
            } else {
                $class = "textcenter nwikibargroundblanco";
            }
            if (isset($prop->header)) {
                $prop->class = $class;
                wiki_change_row($prop);
            } else {
                $prop = null;
                $prop->class = $class;
                wiki_change_row($prop);
            }
            // input types for history diff
            if ($countver > 1) {
                $style = 'style="visibility:hidden" ';
                $checked = 'checked="checked"';
                if ($i == 0) {
                    echo '<input type="radio" value="' . $ver->version . '" name="oldid" ' . $style . ' />';
                    echo '<input type="radio" value="' . $ver->version . '" name="diff" ' . $checked . ' />';
                } elseif ($i == 1) {
                    echo '<input type="radio" value="' . $ver->version . '" name="oldid" ' . $checked . ' />';
                    echo '<input type="radio" value="' . $ver->version . '" name="diff" ' . $style . ' />';
                } else {
                    echo '<input type="radio" value="' . $ver->version . '" name="oldid" />';
                    echo '<input type="radio" value="' . $ver->version . '" name="diff" ' . $style . ' />';
                }
                $prop = null;
                $prop->class = $class;
                wiki_change_column($prop);
            }
            if ($ver->version == $WS->pagedata->version) {
                echo $ver->version;
            } else {
                $prop = null;
                $prop->href = "javascript:document.forms['formu" . $i . "'].submit()";
                $out = wiki_a($ver->version, $prop, true);
                $prop = null;
                $prop->name = "dfcontent";
                $prop->value = "11";
                $out .= wiki_input_hidden($prop, true);
                $out2 = wiki_div($out, '', true);
                $prop = null;
                $prop->id = "formu{$i}";
                $prop->action = "view.php?id={$WS->linkid}&amp;page=" . urlencode("oldversion/{$ver->pagename}") . "&amp;ver={$ver->version}&amp;gid={$WS->groupmember->groupid}&amp;uid={$WS->member->id}";
                $prop->method = "post";
                wiki_form($out2, $prop);
            }
            $prop = null;
            $prop->class = $class;
            wiki_change_column($prop);
            $author = wiki_get_user_info($ver->author);
            echo $author;
            $prop = null;
            $prop->class = $class;
            wiki_change_column($prop);
            $modified = strftime('%A, %d %B %Y %H:%M', $ver->lastmodified);
            echo $modified;
            if (wiki_grade_got_permission($WS)) {
                $prop = null;
                $prop->class = $class;
                wiki_change_column($prop);
                $scale = array(1 => "+", 2 => "=", 3 => "-");
                $gradevalue = get_field_select('wiki_evaluation_edition', 'valoration', 'wiki_pageid=' . $ver->id);
                if ($gradevalue) {
                    echo wiki_grade_translate($gradevalue, $scale);
                } else {
                    echo get_string('eval_notset', 'wiki');
                }
            }
            $i++;
        }
        wiki_table_end();
        if ($countver > 1) {
            echo '<br/>';
            echo '<input type="submit" name="' . get_string('compareversions', 'wiki') . '" value="' . get_string('compareversions', 'wiki') . '"/>';
        }
        echo '</form>';
    } else {
        print_string('noversion', 'wiki');
    }
}
print_header("{$course->shortname}: {$dfwiki->name}", "{$course->fullname}", "{$navigation} <a href=\"../index.php?id={$course->id}\">{$strdfwikis}</a> -> {$dfwiki->name}");
print_heading(get_string("importing", 'wiki'));
$prop = null;
$prop->class = 'box generalbox generalboxcontent boxaligncenter textcenter';
wiki_div_start($prop);
$prop = null;
$prop->action = 'import.php?id=' . $course->id . '&amp;cm=' . $cm->id . '&amp;wdir=/';
$prop->method = 'post';
$prop->id = 'form1';
wiki_form_start($prop);
$prop = null;
$prop->name = 'dfform[importfromxml]';
$prop->value = get_string('importfromxml', 'wiki');
$input = wiki_input_submit($prop, true);
wiki_div($input);
wiki_form_end();
wiki_br();
$prop = null;
$prop->action = 'importwiki.php?id=' . $course->id . '&amp;cm=' . $cm->id . '&amp;wdir=/';
$prop->method = 'post';
$prop->id = 'form2';
wiki_form_start($prop);
$prop = null;
$prop->name = 'dfform[importfrombackup]';
$prop->value = get_string('importfrombackup', 'wiki');
$input = wiki_input_submit($prop, true);
wiki_div($input);
wiki_form_end();
wiki_div_end();
//Print footer
print_footer();