From 16ded6c03fb807138346159279b3086a65acec0d Mon Sep 17 00:00:00 2001 From: skeeter Date: Tue, 16 Oct 2001 01:31:47 +0000 Subject: [PATCH] Making use of the new portalbox. --- calendar/inc/hook_home.inc.php | 33 +++++++++- phpgwapi/inc/class.portalbox.inc.php | 93 +++++++++++++++++++++++++++- 2 files changed, 121 insertions(+), 5 deletions(-) diff --git a/calendar/inc/hook_home.inc.php b/calendar/inc/hook_home.inc.php index c8a496775f..4387a37ef7 100755 --- a/calendar/inc/hook_home.inc.php +++ b/calendar/inc/hook_home.inc.php @@ -28,7 +28,7 @@ $time = time() - ((60*60) * intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'])); $date = $GLOBALS['phpgw']->common->show_date($time,'Ymd'); $cal = CreateObject('calendar.uicalendar'); - echo "\n".'
'."\n" + $extra_data = "\n".'
' . $cal->mini_calendar( Array( 'day' => $cal->bo->day, @@ -45,7 +45,36 @@ 'month' => $cal->bo->month, 'day' => $cal->bo->day ) - ).'
'."\n\n".'
'."\n"; + ).''."\n".''."\n"; + + $title = ''.lang('Calendar').''; + + $portalbox = CreateObject('phpgwapi.listbox', + Array( + 'title' => $title, + 'primary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], + 'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], + 'tertiary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], + 'width' => '90%', + 'outerborderwidth' => '0', + 'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler.gif') + ) + ); + + $var = Array( + 'up' => Array('url' => '/set_box.php', 'app' => 'calendar'), + 'down' => Array('url' => '/set_box.php', 'app' => 'calendar'), + 'close' => Array('url' => '/set_box.php', 'app' => 'calendar'), + 'question' => Array('url' => '/set_box.php', 'app' => 'calendar'), + 'edit' => Array('url' => '/set_box.php', 'app' => 'calendar') + ); + + while(list($key,$value) = each($var)) + { + $portalbox->set_controls($key,$value); + } + + echo ''."\n".$portalbox->draw($extra_data)."\n".''."\n"; unset($cal); } flush(); diff --git a/phpgwapi/inc/class.portalbox.inc.php b/phpgwapi/inc/class.portalbox.inc.php index b0e6fab54c..7f94b4eeb3 100755 --- a/phpgwapi/inc/class.portalbox.inc.php +++ b/phpgwapi/inc/class.portalbox.inc.php @@ -29,15 +29,26 @@ var $outerwidth; var $outerbordercolor; - var $outerborderwidth; + var $outerborderwidth = 1; var $titlebgcolor; var $width; var $innerwidth; var $innerbgcolor; + var $controls; + var $header_background_image; + var $classname; + var $up; + var $down; + var $close; + var $question; + var $edit; // Textual variables var $title; + // Template + var $p; + /* Use these functions to get and set the values of this object's variables. This is good OO practice, as it means @@ -58,7 +69,7 @@ { if ($var=='' || !isset($this->$var)) { - echo 'Programming Error: '.$this->classname().'->getvar('.$var.')!
\n'; + echo 'Programming Error: '.$this->getvar('classname').'->getvar('.$var.')!
'."\n"; $GLOBALS['phpgw']->common->phpgw_exit(); } //echo "Var = ".$var."
\n"; @@ -73,9 +84,85 @@ { $this->setvar('title',$title); // echo 'After SetVar Title = '.$this->getvar('title')."
\n"; - $this->setvar('outerborderwidth',1); $this->setvar('titlebgcolor',$primary); $this->setvar('innerbgcolor',$secondary); $this->setvar('outerbordercolor',$tertiary); } + + function start_template() + { + $this->p = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('home')); + $this->p->set_file( + array( + 'PORTAL' => 'portal.tpl' + ) + ); + + $this->p->set_block('PORTAL','portal_box','portal_box'); + $this->p->set_block('PORTAL','portal_row','portal_row'); + $this->p->set_block('PORTAL','portal_listbox_header','portal_listbox_header'); + $this->p->set_block('PORTAL','portal_listbox_link','portal_listbox_link'); + $this->p->set_block('PORTAL','portal_listbox_footer','portal_listbox_footer'); + $this->p->set_block('PORTAL','portal_control','portal_control'); + $this->p->set_block('PORTAL','link_field','link_field'); + + $var = Array( + 'outer_border' => $this->getvar('outerborderwidth'), + 'outer_width' => $this->getvar('width'), + 'outer_bordercolor' => $this->getvar('outerbordercolor'), + 'outer_bgcolor' => $this->getvar('titlebgcolor'), + 'title' => $this->getvar('title'), + 'inner_width' => $this->getvar('width'), + 'inner_bgcolor' => $this->getvar('innerbgcolor'), + 'header_background_image' => $this->getvar('header_background_image'), + 'control_link' => '' + ); + $this->p->set_var($var); + $this->p->set_var('row','',False); + } + + function set_controls($control='',$control_param='') + { + if($control != '' && $control_param != '') + { + $this->setvar($control,$GLOBALS['phpgw']->link($control_param['url'],'app='.$control_param['app'].'&control='.$control)); + } + } + + function set_internal($data) + { + $this->p->set_var('output',$data); + $this->p->parse('row','portal_row',true); + } + + function draw_box() + { + $control = ''; + if($this->up || $this->down || $this->close || $this->question || $this->edit) + { + $control_array = Array( + 'up', + 'down', + 'question', + 'close', + 'edit' + ); + @reset($control_array); + while(list($key,$param) = each($control_array)) + { + if(isset($this->$param) && $this->$param) + { + $image_width = 15; + if($param == 'edit') + { + $image_width = 30; + } + $this->p->set_var('link_field_data',''.$param.''); + $this->p->parse('control_link','link_field',True); + } + } + $this->p->parse('portal_controls','portal_control',True); + } + return $this->p->fp('out','portal_box'); + } }