mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
put all pre-defined select-boxes in an extension, dont need sbox-class any more
This commit is contained in:
parent
53d5b63359
commit
53da587f5b
@ -40,14 +40,6 @@
|
||||
'date' => '', // Datefield, size='' timestamp or size=format like 'm/d/Y'
|
||||
'select' => 'Selectbox', // Selectbox ($sel_options[$name] or $content[options-$name] is array with options)
|
||||
// if size > 1 then multiple selections, size lines showed
|
||||
'select-percent' => 'Select Percentage',
|
||||
'select-priority' => 'Select Priority',
|
||||
'select-access' => 'Select Access',
|
||||
'select-country' => 'Select Country',
|
||||
'select-state' => 'Select State', // US-states
|
||||
'select-cat' => 'Select Category', // Category-Selection, size: -1=Single+All, 0=Single, >0=Multiple with size lines
|
||||
'select-account' => 'Select Account', // label=accounts(default),groups,both
|
||||
// size: -1=Single+not assigned, 0=Single, >0=Multiple
|
||||
'raw' => 'Raw', // Raw html in $content[$cell['name']]
|
||||
'file' => 'FileUpload' // show an input type='file', set the local name as ${name}_path
|
||||
);
|
||||
|
@ -410,7 +410,7 @@
|
||||
if (substr($content['name'],0,9) == 'etemplate')
|
||||
{
|
||||
$m = new editor(False);
|
||||
$additional = $m->messages + $this->etemplate->types + $this->aligns;
|
||||
$additional = $m->messages + $this->etemplate->types + $this->extensions + $this->aligns;
|
||||
}
|
||||
$msg = $this->etemplate->writeLangFile($content['name'],'en',$additional);
|
||||
}
|
||||
@ -708,7 +708,21 @@
|
||||
if (ereg('class\\.([a-zA-Z0-9_]*)_widget.inc.php',$file,$regs) &&
|
||||
($ext = $this->etemplate->loadExtension($regs[1].'.'.$app,$this->etemplate)))
|
||||
{
|
||||
$extensions[$regs[1]] = $ext;
|
||||
if (is_array($ext))
|
||||
{
|
||||
if (!is_array($extensions))
|
||||
{
|
||||
$extensions = $ext;
|
||||
}
|
||||
else
|
||||
{
|
||||
$extensions += $ext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$extensions[$regs[1]] = $ext;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $extensions;
|
||||
|
@ -27,6 +27,51 @@ class html
|
||||
//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";
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
// 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 div($content,$options='')
|
||||
{
|
||||
return "<DIV $options>\n$content</DIV>\n";
|
||||
|
472
etemplate/inc/class.select_widget.inc.php
Normal file
472
etemplate/inc/class.select_widget.inc.php
Normal file
@ -0,0 +1,472 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - eTemplate Extension - Select Widgets *
|
||||
* 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$ */
|
||||
|
||||
/*!
|
||||
@class select_widget
|
||||
@author ralfbecker
|
||||
@abstract Several select-boxes with predefined phpgw specific content.
|
||||
@discussion This widget replaces the old sbox class
|
||||
@discussion This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
|
||||
*/
|
||||
class select_widget
|
||||
{
|
||||
var $public_functions = array(
|
||||
'pre_process' => True
|
||||
);
|
||||
var $human_name = array( // this are the names for the editor
|
||||
'select-percent' => 'Select Percentage',
|
||||
'select-priority' => 'Select Priority',
|
||||
'select-access' => 'Select Access',
|
||||
'select-country' => 'Select Country',
|
||||
'select-state' => 'Select State', // US-states
|
||||
'select-cat' => 'Select Category',// Category-Selection, size: -1=Single+All, 0=Single, >0=Multiple with size lines
|
||||
'select-account' => 'Select Account', // label=accounts(default),groups,both
|
||||
// size: -1=Single+not assigned, 0=Single, >0=Multiple
|
||||
'select-month' => 'Select Month'
|
||||
);
|
||||
var $monthnames = array(
|
||||
0 => '',
|
||||
1 => 'January',
|
||||
2 => 'February',
|
||||
3 => 'March',
|
||||
4 => 'April',
|
||||
5 => 'May',
|
||||
6 => 'June',
|
||||
7 => 'July',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'October',
|
||||
11 => 'November',
|
||||
12 => 'December'
|
||||
);
|
||||
|
||||
var $countrys = array(
|
||||
'' =>'',
|
||||
'AF'=>'AFGHANISTAN',
|
||||
'AL'=>'ALBANIA',
|
||||
'DZ'=>'ALGERIA',
|
||||
'AS'=>'AMERICAN SAMOA',
|
||||
'AD'=>'ANDORRA',
|
||||
'AO'=>'ANGOLA',
|
||||
'AI'=>'ANGUILLA',
|
||||
'AQ'=>'ANTARCTICA',
|
||||
'AG'=>'ANTIGUA AND BARBUDA',
|
||||
'AR'=>'ARGENTINA',
|
||||
'AM'=>'ARMENIA',
|
||||
'AW'=>'ARUBA',
|
||||
'AU'=>'AUSTRALIA',
|
||||
'AT'=>'AUSTRIA',
|
||||
'AZ'=>'AZERBAIJAN',
|
||||
'BS'=>'BAHAMAS',
|
||||
'BH'=>'BAHRAIN',
|
||||
'BD'=>'BANGLADESH',
|
||||
'BB'=>'BARBADOS',
|
||||
'BY'=>'BELARUS',
|
||||
'BE'=>'BELGIUM',
|
||||
'BZ'=>'BELIZE',
|
||||
'BJ'=>'BENIN',
|
||||
'BM'=>'BERMUDA',
|
||||
'BT'=>'BHUTAN',
|
||||
'BO'=>'BOLIVIA',
|
||||
'BA'=>'BOSNIA AND HERZEGOVINA',
|
||||
'BW'=>'BOTSWANA',
|
||||
'BV'=>'BOUVET ISLAND',
|
||||
'BR'=>'BRAZIL',
|
||||
'IO'=>'BRITISH INDIAN OCEAN TERRITORY',
|
||||
'BN'=>'BRUNEI DARUSSALAM',
|
||||
'BG'=>'BULGARIA',
|
||||
'BF'=>'BURKINA FASO',
|
||||
'BI'=>'BURUNDI',
|
||||
'KH'=>'CAMBODIA',
|
||||
'CM'=>'CAMEROON',
|
||||
'CA'=>'CANADA',
|
||||
'CV'=>'CAPE VERDE',
|
||||
'KY'=>'CAYMAN ISLANDS',
|
||||
'CF'=>'CENTRAL AFRICAN REPUBLIC',
|
||||
'TD'=>'CHAD',
|
||||
'CL'=>'CHILE',
|
||||
'CN'=>'CHINA',
|
||||
'CX'=>'CHRISTMAS ISLAND',
|
||||
'CC'=>'COCOS (KEELING) ISLANDS',
|
||||
'CO'=>'COLOMBIA',
|
||||
'KM'=>'COMOROS',
|
||||
'CG'=>'CONGO',
|
||||
'CD'=>'CONGO, THE DEMOCRATIC REPUBLIC OF THE',
|
||||
'CK'=>'COOK ISLANDS',
|
||||
'CR'=>'COSTA RICA',
|
||||
'CI'=>'COTE D IVOIRE',
|
||||
'HR'=>'CROATIA',
|
||||
'CU'=>'CUBA',
|
||||
'CY'=>'CYPRUS',
|
||||
'CZ'=>'CZECH REPUBLIC',
|
||||
'DK'=>'DENMARK',
|
||||
'DJ'=>'DJIBOUTI',
|
||||
'DM'=>'DOMINICA',
|
||||
'DO'=>'DOMINICAN REPUBLIC',
|
||||
'TP'=>'EAST TIMOR',
|
||||
'EC'=>'ECUADOR',
|
||||
'EG'=>'EGYPT',
|
||||
'SV'=>'EL SALVADOR',
|
||||
'GQ'=>'EQUATORIAL GUINEA',
|
||||
'ER'=>'ERITREA',
|
||||
'EE'=>'ESTONIA',
|
||||
'ET'=>'ETHIOPIA',
|
||||
'FK'=>'FALKLAND ISLANDS (MALVINAS)',
|
||||
'FO'=>'FAROE ISLANDS',
|
||||
'FJ'=>'FIJI',
|
||||
'FI'=>'FINLAND',
|
||||
'FR'=>'FRANCE',
|
||||
'GF'=>'FRENCH GUIANA',
|
||||
'PF'=>'FRENCH POLYNESIA',
|
||||
'TF'=>'FRENCH SOUTHERN TERRITORIES',
|
||||
'GA'=>'GABON',
|
||||
'GM'=>'GAMBIA',
|
||||
'GE'=>'GEORGIA',
|
||||
'DE'=>'GERMANY',
|
||||
'GH'=>'GHANA',
|
||||
'GI'=>'GIBRALTAR',
|
||||
'GR'=>'GREECE',
|
||||
'GL'=>'GREENLAND',
|
||||
'GD'=>'GRENADA',
|
||||
'GP'=>'GUADELOUPE',
|
||||
'GU'=>'GUAM',
|
||||
'GT'=>'GUATEMALA',
|
||||
'GN'=>'GUINEA',
|
||||
'GW'=>'GUINEA-BISSAU',
|
||||
'GY'=>'GUYANA',
|
||||
'HT'=>'HAITI',
|
||||
'HM'=>'HEARD ISLAND AND MCDONALD ISLANDS',
|
||||
'VA'=>'HOLY SEE (VATICAN CITY STATE)',
|
||||
'HN'=>'HONDURAS',
|
||||
'HK'=>'HONG KONG',
|
||||
'HU'=>'HUNGARY',
|
||||
'IS'=>'ICELAND',
|
||||
'IN'=>'INDIA',
|
||||
'ID'=>'INDONESIA',
|
||||
'IR'=>'IRAN, ISLAMIC REPUBLIC OF',
|
||||
'IQ'=>'IRAQ',
|
||||
'IE'=>'IRELAND',
|
||||
'IL'=>'ISRAEL',
|
||||
'IT'=>'ITALY',
|
||||
'JM'=>'JAMAICA',
|
||||
'JP'=>'JAPAN',
|
||||
'JO'=>'JORDAN',
|
||||
'KZ'=>'KAZAKSTAN',
|
||||
'KE'=>'KENYA',
|
||||
'KI'=>'KIRIBATI',
|
||||
'KP'=>'KOREA, DEMOCRATIC PEOPLES REPUBLIC OF',
|
||||
'KR'=>'KOREA, REPUBLIC OF',
|
||||
'KW'=>'KUWAIT',
|
||||
'KG'=>'KYRGYZSTAN',
|
||||
'LA'=>'LAO PEOPLES DEMOCRATIC REPUBLIC',
|
||||
'LV'=>'LATVIA',
|
||||
'LB'=>'LEBANON',
|
||||
'LS'=>'LESOTHO',
|
||||
'LR'=>'LIBERIA',
|
||||
'LY'=>'LIBYAN ARAB JAMAHIRIYA',
|
||||
'LI'=>'LIECHTENSTEIN',
|
||||
'LT'=>'LITHUANIA',
|
||||
'LU'=>'LUXEMBOURG',
|
||||
'MO'=>'MACAU',
|
||||
'MK'=>'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF',
|
||||
'MG'=>'MADAGASCAR',
|
||||
'MW'=>'MALAWI',
|
||||
'MY'=>'MALAYSIA',
|
||||
'MV'=>'MALDIVES',
|
||||
'ML'=>'MALI',
|
||||
'MT'=>'MALTA',
|
||||
'MH'=>'MARSHALL ISLANDS',
|
||||
'MQ'=>'MARTINIQUE',
|
||||
'MR'=>'MAURITANIA',
|
||||
'MU'=>'MAURITIUS',
|
||||
'YT'=>'MAYOTTE',
|
||||
'MX'=>'MEXICO',
|
||||
'FM'=>'MICRONESIA, FEDERATED STATES OF',
|
||||
'MD'=>'MOLDOVA, REPUBLIC OF',
|
||||
'MC'=>'MONACO',
|
||||
'MN'=>'MONGOLIA',
|
||||
'MS'=>'MONTSERRAT',
|
||||
'MA'=>'MOROCCO',
|
||||
'MZ'=>'MOZAMBIQUE',
|
||||
'MM'=>'MYANMAR',
|
||||
'NA'=>'NAMIBIA',
|
||||
'NR'=>'NAURU',
|
||||
'NP'=>'NEPAL',
|
||||
'NL'=>'NETHERLANDS',
|
||||
'AN'=>'NETHERLANDS ANTILLES',
|
||||
'NC'=>'NEW CALEDONIA',
|
||||
'NZ'=>'NEW ZEALAND',
|
||||
'NI'=>'NICARAGUA',
|
||||
'NE'=>'NIGER',
|
||||
'NG'=>'NIGERIA',
|
||||
'NU'=>'NIUE',
|
||||
'NF'=>'NORFOLK ISLAND',
|
||||
'MP'=>'NORTHERN MARIANA ISLANDS',
|
||||
'NO'=>'NORWAY',
|
||||
'OM'=>'OMAN',
|
||||
'PK'=>'PAKISTAN',
|
||||
'PW'=>'PALAU',
|
||||
'PS'=>'PALESTINIAN TERRITORY, OCCUPIED',
|
||||
'PA'=>'PANAMA',
|
||||
'PG'=>'PAPUA NEW GUINEA',
|
||||
'PY'=>'PARAGUAY',
|
||||
'PE'=>'PERU',
|
||||
'PH'=>'PHILIPPINES',
|
||||
'PN'=>'PITCAIRN',
|
||||
'PL'=>'POLAND',
|
||||
'PT'=>'PORTUGAL',
|
||||
'PR'=>'PUERTO RICO',
|
||||
'QA'=>'QATAR',
|
||||
'RE'=>'REUNION',
|
||||
'RO'=>'ROMANIA',
|
||||
'RU'=>'RUSSIAN FEDERATION',
|
||||
'RW'=>'RWANDA',
|
||||
'SH'=>'SAINT HELENA',
|
||||
'KN'=>'SAINT KITTS AND NEVIS',
|
||||
'LC'=>'SAINT LUCIA',
|
||||
'PM'=>'SAINT PIERRE AND MIQUELON',
|
||||
'VC'=>'SAINT VINCENT AND THE GRENADINES',
|
||||
'WS'=>'SAMOA',
|
||||
'SM'=>'SAN MARINO',
|
||||
'ST'=>'SAO TOME AND PRINCIPE',
|
||||
'SA'=>'SAUDI ARABIA',
|
||||
'SN'=>'SENEGAL',
|
||||
'SC'=>'SEYCHELLES',
|
||||
'SL'=>'SIERRA LEONE',
|
||||
'SG'=>'SINGAPORE',
|
||||
'SK'=>'SLOVAKIA',
|
||||
'SI'=>'SLOVENIA',
|
||||
'SB'=>'SOLOMON ISLANDS',
|
||||
'SO'=>'SOMALIA',
|
||||
'ZA'=>'SOUTH AFRICA',
|
||||
'GS'=>'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS',
|
||||
'ES'=>'SPAIN',
|
||||
'LK'=>'SRI LANKA',
|
||||
'SD'=>'SUDAN',
|
||||
'SR'=>'SURINAME',
|
||||
'SJ'=>'SVALBARD AND JAN MAYEN',
|
||||
'SZ'=>'SWAZILAND',
|
||||
'SE'=>'SWEDEN',
|
||||
'CH'=>'SWITZERLAND',
|
||||
'SY'=>'SYRIAN ARAB REPUBLIC',
|
||||
'TW'=>'TAIWAN, PROVINCE OF CHINA',
|
||||
'TJ'=>'TAJIKISTAN',
|
||||
'TZ'=>'TANZANIA, UNITED REPUBLIC OF',
|
||||
'TH'=>'THAILAND',
|
||||
'TG'=>'TOGO',
|
||||
'TK'=>'TOKELAU',
|
||||
'TO'=>'TONGA',
|
||||
'TT'=>'TRINIDAD AND TOBAGO',
|
||||
'TN'=>'TUNISIA',
|
||||
'TR'=>'TURKEY',
|
||||
'TM'=>'TURKMENISTAN',
|
||||
'TC'=>'TURKS AND CAICOS ISLANDS',
|
||||
'TV'=>'TUVALU',
|
||||
'UG'=>'UGANDA',
|
||||
'UA'=>'UKRAINE',
|
||||
'AE'=>'UNITED ARAB EMIRATES',
|
||||
'GB'=>'UNITED KINGDOM',
|
||||
'US'=>'UNITED STATES',
|
||||
'UM'=>'UNITED STATES MINOR OUTLYING ISLANDS',
|
||||
'UY'=>'URUGUAY',
|
||||
'UZ'=>'UZBEKISTAN',
|
||||
'VU'=>'VANUATU',
|
||||
'VE'=>'VENEZUELA',
|
||||
'VN'=>'VIET NAM',
|
||||
'VG'=>'VIRGIN ISLANDS, BRITISH',
|
||||
'VI'=>'VIRGIN ISLANDS, U.S.',
|
||||
'WF'=>'WALLIS AND FUTUNA',
|
||||
'EH'=>'WESTERN SAHARA',
|
||||
'YE'=>'YEMEN',
|
||||
'YU'=>'YUGOSLAVIA',
|
||||
'ZM'=>'ZAMBIA',
|
||||
'ZW'=>'ZIMBABWE'
|
||||
);
|
||||
|
||||
var $states = array(
|
||||
//'' => lang('Select one'),
|
||||
'--' => 'non US',
|
||||
'AL' => 'Alabama',
|
||||
'AK' => 'Alaska',
|
||||
'AZ' => 'Arizona',
|
||||
'AR' => 'Arkansas',
|
||||
'CA' => 'California',
|
||||
'CO' => 'Colorado',
|
||||
'CT' => 'Connecticut',
|
||||
'DE' => 'Delaware',
|
||||
'DC' => 'District of Columbia',
|
||||
'FL' => 'Florida',
|
||||
'GA' => 'Georgia',
|
||||
'HI' => 'Hawaii',
|
||||
'ID' => 'Idaho',
|
||||
'IL' => 'Illinois',
|
||||
'IN' => 'Indiana',
|
||||
'IA' => 'Iowa',
|
||||
'KS' => 'Kansas',
|
||||
'KY' => 'Kentucky',
|
||||
'LA' => 'Louisiana',
|
||||
'ME' => 'Maine',
|
||||
'MD' => 'Maryland',
|
||||
'MA' => 'Massachusetts',
|
||||
'MI' => 'Michigan',
|
||||
'MN' => 'Minnesota',
|
||||
'MO' => 'Missouri',
|
||||
'MS' => 'Mississippi',
|
||||
'MT' => 'Montana',
|
||||
'NC' => 'North Carolina',
|
||||
'ND' => 'Noth Dakota',
|
||||
'NE' => 'Nebraska',
|
||||
'NH' => 'New Hampshire',
|
||||
'NJ' => 'New Jersey',
|
||||
'NM' => 'New Mexico',
|
||||
'NV' => 'Nevada',
|
||||
'NY' => 'New York',
|
||||
'OH' => 'Ohio',
|
||||
'OK' => 'Oklahoma',
|
||||
'OR' => 'Oregon',
|
||||
'PA' => 'Pennsylvania',
|
||||
'RI' => 'Rhode Island',
|
||||
'SC' => 'South Carolina',
|
||||
'SD' => 'South Dakota',
|
||||
'TN' => 'Tennessee',
|
||||
'TX' => 'Texas',
|
||||
'UT' => 'Utah',
|
||||
'VA' => 'Virginia',
|
||||
'VT' => 'Vermont',
|
||||
'WA' => 'Washington',
|
||||
'WI' => 'Wisconsin',
|
||||
'WV' => 'West Virginia',
|
||||
'WY' => 'Wyoming'
|
||||
);
|
||||
|
||||
function select_widget($ui)
|
||||
{
|
||||
}
|
||||
|
||||
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
||||
{
|
||||
//echo "<p>nextmatch_widget.pre_process: value = "; _debug_array($value);
|
||||
// save values in persistent extension_data to be able use it in post_process
|
||||
//$extension_data = $value;
|
||||
|
||||
list($rows,$type) = explode(',',$cell['size']);
|
||||
|
||||
switch ($cell['type'])
|
||||
{
|
||||
case 'select-percent':
|
||||
for ($i=0; $i <= 100; $i+=10)
|
||||
{
|
||||
$cell['sel_options'][$i] = "$i%";
|
||||
}
|
||||
$value = intval(($value+5) / 10) * 10;
|
||||
$cell['no_lang'] = True;
|
||||
break;
|
||||
|
||||
case 'select-priority':
|
||||
$cell['sel_options'] = array('','low','normal','high');
|
||||
break;
|
||||
|
||||
case 'select-access':
|
||||
$cell['sel_options'] = array(
|
||||
'private' => 'Private',
|
||||
'public' => 'Global public',
|
||||
'group' => 'Group public'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select-country':
|
||||
$cell['sel_options'] = $this->countrys;
|
||||
$cell['no_lang'] = True;
|
||||
break;
|
||||
|
||||
case 'select-state':
|
||||
$cell['sel_options'] = $this->states;
|
||||
$cell['no_lang'] = True;
|
||||
break;
|
||||
|
||||
case 'select-cat':
|
||||
if (!is_object($GLOBALS['phpgw']->categories))
|
||||
{
|
||||
$GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories');
|
||||
}
|
||||
if ($type != 'all')
|
||||
{
|
||||
$cats = $GLOBALS['phpgw']->categories->return_array($type,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cats = $GLOBALS['phpgw']->categories->return_sorted_array(0);
|
||||
}
|
||||
while (list(,$cat) = @each($cats))
|
||||
{
|
||||
for ($j=0,$s=''; $j < $cat['level']; $j++)
|
||||
{
|
||||
$s .= ' ';
|
||||
}
|
||||
$s .= $GLOBALS['phpgw']->strip_html($cat['name']);
|
||||
if ($cat['app_name'] == 'phpgw')
|
||||
{
|
||||
$s .= ' <' . lang('Global') . '>';
|
||||
}
|
||||
if ($cat['owner'] == '-1')
|
||||
{
|
||||
$s .= ' <' . lang('Global') . ' ' . lang($this->app_name) . '>';
|
||||
}
|
||||
$cell['sel_options'][$cat['id']] = $s;
|
||||
}
|
||||
$cell['no_lang'] = True;
|
||||
break;
|
||||
|
||||
case 'select-account':
|
||||
$accs = $GLOBALS['phpgw']->accounts->get_list(empty($type) ? 'accounts' : $type); // default is accounts
|
||||
|
||||
while (list(,$acc) = each($accs))
|
||||
{
|
||||
$cell['sel_options'][$acc['account_id']] = $this->accountInfo($a['account_id'],$a,$longnames,$type=='both');
|
||||
}
|
||||
$cell['no_lang'] = True;
|
||||
break;
|
||||
|
||||
case 'select-month':
|
||||
$cell['sel_options'] = $this->monthnames;
|
||||
break;
|
||||
}
|
||||
return True; // extra Label Ok
|
||||
}
|
||||
|
||||
function accountInfo($id,$account_data=0,$longnames=0,$show_type=0)
|
||||
{
|
||||
if (!$id)
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
|
||||
if (!is_array($account_data))
|
||||
{
|
||||
$accounts = createobject('phpgwapi.accounts',$id);
|
||||
$accounts->db = $GLOBALS['phpgw']->db;
|
||||
$accounts->read_repository();
|
||||
$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;
|
||||
}
|
||||
}
|
@ -26,13 +26,13 @@
|
||||
@example if the user submitts the form. Vor the complete param's see the description of exec.
|
||||
@param $debug enables debug messages: 0=no, 1=calls to show and process_show, 2=content of process_show
|
||||
@param 3=calls to show_cell OR template- or cell-type name
|
||||
@param $html,$sbox instances of html and sbox2 class used to generate the html
|
||||
@param $html instances of html class used to generate the html
|
||||
*/
|
||||
class etemplate extends boetemplate
|
||||
{
|
||||
var $debug; // 1=calls to show and process_show, 2=content after process_show,
|
||||
// 3=calls to show_cell and process_show_cell, or template-name or cell-type
|
||||
var $html,$sbox; // instance of html / sbox2-class
|
||||
var $html; // instance of html-class
|
||||
var $class_conf = array('nmh' => 'th','nmr0' => 'row_on','nmr1' => 'row_off');
|
||||
|
||||
/*!
|
||||
@ -50,7 +50,6 @@
|
||||
'process_show' => True,
|
||||
);
|
||||
$this->html = CreateObject('etemplate.html'); // should be in the api (older version in infolog)
|
||||
$this->sbox = CreateObject('etemplate.sbox2'); // older version is in the api
|
||||
|
||||
$this->boetemplate($name,$load_via);
|
||||
|
||||
@ -342,11 +341,7 @@
|
||||
}
|
||||
$name = $this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
||||
|
||||
/*if (strstr($name,'|')) // extension which uses whole content array
|
||||
{
|
||||
$value = $content;
|
||||
}
|
||||
else*/if (ereg('^([^[]*)(\\[.*\\])$',$name,$regs)) // name contains array-index
|
||||
if (ereg('^([^[]*)(\\[.*\\])$',$name,$regs)) // name contains array-index
|
||||
{
|
||||
$form_name = $cname == '' ? $name : $cname.'['.$regs[1].']'.$regs[2];
|
||||
eval(str_replace(']',"']",str_replace('[',"['",'$value = $content['.$regs[1].']'.$regs[2].';')));
|
||||
@ -372,16 +367,13 @@
|
||||
}
|
||||
$extra_label = True;
|
||||
|
||||
if (!$this->types[$cell['type']] && $this->haveExtension($cell['type'],'pre_process'))
|
||||
list($type,$sub_type) = explode('-',$cell['type']);
|
||||
if ((!$this->types[$cell['type']] || !empty($sub_type)) && $this->haveExtension($type,'pre_process'))
|
||||
{
|
||||
$ext_type = $cell['type'];
|
||||
$ext_type = $type;
|
||||
$extra_label = $this->extensionPreProcess($ext_type,$form_name,$value,$cell,$readonlys[$name]);
|
||||
|
||||
/*if (strstr($name,'|'))
|
||||
{
|
||||
$content = $this->complete_array_merge($content,$value);
|
||||
}
|
||||
else*/if (!$regs)
|
||||
if (!$regs)
|
||||
{
|
||||
$content[$name] = $value; // set result for template
|
||||
}
|
||||
@ -417,7 +409,8 @@
|
||||
$options .= ' onChange="'.($cell['onchange']=='1'?'this.form.submit();':$cell['onchange']).'"';
|
||||
}
|
||||
}
|
||||
switch ($cell['type'])
|
||||
list($type,$sub_type) = explode('-',$cell['type']);
|
||||
switch ($type)
|
||||
{
|
||||
case 'label': // size: [[b]old][[i]talic]
|
||||
$value = strlen($value) > 1 && !$cell['no_lang'] ? lang($value) : $value;
|
||||
@ -455,22 +448,47 @@
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
break;
|
||||
case 'checkbox':
|
||||
if (!empty($cell['size']))
|
||||
{
|
||||
list($true_val,$false_val,$ro_true,$ro_false) = explode(',',$cell['size']);
|
||||
$value = $value == $true_val;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ro_true = 'x';
|
||||
$ro_false = '';
|
||||
}
|
||||
if ($value)
|
||||
{
|
||||
$options .= ' CHECKED';
|
||||
}
|
||||
$html .= $this->html->input($form_name,'1','CHECKBOX',$options);
|
||||
if (!$readonly)
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
if ($readonly)
|
||||
{
|
||||
$html .= $value ? $this->html->bold($ro_true) : $ro_false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$html .= $this->html->input($form_name,'1','CHECKBOX',$options);
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = array(
|
||||
'type' => $cell['type'],
|
||||
'values' => $cell['size']
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'radio': // size: value if checked
|
||||
if ($value == $cell['size'])
|
||||
{
|
||||
$options .= ' CHECKED';
|
||||
}
|
||||
$html .= $this->html->input($form_name,$cell['size'],'RADIO',$options);
|
||||
if (!$readonly)
|
||||
if ($readonly)
|
||||
{
|
||||
$html .= $value == $cell['size'] ? $this->html->bold('x') : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$html .= $this->html->input($form_name,$cell['size'],'RADIO',$options);
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
}
|
||||
break;
|
||||
case 'button':
|
||||
if ($this->java_script() && $cell['onchange'])
|
||||
@ -548,62 +566,47 @@
|
||||
$html .= $cell['obj']->show($content,$sel_options,$readonlys,$cname,$show_c,$show_row);
|
||||
break;
|
||||
case 'select': // size:[linesOnMultiselect]
|
||||
if (isset($sel_options[$name]))
|
||||
if (!empty($cell['sel_options']))
|
||||
{
|
||||
if (!is_array($cell))
|
||||
{
|
||||
$sel_options = array();
|
||||
$opts = explode(',',$cell['sel_options']);
|
||||
while (list(,$opt) = each($opts))
|
||||
{
|
||||
list($k,$v) = explode('=',$opt);
|
||||
$sel_options[$k] = $v;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sel_options = $cell['sel_options'];
|
||||
}
|
||||
}
|
||||
elseif (isset($sel_options[$name]))
|
||||
{
|
||||
$sel_options = $sel_options[$name];
|
||||
}
|
||||
elseif (isset($sel_options[$org_name]))
|
||||
{
|
||||
$sel_options = $sel_options[$org_name];
|
||||
} elseif (isset($content["options-$name"]))
|
||||
}
|
||||
elseif (isset($content["options-$name"]))
|
||||
{
|
||||
$sel_options = $content["options-$name"];
|
||||
}
|
||||
$html .= $this->sbox->getArrayItem($form_name.'[]',$value,$sel_options,$cell['no_lang'],
|
||||
$options,$cell['size']);
|
||||
if (!$readonly)
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
break;
|
||||
case 'select-percent':
|
||||
$html .= $this->sbox->getPercentage($form_name,$value,$options);
|
||||
if (!$readonly)
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
break;
|
||||
case 'select-priority':
|
||||
$html .= $this->sbox->getPriority($form_name,$value,$options);
|
||||
if (!$readonly)
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
break;
|
||||
case 'select-access':
|
||||
$html .= $this->sbox->getAccessList($form_name,$value,$options);
|
||||
if (!$readonly)
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
break;
|
||||
case 'select-country':
|
||||
$html .= $this->sbox->getCountry($form_name,$value,$options);
|
||||
if (!$readonly)
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
break;
|
||||
case 'select-state':
|
||||
$html .= $this->sbox->list_states($form_name,$value); // no helptext - old Function!!!
|
||||
if (!$readonly)
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
break;
|
||||
case 'select-cat':
|
||||
$html .= $this->sbox->getCategory($form_name.'[]',$value,$cell['size'] >= 0,
|
||||
False,$cell['size'],$options);
|
||||
if (!$readonly)
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
break;
|
||||
case 'select-account':
|
||||
$type = substr(strstr($cell['size'],','),1);
|
||||
if ($type == '')
|
||||
list($multiple) = explode(',',$cell['size']);
|
||||
|
||||
if ($readonly)
|
||||
{
|
||||
$type = 'accounts'; // default is accounts
|
||||
$html .= $cell['no_lang'] ? $sel_options[$value] : lang($sel_options[$value]);
|
||||
}
|
||||
$html .= $this->sbox->getAccount($form_name.'[]',$value,2,$type,0+$cell['size'],$options);
|
||||
if (!$readonly)
|
||||
else
|
||||
{
|
||||
$html .= $this->html->select($form_name.($multiple > 1 ? '[]' : ''),$value,$sel_options,
|
||||
$cell['no_lang'],$options,$multiple);
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
|
||||
}
|
||||
break;
|
||||
case 'image':
|
||||
$image = $this->html->image(substr($this->name,0,strpos($this->name,'.')),
|
||||
@ -630,7 +633,8 @@
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ($ext_type && !$readonly) // extension-processing need to be after all other
|
||||
if ($ext_type && !$readonly && // extension-processing need to be after all other and only with diff. name
|
||||
!isset($GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name]))
|
||||
{
|
||||
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = 'ext-'.$ext_type;
|
||||
}
|
||||
@ -677,14 +681,24 @@
|
||||
}
|
||||
if ($this->debug >= 1 || $this->debug == $this->name && $this->name)
|
||||
{
|
||||
echo "<p>process_show($this->name) start: content ="; _debug_array($GLOBALS['HTTP_POST_VARS']/*$content*/);
|
||||
echo "<p>process_show($this->name) start: content ="; _debug_array($content);
|
||||
}
|
||||
$content_in = $cname ? array($cname => $content) : $content;
|
||||
$content = array();
|
||||
reset($to_process);
|
||||
while (list($form_name,$type) = each($to_process))
|
||||
{
|
||||
if (is_array($type))
|
||||
{
|
||||
$attr = $type;
|
||||
$type = $attr['type'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$attr = array();
|
||||
}
|
||||
$value = $this->get_array($content_in,$form_name);
|
||||
//echo "<p>process_show($this->name) $type: $form_name = '$value'</p>\n";
|
||||
list($type,$sub) = explode('-',$type);
|
||||
switch ($type)
|
||||
{
|
||||
@ -713,6 +727,11 @@
|
||||
{
|
||||
$value = 0; // need to be reported too
|
||||
}
|
||||
if (!empty($attr['values']))
|
||||
{
|
||||
list($true_val,$false_val) = explode(',',$attr['values']);
|
||||
$value = $value ? $true_val : $false_val;
|
||||
}
|
||||
$this->set_array($content,$form_name,$value);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user