Reorganised code layout

Separated class library and web interface code
Added a common config/database config to be referenced by all
subprojects

Fixed previous commit
This commit is contained in:
2010-08-14 14:55:37 +01:00
parent 5aa4bf11c7
commit 76f2c4790d
70 changed files with 52 additions and 9 deletions

5
.gitignore vendored
View File

@@ -2,6 +2,7 @@
.buildpath .buildpath
.project .project
.settings .settings
.htaccess /config.php
/dbconfig.conf /dbconfig.conf
tmp/* /webui/.htaccess
/webui/tmp/*

23
config.php.dist Normal file
View File

@@ -0,0 +1,23 @@
<?php
/**
* HandBrakeCluster Library path
*
* Specifies the absolute or relative path to the HandBrakeCluster library directory, relative to the webui root directory.
* Path must end with a trailing slash.
*
* @var string
*/
define('HandBrakeCluster_Lib', '../lib/');
/**
* HandBrakeCluster Database Configuration
*
* Specifies the absolute or relative path to the HandBrakeCluster database configuration file.
* This is a standard ini type file, containing the config required to connect to the database.
*
* @var string
*/
define('HandBrakeCluster_DBConfig', '../dbconfig.conf');
?>

5
dbconfig.conf.dist Normal file
View File

@@ -0,0 +1,5 @@
hostname = localhost
username = handbrake
password = handbrake
dbname = handbrake_cluster

View File

@@ -1,3 +1,8 @@
<Files dbconfig.conf>
Order Allow,Deny
Deny from all
</Files>
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
RewriteEngine on RewriteEngine on

View File

@@ -9,8 +9,8 @@ class HandBrakeCluster_Cache {
$this->config = $config; $this->config = $config;
$this->cache_dir = $config->get('cache.base_dir'); $this->cache_dir = $config->get('cache.base_dir');
if (is_dir($cache_dir)) { if (is_dir($this->cache_dir)) {
if ( ! is_writeable($cache_dir)) { if ( ! is_writeable($this->cache_dir)) {
throw new HandBrakeCluster_Exception_InvalidCacheDir(); throw new HandBrakeCluster_Exception_InvalidCacheDir();
} }
} else { } else {

View File

@@ -52,7 +52,7 @@ class HandBrakeCluster_Job {
public static function fromDatabaseRow($row) { public static function fromDatabaseRow($row) {
return new HandBrakeCluster_Job( return new HandBrakeCluster_Job(
HandBrakeCluster_Rips_Source::load($rips['source']), HandBrakeCluster_Rips_Source::load($row['source']),
$row['id'], $row['id'],
$row['name'], $row['name'],
$row['source'], $row['source'],

View File

@@ -18,7 +18,7 @@ class HandBrakeCluster_Main {
private function __construct() { private function __construct() {
$request_string = isset($_GET['l']) ? $_GET['l'] : ''; $request_string = isset($_GET['l']) ? $_GET['l'] : '';
$this->config = new HandBrakeCluster_Config("dbconfig.conf"); $this->config = new HandBrakeCluster_Config(HandBrakeCluster_DBConfig);
$this->database = new HandBrakeCluster_Database($this->config); $this->database = new HandBrakeCluster_Database($this->config);
$this->config->setDatabase($this->database); $this->config->setDatabase($this->database);
@@ -126,12 +126,12 @@ class HandBrakeCluster_Main {
// Special case: All exceptions are stored in the same file // Special case: All exceptions are stored in the same file
if (preg_match('/^HandBrakeCluster_Exception/', $classname)) { if (preg_match('/^HandBrakeCluster_Exception/', $classname)) {
require_once('HandBrakeCluster/Exceptions.class.php'); require_once(HandBrakeCluster_Lib . 'HandBrakeCluster/Exceptions.class.php');
return; return;
} }
// Replace any underscores with directory separators // Replace any underscores with directory separators
$filename = preg_replace('/_/', '/', $classname); $filename = HandBrakeCluster_Lib . preg_replace('/_/', '/', $classname);
// Tack on the class file suffix // Tack on the class file suffix
$filename .= '.class.php'; $filename .= '.class.php';

6
webui/_inc.php Normal file
View File

@@ -0,0 +1,6 @@
<?php
require_once '../config.php';
require_once HandBrakeCluster_Lib . 'HandBrakeCluster/Main.class.php';
?>

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,6 +1,9 @@
<?php <?php
require 'HandBrakeCluster/Main.class.php'; define('HBCFile', 'index');
require '_inc.php';
try { try {
$main = HandBrakeCluster_Main::instance(); $main = HandBrakeCluster_Main::instance();
$smarty = $main->smarty(); $smarty = $main->smarty();

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB