[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.sbox2.inc.php,1.10.2.1,1.10.
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.sbox2.inc.php,1.10.2.1,1.10.2.1.2.1 |
Date: |
Mon, 05 May 2003 17:57:36 -0400 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv25278
Modified Files:
Tag: Version-0_9_16-branch
class.sbox2.inc.php
Log Message:
merge etemplate/HEAD version of sbox
Index: class.sbox2.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.sbox2.inc.php,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.1.2.1
diff -C2 -r1.10.2.1 -r1.10.2.1.2.1
*** class.sbox2.inc.php 21 May 2002 03:25:43 -0000 1.10.2.1
--- class.sbox2.inc.php 5 May 2003 21:57:34 -0000 1.10.2.1.2.1
***************
*** 7,11 ****
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
! * http://www.phpgroupware.org/api
*
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
--- 7,11 ----
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
! * http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
***************
*** 24,28 ****
/* $Id$ */
! include(PHPGW_API_INC . '/class.sbox.inc.php');
class sbox2 extends sbox
--- 24,32 ----
/* $Id$ */
! if(!isset($GLOBALS['phpgw_info']['flags']['included_classes']['sbox']))
! {
! include(PHPGW_API_INC . '/class.sbox.inc.php');
! $GLOBALS['phpgw_info']['flags']['included_classes']['sbox'] =
True;
! }
class sbox2 extends sbox
***************
*** 48,55 ****
*/
function
getId($name,$lang_name,$prompt,$id_name,$content='',$note='',$multiple=False)
{
// echo
"<p>getId('$name','$lang_name','$prompt',$id_name,'$content') =";
! $ret['doSearchFkt'] =
'<script language="JavaScript">'."\n".
" function doSearch(field,ask) {\n".
--- 52,64 ----
*/
+ function sbox2()
+ {
+ $this->sbox(); // call constructor extended class
+ }
+
function
getId($name,$lang_name,$prompt,$id_name,$content='',$note='',$multiple=False)
{
// echo
"<p>getId('$name','$lang_name','$prompt',$id_name,'$content') =";
! $ret['doSearchFkt'] =
'<script language="JavaScript">'."\n".
" function doSearch(field,ask) {\n".
***************
*** 64,68 ****
'</script>';
! $ret[$name.'_title'] = is_array($content) &&
count($content) ? $lang_name :
'<script language="JavaScript">'."\n".
" document.writeln('<input type=\"hidden\" name=\"query_$name\"
value=\"\">');\n".
--- 73,77 ----
'</script>';
! $ret[$name.'_title'] = is_array($content) &&
count($content) ? $lang_name :
'<script language="JavaScript">'."\n".
" document.writeln('<input type=\"hidden\" name=\"query_$name\"
value=\"\">');\n".
***************
*** 74,80 ****
if (is_array($content))
! { // result from search
if (!count($content))
! { // search was unsuccessful
$ret[$name] = lang('no entries found,
try again ...');
}
--- 83,91 ----
if (is_array($content))
! {
! // result from search
if (!count($content))
! {
! // search was unsuccsessful
$ret[$name] = lang('no entries found,
try again ...');
}
***************
*** 112,116 ****
$ret[$name.'_nojs'] =
"<noscript>\n".
! " <input name=\"query_$name\" value=\"\" size=10> <input
type=\"submit\" value=\"?\">\n".
"</noscript>";
--- 123,127 ----
$ret[$name.'_nojs'] =
"<noscript>\n".
! " <input name=\"query_$name\" value=\"\" size=10> <input
type=\"submit\" value=\"?\">\n".
"</noscript>";
***************
*** 119,122 ****
--- 130,210 ----
}
+ function event2name( $event )
+ {
+ if (!is_object($this->bocal))
+ {
+ $this->bocal =
createobject('calendar.bocalendar');
+ }
+ if (!is_array($event) && (int) $event > 0)
+ {
+ $event = $this->bocal->read_entry($event);
+ }
+ if (!is_array($event))
+ {
+ return 'not an event !!!';
+ }
+ $name =
$GLOBALS['phpgw']->common->show_date($this->bocal->maketime($event['start']) -
$this->bocal->datetime->tz_offset);
+ $name .= ' -- ' .
$GLOBALS['phpgw']->common->show_date($this->bocal->maketime($event['end']) -
$this->bocal->datetime->tz_offset);
+ $name .= ': ' . $event['title'];
+
+ return $GLOBALS['phpgw']->strip_html($name);
+ }
+
+ /*
+ * Function Allows you to show and select an event
from the calendar (works with and without javascript !!!)
+ * Parameters $name string with basename of all
variables (not to conflict with the name other template or submitted vars !!!)
+ * $id_name
id of the address for edit or 0 if none selected so far
+ * $query_name have to be
called $query_XXX, the search pattern after the submit, has to be passed back
to the function
+ * $multipe present
a multiple selectable box instead of one selector-button
+ * On Submit $id_XXX contains the selected event (if
!= 0)
+ * $query_XXX search
pattern if the search button is pressed by the user, or '' if regular submit
+ * Returns array with vars to set for the
template, set with: $template->set_var( getEvent( ... )); (see getId( ))
+ *
+ * Note As query's for an event are submitted,
you have to check $query_XXX if it is a search or a regular submit
(!$query_string)
+ */
+ function getEvent(
$name,$id_name,$query_name,$title='',$multiple=False)
+ {
+ // echo
"<p>getEvent('$name',$id_name,'$query_name','$title')</p>";
+
+ // fallback if calendar is not installed or not enabled
for user
+ if (!file_exists(PHPGW_SERVER_ROOT.'/calendar') ||
!$GLOBALS['phpgw_info']['user']['apps']['calendar']['enabled'])
+ {
+ return array(
+ $name => "<input type=\"hidden\"
name=\"id_$name\" value=\"$id_name\">\n",
+ $name.'_no_js' => '',
+ $name.'_title' => ''
+ );
+ }
+ if ($id_name || $query_name)
+ {
+ if (!is_object($this->bocal))
+ {
+ $this->bocal =
createobject('calendar.bocalendar');
+ }
+ if ($query_name)
+ {
+ $event_ids =
$this->bocal->search_keywords($query_name);
+ $content = array( );
+ while ($event_ids && list( $key,$id ) =
each( $event_ids ))
+ {
+ $content[$id] =
$this->event2name( $id );
+ }
+ }
+ else
+ {
+ $event = $this->bocal->read_entry(
$id_name );
+ if ($event && is_array($event))
+ {
+ $content = $this->event2name(
$event );
+ }
+ }
+ }
+ if (!$title)
+ {
+ $title = lang('Calendar');
+ }
+ return $this->getId($name,$title,lang('Pattern for
Search in Calendar'),$id_name,$content,lang('use Button to search for
Calendarevent'),$multiple);
+ }
+
function addr2name( $addr )
{
***************
*** 152,156 ****
* Note As query's for an address are
submitted, you have to check $query_XXX if it is a search or a regular submit
(!$query_string)
*/
-
function getAddress(
$name,$id_name,$query_name,$title='',$multiple=False)
{
--- 240,243 ----
***************
*** 269,288 ****
{
// echo
"<p>getProject('$name',$id_name,'$query_name','$title')</p>";
if ($id_name || $query_name)
{
! $projects = createobject('projects.projects');
if ($query_name)
{
! $projs = $projects->read_projects(
0,0,$query_name,'','','','',0 );
$content = array();
while ($projs && list( $key,$proj ) =
each( $projs ))
{
! $content[$proj['id']] =
$proj['title'];
}
}
else
{
! list( $proj ) =
$projects->read_single_project( $id_name );
! if (count($proj))
{
$content = $proj['title'];
--- 356,388 ----
{
// echo
"<p>getProject('$name',$id_name,'$query_name','$title')</p>";
+
+ // fallback if projects is not installed or not enabled
for user
+ if (!file_exists(PHPGW_SERVER_ROOT.'/projects') ||
!$GLOBALS['phpgw_info']['user']['apps']['projects']['enabled'])
+ {
+ return array(
+ $name => "<input type=\"hidden\"
name=\"id_$name\" value=\"$id_name\">\n",
+ $name.'_no_js' => '',
+ $name.'_title' => ''
+ );
+ }
if ($id_name || $query_name)
{
! $projects = createobject('projects.boprojects');
! if (!is_object($projects))
! {
! return '';
! }
if ($query_name)
{
! $projs = $projects->list_projects(
0,0,$query_name,'','','','',0,'mains','' );
$content = array();
while ($projs && list( $key,$proj ) =
each( $projs ))
{
! $content[$proj['project_id']] =
$proj['title'];
}
}
else
{
! if ($proj =
$projects->read_single_project( $id_name ))
{
$content = $proj['title'];
***************
*** 302,335 ****
* 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 of already selected item from $arr
* $arr
array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' =>
'maybe');
! * $no_lang
if !$no_lang send items through lang()
! * 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 getArrayItem($name, $key, $arr=0,$no_lang=0)
! { // should be in class common.sbox
if (!is_array($arr))
{
$arr = array('no','yes');
}
!
! $out = "<select name=\"$name\">\n";
while (list($k,$text) = each($arr))
{
$out .= '<option value="'.$k.'"';
! if($k == $key)
{
$out .= " SELECTED";
}
! $out .= ">" . ($no_lang ? $text : lang($text))
. "</option>\n";
}
$out .= "</select>\n";
!
return $out;
}
! function accountInfo($id,$account_data=0,$longname=0)
{
if (!$id)
--- 402,495 ----
* 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 getArrayItem($name, $key,
$arr=0,$no_lang=0,$options='',$multiple=0)
! {
! // should be in class common.sbox
if (!is_array($arr))
{
$arr = array('no','yes');
}
! if (0+$multiple > 0)
! {
! $options .= ' MULTIPLE SIZE='.(0+$multiple);
! if (substr($name,-2) != '[]')
! {
! $name .= '[]';
! }
! }
! $out = "<select name=\"$name\" $options>\n";
+ if (is_array($key))
+ {
+ $key = implode(',',$key);
+ }
while (list($k,$text) = each($arr))
{
$out .= '<option value="'.$k.'"';
! if($k == $key || strstr(",$key,",",$k,"))
{
$out .= " SELECTED";
}
! $out .= ">" . ($no_lang || $text == '' ? $text
: lang($text)) . "</option>\n";
}
$out .= "</select>\n";
!
return $out;
}
! function getPercentage($name, $selected=0,$options='')
! {
! // reimplemented using getArrayItem
! for ($i=0; $i <= 100; $i+=10)
! {
! $arr[$i] = "$i%";
! }
! return
$this->getArrayItem($name,$selected,$arr,1,$options);
! }
!
! function getPriority($name, $selected=2,$options='')
! {
! // reimplemented using getArrayItem
! $arr = array('','low','normal','high');
!
! return
$this->getArrayItem($name,$selected,$arr,0,$options);
! }
!
! function getAccessList($name,$selected='private',$options='')
! {
! // reimplemented using getArrayItem
! $arr = array(
! 'private' => 'Private',
! 'public' => 'Global public',
! 'group' => 'Group public'
! );
!
! if (strstr($selected,','))
! {
! $selected = "group";
! }
!
! return
$this->getArrayItem($name,$selected,$arr,0,$options);
! }
!
! function getCountry($name='country',$selected=' ',$options='')
! {
! // reimplemented using getArrayItem
! return
$this->getArrayItem($name,$selected,$this->country_array,0,$options);
! }
!
! function form_select($name='country',$selected=' ',$options='')
! {
! // reimplemented using getArrayItem (stupid name!!!)
! return getCountry($name,$selected,$options);
! }
!
! function
accountInfo($id,$account_data=0,$longnames=0,$show_type=0)
{
if (!$id)
***************
*** 345,354 ****
$account_data = $accounts->data;
}
! if ($longnames)
{
! return $account_data['firstname'].'
'.$account_data['lastname'];
}
!
! return $account_data['account_lid'];
}
--- 505,517 ----
$account_data = $accounts->data;
}
! $info = $show_type ?
'('.$account_data['account_type'].') ' : '';
!
! switch ($longnames)
{
! case 2: $info .=
'<'.$account_data['account_lid'].'> '; // fall-through
! case 1: $info .=
$account_data['account_firstname'].' '.$account_data['account_lastname']; break;
! default: $info .= $account_data['account_lid'];
break;
}
! return $info;
}
***************
*** 357,381 ****
* Parameters: $name string with
name of the submitted var, which holds the account_id or 0 after submit
* $id
account_id of already selected account
! *
$id2text($id,$acct_data) fkt that translates account_id $id in text to
show
*/
!
! function getAccount($name,$id,$longnames=0)
{
$accounts = createobject('phpgwapi.accounts');
$accounts->db = $GLOBALS['phpgw']->db;
! $accs = $accounts->get_list('accounts');
! $aarr = Array(lang('not assigned'));
while ($a = current($accs))
{
! $aarr[$a['account_id']] =
$this->accountInfo($a['account_id'],$a,$longnames);
next($accs);
}
! return $this->getArrayItem($name,$id,$aarr,1);
}
! function getDate($n_year,$n_month,$n_day,$date)
{
! if (!$date)
{
$day = $month = $year = 0;
--- 520,550 ----
* Parameters: $name string with
name of the submitted var, which holds the account_id or 0 after submit
* $id
account_id of already selected account
! * $longnames
0=account_lid 1=firstname lastname
*/
! function
getAccount($name,$id,$longnames=0,$type='accounts',$multiple=0,$options='')
{
$accounts = createobject('phpgwapi.accounts');
$accounts->db = $GLOBALS['phpgw']->db;
! $accs = $accounts->get_list($type);
! if ($multiple < 0)
! {
! $aarr[] = lang('not assigned');
! }
while ($a = current($accs))
{
! $aarr[$a['account_id']] =
$this->accountInfo($a['account_id'],$a,$longnames,$type=='both');
next($accs);
}
! return
$this->getArrayItem($name,$id,$aarr,1,$options,$multiple);
}
! function getDate($n_year,$n_month,$n_day,$date,$options='')
{
! if (is_array($date))
! {
! list($year,$month,$day) = $date;
! }
! elseif (!$date)
{
$day = $month = $year = 0;
***************
*** 387,395 ****
$year = date('Y',$date);
}
! return
$GLOBALS['phpgw']->common->dateformatorder($this->getYears($n_year,$year),
$this->getMonthText($n_month,$month),
! $this->getDays($n_day,$day));
}
- }
! ?>
--- 556,602 ----
$year = date('Y',$date);
}
! return $GLOBALS['phpgw']->common->dateformatorder(
! $this->getYears($n_year,$year),
$this->getMonthText($n_month,$month),
! $this->getDays($n_day,$day)
! );
}
! function
getCategory($name,$cat_id='',$notall=False,$jscript=True,$multiple=0,$options='')
! {
! if (!is_object($this->cat))
! {
! $this->cat =
CreateObject('phpgwapi.categories');
! }
! if ($jscript)
! {
! $options .= ' onChange="this.form.submit();"';
! }
! if (0+$multiple > 0)
! {
! $options .= ' MULTIPLE SIZE='.(0+$multiple);
! if (substr($name,-2) != '[]')
! {
! $name .= '[]';
! }
! }
! /* Setup all and none first */
! $cats_link = "\n<SELECT NAME=\"$name\" $options>\n";
!
! if (!$notall)
! {
! $cats_link .= '<option value=""';
! if ($cat_id=='all')
! {
! $cats_link .= ' selected';
! }
! $cats_link .= '>'.lang("all")."</option>\n";
! }
!
! /* Get global and app-specific category listings */
! $cats_link .=
$this->cat->formatted_list('select','all',$cat_id,True);
! $cats_link .= '</select>'."\n";
!
! return $cats_link;
! }
! }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpgwapi/inc class.sbox2.inc.php,1.10.2.1,1.10.2.1.2.1,
Ralf Becker <address@hidden> <=