[svn r20456] FS#306 - The common libraries: Improvements for better encoding support, part 1.

skala
Ivan Tcholakov 17 years ago
parent 2a2f5d5af5
commit 126ed7adee
  1. 2
      main/inc/lib/fckeditor/editor/plugins/audio/fck_audio.html
  2. 6
      main/inc/lib/fckeditor/fcktemplates.xml.php
  3. 3
      main/inc/lib/formvalidator/Element/calendar_popup.php
  4. 6
      main/inc/lib/formvalidator/Element/datepicker.php
  5. 6
      main/inc/lib/formvalidator/Rule/Filetype.php
  6. 7
      main/inc/lib/pear/HTML/Common.php
  7. 16
      main/inc/lib/pear/HTML/QuickForm/Renderer/ArraySmarty.php
  8. 12
      main/inc/lib/pear/HTML/QuickForm/Renderer/ObjectFlexy.php
  9. 6
      main/inc/lib/pear/HTML/QuickForm/Rule/Range.php
  10. 9
      main/inc/lib/pear/HTML/QuickForm/date.php
  11. 7
      main/inc/lib/pear/HTML/QuickForm/element.php
  12. 8
      main/inc/lib/pear/HTML/QuickForm/group.php
  13. 8
      main/inc/lib/pear/HTML/QuickForm/hierselect.php
  14. 8
      main/inc/lib/pear/HTML/QuickForm/textarea.php
  15. 19
      main/inc/lib/pear/Pager/Common.php

@ -94,7 +94,7 @@ document.write( FCKTools.GetStyleHtml( GetCommonDialogCss() ) ) ;
<span fckLang="DlgLnkUpload">Upload</span><br />
<input id="txtUploadFile" style="width: 100%" type="file" size="40" name="NewFile" /><br />
<br />
<button id="btnUpload" type="submit" class="save" value="Send it to the Server" fckLang="DlgLnkBtnUpload" />Send it to the ServerCarlos</button>
<button id="btnUpload" type="submit" class="save" value="Send it to the Server" fckLang="DlgLnkBtnUpload" />Send it to the Server</button>
<script type="text/javascript">
document.write( '<iframe name="UploadWindow" style="display: none" src="' + FCKTools.GetVoidUrl() + '"><\/iframe>' ) ;
</script>

@ -62,7 +62,7 @@ function s($var)
global $charset;
$search = array('&','<','>');
$replace = array ('&amp;','&amp;lt;','&amp;gt;');
return str_replace($search,$replace,mb_convert_encoding(get_lang($var),'UTF-8',$charset));
return str_replace($search,$replace,api_convert_encoding(get_lang($var),'UTF-8',$charset));
}
/**
@ -76,7 +76,7 @@ function s2($var)
global $charset;
$search = array('&','<','>');
$replace = array ('&amp;','&amp;lt;','&amp;gt;');
return str_replace($search,$replace,mb_convert_encoding($var,'UTF-8',$charset));
return str_replace($search,$replace,api_convert_encoding($var,'UTF-8',$charset));
}
/**
@ -195,4 +195,4 @@ function load_empty_template()
</Template>
<?php
}
?>
?>

@ -1,5 +1,5 @@
<?php
// $Id: calendar_popup.php 10204 2006-11-26 20:46:53Z pcool $
// $Id: calendar_popup.php 20456 2009-05-10 17:27:44Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
@ -47,6 +47,7 @@ if (empty ($iso_lang) )
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $iso_lang; ?>" lang="<?php echo $iso_lang; ?>">
<head>
<title>Calendar</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH); ?>/css/default.css"/>
<style type="text/css">
/*<![CDATA[*/

