Formatting output Plese Wait...
Rewrite Map Parser.
More...
Detailed Description
Rewrite Map Parser.
Definition at line 27 of file prs_rewrite.php.
Member Function Documentation
rewriteMapParser::parse( unknown $filePath )
Definition at line 28 of file prs_rewrite.php.
References $filePath, and perror().
Referenced by match().
Show Source00028 {
00029 if(!file_exists($filePath)){
00030 perror('<code>zigmoyd.mvc.rewrite.parser</code><br />Failed to Parse '.$filePath.' as it doesn\t exist');
00031 return false;
00032 }
00033 if(!is_readable($filePath)){
00034 perror('<code>zigmoyd.mvc.rewrite.parser</code><br />Failed to Parse '.$filePath.' as its not readable');
00035 return false;
00036 }
00037 $content=file($filePath);
00038 foreach($content as $i => $line){
00039 if(!preg_match('~(.+)\s*\->\s*(.+)~', $line, $m)){
00040 perror('<code>zigmoyd.mvc.rewrite.parser</code><br />Failed to Parse '.$filePath.' unexpected format near line '.($i+1));
00041 return false;
00042 }else{
00043 $content[$i] = array('fake' => trim($m[1]), 'original' => trim($m[2]));
00044 }
00045 }
00046 return $content;
00047 }
Top
rewriteMapParser::match( unknown $filePath, unknown $fakePath )
Definition at line 48 of file prs_rewrite.php.
References $filePath, and parse().
Referenced by matchCurrentUrlPath().
Show Source00048 {
00049 foreach(rewriteMapParser::parse($filePath) as $rule){
00050 if(preg_match('$'.trim(trim($rule['fake']), '/').'$',trim(trim($fakePath), '/'))){
00051 return trim(preg_replace('$'.trim(trim($rule['fake']), '/').'$', $rule['original'], trim(trim($fakePath), '/')), '/');
00052 }
00053 }
00054 return false;
00055 }
Top
rewriteMapParser::currentUrlPath( )
rewriteMapParser::matchCurrentUrlPath( unknown $filePath )
rewriteMapParser::explode( unknown $realPathStr )
Definition at line 62 of file prs_rewrite.php.
References perror().
Show Source00062 {
00063 $explodedRealPath = explode('/', trim($realPathStr, '/'));
00064 if(!isset($explodedRealPath[0]))perror("<code>zigmoyd.mvc.rewrite.parser</code><br />Unexpected format of real path (Controller not Found)");
00065 if(!isset($explodedRealPath[1]))perror("<code>zigmoyd.mvc.rewrite.parser</code><br />Unexpected format of real path (Method Name not Found)");
00066 $ret = array($explodedRealPath[0], $explodedRealPath[1]);
00067 unset($explodedRealPath[0]);
00068 unset($explodedRealPath[1]);
00069 $args = array_values($explodedRealPath);
00070 return array($ret, $args);
00071 }
Top
The documentation for this class was generated from the following file: