summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2005-10-02 13:32:55 +0200
committerAndreas Gohr <andi@splitbrain.org>2005-10-02 13:32:55 +0200
commitb6912aeac771ef294377b8af071d28f6acfa7050 (patch)
tree7c93c9124d89ef748213b421cd582dace7d7442a
parent075f000f1c8f0899f80f94e63a11071fcc506c55 (diff)
downloadrpg-b6912aeac771ef294377b8af071d28f6acfa7050.tar.gz
rpg-b6912aeac771ef294377b8af071d28f6acfa7050.tar.bz2
minor edit checkbox
This patch adds a minor edit checkbox to the edit form for logged in users. Minor edits are displayed different in recent changes and the page revision history. The RSS feed excludes minor edits by default - this can be changed by adding a minor darcs-hash:20051002113255-7ad00-2bc9e1aaa76d9616428e760529ecc14ef119cf71.gz
-rw-r--r--feed.php11
-rw-r--r--inc/actions.php2
-rw-r--r--inc/common.php76
-rw-r--r--inc/html.php60
-rw-r--r--inc/lang/en/lang.php1
-rw-r--r--inc/template.php2
-rw-r--r--lib/tpl/default/design.css10
-rw-r--r--lib/tpl/default/mediaedit.php10
8 files changed, 129 insertions, 43 deletions
diff --git a/feed.php b/feed.php
index c4c386261..9a6e39264 100644
--- a/feed.php
+++ b/feed.php
@@ -20,6 +20,7 @@
$num = $_REQUEST['num'];
$type = $_REQUEST['type'];
$mode = $_REQUEST['mode'];
+ $minor = $_REQUEST['minor'];
$ns = $_REQUEST['ns'];
$ltype = $_REQUEST['linkto'];
@@ -69,7 +70,7 @@
if($mode == 'list'){
rssListNamespace($rss,$ns);
}else{
- rssRecentChanges($rss,$num,$ltype,$ns);
+ rssRecentChanges($rss,$num,$ltype,$ns,$minor);
}
$feed = $rss->createFeed($type,'utf-8');
@@ -88,12 +89,16 @@
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function rssRecentChanges(&$rss,$num,$ltype,$ns){
+function rssRecentChanges(&$rss,$num,$ltype,$ns,$minor){
global $conf;
if(!$num) $num = $conf['recent'];
$guardmail = ($conf['mailguard'] != '' && $conf['mailguard'] != 'none');
- $recents = getRecents(0,$num,false,$ns);
+
+ $flags = RECENTS_SKIP_DELETED;
+ if(!$minor) $flags += RECENTS_SKIP_MINORS;
+
+ $recents = getRecents(0,$num,$ns,$flags);
//this can take some time if a lot of recaching has to be done
@set_time_limit(90); // set max execution time
diff --git a/inc/actions.php b/inc/actions.php
index 3636406db..636858106 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -190,7 +190,7 @@ function act_save($act){
return 'conflict';
//save it
- saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM); //use pretty mode for con
+ saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM,$_REQUEST['minor']); //use pretty mode for con
//unlock it
unlock($ID);
diff --git a/inc/common.php b/inc/common.php
index d6a367566..3589eae14 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -14,6 +14,13 @@
require_once(DOKU_INC.'inc/parserutils.php');
/**
+ * These constants are used with the recents function
+ */
+define('RECENTS_SKIP_DELETED',2);
+define('RECENTS_SKIP_MINORS',4);
+define('RECENTS_SKIP_SUBSPACES',8);
+
+/**
* Return info about the current document as associative
* array.
*
@@ -66,6 +73,7 @@ function pageinfo(){
$info['ip'] = $revinfo['ip'];
$info['user'] = $revinfo['user'];
$info['sum'] = $revinfo['sum'];
+ $info['minor'] = $revinfo['minor'];
if($revinfo['user']){
$info['editor'] = $revinfo['user'];
@@ -578,7 +586,7 @@ function dbg($msg,$hidden=false){
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function addLogEntry($date,$id,$summary=""){
+function addLogEntry($date,$id,$summary='',$minor=false){
global $conf;
if(!@is_writable($conf['changelog'])){
@@ -590,11 +598,33 @@ function addLogEntry($date,$id,$summary=""){
$remote = $_SERVER['REMOTE_ADDR'];
$user = $_SERVER['REMOTE_USER'];
+ if($conf['useacl'] && $user && $minor){
+ $summary = '*'.$summary;
+ }else{
+ $summary = ' '.$summary;
+ }
+
$logline = join("\t",array($date,$remote,$id,$user,$summary))."\n";
io_saveFile($conf['changelog'],$logline,true);
}
/**
+ * Checks an summary entry if it was a minor edit
+ *
+ * The summary is cleaned of the marker char
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function isMinor(&$summary){
+ if(substr($summary,0,1) == '*'){
+ $summary = substr($summary,1);
+ return true;
+ }
+ $summary = trim($summary);
+ return false;
+}
+
+/**
* Internal function used by getRecents
*
* don't call directly
@@ -602,7 +632,7 @@ function addLogEntry($date,$id,$summary=""){
* @see getRecents()
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function _handleRecent($line,$incdel,$ns,$subNS){
+function _handleRecent($line,$ns,$flags){
static $seen = array(); //caches seen pages and skip them
if(empty($line)) return false; //skip empty lines
@@ -611,6 +641,16 @@ function _handleRecent($line,$incdel,$ns,$subNS){
// skip seen ones
if($seen[$id]) return false;
+ $recent = array();
+
+ // check minors
+ if(isMinor($sum)){
+ // skip minors
+ if($flags & RECENTS_SKIP_MINORS) return false;
+ $recent['minor'] = true;
+ }else{
+ $recent['minor'] = false;
+ }
// remember in seen to skip additional sights
$seen[$id] = 1;
@@ -619,21 +659,19 @@ function _handleRecent($line,$incdel,$ns,$subNS){
if (($ns) && (strpos($id,$ns.':') !== 0)) return false;
// exclude subnamespaces
- if ((!$subNS) && (getNS($id) != $ns)) return false;
+ if (($flags & RECENTS_SKIP_SUBSPACES) && (getNS($id) != $ns)) return false;
// check ACL
if (auth_quickaclcheck($id) < AUTH_READ) return false;
// check existance
if(!@file_exists(wikiFN($id))){
- if(!$incdel){
+ if($flags & RECENTS_SKIP_DELETED){
return false;
}else{
- $recent = array();
$recent['del'] = true;
}
}else{
- $recent = array();
$recent['del'] = false;
}
@@ -646,19 +684,26 @@ function _handleRecent($line,$incdel,$ns,$subNS){
return $recent;
}
+
/**
* returns an array of recently changed files using the
* changelog
*
+ * The following constants can be used to control which changes are
+ * included. Add them together as needed.
+ *
+ * RECENTS_SKIP_DELETED - don't include deleted pages
+ * RECENTS_SKIP_MINORS - don't include minor changes
+ * RECENTS_SKIP_SUBSPACES - don't include subspaces
+ *
* @param int $first number of first entry returned (for paginating
* @param int $num return $num entries
- * @param bool $incdel include deleted pages?
* @param string $ns restrict to given namespace
- * @param bool $subNS include subnamespaces
+ * @param bool $flags see above
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function getRecents($first,$num,$incdel=false,$ns='',$subNS=true){
+function getRecents($first,$num,$ns='',$flags=0){
global $conf;
$recent = array();
$count = 0;
@@ -696,7 +741,7 @@ function getRecents($first,$num,$incdel=false,$ns='',$subNS=true){
// handle lines
for($i = $cnt-1; $i >= 0; $i--){
- $rec = _handleRecent($lines[$i],$incdel,$ns,$subNS);
+ $rec = _handleRecent($lines[$i],$ns,$flags);
if($rec !== false){
if(--$first >= 0) continue; // skip first entries
$recent[] = $rec;
@@ -735,10 +780,11 @@ function getRevisionInfo($id,$rev){
$loglines = preg_grep("/$rev\t\d+\.\d+\.\d+\.\d+\t$id\t/",$loglines);
$loglines = array_reverse($loglines); //reverse sort on timestamp (shouldn't be needed)
$line = split("\t",$loglines[0]);
- $info['date'] = $line[0];
- $info['ip'] = $line[1];
- $info['user'] = $line[3];
+ $info['date'] = $line[0];
+ $info['ip'] = $line[1];
+ $info['user'] = $line[3];
$info['sum'] = $line[4];
+ $info['minor'] = isMinor($info['sum']);
return $info;
}
@@ -747,7 +793,7 @@ function getRevisionInfo($id,$rev){
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function saveWikiText($id,$text,$summary){
+function saveWikiText($id,$text,$summary,$minor=false){
global $conf;
global $lang;
umask($conf['umask']);
@@ -778,7 +824,7 @@ function saveWikiText($id,$text,$summary){
$del = false;
}
- addLogEntry(@filemtime($file),$id,$summary);
+ addLogEntry(@filemtime($file),$id,$summary,$minor);
// send notify mails
notify($id,'admin',$old,$summary);
notify($id,'subscribers',$old,$summary);
diff --git a/inc/html.php b/inc/html.php
index 1e48b548c..d4fafdaf3 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -56,11 +56,11 @@ function html_login(){
<legend><?php echo $lang['btn_login']?></legend>
<input type="hidden" name="id" value="<?php echo $ID?>" />
<input type="hidden" name="do" value="login" />
- <label>
+ <label class="block">
<span><?php echo $lang['user']?></span>
<input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" />
</label><br />
- <label>
+ <label class="block">
<span><?php echo $lang['pass']?></span>
<input type="password" name="p" class="edit" />
</label><br />
@@ -392,7 +392,7 @@ function html_revisions(){
print p_locale_xhtml('revisions');
print '<ul>';
if($INFO['exists']){
- print '<li>';
+ print ($INFO['minor']) ? '<li class="minor">' : '<li>';
print $date;
@@ -413,8 +413,7 @@ function html_revisions(){
$date = date($conf['dformat'],$rev);
$info = getRevisionInfo($ID,$rev);
- print '<li>';
-
+ print ($info['minor']) ? '<li class="minor">' : '<li>';
print $date;
print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
@@ -459,10 +458,10 @@ function html_recent($first=0){
* decide if this is the last page or is there another one.
* This is the cheapest solution to get this information.
*/
- $recents = getRecents($first,$conf['recent'] + 1,true,getNS($ID));
+ $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
if(count($recents) == 0 && $first != 0){
$first=0;
- $recents = getRecents(0,$conf['recent'] + 1,true,getNS($ID));
+ $recents = getRecents(0,$conf['recent'] + 1,getNS($ID));
}
$cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
@@ -471,7 +470,7 @@ function html_recent($first=0){
foreach($recents as $recent){
$date = date($conf['dformat'],$recent['date']);
- print '<li>';
+ print ($recent['minor']) ? '<li class="minor">' : '<li>';
print $date.' ';
@@ -500,8 +499,8 @@ function html_recent($first=0){
print '</a> ';
print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']);
-
print ' '.htmlspecialchars($recent['sum']);
+
print ' <span class="user">';
if($recent['user']){
print $recent['user'];
@@ -795,7 +794,7 @@ function html_register(){
<input type="hidden" name="save" value="1" />
<fieldset>
<legend><?php echo $lang['register']?></legend>
- <label>
+ <label class="block">
<?php echo $lang['user']?>
<input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
</label><br />
@@ -803,11 +802,11 @@ function html_register(){
<?php
if (!$conf['autopasswd']) {
?>
- <label>
+ <label class="block">
<?php echo $lang['pass']?>
<input type="password" name="pass" class="edit" size="50" />
</label><br />
- <label>
+ <label class="block">
<?php echo $lang['passchk']?>
<input type="password" name="passchk" class="edit" size="50" />
</label><br />
@@ -815,11 +814,11 @@ function html_register(){
}
?>
- <label>
+ <label class="block">
<?php echo $lang['fullname']?>
<input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
</label><br />
- <label>
+ <label class="block">
<?php echo $lang['email']?>
<input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
</label><br />
@@ -943,8 +942,8 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
<tr id="wikieditbar">
<td>
<?php if($wr){?>
- <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="3" />
- <input class="button" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="4" />
+ <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="4" />
+ <input class="button" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="5" />
<input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="5" />
<?php } ?>
</td>
@@ -952,6 +951,7 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
<?php if($wr){ ?>
<?php echo $lang['summary']?>:
<input type="text" class="edit" name="summary" id="summary" size="50" onkeyup="summaryCheck();" value="<?php echo formText($SUM)?>" tabindex="2" />
+ <?php html_minoredit()?>
<?php }?>
</td>
<td align="right">
@@ -976,6 +976,34 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
}
/**
+ * Adds a checkbox for minor edits for logged in users
+ *
+ * @author Andrea Gohr <andi@splitbrain.org>
+ */
+function html_minoredit(){
+ global $conf;
+ global $lang;
+ // minor edits are for logged in users only
+ if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
+ return;
+ }
+
+ $p = array();
+ $p['name'] = 'minor';
+ $p['type'] = 'checkbox';
+ $p['id'] = 'minoredit';
+ $p['tabindex'] = 3;
+ $p['value'] = '1';
+ if($_REQUEST['minor']) $p['checked']='checked';
+ $att = buildAttributes($p);
+
+ print "<input $att />";
+ print '<label for="minoredit">';
+ print $lang['minoredit'];
+ print '</label>';
+}
+
+/**
* prepares the signature string as configured in the config
*
* @author Andreas Gohr <andi@splitbrain.org>
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index b7fe08225..9cfae794e 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -45,6 +45,7 @@ $lang['fullname'] = 'Full name';
$lang['email'] = 'E-Mail';
$lang['register'] = 'Register';
$lang['badlogin'] = 'Sorry, username or password was wrong.';
+$lang['minoredit'] = 'Minor Edit';
$lang['regmissing'] = 'Sorry, you must fill in all fields.';
$lang['reguexists'] = 'Sorry, a user with this login already exists.';
diff --git a/inc/template.php b/inc/template.php
index e14d0d0ad..8b9aab635 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -800,7 +800,7 @@ function tpl_mediauploadform(){
ptln('<input type="text" name="id" class="edit" />',4);
ptln('<input type="submit" class="button" value="'.$lang['btn_upload'].'" accesskey="s" />',4);
if($AUTH >= AUTH_DELETE){
- ptln('<label for="ow" class="simple"><input type="checkbox" name="ow" value="1" id="ow">'.$lang['txt_overwrt'].'</label>',4);
+ ptln('<label for="ow"><input type="checkbox" name="ow" value="1" id="ow">'.$lang['txt_overwrt'].'</label>',4);
}
ptln('</form>',2);
}
diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css
index d080c88e3..83547b9b4 100644
--- a/lib/tpl/default/design.css
+++ b/lib/tpl/default/design.css
@@ -55,18 +55,19 @@ form {
display: inline;
}
-label {
+label.block {
display: block;
text-align: right;
font-weight: bold;
}
label.simple {
+ display: block;
text-align: left;
font-weight: normal;
}
-label input.edit {
+label.block input.edit {
width: 50%;
}
@@ -280,6 +281,11 @@ span.user{
font-size: 90%;
}
+li.minor {
+ color: #666;
+ font-style: italic;
+}
+
/* embedded images */
img.media {
margin: 3px;
diff --git a/lib/tpl/default/mediaedit.php b/lib/tpl/default/mediaedit.php
index 53a969e1b..c7b7e2e53 100644
--- a/lib/tpl/default/mediaedit.php
+++ b/lib/tpl/default/mediaedit.php
@@ -40,11 +40,11 @@
<input type="hidden" name="edit" value="<?php echo hsc($IMG)?>" />
<input type="hidden" name="save" value="1" />
- <label for="title"><?php echo $lang['img_title']?></label>
+ <label class="block" for="title"><?php echo $lang['img_title']?></label>
<input type="text" name="meta[Iptc.Headline]" id="title" class="edit"
value="<?php echo hsc(tpl_img_getTag('IPTC.Headline'))?>" /><br />
- <label for="caption"><?php echo $lang['img_caption']?></label>
+ <label class="block" for="caption"><?php echo $lang['img_caption']?></label>
<textarea name="meta[Iptc.Caption]" id="caption" class="edit" rows="5"><?php
echo hsc(tpl_img_getTag(array('IPTC.Caption',
'EXIF.UserComment',
@@ -52,19 +52,19 @@
'EXIF.TIFFUserComment')));
?></textarea><br />
- <label for="artist"><?php echo $lang['img_artist']?></label>
+ <label class="block" for="artist"><?php echo $lang['img_artist']?></label>
<input type="text" name="meta[Iptc.Byline]" id="artist" class="edit"
value="<?php echo hsc(tpl_img_getTag(array('Iptc.Byline',
'Exif.TIFFArtist',
'Exif.Artist',
'Iptc.Credit')))?>" /><br />
- <label for="copy"><?php echo $lang['img_copyr']?></label>
+ <label class="block" for="copy"><?php echo $lang['img_copyr']?></label>
<input type="text" name="meta[Iptc.CopyrightNotice]" id="copy" class="edit"
value="<?php echo hsc(tpl_img_getTag(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright')))?>" /><br />
- <label for="keywords"><?php echo $lang['img_keywords']?></label>
+ <label class="block" for="keywords"><?php echo $lang['img_keywords']?></label>
<textarea name="meta[Iptc.Keywords]" id="keywords" class="edit"><?php
echo hsc(tpl_img_getTag(array('IPTC.Keywords',
'EXIF.Category')));