Browse Source

Issue #306 - Cleaning trailing whitespace in some files.

Ivan Tcholakov 15 years ago
parent
commit
88fffff15f

+ 1 - 1
main/inc/lib/internationalization.lib.php

@@ -250,7 +250,7 @@ function api_format_date($date_format, $time_stamp = -1, $language = null) {
 	}
 	// We replace %a %A %b %B masks of date format with translated strings.
 	$translated = &_api_get_day_month_names($language);
-	$date_format = str_replace(array('%A', '%a', '%B', '%b'), 
+	$date_format = str_replace(array('%A', '%a', '%B', '%b'),
 		array($translated['days_long'][(int)strftime('%w', $time_stamp)],
 			$translated['days_short'][(int)strftime('%w', $time_stamp)],
 			$translated['months_long'][(int)strftime('%m', $time_stamp) - 1],

+ 1 - 1
main/inc/lib/internationalization_internal.lib.php

@@ -119,7 +119,7 @@ function _api_get_person_name_convention($language, $type) {
 
 /**
  * Replaces non-valid formats for person names with the default (English) format.
- * @param string $format	The input format to be verified. 
+ * @param string $format	The input format to be verified.
  * @return bool				Returns the same format if is is valid, otherwise returns a valid English format.
  */
 function _api_validate_person_name_format($format) {

+ 10 - 10
main/inc/lib/multibyte_string_functions.lib.php

@@ -19,7 +19,7 @@
  *
  * 1. For all the functions from this library witn optional encoding
  * parameters, the system's encoding is assumed by default, i.e. the
- * value that is returned by api_get_setting('platform_charset') or 
+ * value that is returned by api_get_setting('platform_charset') or
  * the value of the global variable $charset.
  *
  * 2. In other aspects, most of the functions in this library try to copy
@@ -39,7 +39,7 @@
  * When encodings to be used are not supported by mbstring, this library
  * is able to exploit the PHP iconv extesion, which in this case should
  * be activated too.
- * 
+ *
  * 5. For improved sorting of multibyte strings the library uses the intl
  * php-extension if it is installed.
  */
@@ -518,7 +518,7 @@ function api_transliterate($string, $unknown = '?', $from_encoding = null) {
 				}
 				$ord = $ord & 255;
 				$result .= isset($map[$bank]['en'][$ord]) ? $map[$bank]['en'][$ord] : $unknown;
-				
+
 				$head = '';
 			}
 			elseif ($c < "\x80") {
@@ -553,7 +553,7 @@ function api_transliterate($string, $unknown = '?', $from_encoding = null) {
  * @param mixed $search					String or array of strings to be found.
  * @param mixed $replace				String or array of strings used for replacement.
  * @param mixed $subject				String or array of strings being searced.
- * @param int $count (optional)			The number of matched and replaced needles will be returned in count, which is passed by reference. 
+ * @param int $count (optional)			The number of matched and replaced needles will be returned in count, which is passed by reference.
  * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
  * @return mixed						String or array as a result.
  * Notes:
@@ -680,7 +680,7 @@ function api_str_split($string, $split_length = 1, $encoding = null) {
  * @param int $offset					The position in $haystack to start searching from. If it is omitted, searching starts from the beginning.
  * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
  * @return mixed						Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found.
- * Note: The first character's position is 0, the second character position is 1, and so on. 
+ * Note: The first character's position is 0, the second character position is 1, and so on.
  * This function is aimed at replacing the functions stripos() and mb_stripos() for human-language strings.
  * @link http://php.net/manual/en/function.stripos
  * @link http://php.net/manual/en/function.mb-stripos
@@ -819,7 +819,7 @@ function api_strlen($string, $encoding = null) {
  * @param int $offset (optional)		The position in $haystack to start searching from. If it is omitted, searching starts from the beginning.
  * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
  * @return mixed						Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found.
- * Note: The first character's position is 0, the second character position is 1, and so on. 
+ * Note: The first character's position is 0, the second character position is 1, and so on.
  * This function is aimed at replacing the functions strpos() and mb_strpos() for human-language strings.
  * @link http://php.net/manual/en/function.strpos
  * @link http://php.net/manual/en/function.mb-strpos
@@ -967,7 +967,7 @@ function api_strrev($string, $encoding = null) {
  * @param int $offset (optional)		$offset may be specified to begin searching an arbitrary position. Negative values will stop searching at an arbitrary point prior to the end of the string.
  * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
  * @return mixed						Returns the numeric position of the first occurrence (case insensitive) of $needle in the $haystack, or FALSE if $needle is not found.
- * Note: The first character's position is 0, the second character position is 1, and so on. 
+ * Note: The first character's position is 0, the second character position is 1, and so on.
  * This function is aimed at replacing the functions strripos() and mb_strripos() for human-language strings.
  * @link http://php.net/manual/en/function.strripos
  * @link http://php.net/manual/en/function.mb-strripos
@@ -983,7 +983,7 @@ function api_strripos($haystack, $needle, $offset = 0, $encoding = null) {
  * @param int $offset (optional)		$offset may be specified to begin searching an arbitrary position. Negative values will stop searching at an arbitrary point prior to the end of the string.
  * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
  * @return mixed						Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found.
- * Note: The first character's position is 0, the second character position is 1, and so on. 
+ * Note: The first character's position is 0, the second character position is 1, and so on.
  * This function is aimed at replacing the functions strrpos() and mb_strrpos() for human-language strings.
  * @link http://php.net/manual/en/function.strrpos
  * @link http://php.net/manual/en/function.mb-strrpos
@@ -1410,7 +1410,7 @@ function api_substr($string, $start, $length = null, $encoding = null) {
  * If given and is positive, it represents the length of the portion of the string which is to be replaced.
  * If it is negative, it represents the number of characters from the end of string at which to stop replacing.
  * If it is not given, then it will default to api_strlen($string); i.e. end the replacing at the end of string.
- * If $length is zero, then this function will have the effect of inserting replacement into the string at the given start offset. 
+ * If $length is zero, then this function will have the effect of inserting replacement into the string at the given start offset.
  * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
  * @return string						The result string is returned.
  * This function is aimed at replacing the function substr_replace() for human-language strings.
@@ -1898,7 +1898,7 @@ function api_strnatcasecmp($string1, $string2, $language = null, $encoding = nul
  * @param string $string2				The second string.
  * @param string $language (optional)	The language in which comparison is to be made. If language is omitted, interface language is assumed then.
  * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
- * @return int							Returns < 0 if $string1 is less than $string2; > 0 if $string1 is greater than $string2; and 0 if the strings are equal. 
+ * @return int							Returns < 0 if $string1 is less than $string2; > 0 if $string1 is greater than $string2; and 0 if the strings are equal.
  * This function is aimed at replacing the function strnatcmp() for human-language strings.
  * @link http://php.net/manual/en/function.strnatcmp.php
  * @link http://php.net/manual/en/collator.compare.php

+ 2 - 2
main/inc/lib/multibyte_string_functions_internal.lib.php

@@ -675,7 +675,7 @@ function api_get_default_locale() {
 /**
  * Returns a table with non-UTF-8 encodings for all system languages.
  * @return array		Returns an array in the form array('language1' => array('encoding1', encoding2', ...), ...)
- * Note: The function api_get_non_utf8_encoding() returns the first encoding from this array that is correspondent to the given language. 
+ * Note: The function api_get_non_utf8_encoding() returns the first encoding from this array that is correspondent to the given language.
  */
 function & _api_non_utf8_encodings() {
 	static $encodings;
@@ -999,7 +999,7 @@ if (MBSTRING_INSTALLED && !function_exists('mb_strrchr')) {
 		$pos = mb_strrpos($haystack, $needle, mb_strlen($haystack, $encoding) - 1, $encoding);
 		if ($pos === false) {
 			return false;
-		} 
+		}
 		if ($part) {
 			return mb_substr($haystack, 0, $pos + 1, $encoding);
 		}

+ 35 - 35
tests/main/inc/lib/multibyte_string_functions.lib.test.php

@@ -2,7 +2,7 @@
 
 /**
  * This is a test of multibyte_string_functions.lib which is
- * a common purpose library for supporting multibyte string 
+ * a common purpose library for supporting multibyte string
  * aware functions. Only the public API is tested here.
  * @author Ricardo Rodriguez Salazar, 2009.
  * @author Ivan Tcholakov, August 2009.
@@ -62,7 +62,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 		$from_encoding = 'ISO-8859-15';
 		$string1 = api_utf8_decode($string, $from_encoding);
 		$res = api_utf8_encode($string1, $from_encoding);
-		$this->assertTrue(is_string($res)); 
+		$this->assertTrue(is_string($res));
 		$this->assertTrue($res == $string);
 		//var_dump($res);
 	}
@@ -71,14 +71,14 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 		$string = 'xxxx1ws?!áéíóú@€'; // UTF-8
 		$to_encoding = 'ISO-8859-15';
 		$res = api_utf8_decode($string, $to_encoding);
-		$this->assertTrue(is_string($res)); 
+		$this->assertTrue(is_string($res));
 		$this->assertTrue(api_utf8_encode($res, $to_encoding) == $string);
 		//var_dump($res);
 	}
 
 	public function test_api_to_system_encoding() {
 		$string = '!?/\áéíóú@€'; // UTF-8
-		$from_encoding = 'UTF-8'; 
+		$from_encoding = 'UTF-8';
 		$check_utf8_validity = false;
 		$res = api_to_system_encoding($string, $from_encoding, $check_utf8_validity);
 		$this->assertTrue(is_string($res));
@@ -88,17 +88,17 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_htmlentities() {
 		$string = 'áéíóú@!?/\-_`*ç´`'; // UTF-8
-		$quote_style = ENT_QUOTES; 
+		$quote_style = ENT_QUOTES;
 		$encoding = 'UTF-8';
 		$res = api_htmlentities($string, $quote_style, $encoding);
 		$this->assertTrue(is_string($res));
 		$this->assertTrue(api_convert_encoding($res, $encoding, 'HTML-ENTITIES') == $string);
-		//var_dump($res);	
+		//var_dump($res);
 	}
 
 	public function test_api_html_entity_decode() {
 		$string = 'áéíóú@/\!?Ç´`+*?-_ '; // UTF-8
-		$quote_style = ENT_QUOTES; 
+		$quote_style = ENT_QUOTES;
 		$encoding = 'UTF-8';
 		$res = api_html_entity_decode(api_convert_encoding($string, 'HTML-ENTITIES', $encoding), $quote_style, $encoding);
 		$this->assertTrue(is_string($res));
@@ -124,8 +124,8 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_file_system_decode() {
 		$string='áéíóú@/\!?Ç´`+*?-_'; // UTF-8
-		$to_encoding = 'UTF-8';	
-		$res = api_file_system_decode($string, $to_encoding); 
+		$to_encoding = 'UTF-8';
+		$res = api_file_system_decode($string, $to_encoding);
 		$this->assertTrue(is_string($res));
 		//var_dump($res);
 	}
@@ -140,7 +140,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 			'&#1044;&#1086;&#1089;&#1090;&#1086;&#1077;&#1074;&#1082;&#1080;&#1081;',
 			ENT_QUOTES, 'UTF-8');
 		*/
-		$unknown = 'X'; 
+		$unknown = 'X';
 		$from_encoding = 'UTF-8';
 		$res = api_transliterate($string, $unknown, $from_encoding);
 		$this->assertTrue($res);
@@ -150,7 +150,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 		//var_dump($res);
 	}
 
-	
+
 /**
  * ----------------------------------------------------------------------------
  * Common multibyte string functions
@@ -161,7 +161,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 		$search = 'Á'; // UTF-8
 		$replace = 'a';
 		$subject = 'bájando'; // UTF-8
-		$count = null; 
+		$count = null;
 		$encoding = 'UTF-8';
 		$res = api_str_ireplace($search, $replace, $subject, & $count, $encoding);
 		$this->assertTrue($res);
@@ -266,9 +266,9 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_strstr() {
 		$haystack = 'aviación'; // UTF-8
-		$needle = 'ó'; 
-		$part = false; 
-		$encoding = 'UTF-8';		
+		$needle = 'ó';
+		$part = false;
+		$encoding = 'UTF-8';
 		$res = api_strstr($haystack, $needle, $part, $encoding);
 		$this->assertTrue(is_bool($res)|| is_string($res));
 		$this->assertTrue($res == 'ón');
@@ -296,7 +296,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 	public function test_api_substr() {
 		$string = 'áéíóúº|\/?Ç][ç]'; // UTF-8
 		$start = 10;
-		$length = 4; 
+		$length = 4;
 		$encoding = 'UTF-8';
 		$res = api_substr($string, $start, $length, $encoding);
 		$this->assertTrue(is_string($res));
@@ -306,9 +306,9 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_substr_replace() {
 		$string = 'áéíóúº|\/?Ç][ç]'; // UTF-8
-		$replacement = 'eiou'; 
-		$start= 1; 
-		$length = 4; 
+		$replacement = 'eiou';
+		$start= 1;
+		$length = 4;
 		$encoding = 'UTF-8';
 		$res = api_substr_replace($string, $replacement, $start, $length, $encoding);
 		$this->assertTrue(is_string($res));
@@ -410,7 +410,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
  * ----------------------------------------------------------------------------
  */
 
-	public function test_api_ereg() {	
+	public function test_api_ereg() {
 		$pattern = 'scorm/showinframes.php([^"\'&]*)(&|&amp;)file=([^"\'&]*)$';
 		$string = 'http://localhost/dokeos/main/scorm/showinframes.php?id=5&amp;file=test.php';
 		$res = api_ereg($pattern, $string, $regs);
@@ -421,8 +421,8 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_ereg_replace() {
 		$pattern = 'file=([^"\'&]*)$';
-		$string = 'http://localhost/dokeos/main/scorm/showinframes.php?id=5&amp;file=test.php'; 
-		$replacement = 'file=my_test.php'; 
+		$string = 'http://localhost/dokeos/main/scorm/showinframes.php?id=5&amp;file=test.php';
+		$replacement = 'file=my_test.php';
 		$option = null;
 		$res = api_ereg_replace($pattern, $replacement, $string, $option);
 		$this->assertTrue(is_string($res));
@@ -441,8 +441,8 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_eregi_replace() {
 		$pattern = 'file=([^"\'&]*)$';
-		$string = 'http://localhost/dokeos/main/scorm/showinframes.php?id=5&amp;file=test.php'; 
-		$replacement = 'file=my_test.php'; 
+		$string = 'http://localhost/dokeos/main/scorm/showinframes.php?id=5&amp;file=test.php';
+		$replacement = 'file=my_test.php';
 		$option = null;
 		$res = api_eregi_replace($pattern, $replacement, $string, $option);
 		$this->assertTrue(is_string($res));
@@ -452,7 +452,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_split() {
 		$pattern = '[/.-]';
-		$string = '08/22/2009'; 
+		$string = '08/22/2009';
 		$limit = null;
 		$res = api_split($pattern, $string, $limit);
 		$this->assertTrue(is_array($res));
@@ -520,7 +520,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_asort() {
 		$array = array('úéo', 'aíó', 'áed'); // UTF-8
-		$sort_flag = SORT_REGULAR; 
+		$sort_flag = SORT_REGULAR;
 		$language = 'english';
 		$encoding = 'UTF-8';
 		$res = api_asort($array, $sort_flag, $language, $encoding);
@@ -530,10 +530,10 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 		//var_dump($array);
 		//var_dump($res);
 	}
-	
+
 	public function test_api_arsort() {
 		$array = array('aíó', 'úéo', 'áed'); // UTF-8
-		$sort_flag = SORT_REGULAR; 
+		$sort_flag = SORT_REGULAR;
 		$language = 'english';
 		$encoding = 'UTF-8';
 		$res = api_arsort($array, $sort_flag, $language, $encoding);
@@ -555,7 +555,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 		//var_dump($array);
 		//var_dump($res);
 	}
-	
+
 	public function test_api_natrsort() {
 		$array = array('img2.png', 'img10.png', 'img12.png', 'img1.png'); // UTF-8
 		$language = 'english';
@@ -594,7 +594,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_ksort() {
 		$array = array('aíó' => 'img2.png', 'úéo' => 'img10.png', 'áed' => 'img12.png', 'áedc' => 'img1.png'); // UTF-8
-		$sort_flag = SORT_REGULAR; 
+		$sort_flag = SORT_REGULAR;
 		$language = 'english';
 		$encoding = 'UTF-8';
 		$res = api_ksort($array, $sort_flag, $language, $encoding);
@@ -607,7 +607,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_krsort() {
 		$array = array('aíó' => 'img2.png', 'úéo' => 'img10.png', 'áed' => 'img12.png', 'áedc' => 'img1.png'); // UTF-8
-		$sort_flag = SORT_REGULAR; 
+		$sort_flag = SORT_REGULAR;
 		$language = 'english';
 		$encoding = 'UTF-8';
 		$res = api_krsort($array, $sort_flag, $language, $encoding);
@@ -668,7 +668,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function test_api_sort() {
 		$array = array('úéo', 'aíó', 'áed', 'áedc'); // UTF-8
-		$sort_flag = SORT_REGULAR; 
+		$sort_flag = SORT_REGULAR;
 		$language = 'english';
 		$encoding = 'UTF-8';
 		$res = api_sort($array, $sort_flag, $language, $encoding);
@@ -680,7 +680,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 
 	public function testapi_rsort() {
 		$array = array('aíó', 'úéo', 'áed', 'áedc'); // UTF-8
-		$sort_flag = SORT_REGULAR; 
+		$sort_flag = SORT_REGULAR;
 		$language = 'english';
 		$encoding = 'UTF-8';
 		$res = api_rsort($array, $sort_flag, $language, $encoding);
@@ -700,7 +700,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 	public function test_api_in_array_nocase() {
 		$needle = 'áéíó'; // UTF-8
 		$haystack = array('Áéíó', 'uáé', 'íóú'); // UTF-8
-		$strict = false; 
+		$strict = false;
 		$encoding = 'UTF-8';
 		$res = api_in_array_nocase($needle, $haystack, $strict, $encoding);
 		$this->assertTrue(is_bool($res));
@@ -827,7 +827,7 @@ class TestMultibyte_String_Functions extends UnitTestCase {
 		<User>username2</User>
     	</Course>
     </Session>
-    
+
     <Session>
         <SessionName>xxx</SessionName>
         <Coach>xxx</Coach>