@ -1,5 +1,5 @@
<?php
// $Id: datepicker.php 18078 2009-01-29 17:21:11Z cfasanando $
// $Id: datepicker.php 20456 2009-05-10 17:27:44Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
@ -59,7 +59,7 @@ class HTML_QuickForm_datepicker extends HTML_QuickForm_date
$this->_locale[$editor_lang]['months_long'] = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
}
$this->_options['format'] = 'dFY '.$popup_link.' H '.$hour_minute_devider.' i';
$this->_options['minYear'] = date('Y')-1;
$this->_options['minYear'] = date('Y')-7;
$this->_options['maxYear'] = date('Y')+15;
$this->_options['language'] = $editor_lang;
//$this->_options['addEmptyOption'] = true;
@ -119,4 +119,4 @@ class HTML_QuickForm_datepicker extends HTML_QuickForm_date
$this->_options[$name] = $value;
}
}
?>
?>

@ -1,5 +1,5 @@
<?php
// $Id: Filetype.php 6187 2005-09-07 10:23:57Z bmol $
// $Id: Filetype.php 20456 2009-05-10 17:27:44Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
@ -42,7 +42,7 @@ class HTML_QuickForm_Rule_Filetype extends HTML_QuickForm_Rule
return false;
}
$ext = $parts[count($parts)-1];
return in_array($ext,$extensions);
return api_in_array_nocase($ext, $extensions);
}
}
?>
?>

