Skip to content

Commit db131af

Browse files
committed
Create a folder per plugin
Always detect Composer system dependencies to not break installation because of optional modules
1 parent de0a71c commit db131af

File tree

71 files changed

+1425
-1044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1425
-1044
lines changed

.php_cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $finder = Symfony\CS\Finder\DefaultFinder::create()
1010
->in(__DIR__)
1111
->in(__DIR__ . '/modules/localplay')
1212
->in(__DIR__ . '/modules/catalog')
13-
->in(__DIR__ . '/modules/ampacheapi')
13+
->in(__DIR__ . '/modules/plugins')
1414
;
1515

1616
return Symfony\CS\Config\Config::create()

admin/catalog.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222

2323
require_once '../lib/init.php';
24-
require_once AmpConfig::get('prefix') . '/modules/catalog/local.catalog.php';
24+
require_once AmpConfig::get('prefix') . '/modules/catalog/local/local.catalog.php';
2525

2626
if (!Access::check('interface','100')) {
2727
UI::access_denied();

composer.json

+36-45
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,32 @@
88
"config":
99
{
1010
"vendor-dir": "lib/vendor",
11-
"component-dir": "lib/components"
11+
"component-dir": "lib/components",
12+
13+
"platform": {
14+
"ext-curl": "1.0",
15+
"ext-gd": "1.0",
16+
"ext-gmp": "1.0",
17+
"ext-dom": "1.0",
18+
"ext-pcre": "1.0",
19+
"ext-spl": "1.0",
20+
"ext-simplexml": "1.0",
21+
"ext-ctype": "1.0",
22+
"ext-date": "1.0",
23+
"ext-iconv": "1.0",
24+
"ext-libxml": "1.0",
25+
"ext-mbstring": "1.0",
26+
"ext-xmlwriter": "1.0",
27+
"ext-xmlreader": "1.0",
28+
"lib-libxml": "2.6.20"
29+
}
1230
},
1331
"require": {
1432
"php": ">=5.3.0",
33+
"wikimedia/composer-merge-plugin": "1.*",
34+
1535
"james-heinrich/getid3": "1.9.*",
1636
"mikealmond/musicbrainz": "0.2.*",
17-
"guzzlehttp/guzzle": "5.*",
1837
"phpmailer/phpmailer": "5.2.*",
1938
"rmccue/requests": "1.6.*",
2039
"react/react": "0.4.*",
@@ -27,16 +46,10 @@
2746
"happyworm/jplayer": "2.*",
2847
"needim/noty": "2.3.*",
2948
"openid/php-openid": "2.*",
30-
"dropbox/dropbox-sdk": "1.*",
3149
"sabre/dav": "3.*",
3250
"maennchen/zipstream-php": "0.*",
33-
"php-tmdb/api": "2.*",
34-
"moinax/tvdb": "1.*",
3551

36-
"jamiebicknell/Growl-GNTP": "1.*",
3752
"bshaffer/php-echonest-api": "dev-master",
38-
"krixon/xbmc-php-rpc": "dev-master",
39-
"mptre/php-soundcloud": "2.*",
4053

4154
"components/jquery": "2.0.*",
4255
"components/jqueryui": "1.*",
@@ -55,18 +68,6 @@
5568

5669
"repositories":
5770
[
58-
{
59-
"type": "package",
60-
"package": {
61-
"name": "jamiebicknell/Growl-GNTP",
62-
"version": "1.0.0",
63-
"source": {
64-
"url": "https://github.com/jamiebicknell/Growl-GNTP.git",
65-
"type": "git",
66-
"reference": "1.0.0"
67-
}
68-
}
69-
},
7071
{
7172
"type": "package",
7273
"package": {
@@ -79,30 +80,6 @@
7980
}
8081
}
8182
},
82-
{
83-
"type": "package",
84-
"package": {
85-
"name": "krixon/xbmc-php-rpc",
86-
"version": "dev-master",
87-
"source": {
88-
"url": "https://github.com/krixon/xbmc-php-rpc.git",
89-
"type": "git",
90-
"reference": "master"
91-
}
92-
}
93-
},
94-
{
95-
"type": "package",
96-
"package": {
97-
"name": "mptre/php-soundcloud",
98-
"version": "2.3.2",
99-
"source": {
100-
"url": "https://github.com/mptre/php-soundcloud.git",
101-
"type": "git",
102-
"reference": "v2.3.2"
103-
}
104-
}
105-
},
10683
{
10784
"type": "package",
10885
"package": {
@@ -327,5 +304,19 @@
327304
}
328305
}
329306
}
330-
]
307+
],
308+
309+
"extra": {
310+
"merge-plugin": {
311+
"include": [
312+
"composer.local.json",
313+
"modules/catalog/*/composer.json",
314+
"modules/localplay/*/composer.json",
315+
"modules/plugins/*/composer.json"
316+
],
317+
"recurse": false,
318+
"replace": false,
319+
"merge-extra": false
320+
}
321+
}
331322
}

composer.lock

+73-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/PLUGINS

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-------------------------------------------------------------------------------
44

