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