@ -16,7 +16,7 @@
// | Author: Adam Daniel <adaniel1@eesus.jnj.com> |
// +----------------------------------------------------------------------+
//
// $Id: Common.php 6184 2005-09-07 10:08:17Z bmol $
// $Id: Common.php 20456 2009-05-10 17:27:44Z ivantcholakov $
/**
* Base class for all HTML classes
@ -135,9 +135,10 @@ class HTML_Common {
{
$strAttr = '';
global $charset;
if (is_array($attributes)) {
foreach ($attributes as $key => $value) {
$strAttr .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
$strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES, $charset) . '"';
}
}
return $strAttr;
@ -416,4 +417,4 @@ class HTML_Common {
} // end func display
} // end class HTML_Common
?>
?>

@ -18,7 +18,7 @@
// | Thomas Schulz <ths@4bconsult.de> |
// +----------------------------------------------------------------------+
//
// $Id: ArraySmarty.php 9612 2006-10-20 11:56:44Z bmol $
// $Id: ArraySmarty.php 20456 2009-05-10 17:27:44Z ivantcholakov $
require_once 'HTML/QuickForm/Renderer/Array.php';
@ -179,15 +179,15 @@ class HTML_QuickForm_Renderer_ArraySmarty extends HTML_QuickForm_Renderer_Array
$ret['error'] = $error;
}
// create keys for elements grouped by native group or name
if (strstr($ret['name'], '[') or $this->_currentGroup) {
if (api_strstr($ret['name'], '[') or $this->_currentGroup) {
// Fix for bug #8123: escape backslashes and quotes to prevent errors
// in eval(). The code below seems to handle the case where element
// name has unbalanced square brackets. Dunno whether we really
// need this after the fix for #8123, but I'm wary of making big
// changes to this code.
preg_match('/([^]]*)\\[([^]]*)\\]/', $ret['name'], $matches);
preg_match(api_add_pcre_unicode_modifier('/([^]]*)\\[([^]]*)\\]/'), $ret['name'], $matches);
if (isset($matches[1])) {
$sKeysSub = substr_replace($ret['name'], '', 0, strlen($matches[1]));
$sKeysSub = api_substr_replace($ret['name'], '', 0, api_strlen($matches[1]));
$sKeysSub = str_replace(
array('\\', '\'', '[' , ']', '[\'\']'),
array('\\\\', '\\\'', '[\'', '\']', '[]' ),
@ -205,8 +205,8 @@ class HTML_QuickForm_Renderer_ArraySmarty extends HTML_QuickForm_Renderer_Array
return false;
}
// reduce string of keys by remove leading group keys
if (0 === strpos($sKeys, $this->_currentGroup['keys'])) {
$sKeys = substr_replace($sKeys, '', 0, strlen($this->_currentGroup['keys']));
if (0 === api_strpos($sKeys, $this->_currentGroup['keys'])) {
$sKeys = api_substr_replace($sKeys, '', 0, api_strlen($this->_currentGroup['keys']));
}
}
// element without a name
@ -217,7 +217,7 @@ class HTML_QuickForm_Renderer_ArraySmarty extends HTML_QuickForm_Renderer_Array
$sKeys = '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['name']) . '\']';
}
// for radios: add extra key from value
if ('radio' == $ret['type'] and substr($sKeys, -2) != '[]') {
if ('radio' == $ret['type'] and api_substr($sKeys, -2) != '[]') {
$sKeys .= '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['value']) . '\']';
}
$this->_elementIdx++;
@ -378,4 +378,4 @@ class HTML_QuickForm_Renderer_ArraySmarty extends HTML_QuickForm_Renderer_Array
$this->_error = $template;
} // end func setErrorTemplate
}
?>
?>

@ -16,7 +16,7 @@
// | Author: Ron McClain <ron@humaniq.com> |
// +----------------------------------------------------------------------+
//
// $Id: ObjectFlexy.php 9612 2006-10-20 11:56:44Z bmol $
// $Id: ObjectFlexy.php 20456 2009-05-10 17:27:44Z ivantcholakov $
require_once("HTML/QuickForm/Renderer/Object.php");
@ -139,7 +139,7 @@ class HTML_QuickForm_Renderer_ObjectFlexy extends HTML_QuickForm_Renderer_Object
}
// Create an element key from the name
if (false !== ($pos = strpos($ret->name, '[')) || is_object($this->_currentGroup)) {
if (false !== ($pos = api_strpos($ret->name, '[')) || is_object($this->_currentGroup)) {
if (!$pos) {
$keys = '->{\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret->name) . '\'}';
} else {
@ -156,17 +156,17 @@ class HTML_QuickForm_Renderer_ObjectFlexy extends HTML_QuickForm_Renderer_Object
return false;
}
// reduce string of keys by remove leading group keys
if (0 === strpos($keys, $this->_currentGroup->keys)) {
$keys = substr_replace($keys, '', 0, strlen($this->_currentGroup->keys));
if (0 === api_strpos($keys, $this->_currentGroup->keys)) {
$keys = api_substr_replace($keys, '', 0, api_strlen($this->_currentGroup->keys));
}
}
} elseif (0 == strlen($ret->name)) {
} elseif (0 == api_strlen($ret->name)) {
$keys = '->{\'element_' . $this->_elementIdx . '\'}';
} else {
$keys = '->{\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret->name) . '\'}';
}
// for radios: add extra key from value
if ('radio' == $ret->type && '[]' != substr($keys, -2)) {
if ('radio' == $ret->type && '[]' != api_substr($keys, -2)) {
$keys .= '->{\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret->value) . '\'}';
}
$ret->keys = $keys;

@ -16,7 +16,7 @@
// | Authors: Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
// $Id: Range.php 6184 2005-09-07 10:08:17Z bmol $
// $Id: Range.php 20456 2009-05-10 17:27:44Z ivantcholakov $
require_once('HTML/QuickForm/Rule.php');
@ -36,7 +36,7 @@ class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule
*/
function validate($value, $options)
{
$length = strlen($value);
$length = api_strlen($value);
switch ($this->name) {
case 'minlength': return ($length >= $options);
case 'maxlength': return ($length <= $options);
@ -61,4 +61,4 @@ class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule
} // end func getValidationScript
} // end class HTML_QuickForm_Rule_Range
?>
?>

