Initial commit of HandBrakeCluster PHP framework
Replaced dodgy placeholder with a set of PHP classes for displaying a HandBrake webui. Current code uses Smarty as a templating engine, and includes an ugly but functional set of pages. The HandBrake classes are at present only placeholders, and offer no real functionality. Working class autoloader for the HandBrakeCluster_ hierarchy.
This commit is contained in:
44
HandBrakeCluster/RequestParser.class.php
Normal file
44
HandBrakeCluster/RequestParser.class.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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() {
|
||||
$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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user