Skip to content

Commit

Permalink
Use PSR-4 autoloading.
Browse files Browse the repository at this point in the history
  • Loading branch information
cokernel committed Jul 1, 2016
1 parent d7a79d8 commit 7319829
Show file tree
Hide file tree
Showing 17 changed files with 603 additions and 23 deletions.
13 changes: 7 additions & 6 deletions lib/CacheFile.class.php → app/Ohms/Interview.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Ohms;
/*
* Model for the XML CacheFile
*
Expand All @@ -7,7 +7,10 @@
* @license http://www.uky.edu
*/

class CacheFile {
use Ohms\Interview\Legacy;
use Ohms\Interview\Version3;

class Interview {
public static function getInstance($cachefile = NULL, $configtmpDir, $config) {
$viewerconfig = $config;
$tmpDir = $configtmpDir;
Expand All @@ -34,12 +37,10 @@ public static function getInstance($cachefile = NULL, $configtmpDir, $config) {

$cacheversion = (string)$filecheck->record->version;
if ($cacheversion=='') {
require_once 'LegacyCacheFile.class.php';
return LegacyCacheFile::getInstanceLegacy($cachefile, $tmpDir, $viewerconfig);
return Legacy::getInstanceLegacy($cachefile, $tmpDir, $viewerconfig);
}
else {
require_once 'Version3CacheFile.class.php';
return Version3CacheFile::getInstanceVersion3($cachefile, $tmpDir, $viewerconfig);
return Version3::getInstanceVersion3($cachefile, $tmpDir, $viewerconfig);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Ohms\Interview;
/*
* Model for the XML LegacyCacheFile
*
Expand All @@ -7,9 +7,7 @@
* @license http://www.uky.edu
*/

require_once 'Transcript.class.php';

class LegacyCacheFile {
class Legacy {
private static $InstanceLegacy = NULL;
public $Transcript;
private $data;
Expand Down Expand Up @@ -111,7 +109,7 @@ public function getFields() {

public static function getInstanceLegacy($cachefile = NULL, $tmpDir, $viewerconfig) {
if (!self::$InstanceLegacy) {
self::$InstanceLegacy = new LegacyCacheFile($cachefile, $tmpDir, $viewerconfig);
self::$InstanceLegacy = new Legacy($cachefile, $tmpDir, $viewerconfig);
}
return self::$InstanceLegacy;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Ohms\Interview;
/*
* Model for the XML Version3CacheFile
*
Expand All @@ -7,10 +7,11 @@
* @license http://www.uky.edu
*/

require_once 'Transcript.class.php';
use Ohms\Transcript;

if(!isset($_GET['translate'])) $_GET['translate'] = '0';

class Version3CacheFile {
class Version3 {
private static $InstanceVersion3 = NULL;
public $Transcript;
private $data;
Expand Down Expand Up @@ -156,7 +157,7 @@ public function getFields() {

public static function getInstanceVersion3($cachefile = NULL,$tmpDir,$viewerconfig) {
if (!self::$InstanceVersion3) {
self::$InstanceVersion3 = new Version3CacheFile($cachefile,$tmpDir,$viewerconfig);
self::$InstanceVersion3 = new Version3($cachefile,$tmpDir,$viewerconfig);
}
return self::$InstanceVersion3;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Transcript.class.php → app/Ohms/Transcript.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Ohms;
class Transcript {
private $transcript;
private $chunks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
<?php namespace Ohms;

use Ohms\Interview;

session_start();
require_once 'lib/CacheFile.class.php';

class ViewerController {
private $cacheFile;
Expand All @@ -9,7 +11,7 @@ class ViewerController {
private $config;
public function __construct($cacheFileName) {
$this->config = parse_ini_file("config/config.ini",true);
$this->cacheFile = CacheFile::getInstance($cacheFileName,$this->config['tmpDir'],$this->config);
$this->cacheFile = Interview::getInstance($cacheFileName,$this->config['tmpDir'],$this->config);
$this->cacheFileName = $cacheFileName;
}

Expand Down
3 changes: 3 additions & 0 deletions app/init.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"autoload": {
"psr-4": {
"Ohms\\": "app/Ohms"
}
}
}
5 changes: 3 additions & 2 deletions render.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use Ohms\ViewerController;

require_once 'lib/ViewerController.class.php';
require_once 'app/init.php';

if(isset($_REQUEST['cachefile'])) {
$kw = (isset($_REQUEST['kw'])) ? $_REQUEST['kw'] : NULL;
Expand All @@ -14,4 +15,4 @@
exit();
}

?>
?>
7 changes: 7 additions & 0 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInit9387792ad7c03b8c2bde1beda1e24982::getLoader();
Loading

0 comments on commit 7319829

Please sign in to comment.