@ -18,7 +18,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
// $Id: date.php 15921 2008-08-05 22:53:45Z yannoo $
// $Id: date.php 20456 2009-05-10 17:27:44Z ivantcholakov $
require_once 'HTML/QuickForm/group.php';
require_once 'HTML/QuickForm/select.php';
@ -297,8 +297,9 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
$separator = '';
$locale =& $this->_locale[$this->_options['language']];
$backslash = false;
for ($i = 0, $length = strlen($this->_options['format']); $i < $length; $i++) {
$sign = $this->_options['format']{$i};
for ($i = 0, $length = api_strlen($this->_options['format']); $i < $length; $i++) {
//$sign = $this->_options['format']{$i};
$sign = api_get_character($this->_options['format'], $i);
if ($backslash) {
$backslash = false;
$separator .= $sign;
@ -493,4 +494,4 @@ class HTML_QuickForm_date extends HTML_QuickForm_group
// }}}
}
?>
?>

@ -17,7 +17,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
// $Id: element.php 9612 2006-10-20 11:56:44Z bmol $
// $Id: element.php 20456 2009-05-10 17:27:44Z ivantcholakov $
require_once('HTML/Common.php');
@ -226,7 +226,8 @@ class HTML_QuickForm_element extends HTML_Common
function getFrozenHtml()
{
$value = $this->getValue();
return ('' != $value? htmlspecialchars($value): '&nbsp;') .
global $charset;
return ('' != $value? htmlspecialchars($value, ENT_COMPAT, $charset): '&nbsp;') .
$this->_getPersistantData();
} //end func getFrozenHtml
@ -482,4 +483,4 @@ class HTML_QuickForm_element extends HTML_Common
// }}}
} // end class HTML_QuickForm_element
?>
?>

@ -17,7 +17,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
// $Id: group.php 6184 2005-09-07 10:08:17Z bmol $
// $Id: group.php 20456 2009-05-10 17:27:44Z ivantcholakov $
require_once("HTML/QuickForm/element.php");
@ -161,7 +161,7 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
} else {
$elementName = $this->_elements[$key]->getName();
$index = strlen($elementName) ? $elementName : $key;
$index = api_strlen($elementName) ? $elementName : $key;
if (is_array($value)) {
if (isset($value[$index])) {
$this->_elements[$key]->onQuickFormEvent('setGroupValue', $value[$index], $this);
@ -433,7 +433,7 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
if ($this->_appendName) {
$elementName = $element->getName();
if (isset($elementName)) {
$element->setName($name . '['. (strlen($elementName)? $elementName: $key) .']');
$element->setName($name . '['. (api_strlen($elementName)? $elementName: $key) .']');
} else {
$element->setName($name);
}
@ -576,4 +576,4 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
// }}}
} //end class HTML_QuickForm_group
?>
?>

@ -18,7 +18,7 @@
// | Alexey Borzov <avb@php.net>
// +----------------------------------------------------------------------+
//
// $Id: hierselect.php 9612 2006-10-20 11:56:44Z bmol $
// $Id: hierselect.php 20456 2009-05-10 17:27:44Z ivantcholakov $
require_once('HTML/QuickForm/group.php');
require_once('HTML/QuickForm/select.php');
@ -480,8 +480,8 @@ JAVASCRIPT;
// add onreset handler to form to properly reset hierselect (see bug #2970)
if ('addElement' == $event) {
$onReset = $caller->getAttribute('onreset');
if (strlen($onReset)) {
if (strpos($onReset, '_hs_setupOnReset')) {
if (api_strlen($onReset)) {
if (api_strpos($onReset, '_hs_setupOnReset')) {
$caller->updateAttributes(array('onreset' => str_replace('_hs_setupOnReset(this, [', "_hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "', ", $onReset)));
} else {
$caller->updateAttributes(array('onreset' => "var temp = function() { {$onReset} } ; if (!temp()) { return false; } ; if (typeof _hs_setupOnReset != 'undefined') { return _hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "']); } "));
@ -575,4 +575,4 @@ JAVASCRIPT;
// }}}
} // end class HTML_QuickForm_hierselect
?>
?>

@ -17,7 +17,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
// $Id: textarea.php 6184 2005-09-07 10:08:17Z bmol $
// $Id: textarea.php 20456 2009-05-10 17:27:44Z ivantcholakov $
require_once("HTML/QuickForm/element.php");
@ -187,10 +187,11 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
if ($this->_flagFrozen) {
return $this->getFrozenHtml();
} else {
global $charset;
return $this->_getTabs() .
'<textarea' . $this->_getAttrString($this->_attributes) . '>' .
// because we wrap the form later we don't want the text indented
preg_replace("/(\r\n|\n|\r)/", '&#010;', htmlspecialchars($this->_value)) .
preg_replace("/(\r\n|\n|\r)/", '&#010;', htmlspecialchars($this->_value, ENT_COMPAT, $charset)) .
'</textarea>';
}
} //end func toHtml
@ -207,7 +208,8 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
*/
function getFrozenHtml()
{
$value = htmlspecialchars($this->getValue());
global $charset;
$value = htmlspecialchars($this->getValue(), ENT_COMPAT, $charset);
if ($this->getAttribute('wrap') == 'off') {
$html = $this->_getTabs() . '<pre>' . $value."</pre>\n";
} else {

@ -33,7 +33,7 @@
* @author Richard Heyes <richard@phpguru.org>
* @copyright 2003-2006 Lorenzo Alberton, Richard Heyes
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
* @version CVS: $Id: Common.php 12273 2007-05-03 14:49:21Z elixir_julian $
* @version CVS: $Id: Common.php 20456 2009-05-10 17:27:44Z ivantcholakov $
* @link http://pear.php.net/package/Pager
*/
@ -845,6 +845,7 @@ class Pager_Common
*/
function _generateFormOnClickHelper($data, $prev = '')
{
global $charset;
$str = '';
if (is_array($data) || is_object($data)) {
// foreach key/visible member
@ -864,8 +865,9 @@ class Pager_Common
if (!$this->_isEncoded($escapedData)) {
$escapedData = urlencode($escapedData);
}
$escapedData = htmlentities($escapedData, ENT_QUOTES, 'UTF-8');
//$escapedData = htmlentities($escapedData, ENT_QUOTES, 'UTF-8');
$escapedData = api_htmlentities($escapedData, ENT_QUOTES, $charset);
$str .= 'input = document.createElement("input"); ';
$str .= 'input.type = "hidden"; ';
$str .= sprintf('input.name = "%s"; ', $prev);
@ -1292,6 +1294,7 @@ class Pager_Common
*/
function __http_build_query($array, $name)
{
global $charset;
$tmp = array ();
$separator = ini_get('arg_separator.output');
if ($separator == '&amp;') {
@ -1303,7 +1306,7 @@ class Pager_Common
array_push($tmp, $this->__http_build_query($value, $name.'%5B'.$key.'%5D'));
} elseif (is_scalar($value)) {
//array_push($tmp, sprintf('%s[%s]=%s', $name, htmlentities($key), htmlentities($value)));
array_push($tmp, $name.'%5B'.htmlentities($key).'%5D='.htmlentities($value));
array_push($tmp, $name.'%5B'.api_htmlentities($key, ENT_QUOTES, $charset).'%5D='.api_htmlentities($value, ENT_QUOTES, $charset));
} elseif (is_object($value)) {
//array_push($tmp, $this->__http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key)));
array_push($tmp, $this->__http_build_query(get_object_vars($value), $name.'%5B'.$key.'%5D'));
@ -1390,17 +1393,17 @@ class Pager_Common
if (strncasecmp($this->_fileName, 'javascript', 10) != 0) {
$this->_url .= '/';
}
if (!strstr($this->_fileName, '%d')) {
if (!api_strstr($this->_fileName, '%d')) {
trigger_error($this->errorMessage(ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);
}
}
$this->_classString = '';
if (strlen($this->_linkClass)) {
if (api_strlen($this->_linkClass)) {
$this->_classString = 'class="'.$this->_linkClass.'"';
}
if (strlen($this->_curPageLinkClassName)) {
if (api_strlen($this->_curPageLinkClassName)) {
$this->_curPageSpanPre = '<span class="'.$this->_curPageLinkClassName.'">';
$this->_curPageSpanPost = '</span>';
}
@ -1503,4 +1506,4 @@ class Pager_Common
// }}}
}
?>
?>

Loading…
Cancel
Save