forked from extern/egroupware
enhance server-side mobile browser detection (windows phone, blackberry, kindle, ...) and fix IDE warnings
This commit is contained in:
parent
3e6a7a7ba4
commit
1d668d5a10
@ -6,7 +6,7 @@
|
|||||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> complete rewrite in 6/2006 and earlier modifications
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> complete rewrite in 6/2006 and earlier modifications
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
* @author RalfBecker-AT-outdoor-training.de
|
* @author RalfBecker-AT-outdoor-training.de
|
||||||
* @copyright 2001-2009 by RalfBecker@outdoor-training.de
|
* @copyright 2001-2014 by RalfBecker@outdoor-training.de
|
||||||
* @package api
|
* @package api
|
||||||
* @subpackage html
|
* @subpackage html
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
@ -25,8 +25,8 @@ class html
|
|||||||
*/
|
*/
|
||||||
static $user_agent;
|
static $user_agent;
|
||||||
/**
|
/**
|
||||||
* User agent is a mobile browser
|
* User agent is mobile browser: "iphone", "ipod", "ipad", "android", "symbianos", "blackberry", "kindle", "opera mobi", "windows phone"
|
||||||
* @var boolean
|
* @var string with name of mobile browser or null, if not mobile browser
|
||||||
*/
|
*/
|
||||||
static $ua_mobile;
|
static $ua_mobile;
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,8 @@ class html
|
|||||||
self::$ua_version = preg_match('|Trident/[0-9.]+; rv:([0-9.]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) ?
|
self::$ua_version = preg_match('|Trident/[0-9.]+; rv:([0-9.]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) ?
|
||||||
$matches[1] : 11.0;
|
$matches[1] : 11.0;
|
||||||
}
|
}
|
||||||
self::$ua_mobile = preg_match('/(iPhone|iPad|Android|SymbianOS)/i',$_SERVER['HTTP_USER_AGENT']);
|
self::$ua_mobile = preg_match('/(iPhone|iPod|iPad|Android|SymbianOS|Blackberry|Kindle|Opera Mobi|Windows Phone)/i',
|
||||||
|
$_SERVER['HTTP_USER_AGENT'], $matches) ? strtolower($matches[1]) : null;
|
||||||
|
|
||||||
self::$netscape4 = self::$user_agent == 'mozilla' && self::$ua_version < 5;
|
self::$netscape4 = self::$user_agent == 'mozilla' && self::$ua_version < 5;
|
||||||
self::$prefered_img_title = self::$netscape4 ? 'alt' : 'title';
|
self::$prefered_img_title = self::$netscape4 ? 'alt' : 'title';
|
||||||
@ -233,7 +234,7 @@ class html
|
|||||||
* allows to show and select one item from an array
|
* allows to show and select one item from an array
|
||||||
*
|
*
|
||||||
* @param string $name string with name of the submitted var which holds the key of the selected item form array
|
* @param string $name string with name of the submitted var which holds the key of the selected item form array
|
||||||
* @param string/array $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
|
* @param string|array $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
|
||||||
* @param array $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
|
* @param array $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
|
||||||
* @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang()
|
* @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang()
|
||||||
* @param string $options additional options (e.g. 'width')
|
* @param string $options additional options (e.g. 'width')
|
||||||
@ -321,7 +322,7 @@ class html
|
|||||||
* in the same way. Therefor I made it an extra function.
|
* in the same way. Therefor I made it an extra function.
|
||||||
*
|
*
|
||||||
* @param string $name string with name of the submitted var which holds the key of the selected item form array
|
* @param string $name string with name of the submitted var which holds the key of the selected item form array
|
||||||
* @param string/array $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
|
* @param string|array $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
|
||||||
* @param array $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
|
* @param array $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
|
||||||
* @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang()
|
* @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang()
|
||||||
* @param string $options additional options (e.g. 'width')
|
* @param string $options additional options (e.g. 'width')
|
||||||
@ -451,7 +452,7 @@ class html
|
|||||||
/**
|
/**
|
||||||
* generate one or more hidden input tag(s)
|
* generate one or more hidden input tag(s)
|
||||||
*
|
*
|
||||||
* @param array/string $vars var-name or array with name / value pairs
|
* @param array|string $vars var-name or array with name / value pairs
|
||||||
* @param string $value value if $vars is no array, default ''
|
* @param string $value value if $vars is no array, default ''
|
||||||
* @param boolean $ignore_empty if true all empty, zero (!) or unset values, plus filer=none
|
* @param boolean $ignore_empty if true all empty, zero (!) or unset values, plus filer=none
|
||||||
* @param string html
|
* @param string html
|
||||||
@ -780,24 +781,24 @@ egw_LAB.wait(function() {
|
|||||||
* Example link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123))
|
* Example link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123))
|
||||||
* gives 'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
|
* gives 'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
|
||||||
*
|
*
|
||||||
* @param string $url phpgw-relative link, may include query / get-vars
|
* @param string $_url egw-relative link, may include query / get-vars
|
||||||
* @param array/string $vars query or array ('name' => 'value', ...) with query
|
* @param array|string $vars query or array ('name' => 'value', ...) with query
|
||||||
* @return string absolut link already run through $phpgw->link
|
* @return string absolut link already run through $phpgw->link
|
||||||
*/
|
*/
|
||||||
static function link($url,$vars='')
|
static function link($_url,$vars='')
|
||||||
{
|
{
|
||||||
//echo "<p>html::link(url='$url',vars='"; print_r($vars); echo "')</p>\n";
|
//echo "<p>html::link(url='$url',vars='"; print_r($vars); echo "')</p>\n";
|
||||||
if (!is_array($vars))
|
if (!is_array($vars))
|
||||||
{
|
{
|
||||||
parse_str($vars,$vars);
|
parse_str($vars,$vars);
|
||||||
}
|
}
|
||||||
list($url,$v) = explode('?',$url); // url may contain additional vars
|
list($url,$v) = explode('?', $_url); // url may contain additional vars
|
||||||
if ($v)
|
if ($v)
|
||||||
{
|
{
|
||||||
parse_str($v,$v);
|
parse_str($v,$v);
|
||||||
$vars += $v;
|
$vars += $v;
|
||||||
}
|
}
|
||||||
return $GLOBALS['egw']->link($url,$vars);
|
return egw::link($url,$vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -819,16 +820,16 @@ egw_LAB.wait(function() {
|
|||||||
*
|
*
|
||||||
* @param string $content of the form, if '' only the opening tag gets returned
|
* @param string $content of the form, if '' only the opening tag gets returned
|
||||||
* @param array $hidden_vars array with name-value pairs for hidden input fields
|
* @param array $hidden_vars array with name-value pairs for hidden input fields
|
||||||
* @param string $url eGW relative URL, will be run through the link function, if empty the current url is used
|
* @param string $_url eGW relative URL, will be run through the link function, if empty the current url is used
|
||||||
* @param string/array $url_vars parameters for the URL, send to link static function too
|
* @param string|array $url_vars parameters for the URL, send to link static function too
|
||||||
* @param string $name name of the form, defaul ''=none
|
* @param string $name name of the form, defaul ''=none
|
||||||
* @param string $options attributes for the tag, default ''=none
|
* @param string $options attributes for the tag, default ''=none
|
||||||
* @param string $method method of the form, default 'POST'
|
* @param string $method method of the form, default 'POST'
|
||||||
* @return string html
|
* @return string html
|
||||||
*/
|
*/
|
||||||
static function form($content,$hidden_vars,$url,$url_vars='',$name='',$options='',$method='POST')
|
static function form($content,$hidden_vars,$_url,$url_vars='',$name='',$options='',$method='POST')
|
||||||
{
|
{
|
||||||
$url = $url ? self::link($url,$url_vars) : $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
|
$url = $_url ? self::link($_url, $url_vars) : $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
|
||||||
$html = "<form method=\"$method\" ".($name != '' ? "name=\"$name\" " : '')."action=\"$url\" $options>\n";
|
$html = "<form method=\"$method\" ".($name != '' ? "name=\"$name\" " : '')."action=\"$url\" $options>\n";
|
||||||
$html .= self::input_hidden($hidden_vars);
|
$html .= self::input_hidden($hidden_vars);
|
||||||
|
|
||||||
@ -847,7 +848,7 @@ egw_LAB.wait(function() {
|
|||||||
* @param string $label label of the button
|
* @param string $label label of the button
|
||||||
* @param array $hidden_vars array with name-value pairs for hidden input fields
|
* @param array $hidden_vars array with name-value pairs for hidden input fields
|
||||||
* @param string $url eGW relative URL, will be run through the link function
|
* @param string $url eGW relative URL, will be run through the link function
|
||||||
* @param string/array $url_vars parameters for the URL, send to link static function too
|
* @param string|array $url_vars parameters for the URL, send to link static function too
|
||||||
* @param string $options attributes for the tag, default ''=none
|
* @param string $options attributes for the tag, default ''=none
|
||||||
* @param string $form_name name of the form, defaul ''=none
|
* @param string $form_name name of the form, defaul ''=none
|
||||||
* @param string $method method of the form, default 'POST'
|
* @param string $method method of the form, default 'POST'
|
||||||
@ -964,21 +965,21 @@ egw_LAB.wait(function() {
|
|||||||
/**
|
/**
|
||||||
* html-widget showing progessbar with a view div's (html4 only, textual percentage otherwise)
|
* html-widget showing progessbar with a view div's (html4 only, textual percentage otherwise)
|
||||||
*
|
*
|
||||||
* @param mixed $percent percent-value, gets casted to int
|
* @param mixed $_percent percent-value, gets casted to int
|
||||||
* @param string $title title for the progressbar, default ''=the percentage itself
|
* @param string $_title title for the progressbar, default ''=the percentage itself
|
||||||
* @param string $options attributes for the outmost div (may include onclick="...")
|
* @param string $options attributes for the outmost div (may include onclick="...")
|
||||||
* @param string $width width, default 30px
|
* @param string $width width, default 30px
|
||||||
* @param string $color color, default '#D00000' (dark red)
|
* @param string $color color, default '#D00000' (dark red)
|
||||||
* @param string $height height, default 5px
|
* @param string $height height, default 5px
|
||||||
* @return string html
|
* @return string html
|
||||||
*/
|
*/
|
||||||
static function progressbar( $percent,$title='',$options='',$width='',$color='',$height='' )
|
static function progressbar($_percent, $_title='',$options='',$width='',$color='',$height='' )
|
||||||
{
|
{
|
||||||
$percent = (int) $percent;
|
$percent = (int)$_percent;
|
||||||
if (!$width) $width = '30px';
|
if (!$width) $width = '30px';
|
||||||
if (!$height)$height= '5px';
|
if (!$height)$height= '5px';
|
||||||
if (!$color) $color = '#D00000';
|
if (!$color) $color = '#D00000';
|
||||||
$title = $title ? self::htmlspecialchars($title) : $percent.'%';
|
$title = $_title ? self::htmlspecialchars($_title) : $percent.'%';
|
||||||
|
|
||||||
if (self::$netscape4)
|
if (self::$netscape4)
|
||||||
{
|
{
|
||||||
@ -999,7 +1000,7 @@ egw_LAB.wait(function() {
|
|||||||
* This way session-information gets passed, eg. $name=array('menuaction'=>'myapp.class.image','id'=>123).
|
* This way session-information gets passed, eg. $name=array('menuaction'=>'myapp.class.image','id'=>123).
|
||||||
*
|
*
|
||||||
* @param string $app app-name to search the image
|
* @param string $app app-name to search the image
|
||||||
* @param string/array $name image-name or URL (incl. vfs:/) or array with get-vars
|
* @param string|array $name image-name or URL (incl. vfs:/) or array with get-vars
|
||||||
* @param string $title tooltip, default '' = none
|
* @param string $title tooltip, default '' = none
|
||||||
* @param string $options further options for the tag, default '' = none
|
* @param string $options further options for the tag, default '' = none
|
||||||
* @return string the html
|
* @return string the html
|
||||||
@ -1075,7 +1076,7 @@ egw_LAB.wait(function() {
|
|||||||
*
|
*
|
||||||
* @param string $content of the link, if '' only the opening tag gets returned
|
* @param string $content of the link, if '' only the opening tag gets returned
|
||||||
* @param string $url eGW relative URL, will be run through the link function
|
* @param string $url eGW relative URL, will be run through the link function
|
||||||
* @param string/array $vars parameters for the URL, send to link static function too
|
* @param string|array $vars parameters for the URL, send to link static function too
|
||||||
* @param string $options attributes for the tag, default ''=none
|
* @param string $options attributes for the tag, default ''=none
|
||||||
* @return string the html
|
* @return string the html
|
||||||
*/
|
*/
|
||||||
@ -1249,7 +1250,7 @@ egw_LAB.wait(function() {
|
|||||||
* @param string $_selected path of selected folder
|
* @param string $_selected path of selected folder
|
||||||
* @param mixed $_topFolder =false node of topFolder or false for none
|
* @param mixed $_topFolder =false node of topFolder or false for none
|
||||||
* @param string $_onNodeSelect ='alert' js static function to call if node gets selected
|
* @param string $_onNodeSelect ='alert' js static function to call if node gets selected
|
||||||
* @param string $_tree='foldertree' id of the div and name of the variable containing the tree object
|
* @param string $tree ='foldertree' id of the div and name of the variable containing the tree object
|
||||||
* @param string $_divClass ='' css class of the div
|
* @param string $_divClass ='' css class of the div
|
||||||
* @param string $_leafImage ='' default image of a leaf-node, ''=default of foldertree, set it eg. 'folderClosed.gif' to show leafs as folders
|
* @param string $_leafImage ='' default image of a leaf-node, ''=default of foldertree, set it eg. 'folderClosed.gif' to show leafs as folders
|
||||||
* @param boolean|string $_onCheckHandler =false string with handler-name to display a checkbox for each folder, or false (default), 'null' switches checkboxes on without an handler!
|
* @param boolean|string $_onCheckHandler =false string with handler-name to display a checkbox for each folder, or false (default), 'null' switches checkboxes on without an handler!
|
||||||
@ -1451,8 +1452,8 @@ egw_LAB.wait(function() {
|
|||||||
* Runs HTMLPurifier over supplied html to remove malicious code
|
* Runs HTMLPurifier over supplied html to remove malicious code
|
||||||
*
|
*
|
||||||
* @param string $html
|
* @param string $html
|
||||||
* @param array/string $config=null - config to influence the behavior of current purifying engine
|
* @param array|string $config =null - config to influence the behavior of current purifying engine
|
||||||
* @param array/string $spec=null - spec to influence the behavior of current purifying engine
|
* @param array|string $spec =null - spec to influence the behavior of current purifying engine
|
||||||
* The $spec argument can be used to disallow an otherwise legal attribute for an element,
|
* The $spec argument can be used to disallow an otherwise legal attribute for an element,
|
||||||
* or to restrict the attribute's values
|
* or to restrict the attribute's values
|
||||||
* @param boolean $_force =null - force the config passed to be used without merging to the default
|
* @param boolean $_force =null - force the config passed to be used without merging to the default
|
||||||
|
Loading…
Reference in New Issue
Block a user