File modules/cms/action/text/TextDiffAction.class.php

Last commit: Mon Dec 6 01:00:00 2021 +0100	dankert	New: Show a version from file history; New: Text history.
1 <?php 2 namespace cms\action\text; 3 use cms\action\Method; 4 use cms\action\PageelementAction; 5 use cms\action\TextAction; 6 use cms\generator\PublishEdit; 7 use cms\generator\PublishPreview; 8 use cms\model\Value; 9 use util\exception\ValidationException; 10 use util\Text; 11 12 class TextDiffAction extends TextAction implements Method { 13 14 public function view() { 15 $value1id = $this->request->getNumber('compareid'); 16 $value2id = $this->request->getNumber('withid' ); 17 18 // Wenn Value1-Id = Value2-Id 19 if ( $value1id == $value2id ) 20 throw new ValidationException('withid' ); 21 22 // Wenn Value1-Id groesser als Value2-Id, dann Variablen tauschen 23 if ( $value1id > $value2id ) 24 list($value1id,$value2id) = array( $value2id,$value1id ); 25 26 27 $value1 = new Value(); 28 $value2 = new Value(); 29 $value1->loadWithId( $value1id ); 30 $value2->loadWithId( $value2id ); 31 32 $this->setTemplateVar('date_left' ,$value1->lastchangeTimeStamp); 33 $this->setTemplateVar('date_right',$value2->lastchangeTimeStamp); 34 35 $text1 = explode("\n",$value1->file); 36 $text2 = explode("\n",$value2->file); 37 38 // Unterschiede feststellen. 39 $diffResult = Text::diff($text1,$text2); 40 41 $outputResult = array_map( function( $left,$right) { 42 return [ 43 'left' => $left, 44 'right'=> $right 45 ]; 46 },$diffResult[0],$diffResult[1] ); 47 48 $this->setTemplateVar('diff',$outputResult ); 49 } 50 51 52 public function post() { 53 } 54 }
Download modules/cms/action/text/TextDiffAction.class.php
History Mon, 6 Dec 2021 01:00:00 +0100 dankert New: Show a version from file history; New: Text history. Sat, 27 Nov 2021 01:52:24 +0100 Jan Dankert New: Releasing and Restoring for file and template values.