Files
handbrake-cluster-webui/HandBrakeCluster/RequestParser.class.php
Ben Roberts a9ebf6e0cb Core class updates
Improved database abstraction class to support insert and select queries
in various forms.
Added classes for pulling log entries back out of the database.
Updated Job class to describe a known job in the database, and added
JobStatus to track status updates on jobs.
Updated Config class to connect to the database, and load all settings
on startup.
Improved the class autoloader to support Exceptions in a single file as
a special case, and added this file.
2010-03-18 02:00:53 +00:00

49 lines
1.0 KiB
PHP

<?php
class HandBrakeCluster_RequestParser {
private $request_string;
private $page = 'home';
private $vars = array();
public function __construct($request_string) {
$this->request_string = $request_string;
$this->parse();
}
public function parse() {
if (!$this->request_string) {
return;
}
$components = explode('/', $this->request_string);
if (!$components) {
return;
}
// The first token is the page to execute
$this->page = array_shift($components);
// The subsequent tokens are parameters for this page in key value pairs
while ($components) {
$this->vars[array_shift($components)] = $components ? array_shift($components) : null;
}
}
public function page() {
return $this->page;
}
public function get($key) {
if (isset($this->vars[$key])) {
return $this->vars[$key];
}
return null;
}
};
?>