MDL-22112, push wiki 2.0 into head

This commit is contained in:
Dongsheng Cai
2010-05-02 11:28:11 +00:00
parent b65e022034
commit 00710f4cc1
173 changed files with 12180 additions and 9271 deletions
+5
View File
@@ -0,0 +1,5 @@
Wiki 2.0
by Jordi Piguillem and Ludo (Marc Alier) 2008 - Universitat Politecnica de
Catalunya
http://www.upc.edu - http://dfwikilabs.org
-22
View File
@@ -1,22 +0,0 @@
ToDo
Mike:
- Group Handling (Mike)
> deal with changing group mode on active wikis
> handle group mode for teacher wikis
- Rating
- Commenting
- Grading
Michael:
- Upload: There is an error when having a bin html-wiki: File does not show up
- Log when up- or download
- Notify when page changes
Unassigned or not ready:
- Wiki HTML: http://moodle.org/mod/forum/discuss.php?d=8920
- http://moodle.org/mod/forum/discuss.php?d=7768#36954
- Image Thumbnails http://moodle.org/mod/forum/discuss.php?d=8351
ewiki Preparation:
- Current Version: 1.01d
-366
View File
@@ -1,366 +0,0 @@
<?PHP
/// Extended by Michael Schneider
require_once("../../config.php");
require_once("lib.php");
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // wiki ID
$page = optional_param('page', false, PARAM_CLEAN); // Pagename
$confirm = optional_param('confirm', '', PARAM_RAW);
$action = optional_param('action', '', PARAM_ACTION); // Admin Action
$userid = optional_param('userid', 0, PARAM_INT); // User wiki.
$groupid = optional_param('groupid', 0, PARAM_INT); // Group wiki.
if ($id) {
if (! $cm = get_coursemodule_from_id('wiki', $id)) {
print_error('invalidcoursemodule');
}
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
print_error('coursemisconf');
}
if (! $wiki = $DB->get_record("wiki", array("id"=>$cm->instance))) {
print_error('invalidcoursemodule');
}
} else {
if (! $wiki = $DB->get_record("wiki", array("id"=>$a))) {
print_error('coursemisconf');
}
if (! $course = $DB->get_record("course", array("id"=>$wiki->course))) {
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) {
print_error('invalidcoursemodule');
}
}
$url = new moodle_url('/mod/wiki/admin.php', array('id'=>$cm->id));
if ($page !== false) {
$url->param('page', $page);
}
if ($confirm !== '') {
$url->param('confirm', $confirm);
}
if ($action !== '') {
$url->param('action', $action);
}
if ($userid !== 0) {
$url->param('userid', $userid);
}
if ($groupid !== 0) {
$url->param('groupid', $groupid);
}
$PAGE->set_url($url);
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:manage', $context);
/// Build the ewsiki script constant
$ewbase = 'view.php?id='.$id;
if (isset($userid) && $userid!=0) $ewbase .= '&amp;userid='.$userid;
if (isset($groupid) && $groupid!=0) $ewbase .= '&amp;groupid='.$groupid;
$ewscript = $ewbase.'&amp;page=';
define("EWIKI_SCRIPT", $ewscript);
if($wiki->ewikiacceptbinary) {
define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
}
/// Add the course module 'groupmode' to the wiki object, for easy access.
$wiki->groupmode = $cm->groupmode;
/// Is an Action given ?
if(!$action) {
print_error('noadministrationaction','wiki');
}
/// Correct Action ?
if(!in_array($action, array("setpageflags", "removepages", "strippages", "checklinks", "revertpages"))) {
print_error('unknowaction');
}
/// May the User administrate it ?
if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false || wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course) === false) {
print_error('notadministratewiki', 'wiki');
}
$canedit = wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course);
# Check for dangerous events (hacking) !
if(in_array($action,array("removepages","strippages","revertpages"))) {
if(!($wiki->wtype=="student" || ($wiki->wtype=="group" and $canedit) || wiki_is_teacher($wiki))) {
add_to_log($course->id, "wiki", "hack", "", $wiki->name.": Tried to trick admin.php with action=$action.");
print_error('hackdetected');
}
}
# Database and Binary Handler
include_once($CFG->dirroot."/mod/wiki/ewikimoodlelib.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php");
/// The wiki_entry->pagename is set to the specified value of the wiki,
/// or the default value in the 'lang' file if the specified value was empty.
define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
# The mighty Wiki itself
include_once($CFG->dirroot."/mod/wiki/ewiki/ewiki.php");
$strwikis = get_string("modulenameplural", "wiki");
$strwiki = get_string("modulename", "wiki");
/// Validate Form
if ($form = data_submitted()) {
switch($action) {
case "revertpages":
if(!$form->deleteversions || 0 > $form->deleteversions || $form->deleteversions > 1000) {
$focus="form.deleteversions";
$err->deleteversions=get_string("deleteversionserror","wiki");
}
if(!$form->changesfield || 0 > $form->changesfield || $form->changesfield > 100000) {
$focus="form.changesfield";
$err->changesfield=get_string("changesfielderror","wiki");
}
if($form->authorfieldpattern=="") {
$focus="form.authorfieldpattern";
$err->authorfieldpattern=get_string("authorfieldpatternerror","wiki");
}
break;
default: break;
}
}
$PAGE->navbar->add(get_string("administration","wiki"));
$PAGE->set_title($wiki_entry->pagename);
$PAGE->set_focuscontrol($focus);
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'wiki'));
echo $OUTPUT->header();
////////////////////////////////////////////////////////////
/// Check if the Form has been submitted and display confirmation
////////////////////////////////////////////////////////////
if ($form = data_submitted()) {
/// Moodle Log
/// Get additional info
$addloginfo="";
switch($action) {
case "removepages":
$addloginfo=@join(", ", $form->pagestodelete);
break;
case "strippages":
$addloginfo=@join(", ", $form->pagestostrip);
break;
case "checklinks":
$addloginfo=$form->pagetocheck;
break;
case "setpageflags":
// No additional info
break;
case "revertpages":
// No additional info
break;
}
add_to_log($course->id, "wiki", $action, "admin.php?action=$action&amp;userid=$userid&amp;groupid=$groupid&amp;id=$id", $wiki->name.($addloginfo?": ".$addloginfo:""));
$link="admin.php?action=$action".($userid?"&amp;userid=".$userid:"").($groupid?"&amp;groupid=".$groupid:"")."&amp;id=$id&amp;page=$page";
switch($action) {
case "removepages":
if($form->proceed) {
if(!$confirm && $form->pagestodelete) {
echo $OUTPUT->confirm(get_string("removepagecheck", "wiki")."<br />".join(", ", $form->pagestodelete),
$link."&confirm=".urlencode(join(" ",$form->pagestodelete)), $link);
echo $OUTPUT->footer();
exit;
}
}
break;
case "strippages":
if($form->proceed) {
if(!$confirm && $form->pagestostrip) {
$err=array();
$strippages=wiki_admin_strip_versions($form->pagestostrip,$form->version, $err);
$confirm="";
foreach($strippages as $cnfid => $cnfver) {
$confirm.="&confirm[$cnfid]=".urlencode(join(" ",$cnfver));
}
if(count($err)==0) {
$pagestostrip=array();
foreach($form->pagestostrip as $pagetostrip) {
$pagestostrip[]=htmlspecialchars(urldecode($pagetostrip));
}
echo $OUTPUT->confirm(get_string("strippagecheck", "wiki")."<br />".join(", ", $pagestostrip), $link.$confirm, $link);
echo $OUTPUT->footer();
exit;
}
}
}
break;
case "checklinks":
if($form->proceed) {
if(!$confirm && $form->pagetocheck) {
$confirm="&amp;confirm=".$form->pagetocheck;
echo $OUTPUT->confirm(get_string("checklinkscheck", "wiki").$form->pagetocheck, $link.$confirm, $link);
echo $OUTPUT->footer();
exit;
}
}
break;
case "setpageflags":
// pageflagstatus is used in setpageflags.html
$pageflagstatus=wiki_admin_setpageflags($form->flags);
break;
case "revertpages":
if(!$err) {
if(!$confirm) {
$confirm="&confirm[changesfield]=".urlencode($form->changesfield).
"&confirm[authorfieldpattern]=".urlencode($form->authorfieldpattern).
"&confirm[howtooperate]=".urlencode($form->howtooperate).
"&confirm[deleteversions]=".urlencode($form->deleteversions);
$revertedpages=wiki_admin_revert("", $form->authorfieldpattern, $form->changesfield, $form->howtooperate, $form->deleteversions);
if($revertedpages) {
echo $OUTPUT->confirm(get_string("revertpagescheck", "wiki")."<br />".$revertedpages, $link.$confirm, $link);
echo $OUTPUT->footer();
exit;
} else {
$err->remark=get_string("nochangestorevert","wiki");
}
}
}
break;
default: print_error('unknowaction');
break;
}
}
/// Actions which need a confirmation. If confirmed, do the action
$redirect="view.php?".($groupid?"&amp;groupid=".$groupid:"").($userid?"&amp;userid=".$userid:"")."&amp;id=$id&amp;page=$page";
if($confirm && !$err) {
switch($action) {
case "removepages":
$ret=wiki_admin_remove(split(" ",$confirm), $course, $wiki, $userid, $groupid);
if(!$ret) {
redirect($redirect, get_string("pagesremoved","wiki"), 1);
} else {
print_error('invalidaction');
}
exit;
case "strippages":
$strippages=array();
foreach($confirm as $pageid => $versions) {
$strippages[$pageid]=split(" ",$versions);
}
$ret=wiki_admin_strip($strippages);
if(!$ret) {
redirect($redirect, get_string("pagesstripped","wiki"), 1);
} else {
print_error('invalidaction');
}
exit;
case "checklinks":
$ret=wiki_admin_checklinks($confirm);
redirect($redirect, get_string("linkschecked","wiki")."<br />".$ret, 5);
exit;
case "revertpages":
$revertedpages=wiki_admin_revert(1, $confirm["authorfieldpattern"], $confirm["changesfield"], $confirm["howtooperate"], $confirm["deleteversions"]);
redirect($redirect, get_string("pagesreverted","wiki"), 1);
exit;
case "setpageflags":
# No confirmation needed
break;
default: print_error('unknowaction');
}
}
/// The top row contains links to other wikis, if applicable.
if ($wiki_list = wiki_get_other_wikis($wiki, $USER, $course, $wiki_entry->id)) {
if (isset($wiki_list['selected'])) {
$selected = $wiki_list['selected'];
unset($wiki_list['selected']);
}
echo '<tr><td colspan="2">';
echo '<form id="otherwikis" action="'.$CFG->wwwroot.'/mod/wiki/admin.php">';
echo '<fieldset class="invisiblefieldset">';
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>';
echo '<td class="sideblockheading">&nbsp;'
.$WIKI_TYPES[$wiki->wtype].' '
.get_string('modulename', 'wiki').' for '
.wiki_get_owner($wiki_entry).':</td>';
echo '<td class="sideblockheading" align="right">'
.get_string('otherwikis', 'wiki').':&nbsp;&nbsp;';
$script = 'self.location=getElementById(\'otherwikis\').wikiselect.options[getElementById(\'otherwikis\').wikiselect.selectedIndex].value';
/// Add Admin-Action
reset($wiki_list);
$wiki_admin_list=array();
while(list($key,$val)=each($wiki_list)) {
$wiki_admin_list[$key."&amp;action=$action"]=$val;
}
$aid = $OUTPUT->add_action_handler(new component_action('change', 'go_to_wiki'));
$attributes = array('id'=>$aid);
echo html_writer::select($wiki_admin_list, 'wikiselect', $selected, array(''=>'choose'), $attributes);
echo '</td>';
echo '</tr></table>';
echo '</fieldset></form>';
echo '</td>';
echo '</tr>';
}
if ($wiki_entry) {
/// Page Actions
echo '<table border="0" width="100%">';
echo '<tr>';
/* echo '<tr><td align="center">';
* $specialpages=array("SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
* wiki_print_page_actions($cm->id, $specialpages, $ewiki_id, $ewiki_action, $wiki->ewikiacceptbinary, $canedit);
* echo '</td>';*/
/// Searchform
echo '<td align="center">';
wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
echo '</td>';
/// Internal Wikilinks
/// TODO: DOES NOT WORK !!!!
echo '<td align="center">';
wiki_print_wikilinks_block($cm->id, $wiki->ewikiacceptbinary);
echo '</td>';
/// Administrative Links
echo '<td align="center">';
wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $page, $wiki->htmlmode!=2, $course);
echo '</td>';
/** if($wiki->htmlmode!=2) {
* echo '<td align="center">';
* helpbutton('formattingrules', get_string('formattingrules', 'wiki'), 'wiki');
* echo get_string("formattingrules","wiki");
* echo '</td>';
* }*/
echo '</tr></table>';
}
// The wiki Contents
echo $OUTPUT->box_start();
// Do the Action
# "setpageflags", "removepages", "strippages", "checklinks", "revertpages"
echo $OUTPUT->heading_with_help(get_string($action,"wiki"), $action, 'wiki');
include $action.".html";
echo $OUTPUT->box_end();
/// Finish the page
echo $OUTPUT->footer();
exit;
+14 -241
View File
@@ -1,243 +1,16 @@
<?php
//This php script contains all the stuff to backup/restore
//wiki mods
//This is the "graphical" structure of the wiki mod:
//
// wiki
// (CL,pk->id)
//
// wiki_entries
// (pk->id, fk->wikiid)
//
// wiki_pages
// (pk->pagename,version,wiki, fk->wiki)
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
// nt->nested field (recursive data)
// CL->course level info
// UL->user level info
// files->table may have files)
//
//-----------------------------------------------------------
//This function executes all the backup procedure about this mod
function wiki_backup_mods($bf,$preferences) {
global $CFG, $DB;
$status = true;
////Iterate over wiki table
if ($wikis = $DB->get_records ("wiki","course", array($preferences->backup_course=>"id"))) {
foreach ($wikis as $wiki) {
if (backup_mod_selected($preferences,'wiki',$wiki->id)) {
wiki_backup_one_mod($bf,$preferences,$wiki);
}
}
}
return $status;
}
function wiki_backup_one_mod($bf,$preferences,$wiki) {
global $DB;
$status = true;
if (is_numeric($wiki)) {
$wiki = $DB->get_record('wiki', array('id'=>$wiki));
}
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print assignment data
fwrite ($bf,full_tag("ID",4,false,$wiki->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"wiki"));
fwrite ($bf,full_tag("NAME",4,false,$wiki->name));
fwrite ($bf,full_tag("SUMMARY",4,false,$wiki->intro));
fwrite ($bf,full_tag("PAGENAME",4,false,$wiki->pagename));
fwrite ($bf,full_tag("WTYPE",4,false,$wiki->wtype));
fwrite ($bf,full_tag("EWIKIPRINTTITLE",4,false,$wiki->ewikiprinttitle));
fwrite ($bf,full_tag("HTMLMODE",4,false,$wiki->htmlmode));
fwrite ($bf,full_tag("EWIKIACCEPTBINARY",4,false,$wiki->ewikiacceptbinary));
fwrite ($bf,full_tag("DISABLECAMELCASE",4,false,$wiki->disablecamelcase));
fwrite ($bf,full_tag("SETPAGEFLAGS",4,false,$wiki->setpageflags));
fwrite ($bf,full_tag("STRIPPAGES",4,false,$wiki->strippages));
fwrite ($bf,full_tag("REMOVEPAGES",4,false,$wiki->removepages));
fwrite ($bf,full_tag("REVERTCHANGES",4,false,$wiki->revertchanges));
fwrite ($bf,full_tag("INITIALCONTENT",4,false,$wiki->initialcontent));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$wiki->timemodified));
//backup entries and pages
if (backup_userdata_selected($preferences,'wiki',$wiki->id)) {
$status = backup_wiki_entries($bf,$preferences,$wiki->id, $preferences->mods["wiki"]->userinfo);
$status = backup_wiki_files_instance($bf,$preferences,$wiki->id);
}
//End mod
fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
function wiki_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = $instance->name;
$info[$instance->id.'0'][1] = '';
// wiki_check_backup_mods ignores userdata, so we do too.
return $info;
}
////Return an array of info (name,value)
function wiki_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
global $DB;
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += wiki_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","wiki");
$info[0][1] = $DB->count_records("wiki", array("course"=>$course));
return $info;
}
//Backup wiki_entries contents (executed from wiki_backup_mods)
function backup_wiki_entries ($bf,$preferences,$wiki, $userinfo) {
global $CFG, $DB;
$status = true;
$wiki_entries = $DB->get_records("wiki_entries", array("wikiid"=>$wiki), "id");
//If there are entries
if ($wiki_entries) {
//Write start tag
$status =fwrite ($bf,start_tag("ENTRIES",4,true));
//Iterate over each entry
foreach ($wiki_entries as $wik_ent) {
//Entry start
$status =fwrite ($bf,start_tag("ENTRY",5,true));
fwrite ($bf,full_tag("ID",6,false,$wik_ent->id));
fwrite ($bf,full_tag("GROUPID",6,false,$wik_ent->groupid));
fwrite ($bf,full_tag("USERID",6,false,$wik_ent->userid));
fwrite ($bf,full_tag("PAGENAME",6,false,$wik_ent->pagename));
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$wik_ent->timemodified));
//Now save entry pages
$status = backup_wiki_pages($bf,$preferences,$wik_ent->id);
//Entry end
$status =fwrite ($bf,end_tag("ENTRY",5,true));
}
//Write end tag
$status =fwrite ($bf,end_tag("ENTRIES",4,true));
}
return $status;
}
//Write wiki_pages contents
function backup_wiki_pages ($bf,$preferences,$entryid) {
global $CFG, $DB;
$status = true;
$pages = $DB->get_records("wiki_pages", array("wiki"=>$entryid));
if ($pages) {
//Start tag
$status =fwrite ($bf,start_tag("PAGES",6,true));
//Iterate over each page
foreach ($pages as $page) {
$status =fwrite ($bf,start_tag("PAGE",7,true));
fwrite ($bf,full_tag("ID",8,false,$page->id));
fwrite ($bf,full_tag("PAGENAME",8,false,$page->pagename));
fwrite ($bf,full_tag("VERSION",8,false,$page->version));
fwrite ($bf,full_tag("FLAGS",8,false,$page->flags));
fwrite ($bf,full_tag("CONTENT",8,false,$page->content));
fwrite ($bf,full_tag("AUTHOR",8,false,$page->author));
fwrite ($bf,full_tag("USERID",8,false,$page->userid));
fwrite ($bf,full_tag("CREATED",8,false,$page->created));
fwrite ($bf,full_tag("LASTMODIFIED",8,false,$page->lastmodified));
fwrite ($bf,full_tag("REFS",8,false,str_replace("\n","$@LINEFEED@$",$page->refs)));
fwrite ($bf,full_tag("META",8,false,$page->meta));
fwrite ($bf,full_tag("HITS",8,false,$page->hits));
$status =fwrite ($bf,end_tag("PAGE",7,true));
}
$status =fwrite ($bf,end_tag("PAGES",6,true));
}
return $status;
}
function backup_wiki_files_instance($bf,$preferences,$instanceid) {
global $CFG, $DB;
$status = true;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/wiki/",true);
//Now copy the forum dir
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki/".$instanceid)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki/".$instanceid,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/wiki/".$instanceid);
}
}
return $status;
}
//Backup wiki binary files
function backup_wiki_files($bf,$preferences) {
global $CFG;
$status = true;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
//Now copy the forum dir
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki")) {
$handle = opendir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki");
while (false!==($item = readdir($handle))) {
if ($item != '.' && $item != '..' && is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki/".$item)
&& array_key_exists($item,$preferences->mods['wiki']->instances)
&& !empty($preferences->mods['wiki']->instances[$item]->backup)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki/".$item,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/wiki/",$item);
}
}
}
}
return $status;
}
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function wiki_encode_content_links ($content,$preferences) {
global $CFG;
$base = preg_quote($CFG->wwwroot,"/");
//Link to the list of wikis
$buscar="/(".$base."\/mod\/wiki\/index.php\?id\=)([0-9]+)/";
$result= preg_replace($buscar,'$@WIKIINDEX*$2@$',$content);
//Link to wiki view by moduleid
$buscar="/(".$base."\/mod\/wiki\/view.php\?id\=)([0-9]+)/";
$result= preg_replace($buscar,'$@WIKIVIEWBYID*$2@$',$result);
return $result;
}
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-18
View File
@@ -1,18 +0,0 @@
<?PHP
// Make sure all variables are defined
?>
<form action="admin.php" method="post" enctype="multipart/form-data">
<fieldset class="invisiblefieldset">
<input type="hidden" name="userid" value="<?php print $userid; ?>" />
<input type="hidden" name="groupid" value="<?php print $groupid ?>" />
<input type="hidden" name="action" value="<?php print $action; ?>" />
<input type="hidden" name="id" value="<?php print $cm->id ?>" />
<input type="hidden" name="wikipage" value="<?php print $wikipage?>" />
<?php
$pagelist=wiki_admin_checklinks_list();
echo html_writer::select($pagelist, "pagetocheck", $wikipage, false);
?>
<input type="submit" name="proceed" value="<?php print get_string("checklinks","wiki"); ?>" />
</fieldset>
</form>
+73
View File
@@ -0,0 +1,73 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains all necessary code to view a discussion page
*
* @package mod-wiki-2.0
* @copyrigth 2009 Marc Alier, Jordi Piguillem [email protected]
* @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Jordi Piguillem
* @author Marc Alier
* @author David Jimenez
* @author Josep Arus
* @author Kenneth Riba
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once($CFG->dirroot . '/mod/wiki/lib.php');
require_once($CFG->dirroot . '/mod/wiki/locallib.php');
require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
$pageid = required_param('pageid', PARAM_TEXT);
if (!$page = wiki_get_page($pageid)) {
print_error('incorrectpageid', 'wiki');
}
if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
print_error('incorrectsubwikiid', 'wiki');
}
if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
print_error('incorrectwikiid', 'wiki');
}
if (!$cm = get_coursemodule_from_instance('wiki', $wiki->id)) {
print_error('invalidcoursemodule');
}
if (!$course = get_course_by_id($cm->course)) {
print_error('coursemisconf');
}
require_course_login($course->id, true, $cm);
add_to_log($course->id, 'wiki', 'comments', 'comments.php?id='.$cm->id, $wiki->id);
/// Print the page header
$wikipage = new page_wiki_comments($wiki, $subwiki, $cm);
$wikipage->set_page($page);
$wikipage->print_header();
$wikipage->print_content();
$wikipage->print_footer();
+38
View File
@@ -0,0 +1,38 @@
<?php
require_once($CFG->dirroot . '/lib/formslib.php');
class mod_wiki_comments_form extends moodleform {
function definition() {
$pageid = optional_param('pageid', 0, PARAM_INT);
$mform =& $this->_form;
$current = $this->_customdata['current'];
$commentoptions = $this->_customdata['commentoptions'];
// visible elements
$mform->addElement('editor', 'entrycomment_editor', get_string('comment', 'glossary'), null, $commentoptions);
$mform->addRule('entrycomment_editor', get_string('required'), 'required', null, 'client');
$mform->setType('entrycomment_editor', PARAM_RAW); // processed by trust text or cleaned before the display
// hidden optional params
$mform->addElement('hidden', 'id', '');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'action', '');
$mform->setType('action', PARAM_ACTION);
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons(false);
//-------------------------------------------------------------------------------
$this->set_data($current);
}
public function edit_definition($current, $commentoptions) {
$this->set_data($current);
$this->set_data($commentoptions);
}
}
-34
View File
@@ -1,34 +0,0 @@
<?php
/**
* This script is called through AJAX. It confirms that a user is still
* trying to edit a page that they have locked (they haven't closed
* their browser window or something).
*
* @copyright &copy; 2006 The Open University
* @author [email protected]
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod-wiki
* @category mod
*//** */
require_once("../../config.php");
$PAGE->set_url('/mod/wiki/confirmlock.php');
header('Content-Type: text/plain');
$lockid = optional_param('lockid', 0, PARAM_INT);
if($lockid == 0) {
print 'noid';
exit;
}
if($lock=$DB->get_record('wiki_locks', array('id'=>$lockid))) {
$lock->lockedseen=time();
$DB->update_record('wiki_locks',$lock);
print 'ok';
} else {
print 'cancel'; // Tells user their lock has been cancelled.
}
+106
View File
@@ -0,0 +1,106 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
require_once('../../config.php');
require_once(dirname(__FILE__).'/create_form.php');
require_once($CFG->dirroot . '/mod/wiki/lib.php');
require_once($CFG->dirroot . '/mod/wiki/locallib.php');
require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
// this page accepts two actions: new and create
// 'new' action will display a form contains page title and page format
// selections
// 'create' action will create a new page in db, and redirect to
// page editing page.
$action = optional_param('action', 'new', PARAM_TEXT);
// The title of the new page, can be empty
$title = optional_param('title', '', PARAM_TEXT);
$swid = optional_param('swid', 0, PARAM_INT);
$wid = optional_param('wid', 0, PARAM_INT);
$gid = optional_param('gid', 0, PARAM_INT);
$uid = optional_param('uid', 0, PARAM_INT);
// 'create' action must be submitted by moodle form
// so sesskey must be checked
if ($action == 'create') {
if (!confirm_sesskey()) {
print_error('invalidsesskey');
}
}
$swiki = null;
if (!empty($wid)) {
// @TODO: Check for capabilities
if (!$swid = wiki_add_subwiki($wid, $gid, $uid)) {
print_error('invalidwikiid');
}
}
if (!$subwiki = wiki_get_subwiki($swid)) {
print_error('invalidswid', 'wiki');
}
if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
print_error('invalidwikiid', 'wiki');
}
if (!$cm = get_coursemodule_from_instance('wiki', $wiki->id)) {
print_error('invalidcoursemoduleid', 'wiki');
}
if (!$course = get_course_by_id($cm->course)) {
print_error('invalidcourseid', 'wiki');
}
require_course_login($course->id, true, $cm);
add_to_log($course->id, 'createpage', 'createpage', 'view.php?id='.$cm->id, $wiki->id);
$wikipage = new page_wiki_create($wiki, $subwiki, $cm);
$wikipage->set_gid($gid);
$wikipage->set_swid($swid);
if (!empty($title)) {
$wikipage->set_title($title);
} else {
$wikipage->set_title(get_string('newpage', 'wiki'));
}
// set page action, and initialise moodle form
$wikipage->set_action($action);
switch ($action) {
case 'create':
$wikipage->create_page($title);
break;
case 'new':
if (!empty($title)) {
// create page from interlink with pagetitle
$wikipage->print_header();
$wikipage->print_content($title);
} else {
// create link from moodle navigation block without pagetitle
$wikipage->print_header();
// new page without page title
$wikipage->print_content();
}
$wikipage->print_footer();
break;
}
+60
View File
@@ -0,0 +1,60 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains all necessary code to define and process an edit form
*
* @package mod-wiki-2.0
* @copyright 2010 Dongsheng Cai <[email protected]>
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_wiki_create_form extends moodleform {
protected function definition() {
global $CFG;
$mform =& $this->_form;
$formats = $this->_customdata['formats'];
$mform->addElement('header', 'general', get_string('createpage', 'wiki'));
$textoptions = array();
if (!empty($this->_customdata['disable_pagetitle'])) {
$textoptions = array('disabled'=>'disabled');
}
$mform->addElement('text', 'pagetitle', get_string('newpagetitle', 'wiki'), $textoptions);
// TODO: disable creole and nwiki format until moodle core text format lib added
$disabled_formats = array('creole', 'nwiki');
foreach ($formats as $format) {
if (in_array($format, $disabled_formats)) {
$attr = array('disabled'=>'disabled');
} else {
$attr = array('checked'=>'checked');
}
$mform->addElement('radio', 'pageformat', '', get_string('format'.$format, 'wiki'), $format, $attr);
}
//hiddens
$mform->addElement('hidden', 'action');
$mform->setDefault('action', 'create');
$this->add_action_buttons(false, get_string('createpage', 'wiki'));
}
}
+71 -6
View File
@@ -1,12 +1,30 @@
<?php
/**
* Capability definitions for the wiki module.
*
* For naming conventions, see lib/db/access.php.
* This file defines all wiki module specific capabilities
*
* @author Jordi Piguillem
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package wiki
*/
$capabilities = array(
'mod/wiki:participate' => array(
'mod/wiki:viewpage' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'guest' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'mod/wiki:editpage' => array(
'riskbitmask' => RISK_SPAM,
@@ -20,10 +38,48 @@ $capabilities = array(
)
),
'mod/wiki:manage' => array(
'mod/wiki:createpage' => array(
'riskbitmask' => RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'mod/wiki:viewcomment' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'mod/wiki:editcomment' => array(
'riskbitmask' => RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'mod/wiki:managecomment' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
@@ -35,7 +91,16 @@ $capabilities = array(
'mod/wiki:overridelock' => array(
'riskbitmask' => 0,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'mod/wiki:managewiki' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
@@ -44,5 +109,5 @@ $capabilities = array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
)
),
);
+2 -7
View File
@@ -1,13 +1,8 @@
<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_wiki_install() {
global $DB;
/// Install logging support here
}
}
+83 -65
View File
@@ -1,28 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/wiki/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/wiki"
<XMLDB PATH="mod/wiki/db" VERSION="20100427" COMMENT="XMLDB file for Moodle mod/wiki"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="wiki" COMMENT="Main wik table" NEXT="wiki_entries">
<TABLE NAME="wiki" COMMENT="Stores Wiki activity configuration" NEXT="wiki_subwikis">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="course" NEXT="intro"/>
<FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="name" NEXT="introformat"/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="intro text field format" PREVIOUS="intro" NEXT="pagename"/>
<FIELD NAME="pagename" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="introformat" NEXT="wtype"/>
<FIELD NAME="wtype" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="group" SEQUENCE="false" PREVIOUS="pagename" NEXT="ewikiprinttitle"/>
<FIELD NAME="ewikiprinttitle" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="wtype" NEXT="htmlmode"/>
<FIELD NAME="htmlmode" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="ewikiprinttitle" NEXT="ewikiacceptbinary"/>
<FIELD NAME="ewikiacceptbinary" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="htmlmode" NEXT="disablecamelcase"/>
<FIELD NAME="disablecamelcase" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="ewikiacceptbinary" NEXT="setpageflags"/>
<FIELD NAME="setpageflags" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="disablecamelcase" NEXT="strippages"/>
<FIELD NAME="strippages" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="setpageflags" NEXT="removepages"/>
<FIELD NAME="removepages" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="strippages" NEXT="revertchanges"/>
<FIELD NAME="revertchanges" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="removepages" NEXT="initialcontent"/>
<FIELD NAME="initialcontent" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="revertchanges" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="initialcontent"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Course wiki activity belongs to" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="Wiki" SEQUENCE="false" COMMENT="name field for moodle instances" PREVIOUS="course" NEXT="intro"/>
<FIELD NAME="intro" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="General introduction of the wiki activity" PREVIOUS="name" NEXT="introformat"/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Format of the intro field (MOODLE, HTML, MARKDOWN...)" PREVIOUS="intro" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="introformat" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="firstpagetitle"/>
<FIELD NAME="firstpagetitle" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="First Page" SEQUENCE="false" COMMENT="Wiki first page's name" PREVIOUS="timemodified" NEXT="wikimode"/>
<FIELD NAME="wikimode" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="collaborative" SEQUENCE="false" COMMENT="Wiki mode (individual, collaborative)" PREVIOUS="firstpagetitle" NEXT="defaultformat"/>
<FIELD NAME="defaultformat" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="creole" SEQUENCE="false" COMMENT="Wiki's default editor" PREVIOUS="wikimode" NEXT="forceformat"/>
<FIELD NAME="forceformat" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="Forces the default editor" PREVIOUS="defaultformat" NEXT="editbegin"/>
<FIELD NAME="editbegin" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="editbegin" PREVIOUS="forceformat" NEXT="editend"/>
<FIELD NAME="editend" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="editend" PREVIOUS="editbegin"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
@@ -31,68 +27,90 @@
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
</INDEXES>
</TABLE>
<TABLE NAME="wiki_entries" COMMENT="Holds entries for each wiki start instance" PREVIOUS="wiki" NEXT="wiki_pages">
<TABLE NAME="wiki_subwikis" COMMENT="Stores subwiki instances" PREVIOUS="wiki" NEXT="wiki_pages">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="wikiid"/>
<FIELD NAME="wikiid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="wikiid" NEXT="groupid"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="course" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="groupid" NEXT="pagename"/>
<FIELD NAME="pagename" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="userid" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="pagename"/>
<FIELD NAME="wikiid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Wiki activity" PREVIOUS="id" NEXT="groupid"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Group that owns this wiki" PREVIOUS="wikiid" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Owner of that subwiki" PREVIOUS="groupid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="wikiid"/>
<KEY NAME="wikiid" TYPE="foreign" FIELDS="wikiid" REFTABLE="wiki" REFFIELDS="id" PREVIOUS="primary"/>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="wikifk"/>
<KEY NAME="wikifk" TYPE="foreign" FIELDS="wikiid" REFTABLE="wiki" REFFIELDS="id" COMMENT="Foreign key to wiki table" PREVIOUS="primary" NEXT="wikiidgroupiduserid"/>
<KEY NAME="wikiidgroupiduserid" TYPE="unique" FIELDS="wikiid, groupid, userid" COMMENT="Unique key" PREVIOUS="wikifk"/>
</KEYS>
<INDEXES>
<INDEX NAME="course" UNIQUE="false" FIELDS="course" NEXT="gropuid"/>
<INDEX NAME="gropuid" UNIQUE="false" FIELDS="groupid" PREVIOUS="course" NEXT="userid"/>
<INDEX NAME="userid" UNIQUE="false" FIELDS="userid" PREVIOUS="gropuid" NEXT="pagename"/>
<INDEX NAME="pagename" UNIQUE="false" FIELDS="pagename" PREVIOUS="userid"/>
</INDEXES>
</TABLE>
<TABLE NAME="wiki_pages" COMMENT="Holds the Wiki-Pages" PREVIOUS="wiki_entries" NEXT="wiki_locks">
<TABLE NAME="wiki_pages" COMMENT="Stores wiki pages" PREVIOUS="wiki_subwikis" NEXT="wiki_versions">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="pagename"/>
<FIELD NAME="pagename" TYPE="char" LENGTH="160" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="version"/>
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="pagename" NEXT="flags"/>
<FIELD NAME="flags" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="version" NEXT="content"/>
<FIELD NAME="content" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" PREVIOUS="flags" NEXT="author"/>
<FIELD NAME="author" TYPE="char" LENGTH="100" NOTNULL="false" DEFAULT="ewiki" SEQUENCE="false" PREVIOUS="content" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="author" NEXT="created"/>
<FIELD NAME="created" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="lastmodified"/>
<FIELD NAME="lastmodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="created" NEXT="refs"/>
<FIELD NAME="refs" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" PREVIOUS="lastmodified" NEXT="meta"/>
<FIELD NAME="meta" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" PREVIOUS="refs" NEXT="hits"/>
<FIELD NAME="hits" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="meta" NEXT="wiki"/>
<FIELD NAME="wiki" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="hits"/>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="subwikiid"/>
<FIELD NAME="subwikiid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Subwiki instance of this page" PREVIOUS="id" NEXT="title"/>
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="title" SEQUENCE="false" COMMENT="Page name" PREVIOUS="subwikiid" NEXT="cachedcontent"/>
<FIELD NAME="cachedcontent" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" COMMENT="Cache wiki content" PREVIOUS="title" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Wiki page creation timestamp" PREVIOUS="cachedcontent" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="page edition timestamp" PREVIOUS="timecreated" NEXT="timerendered"/>
<FIELD NAME="timerendered" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Last render timestamp" PREVIOUS="timemodified" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Edition author" PREVIOUS="timerendered" NEXT="pageviews"/>
<FIELD NAME="pageviews" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Number of page views" PREVIOUS="userid" NEXT="readonly"/>
<FIELD NAME="readonly" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Read only flag" PREVIOUS="pageviews"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="wiki"/>
<KEY NAME="wiki" TYPE="foreign" FIELDS="wiki" REFTABLE="wiki" REFFIELDS="id" PREVIOUS="primary"/>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="subwikititle"/>
<KEY NAME="subwikititleuser" TYPE="unique" FIELDS="subwikiid, title, userid" PREVIOUS="primary" NEXT="subwikifk"/>
<KEY NAME="subwikifk" TYPE="foreign" FIELDS="subwikiid" REFTABLE="wiki_subwiki" REFFIELDS="id" COMMENT="Foreign key to subwiki table" PREVIOUS="subwikititle"/>
</KEYS>
<INDEXES>
<INDEX NAME="pagename-version-wiki" UNIQUE="true" FIELDS="pagename, version, wiki"/>
</INDEXES>
</TABLE>
<TABLE NAME="wiki_locks" COMMENT="Stores editing locks on Wiki pages" PREVIOUS="wiki_pages">
<TABLE NAME="wiki_versions" COMMENT="Stores wiki page history" PREVIOUS="wiki_pages" NEXT="wiki_synonyms">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="wikiid"/>
<FIELD NAME="wikiid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="pagename"/>
<FIELD NAME="pagename" TYPE="char" LENGTH="160" NOTNULL="true" SEQUENCE="false" PREVIOUS="wikiid" NEXT="lockedby"/>
<FIELD NAME="lockedby" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="If the page is or was locked, this field holds the userid of the locker" PREVIOUS="pagename" NEXT="lockedsince"/>
<FIELD NAME="lockedsince" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Time (seconds since epoch) at which lock began" PREVIOUS="lockedby" NEXT="lockedseen"/>
<FIELD NAME="lockedseen" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Time (seconds since epoch) at which lock was last reconfirmed (we ignore lock if this is &amp;gt;2 mins ago)" PREVIOUS="lockedsince"/>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="pageid"/>
<FIELD NAME="pageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Page id" PREVIOUS="id" NEXT="content"/>
<FIELD NAME="content" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" COMMENT="Not parsed wiki content" PREVIOUS="pageid" NEXT="contentformat"/>
<FIELD NAME="contentformat" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="creole" SEQUENCE="false" COMMENT="Markup used to write content" PREVIOUS="content" NEXT="version"/>
<FIELD NAME="version" TYPE="int" LENGTH="5" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Wiki page version" PREVIOUS="contentformat" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Page edition timestamp" PREVIOUS="version" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Edition autor" PREVIOUS="timecreated"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="wikiid"/>
<KEY NAME="wikiid" TYPE="foreign" FIELDS="wikiid" REFTABLE="wiki" REFFIELDS="id" PREVIOUS="primary"/>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="pagefk"/>
<KEY NAME="pagefk" TYPE="foreign" FIELDS="pageid" REFTABLE="wiki_pages" REFFIELDS="id" COMMENT="Foreign key to pages table" PREVIOUS="primary"/>
</KEYS>
</TABLE>
<TABLE NAME="wiki_synonyms" COMMENT="Stores wiki pages synonyms" PREVIOUS="wiki_versions" NEXT="wiki_links">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="subwikiid"/>
<FIELD NAME="subwikiid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Subwiki instance" PREVIOUS="id" NEXT="pageid"/>
<FIELD NAME="pageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Original page" PREVIOUS="subwikiid" NEXT="pagesynonym"/>
<FIELD NAME="pagesynonym" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="Pagesynonym" SEQUENCE="false" COMMENT="Page name synonym" PREVIOUS="pageid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="pageidsyn"/>
<KEY NAME="pageidsyn" TYPE="unique" FIELDS="pageid, pagesynonym" PREVIOUS="primary"/>
</KEYS>
</TABLE>
<TABLE NAME="wiki_links" COMMENT="Page wiki links" PREVIOUS="wiki_synonyms" NEXT="wiki_locks">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="subwikiid"/>
<FIELD NAME="subwikiid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Subwiki instance" PREVIOUS="id" NEXT="frompageid"/>
<FIELD NAME="frompageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Page id with a link" PREVIOUS="subwikiid" NEXT="topageid"/>
<FIELD NAME="topageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Page id that recives a link" PREVIOUS="frompageid" NEXT="tomissingpage"/>
<FIELD NAME="tomissingpage" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="link to a nonexistent page" PREVIOUS="topageid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="frompageidfk"/>
<KEY NAME="frompageidfk" TYPE="foreign" FIELDS="frompageid" REFTABLE="wiki_pages" REFFIELDS="id" COMMENT="Foreig key to wiki_pages" PREVIOUS="primary" NEXT="subwikifk"/>
<KEY NAME="subwikifk" TYPE="foreign" FIELDS="subwikiid" REFTABLE="wiki_subwiki" REFFIELDS="id" COMMENT="Foreign key to wiki_subwiki table" PREVIOUS="frompageidfk"/>
</KEYS>
</TABLE>
<TABLE NAME="wiki_locks" COMMENT="Manages page locks" PREVIOUS="wiki_links">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="pageid"/>
<FIELD NAME="pageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Locked page" PREVIOUS="id" NEXT="sectionname"/>
<FIELD NAME="sectionname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="locked page section" PREVIOUS="pageid" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Locking user" PREVIOUS="sectionname" NEXT="lockedat"/>
<FIELD NAME="lockedat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="timestamp" PREVIOUS="userid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="wikiid-pagename" UNIQUE="true" FIELDS="wikiid, pagename" COMMENT="Main index used for retrieving locks" NEXT="lockedseen"/>
<INDEX NAME="lockedseen" UNIQUE="false" FIELDS="lockedseen" COMMENT="Secondary index used only during cron for deleting expired locks" PREVIOUS="wikiid-pagename"/>
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
+66
View File
@@ -0,0 +1,66 @@
<?php
function wiki_ewiki_2_html($oldentry, $oldpage, $oldwiki) {
global $CFG, $wiki_entry, $moodle_disable_camel_case, $ewiki_plugins, $ewiki_config, $moodle_format;
$wiki_entry = $oldentry;
$moodle_disable_camel_case = ($oldwiki->disablecamelcase == 1);
// Block of dinamic ewiki defines
wiki_set_define("EWIKI_NAME", $wiki_entry->pagename);
wiki_set_define("EWIKI_DEFAULT_LANG", current_language());
if ($moodle_disable_camel_case) {
wiki_set_define("EWIKI_CHARS_L", "");
wiki_set_define("EWIKI_CHARS_U", "");
} else {
wiki_set_define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377");
wiki_set_define("EWIKI_CHARS_U", "A-Z0-9\300-\336");
}
wiki_set_define("EWIKI_CHARS", wiki_get_define('EWIKI_CHARS_L') . wiki_get_define('EWIKI_CHARS_U'));
require_once($CFG->dirroot . '/mod/wiki/db/migration/wiki/ewikimoodlelib.php');
require_once($CFG->dirroot . '/mod/wiki/db/migration/wiki/ewiki/ewiki.php');
if ($oldwiki->htmlmode == 0) {
# No HTML
$ewiki_config["htmlentities"] = array(); // HTML is managed by moodle
$moodle_format = FORMAT_TEXT;
}
if ($oldwiki->htmlmode == 1) {
# Safe HTML
include_once($CFG->dirroot . "/mod/wiki/db/migration/wiki/ewiki/plugins/moodle/moodle_rescue_html.php");
$moodle_format = FORMAT_HTML;
}
if ($oldwiki->htmlmode == 2) {
# HTML Only
$moodle_format = FORMAT_HTML;
$ewiki_use_editor = 1;
$ewiki_config["htmlentities"] = array(); // HTML is allowed
$ewiki_config["wiki_link_regex"] = "\007 [!~]?(
\#?\[[^<>\[\]\n]+\] |
\^[-" .
wiki_get_define('EWIKI_CHARS_U') . wiki_get_define('EWIKI_CHARS_L') . "]{3,} |
\b([\w]{3,}:)*([" .
wiki_get_define('EWIKI_CHARS_U') . "]+[" . wiki_get_define('EWIKI_CHARS_L') . "]+){2,}\#?[\w\d]* |
\w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x";
}
$content = ewiki_format($oldpage->content);
return format_text($content, $moodle_format);
}
function wiki_set_define($key, $value) {
global $ewikidefines;
$ewikidefines[$key] = $value;
}
function wiki_get_define($key) {
global $ewikidefines;
return $ewikidefines[$key];
}
@@ -37,7 +37,7 @@
# define("EWIKI_SCRIPT_URL", "http://...?id="); # absolute URL
#-- change to your needs (site lang)
define("EWIKI_NAME", "ErfurtWiki");
//define("EWIKI_NAME", "ErfurtWiki");
define("EWIKI_PAGE_INDEX", "ErfurtWiki");
define("EWIKI_PAGE_NEWEST", "NewestPages");
define("EWIKI_PAGE_SEARCH", "SearchPages");
@@ -75,7 +75,7 @@
define("EWIKI_UP_BINARY", "binary");
define("EWIKI_UP_UPLOAD", "upload");
#- other stuff
define("EWIKI_DEFAULT_LANG", "en");
//define("EWIKI_DEFAULT_LANG", "en");
define("EWIKI_CHARSET", "UTF-8");
#- user permissions
define("EWIKI_PROTECTED_MODE", 0); # disable funcs + require auth
@@ -86,22 +86,24 @@
#-- allowed WikiPageNameCharacters
#### BEGIN MOODLE CHANGES - to remove auto-camelcase linking.
global $moodle_disable_camel_case;
if ($moodle_disable_camel_case) {
define("EWIKI_CHARS_L", "");
define("EWIKI_CHARS_U", "");
}
else {
#### END MOODLE CHANGES
define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377");
define("EWIKI_CHARS_U", "A-Z0-9\300-\336");
#### BEGIN MOODLE CHANGES
}
#### END MOODLE CHANGES
define("EWIKI_CHARS", EWIKI_CHARS_L.EWIKI_CHARS_U);
// global $moodle_disable_camel_case;
// if ($moodle_disable_camel_case) {
// define("EWIKI_CHARS_L", "");
// define("EWIKI_CHARS_U", "");
// }
// else {
//#### END MOODLE CHANGES
//
// define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377");
// define("EWIKI_CHARS_U", "A-Z0-9\300-\336");
//
//#### BEGIN MOODLE CHANGES
// }
//#### END MOODLE CHANGES
//
// define("EWIKI_CHARS", EWIKI_CHARS_L.EWIKI_CHARS_U);
//
// COMMENTED BY PIGUI BECOUSE OF MIGRATION
#-- database
define("EWIKI_DB_TABLE_NAME", "ewiki"); # MySQL / ADOdb
@@ -214,15 +216,15 @@
"wiki_pre_scan_regex" => '/
(?<![~!])
((?:(?:\w+:)*['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+){2,}[\w\d]*)
|\^([-'.EWIKI_CHARS_L.EWIKI_CHARS_U.']{3,})
((?:(?:\w+:)*['.wiki_get_define('EWIKI_CHARS_U').']+['.wiki_get_define('EWIKI_CHARS_L').']+){2,}[\w\d]*)
|\^([-'.wiki_get_define('EWIKI_CHARS_L').wiki_get_define('EWIKI_CHARS_U').']{3,})
|\[ (?:"[^\]\"]+" | \s+ | [^:\]#]+\|)* ([^\|\"\[\]\#]+) (?:\s+ | "[^\]\"]+")* [\]\#]
|(\w{3,9}:\/\/[^?#\s\[\]\'\"\)\,<]+) /x',
"wiki_link_regex" => "\007 [!~]?(
\#?\[[^<>\[\]\n]+\] |
\^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} |
\b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* |
\^[-".wiki_get_define('EWIKI_CHARS_U').wiki_get_define('EWIKI_CHARS_L')."]{3,} |
\b([\w]{3,}:)*([".wiki_get_define('EWIKI_CHARS_U')."]+[".wiki_get_define('EWIKI_CHARS_L')."]+){2,}\#?[\w\d]* |
([a-z]{2,9}://|mailto:)[^\s\[\]\'\"\)\,<]+ |
\w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x",
@@ -300,9 +302,9 @@
#### MOODLE CHANGE TO BE COMPATIBLE WITH PHP 4.1
#if(headers_sent($file,$line)) {
# print_error('headersent');
if(headers_sent()) {
/*if(headers_sent()) {
print_error('headersent');
}
}*/
$pf($GLOBALS);
}
unset($ewiki_plugins["init"]);
@@ -660,7 +662,7 @@ function ewiki_page_css_container(&$o, &$id, &$data, &$action) {
function ewiki_split_title ($id='', $split=EWIKI_SPLIT_TITLE, $entities=1) {
strlen($id) or ($id = $GLOBALS["ewiki_id"]);
if ($split) {
$id = preg_replace("/([".EWIKI_CHARS_L."])([".EWIKI_CHARS_U."]+)/", "$1 $2", $id);
$id = preg_replace("/([".wiki_get_define('EWIKI_CHARS_L')."])([".wiki_get_define('EWIKI_CHARS_U')."]+)/", "$1 $2", $id);
}
return($entities ? s($id) : $id);
}
@@ -1273,7 +1275,7 @@ function ewiki_page_info($id, &$data, $action) {
elseif ($i == "author") {
continue;
$ewiki_links=1;
$value = preg_replace_callback("/((\w+:)?([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}[\w\d]*)/", "ewiki_link_regex_callback", $value);
$value = preg_replace_callback("/((\w+:)?([".wiki_get_define('EWIKI_CHARS_U')."]+[".wiki_get_define('EWIKI_CHARS_L')."]+){2,}[\w\d]*)/", "ewiki_link_regex_callback", $value);
}
elseif ($i == "userid") {
$i = 'author';
@@ -1742,11 +1744,7 @@ function ewiki_control_links($id, &$data, $action) {
process. The $params array can activate various features and extensions.
only accepts UNIX newlines!
*/
function ewiki_format (
$wiki_source,
$params = array()
)
{
function ewiki_format ( $wiki_source, $params = array()) {
global $ewiki_links, $ewiki_plugins, $ewiki_config;
#-- state vars
@@ -2296,6 +2294,7 @@ function ewiki_merge_links(&$ewiki_links) {
(ooutch, this is a complicated one)
*/
function ewiki_link_regex_callback($uu, $force_noimg=0) {
global $DB, $CFG;
#print "<pre>"; print_r($uu); print "</pre>";
global $ewiki_links, $ewiki_plugins, $ewiki_config, $ewiki_id;
@@ -2319,7 +2318,8 @@ function ewiki_link_regex_callback($uu, $force_noimg=0) {
#-- explicit title given via [ title | WikiLink ]
$href = $title = strtok($str, "|");
if ($uu = strtok("|")) {
$href = $uu;
$parts = explode('|', $str);
$title = $parts[1] . ' | ' .$parts[0];
$states["titled"] = 1;
}
#-- title and href swapped: swap back
@@ -2395,8 +2395,7 @@ function ewiki_link_regex_callback($uu, $force_noimg=0) {
#### BEGIN MOODLE CHANGES
global $ewiki_link_case;
$href_realcase=array_key_exists($href_i,$ewiki_link_case) ? $ewiki_link_case[$href_i] : $href;
$str = '<a href="' . ewiki_script("", $href_realcase) . s($href2)
. '">' . $title . '</a>';
$str = '[[' . $title . ']]';
#### END MOODLE CHANGES
}
#-- guess for mail@addresses, convert to URI if
@@ -2418,8 +2417,9 @@ function ewiki_link_regex_callback($uu, $force_noimg=0) {
#-- (QuestionMarkLink to edit/ action)
if (!$str) {
$type = array("notfound");
$str = '<span class="NotFound"><b>' . $title . '</b><a href="' .
ewiki_script("", $href) . '">?</a></span>';
//$str = '<span class="NotFound"><b>' . $title . '</b><a href="' .
// ewiki_script("", $href) . '">?</a></span>';
$str = '[['. $title . ']]';
}
}
@@ -2446,8 +2446,15 @@ function ewiki_link_regex_callback($uu, $force_noimg=0) {
if (EWIKI_SCRIPT_BINARY && ((strpos($href, EWIKI_IDF_INTERNAL)===0) ||
EWIKI_IMAGE_MAXSIZE && EWIKI_CACHE_IMAGES && $img && !$nocache) )
{
$type = array("binary");
$href = ewiki_script_binary("", $href);
$type = array("binary");
//$href = ewiki_script_binary("", $href);
//##### BEGIN MOODLE ADDITION #####
$pattern = 'internal://';
$matches = array();
$filename = str_replace($pattern, '', $href);
$filename = clean_param($filename, PARAM_FILE);
$href = "@@PLUGINFILE@@/$filename";
//##### END MOODLE ADDITION #####
}
#-- output html reference
@@ -2501,12 +2508,11 @@ function ewiki_link_regex_callback($uu, $force_noimg=0) {
function ewiki_interwiki($href, &$type) {
global $ewiki_config, $ewiki_plugins;
if (strpos($href, ":") and !strpos($href, "//")
and ($p1 = strtok($href, ":"))) {
if (strpos($href, ":") and !strpos($href, "//") and ($p1 = strtok($href, ":"))) {
$page = strtok("\000");
if (($p1 = ewiki_array($ewiki_config["interwiki"], $p1)) !== NULL) {
if (!empty($ewiki_config["interwiki"]) && (($p1 = ewiki_array($ewiki_config["interwiki"], $p1)) !== NULL)) {
$type = array("interwiki", $uu);
while ($p1_alias = $ewiki_config["interwiki"][$p1]) {
$type[] = $p1;
@@ -2877,7 +2883,7 @@ function ewiki_localization() {
global $ewiki_t, $ewiki_plugins;
$deflangs = ','.@$_ENV["LANGUAGE"] . ','.@$_ENV["LANG"]
. ",".EWIKI_DEFAULT_LANG . ",en,C";
. ",".wiki_get_define('EWIKI_DEFAULT_LANG') . ",en,C";
foreach (explode(",", @$_SERVER["HTTP_ACCEPT_LANGUAGE"].$deflangs) as $l) {
@@ -1,4 +1,4 @@
<?php
<?php // $Id$
/*
Can be used to allow preserving of certain "safe" HTML <tags>
@@ -23,11 +23,11 @@ function ewiki_moodle_rescue_html(&$wiki_source) {
$rescue_html = array(
"br", "tt", "b", "i", "strong", "em", "s", "kbd", "var", "xmp", "sup", "sub",
"pre", "q", "h1", "h2", "h3", "h4", "h5", "h6", "cite", "code", "u",
"pre", "q", "h1", "h2", "h3", "h4", "h5", "h6", "cite", "code", "u",
);
#-- unescape allowed html
if ($safe_html) {
/*
@@ -43,4 +43,4 @@ function ewiki_moodle_rescue_html(&$wiki_source) {
}
?>
@@ -9,13 +9,13 @@
$ewiki_plugins["database"][0] = "ewiki_database_moodle";
/// #-- predefine some of the configuration constants
define("EWIKI_NAME", $wiki_entry->pagename);
//define("EWIKI_NAME", $wiki_entry->pagename); COMMENTED BY PIGUI BECOUSE OF MIGRATION
define("EWIKI_CONTROL_LINE", 0);
define("EWIKI_LIST_LIMIT", 25);
define("EWIKI_DEFAULT_LANG", current_language());
//define("EWIKI_DEFAULT_LANG", current_language()); COMMENTED BY PIGUI BECOUSE OF MIGRATION
define("EWIKI_HTML_CHARS", 1);
define("EWIKI_DB_TABLE_NAME", "wiki_pages");
define("EWIKI_DB_TABLE_NAME", "wiki_pages_old");
function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
+291 -49
View File
@@ -1,74 +1,316 @@
<?php
// This file keeps track of upgrades to
// the wiki module
// This file is part of Moodle - http://moodle.org/
//
// Sometimes, changes between versions involve
// alterations to database structures and other
// major things that may break installations.
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The upgrade function in this file will attempt
// to perform all the necessary actions to upgrade
// your older installtion to the current version.
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// If there's something it cannot do itself, it
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* 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 installtion to the current version.
*
* @package mod-wiki-2.0
* @copyrigth 2009 Marc Alier, Jordi Piguillem [email protected]
* @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Jordi Piguillem
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
*/
/**
*
* TODO LIST:
*
* 1. Add needed fields to wiki table. DONE
* 2. Rename other wiki tables. DONE
* 3. Create new wiki tables. DONE BUT NOT FINISHED, WATING FOR NEW TABLES
* 4. Move/Adapt/Transform configurations info to new structure
* 5. Migrate wiki entries to subwikis. DONE
* 6. Fill pages table with latest versions of every page. DONE
* 7. Migrate page history to new table (transforming formats). DONE, BUT STILL WORKING
* 8. Fill links table
* 9. Drop useless information
*
* ADITIONAL THINGS AFTER CHAT WITH ELOY:
*
* 1. addField is deprecated. DONE
* 2. Fix SQL error at block 3. DONE
* 3. Merge set_field_select with previous update sentence. DONE
* 4. Don't insert id fields on database (it won't work on mssql, oracle, pg). DONE.
* 5. Use upgrade_set_timeout function.
* 6. Use grafic of progess
*
* OTHER THINGS:
*
* 1. Use recordset instead of record when migrating historic
* 2. Select only usefull data on block 06
*
*/
function xmldb_wiki_upgrade($oldversion) {
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
// Step 0: Add new fields to main wiki table
if ($result && $oldversion < 2010040100) {
require_once(dirname(__FILE__) . '/upgradelib.php');
echo $OUTPUT->notification('Adding new fields to wiki table', 'notifysuccess');
wiki_add_wiki_fields();
if ($result && $oldversion < 2009042000) {
/// Rename field summary on table wiki to intro
$table = new xmldb_table('wiki');
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
/// Launch rename field summary
$dbman->rename_field($table, $field, 'intro');
/// wiki savepoint reached
upgrade_mod_savepoint($result, 2009042000, 'wiki');
upgrade_mod_savepoint($result, 2010040100, 'wiki');
}
if ($result && $oldversion < 2009042001) {
// Step 1: Rename old tables
if ($result && $oldversion < 2010040101) {
$tables = array('wiki_pages', 'wiki_locks', 'wiki_entries');
/// Define field introformat to be added to wiki
$table = new xmldb_table('wiki');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
/// Launch add field introformat
$dbman->add_field($table, $field);
/// wiki savepoint reached
upgrade_mod_savepoint($result, 2009042001, 'wiki');
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($result, 2010040101, 'wiki');
}
/// Dropping all enums/check contraints from core. MDL-18577
if ($result && $oldversion < 2009042700) {
// Step 2: Creating new tables
if ($result && $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($result, 2010040102, 'wiki');
}
/// Changing list of values (enum) of field wtype on table wiki to none
// Step 3: migrating wiki instances
if ($result && $oldversion < 2010040103) {
upgrade_set_timeout();
// Setting up wiki configuration
$sql = 'UPDATE {wiki} w ' .
'SET w.intro = w.summary, ' .
'w.firstpagetitle = w.pagename, ' .
'w.defaultformat = "html"';
$DB->execute($sql);
$sql = 'UPDATE {wiki} w ' .
'SET w.wikimode = "collaborative" ' .
'WHERE w.wtype = "group"';
$DB->execute($sql);
$sql = 'UPDATE {wiki} w ' .
'SET w.wikimode = "individual" ' .
'WHERE w.wtype != "group"';
$DB->execute($sql);
// 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($result, 2010040103, 'wiki');
}
// Step 4: migrating wiki entries to new subwikis
if ($result && $oldversion < 2010040104) {
/**
* Migrating wiki entries to new subwikis
*/
$sql = 'INSERT into {wiki_subwikis} (wikiid, groupid, userid) ' .
'SELECT e.wikiid, e.groupid, e.userid ' .
'FROM {wiki_entries_old} e ';
echo $OUTPUT->notification('Migrating old entries to new subwikis', 'notifysuccess');
$DB->execute($sql, array());
upgrade_mod_savepoint($result, 2010040104, 'wiki');
}
// Step 5: Migrating pages
if ($result && $oldversion < 2010040105) {
/**
* Filling pages table with latest versions of every page.
*
* @TODO: Ensure that ALL versions of every page are always in database and
* they can be removed or cleaned.
* That fact could let us rewrite the subselect to execute a count(*) to avoid
* the order by and it would be much faster.
*/
$sql = 'INSERT into {wiki_pages} (subwikiid, title, cachedcontent, timecreated, timemodified, userid, pageviews) ' .
'SELECT s.id, p.pagename, "**reparse needed**", p.created, p.lastmodified, p.userid, p.hits ' .
'FROM {wiki_pages_old} p '.
'LEFT OUTER JOIN {wiki_entries_old} e ON e.id = p.wiki ' .
'LEFT OUTER JOIN {wiki_subwikis} s ' .
'ON s.wikiid = e.wikiid AND s.groupid = e.groupid AND s.userid = e.userid ' .
'WHERE p.version = (' .
' SELECT po.version ' .
' FROM {wiki_pages_old} po ' .
' WHERE p.pagename = po.pagename and ' .
' p.wiki = po.wiki ' .
' ORDER BY p.version DESC ' .
' LIMIT 1)';
echo $OUTPUT->notification('Migrating old pages to new pages', 'notifysuccess');
$DB->execute($sql, array());
upgrade_mod_savepoint($result, 2010040105, 'wiki');
}
// Step 6: Migrating versions
if ($result && $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($result, 2010040106, 'wiki');
}
// Step 7: refresh cachedcontent and fill wiki links table
if ($result && $oldversion < 2010040107) {
require_once($CFG->dirroot. '/mod/wiki/locallib.php');
upgrade_set_timeout();
$pages = $DB->get_recordset('wiki_pages');
while ($pages->valid()) {
$page = $pages->current();
wiki_refresh_cachedcontent($page);
$pages->next();
}
$pages->close();
echo $OUTPUT->notification('Caching content', 'notifysuccess');
upgrade_mod_savepoint($result, 2010040107, 'wiki');
}
// Step 8, migrating files
if ($result && $oldversion < 2010040108) {
$fs = get_file_storage();
$sql = "SELECT DISTINCT po.pagename, w.id AS wikiid, po.userid,
po.meta AS filemeta, eo.id AS entryid, eo.groupid, s.id AS subwiki,
w.course AS courseid, cm.id AS cmid
FROM {wiki_pages_old} po
LEFT OUTER JOIN {wiki_entries_old} eo
ON eo.id=po.wiki
LEFT OUTER JOIN {wiki} w
ON w.id = eo.wikiid
LEFT OUTER JOIN {wiki_subwikis} s
ON s.groupid = eo.groupid AND s.wikiid = eo.wikiid AND eo.userid = s.userid
JOIN {modules} m ON m.name = 'wiki'
JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = w.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_readable($thefile)) {
$filerecord = array('contextid' => $context->id,
'filearea' => 'wiki_attachments',
'itemid' => $r->subwiki,
'filepath' => '/',
'filename' => $orgifilename,
'userid' => $r->userid);
if (!$fs->file_exists($context->id, '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, 'wiki_attachments', $r->subwiki, '/', $filename)) {
$filerecord['filename'] = $filename;
echo $OUTPUT->notification('Migrating file '.$filename, 'notifysuccess');
$storedfile = $fs->create_file_from_pathname($filerecord, $thefile);
}
}
}
}
$rs->close();
upgrade_mod_savepoint($result, 2010040108, 'wiki');
}
// Step 9: clean wiki table
if ($result && $oldversion < 2010040109) {
$fields = array('summary', 'pagename', 'wtype', 'ewikiprinttitle', 'htmlmode', 'ewikiacceptbinary', 'disablecamelcase', 'setpageflags', 'strippages', 'removepages', 'revertchanges', 'initialcontent');
$table = new xmldb_table('wiki');
$field = new xmldb_field('wtype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'group', 'pagename');
foreach ($fields as $fieldname) {
$field = new xmldb_field($fieldname);
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
/// Launch change of list of values for field wtype
$dbman->drop_enum_from_field($table, $field);
}
echo $OUTPUT->notification('Cleaning wiki table', 'notifysuccess');
upgrade_mod_savepoint($result, 2010040109, 'wiki');
}
/// wiki savepoint reached
upgrade_mod_savepoint($result, 2009042700, '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 ($result && $oldversion < 2010040120) {
//$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($result, 2010040110, 'wiki');
}
return $result;
}
+303
View File
@@ -0,0 +1,303 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package mod-wiki
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function wiki_add_wiki_fields() {
global $DB;
upgrade_set_timeout();
$dbman = $DB->get_manager();
/// Define table wiki to be created
$table = new xmldb_table('wiki');
// Adding fields to wiki table
$wikitable = new xmldb_table('wiki');
// in MOODLE_20_SABLE branch, summary field is renamed as intro
// so we renamed it back to summary to keep upgrade going as moodle 1.9
$field = new xmldb_field('intro', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null);
if ($dbman->field_exists($wikitable, $field)) {
$dbman->rename_field($wikitable, $field, 'summary');
}
$dbman->add_field($wikitable, $field);
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
if (!$dbman->field_exists($wikitable, $field)) {
$dbman->add_field($wikitable, $field);
}
$field = new xmldb_field('firstpagetitle', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, 'First Page', null);
$dbman->add_field($wikitable, $field);
$field = new xmldb_field('wikimode', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'collaborative', null);
$dbman->add_field($wikitable, $field);
$field = new xmldb_field('defaultformat', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'creole', null);
$dbman->add_field($wikitable, $field);
$field = new xmldb_field('forceformat', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', null);
$dbman->add_field($wikitable, $field);
$field = new xmldb_field('scaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
$dbman->add_field($wikitable, $field);
$field = new xmldb_field('editbegin', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
$dbman->add_field($wikitable, $field);
$field = new xmldb_field('editend', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0', null);
$dbman->add_field($wikitable, $field);
}
/**
* Install wiki 2.0 tables
*/
function wiki_upgrade_install_20_tables() {
global $DB;
upgrade_set_timeout();
$dbman = $DB->get_manager();
/// Define table wiki_subwikis to be created
$table = new xmldb_table('wiki_subwikis');
/// Adding fields to table wiki_subwikis
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('wikiid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
/// Adding keys to table wiki_subwikis
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('wikiidgroupiduserid', XMLDB_KEY_UNIQUE, array('wikiid', 'groupid', 'userid'));
$table->add_key('wikifk', XMLDB_KEY_FOREIGN, array('wikiid'), 'wiki', array('id'));
/// Conditionally launch create table for wiki_subwikis
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
/// Define table wiki_pages to be created
$table = new xmldb_table('wiki_pages');
/// Adding fields to table wiki_pages
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('subwikiid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, 'title');
$table->add_field('cachedcontent', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('timerendered', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('pageviews', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('readonly', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
/// Adding keys to table wiki_pages
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('subwikititleuser', XMLDB_KEY_UNIQUE, array('subwikiid', 'title', 'userid'));
$table->add_key('subwikifk', XMLDB_KEY_FOREIGN, array('subwikiid'), 'wiki_subwiki', array('id'));
/// Conditionally launch create table for wiki_pages
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
/// Define table wiki_versions to be created
$table = new xmldb_table('wiki_versions');
/// Adding fields to table wiki_versions
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('pageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('content', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null);
$table->add_field('contentformat', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'creole');
$table->add_field('version', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
/// Adding keys to table wiki_versions
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('pagefk', XMLDB_KEY_FOREIGN, array('pageid'), 'wiki_pages', array('id'));
/// Conditionally launch create table for wiki_versions
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
/// Define table wiki_synonyms to be created
$table = new xmldb_table('wiki_synonyms');
/// Adding fields to table wiki_synonyms
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('subwikiid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('pageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('pagesynonym', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, 'Pagesynonym');
/// Adding keys to table wiki_synonyms
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('pageidsyn', XMLDB_KEY_UNIQUE, array('pageid', 'pagesynonym'));
/// Conditionally launch create table for wiki_synonyms
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
/// Define table wiki_links to be created
$table = new xmldb_table('wiki_links');
/// Adding fields to table wiki_links
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('subwikiid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('frompageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('topageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('tomissingpage', XMLDB_TYPE_CHAR, '255', null, null, null, null);
/// Adding keys to table wiki_links
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('frompageidfk', XMLDB_KEY_FOREIGN, array('frompageid'), 'wiki_pages', array('id'));
$table->add_key('subwikifk', XMLDB_KEY_FOREIGN, array('subwikiid'), 'wiki_subwiki', array('id'));
/// Conditionally launch create table for wiki_links
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
/// Define table wiki_locks to be created
$table = new xmldb_table('wiki_locks');
/// Adding fields to table wiki_locks
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('pageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('sectionname', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('lockedat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
/// Adding keys to table wiki_locks
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Conditionally launch create table for wiki_locks
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
}
/**
* Migrating wiki pages history
*/
function wiki_upgrade_migrate_versions() {
global $DB, $CFG;
upgrade_set_timeout();
require_once($CFG->dirroot . '/mod/wiki/db/migration/lib.php');
$sql = 'SELECT po.id as oldpage_id, po.pagename as oldpage_pagename, po.version, po.flags, po.content, po.author, po.userid as oldpage_userid, po.created, po.lastmodified, po.refs, po.meta, po.hits, po.wiki, ' .
'p.id as newpage_id, p.subwikiid, p.title, p.cachedcontent, p.timecreated, p.timemodified as newpage_timemodified, p.timerendered, p.userid as newpage_userid, p.pageviews, p.readonly, ' .
'e.id as entry_id, e.wikiid, e.course as entrycourse, e.groupid, e.userid as entry_userid, e.pagename as entry_pagename, e.timemodified as entry_timemodified, ' .
'w.id as wiki_id, w.course as wiki_course, w.name, w.summary as summary, w.pagename as wiki_pagename, w.wtype, w.ewikiprinttitle, w.htmlmode, w.ewikiacceptbinary, w.disablecamelcase, w.setpageflags, w.strippages, w.removepages, w.revertchanges, w.initialcontent, w.timemodified as wiki_timemodified ' .
'FROM {wiki_pages_old} po LEFT OUTER JOIN {wiki_entries_old} e ' .
'ON e.id = po.wiki ' .
'LEFT OUTER JOIN {wiki} w ' .
'ON w.id = e.wikiid ' .
'LEFT OUTER JOIN {wiki_subwikis} s ' .
'ON e.groupid = s.groupid AND e.wikiid = s.wikiid AND e.userid = s.userid ' .
'LEFT OUTER JOIN {wiki_pages} p ' .
'ON po.pagename = p.title AND p.subwikiid = s.id';
$pagesinfo = $DB->get_recordset_sql($sql, array());
while ($pagesinfo->valid()) {
$pageinfo = $pagesinfo->current();
$oldpage = new StdClass();
$oldpage->id = $pageinfo->oldpage_id;
$oldpage->pagename = $pageinfo->oldpage_pagename;
$oldpage->version = $pageinfo->version;
$oldpage->flags = $pageinfo->flags;
$oldpage->content = $pageinfo->content;
$oldpage->author = $pageinfo->author;
$oldpage->userid = $pageinfo->oldpage_userid;
$oldpage->created = $pageinfo->created;
$oldpage->lastmodified = $pageinfo->lastmodified;
$oldpage->refs = $pageinfo->refs;
$oldpage->meta = $pageinfo->meta;
$oldpage->hits = $pageinfo->hits;
$oldpage->wiki = $pageinfo->wiki;
$page = new StdClass();
$page->id = $pageinfo->newpage_id;
$page->subwikiid = $pageinfo->subwikiid;
$page->title = $pageinfo->title;
$page->cachedcontent = $pageinfo->cachedcontent;
$page->timecreated = $pageinfo->timecreated;
$page->timemodified = $pageinfo->newpage_timemodified;
$page->timerendered = $pageinfo->timerendered;
$page->userid = $pageinfo->newpage_userid;
$page->pageviews = $pageinfo->pageviews;
$page->readonly = $pageinfo->readonly;
$entry = new StdClass();
$entry->id = $pageinfo->entry_id;
$entry->wikiid = $pageinfo->wikiid;
$entry->course = $pageinfo->entrycourse;
$entry->groupid = $pageinfo->groupid;
$entry->userid = $pageinfo->entry_userid;
$entry->pagename = $pageinfo->entry_pagename;
$entry->timemodified = $pageinfo->entry_timemodified;
$wiki = new StdClass();
$wiki->id = $pageinfo->wiki_id;
$wiki->course = $pageinfo->wiki_course;
$wiki->name = $pageinfo->name;
$wiki->summary = $pageinfo->summary;
$wiki->pagename = $pageinfo->wiki_pagename;
$wiki->wtype = $pageinfo->wtype;
$wiki->ewikiprinttitle = $pageinfo->ewikiprinttitle;
$wiki->htmlmode = $pageinfo->htmlmode;
$wiki->ewikiacceptbinary = $pageinfo->ewikiacceptbinary;
$wiki->disablecamelcase = $pageinfo->disablecamelcase;
$wiki->setpageflags = $pageinfo->setpageflags;
$wiki->strippages = $pageinfo->strippages;
$wiki->removepages = $pageinfo->removepages;
$wiki->revertchanges = $pageinfo->revertchanges;
$wiki->initialcontent = $pageinfo->initialcontent;
$wiki->timemodified = $pageinfo->wiki_timemodified;
$version = new StdClass();
$version->pageid = $page->id;
$version->content = wiki_ewiki_2_html($entry, $oldpage, $wiki);
$version->contentformat = "html";
$version->version = $oldpage->version;
$version->timecreated = $oldpage->lastmodified;
$version->userid = $oldpage->userid;
if ($version->version == 1) {
// The oldest version of page in moodle 2.0 is 0 which has empty content
// so we need to insert an extra record
$content = $version->content;
$version->version = 0;
$version->content == '';
$DB->insert_record('wiki_versions', $version);
$version->version = 1;
$version->content == $content;
$DB->insert_record('wiki_versions', $version);
} else {
$DB->insert_record('wiki_versions', $version);
}
$pagesinfo->next();
}
$pagesinfo->close();
}
+83
View File
@@ -0,0 +1,83 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains all necessary code to view a diff page
*
* @package mod-wiki-2.0
* @copyrigth 2009 Marc Alier, Jordi Piguillem [email protected]
* @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Jordi Piguillem
* @author Marc Alier
* @author David Jimenez
* @author Josep Arus
* @author Kenneth Riba
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once($CFG->dirroot . '/mod/wiki/lib.php');
require_once($CFG->dirroot . '/mod/wiki/locallib.php');
require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
require_once($CFG->dirroot . '/mod/wiki/diff/difflib.php');
require_once($CFG->dirroot . '/mod/wiki/diff/diff_nwiki.php');
$pageid = required_param('pageid', PARAM_TEXT);
$compare = required_param('compare', PARAM_INT);
$comparewith = required_param('comparewith', PARAM_INT);
if (!$page = wiki_get_page($pageid)) {
print_error('incorrectpageid', 'wiki');
}
if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
print_error('incorrectsubwikiid', 'wiki');
}
if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
print_error('incorrectwikiid', 'wiki');
}
if (!$cm = get_coursemodule_from_instance('wiki', $wiki->id)) {
print_error('invalidcoursemodule');
}
if (!$course = get_course_by_id($cm->course)) {
print_error('coursemisconf');
}
if ($compare >= $comparewith) {
print_error("A page version can only be compared with an older version.");
}
require_course_login($course->id, true, $cm);
add_to_log($course->id, "wiki", "diff", "diff.php?id=$cm->id", "$wiki->id");
$wikipage = new page_wiki_diff($wiki, $subwiki, $cm);
$wikipage->set_page($page);
$wikipage->set_comparison($compare, $comparewith);
$wikipage->print_header();
$wikipage->print_content();
$wikipage->print_footer();
Binary file not shown.

After

Width:  |  Height:  |  Size: 61 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

File diff suppressed because it is too large Load Diff
+728
View File
@@ -0,0 +1,728 @@
<?php
/**
* Standard diff function plus some extras for handling XHTML diffs.
* @copyright &copy; 2007 The Open University
* @author [email protected]
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package ouwiki
*//** */
// Standard diff
////////////////
/**
* Basic diff utility function, using standard diff algorithm.
*
* Based on Bell Laboratories Computing Science Technical Report #41,
* July 1976, Hunt & McIlroy, Appendix A.1 and A.3.
*
* http://www.cs.dartmouth.edu/~doug/diff.ps
*
* @param array $file1 Array of lines in file 1. The first line in the file
* MUST BE INDEX 1 NOT ZERO!!
* @param array $file2 Array of lines in file 2, again starting from 1.
* @return array An array with one entry (again 1-based) for each line in
* file 1, with its corresponding position in file 2 or 0 if it isn't there.
*/
function ouwiki_diff_internal($file1,$file2) {
// Basic variables
$n=count($file2);
$m=count($file1);
// Special-case for empty file2 which otherwise causes error
if($n==0)
{
$result=array();
for($i=1;$i<=$m;$i++)
{
$result[$i]=0;
}
return $result;
}
// Step 1 Build list of elements
/////////
$V=array();
for($j=1;$j<=$n;$j++) {
$V[$j]=new StdClass;
$V[$j]->serial=$j;
$V[$j]->hash=crc32($file2[$j]);
}
// Step 2 Sort by hash,serial
/////////
usort($V,"ouwiki_diff_sort_v");
// Make it start from 1 again
array_unshift($V,'bogus');
unset($V[0]);
// $V is now an array including the line number 'serial' and hash
// of each line in file 2, sorted by hash and then serial.
// Step 3 Equivalence classes
/////////
$E=array();
$E[0]=new StdClass;
$E[0]->serial=0;
$E[0]->last=true;
for($j=1;$j<=$n;$j++) {
$E[$j]=new StdClass;
$E[$j]->serial=$V[$j]->serial;
$E[$j]->last=$j===$n || $V[$j]->hash!==$V[$j+1]->hash;
}
// E is now an array sorted the same way as $V which includes
// the line number 'serial' and whether or not that is the 'last'
// line in the given equivalence class, i.e. set of identical lines
// Step 4 For each line in file1, finds start of equivalence class
/////////
$P=array();
for($i=1;$i<=$m;$i++) {
// Find matching last entry from equivalence list
$P[$i]=ouwiki_diff_find_last($V,$E,crc32($file1[$i]));
}
// P is now an array that finds the index (within $V) of the *first*
// matching line in $V (referencing file 2, but not a line number,
// because sorted in $V order) for each line in file 1. In other words
// if you were to start at the P-value in $V and continue through, you
// would find all the lines from file 2 that are equal to the given line
// from file 1.
// Step 5 Initialise vector of candidates
/////////
// I do not trust PHP references further than I can throw them (preferably
// at the idiot who came up with the idea) so I am using a separate array
// to store candidates and all references are integers into that.
$candidates=array();
$candidates[0]=new StdClass;
$candidates[0]->a=0;
$candidates[0]->b=0;
$candidates[0]->previous=null;
$candidates[1]=new StdClass;
$candidates[1]->a=$m+1;
$candidates[1]->b=$n+1;
$candidates[1]->previous=null;
$K=array();
$K[0]=0; // Ref to candidate 0
$K[1]=1; // Ref to candidate 1
$k=0;
// Step 6 Merge stage
/////////
for($i=1;$i<=$m;$i++) {
if($P[$i]!==0) {
ouwiki_diff_merge($K,$k,$i,$E,$P[$i],$candidates);
}
}
// Step 7
/////////
$J=array();
for($i=1;$i<=$m;$i++) {
$J[$i]=0;
}
// Step 8 Follow candidate chain to make nice representation
/////////
$index=$K[$k];
while(!is_null($index)) {
// Stop when we reach the first, dummy candidate
if($candidates[$index]->a!=0) {
$J[$candidates[$index]->a]=$candidates[$index]->b;
}
$index=$candidates[$index]->previous;
}
// Step 9 Get rid of 'jackpots' (hash collisions)
/////////
for($i=1;$i<=$m;$i++) {
if($J[$i]!=0 && $file1[$i]!=$file2[$J[$i]]) {
$J[$i]=0;
}
}
// Done! (Maybe.)
return $J;
}
// Functions needed by parts of the algorithm
/////////////////////////////////////////////
// Merge, from step 7 (Appendix A.3)
function ouwiki_diff_merge(&$K,&$k,$i,&$E,$p,&$candidates) {
$r=0;
$c=$K[0];
while(true) {
$j=$E[$p]->serial; // Paper says 'i' but this is wrong (OCR)
// Binary search in $K from $r to $k
$min=$r;
$max=$k+1;
while(true) {
$try = (int)(($min+$max)/2);
if($candidates[$K[$try]]->b >= $j) {
$max=$try;
} else if($candidates[$K[$try+1]]->b <= $j) {
$min=$try+1;
} else { // $try is less and $try+1 is more
$s=$try;
break;
}
if($max<=$min) {
$s=-1;
break;
}
}
if($s>-1) {
if($candidates[$K[$s+1]]->b > $j) {
// Create new candidate
$index=count($candidates);
$candidates[$index]=new StdClass;
$candidates[$index]->a=$i;
$candidates[$index]->b=$j;
$candidates[$index]->previous=$K[$s];
$K[$r]=$c;
$r=$s+1;
$c=$index; // Or should this go before?
}
if($s===$k) {
$K[$k+2]=$K[$k+1];
$k++;
break;
}
}
if($E[$p]->last) {
break;
}
$p++;
}
$K[$r]=$c;
}
// From Step 2
function ouwiki_diff_sort_v($a,$b) {
if($a->hash < $b->hash) {
return -1;
} else if($a->hash > $b->hash) {
return 1;
} else if($a->serial < $b->serial) {
return -1;
} else if($a->serial > $b->serial) {
return 1;
} else {
return 0;
}
}
// From Step 4
function ouwiki_diff_find_last(&$V,&$E,$hash) {
// Binary search in $V until we find something with $hash
// Min = 1, array is 1-indexed
$min=1;
// Max = 1 higher than highest key
end($V);
$max=key($V)+1;
while(true) {
$try = (int)(($min+$max)/2);
if($V[$try]->hash > $hash) {
$max=$try;
} else if($V[$try]->hash < $hash) {
$min=$try+1;
} else { // Equal
break;
}
if($max<=$min) {
// No matching line
return 0;
}
}
// Now check back in $E to find the first line of that equivalence class
for($j=$try;!$E[$j-1]->last;$j--) ;
return $j;
}
///////////////////////////
/**
* Class representing one 'line' of HTML content for the purpose of
* text comparison.
*/
class ouwiki_line {
/** Array of ouwiki_words */
var $words=array();
/**
* Construct line object based on a chunk of text.
* @param string $data Text data that makes up this 'line'. (May include line breaks etc.)
* @param int $linepos Position number for first character in text
*/
function ouwiki_line($data,$linepos) {
// 1. Turn things we don't want into spaces (so that positioning stays same)
// Whitespace replaced with space
$data=preg_replace('/\s/',' ',$data);
// Various ways of writing non-breaking space replaced with space
// Note that using a single param for replace only works because all
// the search strings are 6 characters long
$data=str_replace(array('&nbsp;','&#xA0;','&#160;'),' ',$data);
// Tags replaced with equal number of spaces
$data=preg_replace_callback('/<.*?'.'>/',create_function(
'$matches','return preg_replace("/./"," ",$matches[0]);'),$data);
// 2. Analyse string so that each space-separated thing
// is counted as a 'word' (note these may not be real words,
// for instance words may include punctuation at either end)
$pos=0;
while(true) {
// Find a non-space
for(;$pos < strlen($data) && substr($data,$pos,1)===' ';$pos++) ;
if($pos==strlen($data)) {
// No more content
break;
}
// Aaaand find the next space after that
$space2=strpos($data,' ',$pos);
if($space2===false) {
// No more spaces? Everything left must be a word
$this->words[]=new ouwiki_word(substr($data,$pos),$pos+$linepos);
break;
} else {
$this->words[]=new ouwiki_word(substr($data,$pos,$space2-$pos),$pos+$linepos);
$pos=$space2;
}
}
}
/**
* @return string Normalised string representation of this line object
*/
function get_as_string() {
$result='';
foreach($this->words as $word) {
if($result!=='') {
$result.=' ';
}
$result.=$word->word;
}
return $result;
}
/**
* Static function converts lines to strings.
* @param array $lines Array of ouwiki_line
* @return array Array of strings
*/
function get_as_strings($lines) {
$strings=array();
foreach($lines as $key=>$value) {
$strings[$key]=$value->get_as_string();
}
return $strings;
}
/**
* @return True if there are no words in the line
*/
function is_empty() {
return count($this->words)===0;
}
}
/**
* Represents single word for html comparison. Note that words
* are just chunks of plain text and may not be actual words;
* they could include punctuation or (if there was e.g. a span
* in the middle of something) even be part-words.
*/
class ouwiki_word {
/** Word as plain string */
var $word;
/** Start position in original xhtml */
var $start;
function ouwiki_word($word,$start) {
$this->word=$word;
$this->start=$start;
}
}
/**
* Prepares XHTML content for text difference comparison.
* @param string $content XHTML content [NO SLASHES]
* @return array Array of ouwiki_line objects
*/
function ouwiki_diff_html_to_lines($content) {
// These functions are a pain mostly because PHP preg_* don't provide
// proper information as to the start/end position of matches. As a
// consequence there is a lot of hackery going down. At every point we
// replace things with spaces rather than getting rid, in order to store
// positions within original content.
// Get rid of all script, style, object tags (that might contain non-text
// outside tags)
$content=preg_replace_callback(
'^(<script .*?</script>)|(<object .*?</object>)|(<style .*?</style>)^i',create_function(
'$matches','return preg_replace("/./"," ",$matches[0]);'),$content);
// Get rid of all ` symbols as we are going to use these for a marker later.
$content=preg_replace('/[`]/',' ',$content);
// Put line breaks on block tags. Mark each line break with ` symbol
$blocktags=array('p','div','h1','h2','h3','h4','h5','h6','td','li');
$taglist='';
foreach($blocktags as $blocktag) {
if($taglist!=='') {
$taglist.='|';
}
$taglist.="<$blocktag>|<\\/$blocktag>";
}
$content=preg_replace_callback('/(('.$taglist.')\s*)+/i',create_function(
'$matches','return "`".preg_replace("/./"," ",substr($matches[0],1));'),$content);
// Now go through splitting each line
$lines=array(); $index=1;
$pos=0;
while($pos<strlen($content)) {
$nextline=strpos($content,'`',$pos);
if($nextline===false) {
// No more line breaks? Take content to end
$nextline=strlen($content);
}
$linestr=substr($content,$pos,$nextline-$pos);
$line=new ouwiki_line($linestr,$pos);
if(!$line->is_empty()) {
$lines[$index++]=$line;
}
$pos=$nextline+1;
}
return $lines;
}
/**
* Represents a changed area of file and where it is located in the
* two source files.
*/
class ouwiki_change_range {
var $file1start,$file1count;
var $file2start,$file2count;
}
/**
* A more logical representation of the results from ouwiki_internal_diff()
*/
class ouwiki_changes {
/** Array of indexes (in file 2) of added lines */
var $adds;
/** Array of indexes (in file 1) of deleted lines */
var $deletes;
/** Array of changed ranges */
var $changes;
/**
* @param array $diff Array from line indices in file1
* to indices in file2. All indices 1-based.
* @param int $count2 Number of lines in file2
*/
function ouwiki_changes($diff,$count2) {
// Find deleted lines
$this->deletes=self::internal_find_deletes($diff,$count2);
// Added lines work the same way after the comparison is
// reversed.
$this->adds=self::internal_find_deletes(
ouwiki_diff_internal_flip($diff,$count2),count($diff));
// Changed ranges are all the other lines from file 1 that
// weren't found in file 2 but aren't deleted, and the
// corresponding lines from file 2 (between the equivalent
// 'found' lines).
$this->changes=array();
$matchbefore=0;
$inrange=-1; $lastrange=-1;
foreach($diff as $index1=>$index2) {
// Changed line if this isn't in 'deleted' section and
// doesn't have a match in file2.
if($index2===0 && !in_array($index1,$this->deletes)) {
if($inrange===-1) {
// Not already in a range, start a new one at array end
$inrange=count($this->changes);
$this->changes[$inrange]=new ouwiki_change_range;
$this->changes[$inrange]->file1start=$index1;
$this->changes[$inrange]->file1count=1;
$this->changes[$inrange]->file2start=$matchbefore+1; // Last valid from file2
$this->changes[$inrange]->file2count=0;
$lastrange=$inrange;
} else {
// One more line that gets added to the range
$this->changes[$inrange]->file1count++;
}
} else {
// Not in a range any more
$inrange=-1;
// If we have a line match...
if($index2!==0) {
// Remember this line as next range must start after it
$matchbefore=$index2;
// If last range is still looking for a number, fill that in too
if($lastrange!==-1) {
$this->changes[$lastrange]->file2count=$index2
-$this->changes[$lastrange]->file2start;
$lastrange=-1;
}
}
}
}
// Unfinished range in file2 gets end of file
if($lastrange!==-1) {
$this->changes[$lastrange]->file2count=$count2
-$this->changes[$lastrange]->file2start+1;
}
}
/**
* Find deleted lines. These are lines in file1 that
* cannot be present even in modified form in file2
* because we have matching lines around them.
* O(n) algorithm.
* @param array $diff Array of file1->file2 indexes
* @param int $count2 Count of lines in file2
*/
function internal_find_deletes($diff,$count2) {
$deletes=array();
// 1. Create a new array that includes the lowest-valued
// index2 value below each run of 0s.
// I.e. if our array is say 1,2,0,0,0,3,0 then the
// resulting array will be -,-,3,3,3,-,0
$squidges=array();
$lowest=0;
for($index1=count($diff);$index1>=1;$index1--) {
$index2=$diff[$index1];
if($index2===0) {
$squidges[$index1]=$lowest;
} else {
$lowest=$index2;
}
}
// 2. OK now we can use this new array to work out
// items that are known to be deleted because we
// have matching items either side
$highest=0;
foreach($diff as $index1=>$index2) {
if($index2===0) {
if($highest===$count2 || $highest+1===$squidges[$index1]) {
// Yep! Definitely deleted.
$deletes[]=$index1;
}
} else {
$highest=$index2;
}
}
return $deletes;
}
}
/**
* Flips around the array returned by ouwiki_diff_internal
* so that it refers to lines from the other file.
* @param array $diff Array of index1=>index2
* @param int $count2 Count of lines in file 2
* @return array Flipped version
*/
function ouwiki_diff_internal_flip($diff,$count2) {
$flip=array();
for($i=1;$i<=$count2;$i++) {
$flip[$i]=0;
}
foreach($diff as $index1=>$index2) {
if($index2!==0) {
$flip[$index2]=$index1;
}
}
return $flip;
}
/**
* Compares two files based initially on lines and then on words within the lines that
* differ.
* @param array $lines1 Array of ouwiki_line
* @param array $lines2 Array of ouwiki_line
* @return array (deleted,added); deleted and added are arrays of ouwiki_word with
* position numbers from $lines1 and $lines2 respectively
*/
function ouwiki_diff_words($lines1,$lines2) {
// Prepare arrays
$deleted=array();
$added=array();
// Get line difference
$linediff=ouwiki_diff(
ouwiki_line::get_as_strings($lines1),
ouwiki_line::get_as_strings($lines2));
// Handle lines that were entirely deleted
foreach($linediff->deletes as $deletedline) {
$deleted = array_merge($deleted, $lines1[$deletedline]->words);
}
// And ones that were entirely added
foreach($linediff->adds as $addedline) {
$added = array_merge($added, $lines2[$addedline]->words);
}
// Changes get diffed at the individual-word level
foreach($linediff->changes as $changerange) {
// Build list of all words in each side of the range
$file1words=array();
for($index=$changerange->file1start;
$index<$changerange->file1start+$changerange->file1count;$index++) {
foreach($lines1[$index]->words as $word) {
$file1words[]=$word;
}
}
$file2words=array();
for($index=$changerange->file2start;
$index<$changerange->file2start+$changerange->file2count;$index++) {
foreach($lines2[$index]->words as $word) {
$file2words[]=$word;
}
}
// Make arrays 1-based
array_unshift($file1words,'dummy');
unset($file1words[0]);
array_unshift($file2words,'dummy');
unset($file2words[0]);
// Convert word lists into plain strings
$file1strings=array();
foreach($file1words as $index=>$word) {
$file1strings[$index]=$word->word;
}
$file2strings=array();
foreach($file2words as $index=>$word) {
$file2strings[$index]=$word->word;
}
// Run diff on strings
$worddiff=ouwiki_diff($file1strings,$file2strings);
foreach($worddiff->adds as $index) {
$added[]=$file2words[$index];
}
foreach($worddiff->deletes as $index) {
$deleted[]=$file1words[$index];
}
foreach($worddiff->changes as $changerange) {
for($index=$changerange->file1start;
$index<$changerange->file1start+$changerange->file1count;$index++) {
$deleted[]=$file1words[$index];
}
for($index=$changerange->file2start;
$index<$changerange->file2start+$changerange->file2count;$index++) {
$added[]=$file2words[$index];
}
}
}
return array($deleted,$added);
}
/**
* Runs diff and interprets results into ouwiki_changes object.
* @param array $file1 Array of lines in file 1. The first line in the file
* MUST BE INDEX 1 NOT ZERO!!
* @param array $file2 Array of lines in file 2, again starting from 1.
* @return ouwiki_changes Object describing changes
*/
function ouwiki_diff($file1,$file2) {
return new ouwiki_changes(ouwiki_diff_internal($file1,$file2),count($file2));
}
/**
* Adds HTML span elements to $html around the words listed in $words.
* @param string $html HTML content
* @param array $words Array of ouwiki_word to mark
* @param string $markerclass Name of class for span element
* @return HTML with markup added
*/
function ouwiki_diff_add_markers($html,$words,$markerclass,$beforetext,$aftertext) {
// Sort words by start position
usort($words, create_function('$a,$b','return $a->start-$b->start;'));
// Add marker for each word. We use an odd tag name which will
// be replaced by span later, this for ease of replacing
$spanstart="<ouwiki_diff_add_markers>";
$pos=0;
$result='';
foreach($words as $word) {
// Add everything up to the word
$result.=substr($html,$pos,$word->start-$pos);
// Add word
$result.=$spanstart.$word->word.'</ouwiki_diff_add_markers>';
// Update position
$pos=$word->start+strlen($word->word);
}
// Add everything after last word
$result.=substr($html,$pos);
// If we end a marker then immediately start one, get rid of
// both the end and start
$result=preg_replace('^</ouwiki_diff_add_markers>(\s*)<ouwiki_diff_add_markers>^','$1',$result);
// Turn markers into proper span
$result=preg_replace('^<ouwiki_diff_add_markers>^',$beforetext.'<span class="'.$markerclass.'">',$result);
$result=preg_replace('^</ouwiki_diff_add_markers>^','</span>'.$aftertext,$result);
return $result;
}
/**
* Compares two HTML files. (This is the main function that everything else supports.)
* @param string $html1 XHTML for file 1
* @param string $html2 XHTML for file 2
* @return array ($result1,$result2) to be displayed indicating the differences
*/
function ouwiki_diff_html($html1,$html2) {
$lines1=ouwiki_diff_html_to_lines($html1);
$lines2=ouwiki_diff_html_to_lines($html2);
list($deleted,$added)=ouwiki_diff_words($lines1,$lines2);
$result1=ouwiki_diff_add_markers($html1,$deleted,'ouw_deleted',
'<strong class="accesshide">'.get_string('deletedbegins','wiki').'</strong>',
'<strong class="accesshide">'.get_string('deletedends','wiki').'</strong>');
$result2=ouwiki_diff_add_markers($html2,$added,'ouw_added',
'<strong class="accesshide">'.get_string('addedbegins','wiki').'</strong>',
'<strong class="accesshide">'.get_string('addedends','wiki').'</strong>');
return array($result1,$result2);
}
+138
View File
@@ -0,0 +1,138 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains all necessary code to edit a wiki page
*
* @package mod-wiki-2.0
* @copyrigth 2009 Marc Alier, Jordi Piguillem [email protected]
* @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Jordi Piguillem
* @author Marc Alier
* @author David Jimenez
* @author Josep Arus
* @author Kenneth Riba
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once($CFG->dirroot . '/mod/wiki/lib.php');
require_once($CFG->dirroot . '/mod/wiki/locallib.php');
require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
$pageid = required_param('pageid', PARAM_INT);
$contentformat = optional_param('contentformat', '', PARAM_ALPHA);
$option = optional_param('editoption', '', PARAM_TEXT);
$section = optional_param('section', "", PARAM_TEXT);
$version = optional_param('version', -1, PARAM_INT);
$newcontent = optional_param('newcontent', '', PARAM_CLEANHTML);
$attachments = optional_param('attachments', 0, PARAM_INT);
$deleteuploads = optional_param('deleteuploads', 0, PARAM_RAW);
if (!$page = wiki_get_page($pageid)) {
print_error('incorrectpageid', 'wiki');
}
if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
print_error('incorrectsubwikiid', 'wiki');
}
if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
print_error('incorrectwikiid', 'wiki');
}
if (!$cm = get_coursemodule_from_instance('wiki', $wiki->id)) {
print_error('invalidcoursemodule');
}
if (!$course = get_course_by_id($cm->course)) {
print_error('coursemisconf');
}
if (!empty($section) && !$sectioncontent = wiki_get_section_page($page, $section)) {
print_error('invalidsection', 'wiki');
}
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:editpage', $context);
add_to_log($course->id, 'wiki', 'edit', "edit.php?id=$cm->id", "$wiki->id");
if ($option == get_string('save', 'wiki')) {
if (!confirm_sesskey()) {
print_error(get_string('invalidsesskey', 'wiki'));
}
$wikipage = new page_wiki_save($wiki, $subwiki, $cm);
$wikipage->set_page($page);
$wikipage->set_newcontent($newcontent);
$wikipage->set_upload(true);
} else {
if ($option == get_string('preview')) {
if (!confirm_sesskey()) {
print_error(get_string('invalidsesskey', 'wiki'));
}
$wikipage = new page_wiki_preview($wiki, $subwiki, $cm);
$wikipage->set_page($page);
$wikipage->set_newcontent($newcontent);
} else {
if ($option == get_string('cancel')) {
//delete lock
wiki_delete_locks($page->id, $USER->id, $section);
redirect($CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $pageid);
} else {
$wikipage = new page_wiki_edit($wiki, $subwiki, $cm);
$wikipage->set_page($page);
$wikipage->set_upload($option == get_string('upload', 'wiki'));
}
}
if (has_capability('mod/wiki:overridelock', $context)) {
$wikipage->set_overridelock(true);
}
}
if ($version >= 0) {
$wikipage->set_versionnumber($version);
}
if (!empty($section)) {
$wikipage->set_section($sectioncontent, $section);
}
if (!empty($attachments)) {
$wikipage->set_attachments($attachments);
}
if (!empty($deleteuploads)) {
$wikipage->set_deleteuploads($deleteuploads);
}
if (!empty($contentformat)) {
$wikipage->set_format($contentformat);
}
$wikipage->print_header();
$wikipage->print_content();
$wikipage->print_footer();
+95
View File
@@ -0,0 +1,95 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains all necessary code to define and process an edit form
*
* @package mod-wiki-2.0
* @copyrigth 2009 Marc Alier, Jordi Piguillem [email protected]
* @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Josep Arus
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot . "/mod/wiki/editors/wikieditor.php");
require_once($CFG->dirroot . "/mod/wiki/editors/wikifiletable.php");
class mod_wiki_edit_form extends moodleform {
protected function definition() {
global $CFG;
$mform =& $this->_form;
$version = $this->_customdata['version'];
$format = $this->_customdata['format'];
if ($format != 'html') {
$contextid = $this->_customdata['contextid'];
$filearea = $this->_customdata['filearea'];
$fileitemid = $this->_customdata['fileitemid'];
}
//editor
$mform->addElement('header', 'general', get_string('general'));
if ($format != 'html') {
$mform->addElement('wikieditor', 'newcontent', get_string('content'), array('cols' => 50, 'rows' => 20, 'wiki_format' => $format));
} else {
$mform->addElement('editor', 'newcontent_editor', get_string('content'), null, page_wiki_edit::$attachmentoptions);
}
//hiddens
if ($version >= 0) {
$mform->addElement('hidden', 'version');
$mform->setDefault('version', $version);
}
$mform->addElement('hidden', 'contentformat');
$mform->setDefault('contentformat', $format);
if ($format != 'html') {
//uploads
$mform->addElement('header', 'attachments_tags', get_string('attachments', 'wiki'));
$mform->addElement('filemanager', 'attachments', get_string('attachments', 'wiki'), null, page_wiki_edit::$attachmentoptions);
$fileinfo = array(
'contextid'=>$contextid,
'filearea'=>$filearea,
'itemid'=>$fileitemid,
);
$mform->addElement('wikifiletable', 'deleteuploads', get_string('wikifiletable', 'wiki'), null, $fileinfo, $format);
$mform->addElement('submit', 'editoption', get_string('upload', 'wiki'), array('id' => 'tags'));
}
if (!empty($CFG->usetags)) {
$mform->addElement('header', 'tagshdr', get_string('tags', 'tag'));
$mform->addElement('tags', 'tags', get_string('tags'));
}
$buttongroup = array();
$buttongroup[] =& $mform->createElement('submit', 'editoption', get_string('save', 'wiki'), array('id' => 'save'));
$buttongroup[] =& $mform->createElement('submit', 'editoption', get_string('preview'), array('id' => 'preview'));
$buttongroup[] =& $mform->createElement('submit', 'editoption', get_string('cancel'), array('id' => 'cancel'));
$mform->addGroup($buttongroup, 'buttonar', '', array(' '), false);
$mform->closeHeaderBefore('buttonar');
}
}
+72
View File
@@ -0,0 +1,72 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
*
* @package mod-wiki-2.0
* @copyrigth 2009 Marc Alier, Jordi Piguillem [email protected]
* @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Jordi Piguillem
* @author Marc Alier
* @author David Jimenez
* @author Josep Arus
* @author Daniel Serrano
* @author Kenneth Riba
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once($CFG->dirroot . '/mod/wiki/locallib.php');
require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
$pageid = required_param('pageid', PARAM_INT);
$action = optional_param('action', '', PARAM_ACTION);
$commentid = optional_param('commentid', 0, PARAM_INT);
if (!$page = wiki_get_page($pageid)) {
print_error('incorrectpageid', 'wiki');
}
if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
print_error('incorrectsubwikiid', 'wiki');
}
if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) {
print_error('invalidcoursemodule');
}
if (!$course = get_course_by_id($cm->course)) {
print_error('coursemisconf');
}
if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
print_error('incorrectwikiid', 'wiki');
}
require_course_login($course->id, true, $cm);
$editcomments = new page_wiki_editcomment($wiki, $subwiki, $cm);
$comment = new stdClass();
if ($action == 'edit') {
if (!$comment = $DB->get_record('comments', array('id' => $commentid))) {
print_error('invalidcomment');
}
}
$editcomments->set_page($page);
$editcomments->set_action($action, $comment);
$editcomments->print_header();
$editcomments->print_content();
$editcomments->print_footer();
+34
View File
@@ -0,0 +1,34 @@
<?php
/**
* This file defines a simple editor
*
* @author Jordi Piguillem
* @author Josep Arus
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package wiki
*
*/
/**
* @TODO: Doc this function
*/
function wiki_print_editor_html($pageid, $content, $version = -1, $section = null, $upload = false, $deleteuploads = array()) {
global $CFG, $OUTPUT;
$OUTPUT->heading(strtoupper(get_string('formathtml', 'wiki')));
$action = $CFG->wwwroot.'/mod/wiki/edit.php?pageid='.$pageid;
if (!empty($section)) {
$action .= "&section=".urlencode($section);
}
print_container_start(false, 'mdl-align');
echo '<form method="post" action="'.$action.'">';
print_container(print_textarea(true, 20, 100, 0, 0, "newcontent", $content, 0, true, '', 'form-textarea-advanced'), false, 'wiki_editor');
wiki_print_edit_form_default_fields('html', $pageid, $version, $upload, $deleteuploads);
echo '</form>';
print_container_end();
}
+82
View File
@@ -0,0 +1,82 @@
// Wikipedia JavaScript support functions
// if this is true, the toolbar will no longer overwrite the infobox when you move the mouse over individual items
var noOverwrite=false;
var alertText;
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
&& (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
var is_safari = ((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1));
var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
if (clientPC.indexOf('opera')!=-1) {
var is_opera = true;
var is_opera_preseven = (window.opera && !document.childNodes);
var is_opera_seven = (window.opera && document.childNodes);
}
// apply tagOpen/tagClose to selection in textarea,
// use sampleText instead of selection if there is none
// copied and adapted from phpBB
function insertTags(tagOpen, tagClose, sampleText) {
tagOpen = unescape(tagOpen);
tagClose = unescape(tagClose);
var txtarea = document.forms['mform1'].newcontent;
// IE
if(document.selection && !is_gecko) {
var theSelection = document.selection.createRange().text;
if(!theSelection) { theSelection=sampleText;}
txtarea.focus();
if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
theSelection = theSelection.substring(0, theSelection.length - 1);
document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
} else {
document.selection.createRange().text = tagOpen + theSelection + tagClose;
}
// Mozilla
} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
var startPos = txtarea.selectionStart;
var endPos = txtarea.selectionEnd;
var scrollTop=txtarea.scrollTop;
var myText = (txtarea.value).substring(startPos, endPos);
if(!myText) { myText=sampleText;}
if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
} else {
subst = tagOpen + myText + tagClose;
}
txtarea.value = txtarea.value.substring(0, startPos) + subst +
txtarea.value.substring(endPos, txtarea.value.length);
txtarea.focus();
var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
txtarea.selectionStart=cPos;
txtarea.selectionEnd=cPos;
txtarea.scrollTop=scrollTop;
// All others
} else {
var copy_alertText=alertText;
var re1=new RegExp("\\$1","g");
var re2=new RegExp("\\$2","g");
copy_alertText=copy_alertText.replace(re1,sampleText);
copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);
var text;
if (sampleText) {
text=prompt(copy_alertText);
} else {
text="";
}
if(!text) { text=sampleText;}
text=tagOpen+text+tagClose;
document.infoform.infobox.value=text;
// in Safari this causes scrolling
if(!is_safari) {
txtarea.focus();
}
noOverwrite=true;
}
// reposition cursor if possible
if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

+82
View File
@@ -0,0 +1,82 @@
<?php
/**
* This file defines a simple editor
*
* @author Jordi Piguillem
* @author Kenneth Riba
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package wiki
*
*/
/**
* Printing wiki editor.
* Depending on where it is called , action will go to different destinations.
* If it is called from comments section, the return will be in comments section
* in any other case it will be in edit view section.
* @param $pageid. Current pageid
* @param $content. Content to be edited.
* @param $section. Current section, default null
* @param $comesfrom. Information about where the function call is made
* @param commentid. id comment of comment that will be edited.
*/
function wiki_print_editor_wiki($pageid, $content, $editor, $version = -1, $section = null, $upload = false, $deleteuploads = array(), $comesfrom = 'editorview', $commentid = 0) {
global $CFG, $OUTPUT, $PAGE;
if ($comesfrom == 'fromcomments') {
$action = $CFG->wwwroot . '/mod/wiki/instancecomments.php?pageid=' . $pageid . '&id=' . $commentid . '&action=edit';
} else {
$action = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $pageid;
}
if (!empty($section)) {
$action .= "&amp;section=" . urlencode($section);
}
///Get tags for every element we are displaying
$tag = wiki_parser_get_token($editor, 'bold');
$wiki_editor['bold'] = array('ed_bold.gif', get_string('wikiboldtext', 'wiki'), $tag[0], $tag[1], get_string('wikiboldtext', 'wiki'));
$tag = wiki_parser_get_token($editor, 'italic');
$wiki_editor['italic'] = array('ed_italic.gif', get_string('wikiitalictext', 'wiki'), $tag[0], $tag[1], get_string('wikiitalictext', 'wiki'));
$tag = wiki_parser_get_token($editor, 'link');
$wiki_editor['internal'] = array('ed_internal.gif', get_string('wikiinternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiinternalurl', 'wiki'));
$tag = wiki_parser_get_token($editor, 'url');
$wiki_editor['external'] = array('ed_external.gif', get_string('wikiexternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiexternalurl', 'wiki'));
$tag = wiki_parser_get_token($editor, 'list');
$wiki_editor['u_list'] = array('ed_ul.gif', get_string('wikiunorderedlist', 'wiki'), '\\n' . $tag[0], '', '');
$wiki_editor['o_list'] = array('ed_ol.gif', get_string('wikiorderedlist', 'wiki'), '\\n' . $tag[1], '', '');
$tag = wiki_parser_get_token($editor, 'image');
$wiki_editor['image'] = array('ed_img.gif', get_string('wikiimage', 'wiki'), $tag[0], $tag[1], get_string('wikiimage', 'wiki'));
$tag = wiki_parser_get_token($editor, 'header');
$wiki_editor['h1'] = array('ed_h1.gif', get_string('wikiheader', 'wiki', 1), '\\n' . $tag . ' ', ' ' . $tag . '\\n', get_string('wikiheader', 'wiki', 1));
$wiki_editor['h2'] = array('ed_h2.gif', get_string('wikiheader', 'wiki', 2), '\\n' . $tag . $tag . ' ', ' ' . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 2));
$wiki_editor['h3'] = array('ed_h3.gif', get_string('wikiheader', 'wiki', 3), '\\n' . $tag . $tag . $tag . ' ', ' ' . $tag . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 3));
$tag = wiki_parser_get_token($editor, 'line_break');
$wiki_editor['hr'] = array('ed_hr.gif', get_string('wikihr', 'wiki'), '\\n' . $tag . '\\n', '', '');
$tag = wiki_parser_get_token($editor, 'nowiki');
$wiki_editor['nowiki'] = array('ed_nowiki.gif', get_string('wikinowikitext', 'wiki'), $tag[0], $tag[1], get_string('wikinowikitext', 'wiki'));
$OUTPUT->heading(strtoupper(get_string('format' . $editor, 'wiki')));
$PAGE->requires->js('/mod/wiki/editors/wiki/buttons.js');
echo $OUTPUT->container_start('mdl-align');
foreach ($wiki_editor as $button) {
echo "<a href=\"javascript:insertTags";
echo "('" . $button[2] . "','" . $button[3] . "','" . $button[4] . "');\">";
echo "<img width=\"23\" height=\"22\" src=\"$CFG->wwwroot/mod/wiki/editors/wiki/images/$button[0]\" alt=\"" . $button[1] . "\" title=\"" . $button[1] . "\" />";
echo "</a>";
}
echo $OUTPUT->container_end();
echo $OUTPUT->container_start('mdl-align');
echo '<form method="post" id="wikiform" action="' . $action . '">';
echo $OUTPUT->container(print_textarea(false, 20, 60, 0, 0, "newcontent", $content, 0, true), false, 'wiki_editor');
echo $OUTPUT->container_start();
wiki_print_edit_form_default_fields($editor, $pageid, $version, $upload, $deleteuploads);
echo $OUTPUT->container_end();
echo '</form>';
echo $OUTPUT->container_end();
}
+141
View File
@@ -0,0 +1,141 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains all necessary code to define a wiki editor
*
* @package mod-wiki-2.0
* @copyrigth 2009 Marc Alier, Jordi Piguillem [email protected]
* @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Josep Arus
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot.'/lib/formslib.php');
require_once($CFG->dirroot.'/lib/form/textarea.php');
class MoodleQuickForm_wikieditor extends MoodleQuickForm_textarea {
function MoodleQuickForm_wikieditor($elementName = null, $elementLabel = null, $attributes = null) {
if (isset($attributes['wiki_format'])) {
$this->wikiformat = $attributes['wiki_format'];
unset($attributes['wiki_format']);
}
parent::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes);
}
function setWikiFormat($wikiformat) {
$this->wikiformat = $wikiformat;
}
function toHtml() {
$textarea = parent::toHtml();
return $this->{
$this->wikiformat."Editor"}
($textarea);
}
function creoleEditor($textarea) {
return $this->printWikiEditor($textarea);
}
function nwikiEditor($textarea) {
return $this->printWikiEditor($textarea);
}
private function printWikiEditor($textarea) {
global $OUTPUT;
$textarea = $OUTPUT->container_start().$textarea.$OUTPUT->container_end();
$buttons = $this->getButtons();
return $buttons.$textarea;
}
private function getButtons() {
global $PAGE, $CFG;
$editor = $this->wikiformat;
$tag = $this->getTokens($editor, 'bold');
$wiki_editor['bold'] = array('ed_bold.gif', get_string('wikiboldtext', 'wiki'), $tag[0], $tag[1], get_string('wikiboldtext', 'wiki'));
$tag = $this->getTokens($editor, 'italic');
$wiki_editor['italic'] = array('ed_italic.gif', get_string('wikiitalictext', 'wiki'), $tag[0], $tag[1], get_string('wikiitalictext', 'wiki'));
$tag = $this->getTokens($editor, 'link');
$wiki_editor['internal'] = array('ed_internal.gif', get_string('wikiinternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiinternalurl', 'wiki'));
$tag = $this->getTokens($editor, 'url');
$wiki_editor['external'] = array('ed_external.gif', get_string('wikiexternalurl', 'wiki'), $tag, "", get_string('wikiexternalurl', 'wiki'));
$tag = $this->getTokens($editor, 'list');
$wiki_editor['u_list'] = array('ed_ul.gif', get_string('wikiunorderedlist', 'wiki'), '\\n'.$tag[0], '', '');
$wiki_editor['o_list'] = array('ed_ol.gif', get_string('wikiorderedlist', 'wiki'), '\\n'.$tag[1], '', '');
$tag = $this->getTokens($editor, 'image');
$wiki_editor['image'] = array('ed_img.gif', get_string('wikiimage', 'wiki'), $tag[0], $tag[1], get_string('wikiimage', 'wiki'));
$tag = $this->getTokens($editor, 'header');
$wiki_editor['h1'] = array('ed_h1.gif', get_string('wikiheader', 'wiki', 1), '\\n'.$tag.' ', ' '.$tag.'\\n', get_string('wikiheader', 'wiki', 1));
$wiki_editor['h2'] = array('ed_h2.gif', get_string('wikiheader', 'wiki', 2), '\\n'.$tag.$tag.' ', ' '.$tag.$tag.'\\n', get_string('wikiheader', 'wiki', 2));
$wiki_editor['h3'] = array('ed_h3.gif', get_string('wikiheader', 'wiki', 3), '\\n'.$tag.$tag.$tag.' ', ' '.$tag.$tag.$tag.'\\n', get_string('wikiheader', 'wiki', 3));
$tag = $this->getTokens($editor, 'line_break');
$wiki_editor['hr'] = array('ed_hr.gif', get_string('wikihr', 'wiki'), '\\n'.$tag.'\\n', '', '');
$tag = $this->getTokens($editor, 'nowiki');
$wiki_editor['nowiki'] = array('ed_nowiki.gif', get_string('wikinowikitext', 'wiki'), $tag[0], $tag[1], get_string('wikinowikitext', 'wiki'));
$PAGE->requires->js('/mod/wiki/editors/wiki/buttons.js');
$html = "";
foreach ($wiki_editor as $button) {
$html .= "<a href=\"javascript:insertTags";
$html .= "('".$button[2]."','".$button[3]."','".$button[4]."');\">";
$html .= "<img width=\"23\" height=\"22\" src=\"$CFG->wwwroot/mod/wiki/editors/wiki/images/$button[0]\" alt=\"".$button[1]."\" title=\"".$button[1]."\" />";
$html .= "</a>";
}
return $html;
}
private function getTokens($format, $token) {
$tokens = wiki_parser_get_token($format, $token);
if (is_array($tokens)) {
foreach ($tokens as & $t) {
$this->escapeToken($t);
}
} else {
$this->escapeToken($tokens);
}
return $tokens;
}
private function escapeToken(&$token) {
$token = urlencode(str_replace("'", "\'", $token));
}
}
//register wikieditor
MoodleQuickForm::registerElementType('wikieditor', $CFG->dirroot."/mod/wiki/editors/wikieditor.php", 'MoodleQuickForm_wikieditor');
+138
View File
@@ -0,0 +1,138 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains all necessary code to define a wiki file table form element
*
* @package mod-wiki-2.0
* @copyrigth 2009 Marc Alier, Jordi Piguillem [email protected]
* @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Josep Arus
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('HTML/QuickForm/element.php');
require_once($CFG->dirroot.'/lib/filelib.php');
class MoodleQuickForm_wikifiletable extends HTML_QuickForm_element {
private $_contextid;
private $_filearea;
private $_fileareaitemid;
private $_fileinfo;
private $_value = array();
function MoodleQuickForm_wikifiletable($elementName = null, $elementLabel = null, $attributes = null, $fileinfo = null, $format = null) {
parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
$this->_fileinfo = $fileinfo;
$this->_format = $format;
}
function onQuickFormEvent($event, $arg, &$caller) {
global $OUTPUT;
switch ($event) {
case 'addElement':
$this->_contextid = $arg[3]['contextid'];
$this->_filearea = $arg[3]['filearea'];
$this->_fileareaitemid = $arg[3]['itemid'];
$this->_format = $arg[4];
break;
}
return parent::onQuickFormEvent($event, $arg, $caller);
}
function setName($name) {
$this->updateAttributes(array('name' => $name));
}
function getName() {
return $this->getAttribute('name');
}
function setValue($value) {
$this->_value = $value;
}
function getValue() {
return $this->_value;
}
function toHtml() {
global $CFG, $OUTPUT;
$htmltable = new html_table();
$htmltable->head = array(get_string('deleteupload', 'wiki'), get_string('uploadname', 'wiki'), get_string('uploadactions', 'wiki'));
$fs = get_file_storage();
$browser = get_file_browser();
$files = $fs->get_area_files($this->_fileinfo['contextid'], $this->_fileinfo['filearea'], $this->_fileinfo['itemid']);
if (count($files) < 2) {
return get_string('noattachments', 'wiki');
}
//get tags
foreach (array('image', 'attach', 'link') as $tag) {
$tags[$tag] = wiki_parser_get_token($this->_format, $tag);
}
foreach ($files as $file) {
if (!$file->is_directory()) {
$checkbox = '<input type="checkbox" name="'.$this->_attributes['name'].'[]" value="'.$file->get_pathnamehash().'"';
if (in_array($file->get_pathnamehash(), $this->_value)) {
$checkbox .= ' checked="checked"';
}
$checkbox .= " />";
//actions
$icon = mimeinfo_from_type('icon', $file->get_mimetype());
$file_url = file_encode_url($CFG->wwwroot.'/pluginfile.php', "/{$this->_contextid}/{$this->_filearea}/{$this->_fileareaitemid}/".$file->get_filename());
$action_icons = "";
if(!empty($tags['attach'])) {
$action_icons .= "<a href=\"javascript:void(0)\" class=\"wiki-attachment-attach\" ".$this->printInsertTags($tags['attach'], $file->get_filename())." title=\"".get_string('attachmentattach', 'wiki')."\"><img src=\"".$OUTPUT->pix_url('f/pdf')->out()."\" alt=\"Attach\" /></a>";
}
$action_icons .= "&nbsp;&nbsp;<a href=\"javascript:void(0)\" class=\"wiki-attachment-link\" ".$this->printInsertTags($tags['link'], $file_url)." title=\"".get_string('attachmentlink', 'wiki')."\"><img src=\"".$OUTPUT->pix_url('f/web')->out()."\" alt=\"Link\" /></a>";
if ($icon == 'image.gif') {
$action_icons .= "&nbsp;&nbsp;<a href=\"javascript:void(0)\" class=\"wiki-attachment-image\" ".$this->printInsertTags($tags['image'], $file->get_filename())." title=\"".get_string('attachmentimage', 'wiki')."\"><img src=\"".$OUTPUT->pix_url('f/image')->out()."\" alt=\"Image\" /></a>";
}
$htmltable->data[] = array($checkbox, '<a href="'.$file_url.'">'.$file->get_filename().'</a>', $action_icons);
}
}
return html_writer::table($htmltable);
}
private function printInsertTags($tags, $value) {
return "onclick=\"javascript:insertTags('{$tags[0]}', '{$tags[1]}', '$value');\"";
}
}
//register wikieditor
MoodleQuickForm::registerElementType('wikifiletable', $CFG->dirroot."/mod/wiki/editors/wikifiletable.php", 'MoodleQuickForm_wikifiletable');
-82
View File
@@ -1,82 +0,0 @@
Who worked on ErfurtWiki
========================
(please note that all mail addresses are 'beautified')
Mario Salzer <mario*erphesfurt·de> [http://mario.erphesfurt.de/]
- original author, current maintainer
Andy Fundinger <andy*burgiss·com> [http://www.burgiss.com/]
- compatibility fixes for PHP.A/W32, notify: address protection for info/
- markup_css_singleat, action_extracttodo
- spellcheck2, phplib_auth, title_calendar
- navbar, aview_posts
- LiveUser authentication / permission framework plugin
Carsten Senf <ewiki*csenf·de> (from Erfurt)
- db_flat_files.php bugfixes for Win32 systems
- calendar.php, db_fast_files.php` code
- page_since_updates.php
Alex Wan <alex*burgiss·com> [http://www.burgiss.com/]
- LiveUser framework auth plugin,
log viewing plugin
Jeremy Mikola <jmikola*arsjerm·net> [http://www.burgiss.com/]
- aview_piclogocntl, the Burgiss Groups` LiveUser framework auth plugin
Culley Harrelson <cully*fastmail·fm>
- fixes for html code generation bugs,
various feature requests
Hans B. Pufal <hansp*aconit·org> [http://www.aconit.org/]
- various enhancements, bugfixes
- mpi_calendar
- mpi_environment
- mpi_plugins
- mpi_page_flags
- markup_complextbl
Vladimir Támara <vtamara*users.sourceforge·net>
- Spanish translation of core messages and
the basic init-pages/
Frank 'Sigi' Luithle <sigi*fsinfo.cs.uni-sb·de>
- contributed the wiki_format.inc (reduced rendering core)
Beate Paland <bep*web·de> [http://www.paland.tv/]
- bug notices and many helpful suggestions
(constantly demanded for <pre> support)
- phpCMS integration, see http://www.paland.tv/...
Markus Ackermann <maol*symlink·ch> [http://www.symlink.ch/]
- bug reports, improvement suggestions
Dominik Eckardt <the.oberon*gmx·de>
- suggested the TAB indentation
(while now SPACEs are supported)
-22
View File
@@ -1,22 +0,0 @@
Information on how to install and use ErfurtWiki can be found in the
README, this file only contains notes for the impatient:
Quick Test Installation
=======================
- just move this newly extracted directory into your webservers docroot:
mv ewiki-R1.00f7 /var/www/wiki
- then edit the "config.php" file, you may need to set the correct
parameters to access your MySQL database server (db user name and
password, and select a database different from "test")
- just go to http://localhost/wiki/
(or whereever you did put the files)
Warning
=======
Simply installing these files unchanged onto a public webserver is a bad
idea, at least the tools/ subdir should be password-protected!
-2
View File
@@ -1,2 +0,0 @@
If you updated from R1.01c or earlier, then use the "tools/upgrade-101d"
to convert the plugin file names in your 'config.php' file.
-114
View File
@@ -1,114 +0,0 @@
ewiki/fragments/
================
This directory contains various (code) snippets, which may or may not
be useful for you. You are on your own, when it comes to make them
work.
mkhuge
¯¯¯¯¯¯
Is a shell script to merge the core "ewiki.php" with some of the common
extension plugins into a "huge-ewiki.php" script - for lazy people ;->
core.css
¯¯¯¯¯¯¯¯
Is an example (text/css) stylesheet, which shows how to tweak
the look of rendered pages using CSS.
You could copy it into yoursites.css or do something like this in
yoursite.php:
<HTML>
<HEAD>
<STYLE TYPE="text/css"><!--
<?php
include("fragments/core.css");
?>
//--></STYLE>
calendar.css
¯¯¯¯¯¯¯¯¯¯¯¯
These stylesheet definitions show all possible CSS classes that
are used within the calendar.php plugin. Use like core.css
binary.php
¯¯¯¯¯¯¯¯¯¯
If yoursite.php is not designed carefully enough or EWIKI_SCRIPT_BINARY
cannot be set correctly, you may want to use this wrapper script to
allow for uploading and retrieval of binary content (images) via ewiki.
Copy it to where the main ewiki.php script is, and set the
EWIKI_SCRIPT_BINARY constant to the correct absolute position (possibly
including http://server.name/) of "binary.php".
(this constant must be set on top of ewiki.php)
You must set the database access params in here, too.
It may also be useful if you'd like to divide the database into its
two parts again - text content and binary content. You could even
let it save binary content in a flat file database, while WikiPages
remain in a RDBMS.
homepage.src
¯¯¯¯¯¯¯¯¯¯¯¯
Is an __EXAMPLE__ on how to build a crippled Wiki (using authentication)
for a private homepage.
There is a lot of infos inside the script. And please remember all
files labeled with "example" are just examples!!!!!!! (read: I'm rarely
interested in bug reports)
funcs.inc
¯¯¯¯¯¯¯¯¯
Possibly useful pseudo-external helper functions are collected in here.
function save_newest_pages()
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reads the recently updated pages list from the database (like
"UpdatedPages") and tries to save it in another database table
(this example does so in my privately used webcms for speed purposes).
htaccess
¯¯¯¯¯¯¯¯
Shows how to use mod_rewrite with ewiki.
* old style: http://www.example.com/wiki.php?page=WikiPage
* PATH_INFO: http://www.example.com/WikiPage
Remember to enable EWIKI_USE_PATH_INFO inside ewiki.php - this was
disabled once, because of the many broken Apache implementations (they
seem to support that broken CGI/1.1 specification, which was for good
reasons and luckily never blessed to become an official RFC).
strip_wonderful_slashes.php
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Fixes the very bad "magic_quotes_gpc" setting from php.ini for PHP
versions prior to 4.3
Does not hurt a well configured PHP interpreter setup.
wiki_format.inc
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Stripped version of the wiki rendering core for easier inclusion into
your own projects.
-41
View File
@@ -1,41 +0,0 @@
<?php
# http user space authentication layer
#
# can be used with the tools/, if you don't want to
# set up the .htaccess and .htpasswd files
#-- (pw array - I have such one in an external config file)
$passwords = array(
// "user" => "password",
// "u2" => "password",
);
#-- fetch user:password
if ($uu = trim($_SERVER["HTTP_AUTHORIZATION"])) {
strtok($uu, " ");
$uu = strtok(" ");
$uu = base64_decode($uu);
list($_a_u, $_a_p) = explode(":", $uu, 2);
}
elseif (strlen($_a_u = trim($_SERVER["PHP_AUTH_USER"]))) {
$_a_p = trim($_SERVER["PHP_AUTH_PW"]);
}
#-- check password
$_success = false;
if (strlen($_a_u) && strlen($_a_p) && ($_a_p == @$passwords[$_a_u])) {
$_success = $_a_u;
}
#-- request HTTP Basic authentication otherwise
if (!$_success) {
header('HTTP/1.1 401 Authentication Required');
header('Status: 401 Authentication Required');
header('WWW-Authenticate: Basic realm="restricted access"');
die();
}
-21
View File
@@ -1,21 +0,0 @@
<?php
# if you cannot manage to include() the core "ewiki.php" library
# before any plain <HTML> output is made inside "yoursite.php", you
# could use such a lib wrapper beside yoursites/index.php
# it is also useful, if you want to keep binary data in a separate
# database, say a db_flat_files one - because you can then set this up
# herein without any affect to yoursites/ewiki.php
# remember to define() inside ewiki.php or yoursite.php:
define("EWIKI_SCRIPT_BINARY", "binary.php?binary=");
#-- that's all:
mysql_connect("localhost", "DBUSER", "DBPASSWORD");
mysql_query("use DATABASENAME");
include("ewiki.php");
-39
View File
@@ -1,39 +0,0 @@
/*
Include these style definitions into your sites` css, if you'd like
to use the calendar plugin.
*/
table.caltable{
background-color: #CDBDAD;
}
td.calhead {
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
text-align:center;
}
th.caldays{
color:#BA997A;
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
text-align:center;
}
td.calday{
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
text-align:right;
}
td.caltoday{
background-color:#D7CFC7;
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
text-align:right;
}
a.calpg{
text-decoration: none;
font-weight:600;
}
a.calhide{
text-decoration: none;
}
-63
View File
@@ -1,63 +0,0 @@
/*
These example style definitions only show how to tweak look
of generated WikiPages.
*/
body, td {
line-height:140%;
}
a {
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
p {
line-height:110%;
}
em {
text-decoration:none;
font-style:normal;
background-color:#cccc22;
}
strong {
font-weight:700;
}
.box {
background-color:#222266;
border:1px #111133 solid;
}
.box hr {
display:none;
}
hr {
visibility:hidden;
}
form[name=ewiki] {
border:2px #ffffff dashed;
padding:5px;
background-color:#444444;
}
textarea[name=content] {
border:2px #000000 dotted;
background-color:#B4D3D7;
}
input[name=save], input[name=preview] {
border:1px #000000 solid;
background-color:#B4D3D7;
-moz-border-redius:10px;
}
-33
View File
@@ -1,33 +0,0 @@
#
# this file contains various useful helper functions, to interfer
# with the ewiki database from within another site engine
#
# may be there is something useful in here for you, too
#
#-- save newest pages
function save_newest_pages()
{
$sorted = array();
foreach (ewiki_database("GETALL", array("lastmodified", "flags", "version")) as $row) {
if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
$sorted[$row["id"]] = $row["lastmodified"];
}
}
arsort($sorted);
$n = 0;
$o = "";
foreach ($sorted as $id=>$uu) {
$o .= '·<a href="/wiki/?id=' . urlencode($id) . '">' .
preg_replace('/(\w{15}[a-zäöüß]*)(\w{3,5})/', '$1&shy;$2', $id) . "</a><br>\n";
if ($n++ >= 15) break;
}
$o = addslashes($o);
mysql_query("UPDATE text_table SET html='$o' WHERE filename='wiki-updated' ")
or
return($o);
}
-172
View File
@@ -1,172 +0,0 @@
<?php
#-- This is an example standalone lite-CMS Homepage based on ewiki.php
# - it requires PHP4.1+
# - you should install it as index.php into your dedicated webspace
# - copy the ewiki.php there, too
# - DON'T upload the tools/ directory, as this requires a lot more
# setup to be used securely
# - HTML Editors usually allow you to tweak the layout without
# garbaging the PHP code inside
# - authentication is done using JavaScript+Cookies
# - requires a MySQL database, just visit http://freesql.org/ and
# get happy (if your provider doesn't provide one)
# - there will be no pages initially, you must first create some
# - most config options are in the upper area of this file:
$HOMEPAGE_TITLE = 'MyHomepage';
$LOGIN_PASSWORD = 'ewiki';
$AUTHOR_NAME = 'your_nickname_here';
$MYSQL_HOST = 'localhost';
$MYSQL_USER = 'root';
$MYSQL_PASSWORD = '';
$MYSQL_DATABASE = 'test';
#-- open database
if (!@mysql_ping()) {
mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
mysql_query("use $MYSQL_DATABASE");
}
#-- no errors shown from here
error_reporting(0);
#-- check for password
if ($LOGIN_PASSWORD == "password") die("poor");
if ($_COOKIE["password"]) {
if ($LOGIN_PASSWORD == $_COOKIE["password"]) {
$ewiki_author = $AUTHOR_NAME;
}
else {
$page_content == "<h3>password wrong</h3>";
}
}
#-- load ewiki
define("EWIKI_EDIT_AUTHENTICATE", 1);
define("EWIKI_SCRIPT", substr(__FILE__, strrpos(__FILE__, "/") + 1) . "?page=");
define("EWIKI_SCRIPT_BINARY", substr(__FILE__, strrpos(__FILE__, "/") + 1) . "?binary=");
define("EWIKI_PAGE_INDEX", $HOMEPAGE_TITLE);
define("EWIKI_CONTROL_LINE", 0);
define("EWIKI_T_CANNOTCHANGEPAGE", "You must first login to change a page.");
include("ewiki.php");
#-- get current page
if (empty($page_content)) {
$page_content = ewiki_page();
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo($ewiki_title); ?></title>
<meta name="GENERATOR" content="ewiki" />
<meta name="ROBOTS" content="INDEX,FOLLOW" />
<style type="text/css">
<!--
body {
background-color:#6666ee;
color:#000011;
}
.menu {
background-color:#111166;
color:#ffffff;
border: 2px solid #000055;
padding: 8px;
text-align:center;
width:120px;
}
a,a:link { color: #ffff33; text-decoration: none; }
a:active { color: #FF6666; }
a:visited { color: #660000; }
a:hover { font-weight:900; background-color:#ffff00; color:#000000; }
.menu a { color:#ffffff; }
.menu a:hover { color:#000000; }
//-->
</style>
<script type="text/javascript">
<!--
function login()
{
var password = window.prompt("Please enter the administrator password:");
window.document.cookie = "password=" + password;
window.document.location.reload();
}
function logout()
{
window.document.cookie = "password=";
}
//-->
</script>
</HEAD>
<BODY>
<CENTER>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="10" WIDTH="90%">
<TR>
<TD WIDTH="120" VALIGN="TOP">
<DIV CLASS="menu">
<h3>Welcome to my Homepage!</h3>
<A HREF=".">Startpage</A> <BR>
<A HREF="?page=EMailMe">EMailMe</A> <BR>
<A HREF="?page=MyLinks">MyLinks</A> <BR>
<BR>
<?php
if ($ewiki_author) {
echo "<A HREF=\"javascript:logout()\">Logout</A><BR>";
echo "<A HREF=\"?page=edit/$ewiki_title\">EditThisPage</A><BR>";
echo "<A HREF=\"?page=info/$ewiki_title\">PageInfo</A><BR>";
}
else {
echo "<A HREF=\"?page=links/$ewiki_title\">Links to here</A><BR><BR>";
echo "<SMALL><A HREF=\"javascript:login()\">EditorLogin</A><BR></SMALL>";
}
?>
</DIV>
</TD>
<TD VALIGN="TOP" WIDTH="90%">
<DIV CLASS="content">
<?php
echo($page_content);
?>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
-25
View File
@@ -1,25 +0,0 @@
# This is file is to be used with the Apache or Nanoweb webserver.
#
# Rename it to .htaccess (or .nwaccess for Nanoweb) in a dedicated
# directory for your Wiki.
#
# It uses the mod_rewrite to look a bit more professionall than
# the usual GET-vars at the end of our URLs. This is highly
# recommended as things like "script.php?edit=1&id=page" usually
# scare search engines and may prevent your Wiki from getting
# indexed.
#
# Please edit ewiki.php and enable EWIKI_USE_PATH_INFO for Apache
# webservers - the PATH_INFO implementation is very broken for many
# versions (mostly commercial Unicies and for PHP-CGI variants),
# because to the Apache Group once choosed to follo that never
# finished and heavily broken (proposed) CGI/1.1 specification.
#-- enable mod_rewrite (Apache + Nanoweb)
RewriteEngine On
#-- pass WikiWord-URLs to the wiki wrapper script:
RewriteRule ^((\w+/)?[A-Z]+[a-z]+\w*[A-Z]+\w+)$ yoursite.php/$1 [L]
#-- or this one, if there is really nothing else in the same directory:
#RewriteRule ^(.*)$ yoursite.php?id=$1 [L]
-61
View File
@@ -1,61 +0,0 @@
#!/bin/sh
#
# a shell script, which combines the ewiki.php library and some
# default plugins into a huger include library
#
HUGE_FILE="huge-ewiki.php"
CORE_FILE="ewiki.php"
#-- current dir
if [ -e "ewiki.php" ] ; then
DWP=.
else
DWP=..
fi
#-- help
if [ "$1" == "-h" -o "$1" == "--help" ] ; then
echo "syntax: mkhuge"
echo "combines many of the plugins and the core ewiki.php file into a bigger lib."
exit
fi
#-- choose size
N=$1
if [ -z "$N" ] ; then
N=0
fi
if [ "$1" -ge "3" ] ; then
PLUGINS="markup_phpwiki.php markup_bbcode.php spellcheck.php $PLUGINS"
fi
if [ "$1" -ge "2" ] ; then
PLUGINS="more_interwiki.php page_imagegallery.php $PLUGINS"
fi
if [ "$1" -ge "1" ] ; then
PLUGINS="diff.php page_randompage.php markup_footnotes.php page_wordindex.php $PLUGINS"
fi
PLUGINS="strip_wonderful_slashes.php calendar.php email_protect.php like_pages.php page_pageindex.php page_powersearch.php $PLUGINS"
#-- proceed
echo -n "writing: $CORE_FILE"
cat $DWP/$CORE_FILE > $DWP/$HUGE_FILE
for ADD in $PLUGINS
do
echo -n "+$ADD"
for SUB in plugins fragments ; do
if [ -e "$DWP/$SUB/$ADD" ] ; then
ADD=$DWP/$SUB/$ADD
fi
done
cat $ADD >> $DWP/$HUGE_FILE
done
echo " > $DWP/$HUGE_FILE"
echo "done."
@@ -1,58 +0,0 @@
<?php
/*
This is a PHPNuke5.2 module (don't know if it works with v6) to be
copied into the modules directory like the filename implies
( phpnuke/modules/Wiki/ ).
You should copy the "ewiki.php" into the same directory!
If you want it to initialize the db correctly you must copy the
init-pages/ to there as well.
*/
#-- stupid legacy code
if (!preg_match("/modules.php/i", $PHP_SELF)) {
die ("You can't access this file directly...");
}
#-- blocks to the left and to the right?
$index = 0;
#-- HTML,HEAD,TABLESTART
include("header.php"); #-- or better "mainfile.php" ???
#-- Output -----------------------------------------------------------
OpenTable(); # do we want to know, what this is for?
chdir("modules/Wiki/");
error_reporting(0);
define("EWIKI_SCRIPT", "modules.php?op=modload&name=Wiki&file=index&wikipage=");
include("ewiki.php");
($wikipage = $_REQUEST["wikipage"]) or
($wikipage = $_REQUEST["page"]) or
($wikipage = EWIKI_PAGE_INDEX);
echo ewiki_page($wikipage);
chdir("../..");
CloseTable(); # strange function names ;)
# /BODY
include("footer.php");
@@ -1,52 +0,0 @@
<?php
/*
this strips all "\" from $_REQUEST and
disables the runtime garbaging as well
just include() it before ewiki.php
and everythink should work fine
for Apache+mod_php you should however rather use the
[.htaccess] PHP reconfiguration trick:
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
*/
#-- this is very evil too
set_magic_quotes_runtime(0);
#-- Moodle always addslashes to everything so
#-- we strip them back again here to allow
#-- the wiki module itself to add them before
#-- insert. Strange triple add-strip-add but
#-- this was the best way to solve problems
#-- without changing how the rest of the
#-- module works.
$superglobals = array(
"_REQUEST",
"_GET",
"_POST",
"_COOKIE",
"_ENV",
"_SERVER"
);
foreach ($superglobals as $AREA) {
foreach ($GLOBALS[$AREA] as $name => $value) {
if (!is_array($value)) {
$GLOBALS[$AREA][$name] = stripslashes($value);
}
}
}
-291
View File
@@ -1,291 +0,0 @@
<?php
/*
* Wiki-Engine from "ErfurtWiki", Mario Salzer <[email protected]>
* Adapted by Frank Luithle <[email protected]>
*
* WikiLinks and binary already stripped off -> just the rendering core
*/
// URL prefixes
$ewiki_idf_url = array( "http://",
"mailto:",
"ftp://",
"irc://",
"telnet://",
"news://",
"internal://",
"chrome://",
"file://" );
// allowed wikinames
//define( "EWIKI_CHARS_L", "a-z_$" );
//define( "EWIKI_CHARS_U", "A-Z" );
function wiki_format( $wiki_source,
$strip_slashes = true,
$safe_html_allowed = true,
$table_html_allowed = false ) {
if ( $strip_slashes ) {
$wiki_source = stripslashes( $wiki_source );
}
// formatted output
$o = "<p>\n";
// state vars
$li_o = "";
$tbl_o = 0;
$post = "";
$wm_whole_line = array( "!!!" => "h2",
"!!" => "h3",
"!" => "h4",
" " => "tt",
";:" => 'div style="left-margin:10pt;"' );
$table_defaults = 'cellpadding="2" border="1" cellspacing="0"';
// these tags will be preserved if the $safe_html_allowed argument
// is set to 'true'
$rescue_html = array( "tt", "b", "i", "strong", "em", "s", "kbd", "var",
"xmp", "sup", "sub", "pre", "q", "h2", "h3", "h4",
"h5", "h6", "cite", "code", "u" );
$syn_htmlentities = array( "&" => "&amp;",
">" => "&gt;",
"<" => "&lt;",
"%%%" => "<br/>" );
$wm_list = array( "-" => array('ul type="square"', "", "li"),
"*" => array('ul type="circle"', "", "li"),
"#" => array("ol", "", "li"),
":" => array("dl", "dt", "dd") );
$wm_text_style = array( "'''" => array("''__", "__''"),
"___" => array("''__", "__''"),
"''" => array("<em>", "</em>"),
"__" => array("<strong>", "</strong>"),
// "^^" => array("<sup>", "</sup>"),
// "***" => array("<b><i>", "</i></b>"),
// "###" => array("<big><b>", "</b></big>"),
"**" => array("<b>", "</b>"),
"##" => array("<big>", "</big>"),
"" => array("<small>", "</small>") );
$link_regex = "#(!?\[[^[\]\n]+\])|((?:!?[a-z]{2,6}://|mailto:)[^\s\[\]\'\"\)\,<]+)#";
#$link_regex = "#(!?\[[^[\]\n]+\])|((?:!?[".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L.
# ":]+){2}[\w\d]*)|((?:!?[a-z]{2,6}://|mailto:)[^\s\[\]\'\"\)\,<]+)#";
// eliminate html
foreach ( $syn_htmlentities as $find => $replace ) {
$wiki_source = str_replace( $find, $replace, $wiki_source );
}
array_pop( $syn_htmlentities );
// unescape allowed html
if ( $safe_html_allowed ) {
foreach ( $rescue_html as $tag ) {
foreach( array( $tag, "/$tag", ( $tag = strtoupper($tag) ), "/$tag" )
as $tag ) {
$wiki_source = str_replace( '&lt;' . $tag . '&gt;',
"<" . $tag . ">",
$wiki_source );
}
}
}
$wiki_source = trim( $wiki_source ) . "\n";
foreach ( explode( "\n", $wiki_source ) as $line ) {
$line = rtrim( $line );
$post = "";
// paragraphs
if ( empty($line) ) {
$post .= "</p>\n\n<p>";
} elseif ( strpos( $line, "----" ) === 0 ) {
$o .= "<hr>\n";
continue;
} elseif ( strpos( $line, "&lt;!--" ) === 0 ) {
$o .= "<!-- " . s( str_replace( "--", "__", substr($line, 7) ) ) . " -->\n";
continue;
}
// unescape html markup || tables wiki markup
if ( strlen( $line ) && ( $line[0] == "|" ) ) {
if ( strlen( $line ) >
strlen( trim( $line, "|" ) ) + 1 ) {
$line = substr( $line, 1, strlen( $line ) - 2 );
if ( !$tbl_o ) {
$o .= "<table " . $table_defaults . ">\n";
}
$line = "<tr>\n<td>" . str_replace("|", "</td>\n<td>", $line) . "</td>\n</tr>";
$tbl_o = 1;
} elseif ( $table_html_allowed ) {
$line = ltrim( substr( $line, 1 ) );
foreach ( array_flip( $syn_htmlentities ) as $find => $replace ) {
$line = str_replace( $find, $replace, $line );
}
}
} elseif ($tbl_o) {
$o .= "</table>\n";
$tbl_o = 0;
}
// whole-line wikimarkup
foreach ( $wm_whole_line as $find => $replace ) {
if ( substr( $line, 0, strlen($find) ) == $find ) {
$line = ltrim( substr( $line, strlen($find) ) );
$o .= "<$replace>";
$post = "</" . strtok( $replace, " " ) . ">" . $post;
}
}
// wiki list markup
if ( strlen( $li_o ) ||
strlen( $line ) && isset( $wm_list[@$line[0]] ) ) {
$n = 0;
$li = "";
// count differences to previous list wikimarkup
while ( strlen( $line ) && ( $li0 = $line[0] ) && isset( $wm_list[$li0] ) ) {
$li .= $li0;
$n++;
$line = substr($line, 1);
}
$line = ltrim($line);
// fetch list definition
if ( strlen( $li ) && ( $last_list_i = $li[strlen($li)-1] ) )
list( $list_tag, $list_dt0, $list_entry_tag ) = $wm_list[$last_list_i];
// output <ul> until new list wikimarkup rule matched
while ( strlen($li_o) < strlen($li) ) {
$add = $li[ strlen($li_o) ];
$o .= "<" . $wm_list[ $add ][ 0 ] . ">\n";
$li_o .= $add;
}
// close </ul> lists until "$li_o" == "$li" (list wikimarkup state var)
while ( strlen($li_o) > strlen($li) ) {
$del = $li_o[ strlen($li_o) - 1 ];
$o .= "</" . strtok( $wm_list[$del][0], " " ) . ">\n";
$li_o = substr( $li_o, 0, strlen($li_o) - 1 );
}
// more work for <dl> lists
if ( !empty($list_dt0) ) {
list( $line_dt, $line ) = explode( $last_list_i, $line, 2 );
$o .= "<$list_dt0>$line_dt</$list_dt0>";
$list_dt0 = $last_list_i = false;
}
// finally enclose current line in <li>...</li>
if ( !empty($line) ) {
$o .= "<$list_entry_tag>";
$post = "</$list_entry_tag>" . $post;
}
$li_o = $li;
}
// link-regex here??
// (was formerly, may be faster if applied to the whole formatted
// page, but this could also introduce some rendering bugs)
// text style triggers
foreach ( $wm_text_style as $find => $replace ) {
$n = strlen( $find );
$loop = 20;
while( ( $loop-- ) &&
( ($l = strpos($line, $find)) !== false ) &&
( $r = strpos($line, $find, $l + $n) ) ) {
$line = substr( $line, 0, $l ) . $replace[0] .
substr( $line, $l + strlen($find), $r - $l - $n ) .
$replace[1] . substr( $line, $r + $n );
}
}
// add formatted line to page-output
$o .= $line . $post . "\n";
}
// close last line
$o .= "</p>\n";
// finally the link-detection-regex
// (impossible to do with simple string arithmetics)
$o = preg_replace_callback( $link_regex, "wiki_link_regex_callback", $o );
return( $o );
}
function wiki_link_regex_callback( $uu ) {
global $ewiki_idf_url;
$str = $uu[0];
// link bracket '[' escaped with '!'
if ( $str[0] == "!" ) {
return(substr($str, 1));
} elseif ( $str[0] == "[" ) {
$str = substr( $str, 1, strlen($str) - 2 );
}
// explicit title given via [ foo | bar ]
$href = $title = strtok( $str, "|" );
if ( $uu = strtok("|") ) {
$href = $uu;
}
// title and href swapped: swap back
if ( strpos( "://", $title ) ||
strpos( $title, ":" ) && !strpos( $href, ":" ) ) {
$uu = $title;
$title = $href;
$href = $uu;
}
$title = trim($title);
$href = trim($href);
/* create _no_ WikiLinks */
if ( false ){
// interwiki links
if ( strpos($href, ":") &&
!strpos($href, "//") &&
($p1 = @$ewiki_interwiki[strtok($href, ":")]) ) {
while ($p1_alias = @$ewiki_interwiki[$p1]) {
$p1 = $p1_alias;
}
$href = $p1 . strtok("\000");
} elseif (($ewiki_links === true) ||
@$ewiki_links[$href] ||
@$ewiki_internal_pages[$href]) {
// ordinary internal WikiLinks
$str = '<a href="' . EWIKI_SCRIPT .
urlencode($href) . '">' . $title . '</a>';
} else {
$str = '<b>' . $title . '</b><a href="' .
EWIKI_SCRIPT . urlencode($href) /*.EWIKI_ADDPARAMDELIM.'edit'*/ .
' ">?</a>';
}
}
// convert normal URLs
foreach ( $ewiki_idf_url as $find ) {
if ( strpos( $href, $find ) === 0 ) {
$str = '<a href="' . $href . '">' . $title . '</a>';
break;
}
}
return($str);
}
@@ -1,21 +0,0 @@
<?php
#
# this plugin prints the "pages linking to" below a page (the same
# information the "links/" action does)
#
# altered to use ewiki_get_backlinks() by AndyFundinger.
$ewiki_plugins["view_append"][] = "ewiki_view_append_backlinks";
function ewiki_view_append_backlinks($id, $data, $action) {
$pages = ewiki_get_backlinks($id);
$o="";
foreach ($pages as $id) {
$o .= ' <a href="'.ewiki_script("",$id).'">'.$id.'</a>';
}
($o) && ($o = "<div class=\"wiki_backlinks\"><small>".get_string('backlinks', 'wiki').":</small><br />$o</div>\n");
return($o);
}
@@ -1,61 +0,0 @@
<?php
# this plugin appends the list of uploaded attachments at the bottom of
# each page, the downloads / attachments plugin must be loaded too
#
# you could alternatively define EWIKI_AUTOVIEW to 0, and call the
# ewiki_attachments() wrapper function anywhere on yoursite.php
if (!defined("EWIKI_AUTOVIEW") || !EWIKI_AUTOVIEW) {
$ewiki_plugins["view_append"][] = "ewiki_view_append_attachments";
}
$ewiki_t["en"]["ATTACHMENTS"] = "attachments";
$ewiki_t["de"]["ATTACHMENTS"] = "Anhnge";
function ewiki_view_append_attachments($id, $data, $action) {
$o = '<hr /><h4><a href="' . ewiki_script(EWIKI_ACTION_ATTACHMENTS, $id) .
'">' . ewiki_t("ATTACHMENTS") . '</a></h4>';
$scan = 's:7:"section";' . serialize($id);
$result = ewiki_database("SEARCH", array("meta" => $scan));
#### BEGIN MOODLE CHANGES - show attachments link only if there are attachments.
#### - don't show the attachments on the content page.
if (count($result->entries) <= 0) {
$o = '';
}
// $ord = array();
// while ($row = $result->get()) {
// $ord[$row["id"]] = $row["created"];
// }
// arsort($ord);
//
// foreach ($ord as $id => $uu) {
// $row = ewiki_database("GET", array("id"=>$id));
// if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
// continue;
// }
// $o .= ewiki_entry_downloads($row, "*");
// }
#### END MOODLE CHANGES
return($o);
}
function ewiki_attachments() {
global $ewiki_title, $ewiki_id;
return(ewiki_view_append_attachments($ewiki_title, array("id"=>$ewiki_id), "view"));
}
-313
View File
@@ -1,313 +0,0 @@
<?php
# This plugin protects email addresses from getting seen by spambots,
# by the cost of additonal effort for real persons, who really want
# to mail someone.
#
# It is __really safe__ because it protects addresses with an request
# <FORM> before the real email address gets shown on a page (it seems
# impossible to me, that there are already all that intelligent spambots
# available, which can automatically fill out a <form> to access the
# following page).
# The 'cipher' method is really unimportant, when it comes to tricking
# automated harvesters.
#
# Additionally it generates faked/trap email addresses to annoy the
# marketing mafia.
#-- change these from time to time:
define("EWIKI_PAGE_EMAIL", "ProtectedEmail");
define("EWIKI_UP_ENCEMAIL", "encoded_email");
define("EWIKI_UP_NOSPAMBOT", "i_am_no_spambot");
define("EWIKI_UP_REQUESTLV", "rl");
define("EWIKI_FAKE_EMAIL_LOOP", 5);
$ewiki_config["feedbots_tarpits"] = "@spamassassin.taint.org,@123webhosting.org,@e.mailsiphon.com,@heypete.com,@ncifcrf.gov";
$ewiki_config["feedbots_badguys"] = "@riaa.com,@whitehouse.gov,@aol.com,@microsoft.com";
#-- text, translations
$ewiki_t["en"]["PROTE0"] = "Protected Email Address";
$ewiki_t["en"]["PROTE1"] = "The email address you've clicked on is protected by this form, so it won't get found by <a href=\"http://google.com/search?q=spambots\">spambots</a> (automated search engines, which crawl the net for addresses just for the entertainment of the marketing mafia).";
$ewiki_t["en"]["PROTE2"] = "The page you're going to edit contains at least one email address. To protect it we must ensure that no spambot reaches the edit box (with the email address in cleartext).";
$ewiki_t["en"]["PROTE4"] = "I'm no spambot, really!";
$ewiki_t["en"]["PROTE5"] = "<b>generate more faked email addresses</b>";
$ewiki_t["en"]["PROTE6"] = "the email address you've clicked on is:";
$ewiki_t["en"]["PROTE7"] = "<b>spammers, please eat these:</b>";
$ewiki_t["de"]["PROTE0"] = "Geschtzte EMail-Adresse";
$ewiki_t["de"]["PROTE1"] = "Die EMail-Adresse, die du angeklickt hast, wird durch dieses Formular vor <a href=\"http://google.com/search?q=spambots\">spambots</a> (automatisierte Suchwerkzeuge, die das Netz zur Freude der MarketingMafia nach Adressen abgrasen) beschtzt.";
$ewiki_t["de"]["PROTE2"] = "Die Seite, die du ndern willst, enthlt momentan wenigstens eine EMail-Adresse. Um diese zu schtzen mssen wir sicherstellen, da kein Spambot an die Edit-Box kommt (weil dort die Adresse ja im Klartext steht).";
$ewiki_t["de"]["PROTE4"] = "Ich bin wirklich kein Spambot!";
$ewiki_t["de"]["PROTE5"] = "<b>noch mehr fingierte Adressen anzeigen</b>";
$ewiki_t["de"]["PROTE6"] = "die EMail-Adresse die du angeklickt hast lautet:";
$ewiki_t["de"]["PROTE7"] = "<b>Liebe Spammer, bitte fret das:</b>";
#-- plugin glue
$ewiki_plugins["link_url"][] = "ewiki_email_protect_link";
$ewiki_plugins["page"][EWIKI_PAGE_EMAIL] = "ewiki_email_protect_form";
$ewiki_plugins["edit_hook"][] = "ewiki_email_protect_edit_hook";
$ewiki_plugins["page_final"][] = "ewiki_email_protect_enctext";
function ewiki_email_protect_enctext(&$html, $id, $data, $action) {
$a_secure = array("info", "diff");
if (in_array($action, $a_secure)) {
$html = preg_replace('/([-_+\w\d.]+@[-\w\d.]+\.[\w]{2,5})\b/me',
'"<a href=\"".ewiki_email_protect_encode("\1",2).
"\">".ewiki_email_protect_encode("\1",0)."</a>"',
$html);
}
}
/* ewiki_format() callback function to replace mailto: links with
* encoded redirection URLs
*/
function ewiki_email_protect_link(&$href, &$title) {
if (substr($href, 0, 7) == "mailto:") {
$href = substr($href, 7);
$href = ewiki_email_protect_encode($href, 2);
$title = ewiki_email_protect_encode($title, 0);
}
}
/* the edit box for every page must be protected as well - else all
* mail addresses would still show up in the wikimarkup (cleartext)
*/
function ewiki_email_protect_edit_hook($id, &$data, &$hidden_postdata) {
$ewiki_up_nospambot = optional_param(EWIKI_UP_NOSPAMBOT, null);
$hidden_postdata[EWIKI_UP_NOSPAMBOT] = 1;
if (empty($ewiki_up_nospambot )
&& strpos($data["content"], "@")
&& preg_match('/\w\w@([-\w]+\.)+\w\w/', $data["content"]) )
{
$url = ewiki_script("edit", $id);
$o = ewiki_email_protect_form($id, $data, "edit", "PROTE2", $url);
return($o);
}
if (!empty($ewiki_up_nospambot) && empty($_COOKIE[EWIKI_UP_NOSPAMBOT]) && EWIKI_HTTP_HEADERS) {
setcookie(EWIKI_UP_NOSPAMBOT, "grant_access", time()+7*24*3600, "/");
}
}
/* this places a <FORM METHOD="POST"> in between the WikiPage with the
* encoded mail address URL and the page with the clearly readable
* mailto: string
*/
function ewiki_email_protect_form($id, $data=0, $action=0, $text="PROTE1", $url="") {
$ewiki_up_encemail = optional_param(EWIKI_UP_ENCEMAIL, null);
$ewiki_up_nospambot = optional_param(EWIKI_UP_NOSPAMBOT, null);
if ($url || ($email = $ewiki_up_encemail)) {
$html = "<h3>" . ewiki_t("PROTE0") . "</h3>\n";
if (empty($ewiki_up_nospambot)) { #// from GET,POST,COOKIE
(empty($url)) and ($url = ewiki_script("", EWIKI_PAGE_EMAIL));
$html .= ewiki_t($text) . "<br /><br /><br />\n";
$html .= '<form action="' . $url .
'" method="POST" enctype="multipart/form-data" encoding="iso-8859-1">';
$html .= '<fieldset class="invisiblefieldset">';
$html .= '<input type="hidden" name="'.EWIKI_UP_ENCEMAIL.'" value="' . $email . '" />';
foreach (array_merge($_GET, $_POST) as $var=>$value) {
if (($var != "id") && ($var != EWIKI_UP_ENCEMAIL) && ($var != EWIKI_UP_NOSPAMBOT)) {
$html .= '<input type="hidden" name="' . s($var) . '" value="' . s($value) . '" />';
}
}
$html .= '<input type="checkbox" name="'.EWIKI_UP_NOSPAMBOT.'" value="true" /> ' . ewiki_t("PROTE4") . '<br /><br />';
$html .= '<input type="submit" name="go" /></fieldset></form><br /><br />';
if (EWIKI_FAKE_EMAIL_LOOP) {
$html .= "\n" . ewiki_t("PROTE7") . "<br />\n";
$html .= ewiki_email_protect_feedbots();
}
}
else {
$email = ewiki_email_protect_encode($email, -1);
$html .= ewiki_t("PROTE6") . "<br />";
$html .= '<a href="mailto:' . $email . '">' . $email . '</a>';
if (EWIKI_HTTP_HEADERS && empty($_COOKIE[EWIKI_UP_NOSPAMBOT])) {
setcookie(EWIKI_UP_NOSPAMBOT, "grant_access", time()+7*24*3600, "/");
}
}
}
return($html);
}
/* security really does not depend on how good "encoding" is, because
* bots cannot automatically guess that one is actually used
*/
function ewiki_email_protect_encode($string, $func) {
switch ($func) {
case 0: // garbage shown email address
if (strpos($string, "mailto:") === 0) {
$string = substr($string, 7);
}
while (($rd = strrpos($string, ".")) > strpos($string, "@")) {
$string = substr($string, 0, $rd);
}
$string = strtr($string, "@.-_", "");
break;
case 1: // encode
$string = str_rot17($string);
$string = base64_encode($string);
break;
case -1: // decode
$string = base64_decode($string);
$string = str_rot17($string);
break;
case 2: // url
$string = ewiki_script("", EWIKI_PAGE_EMAIL,
array(EWIKI_UP_ENCEMAIL => ewiki_email_protect_encode($string, 1))
);
break;
}
return($string);
}
/* this is a non-portable string encoding fucntion which ensures, that
* encoded strings can only be decoded when requested by the same client
* or user in the same dialup session (IP address must match)
* feel free to exchange the random garbage string with anything else
*/
function str_rot17($string) {
if (!defined("STR_ROT17")) {
$i = @$_SERVER["SERVER_SOFTWARE"] .
@$_SERVER["HTTP_USER_AGENT"] .
getremoteaddr();
$i .= 'MxQXF^e-0OKC1\\s{\"?i!8PRoNnljHf65`Eb&A(\':g[D}_|S#~3hG>*9yvdI%<=.urcp/@$ZkqL,TWBw]a;72UzYJ)4mt+ V';
$f = "";
while (strlen($i)) {
if (strpos($f, $i[0]) === false) {
$f .= $i[0];
}
$i = substr($i, 1);
}
define("STR_ROT17", $f);
}
return(strtr($string, STR_ROT17, strrev(STR_ROT17)));
}
/* this function emits some html with random (fake) email addresses
* and spambot traps
*/
function ewiki_email_protect_feedbots() {
global $ewiki_config;
$ewiki_up_requestlv = optional_param(EWIKI_UP_REQUESTLV, 0, PARAM_CLEAN);
$html = "";
srand(time()/17-1000*microtime());
#-- spamtraps, and companys/orgs fighting for spammers rights
$domains = explode(",",
$ewiki_config["feedbots_tarpits"]. "," .$ewiki_config["feedbots_badguys"]
);
$traps = explode(" ", "[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]");
$word_parts = explode(" ", "er an Ma ar on in el en le ll Ca ne ri De Mar Ha Br La Co St Ro ie Sh Mc re or Be li ra Al la al Da Ja il es te Le ha na Ka Ch is Ba nn ey nd He tt ch Ho Ke Ga Pa Wi Do st ma Mi Sa Me he to Car ro et ol ck ic Lo Mo ni ell Gr Bu Bo Ra ia de Jo El am An Re rt at Pe Li Je She Sch ea Sc it se Cha Har Sha Tr as ng rd rr Wa so Ki Ar Bra th Ta ta Wil be Cl ur ee ge ac ay au Fr ns son Ge us nt lo ti ss Cr os Hu We Cor Di ton Ri ke Ste Du No me Go Va Si man Bri ce Lu rn ad da ill Gi Th and rl ry Ros Sta sh To Se ett ley ou Ne ld Bar Ber lin ai Mac Dar Na ve no ul Fa ann Bur ow Ko rs ing Fe Ru Te Ni hi ki yn ly lle Ju Del Su mi Bl di lli Gu ine do Ve Gar ei Hi vi Gra Sto Ti Hol Vi ed ir oo em Bre Man ter Bi Van Bro Col id Fo Po Kr ard ber sa Con ick Cla Mu Bla Pr Ad So om io ho ris un her Wo Chr Her Kat Mil Tre Fra ig Mel od nc yl Ale Jer Mcc Lan lan si Dan Kar Mat Gre ue rg Fi Sp ari Str Mer San Cu rm Mon Win Bel Nor ut ah Pi gh av ci Don ot dr lt ger co Ben Lor Fl Jac Wal Ger tte mo Er ga ert tr ian Cro ff Ver Lin Gil Ken Che Jan nne arr va ers all Cal Cas Hil Han Dor Gl ag we Ed Em ran han Cle im arl wa ug ls ca Ric Par Kel Hen Nic len sk uc ina ste ab err Or Am Mor Fer Rob Luc ob Lar Bea ner pe lm ba ren lla der ec ric Ash Ant Fre rri Den Ham Mic Dem Is As Au che Leo nna rin enn Mal Jam Mad Mcg Wh Ab War Ol ler Whi Es All For ud ord Dea eb nk Woo tin ore art Dr tz Ly Pat Per Kri Min Bet rie Flo rne Joh nni Ce Ty Za ins eli ye rc eo ene ist ev Der Des Val And Can Shi ak Gal Cat Eli May Ea rk nge Fu Qu nie oc um ath oll bi ew Far ich Cra The Ran ani Dav Tra Sal Gri Mos Ang Ter mb Jay les Kir Tu hr oe Tri lia Fin mm aw dy cke itt ale wi eg est ier ze ru sc My lb har ka mer sti br ya Gen Hay a b c d e f g h i j k l m n o p q r s t u v w x y z");
$word_delims = explode(" ", "0 1 2 3 3 3 4 5 5 6 7 8 9 - - - - - - - _ _ _ _ _ _ _ . . . . . . .");
$n_dom = count($domains)-1;
$n_trp = count($traps)-1;
$n_wpt = count($word_parts)-1;
$n_wdl = count($word_delims)-1;
for ($n = 1; $n < EWIKI_FAKE_EMAIL_LOOP; $n++) {
// email name part
$m = "";
while (strlen($m) < rand(3,17)) {
$a = $word_parts[nat_rand($n_wpt)];
if (!empty($m)) {
$a = strtolower($a);
if (rand(1,9)==5) {
$m .= $word_delims[rand(0,$n_wdl)];
}
}
$m .= $a;
}
// add domain
switch ($dom = $domains[rand(0, $n_dom)]) {
case "123webhosting.org":
$m = strtr(".", "-", getremoteaddr())."-".$_SERVER["SERVER_NAME"]."-".time();
break;
default:
}
$m .= $dom;
$html .= '<a href="mailto:'.$m.'">'.$m.'</a>'.",\n";
}
$html .= '<a href="mailto:'.$traps[rand(0, $n_trp)].'">'.$traps[rand(0, $n_trp)].'</a>';
if (($rl = 1 + $ewiki_up_requestlv) < EWIKI_FAKE_EMAIL_LOOP) {
$html .= ",\n" . '<br /><a href="' .
ewiki_script("", EWIKI_PAGE_EMAIL,
array(
EWIKI_UP_ENCEMAIL=>ewiki_email_protect_encode($m, 1),
EWIKI_UP_REQUESTLV=>"$rl"
)
) . '">' . ewiki_t("PROTE5") . '</a><br />' . "\n";
($rl > 1) && sleep(3);
}
sleep(1);
return($html);
}
function nat_rand($max, $dr=0.5) {
$x = $max+1;
while ($x > $max) {
$x = rand(0, $max * 1000)/100;
$x = $x * $dr + $x * $x / 2 * (1-$dr) / $max;
}
return((int)$x);
}
@@ -1,121 +0,0 @@
<?php
# if someone uploads an image, which is larger than the allowed
# image size (EWIKI_IMAGE_MAXSIZE), then this plugin tries to
# rescale that image until it fits; it utilizes the PHP libgd
# functions to accomplish this
# NOTE: It is currently disabled for Win32, because nobody knows, if
# this will crash the PHP interpreter on those systems.
define("EWIKI_IMGRESIZE_WIN", 0);
if (!strstr(PHP_VERSION, "-dev") && !function_exists("imagecreate") && function_exists("dl")) { #-- try to load gd lib
@dl("php_gd2.dll") or @dl("gd.so");
}
if (function_exists("imagecreate")) {
$ewiki_plugins["image_resize"][] = "ewiki_binary_resize_image_gd";
}
function ewiki_binary_resize_image_gd(&$filename, &$mime, $return=0) {
/*** this disallows Win32 ***/
if ( (DIRECTORY_SEPARATOR!="/") && !EWIKI_IMAGERESIZE_WIN
|| (strpos($mime, "image/")!==0) )
{
return(false);
}
$tmp_rescale = $filename;
#-- initial rescale
$r = EWIKI_IMAGE_MAXSIZE / filesize($tmp_rescale);
$r = ($r) + ($r - 1) * ($r - 1);
#-- read orig image
strtok($mime, "/");
$type = strtok("/");
if (function_exists($pf = "imagecreatefrom$type")) {
$orig_image = $pf($filename);
}
else {
return(false);
}
$orig_x = imagesx($orig_image);
$orig_y = imagesy($orig_image);
#-- change mime from .gif to .png
if (($type == "gif") && (false || function_exists("imagepng") && !function_exists("imagegif"))) {
$type = "png";
}
#-- retry resizing
$loop = 20;
while (($loop--) && (filesize($tmp_rescale) > EWIKI_IMAGE_MAXSIZE)) {
if ($filename == $tmp_rescale) {
$tmp_rescale = tempnam(EWIKI_TMP, "ewiki.img_resize_gd.tmp.");
}
#-- sizes
$new_x = (int) ($orig_x * $r);
$new_y = (int) ($orig_y * $r);
#-- new gd image
$tc = function_exists("imageistruecolor") && imageistruecolor($orig_image);
if (!$tc || ($type == "gif")) {
$new_image = imagecreate($new_x, $new_y);
imagepalettecopy($new_image, $orig_image);
}
else {
$new_image = imagecreatetruecolor($new_x, $new_y);
}
#-- resize action
imagecopyresized($new_image, $orig_image, 0,0, 0,0, $new_x,$new_y, $orig_x,$orig_y);
#-- special things
if ( ($type == "png") && function_exists("imagesavealpha") ) {
imagesavealpha($new_image, 1);
}
#-- save
if (function_exists($pf = "image$type")) {
$pf($new_image, $tmp_rescale);
}
else {
return(false); # cannot save in orig format (.gif)
}
#-- prepare next run
imagedestroy($new_image);
clearstatcache();
$r *= 0.95;
}
#-- stop
imagedestroy($orig_image);
#-- security check filesizes, abort
if (!filesize($filename) || !filesize($tmp_rescale) || (filesize($tmp_rescale) > EWIKI_IMAGE_MAXSIZE)) {
unlink($tmp_rescale);
return($false);
}
#-- set $mime, as it may have changed (.gif)
$mime = strtok($mime, "/") . "/" . $type;
if (!strstr($filename, ".$type")) {
unlink($filename);
$filename .= ".$type";
}
#-- move tmp file to old name
copy($tmp_rescale, $filename);
unlink($tmp_rescale);
return(true);
}
-125
View File
@@ -1,125 +0,0 @@
<?php
/*
This plugin is used as SetupWizard and initializes the database with
the distributed default pages from the ./init-pages directory. It
gives some configuration advice, when it thinks this is necessary.
You need this plugin to run only once (when you first run the Wiki),
afterwards you can and should comment out the include() directive which
enabled it.
*/
$ewiki_plugins["handler"][-125] = "ewiki_initialization_wizard";
$ewiki_plugins["page_init"][] = "ewiki_initialization_wizard2";
function ewiki_initialization_wizard2($id, &$data, $action) {
global $ewiki_plugins;
#-- disable the default handler
unset($ewiki_plugins["handler"][-105]);
}
function ewiki_initialization_wizard($id, &$data, &$action) {
global $ewiki_plugins;
$abort = optional_param('abort', false);
$init = optional_param('init', '', PARAM_BOOL);
#-- proceed only if frontpage missing or explicetely requested
if ((strtolower($id)=="wikisetupwizard") || ($id==EWIKI_PAGE_INDEX) && ($action=="edit") && empty($data["version"]) && !($abort)) {
if ($abort) {
}
#-- first print some what-would-we-do-stats
elseif (empty($init)) {
$o = "<h2>WikiSetupWizard</h2>\n";
$o .= "You don't have any pages in your Wiki yet, so we should try to read-in the default ones from <tt>init-pages/</tt> now.<br /><br />";
$o .= '<a href="'.ewiki_script("",$id,array("init"=>"now")).'">[InitializeWikiDatabase]</a>';
$o .= " &nbsp; ";
$o .= '<a href="'.ewiki_script("",$id,array("abort"=>"this")).'">[NoThanks]</a>';
$o .= "<br /><br />";
#-- analyze and print settings and misconfigurations
$pf_db = $ewiki_plugins["database"][0];
$xdb = substr($pf_db, strrpos($pf_db, "_") + 1);
$o .= '<table border="0" width="90%" class="diagnosis">';
$o .= '<tr><td>DatabaseBackend</td><td>';
$o .= "<b>" . $xdb . "</b><br />";
if ($xdb == "files") {
$o .= "<small>_DBFILES_DIR='</small><tt>" . EWIKI_DBFILES_DIRECTORY . "'</tt>";
if (strpos(EWIKI_DBFILES_DIRECTORY, "tmp")) {
$o .= "<br /><b>Warning</b>: Storing your pages into a temporary directory is not what you want (there they would get deleted randomly), except for testing purposes of course. See the README.";
}
}
else {
$o .= "(looks ok)";
}
$o .= "</td></tr>";
$o .= '<tr><td>WikiSoftware</td><td>ewiki '.EWIKI_VERSION."</td></tr>";
$o .= "</table>";
#-- more diagnosis
if (ini_get("magic_quotes")) {
$o.= "<b>Warning</b>: Your PHP interpreter has enabled the ugly and outdated '<i>magic_quotes</i>'. This will lead to problems, so please ask your provider to correct it; or fix it yourself with .htaccess settings as documented in the README. Otherwise don't forget to include() the <tt>fragments/strip_wonderful_slashes.php</tt> (it's ok to proceed for the moment).<br /><br />";
}
if (ini_get("register_globals")) {
$o.= "<b>Security warning</b>: The horrible '<i>register_globals</i>' setting is enabled. Without always using <tt>fragments/strike_register_globals.php</tt> or letting your provider fix that, you could get into trouble some day.<br /><br />";
}
return('<div class="wiki view WikiSetupWizard">' . $o . '</div>');
}
#-- actually initialize the database
else {
ewiki_database("INIT", array());
if ($dh = @opendir($path=EWIKI_INIT_PAGES)) {
while (false !== ($filename = readdir($dh))) {
if (preg_match('/^(['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+\w*)+/', $filename)) {
$found = ewiki_database("FIND", array($filename));
if (! $found[$filename]) {
$content = implode("", file("$path/$filename"));
ewiki_scan_wikiwords($content, $ewiki_links, "_STRIP_EMAIL=1");
$refs = "\n\n" . implode("\n", array_keys($ewiki_links)) . "\n\n";
$save = array(
"id" => "$filename",
"version" => "1",
"flags" => "1",
"content" => $content,
"author" => ewiki_author("ewiki_initialize"),
"refs" => $refs,
"lastmodified" => filemtime("$path/$filename"),
"created" => filectime("$path/$filename") // (not exact)
);
ewiki_database("WRITE", $save);
}
}
}
closedir($dh);
}
else {
return("<b>ewiki error</b>: could not read from directory ". realpath($path) ."<br />\n");
}
#-- try to view/ that newly inserted page
if ($data = ewiki_database("GET", array("id"=>$id))) {
$action = "view";
}
#-- let ewiki_page() proceed as usual
return("");
}
}
}
-100
View File
@@ -1,100 +0,0 @@
<?php
/*
This plugin adds a page redirection feature. ewiki instantly switches
to another page, when one of the following markup snippets is found:
[jump:AnotherPage]
[goto:SwitchToHere]
or
[jump:WardsWiki:WelcomeVisitors]
[jump:Google:ErfurtWiki:MarioSalzer]
[jump:http://www.heise.de/]
One can also use [redirect:] or [location:]. Page switching only occours
with the "view" action. Sending a HTTP redirect is the default, but in
place redirects are also possible.
There exists a loop protection, which limits redirects to 5 (for browsers
that cannot detect this themselfes).
*/
#-- config
define("EWIKI_JUMP_HTTP", 1); #-- issue a HTTP redirect, or jump in place
define("EWIKI_UP_REDIRECT_COUNT", "redir");
#-- text
$ewiki_t["en"]["REDIRECTION_LOOP"] = "<h2>Redirection loop detected<h2>\nOperation stopped, because we're traped in an infinite redirection loop with page \$id.";
#-- plugin glue
$ewiki_plugins["handler"][] = "ewiki_handler_jump";
$ewiki_config["interwiki"]["jump"] = "";
$ewiki_config["interwiki"]["goto"] = "";
function ewiki_handler_jump(&$id, &$data, &$action) {
global $ewiki_config;
static $redirect_count = 5;
$redirect_count = optional_param("EWIKI_UP_REDIRECT_COUNT", $redirect_count, PARAM_INT);
$jump_markup = array("jump", "goto", "redirect", "location");
#-- we only care about "view" action
if ($action != "view") {
return;
}
#-- escape from loop
if ($redirect_count-- <= 0) {
return(ewiki_t("REDIRECTION_LOOP", array("id"=>$id)));
}
#-- search for [jump:...]
if ($links = explode("\n", trim($data["refs"])))
foreach ($links as $link) {
if (strlen($link) && strpos($link, ":")
&& in_array(strtolower(strtok($link, ":")), $jump_markup)
&& ($dest = trim(strtok("\n"))) )
{
$url = "";
if (strpos($dest, "://")) {
$url = $dest;
}
else {
$url = ewiki_interwiki($dest);
}
#-- Location:
if (EWIKI_JUMP_HTTP && EWIKI_HTTP_HEADERS && !headers_sent()) {
if (empty($url)) {
$url = ewiki_script("", $dest,
array(EWIKI_UP_REDIRECT_COUNT=>$redirect_count),
0, 0, ewiki_script_url()
);
}
header("Location: $url");
die();
}
#-- show page as usual, what will reveal dest URL
elseif ($url) {
return("");
# the rendering kernel will just show up the [jump:]!
# (without the jump: of course)
}
#-- it's simply about another WikiPage
else {
#-- we'll just restart ewiki
$data = array();
$id = $dest;
return(ewiki_page("view/".$id));
}
}
}#-search
}
-571
View File
@@ -1,571 +0,0 @@
<?php ############################ <license>GPL</license> #####################
/*
# this was originally implemented for Nanoweb, but can now be used
# within ewiki to enhance the download/upload plugin.
# As it was created from Debians mime-magic data, it is covered by
# the GNU GPL [http://www.gnu.org/]:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
$ewiki_plugins["mime_magic"][] = "ewiki_mime_magic";
function ewiki_mime_magic(&$binary_data) {
global $mime_magic_data;
$fd = substr($binary_data, 0, 3072);
foreach ($mime_magic_data as $def) {
if ($def[0] >= $f_read) {
continue;
}
$pos0 = $def[0];
if ($pos0[0] == ">") {
$pos0 = substr($pos0, 1);
if (strpos($fd, $def[3], $pos0) !== false) {
return($def[4]);
}
}
else {
$part = substr($fd, $pos0, $def[1]);
if ($mask = $def[2]) {
$value = 1 * ('0x'.bin2hex($part));
if (($value & $mask) == $def[3]) {
return($def[4]);
}
}
else {
if ($part == $def[3]) {
return($def[4]);
}
}
}
}
}
$GLOBALS["mime_magic_data"] = array(
array(0, 2, 0, "\x06\x02", "application/x-alan-adventure-game"),
array(0, 4, 0, "TADS", "application/x-tads-game"),
array(0, 2, 0, "\x01\x10", "application/x-executable-file"),
array(0, 2, 0, "\x01\x11", "application/x-executable-file"),
array(0, 2, 0, "\x01", "application/x-executable-file"),
array(0, 5, 0, "Core\001", "application/x-executable-file"),
array(0, 22, 0, "AMANDA: TAPESTART DATE", "application/x-amanda-header"),
array(0, 2, 0xfff0, 0xf0ff, "audio/mpeg"),
array(4, 2, 0, "\x11", "video/fli"),
array(4, 2, 0, "\x12", "video/flc"),
array(0, 4, 0, "MOVI", "video/x-sgi-movie"),
array(4, 4, 0, "moov", "video/quicktime"),
array(4, 4, 0, "mdat", "video/quicktime"),
array(0, 18, 0, "FiLeStArTfIlEsTaRt", "text/x-apple-binscii"),
array(0, 3, 0, "\x0aGL", "application/data"),
array(0, 2, 0, "\x76\xff", "application/data"),
array(0, 6, 0, "NuFile", "application/data"),
array(0, 6, 0, "N\xf5F\xe9l\xe5", "application/data"),
array(0, 4, 0, "\x00\x16\x05\x00", "application/data"),
array(0, 4, 0, "\x07\x16\x05\x00", "application/data"),
array(257, 6, 0, "ustar\0", "application/x-tar"),
array(257, 8, 0, "ustar\040\040\0", "application/x-gtar"),
array(0, 2, 0, "q", "application/x-cpio"),
array(0, 2, 0, "q", "application/x-bcpio"),
array(0, 6, 0, "070707", "application/x-cpio"),
array(0, 6, 0, "070701", "application/x-cpio"),
array(0, 6, 0, "070702", "application/x-cpio"),
array(0, 2, 0, "m", "application/data"),
array(0, 2, 0, "e", "application/data"),
array(0, 5, 0, "=<ar>", "application/x-ar"),
array(0, 19, 0, "!<arch>\n__________E", "application/x-ar"),
array(0, 3, 0, "-h-", "application/data"),
array(0, 7, 0, "!<arch>", "application/x-ar"),
array(0, 4, 0, "<ar>", "application/x-ar"),
array(0, 4, 0, ">ra<", "application/x-ar"),
array(0, 4, 0, "!<ar", "application/x-ar"),
array(0, 4, 0, "\x00\x03", "application/data"),
array(0, 4, 0, "\x00\x03", "application/data"),
array(0, 4, 0x8080ffff, 0x81a, "application/x-arc"),
array(0, 4, 0x8080ffff, 0x91a, "application/x-arc"),
array(0, 4, 0x8080ffff, 0x21a, "application/x-arc"),
array(0, 4, 0x8080ffff, 0x31a, "application/x-arc"),
array(0, 4, 0x8080ffff, 0x41a, "application/x-arc"),
array(0, 4, 0x8080ffff, 0x61a, "application/x-arc"),
array(0, 8, 0, "\032archive", "application/data"),
array(0, 2, 0, "`", "application/x-arj"),
array(0, 4, 0, "HPAK", "application/data"),
array(0, 8, 0, "\351,\001JAM\ ", "application/data"),
array(2, 5, 0, "-lh0-", "application/x-lha"),
array(2, 5, 0, "-lh1-", "application/x-lha"),
array(2, 5, 0, "-lz4-", "application/x-lha"),
array(2, 5, 0, "-lz5-", "application/x-lha"),
array(2, 5, 0, "-lzs-", "application/x-lha"),
array(2, 5, 0, "-lh\40-", "application/x-lha"),
array(2, 5, 0, "-lhd-", "application/x-lha"),
array(2, 5, 0, "-lh2-", "application/x-lha"),
array(2, 5, 0, "-lh3-", "application/x-lha"),
array(2, 5, 0, "-lh4-", "application/x-lha"),
array(2, 5, 0, "-lh5-", "application/x-lha"),
array(0, 4, 0, "Rar!", "application/x-rar"),
array(0, 4, 0, "SQSH", "application/data"),
array(0, 4, 0, "UC2\x1a", "application/data"),
array(0, 4, 0, "PK\003\004", "application/zip"),
array(20, 4, 0, "ħ", "application/x-zoo"),
array(10, 25, 0, "# This is a shell archive", "application/x-shar"),
array(0, 4, 0, "*STA", "application/data"),
array(0, 4, 0, "2278", "application/data"),
array(0, 2, 0, "p\x01", "application/x-executable-file"),
array(0, 2, 0, "q\x01", "application/x-executable-file"),
array(0, 5, 0, "\000\004\036\212\200", "application/core"),
array(0, 4, 0, ".snd", "audio/basic"),
array(0, 4, 0, "\x00ds.", "audio/basic"),
array(0, 4, 0, "MThd", "audio/midi"),
array(0, 4, 0, "CTMF", "audio/x-cmf"),
array(0, 3, 0, "SBI", "audio/x-sbi"),
array(0, 19, 0, "Creative Voice File", "audio/x-voc"),
array(0, 4, 0, "KRTN", "audio/x-multitrack"),
array(0, 4, 0, "RIFF", "audio/x-wav"),
array(0, 4, 0, "EMOD", "audio/x-emod"),
array(0, 4, 0, "ar.", "audio/x-pn-realaudio"),
array(0, 3, 0, "MTM", "audio/x-multitrack"),
array(0, 2, 0, "if", "audio/x-669-mod"),
array(0, 3, 0, "FAR", "audio/mod"),
array(0, 5, 0, "MAS_U", "audio/x-multimate-mod"),
array(0x2c, 4, 0, "SCRM", "audio/x-st3-mod"),
array(0, 22, 0, "GF1PATCH110\0ID#000002\0", "audio/x-gus-patch"),
array(0, 22, 0, "GF1PATCH100\0ID#000002\0", "audio/x-gus-patch"),
array(0, 2, 0, "JN", "audio/x-669-mod"),
array(0, 4, 0, "UN05", "audio/x-mikmod-uni"),
array(21, 8, 0, "!SCREAM!", "audio/x-st2-mod"),
array(1080, 4, 0, "M.K.", "audio/x-protracker-mod"),
array(1080, 4, 0, "M!K!", "audio/x-protracker-mod"),
array(1080, 4, 0, "FLT4", "audio/x-startracker-mod"),
array(1080, 4, 0, "4CHN", "audio/x-fasttracker-mod"),
array(1080, 4, 0, "6CHN", "audio/x-fasttracker-mod"),
array(1080, 4, 0, "8CHN", "audio/x-fasttracker-mod"),
array(1080, 4, 0, "CD81", "audio/x-oktalyzer-mod"),
array(1080, 4, 0, "OKTA", "audio/x-oktalyzer-mod"),
array(1080, 4, 0, "16CN", "audio/x-taketracker-mod"),
array(1080, 4, 0, "32CN", "audio/x-taketracker-mod"),
array(0, 3, 0, "TOC", "audio/x-toc"),
array(0, 2, 0, "\x07\x01", "application/x-executable-file"),
array(0, 2, 0, "\x01\x06", "application/x-executable-file"),
array(0, 2, 0, "\x06\x01", "application/x-executable-file"),
array(0, 2, 0, "//", "text/cpp"),
array(0, 5, 0, "\\1cw ", "application/data"),
array(0, 4, 0, "\\1cw", "application/data"),
array(0, 4, 0xffffff00, 0x140185, "application/data"),
array(0, 4, 0xffffff00, 0xcb0185, "application/data"),
array(0, 2, 0, "\x01}", "application/x-executable-file"),
array(0, 2, 0, "\x01", "application/x-executable-file"),
array(4, 4, 0, "pipe", "application/data"),
array(4, 4, 0, "prof", "application/data"),
array(0, 9, 0, "#!/bin/sh", "application/x-sh"),
array(0, 10, 0, "#! /bin/sh", "application/x-sh"),
array(0, 11, 0, "#!\ /bin/sh", "application/x-sh"),
array(0, 10, 0, "#!/bin/csh", "application/x-csh"),
array(0, 11, 0, "#! /bin/csh", "application/x-csh"),
array(0, 12, 0, "#!\ /bin/csh", "application/x-csh"),
array(0, 10, 0, "#!/bin/ksh", "application/x-ksh"),
array(0, 11, 0, "#! /bin/ksh", "application/x-ksh"),
array(0, 12, 0, "#!\ /bin/ksh", "application/x-ksh"),
array(0, 17, 0, "#!/usr/local/tcsh", "application/x-csh"),
array(0, 21, 0, "#!/usr/local/bin/tcsh", "application/x-csh"),
array(0, 22, 0, "#! /usr/local/bin/tcsh", "application/x-csh"),
array(0, 23, 0, "#!\ /usr/local/bin/tcsh", "application/x-csh"),
array(0, 20, 0, "#!/usr/local/bin/zsh", "application/x-zsh"),
array(0, 21, 0, "#! /usr/local/bin/zsh", "application/x-zsh"),
array(0, 22, 0, "#!\ /usr/local/bin/zsh", "application/x-zsh"),
array(0, 20, 0, "#!/usr/local/bin/ash", "application/x-sh"),
array(0, 21, 0, "#! /usr/local/bin/ash", "application/x-zsh"),
array(0, 22, 0, "#!\ /usr/local/bin/ash", "application/x-zsh"),
array(0, 19, 0, "#!/usr/local/bin/ae", "text/script"),
array(0, 20, 0, "#! /usr/local/bin/ae", "text/script"),
array(0, 21, 0, "#!\ /usr/local/bin/ae", "text/script"),
array(0, 11, 0, "#!/bin/nawk", "application/x-awk"),
array(0, 12, 0, "#! /bin/nawk", "application/x-awk"),
array(0, 13, 0, "#!\ /bin/nawk", "application/x-awk"),
array(0, 15, 0, "#!/usr/bin/nawk", "application/x-awk"),
array(0, 16, 0, "#! /usr/bin/nawk", "application/x-awk"),
array(0, 17, 0, "#!\ /usr/bin/nawk", "application/x-awk"),
array(0, 21, 0, "#!/usr/local/bin/nawk", "application/x-awk"),
array(0, 22, 0, "#! /usr/local/bin/nawk", "application/x-awk"),
array(0, 23, 0, "#!\ /usr/local/bin/nawk", "application/x-awk"),
array(0, 11, 0, "#!/bin/gawk", "application/x-awk"),
array(0, 12, 0, "#! /bin/gawk", "application/x-awk"),
array(0, 13, 0, "#!\ /bin/gawk", "application/x-awk"),
array(0, 15, 0, "#!/usr/bin/gawk", "application/x-awk"),
array(0, 16, 0, "#! /usr/bin/gawk", "application/x-awk"),
array(0, 17, 0, "#!\ /usr/bin/gawk", "application/x-awk"),
array(0, 21, 0, "#!/usr/local/bin/gawk", "application/x-awk"),
array(0, 22, 0, "#! /usr/local/bin/gawk", "application/x-awk"),
array(0, 23, 0, "#!\ /usr/local/bin/gawk", "application/x-awk"),
array(0, 10, 0, "#!/bin/awk", "application/x-awk"),
array(0, 11, 0, "#! /bin/awk", "application/x-awk"),
array(0, 12, 0, "#!\ /bin/awk", "application/x-awk"),
array(0, 14, 0, "#!/usr/bin/awk", "application/x-awk"),
array(0, 15, 0, "#! /usr/bin/awk", "application/x-awk"),
array(0, 16, 0, "#!\ /usr/bin/awk", "application/x-awk"),
array(0, 5, 0, "BEGIN", "application/x-awk"),
array(0, 11, 0, "#!/bin/perl", "application/x-perl"),
array(0, 12, 0, "#! /bin/perl", "application/x-perl"),
array(0, 13, 0, "#!\ /bin/perl", "application/x-perl"),
array(0, 20, 0, "eval \"exec /bin/perl", "application/x-perl"),
array(0, 15, 0, "#!/usr/bin/perl", "application/x-perl"),
array(0, 16, 0, "#! /usr/bin/perl", "application/x-perl"),
array(0, 17, 0, "#!\ /usr/bin/perl", "application/x-perl"),
array(0, 24, 0, "eval \"exec /usr/bin/perl", "application/x-perl"),
array(0, 21, 0, "#!/usr/local/bin/perl", "application/x-perl"),
array(0, 22, 0, "#! /usr/local/bin/perl", "application/x-perl"),
array(0, 23, 0, "#!\ /usr/local/bin/perl", "application/x-perl"),
array(0, 30, 0, "eval \"exec /usr/local/bin/perl", "application/x-perl"),
array(0, 9, 0, "#!/bin/rc", "text/script"),
array(0, 10, 0, "#! /bin/rc", "text/script"),
array(0, 11, 0, "#!\ /bin/rc", "text/script"),
array(0, 11, 0, "#!/bin/bash", "application/x-sh"),
array(0, 12, 0, "#! /bin/bash", "application/x-sh"),
array(0, 13, 0, "#!\ /bin/bash", "application/x-sh"),
array(0, 21, 0, "#!/usr/local/bin/bash", "application/x-sh"),
array(0, 22, 0, "#! /usr/local/bin/bash", "application/x-sh"),
array(0, 23, 0, "#!\ /usr/local/bin/bash", "application/x-sh"),
array(0, 4, 0, "#! /", "text/script"),
array(0, 5, 0, "#!\ /", "text/script"),
array(0, 3, 0, "#!/", "text/script"),
array(0, 3, 0, "#! ", "text/script"),
array(0, 2, 0, "\037\235", "application/compress"),
array(0, 2, 0, "\037\213", "application/x-gzip"),
array(0, 2, 0, "\037\036", "application/data"),
array(0, 2, 0, "\x1f\x1f", "application/data"),
array(0, 2, 0, "\x1f", "application/data"),
array(0, 2, 0, "\377\037", "application/data"),
array(0, 2, 0, "\x05", "application/data"),
array(0, 3, 0, "BZh", "application/x-bzip2"),
array(0, 2, 0, "v", "application/data"),
array(0, 2, 0, "v", "application/data"),
array(0, 2, 0, "v", "application/x-lzh"),
array(0, 2, 0, "\037\237", "application/data"),
array(0, 2, 0, "\037\236", "application/data"),
array(0, 2, 0, "\037\240", "application/data"),
array(0, 2, 0, "BZ", "application/x-bzip"),
array(0, 9, 0, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", "application/data"),
array(0, 4, 0, "W\x12\x01\x00", "application/core"),
array(0, 4, 0, "ΚW\x13", "application/x-gdbm"),
array(0, 4, 0, "\x13W", "application/x-gdbm"),
array(0, 4, 0, "GDBM", "application/x-gdbm"),
array(0, 4, 0, "a\x15\x06\x00", "application/x-db"),
array(0, 4, 0, "b1\x05\x00", "application/x-db"),
array(0, 23, 0, "=<list>\n<protocol bbn-m", "application/data"),
array(0, 5, 0, "diff ", "text/x-patch"),
array(0, 4, 0, "*** ", "text/x-patch"),
array(0, 8, 0, "Only in ", "text/x-patch"),
array(0, 23, 0, "Common subdirectories: ", "text/x-patch"),
array(0, 19, 0, "!<arch>\n________64E", "application/data"),
array(0, 2, 0, "\x01", "application/x-executable-file"),
array(0, 2, 0, "\x01", "application/x-object-file"),
array(0, 3, 0, "\377\377\177", "application/data"),
array(0, 3, 0, "\377\377\174", "application/data"),
array(0, 3, 0, "\377\377\176", "application/data"),
array(0, 3, 0, "\033c\033", "application/data"),
array(0, 4, 0, "\x00\x12և", "image/x11"),
array(0, 8, 0, "!<PDF>!\n", "application/x-prof"),
array(0, 2, 0, "\x05\x01", "application/x-locale"),
array(0, 4, 0, "\177ELF", "application/x-executable-file"),
array(0, 2, 0, "\x01T", "application/data"),
array(0, 2, 0, "\x01U", "application/x-executable-file"),
array(0x438, 2, 0, "S", "application/x-linux-ext2fs"),
array(0, 4, 0, "\366\366\366\366", "application/x-pc-floppy"),
array(0774, 2, 0, "", "application/data"),
array(0x1FE, 2, 0, "U", "application/data"),
array(0x410, 2, 0, "\x13", "application/x-filesystem"),
array(0x410, 2, 0, "\x13", "application/x-filesystem"),
array(0x410, 2, 0, "\x24h", "application/x-filesystem"),
array(0x410, 2, 0, "\x24x", "application/x-filesystem"),
array(0, 9, 0, "-rom1fs-\0", "application/x-filesystem"),
array(0, 4, 0, "\x1b\x03\x136", "application/x-bootable"),
array(0x18b, 4, 0, "OS/2", "application/x-bootable"),
array(0, 4, 0, "FONT", "font/x-vfont"),
array(0, 2, 0, "\x01\x1e", "font/x-vfont"),
array(0, 2, 0, "\x1e\x01", "font/x-vfont"),
array(0, 18, 0, "%!PS-AdobeFont-1.0", "font/type1"),
array(6, 18, 0, "%!PS-AdobeFont-1.0", "font/type1"),
array(0, 10, 0, "STARTFONT\040", "font/x-bdf"),
array(0, 4, 0, "\001fcp", "font/x-pcf"),
array(0, 5, 0, "D1.0\015", "font/x-speedo"),
array(0, 3, 0, "flf", "font/x-figlet"),
array(0, 3, 0, "flc", "application/x-font"),
array(0, 4, 0, "\x19Y\x02\x14", "font/x-libgrx"),
array(0, 4, 0, "NOF", "font/x-dos"),
array(7, 4, 0, "AGE\x00", "font/x-dos"),
array(7, 4, 0, "DIV\x00", "font/x-dos"),
array(0, 10, 0, "<MakerFile", "application/x-framemaker"),
array(0, 8, 0, "<MIFFile", "application/x-framemaker"),
array(0, 16, 0, "<MakerDictionary", "application/x-framemaker"),
array(0, 16, 0, "<MakerScreenFont", "font/x-framemaker"),
array(0, 4, 0, "<MML", "application/x-framemaker"),
array(0, 9, 0, "<BookFile", "application/x-framemaker"),
array(0, 6, 0, "<Maker", "application/x-framemaker"),
array(0, 4, 0377777777, 0x860107, "application/x-executable-file"),
array(0, 4, 0377777777, 0x860108, "application/x-executable-file"),
array(0, 4, 0377777777, 0x86010b, "application/x-executable-file"),
array(0, 4, 0377777777, 0x8600cc, "application/x-executable-file"),
array(7, 22, 0, "\357\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", "application/core"),
array(0, 4, 0, "LDHi", "application/data"),
array(0, 13, 0, "GIMP Gradient", "application/x-gimp-gradient"),
array(0, 8, 0, "gimp xcf", "application/x-gimp-image"),
array(20, 4, 0, "GPAT", "application/x-gimp-pattern"),
array(20, 4, 0, "GIMP", "application/x-gimp-brush"),
array(0, 4, 0, "\336\22\4\225", "application/x-locale"),
array(0, 4, 0, "\225\4\22\336", "application/x-locale"),
array(0, 2, 0, "\x01", "application/x-executable-file"),
array(0, 2, 0, "\x01", "application/x-executable-file"),
array(0, 5, 0, "\000\001\000\000\000", "font/ttf"),
array(0, 4, 0, "\x0a\x0f\x08\x0e", "application/data"),
array(0, 4, 0, "\x0f\x0a\x0e\x08", "application/data"),
array(0, 4, 0, "\x08\x0e\x0a\x0f", "application/data"),
array(0, 4, 0, "\x0e\x08\x0f\x0a", "application/data"),
array(0, 4, 0, "\x06\x01\x10\x02", "application/x-object-file"),
array(0, 4, 0, "\x07\x01\x10\x02", "application/x-executable-file"),
array(0, 4, 0, "\x08\x01\x10\x02", "application/x-executable-file"),
array(0, 4, 0, "\x0b\x01\x10\x02", "application/x-executable-file"),
array(0, 4, 0, "\x0e\x01\x10\x02", "application/x-library-file"),
array(0, 4, 0, "\x0d\x01\x10\x02", "application/x-library-file"),
array(0, 4, 0, "\x06\x01\x14\x02", "application/x-object-file"),
array(0, 4, 0, "\x07\x01\x14\x02", "application/x-executable-file"),
array(0, 4, 0, "\x08\x01\x14\x02", "application/x-executable-file"),
array(0, 4, 0, "\x0b\x01\x14\x02", "application/x-executable-file"),
array(0, 4, 0, "\x0e\x01\x14\x02", "application/x-library-file"),
array(0, 4, 0, "\x0d\x01\x14\x02", "application/x-object-file"),
array(0, 4, 0, "\x06\x01\x0b\x02", "application/x-object-file"),
array(0, 4, 0, "\x07\x01\x0b\x02", "application/x-executable-file"),
array(0, 4, 0, "\x08\x01\x0b\x02", "application/x-executable-file"),
array(0, 4, 0, "\x0b\x01\x0b\x02", "application/x-executable-file"),
array(0, 4, 0, "\x0e\x01\x0b\x02", "application/x-library-file"),
array(0, 4, 0, "\x0d\x01\x0b\x02", "application/x-library-file"),
array(0, 4, 0, "ra<!", "application/x-ar"),
array(0, 4, 0, "\x02\x08\x01\x06", "application/x-executable-file"),
array(0, 4, 0, "\x02\x08\x01\x07", "application/x-executable-file"),
array(0, 4, 0, "\x02\x08\x01\x08", "application/x-executable-file"),
array(0, 4, 0, "\x08\x01\x0c\x02", "application/x-executable-file"),
array(0, 4, 0, "\x07\x01\x0c\x02", "application/x-executable-file"),
array(0, 4, 0, "\x0b\x01\x0c\x02", "application/x-executable-file"),
array(0, 4, 0, "\x06\x01\x0c\x02", "application/x-executable-file"),
array(0, 4, 0, "\x08\x01\x0a\x02", "application/x-executable-file"),
array(0, 4, 0, "\x07\x01\x0a\x02", "application/x-executable-file"),
array(0, 4, 0, "\x0e\x01\x0c\x02", "application/x-library-file"),
array(0, 4, 0, "\x0d\x01\x0c\x02", "application/x-library-file"),
array(0, 4, 0, "\x02\x0ae", "application/x-library-file"),
array(0, 4, 0, "\x02\x0ce", "application/x-library-file"),
array(0, 4, 0, "\x02\x08e", "application/x-library-file"),
array(0, 4, 0, "\x01X!", "application/core"),
array(0, 4, 0, "M", "font/x-hp-windows"),
array(0, 10, 0, "Bitmapfile", "image/unknown"),
array(0, 4, 0, "\x02\x0c\x01\x0c", "application/x-lisp"),
array(0, 8, 0, "msgcat01", "application/x-locale"),
array(0, 2, 0, "P1", "image/x-portable-bitmap"),
array(0, 2, 0, "P2", "image/x-portable-graymap"),
array(0, 2, 0, "P3", "image/x-portable-pixmap"),
array(0, 2, 0, "P4", "image/x-portable-bitmap"),
array(0, 2, 0, "P5", "image/x-portable-graymap"),
array(0, 2, 0, "P6", "image/x-portable-pixmap"),
array(0, 4, 0, "IIN1", "image/tiff"),
array(0, 4, 0, "MM\x00\x2a", "image/tiff"),
array(0, 4, 0, "II\x2a\x00", "image/tiff"),
array(0, 4, 0, "\x89PNG", "image/x-png"),
array(1, 3, 0, "PNG", "image/x-png"),
array(0, 4, 0, "GIF8", "image/gif"),
array(0, 4, 0, "\361\0\100\273", "image/x-cmu-raster"),
array(0, 2, 0, "", "image/jpeg"),
array(0, 4, 0, "hsi1", "image/x-jpeg-proprietary"),
array(0, 2, 0, "BM", "image/x-bmp"),
array(0, 2, 0, "IC", "image/x-ico"),
array(0, 4, 0, "jY", "x/x-image-sun-raster"),
array(0, 2, 0, "\x01", "x/x-image-sgi"),
array(2048, 7, 0, "PCD_IPI", "x/x-photo-cd-pack-file"),
array(0, 7, 0, "PCD_OPA", "x/x-photo-cd-overfiew-file"),
array(0, 2, 0, "\x01H", "application/x-executable-file"),
array(0, 2, 0, "\x01I", "application/x-executable-file"),
array(0, 2, 0, "\x01J", "application/x-executable-file"),
array(0, 2, 0, "\x01R", "application/x-executable-file"),
array(0, 2, 0, "\x01L", "application/x-executable-file"),
array(0, 2, 0, "\x046", "font/linux-psf"),
array(0, 4, 0, "FFIL", "font/ttf"),
array(65, 4, 0, "FFIL", "font/ttf"),
array(0, 4, 0, "LWFN", "font/type1"),
array(65, 4, 0, "LWFN", "font/type1"),
array(0, 12, 0, "Return-Path:", "message/rfc822"),
array(0, 5, 0, "Path:", "message/news"),
array(0, 5, 0, "Xref:", "message/news"),
array(0, 5, 0, "From:", "message/rfc822"),
array(0, 7, 0, "Article", "message/news"),
array(0, 5, 0, "BABYL", "message/x-gnu-rmail"),
array(0, 9, 0, "Received:", "message/rfc822"),
array(0, 2, 0, "MZ", "application/x-ms-dos-executable"),
array(2080, 27, 0, "Microsoft Word 6.0 Document", "text/vnd.ms-word"),
array(2080, 26, 0, "Documento Microsoft Word 6", "text/vnd.ms-word"),
array(2112, 9, 0, "MSWordDoc", "text/vnd.ms-word"),
array(0, 5, 0, "PO^Q`", "text/vnd.ms-word"),
array(2080, 29, 0, "Microsoft Excel 5.0 Worksheet", "application/vnd.ms-excel"),
array(2114, 5, 0, "Biff5", "application/vnd.ms-excel"),
array(1, 3, 0, "WPC", "text/vnd.wordperfect"),
array(0, 4, 0377777777, 0x7018600, "NetBSD/i386"),
array(0, 4, 0377777777, 0x7018700, "NetBSD/m68k"),
array(0, 4, 0377777777, 0x7018800, "NetBSD/m68k4k"),
array(0, 4, 0377777777, 0x7018900, "NetBSD/ns32532"),
array(0, 4, 0377777777, 0x7018a00, "NetBSD/sparc"),
array(0, 4, 0377777777, 0x7018b00, "NetBSD/pmax"),
array(0, 4, 0377777777, 0x7018c00, "NetBSD/vax"),
array(0, 4, 0377777777, 0x7018e00, "NetBSD/mips"),
array(0, 4, 0377777777, 0x7018f00, "NetBSD/arm32"),
array(0, 16, 0, "StartFontMetrics", "font/x-sunos-news"),
array(0, 9, 0, "StartFont", "font/x-sunos-news"),
array(0, 4, 0, "D)z\x13", "font/x-sunos-news"),
array(0, 4, 0, "G)z\x13", "font/x-sunos-news"),
array(0, 4, 0, "P)z\x13", "font/x-sunos-news"),
array(0, 4, 0, "Q)z\x13", "font/x-sunos-news"),
array(8, 4, 0, "E+z\x13", "font/x-sunos-news"),
array(8, 4, 0, "H+z\x13", "font/x-sunos-news"),
array(0, 2, 0, "%!", "application/postscript"),
array(0, 3, 0, "\004%!", "application/postscript"),
array(0, 3, 0, "\033E\033", "image/x-pcl-hp"),
array(0, 14, 0, "<!DOCTYPE HTML", "text/html"),
array(0, 14, 0, "<!doctype html", "text/html"),
array(0, 5, 0, "<HEAD", "text/html"),
array(0, 5, 0, "<head", "text/html"),
array(0, 6, 0, "<TITLE", "text/html"),
array(0, 6, 0, "<title", "text/html"),
array(0, 5, 0, "<html", "text/html"),
array(0, 5, 0, "<HTML", "text/html"),
array(0, 2, 0, "\367\203", "font/x-tex"),
array(0, 2, 0, "\367\131", "font/x-tex"),
array(0, 2, 0, "\367\312", "font/x-tex"),
array(2, 2, 0, "\000\021", "font/x-tex-tfm"),
array(2, 2, 0, "\000\022", "font/x-tex-tfm"),
array('>2', 2, 0, "", "application/java"),
array(8, 4, 0, "AIFF", "audio/x-aiff"),
array(8, 4, 0, "AIFC", "audio/x-aiff"),
array(8, 4, 0, "8SVX", "audio/x-aiff"),
array('>8', 4, 0, "WAVE", "audio/x-wav"),
array('>8', 3, 0, "AVI", "video/x-msvideo"),
array(0, 3, 0, "ID3", "audio/mpeg"),
array(0, 4, 0, "OggS", "audio/x-ogg"),
array(0, 6, 0, "/* XPM", "image/x-xpm"),
array(16, 2, 0, "==", "image/x-3ds"),
array(0, 11, 0, "#!/bin/tcsh", "application/x-shellscript"),
array(0, 12, 0, "#! /bin/tcsh", "application/x-shellscript"),
array(0, 18, 0, "#! /usr/local/tcsh", "application/x-shellscript"),
array('>8', 6, 0, "debian", "application/x-debian-package"),
array('>2', 2, 0, "", "application/x-rpm"),
array(2, 5, 0, "-lh -", "application/x-lha"),
array(2, 5, 0, "-lh6-", "application/x-lha"),
array(2, 5, 0, "-lh7-", "application/x-lha"),
array(0, 15, 0, "<MakerScreenFon", "application/x-frame"),
array(0, 5, 0, "<Book", "application/x-frame"),
array(0, 3, 0, "<h1", "text/html"),
array(0, 3, 0, "<H1", "text/html"),
array(0, 14, 0, "<!doctype HTML", "text/html"),
array(0, 2, 0, "MM", "image/tiff"),
array(0, 2, 0, "II", "image/tiff"),
array(0, 6, 0, "GIF94z", "image/unknown"),
array(0, 6, 0, "FGF95a", "image/unknown"),
array(0, 3, 0, "PBF", "image/unknown"),
array(0, 3, 0, "GIF", "image/gif"),
array(0, 4, 0, "\376\067\0\043", "application/msword"),
array(0, 6, 0, "\320\317\021\340\241\261", "application/msword"),
array(0, 6, 0, "\333\245-\0\0\0", "application/msword"),
array(0, 2, 0, "\x02", "application/x-dvi"),
array(0, 2, 0, "\x11", "video/fli"),
array(0, 2, 0, "\x12", "video/flc"),
array('>8', 4, 0, "AVI ", "video/avi"),
array(0, 1, 0, "\x01", "video/unknown"),
array(0, 1, 0, "\x02", "video/unknown"),
array(0, 19, 0, "[KDE Desktop Entry]", "application/x-kdelnk"),
array(0, 18, 0, "\# KDE Config File", "application/x-kdelnk"),
array(0, 7, 0, "\# xmcd", "text/xmcd"),
array(0, 4, 0, "\x8aMNG", "video/x-mng"),
array(0, 4, 0, "\x03\x00\x00", "application/x-executable-file"),
array(0, 4, 0, "\x03\x00\x00", "application/x-library-file"),
array(0, 4, 0, "\x01\x00\x00", "video/mpeg"),
array(0, 4, 0, "\x01\x00\x00", "video/mpeg"),
array(0, 4, 0, "\x00\x00l", "application/x-apl-workspace"),
array(0, 4, 0, "\x00\x00m", "application/x-ar"),
array(0, 4, 0, "\x00\x00e", "application/data"),
array(0, 4, 0, "\x00\x00\x01\x06", "application/x-executable-file"),
array(0, 4, 0, "G\x01\x00\x00", "application/x-object-file"),
array(0, 4, 0, "K\x01\x00\x00", "application/x-executable-file"),
array(0, 4, 0, "M\x01\x00\x00", "application/x-executable-file"),
array(0, 4, 0, "O\x01\x00\x00", "application/x-executable-file"),
array(24, 4, 0, "k\x00\x00", "application/data"),
array(24, 4, 0, "l\x00\x00", "application/data"),
array(24, 4, 0, "m\x00\x00", "application/data"),
array(24, 4, 0, "n\x00\x00", "application/data"),
array(0, 4, 0, "\x01\x00\x00", "application/x-object-file"),
array(0, 4, 0, "\x01\x00\x00", "application/data"),
array(24, 4, 0, "\x00\x00l", "application/x-dump"),
array(24, 4, 0, "\x00\x00k", "application/x-dump"),
array(0, 4, 0, "\x00\x001", "text/vnd.ms-word"),
array(0, 2, 0, "\x00\x00", "audio/mpeg"),
array('>16', 2, 0, "\x00\x01", "application/x-object"),
array('>16', 2, 0, "\x00\x02", "application/x-executable"),
array('>16', 2, 0, "\x00\x03", "application/x-sharedlib"),
array('>16', 2, 0, "\x00\x04", "application/x-coredump"),
array(0, 4, 0, "\x00\x00\x00", "application/x-executable-file"),
array(0, 4, 0, "\x04\x00\x00\x00", "font/x-snf"),
array(0, 4, 0, "\x00\x00\x00\x04", "font/x-snf"),
array('>12', 4, 0, "\x01\x00\x00\x00", "audio/basic"),
array('>12', 4, 0, "\x02\x00\x00\x00", "audio/basic"),
array('>12', 4, 0, "\x03\x00\x00\x00", "audio/basic"),
array('>12', 4, 0, "\x04\x00\x00\x00", "audio/basic"),
array('>12', 4, 0, "\x05\x00\x00\x00", "audio/basic"),
array('>12', 4, 0, "\x06\x00\x00\x00", "audio/basic"),
array('>12', 4, 0, "\x07\x00\x00\x00", "audio/basic"),
array('>12', 4, 0, "\x17\x00\x00\x00", "audio/x-adpcm"),
array('>12', 4, 0, "\x00\x00\x00\x01", "audio/x-dec-basic"),
array('>12', 4, 0, "\x00\x00\x00\x02", "audio/x-dec-basic"),
array('>12', 4, 0, "\x00\x00\x00\x03", "audio/x-dec-basic"),
array('>12', 4, 0, "\x00\x00\x00\x04", "audio/x-dec-basic"),
array('>12', 4, 0, "\x00\x00\x00\x05", "audio/x-dec-basic"),
array('>12', 4, 0, "\x00\x00\x00\x06", "audio/x-dec-basic"),
array('>12', 4, 0, "\x00\x00\x00\x07", "audio/x-dec-basic"),
array('>12', 4, 0, "\x00\x00\x00\x17", "audio/x-dec-adpcm")
);
@@ -1,60 +0,0 @@
<?php
/*
this plugin introduces markup for footnotes, use it like:
...
some very scientific sentence {{this is a footnote explaination}}
...
this may be useful in some rare cases; usually one should create
a WikiLink to explain a more complex task on another page;
your decision
*/
$ewiki_plugins["format_source"][] = "ewiki_format_source_footnotes";
function ewiki_format_source_footnotes (&$source) {
$notenum = 0;
$l = 0;
while (
($l = strpos($source, "{{", $l))
&& ($r = strpos($source, "}}", $l))
)
{
$l += 2;
#-- skip "{{...\n...}}"
if (strpos($source, "\n", $l) < $r) {
continue;
}
$notenum++;
#-- extract "footnote"
$footnote = substr($source, $l, $r - $l);
#-- strip "{{footnote}}"
$source = substr($source, 0, $l - 2)
. "<a href=\"#fn$notenum\">$notenum</a>"
. substr($source, $r + 2);
#-- add "footnote" to the end of the wiki page source
if ($notenum==1) {
$source .= "\n----";
}
$source .= "\n" .
"<a name=\"fn$notenum\">$notenum</a> ". $footnote . "\n<br />";
}
}
-114
View File
@@ -1,114 +0,0 @@
<?php
# this is the "stupid diff", which shows up changes between two
# saved versions of a WikiPage; even if working very unclean it
# allows to see what has changed
# it is accessible through the "info about page" action
$ewiki_plugins["action"]["diff"] = "ewiki_page_stupid_diff";
$ewiki_config["action_links"]["info"]["diff"] = "diff";
function ewiki_page_stupid_diff($id, $data, $action) {
global $wiki, $moodle_format;
if ($uu=$GLOBALS["ewiki_diff_versions"]) {
list($new_ver, $old_ver) = $uu;
$data = ewiki_database("GET", array("id" => $id, "version" => $new_ver));
}
else {
$new_ver = $data["version"];
$old_ver = $new_ver - 1;
}
if ($old_ver > 0) {
$data0 = ewiki_database("GET", array("id" => $id, "version" => $old_ver));
}
$a->new_ver=$new_ver;
$a->old_ver=$old_ver;
$a->pagename=$id;
$o = ewiki_make_title($id, get_string("differences","wiki",$a));
# Different handling for html: closes Bug #1530 - Wiki diffs useless when using HTML editor
if($wiki->htmlmode==2) {
/// first do the formatiing to get normal display format without filters
$options = new object();
$options->smiley = false;
$options->filter = false;
$content0 = format_text($data0['content'], $moodle_format, $options);
$content = format_text($data['content'], $moodle_format, $options);
/// Remove all new line characters. They will be placed at HTML line breaks.
$content0 = preg_replace('/\n|\r/i', ' ', $content0);
$content0 = preg_replace('/(\S)\s+(\S)/', '$1 $2', $content0); // Remove multiple spaces.
$content = preg_replace('/\n|\r/i', ' ', $content);
$content = preg_replace('/(\S)\s+(\S)/', '$1 $2', $content);
/// Replace <p>&nbsp;</p>
$content0 = preg_replace('#(<p( [^>]*)?>(&nbsp;|\s+)</p>)|(<p( [^>]*)?></p>)#i', "\n", $content0);
$content = preg_replace('#(<p( [^>]*)?>(&nbsp;|\s+)</p>)|(<p( [^>]*)?></p>)#i', "\n", $content);
/// Place new line characters at logical HTML positions.
$htmlendings = array('+(<br.*?>)+iU', '+(<p( [^>]*)?>)+iU', '+(</p>)+i', '+(<hr.*?>)+iU', '+(<ol.*?>)+iU',
'+(</ol>)+i', '+(<ul.*?>)+iU', '+(</ul>)+i', '+(<li.*?>)+iU', '+(</li>)+i',
'+(</tr>)+i', '+(<div.*?>)+iU', '+(</div>)+i');
$htmlrepl = array("\n\$1\n", "\n\$1\n", "\n\$1\n", "\n\$1\n", "\n\$1\n",
"\n\$1\n", "\n\$1\n", "\n\$1\n", "\n\$1\n", "\n\$1\n",
"\n\$1\n", "\n\$1\n", "\n\$1\n");
$content0 = preg_replace($htmlendings, $htmlrepl, $content0);
$content = preg_replace($htmlendings, $htmlrepl, $content);
} else {
$content0=$data0["content"];
$content=$data["content"];
}
$txt0 = preg_split("+\s*\n+", trim($content0));
$txt2 = preg_split("+\s*\n+", trim($content));
$diff0 = array_diff($txt0, $txt2);
$diff2 = array_diff($txt2, $txt0);
foreach ($txt2 as $i => $line) {
$i2 = $i;
while ($rm = $diff0[$i2++]) {
if($wiki->htmlmode == 2) {
if ($rm == '<br />') { //ugly hack to fix line breaks
$rm = '';
}
$o .= "<b>-</b><font color=\"#990000\">".format_text($rm, $moodle_format, $options)."</font><br />\n";
} else {
$o .= "<b>-</b><font color=\"#990000\"><tt>".s($rm)."</tt></font><br />\n";
}
unset($diff0[$i2-1]);
}
if (in_array($line, $diff2)) {
if($wiki->htmlmode == 2) {
if ($line == '<br />') { //ugly hack to fix line breaks
$line = '';
}
$o .= "<b>+</b><font color=\"#009900\">".format_text($line, $moodle_format, $options)."</font><br />\n";
} else {
$o .= "<b>+</b><font color=\"#009900\"><tt>".s($line)."</tt></font><br />\n";
}
}
else {
if($wiki->htmlmode == 2) {
$o .= format_text($line, $moodle_format, $options)."\n";
} else {
$o .= "&nbsp; ".s($line)."<br />\n";
}
}
}
foreach ($diff0 as $rm) {
$o .= "<b>-</b><font color=\"#990000\"> <tt>".s($rm)."</tt></font><br />\n";
}
return($o);
}
?>
-399
View File
@@ -1,399 +0,0 @@
<?php
require_once("../../config.php");
require_once($CFG->libdir.'/filelib.php');
# this is the upload/download plugin, which allows to put arbitrary binary
# files into the ewiki database using the provided specialized form, or the
# standard image upload form below every edit page (if EWIKI_ALLOW_BINARY)
#-- settings
# Defined in view.php
#define("EWIKI_UPLOAD_MAXSIZE", 2*1024*1024);
define("EWIKI_PAGE_UPLOAD", "FileUpload");
define("EWIKI_PAGE_DOWNLOAD", "FileDownload");
define("EWIKI_ACTION_ATTACHMENTS", "attachments"); #-- define to 0 to disable
#-- register plugin (main part)
$ewiki_plugins["page"][EWIKI_PAGE_UPLOAD] = "ewiki_page_fileupload";
$ewiki_plugins["page"][EWIKI_PAGE_DOWNLOAD] = "ewiki_page_filedownload";
$ewiki_plugins["action"]["binary"] = "ewiki_binary";
#-- allow per-page downloads
if (defined("EWIKI_ACTION_ATTACHMENTS") && EWIKI_ACTION_ATTACHMENTS) {
$ewiki_plugins["action"][EWIKI_ACTION_ATTACHMENTS] = "ewiki_action_attachments";
$ewiki_config["action_links"]["view"][EWIKI_ACTION_ATTACHMENTS] = "Attachments";
}
#-- icons (best given absolute to www root)
/*$ewiki_binary_icons = array(
".bin" => "/icons/exec.gif",
"application/" => "/icons/exec.gif",
"application/octet-stream" => "/icons/exec.gif",
".ogg" => "/icons/son.gif",
".jpeg" => "/icons/pic.gif",
"text/" => "/icons/txt.gif",
".pdf" => "/icons/txt.gif",
);*/
#-- the upload function __can__ use different sections
$ewiki_upload_sections = array(
"" => "main",
# "section2" => "section2",
);
#-- text, translations
$ewiki_t["en"]["UPLOAD0"] = "Use this form to upload an arbitrary binary file into the wiki:<br />";
$ewiki_t["en"]["UPL_NEWNAM"] = "Save with different filename";
$ewiki_t["en"]["UPL_INSECT"] = "Upload into section";
$ewiki_t["en"]["UPL_TOOLARGE"] = "Your upload has been rejected, because that file was too large!";
$ewiki_t["en"]["UPL_REJSECT"] = 'The given download section "$sect" has been rejected. Please only use the default ones, or tell the WikiAdmin to reenable per-page uploads; else others can\'t find your uploaded files easily.<br /><br />';
$ewiki_t["en"]["UPL_OK"] = "Your file was uploaded correctly, please see <a href=\"\$script".EWIKI_PAGE_DOWNLOAD."\">".EWIKI_PAGE_DOWNLOAD."</a>.<br /><br />";
$ewiki_t["en"]["UPL_ERROR"] = "We're sorry, but something went wrong during the file upload.<br /><br />";
$ewiki_t["en"]["DWNL_SEEUPL"] = 'See also <a href="$script'.EWIKI_PAGE_UPLOAD.'">FileUpload</a>, this page is only about downloading.<br /><br />';
$ewiki_t["en"]["DWNL_NOFILES"] = "No files uploaded yet.<br />\n";
$ewiki_t["en"]["file"] = "File";
$ewiki_t["en"]["of"] = "of";
$ewiki_t["en"]["comment"] = "Comment";
$ewiki_t["en"]["dwnl_section"] = "download section";
$ewiki_t["en"]["DWNL_ENTRY_FORMAT"] =
'<div class="download"><a href="$url">$icon$title</a><small>$size<br />'.
'uploaded on <b>$time</b>, downloaded <tt>$hits</tt> times<br />'.
'(<a href="$url">$id</a>)<br />'.
'$section'.'file is of type <tt>$type</tt>'.
'$comment'."</small></div><br />\n";
$ewiki_t["de"]["UPLOAD0"] = "Mit diesem Formular kannst du beliebige Dateien in das Wiki abspeichern:<br />";
$ewiki_t["de"]["UPL_NEWNAM"] = "Mit unterschiedlichem Dateinamen speichern";
$ewiki_t["de"]["UPL_INSECT"] = "Hochladen in Bereich:";
$ewiki_t["de"]["UPL_TOOLARGE"] = "Deine Datei wurde nicht aufgenommen, weil sie zu gro war!";
$ewiki_t["de"]["UPL_REJSECT"] = 'Der angegebene Download-Bereich "$sect" wird nicht verwendet. Bitte verwende einen von den voreingestellten Bereichen, damit Andere die Datei spter auch finden knnen, oder frag den Administrator das Hochladen fr beliebige Seiten zu aktivieren.<br /><br />';
$ewiki_t["de"]["UPL_OK"] = "Deine Datei wurde korrekt hochgeladen, sehe einfach auf der <a href=\"\$script".EWIKI_PAGE_DOWNLOAD."\">".EWIKI_PAGE_DOWNLOAD."</a> nach.<br /><br />";
$ewiki_t["de"]["UPL_ERROR"] = "'Tschuldige, aber irgend etwas ist whrend des Hochladens grndlich schief gelaufen.<br /><br />";
$ewiki_t["de"]["DWNL_SEEUPL"] = 'Siehe auch <a href="$script'.EWIKI_PAGE_UPLOAD.'">DateiHochladen</a>, auf dieser Seite stehen nur die Downloads.<br /><br />';
$ewiki_t["de"]["DWNL_NOFILES"] = "Noch keine Dateien hochgeladen.<br />\n";
$ewiki_t["de"]["file"] = "Datei";
$ewiki_t["de"]["of"] = "von";
$ewiki_t["de"]["comment"] = "Kommentar";
$ewiki_t["de"]["dwnl_section"] = "Download Bereich";
$ewiki_t["de"]["DWNL_ENTRY_FORMAT"] =
'<div class="download"><a href="$url">$icon$title</a><small>$size<br />'.
'am <b>$time</b> hochgeladen, <tt>$hits</tt> mal abgerufen<br />'.
'(<a href="$url">$id</a>)<br />'.
'$section'.'Datei ist vom Typ <tt>$type</tt>'.
'$comment'."</small></div><br />\n";
function ewiki_page_fileupload($id, $data, $action, $def_sec="") {
global $CFG, $ewiki_upload_sections, $ewiki_plugins;
$o = ewiki_make_title($id, $id, 2);
$upload_file = $_FILES[EWIKI_UP_UPLOAD];
if (empty($upload_file)) {
$o .= ewiki_t("UPLOAD0");
$o .= '<div class="upload">'.
'<form action="' .
ewiki_script( ($action!="view" ? $action : ""), $id).
'" method="post" enctype="multipart/form-data">' ;
$o .= '<fieldset class="invisiblefieldset">';
require_once($CFG->dirroot.'/lib/uploadlib.php');
$o .= upload_print_form_fragment(1,array(EWIKI_UP_UPLOAD),array(ewiki_t("file")),false,null,0,0,true);
$o .= '<input type="submit" value="' . EWIKI_PAGE_UPLOAD . '" /><br /><br />'
.'<b>' . ewiki_t("comment") . '</b><br /><textarea name="comment" cols="35" rows="3"></textarea><br /><br />';
if (empty($ewiki_upload_sections[$def_sec])) {
$ewiki_upload_sections[$def_sec] = $def_sec;
}
if (count($ewiki_upload_sections) > 1) {
if (empty($def_sec)) {
$def_sec = optional_param('section', '', PARAM_CLEAN);
}
$o .= '<b>'.ewiki_t("UPL_INSECT").'</b><br /><select name="section">';
foreach ($ewiki_upload_sections as $id => $title) {
$o .= '<option value="'.$id.'"' .($id==$def_sec?' selected':''). '>'.$title.'</option>';
}
$o .= '</select><br /><br />';
}
$o .= '<b>'.ewiki_t("UPL_NEWNAM").'</b><br /><input type="text" name="new_filename" size="20" /><br /><br />';
$o .= '</fieldset></form></div>';
}
elseif ($upload_file["size"] > EWIKI_UPLOAD_MAXSIZE) {
$o .= ewiki_t("UPL_TOOLARGE");
}
else {
$meta = array(
"X-Content-Type" => $upload_file["type"],
#"X-Content-Length" => $upload_file["size"],
);
if (($s = $upload_file["name"]) && (strlen($s) >= 3)
|| ($s = substr(md5(time()+microtime()),0,8) . ".dat"))
{
if (strlen($uu = trim(optional_param("new_filename",'', PARAM_FILE))) >= 3) {
if ($uu != $s) {
$meta["Original-Filename"] = $s;
}
$s = $uu;
}
$meta["Content-Location"] = $s;
($p = 0) or
($p = strrpos($s, "/")) and ($p++) or
($p = strrpos($s, '\\')) and ($p++);
$meta["Content-Disposition"] = 'attachment; filename="'.urlencode(substr($s, $p)).'"';
}
if (strlen($sect = optional_param("section",'', PARAM_CLEAN))) {
if ($ewiki_upload_sections[$sect]
|| ($action==EWIKI_ACTION_ATTACHMENTS) && ($data["content"])
&& strlen($ewiki_plugins["action"][EWIKI_ACTION_ATTACHMENTS])) {
$meta["section"] = $sect;
}
else {
$o .= ewiki_t("UPL_REJSECT", array('sect' => $sect));
return($o);
}
}
if (strlen($s = trim(optional_param("comment",'', PARAM_CLEAN)))) {
$meta["comment"] = $s;
}
$result = ewiki_binary_save_image($upload_file["tmp_name"], "", "RETURN", $meta, "ACCEPT_ALL", $care_for_images=0);
if ($result) {
$o .= ewiki_t("UPL_OK", array('$script'=>ewiki_script()));
}
else {
$o .= ewiki_t("UPL_ERROR");
}
}
return($o);
}
function ewiki_page_filedownload($id, $data, $action, $def_sec="") {
global $ewiki_binary_icons, $ewiki_upload_sections;
$o = ewiki_make_title($id, $id, 2);
#<off># $o .= ewiki_t("DWNL_SEEUPL", '$scr'=>ewiki_script("", ""));
#-- params (section, orderby)
$orderby = optional_param('orderby', 'created', PARAM_ALPHA);
if ($def_sec) {
$section = $def_sec;
}
else {
$section = optional_param('section', '', PARAM_CLEAN);
if (count($ewiki_upload_sections) > 1) {
$oa = array();
$ewiki_upload_sections["*"] = "*";
if (empty($ewiki_plugins["action"][EWIKI_ACTION_ATTACHMENTS])) {
$ewiki_upload_sections["**"] = "**";
}
foreach ($ewiki_upload_sections as $sec=>$title) {
$oa[] = '<a href="' . ewiki_script("", $id, array(
"orderby"=>$orderby, "section" => $sec)) .
'">' . $title . "</a>";
}
$o .= '<div class="mdl-align darker">'.implode(" &middot; ", $oa).'</div><br />';
}
}
#-- collect entries
$files = array();
$sorted = array();
$result = ewiki_database("GETALL", array("flags", "meta", "created", "hits", "userid"));
while ($row = $result->get()) {
if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_BINARY) {
$m = &$row["meta"];
if(!$section) {
$section="**";
}
if ($m["section"] != $section) {
if ($section == "**") {
}
elseif (($section == "*") && !empty($ewiki_upload_sections[$m["section"]])) {
}
else {
continue;
}
}
else {
}
$files[$row["id"]] = $row;
$sorted[$row["id"]] = $row[$orderby];
}
}
#-- sort
arsort($sorted);
#-- slice
$pnum = optional_param(EWIKI_UP_PAGENUM, 0, PARAM_INT);
if (count($sorted) > EWIKI_LIST_LIMIT) {
$o_nl .= '<div class="lighter">&gt;&gt; ';
for ($n=0; $n < (int)(count($sorted) / EWIKI_LIST_LIMIT); $n++) {
$o_nl .= '<a href="' . ewiki_script("", $id, array(
"orderby"=>$orderby, "section"=>$section, EWIKI_UP_PAGENUM=>$n)) .
'">[' . $n . "]</a> ";
}
$o_nl .= '</div><br />';
$o .= $o_nl;
}
$sorted = array_slice($sorted, $pnum * EWIKI_LIST_LIMIT, EWIKI_LIST_LIMIT);
#-- output
if (empty($sorted)) {
$o .= ewiki_t("DWNL_NOFILES");
}
else {
foreach ($sorted as $id=>$uu) {
$row = $files[$id];
$o .= ewiki_entry_downloads($row, $section[0]=="*", true);
}
}
$o .= $o_nl;
return($o);
}
function ewiki_entry_downloads($row, $show_section=0, $fullinfo=false) {
global $ewiki_binary_icons, $ewiki_upload_sections, $DB, $OUTPUT;
$meta = &$row["meta"];
$id = $row["id"];
$p_title = basename($meta["Content-Location"]);
$p_time = userdate($row["created"]);
$p_hits = ($row["hits"] ? $row["hits"] : "0");
$p_size = $meta["size"];
$p_size = isset($p_size) ? (", " . ($p_size>=4096 ? round($p_size/1024)."K" : $p_size." bytes")) : "";
$p_ct1 = $meta["Content-Type"];
$p_ct2 = $meta["X-Content-Type"];
if ($p_ct1==$p_ct2) { unset($p_ct2); }
if ($p_ct1 && !$p_ct2) { $p_ct = "<tt>$p_ct1</tt>"; }
elseif (!$p_ct1 && $p_ct2) { $p_ct = "<tt>$p_ct2</tt>"; }
elseif ($p_ct1 && $p_ct2) { $p_ct = "<tt>$p_ct1</tt>, <tt>$p_ct2</tt>"; }
else { $p_ct = "<tt>application/octet-stream</tt>"; }
$p_section = $ewiki_upload_sections[$meta["section"]];
$p_section = $p_section ? $p_section : $meta["section"];
$p_comment = strlen($meta["comment"]) ? '<table border="1" cellpadding="2" cellspacing="0"><tr><td class="lighter">'.
str_replace('</p>', '', str_replace('<p>', '',
ewiki_format($meta["comment"]))) . '</td></tr></table>' : "<br />";
$p_icon = "";
/*foreach ($ewiki_binary_icons as $str => $i) {
if (empty($str) || strstr($row["Content-Location"], $str) || strstr($p_ct, $str) || strstr($p_ct2, $str)) {
$p_icon = $i;
$p_icon_t = $str;
}
}*/
/// Moodle Icon Handling
global $CFG;
$p_icon = $OUTPUT->pix_url(file_extension_icon($id));
$p_icon_t = '';
$info->id = $id;
$info->size = $p_size;
$info->icon = ($p_icon ? '<img src="'.$p_icon.'" alt="['.$p_icon_t.']" class="icon" /> ' : '');
$info->time = $p_time;
$info->hits = $p_hits;
$info->section = ($show_section ? ewiki_t('dwnl_section') . ": $p_section<br />" : '');
$info->type = $p_ct;
$info->url = ewiki_script_binary("", $row["id"]);
$info->title = $p_title;
$info->comment = format_text($p_comment);
if ($fullinfo) {
if ($user = $DB->get_record('user', array('id'=>$row['userid']))) {
if (!isset($course->id)) {
$course->id = 1;
}
$picture = $OUTPUT->user_picture($user, array('courseid'=>$course->id));
$value = $picture . html_writer::link("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", fullname($user));
}
$o .= '<a href="'.$info->url.'">'.$info->icon.$info->title.'</a>'.$info->size.'<br />'.
$info->comment.
$info->section." ".get_string("fileisoftype","wiki").": ".$info->type.'<br />'.
get_string("uploadedon","wiki").": ".$info->time.", ".
' by '.$value.'<br />'.
get_string("downloadtimes","wiki",$info->hits)."<br />".
// '(<a href="'.$info->url.'">'.$info->id."</a>)<br />".
'<br /><br />';
}
else {
// global $moodle_format; // from wiki/view.php
$o .= '<a href="'.$info->url.'">'.$info->icon.$info->title.'</a>'.$info->size.'<br />'.
$info->comment.'<br /><br />';
// $o = format_text($o, $moodle_format);
}
ewiki_t("DWNL_ENTRY_FORMAT", $info);
return($o);
}
#------------------------------------------------------- per-page uploads ---
function ewiki_action_attachments($id, $data, $action=EWIKI_ACTION_ATTACHMENTS) {
if (!empty($_FILES[EWIKI_UP_UPLOAD])) {
$o .= ewiki_page_fileupload($id, $data, EWIKI_ACTION_ATTACHMENTS, $id);
}
$o .= ewiki_page_filedownload(ucwords(EWIKI_ACTION_ATTACHMENTS) . " " . ewiki_t("of") . " $id", $data, "view", $id);
unset($_FILES[EWIKI_UP_UPLOAD]);
$o .= ewiki_page_fileupload($id, $data, EWIKI_ACTION_ATTACHMENTS, $id);
return($o);
}
-177
View File
@@ -1,177 +0,0 @@
<?php
/*
This filter plugin implements minimal html tag balancing, and can also
convert ewiki_page() output into (hopefully) valid xhtml. It just works
around some markup problems found in ewiki and that may arise from Wiki
markup abuse; it however provides no fix for <ul> inside <ul> or even
<h2> inside <p> problems (this should rather be fixed in the ewiki_format
function). So following code is not meant to fix any possible html file,
and it certainly won't make valid html files out of random binary data.
So for full html spec conformance you should rather utilize w3c tidy (by
using your Webservers "Filter" directive).
*/
define("EWIKI_XHTML", 1);
$ewiki_plugins["page_final"][] = "ewiki_html_tag_balancer";
function ewiki_html_tag_balancer(&$html) {
#-- vars
$html_standalone = array(
"img", "br", "hr",
"input", "meta", "link",
);
$html_tags = array(
"a", "abbr", "acronym", "address", "applet", "area", "b", "base",
"basefont", "bdo", "big", "blockquote", "body", "br", "button",
"caption", "center", "cite", "code", "col", "colgroup", "dd", "del",
"dfn", "dir", "div", "dl", "dt", "em", "fieldset", "font", "form",
"h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "html", "i",
"iframe", "img", "input", "ins", "kbd", "label", "legend", "li",
"link", "map", "menu", "meta", "noframes", "noscript", "object", "ol",
"optgroup", "option", "p", "param", "pre", "q", "s", "samp", "script",
"select", "small", "span", "strike", "strong", "style", "sub", "sup",
"table", "tbody", "td", "textarea", "tfoot", "th", "thead", "title",
"tr", "tt", "u", "ul", "var",
#-- H2.0 "nextid", "listing", "xmp", "plaintext",
#-- H3.2 "frame", "frameset",
#-- X1.1 "rb", "rbc", "rp", "rt", "rtc", "ruby",
);
$close_opened_when = array(
"p", "div", "ul", "td", "table", "tr",
);
if (!EWIKI_XHTML) {
$html_tags = array_merge( (array) $html_tags, array(
"bgsound", "embed", "layer", "multicol", "nobr", "noembed",
));
}
#-- walk through all tags
$tree = array();
$len = strlen($html);
$done = "";
$pos = 0;
$loop = (int)$len / 3;
while (($pos < $len) && $loop--) {
#-- search next tag
$l = strpos($html, "<", $pos);
$r = strpos($html, ">", $l);
if (($l===false) or ($r===false)) {
# finish
$done .= substr($html, $pos);
break;
}
#-- copy plain text part
if ($l >= $pos) {
$done .= substr($html, $pos, $l-$pos);
$pos = $l;
}
#-- analyze current html tag
if ($r >= $pos) {
$pos = $r + 1;
$tag = substr($html, $l + 1, $r - $l - 1);
#-- split into name and attributes
$tname = strtolower(strtok($tag, " \t\n>")); // LOWERCASING not needed here really
($tattr = strtok(">")) && ($tattr = " $tattr");
// attribute checking could go here
// (here we just assume good output from ewiki core)
// ...
#-- html comment
if (substr($tname, 0, 3) == "!--") {
$r = strpos($html, "-->", $l+4);
$pos = $r + 3;
$done .= substr($html, $l, $r-$l+3);
continue;
}
#-- opening tag?
elseif ($tname[0] != "/") {
#-- cdata
if($tname=='![cdata[') {
$tname = strtoupper($tname); // Needs to be uppercase for XHTML compliance
// LEAVE THE POOR THING ALONE!
}
#-- standalone tag
else if (in_array($tname, $html_standalone)) {
$tattr = rtrim(rtrim($tattr, "/"));
if (EWIKI_XHTML) {
$tattr .= " /";
}
}
#-- normal tag
else {
if (in_array($tname, $html_tags)) {
#-- ok
}
else {
#$tattr .= " class=\"$tname\"";
#$tname = "div";
}
array_push($tree, $tname);
}
$tag = "$tname$tattr";
}
#-- closing tag
else {
$tname = substr($tname, 1);
if (!in_array($tname, $html_tags)) {
$tname= "div";
}
#-- check if this is allowed
if (!$tree) {
continue; // ignore closing tag
}
$last = array_pop($tree);
if ($last != $tname) {
#-- close until last opened block element
if (in_array($tname, $close_opened_when)) {
do {
$done .= "</$last>";
}
while (($last = array_pop($tree)) && ($last!=$tname));
}
#-- close last, close current, reopen last
else {
array_push($tree, $last);
$done .= "</$last></$tname><$last>";
continue;
}
}
else {
#-- all ok
}
#-- readd closing-slash to tag name
$tag = "/$tname";
}
$done .= "<$tag>";
}
}
#-- close still open tags
while ($tree && ($last = array_pop($tree))) {
$done .= "</$last>";
}
#-- copy back changes
$html = $done;
}
@@ -1,119 +0,0 @@
<?php
/*
This plugin intercepts some of the binary handling functions to
store uploaded files (as is) into a dedicated directory.
Because the ewiki database abstraction layer was not designed to
hold large files (because it reads records in one chunk), you may need
to use this, else large files may break.
WARNING: this is actually a hack and not a database layer extension,
so it will only work with the ewiki.php script itself. The database
administration tools are not aware of this agreement and therefor
cannot (for example) backup the externally stored data files!
If you later choose to disable this extension, the uploaded (and thus
externally stored) files then cannot be accessed any longer, of course.
- You must load this plugin __before__ the main script, because the
binary stuff in ewiki.php always engages automatically.
- The store directory can be the same as for dbff (filenames differ).
- All the administration tools/ are not aware of this hack, so __you__
must take care, when it comes to creating backups.
*/
#-- config
define("EWIKI_DB_STORE_DIRECTORY", "/tmp"); // where to save binary files
define("EWIKI_DB_STORE_MINSIZE", 0); // send smaller files into db
define("EWIKI_DB_STORE_MAXSIZE", 32 <<20); // 32MB max per file (but
// there is actually no way to upload such large files via HTTP)
# define("EWIKI_DB_STORE_URL", "http://example.com/wiki/files/store/");
// allows clients to directly access stored plain data files,
// without redirection through ewiki.php, RTFM
#-- glue
$ewiki_plugins["binary_store"][] = "moodle_binary_store_file";
$ewiki_plugins["binary_get"][] = "moodle_binary_store_get_file";
function moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid) {
global $CFG;
$entry=wiki_get_entry($wiki, $course, $userid, $groupid);
if(!$entry) {
print_error('cannotgetentry', 'wiki');
}
$dir=make_upload_directory("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/".$meta["section"]);
if(substr($id, 0, strlen(EWIKI_IDF_INTERNAL))!=EWIKI_IDF_INTERNAL) {
print_error('cannotstartwith', 'wiki', '', EWIKI_IDF_INTERNAL.substr($id, 0, strlen(EWIKI_IDF_INTERNAL)));
}
$id = substr($id,strlen(EWIKI_IDF_INTERNAL));
$id = clean_filename($id);
return "$dir/$id";
}
#-- upload
function moodle_binary_store_file(&$filename, &$id, &$meta, $ext=".bin") {
# READ-Only
global $_FILES, $CFG, $course, $wiki, $groupid, $userid, $ewiki_title, $cm;
if(!$wiki->ewikiacceptbinary) {
print_error('cannotacceptbin', 'wiki');
return 0;
}
$entry=wiki_get_entry($wiki, $course, $userid, $groupid);
if(!$entry->id) {
print_error('cannotgetentry', 'wiki');
}
require_once($CFG->dirroot.'/lib/uploadlib.php');
$um = new upload_manager('upload',false,false,$course,false,0,true,true);
if ($um->process_file_uploads("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/$ewiki_title")) {
$filename = ''; // this to make sure we don't keep processing in the parent function
if(!$id) {
$newfilename = $um->get_new_filename();
$id = EWIKI_IDF_INTERNAL.$newfilename;
}
return true;
}
print_error('uploaderror', 'wiki', '', $um->print_upload_log(true));
return false;
}
#-- download
function moodle_binary_store_get_file($id, &$meta) {
# READ-Only
global $CFG, $cm, $course, $wiki, $groupid, $userid;
#-- check for file
if(!$wiki->ewikiacceptbinary) {
print_error('cannotacceptbin', 'wiki');
return 0;
}
$filepath=moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid);
if (file_exists($filepath)) {
readfile($filepath);
return(true);
} else {
return(false);
}
//$dbfname = EWIKI_DB_STORE_DIRECTORY."/".rawurlencode($id);
//if (file_exists($dbfname)) {
// readfile($dbfname);
// return(true);
//}
//else {
// return(false);
//}
}
@@ -1,79 +0,0 @@
<?php
/*
CSS-highlights the terms used as search patterns. This is done
by evaluating the REFERRER and using the QUERY_STRINGs "q="
parameter (which is used by Google and ewikis` PowerSearch).
Highlighting color should be controlled from CSS:
em.highlight {
color: red;
}
em.marker {
background: yellow;
}
Using this plugin costs you nearly nothing (not slower), because
there most often isn't a "?q=" from a search engine in the referer
url.
*/
$ewiki_plugins["page_final"][] = "ewiki_moodle_highlight";
function ewiki_moodle_highlight(&$o, &$id, &$data, &$action) {
if (strpos($_SERVER["HTTP_REFERER"], "q=")) {
#-- PHP versions
$stripos = function_exists("stripos") ? "stripos" : "strpos";
#-- get ?q=...
$uu = $_SERVER["HTTP_REFERER"];
$uu = substr($uu, strpos($uu, "?"));
parse_str($uu, $q);
if ($q = $q["q"]) {
#-- get words out of it
$q = preg_replace('/[^-_\d'.EWIKI_CHARS_L.EWIKI_CHARS_U.']+/', " ", $q);
$q = array_unique(explode(" ", $q));
#-- walk through words
foreach ($q as $word) {
if (empty($word)) {
continue;
}
#-- search for word
while ($l = $stripos(strtolower($o), strtolower($word), $l)) {
#-- check for html-tags
$t0 = strpos($o, "<", $l);
$t1 = strpos($o, ">", $l);
if ((!$t0) || ($t0 < $t1)) {
$repl = '<em class="highlight marker">' . $word . '</em>';
$o = substr($o, 0, $l)
. $repl
. substr($o, 1 + $l + strlen($word)-1);
$l += strlen($repl);
}
$l++; // advance strpos
}
} // foreach(word)
}
} // if(q)
} // func
@@ -1,456 +0,0 @@
<?php
# ToDo: Binary Content
# Binary Linking
/*
Allows to download a tarball including all WikiPages and images that
currently are in the database.
*/
#-- text
$ewiki_t["en"]["WIKIEXPORTCOMMENT"] = "Here you can tailor your WikiDump to your needs. When you are ready, click the \"Download\" button.";
$ewiki_t["en"]["DOWNLOAD_ARCHIVE"] = "Download";
#define("EWIKI_WIKIDUMP_ARCNAME", "WikiDump_");
#define("EWIKI_WIKIDUMP_DEFAULTTYPE", "TAR");
#define("EWIKI_WIKIDUMP_MAXLEVEL", 1);
define('EWIKI_DUMP_FILENAME_REGEX',"/\W\+/");
#-- glue
#if((function_exists(gzcompress) && EWIKI_WIKIDUMP_DEFAULTTYPE=="ZIP") || EWIKI_WIKIDUMP_DEFAULTTYPE=="TAR"){
$ewiki_plugins["page"]["WikiExport"] = "moodle_ewiki_page_wiki_dump";
#$ewiki_plugins["action"]['wikidump'] = "moodle_ewiki_page_wiki_dump";
#}
$ewiki_t["c"]["EWIKIDUMPCSS"] = '
<style TYPE="text/css">
<!--
body {
background-color:#eeeeff;
padding:2px;
}
H2 {
background:#000000;
color:#ffffff;
border:1px solid #000000;
}
-->
</style>
';
function moodle_ewiki_page_wiki_dump($id=0, $data=0, $action=0) {
global $userid, $groupid, $cm, $wikipage, $wiki, $course, $CFG, $OUTPUT;
#-- return legacy page
$cont = true;
$wikiexport = optional_param('wikiexport', '', PARAM_BOOL);
$binaries = optional_param("exportbinaries", null);
$exportformatval = optional_param("exportformats", null);
$withvirtualpages = optional_param("withvirtualpages", null);
$exportdestinationsval = optional_param('exportdestinations', null);
if (!empty($wikiexport)) {
if(!$wiki->ewikiacceptbinary) {
$binaries=0;
}
if($wiki->htmlmode==2) {
$exportformatval=1;
}
$cont=ewiki_page_wiki_dump_send($binaries,
$exportformatval,
$withvirtualpages,
optional_param("exportdestinations", null,PARAM_CLEAN));
}
if($cont===false) {
die;
}
$url = ewiki_script("", "WikiExport");
$ret = ewiki_make_title($id, ewiki_t($id), 2);
$ret .= ($cont&&$cont!==true)?$cont."<br /><br />\n":"";
$ret .= get_string("wikiexportcomment","wiki");
// removing name="form" from the following form as it does not validate
// and is not referenced. MDL-7861
$ret .= "<br /><br />\n".
'<FORM method="post" action="view.php">'."\n".
"<div class=\"wikiexportbox\">\n".
'<INPUT type="hidden" name="page" value="WikiExport" />'."\n".
'<INPUT type="hidden" name="userid" value="'.$userid.'" />'."\n".
'<INPUT type="hidden" name="groupid" value="'.$groupid.'" />'."\n".
'<INPUT type="hidden" name="id" value="'.$cm->id.'" />'."\n".
'<INPUT type="hidden" name="wikipage" value="'.$wikipage.'" />'."\n";
// Export binaries too ?
if(!$wiki->ewikiacceptbinary) {
$ret.='<INPUT type="hidden" name="exportbinaries" value="0" />'.$exportdestinations[0]."\n";
} else {
$ret.='<INPUT type="hidden" name="exportbinaries" value="0" />'."\n";
}
$ret.="<TABLE cellpadding=\"5\">\n";
if($wiki->ewikiacceptbinary) {
$ret.=" <TR valign=\"top\">\n".
' <TD align="right">'.get_string("withbinaries","wiki").":</TD>\n".
" <TD>\n".
' <input type="checkbox" name="exportbinaries" value="1"'.($binaries==1?" checked":"")." />\n".
" </TD>\n".
" </TR>\n";
}
$ret.=" <TR valign=\"top\">\n".
' <TD align="right">'.get_string("withvirtualpages","wiki").":</TD>\n".
" <TD>\n".
' <input type="checkbox" name="withvirtualpages" value="1"'.($withvirtualpages==1?" checked":"")." />\n".
" </TD>\n".
" </TR>\n";
$exportformats=array( "0" => get_string("plaintext","wiki") , "1" => get_string("html","wiki"));
/// Formats
$ret.=" <TR valign=\"top\">\n".
' <TD align="right">'.get_string("exportformats","wiki").":</TD>\n".
" <TD>\n";
if($wiki->htmlmode!=2) {
$ret.= html_writer::select($exportformats, "exportformats", $exportformatval, false)."\n";
} else {
$ret.= '<INPUT type="hidden" name="exportformats" value="1" />'.
get_string("html","wiki");
}
$ret.=" </TD>\n".
" </TR>\n";
/// Destination
$exportdestinations=array("0" => get_string("downloadaszip","wiki"));
if(wiki_is_teacher($wiki)) {
// Get Directory List
$rawdirs = get_directory_list("$CFG->dataroot/$course->id", 'moddata', true, true, false);
foreach ($rawdirs as $rawdir) {
$exportdestinations[$rawdir] = get_string("moduledirectory","wiki").": ".$rawdir;
}
}
$ret.=" <TR valign=\"top\">\n".
' <TD align="right">'.get_string("exportto","wiki").":</TD>\n".
" <TD>\n";
if(count($exportdestinations)==1) {
$ret.='<INPUT type="hidden" name="exportdestinations" value="0" />'.$exportdestinations[0]."\n";
} else {
$ret.= html_writer::select($exportdestinations, "exportdestinations", $exportdestinationsval, false)."\n";
}
$ret.=" </TD>\n".
" </TR>\n".
"</TABLE>\n".
' <input type="submit" name="wikiexport" value= "'.get_string("export","wiki").'" />'."\n".
"</div>\n";
"</FORM>\n";
return $ret;
}
function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvirtualpages=0, $exportdestinations=0) {
global $ewiki_config, $wiki, $ewiki_plugins, $wiki_entry, $course, $CFG, $ewiki_t, $userid, $groupid, $OUTPUT;
$filestozip=array();
#-- disable protected email
if (is_array($ewiki_plugins["link_url"])) {
foreach($ewiki_plugins["link_url"] as $key => $linkplugin){
if($linkplugin == "ewiki_email_protect_link"){
unset($ewiki_plugins["link_url"][$key]);
}
}
}
/// HTML-Export
if($exportformats==1) {
#-- if exportformats is html
$HTML_TEMPLATE = '<html>
<head>'.$ewiki_t["c"]["EWIKIDUMPCSS"].'
<title>$title</title>
</head>
<body bgcolor="#ffffff";>
<div id="PageText">
<h2>$title</h2>
$content
</div>
</body>
</html>';
#-- reconfigure ewiki_format() to generate offline pages and files
$html_ext = ".html";
$ewiki_config["script"] = "%s$html_ext";
$ewiki_config["script_binary"] = "%s";
}
// Export Virtual pages special
$a_virtual = array_keys($ewiki_plugins["page"]);
#-- get all pages / binary files
$a_validpages = ewiki_valid_pages(1, $withvirtualpages);
$a_pagelist = ewiki_sitemap_create($wiki_entry->pagename, $a_validpages, 100, 1);
# Add linked binary files to pagelist
foreach($a_pagelist as $key => $value) {
if(is_array($a_validpages[$value]["refs"])){
foreach($a_validpages[$value]["refs"] as $refs){
if($a_validpages[$refs]["type"]=="image" || $a_validpages[$refs]["type"]=="file"){
$a_pagelist[]=$refs;
}
}
}
}
# Adjust links to binary files
foreach($a_pagelist as $key => $value){
if($a_validpages[$value]["type"]=="image"){
$a_images[]=urlencode($value);
$a_rimages[]=urlencode(preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", $value));
unset($a_validpages[$value]);
}
if($a_validpages[$value]["type"]=="file") {
$a_images[]=urlencode($value);
$a_rimages[]=clean_filename(substr($value,strlen(EWIKI_IDF_INTERNAL)));
$a_images[]=$value;
$a_rimages[]=clean_filename(substr($value,strlen(EWIKI_IDF_INTERNAL)));
unset($a_validpages[$value]);
}
}
# Remove binaries from a_validpages and add to a_pagelist
foreach($a_validpages as $key => $value){
if($a_validpages[$key]["type"]=="image" || $a_validpages[$key]["type"]=="file"){
$a_pagelist[]=$key;
unset($a_validpages[$key]);
}
}
#print "<pre>"; print_r($a_validpages); print "</pre>";
#print "<hr /><pre>"; print_r($a_pagelist); print "</pre>";
$a_sitemap = ewiki_sitemap_create($wiki_entry->pagename, $a_validpages, 99, 0);
if ($a_pagelist) {
#-- create new zip file
#if($arctype == "ZIP"){
# $archivename=EWIKI_WIKIDUMP_ARCNAME."$rootid.zip";
# $archive = new ewiki_virtual_zip();
#} elseif ($arctype == "TAR") {
# $archivename=EWIKI_WIKIDUMP_ARCNAME."$rootid.tar";
# $archive = new ewiki_virtual_tarball();
#} else {
# die();
#}
/// Create/Set Directory
$wname=clean_filename(strip_tags(format_string($wiki->name,true)));
if($exportdestinations) {
if(wiki_is_teacher($wiki)) {
$exportdir=$CFG->dataroot."/".$course->id."/".$exportdestinations;
} else {
add_to_log($course->id, "wiki", "hack", "", format_string($wiki->name,true).": Tried to export a wiki as non-teacher into $exportdestinations.");
print_error('younotteacher');
}
} else {
$exportbasedir=tempnam("/tmp","WIKIEXPORT");
@unlink($exportbasedir);
@mkdir($exportbasedir);
/// maybe we need to check the name here...?
$exportdir=$exportbasedir."/".$wname;
@mkdir($exportdir);
if(!is_dir($exportdir)) {
print_error("cannotcreatetempdir");
}
}
$a_pagelist = array_unique($a_pagelist);
#-- convert all pages
foreach($a_pagelist as $pagename){
if ((!in_array($pagename, $a_virtual))) {
$id = $pagename;
#-- not a virtual page
$row = ewiki_database("GET", array("id"=>$pagename));
$content = "";
} elseif($withvirtualpages) {
$id = $pagename;
#-- is a virtual page
$pf = $ewiki_plugins["page"][$id];
$content = $pf($id, $content, "view");
if ($exportformats==1) {
$content = str_replace('$content', $content, str_replace('$title', $id, $HTML_TEMPLATE));
}
$fn = urlencode($id);
$fn = preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", $fn);
$fn = $fn.$html_ext;
} else {
continue;
}
if (empty($content)){
switch ($row["flags"] & EWIKI_DB_F_TYPE) {
// Text Page
case (EWIKI_DB_F_TEXT):
#print "<pre>"; print_r($row[content]); print "\n-------------</pre>";
if($exportformats==1) {/// HTML-Export
$content = ewiki_format($row["content"]);
} else {
$content = $row["content"];
}
# Binary files link adjustment when html
if($exportformats==1) {
$content = str_replace($a_images, $a_rimages, $content);
}
$fn = preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", urlencode($id));
$fn = $fn.$html_ext;
if($exportformats==1) {/// HTML-Export
$content = str_replace('$content', $content, str_replace('$title', $id, $HTML_TEMPLATE));
}
break;
case (EWIKI_DB_F_BINARY):
#print "Binary: $row[id]<br />";
if (($row["meta"]["class"]=="image" || $row["meta"]["class"]=="file") && ($exportbinaries)) {
# Copy files to the appropriate directory
$fn= moodle_binary_get_path($id, $row["meta"], $course, $wiki, $userid, $groupid);
$destfn=clean_filename(substr($id,strlen(EWIKI_IDF_INTERNAL)));
$dest="$exportdir/".$destfn;
if(!copy($fn,$dest)) {
echo $OUTPUT->notification("Cannot copy $fn to $dest.");
}
#$fn = urlencode(preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", $id));
#$content = &$row["content"];
$filestozip[]=$exportdir."/".$destfn;
continue (2);
}
else {
#-- php considers switch statements as loops so continue 2 is needed to
#-- hit the end of the for loop
continue(2);
}
break;
default:
# don't want it
continue(2);
}
}
# Do not translate links when wiki already in pure html - mode
if($wiki->htmlmode!=2) {
$content=preg_replace_callback(
'/(<a href=")(.*?)(\.html">)/',
create_function(
// single quotes are essential here,
// or alternative escape all $ as \$
'$matches',
'return($matches[1].preg_replace(EWIKI_DUMP_FILENAME_REGEX,"",$matches[2]).$matches[3]);'
),
$content
);
}
#-- add file
// Let's make sure the file exists and is writable first.
if (!$handle = fopen($exportdir."/".$fn, 'w')) {
print_error('cannotopenfile', '', '', $exportdir/$fn);
}
// Write $content to our opened file.
if (fwrite($handle, $content) === FALSE) {
print_error('cannotwritefile', '', '', $exportdir/$fn);
}
fclose($handle);
$filestozip[]=$exportdir."/".$fn;
#$archive->add($content, $fn, array(
# "mtime" => $row["lastmodified"],
# "uname" => "ewiki",
# "mode" => 0664 | (($row["flags"]&EWIKI_DB_F_WRITEABLE)?0002:0000),
# ), $complevel);
}
#-- create index page
/// HTML-Export
if($exportformats==1) {
$timer=array();
$level=-1;
$fordump=1;
$str_formatted="<ul>\n<li><a href=\"".($wiki_entry->pagename).$html_ext."\">".($wiki_entry->pagename)."</a></li>";
$fin_level=format_sitemap($a_sitemap, ($wiki_entry->pagename), $str_formatted, $level, $timer, $fordump);
$str_formatted.="</ul>".str_pad("", $fin_level*6, "</ul>\n");
$str_formatted=preg_replace_callback(
'/(<a href=")(.*?)(\.html">)/',
create_function(
// single quotes are essential here,
// or alternative escape all $ as \$
'$matches',
'return($matches[1].preg_replace(EWIKI_DUMP_FILENAME_REGEX,"",$matches[2]).$matches[3]);'
),
$str_formatted
);
$str_formatted = str_replace('$content', $str_formatted, str_replace('$title', get_string("index","wiki"), $HTML_TEMPLATE));
#-- add file
// Let's make sure the file exists and is writable first.
$indexname="index".$html_ext;
if (!$handle = fopen($exportdir."/".$indexname, 'w')) {
print_error('cannnotopenfile', '', '', $exportdir/$indexname);
}
// Write $somecontent to our opened file.
if (fwrite($handle, $str_formatted) === FALSE) {
print_error('cannnotwritefile', '', '', $exportdir/$indexname);
}
fclose($handle);
$filestozip[]=$exportdir."/".$indexname;
#-- add index page
# $archive->add($str_formatted, "Index_$rootid".$html_ext, array(
# "mtime" => $row["lastmodified"],
# "uname" => "ewiki",
# "mode" => 0664 | (($row["flags"]&EWIKI_DB_F_WRITEABLE)?0002:0000),
# ), $complevel);
}
if(!$exportdestinations) {
$archivename=$wname.".zip";
zip_files($filestozip, "$exportbasedir/$archivename");
#-- Headers
Header("Content-type: application/zip");
Header("Content-disposition: attachment; filename=\"$archivename\"");
Header("Cache-control: private");
Header("Original-Filename: $archivename");
Header("X-Content-Type: application/zip");
Header("Content-Location: $archivename");
if(!@readfile("$exportbasedir/$archivename")) {
print_error("cannotreadfile", '', '', $exportbasedir/$archivename);
}
if(!deldir($exportbasedir)) {
print_error('cannotdeletedir', '', '', $exportbasedir);
}
#exit();
return false;
} else {
return get_string("exportsuccessful","wiki")."<br />";
}
}
}
function deldir($dir)
{
$handle = opendir($dir);
while (false!==($FolderOrFile = readdir($handle)))
{
if($FolderOrFile != "." && $FolderOrFile != "..")
{
if(is_dir("$dir/$FolderOrFile"))
{ deldir("$dir/$FolderOrFile"); } // recursive
else
{ unlink("$dir/$FolderOrFile"); }
}
}
closedir($handle);
if(rmdir($dir))
{ $success = true; }
return $success;
}
-242
View File
@@ -1,242 +0,0 @@
<?php
/*
This plugin will create a sitemap rooted at the given location
Written By: Jeffrey Engleman
*/
define("EWIKI_PAGE_SITEMAP", "SiteMap");
define("EWIKI_SITEMAP_DEPTH", 10);
$ewiki_t["en"]["INVALIDROOT"] = "You are not authorized to access the current root page so no sitemap can be created.";
$ewiki_t["en"]["SMFOR"] = "Site map for ";
$ewiki_t["en"]["VIEWSMFOR"] = "View site map for ";
$ewiki_plugins["page"][EWIKI_PAGE_SITEMAP]="ewiki_page_sitemap";
$ewiki_plugins["action"]['sitemap']="ewiki_page_sitemap";
if(!isset($ewiki_config["SiteMap"]["RootList"])){
$ewiki_config["SiteMap"]["RootList"]=array(EWIKI_PAGE_INDEX);
}
/*
populates an array with all sites the current user is allowed to access
calls the sitemap creation function.
returns the sitemap to be displayed.
*/
function ewiki_page_sitemap($id=0, $data=0, $action=0){
global $ewiki_config;
//**code hijacked from page_pageindex.php**
//creates a list of all of the valid wiki pages in the site
$str_null=NULL;
$a_validpages=ewiki_valid_pages(0,1);
//**end of hijacked code**
//$time_end=getmicrotime();
//creates the title bar on top of page
if($id == EWIKI_PAGE_SITEMAP){
$o = ewiki_make_title($id, ewiki_t($id), 2);
foreach($ewiki_config["SiteMap"]["RootList"] as $root){
if(isset($a_validpages[$root])){
$valid_root=TRUE;
$str_rootid=$root;
break;
}
}
}else{
$o = ewiki_make_title($id, ewiki_t("SMFOR")." ".$id, 2);
if(isset($a_validpages[$id])){
$valid_root=TRUE;
$str_rootid=$id;
}
}
$o .= "<p>".ewiki_t("VIEWSMFOR")." ";
foreach($ewiki_config["SiteMap"]["RootList"] as $root){
if(isset($a_validpages[$root])){
$o.='<a href="'.ewiki_script('sitemap/',$root).'">'.$root.'</a> ';
}
}
$o.="</p>";
//checks to see if the user is allowed to view the root page
if(!isset($a_validpages[$str_rootid])){
$o .= ewiki_t("INVALIDROOT");
return $o;
}
//$timesitemap=getmicrotime();
$a_sitemap=ewiki_sitemap_create($str_rootid, $a_validpages, EWIKI_SITEMAP_DEPTH);
$timer=array();
$level=-1;
$fordump=0;
$str_formatted="<ul>\n<li><a href=\"".EWIKI_SCRIPT.$str_rootid."\">".$str_rootid."</a></li>";
$fin_level=format_sitemap($a_sitemap, $str_rootid, $str_formatted, $level, $timer, $fordump);
$str_formatted.="</ul>".str_pad("", $fin_level*6, "</ul>\n");
$o.=$str_formatted;
//$timesitemap_end=getmicrotime();
//$o.="GetAll: ".($time_end-$time)."\n";
//$o.="SiteMap: ".($timesitemap_end-$timesitemap)."\n";
//$o.="Total: ".($timesitemap_end-$time);
return($o);
}
function ewiki_valid_pages($bool_allowimages=0, $virtual_pages=0){
//$time=getmicrotime();
global $ewiki_plugins;
$result = ewiki_database("GETALL", array("flags", "refs", "meta"));
while ($row = $result->get()) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $str_null, "view")) {
continue;
}
$isbinary= ($row["meta"]["class"]=="image"||$row["meta"]["class"]=="file")?true:false;
if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT || ($bool_allowimages ? $isbinary : 0)) {
$temp_refs=explode("\n",$row["refs"]);
foreach($temp_refs as $key => $value) {
if(empty($value)) {
unset($temp_refs[$key]);
}
}
if($isbinary){
$a_validpages[$row["id"]]=$temp_array=array("refs" => $temp_refs, "type" => $row["meta"]["class"], "touched" => FALSE);
} else {
$a_validpages[$row["id"]]=$temp_array=array("refs" => $temp_refs, "type" => "page", "touched" => FALSE);
}
unset($temp_refs);
}
}
if($virtual_pages){
#-- include virtual pages to the sitemap.
$virtual = array_keys($ewiki_plugins["page"]);
foreach($virtual as $vp){
if(!EWIKI_PROTECTED_MODE || !EWIKI_PROTECTED_MODE_HIDING || ewiki_auth($vp, $str_null, "view")){
$a_validpages[$vp]=array("refs" => array(), "type" => "page", "touched" => FALSE);
}
}
}
return $a_validpages;
}
/*
Adds each of the pages in the sitemap to an HTML list. Each site is a clickable link.
*/
function format_sitemap($a_sitemap, $str_rootpage, &$str_formatted, &$prevlevel, &$timer, &$fordump){
//get all children of the root format them and store in $str_formatted array
$a_sitemap[$str_rootpage]["child"]= is_array($a_sitemap[$str_rootpage]["child"])?$a_sitemap[$str_rootpage]["child"]:array();
if($a_sitemap[$str_rootpage]["child"]){
while($str_child = current($a_sitemap[$str_rootpage]["child"])){
$str_mark="";
if($a_sitemap[$str_rootpage]["level"]>$prevlevel){
$str_mark="<ul>\n";
}
elseif ($a_sitemap[$str_rootpage]["level"]<$prevlevel){
//markup length is 6 characters
$str_mark=str_pad("", ($prevlevel-$a_sitemap[$str_rootpage]["level"])*6, "</ul>\n");
}
$prevlevel=$a_sitemap[$str_rootpage]["level"];
if($fordump){
$str_formatted.=($str_mark."<li><a href=\"".preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", urlencode($str_child)).".html\">".$str_child."</a></li>\n");
} else {
$str_formatted.=($str_mark."<li><a href=\"".EWIKI_SCRIPT.$str_child."\">".$str_child."</a></li>\n");
}
array_shift($a_sitemap[$str_rootpage]["child"]);
format_sitemap($a_sitemap, $str_child, $str_formatted, $prevlevel, $timer, $fordump);
}
return ($prevlevel+1);
}
}
/*
gets all children of the given root and stores them in the $a_children array
*/
function ewiki_page_listallchildren($str_root, &$a_children, &$a_sitemap, &$a_validpages, $i_level, $i_maxdepth, $i_flatmap){
if(($i_level<$i_maxdepth) && is_array($a_validpages[$str_root]["refs"])){ //controls depth the sitemap will recurse into
foreach($a_validpages[$str_root]["refs"] as $str_refs){
if($str_refs){ //make sure $str_refs contains a value before doing anything
if(isset($a_validpages[$str_refs])){ //test page validity
if(!$a_validpages[$str_refs]["touched"]){ //check to see if page already exists
if($i_flatmap){
$a_sitemap[]=$str_refs;
}
$a_validpages[$str_refs]["touched"]=TRUE; //mark page as displayed
$a_children[$str_refs]="";
$a_currchildren[]=$str_refs;
}
}
}
}
if(!$i_flatmap){
if($a_currchildren){
$a_sitemap[$str_root]=array("level" => $i_level, "child" => $a_currchildren);
} else {
$a_sitemap[$str_root]=array("level" => $i_level);
}
}
}
}
/*
Creates the sitemap. And sends the data to the format_sitemap function.
Returns the HTML formatted sitemap.
*/
function ewiki_sitemap_create($str_rootid, $a_validpages, $i_maxdepth, $i_flatmap=0){
//map starts out with a depth of 0
$i_depth=0;
$forcelevel=FALSE;
//create entry for root in the sitemap array
if(!$i_flatmap){
$a_sitemap[$str_rootid]=array("parent" => "", "level" => $i_depth, "child" => $str_rootid);
} else {
$a_sitemap[]=$str_rootid;
}
//mark the root page as touched
$a_validpages[$str_rootid]["touched"]=TRUE;
//list all of the children of the root
ewiki_page_listallchildren($str_rootid, $a_children, $a_sitemap, $a_validpages, $i_depth, $i_maxdepth, $i_flatmap);
$i_depth++;
if($a_children){
end($a_children);
$str_nextlevel=key($a_children);
reset($a_children);
while($str_child = key($a_children)){
//list all children of the current child
ewiki_page_listallchildren($str_child, $a_children, $a_sitemap, $a_validpages, $i_depth, $i_maxdepth, $i_flatmap);
//if the child is the next level marker...
if($str_child==$str_nextlevel){
//increment the level counter
$i_depth++;
//determine which child marks the end of this level
end($a_children);
$str_nextlevel=key($a_children);
//reset the array counter to the beginning of the array
reset($a_children);
//we are done with this child...get rid of it
}
array_shift($a_children);
}
}
return $a_sitemap;
}
@@ -1,65 +0,0 @@
<?php
# lists pages, which were referenced
# but not yet written
$ewiki_plugins["page"]["WantedPages"] = "ewiki_page_wantedpages";
#<off># $ewiki_plugins["page"]["DanglingSymlinks"] = "ewiki_page_wantedpages";
function ewiki_page_wantedpages($id, $data, $action) {
$wanted=array();
#-- collect referenced pages
$result = ewiki_database("GETALL", array("refs"));
while ($row = $result->get()) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
continue;
}
$refs .= $row["refs"];
}
#-- build array
$refs = array_unique(explode("\n", $refs));
#-- strip existing pages from array
$refs = ewiki_database("FIND", $refs);
foreach ($refs as $id=>$exists) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
continue;
}
if (!$exists && !strstr($id, "://") && strlen(trim($id))) {
$wanted[] = $id;
}
}
// to prevent empty <ul></ul> getting printed out, we have to interate twice.
// once to make sure the <ul></ul> is needed at all.
// MDL-7861, <ul></ul> does not validate.
$printul = false;
foreach ($wanted as $page) {
$link = ewiki_link_regex_callback(array($page, $page));
if (strstr($link, "?</a>")) {
$printul = true;
}
}
#-- print out
if ($printul) {
$o .= "<ul>";
foreach ($wanted as $page) {
$link = ewiki_link_regex_callback(array($page, $page));
if (strstr($link, "?</a>")) {
$o .= "<li>" . $link . "</li>";
}
}
$o .= "</ul>";
}
return($o);
}
-232
View File
@@ -1,232 +0,0 @@
<?php
#
# The otherwise invisible markup [notify:[email protected]] will trigger a
# mail, whenever a page is changed. The TLD decides in which language
# the message will be delivered. One can also append the lang code after
# a comma or semicolon behind the mail address to set it explicitely:
# [notify:[email protected],de] or [notify:[email protected];eo]
#
# Nevertheless English will be used as the default automagically, if
# nothing else was specified, no need to worry about this.
#
# additional features:
# * diff inclusion
# * [notify:icq:123456789] - suddenly ICQ.com took the pager service down
#
# To include a diff, just set the following constant. Also use it to
# define the minimum number of changed bytes that are necessary to
# result in a notification mail. Only use it with Linux/UNIX.
define("EWIKI_NOTIFY_WITH_DIFF", 0); #-- set it to 100 or so
define("EWIKI_NOTIFY_SENDER",'ewiki');
#-- glue
$ewiki_plugins["edit_hook"][] = "ewiki_notify_edit_hook";
$ewiki_plugins["format_source"][] = "ewiki_format_remove_notify";
$ewiki_config["interwiki"]["notify"] = "mailto:";
#-- email message text ---------------------------------------------------
$ewiki_t["en"]["NOTIFY_SUBJECT"] = '"$id" was changed [notify:...]';
$ewiki_t["en"]["NOTIFY_BODY"] = <<<_END_OF_STRING
Hi,
A WikiPage has changed and you requested to be notified when this
happens. The changed page was '\$id' and can be found
at the following URL:
\$link
To stop messages like this please strip the [notify:...] with your address
from the page edit box at \$edit_link
(\$wiki_title on http://\$server/)
\$server_admin
_END_OF_STRING;
#-- translation.de
$ewiki_t["de"]["NOTIFY_SUBJECT"] = '"$id" wurde gendert [notify:...]';
$ewiki_t["de"]["NOTIFY_BODY"] = <<<_END_OF_STRING
Hi,
Eine WikiSeite hat sich gendert, und du wolltest ja unbedingt wissen,
wenn das passiert. Die genderte Seite war '\$id' und
ist leicht zu finden unter folgender URL:
\$link
Wenn du diese Benachrichtigungen nicht mehr bekommen willst, solltest du
deine [notify:...]-Adresse aus der entsprechenden Edit-Box herauslschen:
\$edit_link
(\$wiki_title auf http://\$server/)
\$server_admin
_END_OF_STRING;
#----------------------------------------------------------------------------
#-- implementatition
function ewiki_notify_edit_hook($id, $data, &$hidden_postdata) {
global $ewiki_t, $ewiki_plugins;
$content = optional_param('content', '', PARAM_CLEAN);
$ret_err = 0;
$save = optional_param('save', false);
if ($save === false) {
return(false);
}
$mailto = ewiki_notify_links($data["content"], 0);
if (!count($mailto)) {
return(false);
}
#-- generate diff
$diff = "";
if (EWIKI_NOTIFY_WITH_DIFF && (DIRECTORY_SEPARATOR=="/")) {
#-- save page versions temporarily as files
$fn1 = EWIKI_TMP."/ewiki.tmp.notify.diff.".md5($data["content"]);
$fn2 = EWIKI_TMP."/ewiki.tmp.notify.diff.".md5($content);
$f = fopen($fn1, "w");
fwrite($f, $data["content"]);
fclose($f);
$f = fopen($fn2, "w");
fwrite($f, $content);
fclose($f);
#-- set mtime of the old one (GNU diff will report it)
touch($fn1, $data["lastmodified"]);
#-- get diff output, rm temp files
$diff_exe = "diff";
if ($f = popen("$diff_exe --normal --ignore-case --ignore-space-change $fn1 $fn2 2>&1 ", "r")) {
$diff .= fread($f, 16<<10);
pclose($f);
$diff_failed = !strlen($diff)
|| (strpos($diff, "Files ") === 0);
#-- do not [notify:] if changes were minimal
if ((!$diff_failed) && (strlen($diff) < EWIKI_NOTIFY_WITH_DIFF)) {
#echo("WikiNotice: no notify, because too few changes (" .strlen($diff)." byte)\n");
$ret_err = 1;
}
$diff = "\n\n-----------------------------------------------------------------------------\n\n"
. $diff;
}
else {
$diff = "";
#echo("WikiWarning: diff failed in notify module\n");
}
unlink($fn1);
unlink($fn2);
if ($ret_err) {
return(false);
}
}
#-- separate addresses into (TLD) groups
$mailto_lang = array(
);
foreach ($mailto as $m) {
$lang = "";
#-- remove lang selection trailer
$m = strtok($m, ",");
if ($uu = strtok(",")) {
$lang = $uu;
}
$m = strtok($m, ";");
if ($uu = strtok(";")) {
$lang = $uu;
}
#-- else use TLD as language code
if (empty($lang)) {
$r = strrpos($m, ".");
$lang = substr($m, $r+1);
}
$lang = trim($lang);
#-- address mangling
$m = trim($m);
if (substr($m, 0, 4) == "icq:") {
$m = substr($m, 4) . "@pager.icq.com";
}
$mailto_lang[$lang][] = $m;
}
#-- go thru email address groups
foreach ($mailto_lang as $lang=>$a_mailto) {
$pref_langs = array_merge(array(
"$lang", "en"
), $ewiki_t["languages"]);
($server = $_SERVER["HTTP_HOST"]) or
($server = $_SERVER["SERVER_NAME"]);
$s_4 = "http".($_SERVER['HTTPS'] == "on" ? 's':'')."://" . $server . $_SERVER["REQUEST_URI"];
$link = str_replace("edit/$id", "$id", $s_4);
$m_text = ewiki_t("NOTIFY_BODY", array(
"id" => $id,
"link" => $link,
"edit_link" => $s_4,
"server_admin" => $_SERVER["SERVER_ADMIN"],
"server" => $server,
"wiki_title" => EWIKI_PAGE_INDEX,
), $pref_langs);
$m_text .= $diff;
$m_from = EWIKI_NOTIFY_SENDER."@$server";
$m_subject = ewiki_t("NOTIFY_SUBJECT", array(
"id" => $id,
), $pref_langs);
$m_to = implode(", ", $a_mailto);
mail($m_to, $m_subject, $m_text, "From: \"$s_2\" <$m_from>\nX-Mailer: ErfurtWiki/".EWIKI_VERSION);
}
}
function ewiki_notify_links(&$source, $strip=1) {
$links = array();
$l = 0;
if (strlen($source) > 10)
while (($l = @strpos($source, "[notify:", $l)) !== false) {
$r = strpos($source, "]", $l);
$str = substr($source, $l, $r + 1 - $l);
if (!strpos("\n", $str)) {
$links[] = trim(substr($str, 8, -1));
if ($strip) {
$source = substr($source, 0, $l) . substr($source, $r + 1);
}
}
$l++;
}
return($links);
}
function ewiki_format_remove_notify(&$source) {
ewiki_notify_links($source, 1);
}
@@ -1,62 +0,0 @@
<?php
# lists all pages, which are not referenced from others
# (works rather unclean and dumb)
define("EWIKI_PAGE_ORPHANEDPAGES", "OrphanedPages");
$ewiki_plugins["page"][EWIKI_PAGE_ORPHANEDPAGES] = "ewiki_page_orphanedpages";
function ewiki_page_orphanedpages($id, $data, $action) {
global $ewiki_links;
$o = ewiki_make_title($id, ewiki_t($id), 2);
$pages = array();
$refs = array();
$orphaned = array();
#-- read database
$datab = ewiki_database("GETALL", array("refs", "flags"));
$n=0;
while ($row = $datab->get()) {
$p = $row["id"];
#-- remove self-reference
$row["refs"] = str_replace("\n$p\n", "\n", $row["refs"]);
#-- add to list of referenced pages
$rf = explode("\n", trim($row["refs"]));
$refs = array_merge($refs, $rf);
if ($n++ > 299) {
$refs = array_unique($refs);
$n=0;
} // (clean-up only every 300th loop)
#-- add page name
if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
$pages[] = $row["id"];
}
}
$refs = array_unique($refs);
#-- check pages to be referenced from somewhere
foreach ($pages as $p) {
if (!ewiki_in_array($p, $refs)) {
if (!EWIKI_PROTECTED_MODE || EWIKI_PROTECTED_MODE_HIDING || ewiki_auth($p, $uu, "view")) {
$orphaned[] = $p;
}
}
}
#-- output
$o .= ewiki_list_pages($orphaned, 0);
return($o);
}

Some files were not shown because too many files have changed in this diff Show More