Skip to content

Commit

Permalink
Use Composer autoloader where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbirth committed Jun 29, 2016
1 parent 1c31883 commit 66d40f3
Show file tree
Hide file tree
Showing 20 changed files with 13 additions and 55 deletions.
1 change: 0 additions & 1 deletion JSON_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

require_once ("base.php");
require_once ("book.php");

class JSONRenderer
{
Expand Down
2 changes: 0 additions & 2 deletions author.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @author Sébastien Lucas <[email protected]>
*/

require_once('base.php');

class Author extends Base {
const ALL_AUTHORS_ID = "cops:authors";

Expand Down
2 changes: 2 additions & 0 deletions base.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @author S�bastien Lucas <[email protected]>
*/

require_once 'config.php';

define ("VERSION", "1.0.0RC4");
define ("DB", "db");
date_default_timezone_set($config['default_timezone']);
Expand Down
11 changes: 0 additions & 11 deletions book.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
* @author Sébastien Lucas <[email protected]>
*/

require_once('base.php');
require_once('serie.php');
require_once('author.php');
require_once('rating.php');
require_once('publisher.php');
require_once('tag.php');
require_once('language.php');
require_once("customcolumn.php");
require_once('data.php');
require_once('resources/php-epub-meta/epub.php');

// Silly thing because PHP forbid string concatenation in class const
define ('SQL_BOOKS_LEFT_JOIN', "left outer join comments on comments.book = books.id
left outer join books_ratings_link on books_ratings_link.book = books.id
Expand Down
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"require-dev": {
"sauce/sausage": ">=0.12.0"
},
"autoload": {
"classmap": ["resources/", "JSON_Renderer.php", "OPDS_Renderer.php", "author.php", "base.php", "book.php",
"customcolumn.php", "data.php", "language.php", "publisher.php", "rating.php", "serie.php", "tag.php"]
},
"repositories": [
{
"type": "package",
Expand All @@ -39,6 +43,9 @@
"type": "git",
"url": "https://github.com/seblucas/doT-php",
"reference": "master"
},
"autoload": {
"classmap": ["./"]
}
}
},
Expand Down
1 change: 1 addition & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @author Sébastien Lucas <[email protected]>
*/

require_once dirname(__FILE__) . '/vendor/autoload.php';
require_once 'config_default.php';
if (file_exists(dirname(__FILE__) . '/config_local.php') && (php_sapi_name() !== 'cli')) {
require_once 'config_local.php';
Expand Down
2 changes: 0 additions & 2 deletions customcolumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @author Sébastien Lucas <[email protected]>
*/

require_once('base.php');

class CustomColumn extends Base {
const ALL_CUSTOMS_ID = "cops:custom";

Expand Down
2 changes: 0 additions & 2 deletions data.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @author Sébastien Lucas <[email protected]>
*/

require_once('base.php');

class Data extends Base {
public $id;
public $name;
Expand Down
2 changes: 0 additions & 2 deletions epubfs.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

require_once ("config.php");
require_once ("base.php");
require_once ("book.php");
require_once ("resources/php-epub-meta/epub.php");

function getComponentContent ($book, $component, $add) {
$data = $book->component ($component);
Expand Down
2 changes: 0 additions & 2 deletions epubreader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

require_once ("config.php");
require_once ("base.php");
require_once ("book.php");
require_once ("resources/php-epub-meta/epub.php");

header ("Content-Type: text/html;charset=utf-8");

Expand Down
5 changes: 0 additions & 5 deletions feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@

require_once ("config.php");
require_once ("base.php");
require_once ("author.php");
require_once ("serie.php");
require_once ("tag.php");
require_once ("book.php");
require_once ("OPDS_renderer.php");

header ("Content-Type:application/xml");
$page = getURLParam ("page", Base::PAGE_INDEX);
Expand Down
2 changes: 0 additions & 2 deletions fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/

require_once ("config.php");
require_once ("book.php");
require_once ("data.php");

global $config;

Expand Down
1 change: 0 additions & 1 deletion getJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

require_once ("config.php");
require_once ("JSON_renderer.php");

header ("Content-Type:application/json;charset=utf-8");

Expand Down
11 changes: 1 addition & 10 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@
*/

require_once ("config.php");
require_once ("base.php");
require_once ("author.php");
require_once ("rating.php");
require_once ("publisher.php");
require_once ("serie.php");
require_once ("tag.php");
require_once ("language.php");
require_once ("customcolumn.php");
require_once ("book.php");
require_once ("vendor/seblucas/dot-php/doT.php");
require_once "base.php";

// If we detect that an OPDS reader try to connect try to redirect to feed.php
if (preg_match("/(MantanoReader|FBReader|Stanza|Marvin|Aldiko|Moon+ Reader|Chunky|AlReader|org\.ebookdroid)/", $_SERVER['HTTP_USER_AGENT'])) {
Expand Down
4 changes: 1 addition & 3 deletions language.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* @author Sébastien Lucas <[email protected]>
*/

require_once('base.php');

class language extends Base {
class Language extends Base {
const ALL_LANGUAGES_ID = "cops:languages";

public $id;
Expand Down
2 changes: 0 additions & 2 deletions publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @author At Libitum <[email protected]>
*/

require_once('base.php');

class Publisher extends Base {
const ALL_PUBLISHERS_ID = "cops:publishers";
const PUBLISHERS_COLUMNS = "publishers.id as id, publishers.name as name, count(*) as count";
Expand Down
2 changes: 0 additions & 2 deletions rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @author Michael Pfitzner
*/

require_once('base.php');

class Rating extends Base {
const ALL_RATING_ID = "cops:rating";

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

require_once dirname(__FILE__) . '/vendor/autoload.php';

require_once ("config.php");
require_once "book.php";

function checkConfiguration () {
global $config;
Expand Down
2 changes: 0 additions & 2 deletions serie.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @author Sébastien Lucas <[email protected]>
*/

require_once('base.php');

class Serie extends Base {
const ALL_SERIES_ID = "cops:series";
const SERIES_COLUMNS = "series.id as id, series.name as name, series.sort as sort, count(*) as count";
Expand Down
4 changes: 1 addition & 3 deletions tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* @author Sébastien Lucas <[email protected]>
*/

require_once('base.php');

class tag extends Base {
class Tag extends Base {
const ALL_TAGS_ID = "cops:tags";
const TAG_COLUMNS = "tags.id as id, tags.name as name, count(*) as count";
const SQL_ALL_TAGS = "select {0} from tags, books_tags_link where tags.id = tag group by tags.id, tags.name order by tags.name";
Expand Down

0 comments on commit 66d40f3

Please sign in to comment.