address; while ( $token = array_shift( $address ) ) { // Check for direct descendants if ( strpos( $token, '>' ) === 0 ) { $token = preg_replace( '(>[\\t\\x20]+)', '', $token ); $regexp .= '/' . preg_quote( $token ); } elseif ( ( strpos( $token, '.' ) === 0 ) || ( strpos( $token, '#' ) === 0 ) ) { $regexp .= '(?:/[^/]+)*/[^.]+'; array_unshift( $address, $token ); } else { $regexp .= '(?:/[^/]+)*/' . preg_quote( $token ); } // Append optional class and ID restrictions $restrictions = array(); while ( isset( $address[0] ) && ( ( strpos( $address[0], '.' ) === 0 ) || ( strpos( $address[0], '#' ) === 0 ) ) ) { $token = array_shift( $address ); $restrictions[$token[0]] = substr( $token, 1 ); } // Append optional restrictions if ( isset( $restrictions['.'] ) ) { $regexp .= '\\.(?:[a-z0-9_-]+_)?' . preg_quote( $restrictions['.'] ) . '(?:_[a-z0-9_-]+)?'; } else { $regexp .= '(?:\\.[a-z0-9_-]+)?'; } // Append optional restrictions if ( isset( $restrictions['#'] ) ) { $regexp .= '#' . preg_quote( $restrictions['#'] ); } else { $regexp .= '(?:#[a-z0-9_-]+)?'; } $regexp .= '(?:\\[[^]]+\\])*'; } $regexp .= '$)S'; $this->regularExpression = $regexp; } /** * Return a PCRE regular expression for directive address. * * Return a PCRE regular expression representing the address of * the directive, intended to match location IDs representing * the docbook element nodes. * * @param string $locationId * @return string */ public function getRegularExpression() { if ( $this->regularExpression === null ) { $this->compileRegularExpression(); } return $this->regularExpression; } /** * Recreate directive from var_export. * * @param array $properties * @return ezcDocumentPcssDirective */ public static function __set_state( $properties ) { return new ezcDocumentPcssLayoutDirective( $properties['address'], $properties['formats'], $properties['file'], $properties['line'], $properties['position'] ); } } ?>