diff --git a/JSON_renderer.php b/JSON_renderer.php index e5ddaaec8..87c0cbd59 100644 --- a/JSON_renderer.php +++ b/JSON_renderer.php @@ -7,7 +7,6 @@ */ require_once ("base.php"); -require_once ("book.php"); class JSONRenderer { diff --git a/author.php b/author.php index 6149bd3ac..1cee0223f 100644 --- a/author.php +++ b/author.php @@ -6,8 +6,6 @@ * @author Sébastien Lucas */ -require_once('base.php'); - class Author extends Base { const ALL_AUTHORS_ID = "cops:authors"; diff --git a/base.php b/base.php index f36c144a3..4128632c6 100644 --- a/base.php +++ b/base.php @@ -6,6 +6,8 @@ * @author S�bastien Lucas */ +require_once 'config.php'; + define ("VERSION", "1.0.0RC4"); define ("DB", "db"); date_default_timezone_set($config['default_timezone']); diff --git a/book.php b/book.php index 63a463625..067e9dd85 100644 --- a/book.php +++ b/book.php @@ -6,17 +6,6 @@ * @author Sébastien Lucas */ -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 diff --git a/composer.json b/composer.json index 37322527e..e6b41f754 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -39,6 +43,9 @@ "type": "git", "url": "https://github.com/seblucas/doT-php", "reference": "master" + }, + "autoload": { + "classmap": ["./"] } } }, diff --git a/config.php b/config.php index 29902440f..7d06d9b0e 100644 --- a/config.php +++ b/config.php @@ -6,6 +6,7 @@ * @author Sébastien Lucas */ +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'; diff --git a/customcolumn.php b/customcolumn.php index 9b12cd01d..19803e757 100644 --- a/customcolumn.php +++ b/customcolumn.php @@ -6,8 +6,6 @@ * @author Sébastien Lucas */ -require_once('base.php'); - class CustomColumn extends Base { const ALL_CUSTOMS_ID = "cops:custom"; diff --git a/data.php b/data.php index 718ae681d..989025372 100644 --- a/data.php +++ b/data.php @@ -6,8 +6,6 @@ * @author Sébastien Lucas */ -require_once('base.php'); - class Data extends Base { public $id; public $name; diff --git a/epubfs.php b/epubfs.php index f36bee834..a2f5ff8d0 100644 --- a/epubfs.php +++ b/epubfs.php @@ -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); diff --git a/epubreader.php b/epubreader.php index e3ddcfd62..878bea845 100644 --- a/epubreader.php +++ b/epubreader.php @@ -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"); diff --git a/feed.php b/feed.php index c20dbaad2..e5feb763c 100644 --- a/feed.php +++ b/feed.php @@ -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); diff --git a/fetch.php b/fetch.php index 108450dcc..069a54f9d 100644 --- a/fetch.php +++ b/fetch.php @@ -7,8 +7,6 @@ */ require_once ("config.php"); - require_once ("book.php"); - require_once ("data.php"); global $config; diff --git a/getJSON.php b/getJSON.php index 2697d1917..213c3aefe 100644 --- a/getJSON.php +++ b/getJSON.php @@ -8,7 +8,6 @@ */ require_once ("config.php"); - require_once ("JSON_renderer.php"); header ("Content-Type:application/json;charset=utf-8"); diff --git a/index.php b/index.php index e83230c29..7d02ea54d 100644 --- a/index.php +++ b/index.php @@ -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'])) { diff --git a/language.php b/language.php index 568923ec6..ece8c3e8b 100644 --- a/language.php +++ b/language.php @@ -6,9 +6,7 @@ * @author Sébastien Lucas */ -require_once('base.php'); - -class language extends Base { +class Language extends Base { const ALL_LANGUAGES_ID = "cops:languages"; public $id; diff --git a/publisher.php b/publisher.php index c8ca878f4..25ea6f2b8 100644 --- a/publisher.php +++ b/publisher.php @@ -6,8 +6,6 @@ * @author At Libitum */ -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"; diff --git a/rating.php b/rating.php index e3d521457..a50ddab30 100644 --- a/rating.php +++ b/rating.php @@ -6,8 +6,6 @@ * @author Michael Pfitzner */ -require_once('base.php'); - class Rating extends Base { const ALL_RATING_ID = "cops:rating"; diff --git a/sendtomail.php b/sendtomail.php index 22ac8a5d2..f4bf86ce4 100644 --- a/sendtomail.php +++ b/sendtomail.php @@ -1,9 +1,6 @@ */ -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"; diff --git a/tag.php b/tag.php index 5a90ff134..e306b8959 100644 --- a/tag.php +++ b/tag.php @@ -6,9 +6,7 @@ * @author Sébastien Lucas */ -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";