Location: PHPKode > scripts > Claw > claw/ext/URLPathInfoClawRequest.php
<?php

/**
 * URL PATH_INFO Claw Request
 *
 * @package claw.ext
 * @author Tomas Varaneckas <hide@address.com
 * @version $Id: URLPathInfoClawRequest.php 120 2006-03-19 19:26:44Z spajus $
 */
class URLPathInfoClawRequest implements ClawRequest
{
	/**
	 * Serialized version of the Request
	 *
	 * @var string
	 */
	private $serialized = '/';

	/**
	 * Autogenerates Request from PATH_INFO or ORIG_PATH_INFO (for cgi)
	 *
	 */
	public function __construct()
	{
		if (array_key_exists('PATH_INFO', $_SERVER))
		{
			$this->serialized = $_SERVER['PATH_INFO'];
		}
		elseif (array_key_exists('ORIG_PATH_INFO', $_SERVER))
		{
			$this->serialized = $_SERVER['ORIG_PATH_INFO'];
		}
	}

	/**
	 * Appends serialized path with new elment
	 *
	 * @param string $element
	 * @return URLPathInfoClawRequest return self (for fluent interfaces)
	 */
	public function addElement($element)
	{
		$this->serialized .= '/' . $element;
		return $this;
	}

	/**
	 * A specific function to add element - ClawPage
	 * It's not efficient to create ClawPage object to add it (theyre on the fly),
	 * therefore strings will be used
	 *
	 * @param string $title ClawPage title (according to naming convention!)
	 * @return URLPathInfoClawRequest return self (for fluent interfaces)
	 */	
	public function addPage($title)
	{
		return $this->addElement($title);
	}

	/**
	 * Appends serialized path with provided ClawArgs
	 *
	 * @param ClawArgs $args
	 * @return URLPathInfoClawRequest return self (for fluent interfaces)
	 */
	public function addArgs(ClawArgs $args)
	{
		return $this->addElement($args->serialize());
	}

	/**
	 * Returns ready-to-use request
	 *
	 * @return unknown
	 */
	public function serialize()
	{
		return $this->serialized;
	}

	/**
	 * Returns request as Array
	 *
	 * @return Array
	 */
	public function asArray()
	{
		return array_diff(explode('/', $this->serialized), array(null));
	}
}
?>
Return current item: Claw