openrat-cms

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

commit 0a2b1648a4234ec42ffe898cbfa93ab7cd3e3cea
parent 876df7d166fcb2f3c82a5f7331415902c340300f
Author: dankert <devnull@localhost>
Date:   Fri,  9 Nov 2007 23:03:37 +0100

Umstellung Anzeige DIFF von altem RAW-Code auf neue Elemente. Neues Attribut "type" f?r Element "text".

Diffstat:
actionClasses/PageelementAction.class.php | 23++++++++++++++++++-----
themes/default/include/elements.ini.php | 2+-
themes/default/include/html/text.inc.php | 36+++++++++++++++++++++++++++++-------
themes/default/templates/pageelement/diff.tpl.src.php | 92++++++++++++++++++++++++++++---------------------------------------------------
4 files changed, 80 insertions(+), 73 deletions(-)

diff --git a/actionClasses/PageelementAction.class.php b/actionClasses/PageelementAction.class.php @@ -971,21 +971,34 @@ class PageelementAction extends Action // Logger::debug( 'comparing value '.$value1id.' with '.$value2id ); $date1 = date( lang('DATE_FORMAT'),$value1->lastchangeTimeStamp); - $this->setTemplateVar('title1',$date1); + $this->setTemplateVar('title_left',$date1); $date2 = date( lang('DATE_FORMAT'),$value2->lastchangeTimeStamp); - $this->setTemplateVar('title2',$date2); + $this->setTemplateVar('title_right',$date2); $text1 = explode("\n",$value1->text); $text2 = explode("\n",$value2->text); $res_diff = $this->textdiff($text1,$text2); -// Html::debug($res_diff,'Diff'); list( $text1,$text2 ) = $res_diff; - $this->setTemplateVar('text1',$text1 ); - $this->setTemplateVar('text2',$text2 ); + $diff = array(); + $i = 0; + while( isset($text1[$i]) || isset($text2[$i]) ) + { + $line = array(); + + if ( isset($text1[$i]['text']) ) + $line['left'] = $text1[$i]; + + if ( isset($text2[$i]['text']) ) + $line['right'] = $text2[$i]; + + $i++; + $diff[] = $line; + } + $this->setTemplateVar('diff',$diff ); } diff --git a/themes/default/include/elements.ini.php b/themes/default/include/elements.ini.php @@ -37,7 +37,7 @@ selectbox= list:*,name:*,default,onchange:,title:,class:,addempty:false,multiple radiobox = list:*,name:*,default,onchange:,title:,class: set = var:*,value,key 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,accesskey,escape:true +text = title,class:text,var,text,key,textvar,raw,maxlength,value,suffix,prefix,accesskey,escape:true,type upload = name:*,class:upload,maxlength,size:40 user = user window = title,name,icon,widths,width:93%,rowclasses:oddCOMMAeven,columnclasses:1COMMA2COMMA3 \ No newline at end of file diff --git a/themes/default/include/html/text.inc.php b/themes/default/include/html/text.inc.php @@ -9,8 +9,28 @@ $attr_title = lang($attr_key.'_HELP'); else $attr_title = ''; + if (empty($attr_type)) + $tmp_tag = 'span'; + else + switch( $attr_type ) + { + case 'emphatic': + case 'italic': + $tmp_tag = 'em'; + break; + case 'strong': + case 'bold': + $tmp_tag = 'strong'; + break; + case 'tt': + case 'teletype': + $tmp_tag = 'tt'; + break; + default: + $tmp_tag = 'span'; + } -?><span class="<?php echo $attr_class ?>" title="<?php echo $attr_title ?>"><?php +?><<?php echo $tmp_tag ?> class="<?php echo $attr_class ?>" title="<?php echo $attr_title ?>"><?php $attr_title = ''; if (!empty($attr_array)) @@ -33,17 +53,17 @@ elseif (!empty($attr_key)) $tmp_text = lang($attr_key); elseif (!empty($attr_var)) - $tmp_text = isset($$attr_var)?($attr_escape?htmlentities($$attr_var):$$attr_var):'?'.$attr_var.'?'; + $tmp_text = isset($$attr_var)?$$attr_var:'?'.$attr_var.'?'; elseif (!empty($attr_raw)) $tmp_text = str_replace('_','&nbsp;',$attr_raw); elseif (!empty($attr_value)) $tmp_text = $attr_value; else - { $tmp_text = '&nbsp;'; - //Html::debug($attr);echo 'text error'; - } + if ( $attr_escape && empty($attr_raw) && $tmp_text!='&nbsp;' ) + $tmp_text = htmlentities($tmp_text); + if ( !empty($attr_maxlength) && intval($attr_maxlength)!=0 ) $tmp_text = Text::maxLength( $tmp_text,intval($attr_maxlength) ); @@ -55,4 +75,6 @@ } echo $tmp_text; -?></span>- \ No newline at end of file + + unset($tmp_text); +?></<?php echo $tmp_tag ?>>+ \ No newline at end of file diff --git a/themes/default/templates/pageelement/diff.tpl.src.php b/themes/default/templates/pageelement/diff.tpl.src.php @@ -1,65 +1,36 @@ page window row - cell colspan:2 - text text:GLOBAL_COMPARE + cell + cell + text type:emphatic text:GLOBAL_COMPARE text raw:_ - text var:title1 - cell colspan:2 - text text:GLOBAL_WITH + text type:strong var:title_left + cell + cell +// cell colspan:2 + text type:emphatic text:GLOBAL_WITH text raw:_ - text var:title2 - -RAW -<?php $fx = ''; - if (count($text1) > 0) - { - $i=0; - while( isset($text1[$i]) || isset($text2[$i]) ) - { - $fx = ''; - ?> - <tr> - - <?php - if ( isset($text1[$i]['text']) ) - { - ?> - <td class="<?php echo $fx ?>" width="5%" ><?php echo $text1[$i]['line'] ?></td> - <td class="diff_<?php echo $text1[$i]['type'] ?>" width="45%"><?php echo $text1[$i]['text'] ?></td> - <?php - } - else - { - ?> - <td colspan="2" class="help" with="50%">&nbsp;</td> - <?php - } - - if ( isset($text2[$i]['text']) ) - { - ?> - <td class="<?php echo $fx ?>" width="5%" ><?php echo $text2[$i]['line'] ?></td> - <td class="diff_<?php echo $text2[$i]['type'] ?>" width="45%"><?php echo $text2[$i]['text'] ?></td> - <?php - } - else - { - ?> - <td colspan="2" class="help" with="50%">&nbsp;</td> - <?php - } - ?> - </tr> - <?php - $i++; - } - } - else - { ?> -<tr> - <td class="f1" colspan="4"><strong><?php echo lang('GLOBAL_NO_DIFFERENCES_FOUND') ?></strong></td> -</tr> -<?php } ?> -END - + text type:strong var:title_right + + list list:diff extract:true + row class:diff + if present:left + cell width:5% class:line + text text:arrayvar:left:line type:tt + cell width:45% class:arrayvar:left:type + text text:arrayvar:left:text + else + cell colspan:2 class:help width:50% + text raw:_ + if present:right + cell width:5% class:line + text text:arrayvar:right:line type:tt + cell width:45% class:arrayvar:right:type + text text:arrayvar:right:text + else + cell colspan:2 class:help width:50% + text raw:_ + + set var:left + set var:right+ \ No newline at end of file