PHP Class PHPFusion\Rewrite\RewriteDriver

显示文件 Open project: php-fusion/PHP-Fusion

Protected Properties

Property Type Description
$alias_pattern Array of Pattern for Aliases which are made for matching.
$aliases
$buffer_search_regex
$handlers Array of Handlers example: news, threads, articles
$instance
$output The site render HTML buffer which is to be scanned
$path_search_regex
$pattern_replace Target URLs to which permalink request will be rewrited.
$pattern_search Permalink Patterns which will be searched to match against current request.
$pattern_tables Array of DB Table Names with Schema example: prefix_news, prefix_threads, prefix_articles
$patterns_regex Array of Regular Expressions Patterns which are made for matching.
$queries Array of Total Queries which were run.
$regex_statements array Statements are calculation results of Rewrite scan We will have various types of regex statements This is the results data of the entire permalink success/fails
$requesturi Portion of the URL to match in the Regex
$rewrite_code example: %thread_id%, %news_id%
$rewrite_replace example: %thread_id% should be replaced with ([0-9]+)
$warnings Array of Warnings

Public Methods

Method Description
getInstance ( ) : static Get the instance of the class

Protected Methods

Method Description
HTML_In ( $output ) Entrance to Permalink from PHP Buffer This function prepares HTML codes to be preg_matched against Permalink Driver Decode everything
HTML_Out ( $output ) Exit from Permalink to PHP Buffer This function prepares HTML codes to be viewed by browser
addRegexTag ( array $regex, string $driver ) Adds the Regular Expression Tags
appendSearchPath ( string $str ) : string Append the BASEDIR Path to Search String
cleanRegex ( string $regex ) : string Clean the REGEX by escaping some characters
cleanString ( $mystr = "" ) Clean the URI String for MATCH/AGAINST in MySQL
cleanURL ( string $string, $delimiter = "-" ) : string Cleans the URL
getTagPosition ( string $pattern, string $search ) Calculates the Tag Position in a given pattern.
getUniqueIDtag ( string $type ) Get the Tag of the Unique ID type
handle_non_seo_url ( ) Validate_url
handle_permalink_requests ( ) Builds the Regular Expressions Patterns for Permalink Translations
includeHandlers ( ) Include the Handlers
includeRewrite ( ) Include the rewrite include file
loadSQLDrivers ( ) Import Handlers from Database
makeSearchRegex ( $pattern, string $type ) Adds the Regular Expression Tags -- for permalink search regex
normalize ( $string ) : string Replaces special characters in a string with their "non-special" counterpart.
prepare_searchRegex ( )
redirect_301 ( string $target, $debug = FALSE ) Redirect 301 : Moved Permanently Redirect This function invoked to prevent of caching any kinds of Non SEO URL on render.
replaceOtherTags ( string $type, string $search, string $replace, array $matches, string $matchkey ) : string Replace Other Tags in Pattern
setWarning ( integer $code, string $info = "" ) Set Warnings
verifyHandlers ( ) Verify Handlers
wrapDoubleQuotes ( $str ) : string Add compatibalities with double quotes HTML codes for Permalink
wrapQuotes ( string $str ) : string Wrap a String with Single Quotes (') This function will wrap a string passed with Single Quotes.

Private Methods

Method Description
AddRewrite ( string $include_prefix ) Add the rewrite include file to be included

Method Details

HTML_In() protected method

Entrance to Permalink from PHP Buffer This function prepares HTML codes to be preg_matched against Permalink Driver Decode everything
protected HTML_In ( $output )

HTML_Out() protected method

Exit from Permalink to PHP Buffer This function prepares HTML codes to be viewed by browser
protected HTML_Out ( $output )
$output

addRegexTag() protected method

This will Add Regex Tags, which will be replaced in the search patterns. Example: %news_id% could be replaced with ([0-9]+) as it must be a number.
protected addRegexTag ( array $regex, string $driver )
$regex array Array of Tags to be added.
$driver string Type or Handler name

appendSearchPath() protected method

This function will append the BASEDIR path to the Search pattern. This is required in some cases like when we are on actual php script page and Permalinks are ON.
protected appendSearchPath ( string $str ) : string
$str string The String
return string

cleanRegex() protected static method

This function will escape some characters in the Regex expression
protected static cleanRegex ( string $regex ) : string
$regex string The expression String
return string

cleanString() protected method

This function will Clean the string and removes any unwanted characters from it.
protected cleanString ( $mystr = "" )

cleanURL() protected static method

This function will clean the URL by removing any unwanted characters from it and only allowing alphanumeric and - in the URL. This function can be customized according to your needs.
protected static cleanURL ( string $string, $delimiter = "-" ) : string
$string string The URL String
return string

getInstance() public static method

Get the instance of the class
public static getInstance ( ) : static
return static

getTagPosition() protected method

This function will calculate the position of a given Tag in a given pattern. Example: %id% is at 2 position in articles-%title%-%id%
protected getTagPosition ( string $pattern, string $search )
$pattern string The Pattern string in which particular Tag will be searched.
$search string The Tag which will be searched.

getUniqueIDtag() protected method

Example: For news, unique ID should be news_id So it will return %news_id% because of array("%%news_id" => "news_id")
protected getUniqueIDtag ( string $type )
$type string Type or Handler name

handle_non_seo_url() protected method

If Page is Not SEO, Redirect to SEO one
protected handle_non_seo_url ( )

includeHandlers() protected method

This function will include the neccessary files for the Handler and call the functions to manipulate the information from the Handler files.
protected includeHandlers ( )

includeRewrite() protected method

The include file will be included from INCLUDES."rewrites/".PREFIX."_rewrite_include.php
protected includeRewrite ( )

loadSQLDrivers() protected method

This will import all the Enabled Handlers from the Database Table
protected loadSQLDrivers ( )

makeSearchRegex() protected method

This will Add Regex Tags, which will be replaced in the search patterns. Example: %news_id% could be replaced with ([0-9]+) as it must be a number.
protected makeSearchRegex ( $pattern, string $type )
$type string Type or Handler name

normalize() protected static method

Useful for friendly URLs.
protected static normalize ( $string ) : string
return string

prepare_searchRegex() protected method

protected prepare_searchRegex ( )

redirect_301() protected static method

Let search engine mark as 301 permanently
protected static redirect_301 ( string $target, $debug = FALSE )
$target string The Target URL

replaceOtherTags() protected method

This function will replace all the Tags in the Pattern with their suitable found matches. All the Information is passed to the function and it will replace the Tags with their respective matches.
protected replaceOtherTags ( string $type, string $search, string $replace, array $matches, string $matchkey ) : string
$type string Type of Pattern
$search string specific Search Pattern
$replace string specific Replace Pattern
$matches array Array of the Matches found for a specific pattern
$matchkey string A Unique matchkey for different matches found for same pattern
return string

setWarning() protected method

This function will set Warnings. It will set them by Adding them into the $this->warnings array.
protected setWarning ( integer $code, string $info = "" )
$code integer The Code Number of the Warning
$info string Any other Info to Show along with Warning

verifyHandlers() protected method

This will verify all the added Handlers by checking if they are enabled or not. The Disabled Handlers are removed from the List and only Enabled Handlers are kept for working.
protected verifyHandlers ( )

wrapDoubleQuotes() protected static method

Add compatibalities with double quotes HTML codes for Permalink
protected static wrapDoubleQuotes ( $str ) : string
$str
return string

wrapQuotes() protected static method

Example: mystring will become 'mystring'
protected static wrapQuotes ( string $str ) : string
$str string The String
return string

Property Details

$alias_pattern protected_oe property

Array of Pattern for Aliases which are made for matching.
protected $alias_pattern

$aliases protected_oe property

protected $aliases

$buffer_search_regex protected_oe property

protected $buffer_search_regex

$handlers protected_oe property

Array of Handlers example: news, threads, articles
protected $handlers

$instance protected_oe static_oe property

protected static $instance

$output protected_oe property

The site render HTML buffer which is to be scanned
protected $output

$path_search_regex protected_oe property

protected $path_search_regex

$pattern_replace protected_oe property

Target URLs to which permalink request will be rewrited.
protected $pattern_replace

$pattern_tables protected_oe property

Array of DB Table Names with Schema example: prefix_news, prefix_threads, prefix_articles
protected $pattern_tables

$patterns_regex protected_oe property

Array of Regular Expressions Patterns which are made for matching.
protected $patterns_regex

$queries protected_oe property

Array of Total Queries which were run.
protected $queries

$regex_statements protected_oe property

Statements are calculation results of Rewrite scan We will have various types of regex statements This is the results data of the entire permalink success/fails
protected array $regex_statements
return array

$requesturi protected_oe property

Portion of the URL to match in the Regex
protected $requesturi

$rewrite_code protected_oe property

example: %thread_id%, %news_id%
protected $rewrite_code

$rewrite_replace protected_oe property

example: %thread_id% should be replaced with ([0-9]+)
protected $rewrite_replace

$warnings protected_oe property

Array of Warnings
protected $warnings