PHP 클래스 Jyxo\Html

저자: Jaroslav Hanslík
파일 보기 프로젝트 열기: jyxo/php 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( ) Constructor preventing from creating instances of a static class.
fromText ( string $text, boolean $convertLinks = true ) : string Converts text to HTML source code.
getBody ( string $html ) : string Returns contents from the given HTML source.
is ( string $text ) : boolean Tests if the given text contains at least one HTML tag.
linkFromText ( string $text ) : string Converts text to a link to an url or email.
removeAttributes ( string $html, array $attributes = [] ) : string Removes given attributes from the HTML source.
removeDangerous ( string $html ) : string Removes possibly dangerous attributes that could contain XSS code from the HTML source.
removeInnerTags ( string $html, string $tag ) : string Removes tags of the same type nested into each other from the HTML source.
removeJavascriptEvents ( string $html ) : string Removes all javascript events from the HTML source.
removeRemoteImages ( string $html ) : string Removes foreign images from the HTML source.
removeTags ( string $html, array $tags = [] ) : string Removes given tags from the HTML source.
repair ( string $html ) : string Fixes an invalid HTML source, unifies quotes and removes unnecessary whitespace.
toText ( string $html ) : string Converts HTML source code to plaintext.

비공개 메소드들

메소드 설명
blockquoteToText ( string $text ) : string Converts citations into plaintext.
linkToText ( string $text ) : string Converts HTML links into plaintext.
listToText ( string $text ) : string Converts HTML lists to plaintext.

메소드 상세

__construct() 최종 공개 메소드

Constructor preventing from creating instances of a static class.
final public __construct ( )

fromText() 공개 정적인 메소드

Converts text to HTML source code.
public static fromText ( string $text, boolean $convertLinks = true ) : string
$text string Input text
$convertLinks boolean Convert urls and emails to links
리턴 string

getBody() 공개 정적인 메소드

Expects valid HTML source.
public static getBody ( string $html ) : string
$html string HTML source code
리턴 string

is() 공개 정적인 메소드

It is just an estimation.
public static is ( string $text ) : boolean
$text string Input text to be tested
리턴 boolean

linkFromText() 공개 정적인 메소드

Converts text to a link to an url or email.
public static linkFromText ( string $text ) : string
$text string Input text
리턴 string

removeAttributes() 공개 정적인 메소드

If no attributes are given, the default set will be used. Expects valid HTML source.
public static removeAttributes ( string $html, array $attributes = [] ) : string
$html string HTML source code
$attributes array Attributes to be removed
리턴 string

removeDangerous() 공개 정적인 메소드

Removes possibly dangerous attributes that could contain XSS code from the HTML source.
public static removeDangerous ( string $html ) : string
$html string HTML source code
리턴 string

removeInnerTags() 공개 정적인 메소드

Expects valid HTML source
public static removeInnerTags ( string $html, string $tag ) : string
$html string HTML source code
$tag string Tags to be processed
리턴 string

removeJavascriptEvents() 공개 정적인 메소드

If it is necessary to remove only certain events, the removeAttributes() method can be used. Expects valid HTML source.
public static removeJavascriptEvents ( string $html ) : string
$html string HTML source code
리턴 string

removeRemoteImages() 공개 정적인 메소드

Keeps tags (only set the value about:blank into its src attribute), because removing the tag entirely could affect the page layout. Expects valid HTML source.
public static removeRemoteImages ( string $html ) : string
$html string HTML source code
리턴 string

removeTags() 공개 정적인 메소드

If no tags are given, the default set is used. Expects valid HTML code.
public static removeTags ( string $html, array $tags = [] ) : string
$html string HTML source code
$tags array Tags to be removed
리턴 string

repair() 공개 정적인 메소드

Required the Tidy PHP extension.
public static repair ( string $html ) : string
$html string Input HTML source
리턴 string

toText() 공개 정적인 메소드

Converts HTML source code to plaintext.
public static toText ( string $html ) : string
$html string HTML source code
리턴 string