function print_header($title, $morebreadcrumbs = NULL) { global $USER, $CFG, $WS; $this->init_full(); if ($this->user_allowed_editing()) { $buttons = wiki_table_start('', true); $buttons .= update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'wiki')); if (!empty($CFG->showblocksonmodpages)) { $buttons .= wiki_change_column('', true); $prop = null; $prop->method = "get"; $prop->action = "view.php"; $prop->events = 'onsubmit="this.target=\'_top\'; return true"'; $buttons .= wiki_form_start($prop, true); $buttons .= wiki_div_start('', true); $prop = null; $prop->name = "id"; $prop->value = $this->modulerecord->id; $buttons .= wiki_input_hidden($prop, true); $prop = null; $prop->name = "edit"; $prop->value = $this->user_is_editing() ? 'off' : 'on'; $buttons .= wiki_input_hidden($prop, true); $prop = null; $prop->value = get_string($this->user_is_editing() ? 'blockseditoff' : 'blocksediton'); $buttons .= wiki_input_submit($prop, true); $buttons .= wiki_div_end(true); $buttons .= wiki_form_end(true); } $buttons .= wiki_table_end('', true); } else { $buttons = ' '; } // print_header($title, $this->courserecord->fullname, $crumbtext, '', '', true, $buttons, navmenu($this->courserecord, $this->modulerecord)); /// Print header. $navlinks = array(); $navlinks[] = array('name' => get_string('modulenameplural', 'wiki'), 'link' => $CFG->wwwroot . '/mod/wiki/index.php?id=' . $this->courserecord->id, 'type' => 'activity'); $navlinks[] = array('name' => format_string($this->activityrecord->name), 'link' => "view.php", 'type' => 'activityinstance'); $navigation = build_navigation($navlinks); print_header_simple(format_string($this->activityrecord->name), "", $navigation, "", "", true, $buttons, navmenu($this->courserecord, $WS->cm)); }
function wiki_export_html(&$WS) { global $CFG; check_dir_exists("{$CFG->dataroot}/temp", true); check_dir_exists("{$CFG->dataroot}/temp/html", true); check_dir_exists("{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}", true); check_dir_exists("{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}/atachments", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}", true); //export contents wiki_export_html_content($WS); //export attached files $flist = list_directories_and_files("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}"); if ($flist != null) { foreach ($flist as $fil) { $from_file = "{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}/{$fil}"; $to_file = "{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}/atachments/{$fil}"; copy($from_file, $to_file); } } //zip file name $times = time(); $name = $WS->dfwiki->name . '-' . $times . '.zip'; $cleanzipname = clean_filename($name); //List of files and directories $filelist = list_directories_and_files("{$CFG->dataroot}/temp/html"); //Convert them to full paths $files = array(); if ($filelist != null) { foreach ($filelist as $file) { $files[] = "{$CFG->dataroot}/temp/html/{$file}"; } } check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/exportedhtml", true); $destination = "{$CFG->dataroot}/{$WS->dfwiki->course}/exportedhtml/{$cleanzipname}"; $status = zip_files($files, $destination); //delete the folder created in temp $filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/html"); if ($filelist2 != null) { $del = delete_dir_contents("{$CFG->dataroot}/temp/html"); } //show it all to be albe to download the file $prop = null; $prop->class = "textcenter"; wiki_div_start($prop); wiki_size_text(get_string("exporthtmlcorrectly", "wiki"), 2); wiki_div_end(); $prop = null; $prop->border = "0"; $prop->class = "boxaligncenter"; $prop->classtd = "nwikileftnow"; wiki_table_start($prop); $wdir = '/exportedhtml'; $fileurl = "{$wdir}/{$cleanzipname}"; $ffurl = "/file.php?file=/{$WS->cm->course}{$fileurl}"; $icon = mimeinfo("icon", $cleanzipname); link_to_popup_window($ffurl, "display", "<img src=\"{$CFG->pixpath}/f/{$icon}\" height=\"16\" width=\"16\" alt=\"File\" />", 480, 640); echo "\n" . ' '; link_to_popup_window($ffurl, "display", htmlspecialchars($cleanzipname), 480, 640); $prop = null; $prop->class = "nwikileftnow"; wiki_change_row($prop); echo ' '; wiki_table_end(); $prop = null; $prop->border = "0"; $prop->class = "boxaligncenter"; $prop->classtd = "nwikileftnow"; wiki_table_start($prop); $prop = null; $prop->id = "form"; $prop->method = "post"; $prop->action = '../xml/index.php?id=' . $WS->dfwiki->course . '&wdir=/exportedhtml'; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "dfform[viewexported]"; $prop->value = get_string('viewexported', 'wiki'); wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); wiki_change_column(); print_continue("{$CFG->wwwroot}/mod/wiki/view.php?id={$WS->cm->id}"); wiki_table_end(); }
// Course Module ID if (!($WS->cm = get_record("course_modules", "id", $id))) { error("Course Module ID was incorrect"); } if (!($course = get_record("course", "id", $WS->cm->course))) { error("Course is misconfigured"); } if (!($WS->dfwiki = get_record("wiki", "id", $WS->cm->instance))) { error("Course module is incorrect"); } require_login($course->id); $context = get_context_instance(CONTEXT_MODULE, $WS->cm->id); require_capability('mod/wiki:adminactions', $context); global $COURSE; if ($COURSE->category) { $navigation = "<a href=\"../../../course/view.php?id={$COURSE->id}\">{$COURSE->shortname}</a> ->"; } $strdfwikis = get_string("modulenameplural", "wiki"); // update translation file name (nadavkav patch) $strdfwiki = get_string("modulename", "wiki"); // update translation file name (nadavkav patch) print_header("{$COURSE->shortname}: {$WS->dfwiki->name}", "{$COURSE->fullname}", "{$navigation} <a href=../index.php?id={$COURSE->id}>{$strdfwikis}</a> -> {$WS->dfwiki->name}"); print_heading(get_string("exportinghtml", "wiki")); // update translation file name (nadavkav patch) $prop = null; $prop->class = "box generalbox generalboxcontent boxaligncenter"; wiki_div_start($prop); wiki_export_html($WS); wiki_div_end(); //Print footer print_footer();
function displaydir($wdir) { // $wdir == / or /a or /a/b/c/d etc global $basedir; global $id; global $USER, $CFG; global $choose; $fullpath = $basedir . $wdir; check_dir_exists($fullpath, true); $directory = opendir($fullpath); // Find all files while (false !== ($file = readdir($directory))) { if ($file == "." || $file == "..") { continue; } if (is_dir($fullpath . "/" . $file)) { $dirlist[] = $file; } else { $filelist[] = $file; } } closedir($directory); $strname = get_string("name"); $strsize = get_string("size"); $strmodified = get_string("modified"); $straction = get_string("action"); $strmakeafolder = get_string("makeafolder"); $struploadafile = get_string("uploadafile"); $strwithchosenfiles = get_string("withchosenfiles"); $strmovetoanotherfolder = get_string("movetoanotherfolder"); $strmovefilestohere = get_string("movefilestohere"); $strdeletecompletely = get_string("deletecompletely"); $strcreateziparchive = get_string("createziparchive"); $strrename = get_string("rename"); $stredit = get_string("edit"); $strunzip = get_string("unzip"); $strlist = get_string("list"); $strrestore = get_string("restore"); $strchoose = get_string("choose"); $prop = null; $prop->action = "index.php"; $prop->method = "post"; $prop->id = "dirform"; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "choose"; $prop->value = $choose; wiki_input_hidden($prop); wiki_hr(); $prop = null; $prop->border = "0"; $prop->spacing = "2"; $prop->padding = "2"; $prop->width = "640"; $prop->class = "files"; $prop->header = true; $prop->styleth = "width:5%"; wiki_table_start($prop); $prop = null; $prop->header = true; $prop->align = "left"; $prop->class = "header name"; wiki_change_column($prop); echo $strname; $prop = null; $prop->header = true; $prop->align = "right"; $prop->class = "header size"; wiki_change_column($prop); echo $strsize; $prop = null; $prop->header = true; $prop->align = "right"; $prop->class = "header date"; wiki_change_column($prop); echo $strmodified; $prop = null; $prop->header = true; $prop->align = "right"; $prop->class = "header commands"; wiki_change_column($prop); echo $straction; if ($wdir == "/") { $wdir = ""; } if (!empty($wdir)) { $dirlist[] = '..'; } $count = 0; $header = true; if (!empty($dirlist)) { asort($dirlist); foreach ($dirlist as $dir) { if ($header) { $header = false; $prop = null; $prop->header = true; } else { $prop = null; } if ($dir == '..') { $fileurl = rawurlencode(dirname($wdir)); $prop->style = "white-space: nowrap;"; $prop->align = "center"; $prop->classtr = "folder"; wiki_change_row($prop); echo ' '; $prop = null; $prop->class = 'name'; $prop->align = 'left'; $prop->style = "white-space: nowrap;"; wiki_change_column($prop); $prop = null; $prop->src = $CFG->pixpath . '/f/parent.gif'; $prop->height = "16"; $prop->width = "16"; $prop->alt = get_string('parentfolder'); $out = wiki_img($prop, true); $prop = null; $prop->href = 'index.php?id=' . $id . '&wdir=' . $fileurl; wiki_a($out, $prop); $prop = null; $prop->href = 'index.php?id=' . $id . '&wdir=' . $fileurl; wiki_a(get_string('parentfolder'), $prop); wiki_change_column(); echo ' '; wiki_change_column(); echo ' '; wiki_change_column(); echo ' '; } else { $count++; $filename = $fullpath . "/" . $dir; $fileurl = rawurlencode($wdir . "/" . $dir); $filesafe = rawurlencode($dir); $filesize = display_size(get_directory_size("{$fullpath}/{$dir}")); $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); $prop->align = "center"; $prop->style = "white-space: nowrap;"; $prop->class = "checkbox"; $prop->classtr = "folder"; wiki_change_row($prop); $prop = null; $prop->name = 'file' . $count; $prop->value = $fileurl; wiki_input_checkbox($prop); $prop = null; $prop->class = 'name'; $prop->align = "left"; $prop->style = "white-space: nowrap;"; wiki_change_column($prop); $prop = null; $prop->src = $CFG->pixpath . '/f/folder.gif'; $prop->height = "16"; $prop->width = "16"; $prop->alt = "Folder"; $out = wiki_img($prop, true); $prop = null; $prop->href = 'index.php?id=' . $id . '&wdir=' . $fileurl . '&choose=' . $choose; wiki_a($out, $prop); $prop = null; $prop->href = 'index.php?id=' . $id . '&wdir=' . $fileurl . '&choose=' . $choose; wiki_a(htmlspecialchars($dir), $prop); $prop = null; $prop->class = 'size'; $prop->align = "right"; $prop->style = "white-space: nowrap;"; wiki_change_column($prop); echo $filesize; $prop = null; $prop->class = 'date'; $prop->align = "right"; $prop->style = "white-space: nowrap;"; wiki_change_column($prop); echo $filedate; $prop = null; $prop->class = 'commands'; $prop->align = "right"; $prop->style = "white-space: nowrap;"; wiki_change_column($prop); $prop = null; $prop->href = 'index.php?id=' . $id . '&wdir=' . $wdir . '&file=' . $filesafe . '&action=rename&choose=' . $choose; wiki_a($strrename, $prop); //echo "<a href=\"index.php?id=$id&wdir=$wdir&file=$filesafe&action=rename&choose=$choose\">$strrename</a>"; } } } if (!empty($filelist)) { asort($filelist); foreach ($filelist as $file) { $icon = mimeinfo("icon", $file); $count++; $filename = $fullpath . "/" . $file; $fileurl = "{$wdir}/{$file}"; $filesafe = rawurlencode($file); $fileurlsafe = rawurlencode($fileurl); $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); if (substr($fileurl, 0, 1) == '/') { $selectfile = substr($fileurl, 1); } else { $selectfile = $fileurl; } if ($header) { $header = false; $prop = null; $prop->header = true; } else { $prop = null; } $prop->align = "center"; $prop->style = "white-space: nowrap;"; $prop->class = "checkbox"; $prop->classtr = "file"; wiki_change_row($prop); $prop = null; $prop->name = 'file' . $count; $prop->value = $fileurl; wiki_input_checkbox($prop); $prop = null; $prop->align = "left"; $prop->class = "name nwikileftnow"; wiki_change_column($prop); if ($CFG->slasharguments) { $ffurl = "/file.php/" . $id . $fileurl; } else { $ffurl = "/file.php?file=/" . $id . $fileurl; } link_to_popup_window($ffurl, "display", "<img src=\"{$CFG->pixpath}/f/{$icon}\" height=\"16\" width=\"16\" alt=\"File\" />", 480, 640); echo ' '; link_to_popup_window($ffurl, "display", htmlspecialchars($file), 480, 640); $file_size = filesize($filename); $prop = null; $prop->class = 'size'; $prop->align = "right"; $prop->style = "white-space: nowrap;"; wiki_change_column($prop); echo display_size($file_size); $prop = null; $prop->class = 'date'; $prop->align = "right"; $prop->style = "white-space: nowrap;"; wiki_change_column($prop); echo $filedate; if ($choose) { $edittext = "<b><a onMouseDown=\"return set_value('{$selectfile}')\" href=\"\">{$strchoose}</a></b> "; } else { $edittext = ''; } if ($icon == "text.gif" || $icon == "html.gif") { $edittext .= "<a href=\"index.php?id={$id}&wdir={$wdir}&file={$fileurl}&action=edit&choose={$choose}\">{$stredit}</a>"; } else { if ($icon == "zip.gif") { $edittext .= "<a href=\"index.php?id={$id}&wdir={$wdir}&file={$fileurl}&action=unzip&sesskey={$USER->sesskey}&choose={$choose}\">{$strunzip}</a> "; $edittext .= "<a href=\"index.php?id={$id}&wdir={$wdir}&file={$fileurl}&action=listzip&sesskey={$USER->sesskey}&choose={$choose}\">{$strlist}</a> "; } } $prop = null; $prop->class = 'commands'; $prop->align = "right"; $prop->style = "white-space: nowrap;"; wiki_change_column($prop); echo $edittext; echo "<a href=\"index.php?id={$id}&wdir={$wdir}&file={$filesafe}&action=rename&choose={$choose}\">{$strrename}</a>"; } } if ($header) { $prop = null; $prop->header = true; wiki_table_end($prop); $header = false; } else { wiki_table_end(); } wiki_hr(); if (empty($wdir)) { $wdir = "/"; } $prop = null; $prop->name = "id"; $prop->value = $id; wiki_input_hidden($prop); $prop = null; $prop->name = "choose"; $prop->value = $choose; wiki_input_hidden($prop); $prop = null; $prop->name = "wdir"; $prop->value = $wdir; wiki_input_hidden($prop); $prop = null; $prop->name = "sesskey"; $prop->value = $USER->sesskey; wiki_input_hidden($prop); $options = array("move" => "{$strmovetoanotherfolder}", "delete" => "{$strdeletecompletely}", "zip" => "{$strcreateziparchive}"); if (!empty($count)) { choose_from_menu($options, "action", "", "{$strwithchosenfiles}...", "javascript:document.forms['dirform'].submit()"); } wiki_div_end(); wiki_form_end(); $prop = null; $prop->border = "0"; $prop->spacing = "2"; $prop->padding = "2"; $prop->class = "boxalignright"; $prop->aligntd = "center"; wiki_table_start($prop); if (!empty($USER->fileop) and $USER->fileop == "move" and $USER->filesource != $wdir) { $prop = null; $prop->action = "index.php"; $prop->method = "get"; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "choose"; $prop->value = $choose; wiki_input_hidden($prop); $prop = null; $prop->name = "id"; $prop->value = $id; wiki_input_hidden($prop); $prop = null; $prop->name = "wdir"; $prop->value = $wdir; wiki_input_hidden($prop); $prop = null; $prop->name = "action"; $prop->value = "paste"; wiki_input_hidden($prop); $prop = null; $prop->name = "sesskey"; $prop->value = $USER->sesskey; wiki_input_hidden($prop); $prop = null; $prop->value = $strmovefilestohere; wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); $prop = null; $prop->align = "right"; wiki_change_column($prop); } $prop = null; $prop->action = "index.php"; $prop->method = "get"; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "choose"; $prop->value = $choose; wiki_input_hidden($prop); $prop = null; $prop->name = "id"; $prop->value = $id; wiki_input_hidden($prop); $prop = null; $prop->name = "wdir"; $prop->value = $wdir; wiki_input_hidden($prop); $prop = null; $prop->name = "action"; $prop->value = "mkdir"; wiki_input_hidden($prop); $prop = null; $prop->value = $strmakeafolder; wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); $prop = null; $prop->align = "right"; wiki_change_column($prop); $prop = null; $prop->action = "index.php"; $prop->method = "get"; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "choose"; $prop->value = $choose; wiki_input_hidden($prop); $prop = null; $prop->name = "id"; $prop->value = $id; wiki_input_hidden($prop); $prop = null; $prop->name = "wdir"; $prop->value = $wdir; wiki_input_hidden($prop); $prop = null; $prop->name = "action"; $prop->value = "upload"; wiki_input_hidden($prop); $prop = null; $prop->value = $struploadafile; wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); wiki_table_end(); wiki_hr(); }
/** * Module Blocked Format for Moodle * * @author DFWiki LABS * @author Marc Alier i Forment * @author David Castro, Ferran Recio, Jordi Piguillem, UPC, * and members of DFWikiteam listed at http://morfeo.upc.edu/crom * @version $Id: web.lib.php,v 1.5 2008/05/05 09:10:43 pigui Exp $ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package Activity_Format */ function wiki_header() { global $COURSE, $CFG, $WS; //define block sizes define('BLOCK_L_MIN_WIDTH', 100); define('BLOCK_L_MAX_WIDTH', 210); define('BLOCK_R_MIN_WIDTH', 100); define('BLOCK_R_MAX_WIDTH', 210); $edit = optional_param('edit', NULL, PARAM_ALPHA); //This structure is used to use blocks //Standard blocks: $dfwiki = wiki_param('dfwiki'); //$PAGE = page_create_instance($dfwiki->id); $PAGE = page_create_object('mod-wiki-view', $dfwiki->id); //little patch: if body class is a subtype od mod-wiki, class is mod-wiki if (substr($PAGE->body_class, 0, 8) == 'mod-wiki') { $PAGE->body_class = 'mod-wiki'; } wiki_page_info('PAGE', $PAGE); //Needed function to make blocks work properly $pageblocks = blocks_setup($PAGE); wiki_page_info('pageblocks', $pageblocks); //Function that checks the edit permissions of the wiki wiki_check_edition($PAGE, $edit); //setup the module /// Print the page header if ($COURSE->category) { $navigation = "<a href=\"../../course/view.php?id={$COURSE->id}\">{$COURSE->shortname}</a> ->"; } //get names in both singular and plural $strdfwikis = get_string("modulenameplural", 'wiki'); $strdfwiki = get_string("modulename", 'wiki'); $PAGE->print_header($COURSE->shortname . ': %fullname%'); /// Print the main part of the page $prop = new stdClass(); $prop->class = "course-content"; wiki_div_start($prop); // course wrapper start //to work out the default widths need to check all blocks $preferred_width_left = optional_param('preferred_width_left', blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), PARAM_INT); //preferred_width_left sizes //should be between BLOCK_x_MAX_WIDTH and BLOCK_x_MIN_WIDTH. $preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH); $preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH); $cm = wiki_param('cm'); $context = get_context_instance(CONTEXT_MODULE, $cm->id); //shows a specific topic if (has_capability('mod/wiki:editawiki', $context) and isset($marker) and confirm_sesskey()) { $COURSE->marker = $marker; if (!set_field("course", "marker", $marker, "id", $COURSE->id)) { error("Could not mark that topic for this course"); } } //load strings $streditsummary = get_string('editsummary'); $stradd = get_string('add'); $stractivities = get_string('activities'); $strshowalltopics = get_string('showalltopics'); $strtopic = get_string('topic'); $strgroups = get_string('groups'); $strgroupmy = get_string('groupmy'); //checks if the user is editing $editing = $PAGE->user_is_editing(); //load editing strings if ($editing) { $strstudents = moodle_strtolower($COURSE->students); $strtopichide = get_string('topichide', '', $strstudents); $strtopicshow = get_string('topicshow', '', $strstudents); $strmarkthistopic = get_string('markthistopic'); $strmarkedthistopic = get_string('markedthistopic'); $strmoveup = get_string('moveup'); $strmovedown = get_string('movedown'); } //--------------------------------------------- INTERFACES BEGINS HERE /// Layout the whole page as three big columns. /// The left column ... //checks if there are blocks to place on the left-hand side if (!empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing)) { $prop = new stdClass(); $prop->id = "layout-table"; $prop->idtd = "left-column"; $prop->classtd = "blockcourse"; wiki_table_start($prop); $prop = new stdClass(); $prop->width = $preferred_width_left . 'px'; wiki_table_start($prop); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); wiki_table_end(); $prop = new stdClass(); $prop->id = "middle-column"; wiki_change_column($prop); } else { $prop = new stdClass(); $prop->id = "layout-table"; $prop->idtd = "middle-column"; wiki_table_start($prop); } /// Start main column //central block title //print_heading_block(get_string('wiki','wiki'), 'outline'); echo "<br />"; print_box($dfwiki->intro, "generalbox", "intro"); //begin the content table $prop = new stdClass(); $prop->class = "topics"; $prop->width = "100%"; wiki_table_start($prop); //print_tabs //TODO: clean it when all functionalities are parts global $CFG; //this function is the responsable of printing the content of the module. $dfcontent = wiki_param('dfcontent'); $dfcontentf = wiki_param('dfcontentf'); if (isset($dfcontent) && $dfcontent >= 0 && $dfcontent < count($dfcontentf)) { //we won't print tabs cause is an special situation (this comprobation will be removed when all ead are passed to parts) } else { wiki_print_tabs(); } }
$prop->action = 'dfwikitonewwiki.php?id=' . $cm->id; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "sure"; $prop->value = get_string('yes'); wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); wiki_change_column(); $prop = null; $prop->id = "form2"; $prop->method = "post"; $prop->action = 'view.php?id=' . $cm->id; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "cancel"; $prop->value = get_string('no'); wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); wiki_table_end(); print_simple_box_end(); } /// Finish the page print_footer($course); //This function converts all dfwikis in DB to new wikis function wiki_convert_all_dfwikis($course) { global $CFG;
function wiki_print_menu_teachers($listteachers, $cm) { //this function prints the list of theachers in the wiki's student if (empty($listteachers)) { return; } wiki_br(2); $prop = null; $prop->border = "0"; $prop->class = "boxalignright"; $prop->classtd = "nwikileftnow"; wiki_table_start($prop); print_string('anotherteacher', 'wiki'); wiki_change_column(); $prop = null; $prop->id = "selectteacher"; $prop->method = "post"; $prop->action = 'view.php?id=' . $cm->id; wiki_form_start($prop); wiki_div_start(); $opt = null; foreach ($listteachers as $lteacher) { $prop = null; $prop->value = $lteacher->id; $opt .= wiki_option($lteacher->lastname . ', ' . $lteacher->firstname, $prop, true); } $prop = null; $prop->name = "dfformselectteacher"; wiki_select($opt, $prop); $prop = null; $prop->value = get_string("continue"); wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); $prop = null; $prop->class = "nwikileftnow"; wiki_change_row($prop); echo " "; wiki_table_end(); }
/** Prints the code that sets the wiki page grade * evaluation box. * * @param Object $WS WikiStorage */ function wiki_grade_print_page_evaluation_box(&$WS) { global $USER; // evaluation box available only in view tab if ($WS->pageaction != 'view') { return; } if (!wiki_grade_got_permission($WS)) { return; } $wiki = get_record('wiki', 'id', $WS->cm->instance); if (!$wiki) { return; } $scale = get_record('scale', 'id', (int) $wiki->notetype); if (isset($scale) && $scale != false) { print_box_start(); $prop = null; $prop->id = "form_grades"; $prop->method = "post"; $prop->action = 'view.php?id=' . $WS->linkid . '&page=view/' . stripslashes_safe($WS->page) . '&ver=' . $WS->ver . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id; wiki_form_start($prop); $prop = null; $prop->class = "evaluationbox"; wiki_div_start($prop); $prop = null; //$prop->spacing = "40"; $prop->padding = "2"; //$prop->valigntd = "top"; $prop->aligntd = "right"; //$prop->border = 1; wiki_table_start($prop); echo '<b>' . get_string('grade') . '</b>: '; wiki_change_column(); $scale = wiki_grade_scale_box($scale, true); $eval_instance = wiki_grade_evaluation_exist($WS->page, $WS->dfwiki->id, $WS->groupmember->groupid, $WS->member->id, $USER->id); if ($scale) { echo ' '; $prop = null; $prop->name = 'grade_post_evaluation'; $prop->value = get_string('set', 'wiki'); wiki_input_submit($prop); echo ' '; $context = get_context_instance(CONTEXT_MODULE, $WS->cm->id); if ((has_capability('mod/wiki:authorreview', $context) || has_capability('mod/wiki:mainreview', $context)) && $eval_instance != false) { echo '<i>(' . get_string('eval_current', 'wiki') . ' "' . trim($scale[$eval_instance->wikigrade - 1]) . '")</i>'; } } else { echo 'grades.lib.php: there is no wikigrade yet.'; } wiki_change_row(); echo '<b>' . get_string('eval_feedback', 'wiki') . '</b>: '; wiki_change_column(); unset($prop); $prop->size = 60; $prop->value = ''; if ($eval_instance) { $prop->value = $eval_instance->comment; } $prop->name = "grade_commentary"; wiki_input_text($prop); $prop->align = 'right'; wiki_change_row($prop); wiki_change_column(); $prop = null; $prop->name = 'grade_appendtodiscussion'; wiki_input_checkbox($prop); $a->link = 'view.php?id=' . $WS->cm->id . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&page=discussion/discussion:' . urlencode($WS->page); echo get_string('eval_append_to_disc', 'wiki', $a); $prop->align = 'right'; wiki_change_row($prop); wiki_change_column(); $prop = null; $prop->name = 'grade_anonymous'; wiki_input_checkbox($prop); echo get_string('eval_anonymous', 'wiki'); wiki_table_end(); wiki_div_end(); wiki_form_end(); print_box_end(); } }
function wiki_export_content(&$WS, $folder = 'exportedfiles') { global $CFG, $contents; $export = optional_param('dfformexport', NULL, PARAM_ALPHA); $exportall = optional_param('dfformexportall', NULL, PARAM_ALPHA); //check if the form was filled in if (isset($export) || isset($exportall)) { //make sure the file doesn't exist $dfformname = optional_param('dfformname', NULL, PARAM_FILE); $currentname = clean_filename($dfformname); $cleandfwiki = clean_filename($WS->dfwiki->name); if (file_exists($CFG->dataroot . "/" . $WS->dfwiki->course . "/" . $folder . "/" . $cleandfwiki . $WS->cm->id . "/" . $currentname)) { $err = $currentname . ' already exists!'; error($err); } else { //export to xml wiki_export_content_XML($WS); $prop = null; $prop->class = 'textcenter'; $info = wiki_size_text(get_string("exportcorrectly", 'wiki'), 2, '', true); wiki_div($info, $prop); //make the zip $files = array(); //copy files inside temp where is the xml check_dir_exists("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}", true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/wiki{$WS->cm->id}", true); $flist = list_directories_and_files("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/wiki{$WS->cm->id}"); if ($flist != null) { foreach ($flist as $fil) { $from_file = "{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/wiki{$WS->cm->id}/{$fil}"; $to_file = "{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}/{$fil}"; copy($from_file, $to_file); } } //continue compressing $filelist = list_directories_and_files("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}"); foreach ($filelist as $file) { $files[] = "{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}/{$file}"; } check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/" . $folder, true); check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/" . $folder . "/{$cleandfwiki}{$WS->cm->id}", true); $destination = "{$CFG->dataroot}/{$WS->dfwiki->course}/" . $folder . "/{$cleandfwiki}{$WS->cm->id}/{$currentname}"; $status = zip_files($files, $destination); //delete folder inside temp that we've created $filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}"); foreach ($filelist2 as $file2) { unlink("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}/{$file2}"); } rmdir("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}"); $prop = null; $prop->border = '0'; $prop->class = 'boxaligncenter'; $prop->classtd = 'nwikileftnow'; wiki_table_start($prop); $wdir = '/' . $folder . '/' . $cleandfwiki . $WS->cm->id; $fileurl = "{$wdir}/{$currentname}"; $ffurl = "/file.php?file=/{$WS->cm->course}{$fileurl}"; $icon = mimeinfo("icon", $currentname); $prop = null; $prop->src = "{$CFG->pixpath}/f/{$icon}"; $prop->height = '16'; $prop->width = '16'; $prop->alt = 'File'; $im = wiki_img($prop, true); link_to_popup_window($ffurl, "display", $im, 480, 640); echo ' '; link_to_popup_window($ffurl, "display", htmlspecialchars($currentname), 480, 640); $prop = null; $prop->class = 'nwikileftnow'; wiki_change_row($prop); wiki_table_end(); $prop = null; $prop->border = '0'; $prop->class = 'boxaligncenter'; $prop->classtd = 'nwikileftnow'; wiki_table_start($prop); $prop = null; $prop->action = 'index.php?id=' . $WS->dfwiki->course . '&wdir=/"' . $folder; $prop->method = 'post'; $prop->id = 'form'; wiki_form_start($prop); $prop = null; $prop->name = 'dfformviewexported'; $prop->value = get_string('viewexported', 'wiki'); $input = wiki_input_submit($prop, true); wiki_div($input); wiki_form_end(); wiki_change_column(); print_continue("{$CFG->wwwroot}/mod/wiki/view.php?id={$WS->cm->id}"); wiki_table_end(); } } else { //create the form to export //first of all treat the form that we've sended about the pages to export if (!($frm = data_submitted())) { $contents = null; $contentsall = get_records_sql('SELECT DISTINCT pagename,dfwiki FROM ' . $CFG->prefix . 'wiki_pages WHERE dfwiki=' . $WS->dfwiki->id); if ($contentsall != null) { foreach ($contentsall as $call) { $contents[] = $call->pagename; } } $WS->nocontents = null; } else { if (!empty($frm->addall)) { $contents = null; $contentsall = get_records_sql('SELECT DISTINCT pagename,dfwiki FROM ' . $CFG->prefix . 'wiki_pages WHERE dfwiki=' . $WS->dfwiki->id); if ($contentsall != null) { foreach ($contentsall as $call) { $contents[] = $call->pagename; } } $WS->nocontents = null; } else { if (!empty($frm->removeall)) { $WS->nocontents = null; $nocontentsall = get_records_sql('SELECT DISTINCT pagename,dfwiki FROM ' . $CFG->prefix . 'wiki_pages WHERE dfwiki=' . $WS->dfwiki->id); if ($nocontentsall != null) { foreach ($nocontentsall as $nocall) { $WS->nocontents[] = $nocall->pagename; } } $contents = null; } else { $contents = null; $WS->nocontents = null; for ($i = 0; $i < $frm->sizecontents; $i++) { $contents[] = $frm->contents[$i]; } for ($j = 0; $j < $frm->sizenocontents; $j++) { $WS->nocontents[] = $frm->nocontents[$j]; } if (!empty($frm->add) and !empty($frm->addselect)) { foreach ($frm->addselect as $addpage) { $contents[] = $addpage; wiki_remove_nocontents($addpage, $WS); } } else { if (!empty($frm->remove) and !empty($frm->removeselect)) { foreach ($frm->removeselect as $removepage) { $WS->nocontents[] = $removepage; wiki_remove_contents($removepage); } } } } } } $prop = null; $prop->class = 'textcenter'; $info = wiki_size_text(get_string("selectpages", 'wiki'), 2, '', true); wiki_div($info, $prop); include 'pages.html'; wiki_div_end(); $prop = null; $prop->class = 'box generalbox generalboxcontent boxaligncenter textcenter'; wiki_div_start($prop); $prop = null; $prop->action = 'exportxml.php?id=' . $WS->cm->id . '&pageaction=exportxml'; $prop->method = 'post'; $prop->id = 'form'; wiki_form_start($prop); $prop = null; $prop->border = '0'; $prop->class = 'boxaligncenter'; $prop->classtd = 'textcenter'; wiki_table_start($prop); $sizecon = count($WS->nocontents); for ($i = 0; $i < $sizecon; $i++) { $prop = null; $prop->name = 'dfform[' . $WS->nocontents[$i] . ']'; $prop->value = $WS->nocontents[$i]; wiki_input_hidden($prop); } $prop = null; $prop->class = 'textcenter'; $info = wiki_size_text(get_string("otheroptions", 'wiki'), 2, '', true); wiki_div($info, $prop); $cleandfwiki = clean_filename($WS->dfwiki->name); $times = time(); $prop = null; $prop->class = 'nwikileftnow'; wiki_change_row($prop); $prop = null; $prop->name = 'dfforminfo'; $prop->value = '1'; wiki_input_checkbox($prop); print_string('exportinfo', 'wiki'); $prop = null; $prop->class = 'nwikileftnow'; wiki_change_row($prop); $prop = null; $prop->name = 'dfformblocks'; $prop->value = '1'; wiki_input_checkbox($prop); print_string('blocks', 'wiki'); $prop = null; $prop->class = 'nwikicenternow'; wiki_change_row($prop); $info = get_string('saveas', 'wiki'); $prop = null; $prop->name = 'dfformname'; $prop->value = $cleandfwiki . '-' . $times . '.zip'; $info .= wiki_input_text($prop, true); wiki_paragraph($info, ''); $prop = null; $prop->class = 'nwikicenternow'; wiki_change_row($prop); $prop = null; $prop->name = 'dfformexport'; $prop->value = get_string('export', 'wiki'); wiki_input_submit($prop); $prop = null; $prop->name = 'dfformexportall'; $prop->value = get_string('exportall', 'wiki'); wiki_input_submit($prop); $prop = null; $prop->name = 'dfformcancel'; $prop->value = get_string('cancel'); wiki_input_submit($prop); wiki_table_end(); wiki_form_end(); } }
function wiki_hist_restore(&$WS) { if ($WS->dfperms['restore']) { $prop = null; $prop->id = "form"; $prop->method = "post"; $prop->action = 'view.php?id=' . $WS->linkid . '&page=view/' . urlencode($WS->pageolddata->pagename) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id; wiki_form_start($prop); wiki_div_start(); $prop = null; $prop->name = "dfformversion"; $prop->value = $WS->pagedata->version; wiki_input_hidden($prop); $prop = null; $prop->name = "dfformcreated"; $prop->value = $WS->pageolddata->created; wiki_input_hidden($prop); $prop = null; $prop->name = "dfformeditable"; $prop->value = $WS->pageolddata->editable; wiki_input_hidden($prop); $prop = null; $prop->name = "dfformeditor"; $prop->value = $WS->pageolddata->editor; wiki_input_hidden($prop); $prop = null; $prop->name = "dfformaction"; $prop->value = "edit"; wiki_input_hidden($prop); $prop = null; $prop->name = "dfformcontent"; $prop->value = htmlspecialchars($WS->pageolddata->content); wiki_input_hidden($prop); $prop = null; $prop->name = "dfformsave"; $prop->value = get_string('restore', 'wiki'); wiki_input_submit($prop); wiki_div_end(); wiki_form_end(); } }