* @author Roman Ožana */ class Emogrifier { /** * @var int */ const CACHE_KEY_CSS = 0; /** * @var int */ const CACHE_KEY_SELECTOR = 1; /** * @var int */ const CACHE_KEY_XPATH = 2; /** * @var int */ const CACHE_KEY_CSS_DECLARATIONS_BLOCK = 3; /** * @var int */ const CACHE_KEY_COMBINED_STYLES = 4; /** * for calculating nth-of-type and nth-child selectors * * @var int */ const INDEX = 0; /** * for calculating nth-of-type and nth-child selectors * * @var int */ const MULTIPLIER = 1; /** * @var string */ const ID_ATTRIBUTE_MATCHER = '/(\\w+)?\\#([\\w\\-]+)/'; /** * @var string */ const CLASS_ATTRIBUTE_MATCHER = '/(\\w+|[\\*\\]])?((\\.[\\w\\-]+)+)/'; /** * @var string */ const CONTENT_TYPE_META_TAG = ''; /** * @var string */ const DEFAULT_DOCUMENT_TYPE = ''; /** * @var string */ private $html = ''; /** * @var string */ private $css = ''; /** * @var bool[] */ private $excludedSelectors = array(); /** * @var string[] */ private $unprocessableHtmlTags = array( 'wbr' ); /** * @var bool[] */ private $allowedMediaTypes = array( 'all' => true, 'screen' => true, 'print' => true ); /** * @var array[] */ private $caches = array( self::CACHE_KEY_CSS => array(), self::CACHE_KEY_SELECTOR => array(), self::CACHE_KEY_XPATH => array(), self::CACHE_KEY_CSS_DECLARATIONS_BLOCK => array(), self::CACHE_KEY_COMBINED_STYLES => array(), ); /** * the visited nodes with the XPath paths as array keys * * @var DoMElement[] */ private $visitedNodes = array(); /** * the styles to apply to the nodes with the XPath paths as array keys for the outer array * and the attribute names/values as key/value pairs for the inner array * * @var array[] */ private $styleAttributesForNodes = array(); /** * Determines whether the "style" attributes of tags in the the HTML passed to this class should be preserved. * If set to false, the value of the style attributes will be discarded. * * @var bool */ private $isInlineStyleAttributesParsingEnabled = true; /** * Determines whether the