forked from extern/egroupware
intval -> (int), replace gettype() and ereg_replace() where possible
This commit is contained in:
parent
8afddf6b17
commit
4f612cbbde
@ -61,10 +61,10 @@
|
||||
*/
|
||||
function acl($account_id = '')
|
||||
{
|
||||
$this->db = $GLOBALS['phpgw']->db;
|
||||
if (!($this->account_id = intval($account_id)))
|
||||
copyobj($GLOBALS['phpgw']->db,$this->db);
|
||||
if ((int)$this->account_id != (int)$account_id)
|
||||
{
|
||||
$this->account_id = get_account_id($account_id,@$GLOBALS['phpgw_info']['user']['account_id']);
|
||||
$this->account_id = get_account_id((int)$account_id,@$GLOBALS['phpgw_info']['user']['account_id']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@
|
||||
{
|
||||
reset($this->data);
|
||||
|
||||
$sql = 'delete from phpgw_acl where acl_account = '. intval($this->account_id);
|
||||
$sql = 'delete from phpgw_acl where acl_account = '. (int)$this->account_id;
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
|
||||
$count = count($this->data);
|
||||
@ -534,7 +534,7 @@
|
||||
}
|
||||
$sql = 'SELECT acl_appname, acl_rights from phpgw_acl ';
|
||||
$sql .= "where acl_location = '" . $this->db->db_addslashes($location) . "' ";
|
||||
$sql .= 'AND acl_account = ' . intval($account_id);
|
||||
$sql .= 'AND acl_account = ' . (int)$account_id;
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
$rights = 0;
|
||||
if ($this->db->num_rows() == 0 )
|
||||
@ -579,7 +579,7 @@
|
||||
}
|
||||
$sql = 'SELECT acl_location, acl_rights ';
|
||||
$sql .= "FROM phpgw_acl where acl_appname = '" . $this->db->db_addslashes($app) . "' ";
|
||||
$sql .= 'AND acl_account =' . intval($account_id);
|
||||
$sql .= 'AND acl_account =' . (int)$account_id;
|
||||
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
$rights = 0;
|
||||
@ -627,7 +627,7 @@
|
||||
$rights |= $this->db->f('acl_rights');
|
||||
if (!!($rights & $required) == True)
|
||||
{
|
||||
$accounts[] = intval($this->db->f('acl_account'));
|
||||
$accounts[] = (int)$this->db->f('acl_account');
|
||||
}
|
||||
}
|
||||
@reset($accounts);
|
||||
|
@ -118,7 +118,7 @@
|
||||
//
|
||||
if (!is_array($times))
|
||||
{
|
||||
$next = intval($times);
|
||||
$next = (int)$times;
|
||||
|
||||
return $next > $now ? $next : False;
|
||||
}
|
||||
@ -194,7 +194,7 @@
|
||||
|
||||
return False;
|
||||
}
|
||||
for ($i = intval($min); $i <= $max; ++$i)
|
||||
for ($i = (int)$min; $i <= $max; ++$i)
|
||||
{
|
||||
$times[$u][$i] = True;
|
||||
}
|
||||
@ -214,7 +214,7 @@
|
||||
}
|
||||
if (count($arr) == 1)
|
||||
{
|
||||
$times[$u][intval($one)] = True;
|
||||
$times[$u][(int)$one] = True;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -260,8 +260,8 @@
|
||||
|
||||
foreach($units as $u => $date_pattern)
|
||||
{
|
||||
$unit_now = $u != 'dow' ? intval(date($date_pattern)) :
|
||||
intval(date($date_pattern,mktime(12,0,0,$found['month'],$found['day'],$found['year'])));
|
||||
$unit_now = $u != 'dow' ? (int)date($date_pattern) :
|
||||
(int)date($date_pattern,mktime(12,0,0,$found['month'],$found['day'],$found['year']));
|
||||
|
||||
if (isset($found[$u]))
|
||||
{
|
||||
@ -509,8 +509,8 @@
|
||||
{
|
||||
$job['times'] = $this->db->db_addslashes(serialize($job['times']));
|
||||
$job['data'] = $this->db->db_addslashes(serialize($job['data']));
|
||||
$job['next'] = intval($job['next']);
|
||||
$job['account_id'] = intval($job['account_id']);
|
||||
$job['next'] = (int)$job['next'];
|
||||
$job['account_id'] = (int)$job['account_id'];
|
||||
|
||||
if ($exists || $this->read($job['id']))
|
||||
{
|
||||
|
@ -136,7 +136,7 @@
|
||||
.", '". $db->db_addslashes($err->msg) . "'"
|
||||
.", '". $db->db_addslashes((count($err->parms) > 1?implode('|',$err->parms):$err->parms[1])). "'"
|
||||
.", '". $err->fname . "'"
|
||||
.", " . intval($err->line)
|
||||
.", " . (int)$err->line
|
||||
.")"
|
||||
,__LINE__,__FILE__
|
||||
);
|
||||
|
@ -49,11 +49,11 @@
|
||||
|
||||
function delete($record_id)
|
||||
{
|
||||
$appname = intval($record_id) ? $this->appname : $record_id;
|
||||
$record_id = intval($record_id);
|
||||
$this->db->query('DELETE FROM phpgw_history_log WHERE'.
|
||||
($record_id ? " history_record_id='$record_id' AND" : '').
|
||||
" history_appname='$appname'",__LINE__,__FILE__);
|
||||
$appname = (int)$record_id ? $this->appname : $record_id;
|
||||
$record_id = (int)$record_id;
|
||||
$this->db->query('DELETE FROM phpgw_history_log WHERE'
|
||||
. ($record_id ? " history_record_id='$record_id' AND" : '')
|
||||
. " history_appname='$appname'",__LINE__,__FILE__);
|
||||
|
||||
return $this->db->affected_rows();
|
||||
}
|
||||
@ -64,7 +64,7 @@
|
||||
{
|
||||
$this->db->query("insert into phpgw_history_log (history_record_id,"
|
||||
. "history_appname,history_owner,history_status,history_new_value,history_old_value,history_timestamp) "
|
||||
. "values ('".intval($record_id)."','" . $this->appname . "','"
|
||||
. "values ('".(int)$record_id."','" . $this->appname . "','"
|
||||
. $GLOBALS['phpgw_info']['user']['account_id'] . "','$status','"
|
||||
. addslashes($new_value) . "','" . addslashes($old_value) . "','" . $this->db->to_timestamp(time())
|
||||
. "')",__LINE__,__FILE__);
|
||||
@ -105,7 +105,7 @@
|
||||
}
|
||||
|
||||
$this->db->query("select * from phpgw_history_log where history_appname='"
|
||||
. $this->appname . "' and history_record_id='".intval($record_id)."' $filter $only_show_filter "
|
||||
. $this->appname . "' and history_record_id='".(int)$record_id."' $filter $only_show_filter "
|
||||
. "$orderby",__LINE__,__FILE__);
|
||||
while ($this->db->next_record())
|
||||
{
|
||||
@ -114,7 +114,7 @@
|
||||
'record_id' => $this->db->f('history_record_id'),
|
||||
'owner' => $GLOBALS['phpgw']->accounts->id2name($this->db->f('history_owner')),
|
||||
// 'status' => lang($this->types[$this->db->f('history_status')]),
|
||||
'status' => ereg_replace(' ','',$this->db->f('history_status')),
|
||||
'status' => str_replace(' ','',$this->db->f('history_status')),
|
||||
'new_value' => $this->db->f('history_new_value'),
|
||||
'old_value' => $this->db->f('history_old_value'),
|
||||
'datetime' => $this->db->from_timestamp($this->db->f('history_timestamp'))
|
||||
@ -185,5 +185,4 @@
|
||||
}
|
||||
return $this->template->fp('out','list');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,377 +12,378 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
class html
|
||||
{
|
||||
var $user_agent,$ua_version; // 'mozilla','msie','konqueror'
|
||||
var $prefered_img_title;
|
||||
|
||||
function html()
|
||||
{ // should be Ok for all HTML 4 compatible browsers
|
||||
if (!eregi('compatible; ([a-z_]+)[/ ]+([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts))
|
||||
{
|
||||
eregi('^([a-z_]+)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts);
|
||||
}
|
||||
list(,$this->user_agent,$this->ua_version) = $parts;
|
||||
$this->user_agent = strtolower($this->user_agent);
|
||||
|
||||
$this->prefered_img_title = $this->user_agent == 'mozilla' && $this->ua_version < 5 ? 'ALT' : 'TITLE';
|
||||
//echo "<p>HTTP_USER_AGENT='$GLOBALS[HTTP_USER_AGENT]', UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: '$this->prefered_img_title'</p>\n";
|
||||
|
||||
$this->document_root = $_SERVER['DOCUMENT_ROOT'];
|
||||
// this is because some webservers report their docroot without the leading slash
|
||||
if (!is_dir($this->document_root) && is_dir('/'.$this->document_root))
|
||||
{
|
||||
$this->document_root = '/' . $this->document_root;
|
||||
}
|
||||
//echo "<p>_SERVER[DOCUMENT_ROOT]='$_SERVER[DOCUMENT_ROOT]', this->document_root='$this->document_root'</p>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: Allows to show and select one item from an array
|
||||
* Parameters: $name string with name of the submitted var which holds the key of the selected item form array
|
||||
* $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
|
||||
* $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
|
||||
* $no_lang if !$no_lang send items through lang()
|
||||
* $options additional options (e.g. 'multiple')
|
||||
* On submit $XXX is the key of the selected item (XXX is the content of $name)
|
||||
* Returns: string to set for a template or to echo into html page
|
||||
*/
|
||||
function select($name, $key, $arr=0,$no_lang=0,$options='',$multiple=0)
|
||||
class html
|
||||
{
|
||||
// should be in class common.sbox
|
||||
if (!is_array($arr))
|
||||
var $user_agent,$ua_version; // 'mozilla','msie','konqueror'
|
||||
var $prefered_img_title;
|
||||
|
||||
function html()
|
||||
{
|
||||
$arr = array('no','yes');
|
||||
}
|
||||
if (intval($multiple) > 0)
|
||||
{
|
||||
$options .= ' MULTIPLE SIZE="'.intval($multiple).'"';
|
||||
if (substr($name,-2) != '[]')
|
||||
// should be Ok for all HTML 4 compatible browsers
|
||||
if (!eregi('compatible; ([a-z_]+)[/ ]+([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts))
|
||||
{
|
||||
$name .= '[]';
|
||||
eregi('^([a-z_]+)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts);
|
||||
}
|
||||
}
|
||||
$out = "<select name=\"$name\" $options>\n";
|
||||
list(,$this->user_agent,$this->ua_version) = $parts;
|
||||
$this->user_agent = strtolower($this->user_agent);
|
||||
|
||||
if (is_array($key))
|
||||
{
|
||||
$key = implode(',',$key);
|
||||
}
|
||||
foreach($arr as $k => $text)
|
||||
{
|
||||
$out .= '<option value="'.htmlspecialchars($k).'"';
|
||||
$this->prefered_img_title = $this->user_agent == 'mozilla' && $this->ua_version < 5 ? 'ALT' : 'TITLE';
|
||||
//echo "<p>HTTP_USER_AGENT='$GLOBALS[HTTP_USER_AGENT]', UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: '$this->prefered_img_title'</p>\n";
|
||||
|
||||
if("$k" == "$key" || strstr(",$key,",",$k,"))
|
||||
$this->document_root = $_SERVER['DOCUMENT_ROOT'];
|
||||
// this is because some webservers report their docroot without the leading slash
|
||||
if (!is_dir($this->document_root) && is_dir('/'.$this->document_root))
|
||||
{
|
||||
$out .= " SELECTED";
|
||||
$this->document_root = '/' . $this->document_root;
|
||||
}
|
||||
$out .= ">" . ($no_lang || $text == '' ? $text : lang($text)) . "</option>\n";
|
||||
//echo "<p>_SERVER[DOCUMENT_ROOT]='$_SERVER[DOCUMENT_ROOT]', this->document_root='$this->document_root'</p>\n";
|
||||
}
|
||||
$out .= "</select>\n";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
function div($content,$options='')
|
||||
{
|
||||
return "<DIV $options>\n$content</DIV>\n";
|
||||
}
|
||||
|
||||
function input_hidden($vars,$value='',$ignore_empty=True)
|
||||
{
|
||||
if (!is_array($vars))
|
||||
/*
|
||||
* Function: Allows to show and select one item from an array
|
||||
* Parameters: $name string with name of the submitted var which holds the key of the selected item form array
|
||||
* $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
|
||||
* $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
|
||||
* $no_lang if !$no_lang send items through lang()
|
||||
* $options additional options (e.g. 'multiple')
|
||||
* On submit $XXX is the key of the selected item (XXX is the content of $name)
|
||||
* Returns: string to set for a template or to echo into html page
|
||||
*/
|
||||
function select($name, $key, $arr=0,$no_lang=0,$options='',$multiple=0)
|
||||
{
|
||||
$vars = array( $vars => $value );
|
||||
}
|
||||
foreach($vars as $name => $value)
|
||||
{
|
||||
if (is_array($value))
|
||||
// should be in class common.sbox
|
||||
if (!is_array($arr))
|
||||
{
|
||||
$value = serialize($value);
|
||||
$arr = array('no','yes');
|
||||
}
|
||||
if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none')) // dont need to send all the empty vars
|
||||
if ((int)$multiple > 0)
|
||||
{
|
||||
$html .= "<INPUT TYPE=\"HIDDEN\" NAME=\"$name\" VALUE=\"".htmlspecialchars($value)."\">\n";
|
||||
$options .= ' MULTIPLE SIZE="'.(int)$multiple.'"';
|
||||
if (substr($name,-2) != '[]')
|
||||
{
|
||||
$name .= '[]';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
$out = "<select name=\"$name\" $options>\n";
|
||||
|
||||
function textarea($name,$value='',$options='' )
|
||||
{
|
||||
return "<TEXTAREA name=\"$name\" $options>".htmlspecialchars($value)."</TEXTAREA>\n";
|
||||
}
|
||||
|
||||
function input($name,$value='',$type='',$options='' )
|
||||
{
|
||||
if ($type)
|
||||
{
|
||||
$type = 'TYPE="'.$type.'"';
|
||||
}
|
||||
return "<INPUT $type NAME=\"$name\" VALUE=\"".htmlspecialchars($value)."\" $options>\n";
|
||||
}
|
||||
|
||||
function submit_button($name,$lang,$onClick='',$no_lang=0,$options='',$image='',$app='')
|
||||
{
|
||||
if ($image != '')
|
||||
{
|
||||
if (strpos($image,'.'))
|
||||
if (is_array($key))
|
||||
{
|
||||
$image = substr($image,0,strpos($image,'.'));
|
||||
$key = implode(',',$key);
|
||||
}
|
||||
if (!($path = $GLOBALS['phpgw']->common->image($app,$image)) &&
|
||||
!($path = $GLOBALS['phpgw']->common->image('phpgwapi',$image)))
|
||||
foreach($arr as $k => $text)
|
||||
{
|
||||
$path = $image; // name may already contain absolut path
|
||||
$out .= '<option value="'.htmlspecialchars($k).'"';
|
||||
|
||||
if("$k" == "$key" || strstr(",$key,",",$k,"))
|
||||
{
|
||||
$out .= " SELECTED";
|
||||
}
|
||||
$out .= ">" . ($no_lang || $text == '' ? $text : lang($text)) . "</option>\n";
|
||||
}
|
||||
$image = ' SRC="'.$path.'"';
|
||||
$out .= "</select>\n";
|
||||
|
||||
return $out;
|
||||
}
|
||||
if (!$no_lang)
|
||||
|
||||
function div($content,$options='')
|
||||
{
|
||||
$lang = lang($lang);
|
||||
return "<DIV $options>\n$content</DIV>\n";
|
||||
}
|
||||
if (($accesskey = strstr($lang,'&')) && $accesskey[1] != ' ' &&
|
||||
|
||||
function input_hidden($vars,$value='',$ignore_empty=True)
|
||||
{
|
||||
if (!is_array($vars))
|
||||
{
|
||||
$vars = array( $vars => $value );
|
||||
}
|
||||
foreach($vars as $name => $value)
|
||||
{
|
||||
if (is_array($value))
|
||||
{
|
||||
$value = serialize($value);
|
||||
}
|
||||
if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none')) // dont need to send all the empty vars
|
||||
{
|
||||
$html .= "<INPUT TYPE=\"HIDDEN\" NAME=\"$name\" VALUE=\"".htmlspecialchars($value)."\">\n";
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function textarea($name,$value='',$options='' )
|
||||
{
|
||||
return "<TEXTAREA name=\"$name\" $options>".htmlspecialchars($value)."</TEXTAREA>\n";
|
||||
}
|
||||
|
||||
function input($name,$value='',$type='',$options='' )
|
||||
{
|
||||
if ($type)
|
||||
{
|
||||
$type = 'TYPE="'.$type.'"';
|
||||
}
|
||||
return "<INPUT $type NAME=\"$name\" VALUE=\"".htmlspecialchars($value)."\" $options>\n";
|
||||
}
|
||||
|
||||
function submit_button($name,$lang,$onClick='',$no_lang=0,$options='',$image='',$app='')
|
||||
{
|
||||
if ($image != '')
|
||||
{
|
||||
if (strpos($image,'.'))
|
||||
{
|
||||
$image = substr($image,0,strpos($image,'.'));
|
||||
}
|
||||
if (!($path = $GLOBALS['phpgw']->common->image($app,$image)) &&
|
||||
!($path = $GLOBALS['phpgw']->common->image('phpgwapi',$image)))
|
||||
{
|
||||
$path = $image; // name may already contain absolut path
|
||||
}
|
||||
$image = ' SRC="'.$path.'"';
|
||||
}
|
||||
if (!$no_lang)
|
||||
{
|
||||
$lang = lang($lang);
|
||||
}
|
||||
if (($accesskey = strstr($lang,'&')) && $accesskey[1] != ' ' &&
|
||||
(($pos = strpos($accesskey,';')) === False || $pos > 5))
|
||||
{
|
||||
$lang_u = str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$lang);
|
||||
$lang = str_replace('&','',$lang);
|
||||
$options = 'ACCESSKEY="'.$accesskey[1].'" '.$options;
|
||||
}
|
||||
else
|
||||
{
|
||||
$accesskey = '';
|
||||
$lang_u = $lang;
|
||||
}
|
||||
if ($onClick) $options .= " onClick=\"$onClick\"";
|
||||
{
|
||||
$lang_u = str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$lang);
|
||||
$lang = str_replace('&','',$lang);
|
||||
$options = 'ACCESSKEY="'.$accesskey[1].'" '.$options;
|
||||
}
|
||||
else
|
||||
{
|
||||
$accesskey = '';
|
||||
$lang_u = $lang;
|
||||
}
|
||||
if ($onClick) $options .= " onClick=\"$onClick\"";
|
||||
|
||||
// <button> is not working in all cases if ($this->user_agent == 'mozilla' && $this->ua_version < 5 || $image)
|
||||
{
|
||||
return $this->input($name,$lang,$image != '' ? 'IMAGE' : 'SUBMIT',$options.$image);
|
||||
}
|
||||
return '<button TYPE="submit" NAME="'.$name.'" VALUE="'.$lang.'" '.$options.'>'.
|
||||
// <button> is not working in all cases if ($this->user_agent == 'mozilla' && $this->ua_version < 5 || $image)
|
||||
{
|
||||
return $this->input($name,$lang,$image != '' ? 'IMAGE' : 'SUBMIT',$options.$image);
|
||||
}
|
||||
return '<button TYPE="submit" NAME="'.$name.'" VALUE="'.$lang.'" '.$options.'>'.
|
||||
($image != '' ? "<img$image $this->prefered_img_title=\"$lang\"> " : '').
|
||||
($image == '' || $accesskey ? $lang_u : '').'</button>';
|
||||
}
|
||||
|
||||
/*!
|
||||
@function link
|
||||
@abstract creates an absolut link + the query / get-variables
|
||||
@param $url phpgw-relative link, may include query / get-vars
|
||||
@parm $vars query or array ('name' => 'value', ...) with query
|
||||
@example link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123))
|
||||
@example = 'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
|
||||
@result absolut link already run through $phpgw->link
|
||||
*/
|
||||
function link($url,$vars='')
|
||||
{
|
||||
//echo "<p>html::link(url='$url',vars='"; print_r($vars); echo "')</p>\n";
|
||||
if (!is_array($vars))
|
||||
{
|
||||
parse_str($vars,$vars);
|
||||
}
|
||||
list($url,$v) = explode('?',$url); // url may contain additional vars
|
||||
if ($v)
|
||||
|
||||
/*!
|
||||
@function link
|
||||
@abstract creates an absolut link + the query / get-variables
|
||||
@param $url phpgw-relative link, may include query / get-vars
|
||||
@parm $vars query or array ('name' => 'value', ...) with query
|
||||
@example link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123))
|
||||
@example = 'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
|
||||
@result absolut link already run through $phpgw->link
|
||||
*/
|
||||
function link($url,$vars='')
|
||||
{
|
||||
parse_str($v,$v);
|
||||
$vars += $v;
|
||||
//echo "<p>html::link(url='$url',vars='"; print_r($vars); echo "')</p>\n";
|
||||
if (!is_array($vars))
|
||||
{
|
||||
parse_str($vars,$vars);
|
||||
}
|
||||
list($url,$v) = explode('?',$url); // url may contain additional vars
|
||||
if ($v)
|
||||
{
|
||||
parse_str($v,$v);
|
||||
$vars += $v;
|
||||
}
|
||||
return $GLOBALS['phpgw']->link($url,$vars);
|
||||
}
|
||||
return $GLOBALS['phpgw']->link($url,$vars);
|
||||
}
|
||||
|
||||
function checkbox($name,$value='')
|
||||
{
|
||||
return "<input type=\"checkbox\" name=\"$name\" value=\"True\"" .($value ? ' checked' : '') . ">\n";
|
||||
}
|
||||
|
||||
function form($content,$hidden_vars,$url,$url_vars='',$name='',$options='',$method='POST')
|
||||
{
|
||||
$html = "<form method=\"$method\" ".($name != '' ? "name=\"$name\" " : '')."action=\"".$this->link($url,$url_vars)."\" $options>\n";
|
||||
$html .= $this->input_hidden($hidden_vars);
|
||||
|
||||
if ($content)
|
||||
function checkbox($name,$value='')
|
||||
{
|
||||
$html .= $content;
|
||||
$html .= "</form>\n";
|
||||
return "<input type=\"checkbox\" name=\"$name\" value=\"True\"" .($value ? ' checked' : '') . ">\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function form_1button($name,$lang,$hidden_vars,$url,$url_vars='',$form_name='',$method='POST')
|
||||
{
|
||||
return $this->form($this->submit_button($name,$lang),
|
||||
function form($content,$hidden_vars,$url,$url_vars='',$name='',$options='',$method='POST')
|
||||
{
|
||||
$html = "<form method=\"$method\" ".($name != '' ? "name=\"$name\" " : '')."action=\"".$this->link($url,$url_vars)."\" $options>\n";
|
||||
$html .= $this->input_hidden($hidden_vars);
|
||||
|
||||
if ($content)
|
||||
{
|
||||
$html .= $content;
|
||||
$html .= "</form>\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function form_1button($name,$lang,$hidden_vars,$url,$url_vars='',$form_name='',$method='POST')
|
||||
{
|
||||
return $this->form($this->submit_button($name,$lang),
|
||||
$hidden_vars,$url,$url_vars,$form_name,'',$method);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function table
|
||||
@abstracts creates table from array with rows
|
||||
@discussion abstract the html stuff
|
||||
@param $rows array with rows, each row is an array of the cols
|
||||
@param $options options for the table-tag
|
||||
@example $rows = array ( '1' => array( 1 => 'cell1', '.1' => 'colspan=3',
|
||||
@example 2 => 'cell2', 3 => 'cell3', '.3' => 'width="10%"' ),
|
||||
@example '.1' => 'BGCOLOR="#0000FF"' );
|
||||
@example table($rows,'WIDTH="100%"') = '<table WIDTH="100%"><tr><td colspan=3>cell1</td><td>cell2</td><td width="10%">cell3</td></tr></table>'
|
||||
@result string with html-code of the table
|
||||
*/
|
||||
function table($rows,$options = '',$no_table_tr=False)
|
||||
{
|
||||
$html = $no_table_tr ? '' : "<TABLE $options>\n";
|
||||
|
||||
foreach($rows as $key => $row)
|
||||
/*!
|
||||
@function table
|
||||
@abstracts creates table from array with rows
|
||||
@discussion abstract the html stuff
|
||||
@param $rows array with rows, each row is an array of the cols
|
||||
@param $options options for the table-tag
|
||||
@example $rows = array ( '1' => array( 1 => 'cell1', '.1' => 'colspan=3',
|
||||
@example 2 => 'cell2', 3 => 'cell3', '.3' => 'width="10%"' ),
|
||||
@example '.1' => 'BGCOLOR="#0000FF"' );
|
||||
@example table($rows,'WIDTH="100%"') = '<table WIDTH="100%"><tr><td colspan=3>cell1</td><td>cell2</td><td width="10%">cell3</td></tr></table>'
|
||||
@result string with html-code of the table
|
||||
*/
|
||||
function table($rows,$options = '',$no_table_tr=False)
|
||||
{
|
||||
if (!is_array($row))
|
||||
$html = $no_table_tr ? '' : "<TABLE $options>\n";
|
||||
|
||||
foreach($rows as $key => $row)
|
||||
{
|
||||
continue; // parameter
|
||||
}
|
||||
$html .= $no_table_tr && $key == 1 ? '' : "\t<TR ".$rows['.'.$key].">\n";
|
||||
if (!is_array($row))
|
||||
{
|
||||
continue; // parameter
|
||||
}
|
||||
$html .= $no_table_tr && $key == 1 ? '' : "\t<TR ".$rows['.'.$key].">\n";
|
||||
|
||||
foreach($row as $key => $cell)
|
||||
foreach($row as $key => $cell)
|
||||
{
|
||||
if ($key[0] == '.')
|
||||
{
|
||||
continue; // parameter
|
||||
}
|
||||
$table_pos = strpos($cell,'<TABLE');
|
||||
$td_pos = strpos($cell,'<TD');
|
||||
if ($td_pos !== False && ($table_pos === False || $td_pos < $table_pos))
|
||||
{
|
||||
$html .= $cell;
|
||||
}
|
||||
else
|
||||
{
|
||||
$html .= "\t\t<TD ".$row['.'.$key].">$cell</TD>\n";
|
||||
}
|
||||
}
|
||||
$html .= "\t</TR>\n";
|
||||
}
|
||||
$html .= "</TABLE>\n";
|
||||
|
||||
if ($no_table_tr)
|
||||
{
|
||||
if ($key[0] == '.')
|
||||
{
|
||||
continue; // parameter
|
||||
}
|
||||
$table_pos = strpos($cell,'<TABLE');
|
||||
$td_pos = strpos($cell,'<TD');
|
||||
if ($td_pos !== False && ($table_pos === False || $td_pos < $table_pos))
|
||||
{
|
||||
$html .= $cell;
|
||||
}
|
||||
else
|
||||
{
|
||||
$html .= "\t\t<TD ".$row['.'.$key].">$cell</TD>\n";
|
||||
}
|
||||
$html = substr($html,0,-16);
|
||||
}
|
||||
$html .= "\t</TR>\n";
|
||||
return $html;
|
||||
}
|
||||
$html .= "</TABLE>\n";
|
||||
|
||||
if ($no_table_tr)
|
||||
function sbox_submit( $sbox,$no_script=0 )
|
||||
{
|
||||
$html = substr($html,0,-16);
|
||||
$html = str_replace('<select','<select onChange="this.form.submit()" ',
|
||||
$sbox);
|
||||
if ($no_script)
|
||||
{
|
||||
$html .= '<noscript>'.$this->submit_button('send','>').'</noscript>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function sbox_submit( $sbox,$no_script=0 )
|
||||
{
|
||||
$html = str_replace('<select','<select onChange="this.form.submit()" ',
|
||||
$sbox);
|
||||
if ($no_script)
|
||||
{
|
||||
$html .= '<noscript>'.$this->submit_button('send','>').'</noscript>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function image( $app,$name,$title='',$options='' )
|
||||
{
|
||||
if (!($path = $GLOBALS['phpgw']->common->image($app,$name)))
|
||||
function image( $app,$name,$title='',$options='' )
|
||||
{
|
||||
$path = $name; // name may already contain absolut path
|
||||
if (!($path = $GLOBALS['phpgw']->common->image($app,$name)))
|
||||
{
|
||||
$path = $name; // name may already contain absolut path
|
||||
}
|
||||
if (!@is_readable($this->document_root . $path))
|
||||
{
|
||||
return $title;
|
||||
}
|
||||
if ($title)
|
||||
{
|
||||
$options .= " $this->prefered_img_title=\"".htmlspecialchars($title).'"';
|
||||
}
|
||||
return "<IMG SRC=\"$path\" $options>";
|
||||
}
|
||||
if (!@is_readable($this->document_root . $path))
|
||||
{
|
||||
return $title;
|
||||
}
|
||||
if ($title)
|
||||
{
|
||||
$options .= " $this->prefered_img_title=\"".htmlspecialchars($title).'"';
|
||||
}
|
||||
return "<IMG SRC=\"$path\" $options>";
|
||||
}
|
||||
|
||||
function a_href( $content,$url,$vars='',$options='')
|
||||
{
|
||||
if (!strstr($url,'/') && count(explode('.',$url)) == 3)
|
||||
function a_href( $content,$url,$vars='',$options='')
|
||||
{
|
||||
$url = "/index.php?menuaction=$url";
|
||||
if (!strstr($url,'/') && count(explode('.',$url)) == 3)
|
||||
{
|
||||
$url = "/index.php?menuaction=$url";
|
||||
}
|
||||
if (is_array($url))
|
||||
{
|
||||
$vars = $url;
|
||||
$url = '/index.php';
|
||||
}
|
||||
return '<a href="'.$this->link($url,$vars).'" '.$options.'>'.$content.'</a>';
|
||||
}
|
||||
if (is_array($url))
|
||||
|
||||
function bold($content)
|
||||
{
|
||||
$vars = $url;
|
||||
$url = '/index.php';
|
||||
return '<b>'.$content.'</b>';
|
||||
}
|
||||
return '<a href="'.$this->link($url,$vars).'" '.$options.'>'.$content.'</a>';
|
||||
}
|
||||
|
||||
function bold($content)
|
||||
{
|
||||
return '<b>'.$content.'</b>';
|
||||
}
|
||||
function italic($content)
|
||||
{
|
||||
return '<i>'.$content.'</i>';
|
||||
}
|
||||
|
||||
function italic($content)
|
||||
{
|
||||
return '<i>'.$content.'</i>';
|
||||
}
|
||||
|
||||
function hr($width,$options='')
|
||||
{
|
||||
if ($width)
|
||||
function hr($width,$options='')
|
||||
{
|
||||
if ($width)
|
||||
$options .= " WIDTH=$width";
|
||||
return "<hr $options>\n";
|
||||
}
|
||||
return "<hr $options>\n";
|
||||
}
|
||||
|
||||
/*!
|
||||
@function formatOptions
|
||||
@abstract formats option-string for most of the above functions
|
||||
@param $options String (or Array) with option-values eg. '100%,,1'
|
||||
@param $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER'
|
||||
@example formatOptions('100%,,1','WIDTH,HEIGHT,BORDER') = ' WIDTH="100%" BORDER="1"'
|
||||
@result option string
|
||||
*/
|
||||
function formatOptions($options,$names)
|
||||
{
|
||||
if (!is_array($options)) $options = explode(',',$options);
|
||||
if (!is_array($names)) $names = explode(',',$names);
|
||||
/*!
|
||||
@function formatOptions
|
||||
@abstract formats option-string for most of the above functions
|
||||
@param $options String (or Array) with option-values eg. '100%,,1'
|
||||
@param $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER'
|
||||
@example formatOptions('100%,,1','WIDTH,HEIGHT,BORDER') = ' WIDTH="100%" BORDER="1"'
|
||||
@result option string
|
||||
*/
|
||||
function formatOptions($options,$names)
|
||||
{
|
||||
if (!is_array($options)) $options = explode(',',$options);
|
||||
if (!is_array($names)) $names = explode(',',$names);
|
||||
|
||||
while (list($n,$val) = each($options))
|
||||
while (list($n,$val) = each($options))
|
||||
if ($val != '' && $names[$n] != '')
|
||||
$html .= ' '.$names[$n].'="'.$val.'"';
|
||||
$html .= ' '.$names[$n].'="'.$val.'"';
|
||||
|
||||
return $html;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function themeStyles
|
||||
@abstract returns simple stylesheet (incl. <STYLE> tags) for nextmatch row-colors
|
||||
@result the classes 'th' = nextmatch header, 'row_on'+'row_off' = alternating rows
|
||||
*/
|
||||
function themeStyles()
|
||||
{
|
||||
return $this->style($this->theme2css());
|
||||
}
|
||||
/*!
|
||||
@function themeStyles
|
||||
@abstract returns simple stylesheet (incl. <STYLE> tags) for nextmatch row-colors
|
||||
@result the classes 'th' = nextmatch header, 'row_on'+'row_off' = alternating rows
|
||||
*/
|
||||
function themeStyles()
|
||||
{
|
||||
return $this->style($this->theme2css());
|
||||
}
|
||||
|
||||
/*!
|
||||
@function theme2css
|
||||
@abstract returns simple stylesheet for nextmatch row-colors
|
||||
@result the classes 'th' = nextmatch header, 'row_on'+'row_off' = alternating rows
|
||||
*/
|
||||
function theme2css()
|
||||
{
|
||||
return
|
||||
/*!
|
||||
@function theme2css
|
||||
@abstract returns simple stylesheet for nextmatch row-colors
|
||||
@result the classes 'th' = nextmatch header, 'row_on'+'row_off' = alternating rows
|
||||
*/
|
||||
function theme2css()
|
||||
{
|
||||
return
|
||||
".th { background: ".$GLOBALS['phpgw_info']['theme']['th_bg']."; }\n".
|
||||
".row_on,.th_bright { background: ".$GLOBALS['phpgw_info']['theme']['row_on']."; }\n".
|
||||
".row_off { background: ".$GLOBALS['phpgw_info']['theme']['row_off']."; }\n";
|
||||
}
|
||||
|
||||
function style($styles)
|
||||
{
|
||||
return $styles ? "<STYLE type=\"text/css\">\n<!--\n$styles\n-->\n</STYLE>" : '';
|
||||
}
|
||||
|
||||
function label($content,$id='',$accesskey='',$options='')
|
||||
{
|
||||
if ($id != '')
|
||||
{
|
||||
$id = " FOR=\"$id\"";
|
||||
}
|
||||
if ($accesskey != '')
|
||||
|
||||
function style($styles)
|
||||
{
|
||||
$accesskey = " ACCESSKEY=\"$accesskey\"";
|
||||
return $styles ? "<STYLE type=\"text/css\">\n<!--\n$styles\n-->\n</STYLE>" : '';
|
||||
}
|
||||
|
||||
function label($content,$id='',$accesskey='',$options='')
|
||||
{
|
||||
if ($id != '')
|
||||
{
|
||||
$id = " FOR=\"$id\"";
|
||||
}
|
||||
if ($accesskey != '')
|
||||
{
|
||||
$accesskey = " ACCESSKEY=\"$accesskey\"";
|
||||
}
|
||||
return "<LABEL$id$accesskey $options>$content</LABEL>";
|
||||
}
|
||||
return "<LABEL$id$accesskey $options>$content</LABEL>";
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@
|
||||
if(IsSet($arguments['PostValues']))
|
||||
{
|
||||
$values = $arguments['PostValues'];
|
||||
if(GetType($values) != 'array')
|
||||
if(!@is_array($values))
|
||||
{
|
||||
return('5 it was not specified a valid POST method values array');
|
||||
}
|
||||
@ -294,7 +294,7 @@
|
||||
{
|
||||
$header_name = Key($headers);
|
||||
$header_value = $headers[$header_name];
|
||||
if(GetType($header_value)=='array')
|
||||
if(@is_array($header_value))
|
||||
{
|
||||
for(Reset($header_value),$value=0;$value<count($header_value);Next($header_value),$value++)
|
||||
{
|
||||
@ -402,7 +402,7 @@
|
||||
for(;;)
|
||||
{
|
||||
$line = $this->GetLine();
|
||||
if(GetType($line) != 'string')
|
||||
if(!is_string($line))
|
||||
{
|
||||
return('4 could not read request reply');
|
||||
}
|
||||
@ -415,7 +415,7 @@
|
||||
$header_value = Trim(Chop(strtok("\r\n")));
|
||||
if(IsSet($headers[$header_name]))
|
||||
{
|
||||
if(GetType($headers[$header_name]) == 'string')
|
||||
if(is_string($headers[$header_name]))
|
||||
{
|
||||
$headers[$header_name] = array($headers[$header_name]);
|
||||
}
|
||||
@ -428,7 +428,7 @@
|
||||
switch($header_name)
|
||||
{
|
||||
case 'content-length':
|
||||
$this->content_length = intval($headers[$header_name]);
|
||||
$this->content_length = (int)$headers[$header_name];
|
||||
$this->content_length_set = 1;
|
||||
break;
|
||||
case 'set-cookie':
|
||||
@ -461,7 +461,7 @@
|
||||
case 'expires':
|
||||
if(ereg("^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT$",$value,$matches))
|
||||
{
|
||||
$year = intval($matches[5]);
|
||||
$year = (int)$matches[5];
|
||||
if($year<1900)
|
||||
{
|
||||
$year += ($year<70 ? 2000 : 1900);
|
||||
|
@ -1,82 +1,82 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - API jsCalendar wrapper-class *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
||||
* -------------------------------------------- *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU General Public License as published by the *
|
||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - API jsCalendar wrapper-class *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
||||
* -------------------------------------------- *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU General Public License as published by the *
|
||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
/* $Id$ */
|
||||
|
||||
/*!
|
||||
@class jscalendar
|
||||
@author ralfbecker
|
||||
@abstract wrapper for the jsCalendar
|
||||
@discussion the constructor load the necessary javascript-files
|
||||
*/
|
||||
class jscalendar
|
||||
{
|
||||
/*!
|
||||
@function jscalendar
|
||||
@syntax jscalendar( $do_header=True )
|
||||
@class jscalendar
|
||||
@author ralfbecker
|
||||
@abstract constructor of the class
|
||||
@param $do_header if true, necessary javascript and css gets loaded, only needed for input
|
||||
@abstract wrapper for the jsCalendar
|
||||
@discussion the constructor load the necessary javascript-files
|
||||
*/
|
||||
function jscalendar($do_header=True)
|
||||
class jscalendar
|
||||
{
|
||||
$this->phpgwapi_js_url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js';
|
||||
$this->dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
|
||||
|
||||
if ($do_header && !strstr($GLOBALS['phpgw_info']['flags']['java_script'],'jscalendar'))
|
||||
/*!
|
||||
@function jscalendar
|
||||
@syntax jscalendar( $do_header=True )
|
||||
@author ralfbecker
|
||||
@abstract constructor of the class
|
||||
@param $do_header if true, necessary javascript and css gets loaded, only needed for input
|
||||
*/
|
||||
function jscalendar($do_header=True)
|
||||
{
|
||||
$GLOBALS['phpgw_info']['flags']['java_script'] .=
|
||||
$this->phpgwapi_js_url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js';
|
||||
$this->dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
|
||||
|
||||
if ($do_header && !strstr($GLOBALS['phpgw_info']['flags']['java_script'],'jscalendar'))
|
||||
{
|
||||
$GLOBALS['phpgw_info']['flags']['java_script'] .=
|
||||
'<link rel="stylesheet" type="text/css" media="all" href="'.$this->phpgwapi_js_url.'/jscalendar/calendar-win2k-cold-1.css" title="win2k-cold-1" />
|
||||
<script type="text/javascript" src="'.$this->phpgwapi_js_url.'/jscalendar/calendar.js"></script>
|
||||
<script type="text/javascript" src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',$GLOBALS['phpgw']->link('/phpgwapi/inc/jscalendar-setup.php')).'"></script>
|
||||
';
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function input
|
||||
@syntax input( $name,$date,$year=0,$month=0,$day=0 )
|
||||
@author ralfbecker
|
||||
@abstract creates an inputfield for the jscalendar (returns the necessary html and js)
|
||||
@param $name name and id of the input-field (it also names the id of the img $name.'-toggle')
|
||||
@param $date date as string or unix timestamp (in users localtime)
|
||||
@param $year,$month,$day if $date is not used
|
||||
@param $helpmsg a helpmessage for the statusline of the browser
|
||||
@param $options any other options to the inputfield
|
||||
*/
|
||||
function input($name,$date,$year=0,$month=0,$day=0,$helpmsg='',$options='')
|
||||
{
|
||||
//echo "<p>jscalendar::input(name='$name', date='$date'='".date('Y-m-d',$date)."', year='$year', month='$month', day='$day')</p>\n";
|
||||
|
||||
if ($date && (is_int($date) || is_numeric($date)))
|
||||
{
|
||||
$year = intval($GLOBALS['phpgw']->common->show_date($date,'Y'));
|
||||
$month = intval($GLOBALS['phpgw']->common->show_date($date,'n'));
|
||||
$day = intval($GLOBALS['phpgw']->common->show_date($date,'d'));
|
||||
}
|
||||
if ($year && $month && $day)
|
||||
{
|
||||
$date = date($this->dateformat,$ts = mktime(12,0,0,$month,$day,$year));
|
||||
if (strpos($this->dateformat,'M') !== False)
|
||||
{
|
||||
$date = str_replace(date('M',$ts),substr(lang(date('F',$ts)),0,3),$date);
|
||||
}
|
||||
}
|
||||
if ($helpmsg !== '')
|
||||
|
||||
/*!
|
||||
@function input
|
||||
@syntax input( $name,$date,$year=0,$month=0,$day=0 )
|
||||
@author ralfbecker
|
||||
@abstract creates an inputfield for the jscalendar (returns the necessary html and js)
|
||||
@param $name name and id of the input-field (it also names the id of the img $name.'-toggle')
|
||||
@param $date date as string or unix timestamp (in users localtime)
|
||||
@param $year,$month,$day if $date is not used
|
||||
@param $helpmsg a helpmessage for the statusline of the browser
|
||||
@param $options any other options to the inputfield
|
||||
*/
|
||||
function input($name,$date,$year=0,$month=0,$day=0,$helpmsg='',$options='')
|
||||
{
|
||||
$options .= " onFocus=\"self.status='".addslashes($helpmsg)."'; return true;\"" .
|
||||
//echo "<p>jscalendar::input(name='$name', date='$date'='".date('Y-m-d',$date)."', year='$year', month='$month', day='$day')</p>\n";
|
||||
|
||||
if ($date && (is_int($date) || is_numeric($date)))
|
||||
{
|
||||
$year = (int)$GLOBALS['phpgw']->common->show_date($date,'Y');
|
||||
$month = (int)$GLOBALS['phpgw']->common->show_date($date,'n');
|
||||
$day = (int)$GLOBALS['phpgw']->common->show_date($date,'d');
|
||||
}
|
||||
if ($year && $month && $day)
|
||||
{
|
||||
$date = date($this->dateformat,$ts = mktime(12,0,0,$month,$day,$year));
|
||||
if (strpos($this->dateformat,'M') !== False)
|
||||
{
|
||||
$date = str_replace(date('M',$ts),substr(lang(date('F',$ts)),0,3),$date);
|
||||
}
|
||||
}
|
||||
if ($helpmsg !== '')
|
||||
{
|
||||
$options .= " onFocus=\"self.status='".addslashes($helpmsg)."'; return true;\"" .
|
||||
" onBlur=\"self.status=''; return true;\"";
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
'<input type="text" id="'.$name.'" name="'.$name.'" size="10" value="'.$date.'"'.$options.'/>
|
||||
<script type="text/javascript">
|
||||
document.writeln(\'<img id="'.$name.'-trigger" src="'.$this->phpgwapi_js_url.'/jscalendar/img.gif" title="'.lang('Select date').'" style="cursor:pointer; cursor:hand;"/>\');
|
||||
@ -88,59 +88,59 @@ class jscalendar
|
||||
);
|
||||
</script>
|
||||
';
|
||||
}
|
||||
|
||||
/*!
|
||||
@function input2date
|
||||
@syntax input2date( $datestr,$raw='raw',$day='day',$month='month',$year='year' )
|
||||
@author ralfbecker
|
||||
@abstract converts the date-string back to an array with year, month, day and a timestamp
|
||||
@param $datestr content of the inputfield generated by jscalendar::input()
|
||||
@param $raw key of the timestamp-field in the returned array or False of no timestamp
|
||||
@param $day,$month,$year keys for the array, eg. to set mday instead of day
|
||||
*/
|
||||
function input2date($datestr,$raw='raw',$day='day',$month='month',$year='year')
|
||||
{
|
||||
//echo "<p>jscalendar::input2date('$datestr') ".print_r($fields,True)."</p>\n";
|
||||
if ($datestr === '')
|
||||
{
|
||||
return False;
|
||||
}
|
||||
$fields = split('[./-]',$datestr);
|
||||
foreach(split('[./-]',$this->dateformat) as $n => $field)
|
||||
|
||||
/*!
|
||||
@function input2date
|
||||
@syntax input2date( $datestr,$raw='raw',$day='day',$month='month',$year='year' )
|
||||
@author ralfbecker
|
||||
@abstract converts the date-string back to an array with year, month, day and a timestamp
|
||||
@param $datestr content of the inputfield generated by jscalendar::input()
|
||||
@param $raw key of the timestamp-field in the returned array or False of no timestamp
|
||||
@param $day,$month,$year keys for the array, eg. to set mday instead of day
|
||||
*/
|
||||
function input2date($datestr,$raw='raw',$day='day',$month='month',$year='year')
|
||||
{
|
||||
if ($field == 'M')
|
||||
//echo "<p>jscalendar::input2date('$datestr') ".print_r($fields,True)."</p>\n";
|
||||
if ($datestr === '')
|
||||
{
|
||||
if (!is_numeric($fields[$n]))
|
||||
return False;
|
||||
}
|
||||
$fields = split('[./-]',$datestr);
|
||||
foreach(split('[./-]',$this->dateformat) as $n => $field)
|
||||
{
|
||||
if ($field == 'M')
|
||||
{
|
||||
for($i = 1; $i <= 12; $i++)
|
||||
if (!is_numeric($fields[$n]))
|
||||
{
|
||||
$long_name = date('F',mktime(12,0,0,$i,1,2000));
|
||||
$short_name = date('M',mktime(12,0,0,$i,1,2000));
|
||||
$translated = lang($long_name);
|
||||
if ($fields[$n] == $long_name || $fields[$n] == $short_name ||
|
||||
strstr($translated,$fields[$n]) == $translated) // multibyte save
|
||||
for($i = 1; $i <= 12; $i++)
|
||||
{
|
||||
$fields[$n] = $i;
|
||||
break;
|
||||
$long_name = date('F',mktime(12,0,0,$i,1,2000));
|
||||
$short_name = date('M',mktime(12,0,0,$i,1,2000));
|
||||
$translated = lang($long_name);
|
||||
if ($fields[$n] == $long_name || $fields[$n] == $short_name ||
|
||||
strstr($translated,$fields[$n]) == $translated) // multibyte save
|
||||
{
|
||||
$fields[$n] = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$field = 'm';
|
||||
}
|
||||
$field = 'm';
|
||||
$date[$field] = (int)$fields[$n];
|
||||
}
|
||||
$date[$field] = intval($fields[$n]);
|
||||
}
|
||||
$ret = array(
|
||||
$year => $date['Y'],
|
||||
$month => $date['m'],
|
||||
$day => $date['d']
|
||||
);
|
||||
if ($raw)
|
||||
{
|
||||
$ret[$raw] = mktime(12,0,0,$date['m'],$date['d'],$date['Y']);
|
||||
}
|
||||
//echo "<p>jscalendar::input2date('$datestr','$raw',$day','$month','$year') = "; print_r($ret); echo "</p>\n";
|
||||
$ret = array(
|
||||
$year => $date['Y'],
|
||||
$month => $date['m'],
|
||||
$day => $date['d']
|
||||
);
|
||||
if ($raw)
|
||||
{
|
||||
$ret[$raw] = mktime(12,0,0,$date['m'],$date['d'],$date['Y']);
|
||||
}
|
||||
//echo "<p>jscalendar::input2date('$datestr','$raw',$day','$month','$year') = "; print_r($ret); echo "</p>\n";
|
||||
|
||||
return $ret;
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -423,7 +423,7 @@
|
||||
{
|
||||
//echo "<br>adding - insert into phpgw_lang values ('$message_id','$app_name','$lang','$content')";
|
||||
$result = $this->db->query("INSERT INTO phpgw_lang (message_id,app_name,lang,content) VALUES('$message_id','$app_name','$lang','$content')",__LINE__,__FILE__);
|
||||
if (intval($result) <= 0)
|
||||
if ((int)$result <= 0)
|
||||
{
|
||||
echo "<br>Error inserting record: phpgw_lang values ('$message_id','$app_name','$lang','$content')";
|
||||
}
|
||||
@ -464,7 +464,7 @@
|
||||
if (file_exists($fname))
|
||||
{
|
||||
$ctime = filectime($fname);
|
||||
$ltime = intval($GLOBALS['phpgw_info']['server']['lang_ctimes'][$lang][$app]);
|
||||
$ltime = (int)$GLOBALS['phpgw_info']['server']['lang_ctimes'][$lang][$app];
|
||||
//echo "checking lang='$lang', app='$app', ctime='$ctime', ltime='$ltime'<br>\n";
|
||||
|
||||
if ($ctime != $ltime)
|
||||
|
Loading…
Reference in New Issue
Block a user