Commit fdc2dcf2 authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

MDL-72871 cleanup: Remove incorrect whitespace from codebase

Differences can be checked with git diff --ignore-all-space and
that will show that the only non-whitespace change is in a test
in the git lib/tests/html2text_test.php file. In that case the
whitespace has been replaced by a quoted string (of whitespaces)
keeping the test 100% equivalent and workarrounding the whitespace.
parent 2b2897bf
......@@ -2,15 +2,15 @@
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="moodle_database" type="databaseType" />
<xs:complexType name="databaseType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="table"
type="tableType" />
</xs:sequence>
<xs:attribute name="version" type="xs:float" use="required" />
<xs:sequence>
<xs:element maxOccurs="unbounded" name="table"
type="tableType" />
</xs:sequence>
<xs:attribute name="version" type="xs:float" use="required" />
<xs:attribute name="release" type="xs:string"></xs:attribute>
<xs:attribute name="timestamp" type="xs:dateTime"
use="required" />
<xs:attribute name="comment" type="xs:string" />
use="required" />
<xs:attribute name="comment" type="xs:string" />
</xs:complexType>
<xs:complexType name="tableType">
<xs:sequence>
......
......@@ -5,7 +5,7 @@
* http://sourceforge.net/projects/lamplib
* This project is administered by Markus Baker, Harry Fuecks and Matt
* Mitchell, and the project code is in the public domain.
*
*
* Thanks, guys!
*
* @package moodlecore
......@@ -23,7 +23,7 @@
define("LEXER_EXIT", 4);
/** LEXER_SPECIAL = 5 */
define("LEXER_SPECIAL", 5);
/**
* Compounded regular expression. Any of
* the contained patterns could match and
......@@ -37,7 +37,7 @@
var $_labels;
var $_regex;
var $_case;
/**
* Constructor. Starts with no patterns.
* @param bool $case True for case sensitive, false
......@@ -75,7 +75,7 @@
$this->_labels[$count] = $label;
$this->_regex = null;
}
/**
* Attempts to match all patterns at once against
* a string.
......@@ -101,7 +101,7 @@
}
return true;
}
/**
* Compounds the patterns into a single
* regular expression separated with the
......@@ -121,7 +121,7 @@
}
return $this->_regex;
}
/**
* Accessor for perl regex mode flags to use.
* @return string Flags as string.
......@@ -131,7 +131,7 @@
return ($this->_case ? "msS" : "msSi");
}
}
/**
* States for a stack machine.
*
......@@ -141,7 +141,7 @@
*/
class StateStack {
var $_stack;
/**
* Constructor. Starts in named state.
* @param string $start Starting state name.
......@@ -169,7 +169,7 @@
function getCurrent() {
return $this->_stack[count($this->_stack) - 1];
}
/**
* Adds a state to the stack and sets it
* to be the current state.
......@@ -179,7 +179,7 @@
function enter($state) {
array_push($this->_stack, $state);
}
/**
* Leaves the current state and reverts
* to the previous one.
......@@ -195,7 +195,7 @@
return true;
}
}
/**
* Accepts text and breaks it into tokens.
* Some optimisation to make the sure the
......@@ -213,7 +213,7 @@
var $_mode;
var $_mode_handlers;
var $_case;
/**
* Sets up the lexer in case insensitive matching
* by default.
......@@ -240,7 +240,7 @@
debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
self::__construct($parser, $start, $case);
}
/**
* Adds a token search pattern for a particular
* parsing mode. The pattern does not change the
......@@ -258,7 +258,7 @@
}
$this->_regexes[$mode]->addPattern($pattern);
}
/**
* Adds a pattern that will enter a new parsing
* mode. Useful for entering parenthesis, strings,
......@@ -278,7 +278,7 @@
}
$this->_regexes[$mode]->addPattern($pattern, $new_mode);
}
/**
* Adds a pattern that will exit the current mode
* and re-enter the previous one.
......@@ -293,7 +293,7 @@
}
$this->_regexes[$mode]->addPattern($pattern, "__exit");
}
/**
* Adds a pattern that has a special mode.
* Acts as an entry and exit pattern in one go.
......@@ -311,7 +311,7 @@
}
$this->_regexes[$mode]->addPattern($pattern, "_$special");
}
/**
* Adds a mapping from a mode to another handler.
* @param string $mode Mode to be remapped.
......@@ -321,7 +321,7 @@
function mapHandler($mode, $handler) {
$this->_mode_handlers[$mode] = $handler;
}
/**
* Splits the page text into tokens. Will fail
* if the handlers report an error or if no
......@@ -352,7 +352,7 @@
}
return $this->_invokeParser($raw, LEXER_UNMATCHED);
}
/**
* Sends the matched token and any leading unmatched
* text to the parser changing the lexer to a new
......@@ -390,7 +390,7 @@
}
return $this->_invokeParser($matched, LEXER_MATCHED);
}
/**
* Calls the parser method named after the current
* mode. Empty content will be ignored.
......@@ -409,7 +409,7 @@
}
return $this->_parser->$handler($content, $is_match);
}
/**
* Tries to match a chunk of text and if successful
* removes the recognised chunk and any leading
......
......@@ -78,9 +78,9 @@ class core_html2text_testcase extends basic_testcase {
*/
public function test_build_link_list() {
// Note the trailing whitespace left intentionally in the text.
// Note the trailing whitespace left intentionally in the text after first link.
$text = 'Total of <a title="List of integrated issues"
href="http://tr.mdl.org/sh.jspa?r=1&j=p+%3D+%22I+d%22+%3D">
href="http://tr.mdl.org/sh.jspa?r=1&j=p+%3D+%22I+d%22+%3D"> ' . '
<strong>27 issues</strong></a> and <a href="http://another.url/?f=a&amp;b=2">some</a> other
have been fixed <strong><a href="http://third.url/view.php">last week</a></strong>';
......
Wiki 2.0
by Jordi Piguillem and Ludo (Marc Alier) 2008 - Universitat Politecnica de
by Jordi Piguillem and Ludo (Marc Alier) 2008 - Universitat Politecnica de
Catalunya
http://www.upc.edu - http://dfwikilabs.org
\ No newline at end of file
http://www.upc.edu - http://dfwikilabs.org
This diff is collapsed.
This diff is collapsed.
......@@ -24,58 +24,58 @@ function insertTags(tagOpen, tagClose, sampleText) {
// 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;
}
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 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;
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;
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();
......
......@@ -12,7 +12,7 @@
include_once("wikimarkup.php");
class nwiki_parser extends wiki_markup_parser {
protected $blockrules = array(
'nowiki' => array(
'expression' => "/^<nowiki>(.*?)<\/nowiki>/ims",
......@@ -53,7 +53,7 @@ class nwiki_parser extends wiki_markup_parser {
'tag' => 'p'
)
);
protected $tagrules = array(
'nowiki' => array(
'expression' => "/<nowiki>(.*?)<\/nowiki>/is",
......@@ -93,11 +93,11 @@ class nwiki_parser extends wiki_markup_parser {
'token' => array("''", "''")
)
);
protected function after_parsing() {
parent::after_parsing();
}
/**
* Block hooks
*/
......@@ -106,12 +106,12 @@ class nwiki_parser extends wiki_markup_parser {
if($match[1] != $match[3]) {
return $match[0];
}
$num = strlen($match[1]);
return $this->generate_header($match[2], $num);
}
protected function table_block_rule($match) {
$rows = explode("\n|-", $match[1]);
$table = array();
......@@ -121,14 +121,14 @@ class nwiki_parser extends wiki_markup_parser {
foreach($colsendline as $ce) {
$cols = array_merge($cols, $this->get_table_cells($ce));
}
if(!empty($cols)) {
$table[] = $cols;
}
}
return $this->generate_table($table);
}
private function get_table_cells($string) {
$string = ltrim($string);
$type = (!empty($string) && $string[0] == "!") ? 'header' : 'normal';
......@@ -149,10 +149,10 @@ class nwiki_parser extends wiki_markup_parser {
}
$type = 'normal';
}
return $cells;
}
protected function tab_paragraph_block_rule($match) {
$num = strlen($match[1]);
$text = $match[2];
......@@ -160,31 +160,31 @@ class nwiki_parser extends wiki_markup_parser {
for($i = 0; $i < $num - 1; $i++) {
$html = parser_utils::h('p', $html, array('class' => 'wiki_tab_paragraph'));
}
return parser_utils::h('p', $text, array('class' => 'wiki_tab_paragraph'));
}
protected function desc_list_block_rule($match) {
preg_match_all("/^(.+?)\:(.+?)\;$/ims", $match[0], $listitems, PREG_SET_ORDER);
$list = "";
foreach($listitems as $li) {
$term = $li[1];
$this->rules($term);
$description = $li[2];
$this->rules($description);
$list .= parser_utils::h('dt', $term).parser_utils::h('dd', $description);
}
return $list;
}
/**
* Tag functions
*/
/**
* Bold and italic similar to creole...
*/
......@@ -193,23 +193,23 @@ class nwiki_parser extends wiki_markup_parser {
if(strlen($match[2]) == 5) {
$text .= "''";
}
$this->rules($text, array('only' => array('bold')));
if(strpos($text, "''") !== false) {
$text = str_replace("''", $this->protect("''"), $text);
}
return array($text, array());
}
/**
* Link tag functions
*/
protected function link_tag_rule($match) {
return $this->format_link($match[1]);
}
protected function url_tag_tag_rule($match) {
$text = trim($match[1]);
if(preg_match("/(.+?)\|(.+)/is", $text, $matches)) {
......@@ -225,34 +225,34 @@ class nwiki_parser extends wiki_markup_parser {
}
return array($this->protect($text), array('href' => $this->protect($link)));
}
protected function url_tag_rule($match) {
$url = $this->protect($match[1]);
$options = array('href' => $url);
return array($url, $options);
}
/**
* Attachments & images
*/
protected function image_tag_rule($match) {
return $this->format_image($match[1], $match[2]);
}
protected function attach_tag_rule($match) {
protected function attach_tag_rule($match) {
$parts = explode("|", $match[1]);
$url = array_shift($parts);
if(count($parts) > 0) {
$text = array_shift($parts);
}
$extension = substr($url, strrpos($url, "."));
$text = empty($text) ? $url : $text;
$imageextensions = array('jpg', 'jpeg', 'png', 'bmp', 'gif', 'tif');
if(in_array($extension, $imageextensions)) {
$align = 'left';
......
......@@ -10,9 +10,9 @@
*/
require_once($CFG->dirroot . "/lib/outputcomponents.php");
class parser_utils {
public static function h($tag, $text = null, $options = array(), $escape_text = false) {
$tag = htmlentities($tag, ENT_COMPAT, 'UTF-8');
if(!empty($text) && $escape_text) {
......@@ -20,7 +20,7 @@ class parser_utils {
}
return html_writer::tag($tag, $text, $options);
}
/**
* Default link generator
*/
......@@ -77,7 +77,7 @@ class parser_utils {
}
else if($row[$i][0] == 'normal'){
$htmlrow .= "\n".parser_utils::h('td', $text)."\n";
}
}
}
}
$bodyhtml .= "\n".parser_utils::h('tr', $htmlrow)."\n";
......@@ -86,11 +86,11 @@ class parser_utils {
$html .= "\n".parser_utils::h('tbody', $bodyhtml)."\n";
return "\n".parser_utils::h('table', $html)."\n";
}
/**
* Default path converter
*/
public static function wiki_parser_real_path($url) {
return $url;
}
......
......@@ -44,7 +44,7 @@ $PAGE->navbar->ignore_active(true);
$PAGE->navbar->add(get_string('preferences'), new moodle_url('/user/preferences.php'));
$PAGE->navbar->add(get_string('useraccount'));
$PAGE->navbar->add(get_string('securitykeys', 'webservice'),
new moodle_url('/user/managetoken.php',
new moodle_url('/user/managetoken.php',
array('id' => $tokenid, 'sesskey' => sesskey())));
$PAGE->navbar->add(get_string('wsdocumentation', 'webservice'));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment