[pLog-svn] r2524 - in plog/trunk: . class/net

oscar at devel.plogworld.net oscar at devel.plogworld.net
Sun Sep 25 19:47:05 GMT 2005


Author: oscar
Date: 2005-09-25 19:47:04 +0000 (Sun, 25 Sep 2005)
New Revision: 2524

Modified:
   plog/trunk/class/net/prettyrequestgenerator.class.php
   plog/trunk/class/net/prettyrequestparser.class.php
   plog/trunk/error.php
Log:
Added support for paging when "search engine friendly" urls are enabled.

Modified: plog/trunk/class/net/prettyrequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/prettyrequestgenerator.class.php	2005-09-24 23:49:14 UTC (rev 2523)
+++ plog/trunk/class/net/prettyrequestgenerator.class.php	2005-09-25 19:47:04 UTC (rev 2524)
@@ -386,5 +386,36 @@
         	throw( new Exception( "PrettyRequestGenerator::getRequest: function not implemented" ));
             die();
         }
+		
+		/**
+		 * given the parameters, recalculates the current URL. This method also has support
+		 * for paged urls
+		 *
+		 * @param category
+		 * @param userInfo
+		 * @param date
+		 * @param page
+		 * @return the current url with its page
+		 */
+		function getCurrentUrl( $category = null, $userInfo = null, $date = null, $page = null )
+		{
+			if( $category ) {
+				$url = $this->categoryLink( $category );
+			}
+			elseif( $userInfo ) {
+				$url = $this->postUserLink( $userInfo );
+			}
+			elseif( $date > -1 ) {
+				$url = $this->getArchiveLink( $date );
+			}
+			else {
+				// if none of the above, we should at least get a link to the blog!
+				$url = $this->blogLink();
+			}		
+			
+			$pageFormat = "/page/";
+			
+			return( $url.$pageFormat );
+		}		
     }
 ?>
\ No newline at end of file

Modified: plog/trunk/class/net/prettyrequestparser.class.php
===================================================================
--- plog/trunk/class/net/prettyrequestparser.class.php	2005-09-24 23:49:14 UTC (rev 2523)
+++ plog/trunk/class/net/prettyrequestparser.class.php	2005-09-25 19:47:04 UTC (rev 2524)
@@ -19,9 +19,28 @@
 
             $this->_function  = $function;
         }
+		
+		/** 
+		 * @private
+		 * Retrieves the page from the request
+		 */
+		function getPageValue( $request )
+		{
+			if( preg_match( "/\/page\/([0-9]*)/", $request, $matches ))
+				$page = $matches[1];
+			else
+				$page = "";
+			
+			return( $page );
+		}
 
         function parse()
         {
+			// remove the page from the string, if any and then remove the string itself so that
+			// it doesn't interfere with the old parsing code
+			$page = $this->getPageValue( $this->_path_info );
+			$this->_path_info = preg_replace( "/\/page\/[0-9]*/", "", $this->_path_info );		
+		
             // get the blog id and the post id
             $params = explode( "/", $this->_path_info );
 
@@ -111,8 +130,15 @@
                     $result["op"] = "Trackbacks";
                     $result["articleId"] = $postId;
                  default:
-                 	break;
+                 	$result["op"] = "Default";
+					$userParam=$params[count($params)-1];
+					if( is_numeric($userParam))
+						$result["blogId"] = $userParam;
+					else
+						$result["blogUserName"] = $userParam;
              }
+			 
+			 $result["page"] = $page;
 
              return $result;
         }

Modified: plog/trunk/error.php
===================================================================
--- plog/trunk/error.php	2005-09-24 23:49:14 UTC (rev 2523)
+++ plog/trunk/error.php	2005-09-25 19:47:04 UTC (rev 2524)
@@ -31,21 +31,12 @@
 	$config =& Config::getConfig(); 
 
 	if( $config->getValue( "request_format_mode" ) == SEARCH_ENGINE_FRIENDLY_MODE ) {
-		$server  = HttpVars::getServer();
-		$request = HttpVars::getRequest();
-		
-		$parts = split( "/", $server["REQUEST_URI"] );
-		
-		$userParam=$parts[count($parts)-1];
-		if( is_numeric($userParam))
-			$request["blogId"] = $userParam;
-		else
-			$request["blogUserName"] = $userParam;
-		
-		HttpVars::setRequest( $request );
-		
-		$scriptName = $config->getValue( "script_name", DEFAULT_SCRIPT_NAME );
-		include_once ( PLOG_CLASS_PATH.$scriptName );
+		include_once( PLOG_CLASS_PATH."class/net/prettyrequestparser.class.php" );
+		$server = HttpVars::getServer();
+		$parser = new PrettyRequestParser( "default", $server["REQUEST_URI"]);
+		$result = $parser->parse();
+		HttpVars::setRequest( $result );
+		include_once( "index.php" );		
 	}
 	else {
 		include_once( PLOG_CLASS_PATH."blog.php" );




More information about the pLog-svn mailing list