TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Utility\DiffUtility Class Reference
Inheritance diagram for TYPO3\CMS\Core\Utility\DiffUtility:
t3lib_diff

Public Member Functions

 makeDiffDisplay ($str1, $str2, $wrapTag='span')
 
 getDiff ($str1, $str2)
 
 addClearBuffer ($clearBuffer, $last=0)
 
 explodeStringIntoWords ($str)
 
 tagSpace ($str, $rev=0)
 

Public Attributes

 $stripTags = 0
 
 $diffOptions = ''
 
 $clearBufferIdx = 0
 
 $differenceLgd = 0
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! This class has functions which generates a difference output of a content string

Author
Kasper Skårhøj kaspe.nosp@m.rYYY.nosp@m.Y@typ.nosp@m.o3.c.nosp@m.om

Definition at line 22 of file DiffUtility.php.

Member Function Documentation

◆ addClearBuffer()

TYPO3\CMS\Core\Utility\DiffUtility::addClearBuffer (   $clearBuffer,
  $last = 0 
)

Will bring down the length of strings to < 150 chars if they were longer than 200 chars. This done by preserving the 70 first and last chars and concatenate those strings with "..." and a number indicating the string length

Parameters
string$clearBufferThe input string.
boolean$lastIf set, it indicates that the string should just end with ... (thus no "complete" ending)
Returns
string Processed string. private
Todo:
Define visibility

Definition at line 158 of file DiffUtility.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\fixed_lgd_cs().

Referenced by TYPO3\CMS\Core\Utility\DiffUtility\makeDiffDisplay().

◆ explodeStringIntoWords()

TYPO3\CMS\Core\Utility\DiffUtility::explodeStringIntoWords (   $str)

Explodes the input string into words. This is done by splitting first by lines, then by space char. Each word will be in stored as a value in an array. Lines will be indicated by two subsequent empty values.

Parameters
string$strThe string input
Returns
array Array with words. private
Todo:
Define visibility

Definition at line 175 of file DiffUtility.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Utility\DiffUtility\makeDiffDisplay().

◆ getDiff()

TYPO3\CMS\Core\Utility\DiffUtility::getDiff (   $str1,
  $str2 
)

Produce a diff (using the "diff" application) between two strings The function will write the two input strings to temporary files, then execute the diff program, delete the temp files and return the result.

Parameters
string$str1String 1
string$str2String 2
Returns
array The result from the exec() function call. private
Todo:
Define visibility

Definition at line 133 of file DiffUtility.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\CommandUtility\exec(), TYPO3\CMS\Core\Utility\GeneralUtility\tempnam(), and TYPO3\CMS\Core\Utility\GeneralUtility\writeFile().

Referenced by TYPO3\CMS\Core\Utility\DiffUtility\makeDiffDisplay().

◆ makeDiffDisplay()

TYPO3\CMS\Core\Utility\DiffUtility::makeDiffDisplay (   $str1,
  $str2,
  $wrapTag = 'span' 
)

This will produce a color-marked-up diff output in HTML from the input strings.

Parameters
string$str1String 1
string$str2String 2
string$wrapTagSetting the wrapping tag name
Returns
string Formatted output.
Todo:
Define visibility

Definition at line 58 of file DiffUtility.php.

References TYPO3\CMS\Core\Utility\DiffUtility\addClearBuffer(), TYPO3\CMS\Core\Utility\DiffUtility\explodeStringIntoWords(), TYPO3\CMS\Core\Utility\DiffUtility\getDiff(), and TYPO3\CMS\Core\Utility\DiffUtility\tagSpace().

◆ tagSpace()

TYPO3\CMS\Core\Utility\DiffUtility::tagSpace (   $str,
  $rev = 0 
)

Adds a space character before and after HTML tags (more precisely any found < or >)

Parameters
string$strString to process
boolean$revIf set, the < > searched for will be < and >
Returns
string Processed string private
Todo:
Define visibility

Definition at line 196 of file DiffUtility.php.

Referenced by TYPO3\CMS\Core\Utility\DiffUtility\makeDiffDisplay().

Member Data Documentation

◆ $clearBufferIdx

TYPO3\CMS\Core\Utility\DiffUtility::$clearBufferIdx = 0
Todo:
Define visibility

Definition at line 42 of file DiffUtility.php.

◆ $differenceLgd

TYPO3\CMS\Core\Utility\DiffUtility::$differenceLgd = 0
Todo:
Define visibility

Definition at line 47 of file DiffUtility.php.

◆ $diffOptions

TYPO3\CMS\Core\Utility\DiffUtility::$diffOptions = ''
Todo:
Define visibility

Definition at line 35 of file DiffUtility.php.

◆ $stripTags

TYPO3\CMS\Core\Utility\DiffUtility::$stripTags = 0
Todo:
Define visibility

Definition at line 29 of file DiffUtility.php.