forked from extern/egroupware
fix some PHP 5.6 Deprecated and IDE warnings
This commit is contained in:
parent
6b2c47a98e
commit
9df9b9b533
@ -190,7 +190,7 @@ class HTTP_WebDAV_Server
|
|||||||
*
|
*
|
||||||
* dispatch WebDAV HTTP request to the apropriate method handler
|
* dispatch WebDAV HTTP request to the apropriate method handler
|
||||||
*
|
*
|
||||||
* @param $prefix=null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php
|
* @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function ServeRequest($prefix=null)
|
function ServeRequest($prefix=null)
|
||||||
@ -213,18 +213,19 @@ class HTTP_WebDAV_Server
|
|||||||
// seem to pass '?' unencoded, so we need to extract the path info out
|
// seem to pass '?' unencoded, so we need to extract the path info out
|
||||||
// of the request URI ourselves
|
// of the request URI ourselves
|
||||||
// if request URI contains a full url, remove schema and domain
|
// if request URI contains a full url, remove schema and domain
|
||||||
|
$matches = null;
|
||||||
if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$this->_SERVER["REQUEST_URI"], $matches))
|
if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$this->_SERVER["REQUEST_URI"], $matches))
|
||||||
{
|
{
|
||||||
$path_info = $matches[1];
|
$path_info = $matches[1];
|
||||||
}
|
}
|
||||||
$path_info = substr($path_info, strlen($this->_SERVER["SCRIPT_NAME"]));
|
$path_info_raw = substr($path_info, strlen($this->_SERVER["SCRIPT_NAME"]));
|
||||||
|
|
||||||
// just in case the path came in empty ...
|
// just in case the path came in empty ...
|
||||||
if (empty($path_info)) {
|
if (empty($path_info_raw)) {
|
||||||
$path_info = "/";
|
$path_info_raw = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
$path_info = $this->_urldecode($path_info);
|
$path_info = self::_urldecode($path_info_raw);
|
||||||
|
|
||||||
if ($prefix && strpos($path_info, $prefix) === 0)
|
if ($prefix && strpos($path_info, $prefix) === 0)
|
||||||
{
|
{
|
||||||
@ -237,7 +238,7 @@ class HTTP_WebDAV_Server
|
|||||||
|
|
||||||
// set path
|
// set path
|
||||||
// $_SERVER['PATH_INFO'] is already urldecoded
|
// $_SERVER['PATH_INFO'] is already urldecoded
|
||||||
//$this->path = $this->_urldecode($path_info);
|
//$this->path = self::_urldecode($path_info);
|
||||||
// quote '#' (e.g. OpenOffice uses this for lock-files)
|
// quote '#' (e.g. OpenOffice uses this for lock-files)
|
||||||
$this->path = strtr($path_info,array(
|
$this->path = strtr($path_info,array(
|
||||||
'%' => '%25',
|
'%' => '%25',
|
||||||
@ -306,7 +307,6 @@ class HTTP_WebDAV_Server
|
|||||||
} else { // method not found/implemented
|
} else { // method not found/implemented
|
||||||
if ($this->_SERVER["REQUEST_METHOD"] == "LOCK") {
|
if ($this->_SERVER["REQUEST_METHOD"] == "LOCK") {
|
||||||
$error = '412 Precondition failed';
|
$error = '412 Precondition failed';
|
||||||
;
|
|
||||||
} else {
|
} else {
|
||||||
$error = '405 Method not allowed';
|
$error = '405 Method not allowed';
|
||||||
header("Allow: ".join(", ", $this->_allow())); // tell client what's allowed
|
header("Allow: ".join(", ", $this->_allow())); // tell client what's allowed
|
||||||
@ -650,7 +650,7 @@ class HTTP_WebDAV_Server
|
|||||||
/**
|
/**
|
||||||
* PROPFIND method handler
|
* PROPFIND method handler
|
||||||
*
|
*
|
||||||
* @param string $handler='PROPFIND' allows to use method eg. for CalDAV REPORT
|
* @param string $handler ='PROPFIND' allows to use method eg. for CalDAV REPORT
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function http_PROPFIND($handler='PROPFIND')
|
function http_PROPFIND($handler='PROPFIND')
|
||||||
@ -691,7 +691,7 @@ class HTTP_WebDAV_Server
|
|||||||
if (is_array($lock) && count($lock)) {
|
if (is_array($lock) && count($lock)) {
|
||||||
$created = isset($lock['created']) ? $lock['created'] : time();
|
$created = isset($lock['created']) ? $lock['created'] : time();
|
||||||
$modified = isset($lock['modified']) ? $lock['modified'] : time();
|
$modified = isset($lock['modified']) ? $lock['modified'] : time();
|
||||||
$files['files'][] = array("path" => $this->_slashify($this->path),
|
$files['files'][] = array("path" => self::_slashify($this->path),
|
||||||
"props" => array($this->mkprop("displayname", $this->path),
|
"props" => array($this->mkprop("displayname", $this->path),
|
||||||
$this->mkprop("creationdate", $created),
|
$this->mkprop("creationdate", $created),
|
||||||
$this->mkprop("getlastmodified", $modified),
|
$this->mkprop("getlastmodified", $modified),
|
||||||
@ -917,10 +917,10 @@ class HTTP_WebDAV_Server
|
|||||||
/* TODO right now the user implementation has to make sure
|
/* TODO right now the user implementation has to make sure
|
||||||
collections end in a slash, this should be done in here
|
collections end in a slash, this should be done in here
|
||||||
by checking the resource attribute */
|
by checking the resource attribute */
|
||||||
$href = $this->_mergePaths($this->base_uri, $path);
|
$href_raw = $this->_mergePaths($this->base_uri, $path);
|
||||||
|
|
||||||
/* minimal urlencoding is needed for the resource path */
|
/* minimal urlencoding is needed for the resource path */
|
||||||
$href = $this->_urlencode($href);
|
$href = $this->_urlencode($href_raw);
|
||||||
|
|
||||||
if ($this->crrnd)
|
if ($this->crrnd)
|
||||||
{
|
{
|
||||||
@ -1240,7 +1240,7 @@ class HTTP_WebDAV_Server
|
|||||||
* we can NOT send Content-Length headers, as the have to reflect size
|
* we can NOT send Content-Length headers, as the have to reflect size
|
||||||
* AFTER applying compression/transfer encoding.
|
* AFTER applying compression/transfer encoding.
|
||||||
*
|
*
|
||||||
* @param boolean $set=null
|
* @param boolean $set =null
|
||||||
* @return boolean true if we use compression, false otherwise
|
* @return boolean true if we use compression, false otherwise
|
||||||
*/
|
*/
|
||||||
public static function use_compression($set=null)
|
public static function use_compression($set=null)
|
||||||
@ -1322,7 +1322,7 @@ class HTTP_WebDAV_Server
|
|||||||
. (isset($options['size']) ? $options['size'] : "*"));
|
. (isset($options['size']) ? $options['size'] : "*"));
|
||||||
while ($size && !feof($options['stream'])) {
|
while ($size && !feof($options['stream'])) {
|
||||||
$buffer = fread($options['stream'], 4096);
|
$buffer = fread($options['stream'], 4096);
|
||||||
$size -= $this->bytes($buffer);
|
$size -= self::bytes($buffer);
|
||||||
echo $buffer;
|
echo $buffer;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1358,7 +1358,7 @@ class HTTP_WebDAV_Server
|
|||||||
fseek($options['stream'], $from, SEEK_SET);
|
fseek($options['stream'], $from, SEEK_SET);
|
||||||
while ($size && !feof($options['stream'])) {
|
while ($size && !feof($options['stream'])) {
|
||||||
$buffer = fread($options['stream'], 4096);
|
$buffer = fread($options['stream'], 4096);
|
||||||
$size -= $this->bytes($buffer);
|
$size -= self::bytes($buffer);
|
||||||
echo $buffer;
|
echo $buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1376,7 +1376,7 @@ class HTTP_WebDAV_Server
|
|||||||
if (is_array($options['data'])) {
|
if (is_array($options['data'])) {
|
||||||
// reply to partial request
|
// reply to partial request
|
||||||
} else {
|
} else {
|
||||||
if (!self::use_compression()) header("Content-Length: ".$this->bytes($options['data']));
|
if (!self::use_compression()) header("Content-Length: ".self::bytes($options['data']));
|
||||||
echo $options['data'];
|
echo $options['data'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1406,6 +1406,7 @@ class HTTP_WebDAV_Server
|
|||||||
if (isset($this->_SERVER['HTTP_RANGE'])) {
|
if (isset($this->_SERVER['HTTP_RANGE'])) {
|
||||||
|
|
||||||
// we only support standard "bytes" range specifications for now
|
// we only support standard "bytes" range specifications for now
|
||||||
|
$matches = null;
|
||||||
if (preg_match('/bytes\s*=\s*(.+)/', $this->_SERVER['HTTP_RANGE'], $matches)) {
|
if (preg_match('/bytes\s*=\s*(.+)/', $this->_SERVER['HTTP_RANGE'], $matches)) {
|
||||||
$options["ranges"] = array();
|
$options["ranges"] = array();
|
||||||
|
|
||||||
@ -1613,6 +1614,7 @@ class HTTP_WebDAV_Server
|
|||||||
// single byte range requests are supported
|
// single byte range requests are supported
|
||||||
// the header format is also specified in RFC 2616 14.16
|
// the header format is also specified in RFC 2616 14.16
|
||||||
// TODO we have to ensure that implementations support this or send 501 instead
|
// TODO we have to ensure that implementations support this or send 501 instead
|
||||||
|
$matches = null;
|
||||||
if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
|
if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
|
||||||
$this->http_status('400 bad request');
|
$this->http_status('400 bad request');
|
||||||
echo 'The service does only support single byte ranges';
|
echo 'The service does only support single byte ranges';
|
||||||
@ -1623,7 +1625,7 @@ class HTTP_WebDAV_Server
|
|||||||
if (is_numeric($matches[3])) {
|
if (is_numeric($matches[3])) {
|
||||||
$range['total_length'] = $matches[3];
|
$range['total_length'] = $matches[3];
|
||||||
}
|
}
|
||||||
$option['ranges'][] = $range;
|
$options['ranges'][] = $range;
|
||||||
|
|
||||||
// TODO make sure the implementation supports partial POST
|
// TODO make sure the implementation supports partial POST
|
||||||
// this has to be done in advance to avoid data being overwritten
|
// this has to be done in advance to avoid data being overwritten
|
||||||
@ -1792,6 +1794,7 @@ class HTTP_WebDAV_Server
|
|||||||
// single byte range requests are supported
|
// single byte range requests are supported
|
||||||
// the header format is also specified in RFC 2616 14.16
|
// the header format is also specified in RFC 2616 14.16
|
||||||
// TODO we have to ensure that implementations support this or send 501 instead
|
// TODO we have to ensure that implementations support this or send 501 instead
|
||||||
|
$matches = null;
|
||||||
if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
|
if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
|
||||||
$this->http_status("400 bad request");
|
$this->http_status("400 bad request");
|
||||||
echo "The service does only support single byte ranges";
|
echo "The service does only support single byte ranges";
|
||||||
@ -2156,7 +2159,7 @@ class HTTP_WebDAV_Server
|
|||||||
}
|
}
|
||||||
$content .= '</'.($this->crrnd?'':'D:')."error>\n";
|
$content .= '</'.($this->crrnd?'':'D:')."error>\n";
|
||||||
}
|
}
|
||||||
if (!self::use_compression()) header("Content-Length: ".$this->bytes($content));
|
if (!self::use_compression()) header("Content-Length: ".self::bytes($content));
|
||||||
if ($content) echo $options['content'];
|
if ($content) echo $options['content'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2189,7 +2192,7 @@ class HTTP_WebDAV_Server
|
|||||||
$http_host.= ":".$url["port"];
|
$http_host.= ":".$url["port"];
|
||||||
} else {
|
} else {
|
||||||
// only path given, set host to self
|
// only path given, set host to self
|
||||||
$http_host == $http_header_host;
|
$http_host = $http_header_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($http_host == $http_header_host &&
|
if ($http_host == $http_header_host &&
|
||||||
@ -2267,7 +2270,7 @@ class HTTP_WebDAV_Server
|
|||||||
* @praram boolen property raw-flag
|
* @praram boolen property raw-flag
|
||||||
* @return array property array
|
* @return array property array
|
||||||
*/
|
*/
|
||||||
function mkprop()
|
public static function mkprop()
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
switch (count($args)) {
|
switch (count($args)) {
|
||||||
@ -2323,7 +2326,7 @@ class HTTP_WebDAV_Server
|
|||||||
* @param void
|
* @param void
|
||||||
* @return string a new UUID
|
* @return string a new UUID
|
||||||
*/
|
*/
|
||||||
function _new_uuid()
|
public static function _new_uuid()
|
||||||
{
|
{
|
||||||
// use uuid extension from PECL if available
|
// use uuid extension from PECL if available
|
||||||
if (function_exists("uuid_create")) {
|
if (function_exists("uuid_create")) {
|
||||||
@ -2353,9 +2356,9 @@ class HTTP_WebDAV_Server
|
|||||||
* @param void
|
* @param void
|
||||||
* @return string new RFC2518 opaque lock token
|
* @return string new RFC2518 opaque lock token
|
||||||
*/
|
*/
|
||||||
function _new_locktoken()
|
public static function _new_locktoken()
|
||||||
{
|
{
|
||||||
return "opaquelocktoken:".HTTP_WebDAV_Server::_new_uuid();
|
return "opaquelocktoken:".self::_new_uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -2558,6 +2561,7 @@ class HTTP_WebDAV_Server
|
|||||||
*/
|
*/
|
||||||
function _check_uri_condition($uri, $condition)
|
function _check_uri_condition($uri, $condition)
|
||||||
{
|
{
|
||||||
|
unset($uri); // not used, but required by function signature
|
||||||
// not really implemented here,
|
// not really implemented here,
|
||||||
// implementations must override
|
// implementations must override
|
||||||
|
|
||||||
@ -2694,7 +2698,7 @@ class HTTP_WebDAV_Server
|
|||||||
* @param string URL to encode
|
* @param string URL to encode
|
||||||
* @return string encoded URL
|
* @return string encoded URL
|
||||||
*/
|
*/
|
||||||
function _urlencode($url)
|
public static function _urlencode($url)
|
||||||
{
|
{
|
||||||
// cadaver (and probably all neon using agents) need a more complete url encoding
|
// cadaver (and probably all neon using agents) need a more complete url encoding
|
||||||
// otherwise special chars like "$,()'" in filenames do NOT work
|
// otherwise special chars like "$,()'" in filenames do NOT work
|
||||||
@ -2724,7 +2728,7 @@ class HTTP_WebDAV_Server
|
|||||||
* @param string URL to decode
|
* @param string URL to decode
|
||||||
* @return string decoded URL
|
* @return string decoded URL
|
||||||
*/
|
*/
|
||||||
function _urldecode($path)
|
public static function _urldecode($path)
|
||||||
{
|
{
|
||||||
return rawurldecode($path);
|
return rawurldecode($path);
|
||||||
}
|
}
|
||||||
@ -2850,10 +2854,10 @@ class HTTP_WebDAV_Server
|
|||||||
* @param string directory path
|
* @param string directory path
|
||||||
* @returns string directory path wiht trailing slash
|
* @returns string directory path wiht trailing slash
|
||||||
*/
|
*/
|
||||||
function _slashify($path)
|
public static function _slashify($path)
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__." called with $path");
|
//error_log(__METHOD__." called with $path");
|
||||||
if ($path[$this->bytes($path)-1] != '/') {
|
if ($path[self::bytes($path)-1] != '/') {
|
||||||
//error_log(__METHOD__." added slash at the end of path");
|
//error_log(__METHOD__." added slash at the end of path");
|
||||||
$path = $path."/";
|
$path = $path."/";
|
||||||
}
|
}
|
||||||
@ -2866,10 +2870,10 @@ class HTTP_WebDAV_Server
|
|||||||
* @param string directory path
|
* @param string directory path
|
||||||
* @returns string directory path wihtout trailing slash
|
* @returns string directory path wihtout trailing slash
|
||||||
*/
|
*/
|
||||||
function _unslashify($path)
|
public static function _unslashify($path)
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__." called with $path");
|
//error_log(__METHOD__." called with $path");
|
||||||
if ($path[$this->bytes($path)-1] == '/') {
|
if ($path[self::bytes($path)-1] == '/') {
|
||||||
$path = substr($path, 0, -1);
|
$path = substr($path, 0, -1);
|
||||||
//error_log(__METHOD__." removed slash at the end of path");
|
//error_log(__METHOD__." removed slash at the end of path");
|
||||||
}
|
}
|
||||||
@ -2883,14 +2887,14 @@ class HTTP_WebDAV_Server
|
|||||||
* @param string child path
|
* @param string child path
|
||||||
* @return string merged path
|
* @return string merged path
|
||||||
*/
|
*/
|
||||||
function _mergePaths($parent, $child)
|
public static function _mergePaths($parent, $child)
|
||||||
{
|
{
|
||||||
//error_log("merge called :\n$parent \n$child\n" . function_backtrace());
|
//error_log("merge called :\n$parent \n$child\n" . function_backtrace());
|
||||||
//error_log("merge :\n".print_r($this->_mergePaths($this->_SERVER["SCRIPT_NAME"], $this->path)true));
|
//error_log("merge :\n".print_r($this->_mergePaths($this->_SERVER["SCRIPT_NAME"], $this->path)true));
|
||||||
if ($child{0} == '/') {
|
if ($child{0} == '/') {
|
||||||
return $this->_unslashify($parent).$child;
|
return self::_unslashify($parent).$child;
|
||||||
} else {
|
} else {
|
||||||
return $this->_slashify($parent).$child;
|
return self::_slashify($parent).$child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2900,9 +2904,9 @@ class HTTP_WebDAV_Server
|
|||||||
* @param string $str
|
* @param string $str
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function bytes($str)
|
public static function bytes($str)
|
||||||
{
|
{
|
||||||
static $func_overload;
|
static $func_overload=null;
|
||||||
|
|
||||||
if (is_null($func_overload))
|
if (is_null($func_overload))
|
||||||
{
|
{
|
||||||
@ -2918,4 +2922,3 @@ class HTTP_WebDAV_Server
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
?>
|
|
||||||
|
@ -28,7 +28,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @see Util::extensionExists()
|
* @see Util::extensionExists()
|
||||||
*/
|
*/
|
||||||
function extensionExists($ext)
|
public static function extensionExists($ext)
|
||||||
{
|
{
|
||||||
static $cache = array();
|
static $cache = array();
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @param string $charset The charset to use as the default one.
|
* @param string $charset The charset to use as the default one.
|
||||||
*/
|
*/
|
||||||
function setDefaultCharset($charset)
|
public static function setDefaultCharset($charset)
|
||||||
{
|
{
|
||||||
$GLOBALS['_HORDE_STRING_CHARSET'] = $charset;
|
$GLOBALS['_HORDE_STRING_CHARSET'] = $charset;
|
||||||
if (String::extensionExists('mbstring') &&
|
if (String::extensionExists('mbstring') &&
|
||||||
@ -73,7 +73,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return mixed The converted input data.
|
* @return mixed The converted input data.
|
||||||
*/
|
*/
|
||||||
function convertCharset($input, $from, $to = null)
|
public static function convertCharset($input, $from, $to = null)
|
||||||
{
|
{
|
||||||
/* Don't bother converting numbers. */
|
/* Don't bother converting numbers. */
|
||||||
if (is_numeric($input)) {
|
if (is_numeric($input)) {
|
||||||
@ -127,7 +127,7 @@ class String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal function used to do charset conversion.
|
* Internal public static function used to do charset conversion.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*
|
*
|
||||||
@ -137,7 +137,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string The converted string.
|
* @return string The converted string.
|
||||||
*/
|
*/
|
||||||
function _convertCharset($input, $from, $to)
|
public static function _convertCharset($input, $from, $to)
|
||||||
{
|
{
|
||||||
$output = '';
|
$output = '';
|
||||||
$from_check = (($from == 'iso-8859-1') || ($from == 'us-ascii'));
|
$from_check = (($from == 'iso-8859-1') || ($from == 'us-ascii'));
|
||||||
@ -145,7 +145,7 @@ class String {
|
|||||||
|
|
||||||
/* Use utf8_[en|de]code() if possible and if the string isn't too
|
/* Use utf8_[en|de]code() if possible and if the string isn't too
|
||||||
* large (less than 16 MB = 16 * 1024 * 1024 = 16777216 bytes) - these
|
* large (less than 16 MB = 16 * 1024 * 1024 = 16777216 bytes) - these
|
||||||
* functions use more memory. */
|
* public static functions use more memory. */
|
||||||
if (strlen($input) < 16777216 || !(String::extensionExists('iconv') || String::extensionExists('mbstring'))) {
|
if (strlen($input) < 16777216 || !(String::extensionExists('iconv') || String::extensionExists('mbstring'))) {
|
||||||
if ($from_check && ($to == 'utf-8')) {
|
if ($from_check && ($to == 'utf-8')) {
|
||||||
return utf8_encode($input);
|
return utf8_encode($input);
|
||||||
@ -201,7 +201,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string The string with lowercase characters
|
* @return string The string with lowercase characters
|
||||||
*/
|
*/
|
||||||
function lower($string, $locale = false, $charset = null)
|
public static function lower($string, $locale = false, $charset = null)
|
||||||
{
|
{
|
||||||
static $lowers;
|
static $lowers;
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string The string with uppercase characters
|
* @return string The string with uppercase characters
|
||||||
*/
|
*/
|
||||||
function upper($string, $locale = false, $charset = null)
|
public static function upper($string, $locale = false, $charset = null)
|
||||||
{
|
{
|
||||||
static $uppers;
|
static $uppers;
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string The capitalized string.
|
* @return string The capitalized string.
|
||||||
*/
|
*/
|
||||||
function ucfirst($string, $locale = false, $charset = null)
|
public static function ucfirst($string, $locale = false, $charset = null)
|
||||||
{
|
{
|
||||||
if ($locale) {
|
if ($locale) {
|
||||||
$first = String::substr($string, 0, 1, $charset);
|
$first = String::substr($string, 0, 1, $charset);
|
||||||
@ -316,7 +316,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string The string's part.
|
* @return string The string's part.
|
||||||
*/
|
*/
|
||||||
function substr($string, $start, $length = null, $charset = null)
|
public static function substr($string, $start, $length = null, $charset = null)
|
||||||
{
|
{
|
||||||
if (is_null($length)) {
|
if (is_null($length)) {
|
||||||
$length = String::length($string, $charset) - $start;
|
$length = String::length($string, $charset) - $start;
|
||||||
@ -367,7 +367,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string The string's part.
|
* @return string The string's part.
|
||||||
*/
|
*/
|
||||||
function length($string, $charset = null)
|
public static function length($string, $charset = null)
|
||||||
{
|
{
|
||||||
if (is_null($charset)) {
|
if (is_null($charset)) {
|
||||||
$charset = $GLOBALS['_HORDE_STRING_CHARSET'];
|
$charset = $GLOBALS['_HORDE_STRING_CHARSET'];
|
||||||
@ -400,7 +400,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return integer The position of first occurrence.
|
* @return integer The position of first occurrence.
|
||||||
*/
|
*/
|
||||||
function pos($haystack, $needle, $offset = 0, $charset = null)
|
public static function pos($haystack, $needle, $offset = 0, $charset = null)
|
||||||
{
|
{
|
||||||
if (String::extensionExists('mbstring')) {
|
if (String::extensionExists('mbstring')) {
|
||||||
if (is_null($charset)) {
|
if (is_null($charset)) {
|
||||||
@ -434,7 +434,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string The padded string.
|
* @return string The padded string.
|
||||||
*/
|
*/
|
||||||
function pad($input, $length, $pad = ' ', $type = STR_PAD_RIGHT,
|
public static function pad($input, $length, $pad = ' ', $type = STR_PAD_RIGHT,
|
||||||
$charset = null)
|
$charset = null)
|
||||||
{
|
{
|
||||||
$mb_length = String::length($input, $charset);
|
$mb_length = String::length($input, $charset);
|
||||||
@ -491,7 +491,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string String containing the wrapped text.
|
* @return string String containing the wrapped text.
|
||||||
*/
|
*/
|
||||||
function wordwrap($string, $width = 75, $break = "\n", $cut = false,
|
public static function wordwrap($string, $width = 75, $break = "\n", $cut = false,
|
||||||
$charset = null, $line_folding = false)
|
$charset = null, $line_folding = false)
|
||||||
{
|
{
|
||||||
/* Get the user's default character set if none passed in. */
|
/* Get the user's default character set if none passed in. */
|
||||||
@ -560,7 +560,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return string String containing the wrapped text.
|
* @return string String containing the wrapped text.
|
||||||
*/
|
*/
|
||||||
function wrap($text, $length = 80, $break_char = "\n", $charset = null,
|
public static function wrap($text, $length = 80, $break_char = "\n", $charset = null,
|
||||||
$quote = false)
|
$quote = false)
|
||||||
{
|
{
|
||||||
$paragraphs = array();
|
$paragraphs = array();
|
||||||
@ -593,7 +593,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return boolean True if the parameter was alphabetic only.
|
* @return boolean True if the parameter was alphabetic only.
|
||||||
*/
|
*/
|
||||||
function isAlpha($string, $charset = null)
|
public static function isAlpha($string, $charset = null)
|
||||||
{
|
{
|
||||||
if (!String::extensionExists('mbstring')) {
|
if (!String::extensionExists('mbstring')) {
|
||||||
return ctype_alpha($string);
|
return ctype_alpha($string);
|
||||||
@ -625,7 +625,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return boolean True if the parameter was lowercase.
|
* @return boolean True if the parameter was lowercase.
|
||||||
*/
|
*/
|
||||||
function isLower($string, $charset = null)
|
public static function isLower($string, $charset = null)
|
||||||
{
|
{
|
||||||
return ((String::lower($string, true, $charset) === $string) &&
|
return ((String::lower($string, true, $charset) === $string) &&
|
||||||
String::isAlpha($string, $charset));
|
String::isAlpha($string, $charset));
|
||||||
@ -640,7 +640,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return boolean True if the parameter was uppercase.
|
* @return boolean True if the parameter was uppercase.
|
||||||
*/
|
*/
|
||||||
function isUpper($string, $charset = null)
|
public static function isUpper($string, $charset = null)
|
||||||
{
|
{
|
||||||
return ((String::upper($string, true, $charset) === $string) &&
|
return ((String::upper($string, true, $charset) === $string) &&
|
||||||
String::isAlpha($string, $charset));
|
String::isAlpha($string, $charset));
|
||||||
@ -658,7 +658,7 @@ class String {
|
|||||||
*
|
*
|
||||||
* @return array The matches array from the first regex that matches.
|
* @return array The matches array from the first regex that matches.
|
||||||
*/
|
*/
|
||||||
function regexMatch($text, $regex, $charset = null)
|
public static function regexMatch($text, $regex, $charset = null)
|
||||||
{
|
{
|
||||||
if (!empty($charset)) {
|
if (!empty($charset)) {
|
||||||
$regex = String::convertCharset($regex, $charset, 'utf-8');
|
$regex = String::convertCharset($regex, $charset, 'utf-8');
|
||||||
@ -680,17 +680,17 @@ class String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workaround charsets that don't work with mbstring functions.
|
* Workaround charsets that don't work with mbstring public static functions.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*
|
*
|
||||||
* @param string $charset The original charset.
|
* @param string $charset The original charset.
|
||||||
*
|
*
|
||||||
* @return string The charset to use with mbstring functions.
|
* @return string The charset to use with mbstring public static functions.
|
||||||
*/
|
*/
|
||||||
function _mbstringCharset($charset)
|
public static function _mbstringCharset($charset)
|
||||||
{
|
{
|
||||||
/* mbstring functions do not handle the 'ks_c_5601-1987' &
|
/* mbstring public static functions do not handle the 'ks_c_5601-1987' &
|
||||||
* 'ks_c_5601-1989' charsets. However, these charsets are used, for
|
* 'ks_c_5601-1989' charsets. However, these charsets are used, for
|
||||||
* example, by various versions of Outlook to send Korean characters.
|
* example, by various versions of Outlook to send Korean characters.
|
||||||
* Use UHC (CP949) encoding instead. See, e.g.,
|
* Use UHC (CP949) encoding instead. See, e.g.,
|
||||||
|
Loading…
Reference in New Issue
Block a user