Changeset 84

Show
Ignore:
Timestamp:
05/23/2006 06:10:49 PM (4 years ago)
Author:
DarTar
Message:

handlers/edit.php: fixed minor validation problem, added edit note check depending on config option, changed markup for error messages to <em class="error"> ; wikka.php: added config option for edit note (0: optional/1: required/2: disabled); setup/install.php: added upgrade instructions for new config option - fixes #114 (Credits SamuelDr)

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/handlers/page/edit.php

    r65 r84  
    1010<div class="page"<?php echo $ondblclick;?>> 
    1111<?php 
    12 if (!(preg_match("/^[A-Za-zÄÖÜßäöü]+[A-Za-z0-9ÄÖÜßäöü]*$/s", $this->tag))) { 
     12if (!(preg_match("/^[A-Za-zÄÖÜßäöü]+[A-Za-z0-9ÄÖÜßäöü]*$/s", $this->tag))) { //TODO use central regex library 
    1313        echo '<em>The page name is invalid. Valid page names must start with a letter and contain only letters and numbers.</em>'; 
    1414} 
     
    3535                                if ($this->page['id'] != $_POST['previous']) 
    3636                                { 
    37                                         $error = 'OVERWRITE ALERT: This page was modified by someone else while you were editing it.<br />'."\n".'Please copy your changes and re-edit this page.'; 
     37                                        $error = 'OVERWRITE ALERT: This page was modified by someone else while you were editing it.<br />'."\n".'Please copy your changes and re-edit this page.<br />'; 
    3838                                } 
     39                        } 
     40                        // check for edit note 
     41                        if (($this->config['require_edit_note'] == 1) && $_POST['note']=='') 
     42                        { 
     43                                $error .= 'MISSING EDIT NOTE: Please fill in an edit note!<br />'."\n"; 
    3944                        } 
    4045                        // store 
     
    8388        { 
    8489                $previewButtons = 
    85                         "<hr />\n". 
     90                        "<hr />\n"; 
    8691                        // We need to escape ALL entity refs before display so we display them _as_ entities instead of interpreting them 
    8792                        // so we use htmlspecialchars on the edit note (as on the body) 
    88                         '<input size="50" type="text" name="note" value="'.htmlspecialchars($note).'"/> Note on your edit.<br />'."\n". 
    89                         '<input name="submit" type="submit" value="Store" accesskey="s" />'."\n". 
     93                if ($this->config['require_edit_note'] != 2) //check if edit_notes are enabled 
     94                { 
     95                        $previewButtons .= '<input size="50" type="text" name="note" value="'.htmlspecialchars($note).'"/> Note on your edit.<br />'."\n"; 
     96                } 
     97                $previewButtons .= '<input name="submit" type="submit" value="Store" accesskey="s" />'."\n". 
    9098                        '<input name="submit" type="submit" value="Re-Edit" accesskey="p" id="reedit_id" />'."\n". 
    9199                        '<input type="button" value="Cancel" onclick="document.location=\''.$this->href('').'\';" />'."\n"; 
     
    123131                if ($error) 
    124132                { 
    125                         $output .= '<div class="error">'.$error.'</div>'."\n"; 
     133                        $output .= '<em class="error">'.$error.'</em>'."\n"; 
    126134                } 
    127135 
     
    137145                        // We need to escape ALL entity refs before display so we display them _as_ entities instead of interpreting them 
    138146                        // hence htmlspecialchars() instead of htmlspecialchars_ent() which UNescapes entities! 
    139                         '<textarea id="body" name="body" style="width: 100%; height: 500px">'.htmlspecialchars($body).'</textarea><br />'."\n". 
     147                        '<textarea id="body" name="body" style="width: 100%; height: 500px">'.htmlspecialchars($body).'</textarea><br />'."\n"; 
    140148                        //note add Edit 
    141149                        // We need to escape ALL entity refs before display so we display them _as_ entities instead of interpreting them 
    142150                        // so we use htmlspecialchars on the edit note (as on the body) 
    143                         '<input size="40" type="text" name="note" value="'.htmlspecialchars($note).'" /> Please add a note on your edit.<br />'."\n". 
    144                         //finish 
    145                         '<input name="submit" type="submit" value="Store" accesskey="s" /> <input name="submit" type="submit" value="Preview" accesskey="p" /> <input type="button" value="Cancel" onclick="document.location=\''.$this->Href('').'\';" />'."\n". 
     151                if ($this->config['require_edit_note'] != 2) //check if edit_notes are enabled 
     152                { 
     153                        $output .= '<input size="40" type="text" name="note" value="'.htmlspecialchars($note).'" /> Please add a note on your edit.<br />'."\n"; 
     154                } 
     155                //finish 
     156                $output .=      '<input name="submit" type="submit" value="Store" accesskey="s" /> <input name="submit" type="submit" value="Preview" accesskey="p" /> <input type="button" value="Cancel" onclick="document.location=\''.$this->Href('').'\';" />'."\n". 
    146157                        $this->FormClose(); 
    147158 
    148                 if ($this->GetConfigValue('gui_editor') == 1) { 
    149                         $output .= 
    150                                         '<script language="JavaScript" src="3rdparty/plugins/wikiedit/protoedit.js"></script>'."\n". 
    151                                         '<script language="JavaScript" src="3rdparty/plugins/wikiedit/wikiedit2.js"></script>'."\n"; 
     159                if ($this->config['gui_editor'] == 1)  
     160                { 
     161                        $output .= '<script type="text/javascript" src="3rdparty/plugins/wikiedit/protoedit.js"></script>'."\n". 
     162                                        '<script type="text/javascript" src="3rdparty/plugins/wikiedit/wikiedit2.js"></script>'."\n"; 
    152163                        $output .= '<script type="text/javascript">'."  wE = new WikiEdit(); wE.init('body','WikiEdit','editornamecss');".'</script>'."\n"; 
    153164                } 
  • trunk/setup/install.php

    r79 r84  
    285285        test(sprintf(ADDING_CONFIG_ENTRY, 'wiki_suffix'), 1); 
    286286        $config["wiki_suffix"] = '@wikka'; 
     287        test(sprintf(ADDING_CONFIG_ENTRY, 'require_edit_note'), 1); 
     288        $config["require_edit_note"] = '0'; 
    287289        // cookie names have changed -- logout user and delete the old cookies 
    288290        test(DELETING_COOKIES, 1); 
  • trunk/wikka.php

    r83 r84  
    130130        'xml_recent_changes'            => '10', 
    131131        'hide_comments'                 => '0', 
     132        'require_edit_note'             => '0',         # edit note optional (0, default), edit note required (1) edit note disabled (2) 
    132133        'anony_delete_own_comments'     => '1', 
    133134        'double_doublequote_html'       => 'safe',