egroupware/phpgwapi/inc/class.portalbox.inc.php

188 lines
5.2 KiB
PHP
Raw Normal View History

<?php
2002-10-03 23:38:11 +02:00
/**************************************************************************\
* phpGroupWare API - Portal Box manager *
* Written by Joseph Engo <jengo@phpgroupware.org> *
2003-05-22 01:12:44 +02:00
* and Bettina Gille [ceb@phpgroupware.org] *
2002-10-03 23:38:11 +02:00
* Helps manage the portal boxes for phpGroupWares main page *
2003-05-22 01:12:44 +02:00
* Copyright (C) 2000, 2001 Joseph Engo *
* Copyright (C) 2002, 2003 Bettina Gille *
2002-10-03 23:38:11 +02:00
* ------------------------------------------------------------------------ *
* This library is part of the phpGroupWare API *
2003-04-30 04:13:17 +02:00
* http://www.phpgroupware.org *
2002-10-03 23:38:11 +02:00
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
2001-10-02 07:10:14 +02:00
class portalbox
{
//Set up the Object, reserving memory space for variables
2002-10-06 00:00:25 +02:00
var $app_name;
2002-10-06 18:18:03 +02:00
var $app_id;
2001-10-16 03:31:47 +02:00
var $up;
var $down;
var $close;
var $question;
var $edit;
2002-10-03 23:38:11 +02:00
2002-10-25 18:44:35 +02:00
var $extrabox;
var $xextrabox;
var $listbox;
2002-10-03 23:38:11 +02:00
var $output;
2002-10-25 18:44:35 +02:00
var $data;
2001-10-02 07:10:14 +02:00
// Textual variables
var $title;
/* This is the constructor for the object. */
2002-10-25 23:40:09 +02:00
function portalbox($reset = False)
{
2002-10-26 02:33:22 +02:00
$this->title = '';
$this->app_name = '';
$this->app_id = 0;
2002-10-25 18:44:35 +02:00
2002-10-26 02:33:22 +02:00
$this->up = '';
$this->down = '';
$this->close = '';
$this->question = '';
$this->edit = '';
2002-10-25 18:44:35 +02:00
2002-10-26 02:33:22 +02:00
$this->extrabox = '';
$this->xextrabox = '';
$this->listbox = '';
$this->data = array();
2002-10-25 23:40:09 +02:00
if (!$reset)
{
2002-10-26 02:33:22 +02:00
$this->output = array();
2002-10-25 23:40:09 +02:00
}
2002-10-30 00:35:02 +01:00
$GLOBALS['phpgw']->xslttpl->add_file('portal');
}
2001-10-02 07:10:14 +02:00
/*
Use these functions to get and set the values of this
object's variables. This is good OO practice, as it means
that datatype checking can be completed and errors raised accordingly.
*/
function setvar($var,$value='')
{
if ($value=='')
{
global $$var;
$value = $$var;
}
$this->$var = $value;
// echo $var." = ".$this->$var."<br>\n";
}
function getvar($var='')
{
if ($var=='' || !isset($this->$var))
{
2001-10-16 03:31:47 +02:00
echo 'Programming Error: '.$this->getvar('classname').'->getvar('.$var.')!<br>'."\n";
$GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
exit;
2001-10-02 07:10:14 +02:00
}
//echo "Var = ".$var."<br>\n";
//echo $var." = ".$this->$var."<br>\n";
return $this->$var;
}
2002-12-01 04:35:02 +01:00
function start_template()
2001-10-16 03:31:47 +02:00
{
2002-12-01 04:35:02 +01:00
if ($this->app_name)
2002-10-06 00:00:25 +02:00
{
2002-10-30 00:35:02 +01:00
$GLOBALS['phpgw']->xslttpl->add_file($GLOBALS['phpgw']->common->get_tpl_dir($this->app_name,'default') . SEP . 'extrabox');
2002-10-06 00:00:25 +02:00
}
2001-10-16 03:31:47 +02:00
}
function set_controls($control='',$control_param='')
{
2002-10-03 23:38:11 +02:00
//echo '<br>Control: ' . $control . ', control_param="' . $control_param . '"';
if($control != '' && is_array($control_param))
2001-10-16 03:31:47 +02:00
{
$this->setvar($control,$GLOBALS['phpgw']->link($control_param['url'],'app='.$control_param['app'].'&control='.$control));
}
}
2002-10-07 00:28:41 +02:00
function set_internal($extra_data = '')
2001-10-16 03:31:47 +02:00
{
2002-10-07 00:28:41 +02:00
if($extra_data !='')
{
2002-10-25 18:44:35 +02:00
$this->extrabox = $extra_data;
}
2001-10-16 03:31:47 +02:00
}
2002-10-07 00:28:41 +02:00
function set_xinternal($extra_data='')
2002-10-06 01:40:51 +02:00
{
2002-10-07 00:28:41 +02:00
if($extra_data !='')
2002-10-06 01:40:51 +02:00
{
2002-10-25 18:44:35 +02:00
$this->xextrabox = $extra_data;
2002-10-06 01:40:51 +02:00
}
}
2001-10-16 03:31:47 +02:00
function draw_box()
{
if($this->up || $this->down || $this->close || $this->question || $this->edit)
{
2002-10-03 23:38:11 +02:00
$control_array = array
(
2001-10-16 03:31:47 +02:00
'up',
'down',
'question',
'close',
'edit'
);
2003-04-30 04:13:17 +02:00
if ($GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'] == 'funkwerk')
{
$up =
$down = '[->]';
$question = '[?]';
$close = '[x]';
$edit = '[' . lang('edit') . ']';
}
2001-10-16 03:31:47 +02:00
@reset($control_array);
while(list($key,$param) = each($control_array))
{
if(isset($this->$param) && $this->$param)
{
2002-10-03 23:38:11 +02:00
$control_link[] = array
(
'param_url' => $this->$param,
'link_img' => $GLOBALS['phpgw']->common->image('phpgwapi',$param.'.button'),
2003-04-30 04:13:17 +02:00
'link_icon' => '[ ' . lang($param) . ' ]',
'img_width' => ($param=='edit'?'30':'15'),
2002-10-03 23:38:11 +02:00
'lang_param_statustext' => lang($param)
);
2001-10-16 03:31:47 +02:00
}
}
2002-10-03 23:38:11 +02:00
2002-10-25 18:44:35 +02:00
$this->output['portal_data'][] = array
(
'title' => $this->title,
'control_link' => $control_link,
'listbox' => $this->listbox,
'extrabox' => $this->extrabox,
'xextrabox' => $this->xextrabox
);
2001-10-16 03:31:47 +02:00
}
}
2001-10-02 07:10:14 +02:00
}
2002-10-25 18:44:35 +02:00
?>