openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 9e617e60345ad55cd7ae2829d246d2ecb6c06128
parent 3f83cf419e93d80c1486134125121c7c88009a16
Author: dankert <devnull@localhost>
Date:   Sun,  8 Apr 2007 16:35:31 +0200

Korrektur der Template-Engine.

Diffstat:
serviceClasses/TemplateEngine.class.php | 53+++++++++++++++++++++++++++++------------------------
themes/default/include/elements.ini.php | 6+++---
themes/default/include/html/checkbox.inc.php | 11++++-------
themes/default/include/html/list.inc.php | 4+---
themes/default/include/html/radio.inc.php | 4++--
themes/default/templates/object/aclform.tpl.src.php | 27+++++++++++++++------------
themes/default/templates/object/rights.tpl.src.php | 70+++++++++++++++++++++++++++-------------------------------------------
7 files changed, 81 insertions(+), 94 deletions(-)

diff --git a/serviceClasses/TemplateEngine.class.php b/serviceClasses/TemplateEngine.class.php @@ -139,7 +139,13 @@ class TemplateEngine } else { - return "'".$value."'"; + // Sonderfälle für die Attributwerte "true" und "false". + // Hinweis: Die Zeichenkette "false" entspricht in PHP true. + // Siehe http://de.php.net/manual/de/language.types.boolean.php + if ( $value == 'true' || $value == 'false' ) + return $value; + else + return "'".$value."'"; } } @@ -210,6 +216,7 @@ class TemplateEngine */ function checkAttributes( $cmd,$attr ) { +// Html::debug($cmd,'cmd'); global $conf; $elements = parse_ini_file( OR_THEMES_DIR.$conf['interface']['theme'].'/include/elements.ini.'.PHP_EXT); @@ -217,41 +224,39 @@ class TemplateEngine die( 'parser error: unknown element: '.$cmd ); $checkedAttr = array(); - + + // Schleife über alle Attribute. foreach( explode(',',$elements[$cmd]) as $al ) { $al=trim($al); if ( $al=='') - continue; + continue; // Leeres Attribut... nicht zu gebrauchen. + - list($a,$default) = explode(':',$al,2) + array('',''); - $default = str_replace('COMMA',',',$default); // Komma in Default-Werten ersetzen. + $pair = explode(':',$al,2); + if ( count($pair) == 1 ) $pair[] = null; + list($a,$default) = $pair; + + if ( is_string($default)) + $default = str_replace('COMMA',',',$default); // Komma in Default-Werten ersetzen. + if ( isset($attr[$a])) - $checkedAttr[$a]=$attr[$a]; + $checkedAttr[$a]=$attr[$a]; // Attribut ist bereits vorhanden, alles ok. + elseif ( $default=='*') // Pflichtfeld! + die( 'required attribute not found, element= '.$cmd.', attribute='.$a ); + elseif ( !is_null($default) ) + $checkedAttr[$a]=$default; else - if ( $default=='*') - die( 'required attribute not found, element= '.$cmd.', attribute='.$a ); - else - if ( !empty($default) ) - $checkedAttr[$a]=$default; - unset( $attr[$a] ); - - // Sonderfälle für die Attributwerte "true" und "false". - // Hinweis: Die Zeichenkette "false" entspricht in PHP true. - // Siehe http://de.php.net/manual/de/language.types.boolean.php - if ( isset($checkedAttr[$a])) - { - if ( $checkedAttr[$a] == 'true') - $checkedAttr[$a] = true; - elseif ( $checkedAttr[$a] == 'false') - $checkedAttr[$a] = false; - } + ; + + unset( $attr[$a] ); // Damit am Ende das Urprungsarray leer wird. } +// Html::debug($checkedAttr,'cattr'); if ( count($attr) > 0 ) { foreach($attr as $name=>$value) - die( 'unknown attribute, element= '.$cmd.', attribute='.$name.', known attributes='.$elements[$cmd] ); + die( 'unknown attribute, element= '.$cmd.', attribute='.$name.', known attributes='.$elements[$cmd]."\n" ); } return $checkedAttr; diff --git a/themes/default/include/elements.ini.php b/themes/default/include/elements.ini.php @@ -29,11 +29,11 @@ logo = name:* newline = page = class:main,title:var:cms_title,menu password = name:*,default:,class:,size:40,maxlength:256 -radio = readonly,name:*,value,default,prefix,suffix +radio = readonly:false,name:*,value,default:false,prefix:,suffix:,class:,onchange: raw = row = class -selectbox=list:*,name:*,default,onchange:,title:,class: -listbox =list:*,name:*,default,onchange:,title:,class: +selectbox=list:*,name:*,default:,onchange:,title:,class: +listbox =list:*,name:*,default:,onchange:,title:,class: set = var:*,value:* table = class,width:100%,space:0px,padding:0px,widths,rowclasses:oddCOMMAeven,columnclasses text = title,class:text,var,text,key,textvar,raw,maxlength,value,suffix,prefix diff --git a/themes/default/include/html/checkbox.inc.php b/themes/default/include/html/checkbox.inc.php @@ -1,9 +1,6 @@ <?php - $attr_default = ( $attr_default == true ); - if ( isset($$attr_name) ) - $checked = $$attr_name == true; -// $checked = isset($$$attr_name)&& $$$attr_name==true; + $checked = $$attr_name; else - $checked = $attr_default == true; -?><input type="checkbox" id="id_<?php echo $attr_name ?>" name="<?php echo $attr_name ?>" <?php if ($attr_readonly) echo ' disabled="disabled"' ?> value="1" <?php if( $checked ) echo 'checked="checked"' ?> /><?php unset($attr_name); unset($attr_readonly); unset($attr_default); ?>- \ No newline at end of file + $checked = $attr_default; +?><input type="checkbox" id="id_<?php echo $attr_name ?>" name="<?php echo $attr_name ?>" <?php if ($attr_readonly) echo ' disabled="disabled"' ?> value="1" <?php if( $checked ) echo 'checked="checked"' ?> /><?php unset($attr_name); unset($attr_readonly); unset($attr_default); ?>+ \ No newline at end of file diff --git a/themes/default/include/html/list.inc.php b/themes/default/include/html/list.inc.php @@ -1,12 +1,10 @@ <?php $attr_list_tmp_key = $attr_key; $attr_list_tmp_value = $attr_value; - $attr_list_extract = ($attr_extract==true); + $attr_list_extract = $attr_extract; if ( !isset($$attr_list) || !is_array($$attr_list) ) $$attr_list = array(); -// die('not an array in list,var='.$attr_list); -// Html::debug($$attr_list); foreach( $$attr_list as $$attr_list_tmp_key => $$attr_list_tmp_value ) { diff --git a/themes/default/include/html/radio.inc.php b/themes/default/include/html/radio.inc.php @@ -1 +1 @@ -<input type="radio" id="id_<?php echo $attr_name.'_'.$attr_value ?>" name="<?php echo $attr_prefix.$attr_name ?>"<?php if ( $attr_readonly ) echo ' disabled="disabled"' ?> value="<?php echo $attr_value ?>" <?php if($attr_value==$default) echo 'checked="checked"' ?> />- \ No newline at end of file +<input type="radio" id="id_<?php echo $attr_name.'_'.$attr_value ?>" name="<?php echo $attr_prefix.$attr_name ?>"<?php if ( $attr_readonly ) echo ' disabled="disabled"' ?> value="<?php echo $attr_value ?>" <?php if($attr_value==$attr_default) echo 'checked="checked"' ?> />+ \ No newline at end of file diff --git a/themes/default/templates/object/aclform.tpl.src.php b/themes/default/templates/object/aclform.tpl.src.php @@ -8,16 +8,14 @@ page cell class:fx text text:GLOBAL_ALL cell class:fx - set var:type value:all - radio name:type value:type default:true + radio name:type value:all default:true cell class:fx text raw:_ row cell class:fx text text:GLOBAL_USER cell class:fx - set var:type value:user - radio name:type value:type + radio name:type value:user cell class:fx selectbox name:userid list:users if present:groups @@ -25,8 +23,7 @@ page cell class:fx text text:GLOBAL_GROUP cell class:fx - set var:type value:group - radio name:type value:type + radio name:type value:group cell class:fx selectbox name:groupid list:groups row @@ -43,13 +40,19 @@ page cell colspan:3 class:help text raw:_ - list list:show value:t + list list:show value:t key:k row -RAW -<td class="<?php echo $fx ?>"><?php echo lang('ACL_'.strtoupper($t)) ?></td> -<td class="<?php echo $fx ?>" width="20"><?php echo lang('ACL_'.strtoupper($t).'_ABBREV') ?></td> -<td class="<?php echo $fx ?>"><?php echo Html::checkBox($t,($t=='read'),($t!='read'),array('title'=>lang('ACL_'.strtoupper($t) )) ) ?></td> -END + cell + text key:var:t prefix:acl_ + cell width:20px + text key:var:t prefix:acl_ suffix:_abbrev + cell + if value:var:t equals:read + set var:var:t value:true + checkbox name:var:t readonly:true + else + set var:var:t value:false + checkbox name:var:t readonly:false row cell colspan:3 class:act button type:ok diff --git a/themes/default/templates/object/rights.tpl.src.php b/themes/default/templates/object/rights.tpl.src.php @@ -6,58 +6,42 @@ page row cell class:fx text text:GLOBAL_NOT_FOUND - if empty:acls invert:y + if not:true empty:acls row cell class:help text text:GLOBAL_NAME cell class:help text text:GLOBAL_LANGUAGE - //cell -RAW -<?php foreach( $show as $t ) { ?> -<td class="help"><span title="<?php echo lang('ACL_'.strtoupper($t)) ?>"><strong><?php echo lang('ACL_'.strtoupper($t).'_ABBREV') ?></strong></span></td> -<?php } ?> -END + + list list:show value:t + cell class:help + text key:var:t prefix:acl_ suffix:_abbrev + cell class:help text text:global_delete - list list:acls key:aclid value:z extract:true + list list:acls key:aclid value:acl extract:true row - //cell -RAW -<?php if ( $z['username'] != '' ) - { ?> -<td width="50%" class="<?php echo $fx ?>"><img src="<?php echo $image_dir.'icon_user'.IMG_ICON_EXT ?>" align="left"><?php echo $z['username'] ?></td> -<?php } - elseif ( $z['groupname'] != '' ) - { ?> -<td width="50%" class="<?php echo $fx ?>"><img src="<?php echo $image_dir.'icon_group'.IMG_ICON_EXT ?>" align="left"><?php echo $z['groupname'] ?></td> -<?php } - else - { ?> -<td width="50%" class="<?php echo $fx ?>"><img src="<?php echo $image_dir.'icon_group'.IMG_ICON_EXT ?>" align="left"><?php echo lang('GLOBAL_ALL') ?></td> -<?php } ?> -END + cell + if present:username + image type:user + text text:var:username + if present:groupname + image type:group + text text:var:groupname + if not:true present:username + if not:true present:groupname + image type:group + text key:global_all cell text var:languagename - -RAW -<?php foreach( $show as $t ) { ?> -<td class="<?php echo $fx ?>"><?php echo Html::checkBox('',$z[$t],false,array('title'=>lang('ACL_'.strtoupper($t))) ) ?></td> -<?php } ?> -END - - -RAW -<?php if (isset($z['delete_url'])) - { ?> -<td class="<?php echo $fx ?>"><a href="<?php echo $z['delete_url'] ?>"><?php echo lang('GLOBAL_DELETE') ?></a></td> -<?php } - else - { ?> - -<td class="<?php echo $fx ?>"><?php echo lang('ACL_INHERITED') ?></td> -<?php } ?> -END - + list list:show value:t + cell + checkbox name:var:t default:false readonly:true + cell + if present:delete_url + link url:var:delete_url + text key:GLOBAL_DELETE + else + text key:ACL_INHERITED