55
Plugins are placed in modules/plugins; the name of the file must be
6-
<Name>.plugin.php, e.g. Dummy.plugin.php. The file must declare a
6+
<Name>/<Name>.plugin.php, e.g. Dummay/Dummy.plugin.php. The file must declare a
77
corresponding class and the name of the class must be prefixed with
88
Ampache, e.g. AmpacheDummy.
99

lib/class/catalog.class.php

+15-11
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public static function create_from_id($id)
221221
/**
222222
* create_catalog_type
223223
* This function attempts to create a catalog type
224-
* all Catalog modules should be located in /modules/catalog/<name>.class.php
224+
* all Catalog modules should be located in /modules/catalog/<name>/<name>.class.php
225225
* @param string $type
226226
* @param int $id
227227
* @return Catalog|null
@@ -232,7 +232,7 @@ public static function create_catalog_type($type, $id=0)
232232
return false;
233233
}
234234

235-
$filename = AmpConfig::get('prefix') . '/modules/catalog/' . $type . '.catalog.php';
235+
$filename = AmpConfig::get('prefix') . '/modules/catalog/' . $type . '/' . $type . '.catalog.php';
236236
$include = require_once $filename;
237237

238238
if (!$include) {
@@ -313,7 +313,8 @@ public static function show_catalog_types($divback = 'catalog_type_fields')
313313
public static function get_catalog_types()
314314
{
315315
/* First open the dir */
316-
$handle = opendir(AmpConfig::get('prefix') . '/modules/catalog');
316+
$basedir = AmpConfig::get('prefix') . '/modules/catalog';
317+
$handle = opendir($basedir);
317318

318319
if (!is_resource($handle)) {
319320
debug_event('catalog', 'Error: Unable to read catalog types directory', '1');
@@ -323,16 +324,19 @@ public static function get_catalog_types()
323324
$results = array();
324325

325326
while (false !== ($file = readdir($handle))) {
326-
if (substr($file, -11, 11) != 'catalog.php') {
327+
/* Make sure it is a dir */
328+
if (! is_dir($basedir . '/' . $file)) {
329+
debug_event('catalog', $file . ' is not a directory.', 3);
327330
continue;
328331
}
329-
330-
/* Make sure it isn't a dir */
331-
if (!is_dir($file)) {
332-
/* Get the basename and then everything before catalog */
333-
$filename = basename($file, '.catalog.php');
334-
$results[] = $filename;
332+
333+
// Make sure the plugin base file exists inside the plugin directory
334+
if (! file_exists($basedir . '/' . $file . '/' . $file . '.catalog.php')) {
335+
debug_event('catalog', 'Missing class for ' . $file, 3);
336+
continue;
335337
}
338+
339+
$results[] = $file;
336340
} // end while
337341

338342
return $results;
@@ -613,7 +617,7 @@ public static function create($data)
613617
}
614618

615619
$insert_id = 0;
616-
$filename = AmpConfig::get('prefix') . '/modules/catalog/' . $type . '.catalog.php';
620+
$filename = AmpConfig::get('prefix') . '/modules/catalog/' . $type . '/' . $type . '.catalog.php';
617621
$include = require_once $filename;
618622

619623
if ($include) {

lib/class/localplay.class.php

+13-9
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private function _load_player()
9999
return false;
100100
}
101101

102-
$filename = AmpConfig::get('prefix') . '/modules/localplay/' . $this->type . '.controller.php';
102+
$filename = AmpConfig::get('prefix') . '/modules/localplay/' . $this->type . '/' . $this->type . '.controller.php';
103103
$include = require_once $filename;
104104

105105
if (!$include) {
@@ -138,7 +138,8 @@ public function format_name($name,$id)
138138
public static function get_controllers()
139139
{
140140
/* First open the dir */
141-
$handle = opendir(AmpConfig::get('prefix') . '/modules/localplay');
141+
$basedir = AmpConfig::get('prefix') . '/modules/localplay';
142+
$handle = opendir($basedir);
142143

143144
if (!is_resource($handle)) {
144145
debug_event('Localplay','Error: Unable to read localplay controller directory','1');
@@ -148,16 +149,19 @@ public static function get_controllers()
148149
$results = array();
149150

150151
while (false !== ($file = readdir($handle))) {
151-
if (substr($file,-14,14) != 'controller.php') {
152+
/* Make sure it is a dir */
153+
if (! is_dir($basedir . '/' . $file)) {
154+
debug_event('Localplay', $file . ' is not a directory.', 3);
152155
continue;
153156
}
154-
155-
/* Make sure it isn't a dir */
156-
if (!is_dir($file)) {
157-
/* Get the basename and then everything before controller */
158-
$filename = basename($file,'.controller.php');
159-
$results[] = $filename;
157+
158+
// Make sure the plugin base file exists inside the plugin directory
159+
if (! file_exists($basedir . '/' . $file . '/' . $file . '.controller.php')) {
160+
debug_event('Localplay', 'Missing class for ' . $file, 3);
161+
continue;
160162
}
163+
164+
$results[] = $file;
161165
} // end while
162166

163167
return $results;

0 commit comments

Comments
 (0)