egroupware/felamimail/inc/class.uiwidgets.inc.php

159 lines
5.5 KiB
PHP

<?php
/***************************************************************************\
* EGroupWare - FeLaMiMail *
* http://www.linux-at-work.de *
* http://www.phpgw.de *
* http://www.egroupware.org *
* Written by : Lars Kneschke [lkneschke@linux-at-work.de] *
* ------------------------------------------------- *
* Copyright (c) 2004, Lars Kneschke *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions are *
* met: *
* *
* * Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* * Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution.*
* * Neither the name of the FeLaMiMail organization nor the names of *
* its contributors may be used to endorse or promote products derived *
* from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR*
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
\***************************************************************************/
/* $Id$ */
/**
* a class containing javascript enhanced html widgets
*
* @package FeLaMiMail
* @author Lars Kneschke
* @version 1.35
* @copyright Lars Kneschke 2004
* @license http://www.opensource.org/licenses/bsd-license.php BSD
*/
class uiwidgets
{
/**
* the contructor
*
*/
function uiwidgets()
{
$template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$this->template = $template;
$this->template->set_file(array("body" => 'uiwidgets.tpl'));
}
/**
* create multiselectbox
*
* this function will create a multiselect box. Hard to describe! :)
*
* @param _selectedValues Array of values for already selected values(the left selectbox)
* @param _predefinedValues Array of values for predefined values(the right selectbox)
* @param _valueName name for the variable containing the selected values
* @param _boxWidth the width of the multiselectbox( example: 100px, 100%)
*
* @returns the html code, to be added into the template
*/
function multiSelectBox($_selectedValues, $_predefinedValues, $_valueName, $_boxWidth="100%")
{
$this->template->set_block('body','multiSelectBox');
if(is_array($_selectedValues))
{
foreach($_selectedValues as $key => $value)
{
$options .= "<option value=\"$key\" selected=\"selected\">".@htmlspecialchars($value,ENT_QUOTES)."</option>";
}
$this->template->set_var('multiSelectBox_selected_options',$options);
}
$options = '';
if(is_array($_predefinedValues))
{
foreach($_predefinedValues as $key => $value)
{
if($key != $_selectedValues["$key"])
$options .= "<option value=\"$key\">".@htmlspecialchars($value,ENT_QUOTES)."</option>";
}
$this->template->set_var('multiSelectBox_predefinded_options',$options);
}
$this->template->set_var('multiSelectBox_valueName', $_valueName);
$this->template->set_var('multiSelectBox_boxWidth', $_boxWidth);
return $this->template->fp('out','multiSelectBox');
}
function tableView($_headValues, $_tableWidth="100%")
{
$this->template->set_block('body','tableView');
$this->template->set_block('body','tableViewHead');
if(is_array($_headValues))
{
foreach($_headValues as $head)
{
$this->template->set_var('tableHeadContent',$head);
$this->template->parse('tableView_Head','tableViewHead',True);
}
}
if(is_array($this->tableViewRows))
{
foreach($this->tableViewRows as $tableRow)
{
$rowData .= "<tr>";
foreach($tableRow as $tableData)
{
switch($tableData['type'])
{
default:
$rowData .= '<td>'.$tableData['text'].'</td>';
break;
}
}
$rowData .= "</tr>";
}
}
$this->template->set_var('tableView_width', $_tableWidth);
$this->template->set_var('tableView_Rows', $rowData);
return $this->template->fp('out','tableView');
}
function tableViewAddRow()
{
$this->tableViewRows[] = array();
end($this->tableViewRows);
return key($this->tableViewRows);
}
function tableViewAddTextCell($_rowID,$_text)
{
$this->tableViewRows[$_rowID][]= array
(
'type' => 'text',
'text' => $_text
);
}
}
?>