Version Description
- major changes in the code base to support upcoming features
PLEASE TEST and report any bugs
further interface cleanup
fully implemented autoloading
added composer definitions
hook modules deep into ad selection and display
autoload modules (for base plugin and add-ons)
added
advanced-ads-ad-select-args
filter to modify ad selection argumentsadded
advanced-ads-ad-select-methods
filter to append or override ad code selection methodsstandardise and autoload modules
add AJAX handler
Download this release
Release Info
Developer | webzunft |
Plugin | Advanced Ads |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.9 to 1.5.0
- admin/assets/js/inline-edit-group-ads.js +0 -101
- admin/class-advanced-ads-admin.php +19 -13
- admin/includes/class-overview-widgets.php +7 -5
- admin/includes/index.php +0 -1
- admin/views/ad-display-metabox.php +8 -7
- advanced-ads.php +13 -49
- classes/ad-ajax.php +55 -0
- classes/ad-model.php +107 -0
- classes/ad-select.php +132 -0
- classes/ad.php +4 -4
- classes/ad_ajax_callbacks.php +1 -0
- classes/ad_group.php +92 -90
- classes/ad_placements.php +8 -10
- classes/plugin.php +335 -0
- classes/widget.php +3 -2
- composer.json +24 -4
- composer.lock +145 -0
- includes/array_ad_conditions.php +6 -1
- includes/autoloader.php +0 -31
- {public → includes}/functions.php +4 -33
- includes/index.php +0 -1
- includes/load_modules.php +70 -0
- languages/plugin-name.pot +0 -31
- modules/gadsense/admin/class-gadsense-admin.php +137 -146
- modules/gadsense/config.php +14 -0
- modules/gadsense/main.php +21 -25
- public/class-advanced-ads.php +260 -483
- readme.txt +17 -123
- vendor/autoload.php +7 -0
- vendor/autoload_52.php +7 -0
- vendor/composer/ClassLoader.php +413 -0
- vendor/composer/ClassLoader52.php +271 -0
- vendor/composer/autoload_classmap.php +87 -0
- vendor/composer/autoload_namespaces.php +11 -0
- vendor/composer/autoload_psr4.php +9 -0
- vendor/composer/autoload_real.php +50 -0
- vendor/composer/autoload_real_52.php +44 -0
- vendor/composer/installed.json +133 -0
- vendor/composer/installers/.editorconfig +10 -0
- vendor/composer/installers/.gitignore +3 -0
- vendor/composer/installers/.travis.yml +14 -0
- vendor/composer/installers/LICENSE +19 -0
- vendor/composer/installers/README.md +191 -0
- vendor/composer/installers/composer.json +77 -0
- vendor/composer/installers/phpunit.xml.dist +25 -0
- vendor/composer/installers/src/Composer/Installers/AglInstaller.php +21 -0
- vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php +45 -0
- vendor/composer/installers/src/Composer/Installers/BaseInstaller.php +131 -0
- vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php +78 -0
- vendor/composer/installers/src/Composer/Installers/ChefInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php +10 -0
- vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php +12 -0
- vendor/composer/installers/src/Composer/Installers/CraftInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php +21 -0
- vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php +50 -0
- vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php +16 -0
- vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php +14 -0
- vendor/composer/installers/src/Composer/Installers/ElggInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/FuelInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/GravInstaller.php +30 -0
- vendor/composer/installers/src/Composer/Installers/HuradInstaller.php +25 -0
- vendor/composer/installers/src/Composer/Installers/Installer.php +163 -0
- vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php +15 -0
- vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php +10 -0
- vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php +16 -0
- vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/MakoInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php +50 -0
- vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php +111 -0
- vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php +47 -0
- vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php +46 -0
- vendor/composer/installers/src/Composer/Installers/OxidInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/PPIInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php +21 -0
- vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php +32 -0
- vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php +10 -0
- vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php +10 -0
- vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php +22 -0
- vendor/composer/installers/src/Composer/Installers/SMFInstaller.php +10 -0
- vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php +58 -0
- vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php +36 -0
- vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php +26 -0
- vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php +14 -0
- vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php +38 -0
- vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php +12 -0
- vendor/composer/installers/src/Composer/Installers/TuskInstaller.php +14 -0
- vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php +10 -0
- vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/ZendInstaller.php +11 -0
- vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php +10 -0
- vendor/composer/installers/src/bootstrap.php +13 -0
- vendor/composer/installers/tests/Composer/Installers/Test/AsgardInstallerTest.php +61 -0
- vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php +115 -0
- vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php +89 -0
- vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php +63 -0
- vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php +422 -0
- vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php +66 -0
- vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php +66 -0
- vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php +44 -0
- vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php +63 -0
- vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php +64 -0
- vendor/composer/installers/tests/bootstrap.php +4 -0
- vendor/xrstf/composer-php52/.hg_archival.txt +4 -0
- vendor/xrstf/composer-php52/.hgtags +17 -0
- vendor/xrstf/composer-php52/LICENSE +19 -0
- vendor/xrstf/composer-php52/README.md +29 -0
- vendor/xrstf/composer-php52/composer.json +27 -0
- vendor/xrstf/composer-php52/lib/xrstf/Composer52/AutoloadGenerator.php +324 -0
- vendor/xrstf/composer-php52/lib/xrstf/Composer52/ClassLoader.php +271 -0
- vendor/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php +44 -0
admin/assets/js/inline-edit-group-ads.js
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
/* saving ad group ad settings */
|
2 |
-
|
3 |
-
var inlineEditAdGroupAds;
|
4 |
-
(function($) {
|
5 |
-
inlineEditAdGroupAds = {
|
6 |
-
init: function() {
|
7 |
-
var t = this;
|
8 |
-
$('#the-list').on('click', 'a.edit-ad-group-ads', function() {
|
9 |
-
inlineEditAdGroupAds.edit(this);
|
10 |
-
return false;
|
11 |
-
});
|
12 |
-
$('#the-list').on('click', 'a.cancel', function() {
|
13 |
-
return inlineEditAdGroupAds.revert();
|
14 |
-
});
|
15 |
-
$('#the-list').on('click', 'a.save', function() {
|
16 |
-
return inlineEditAdGroupAds.save(this);
|
17 |
-
});
|
18 |
-
$('#the-list').on('keydown', 'input, select', function() {
|
19 |
-
if (e.which === 13) {
|
20 |
-
return inlineEditAdGroupAds.save(this);
|
21 |
-
}
|
22 |
-
});
|
23 |
-
$('#posts-filter input[type="submit"]').mousedown(function() {
|
24 |
-
t.revert();
|
25 |
-
});
|
26 |
-
},
|
27 |
-
edit: function(link) {
|
28 |
-
var td, id, t = this;
|
29 |
-
// get group id
|
30 |
-
id = t.getId(link);
|
31 |
-
// get container
|
32 |
-
td = $(link).parents('td');
|
33 |
-
// load form with information
|
34 |
-
params = {
|
35 |
-
action: 'advads-ad-group-ads-form',
|
36 |
-
group_id: id,
|
37 |
-
};
|
38 |
-
$.post(ajaxurl, params,
|
39 |
-
// append return
|
40 |
-
function(r) {
|
41 |
-
if (r) {
|
42 |
-
// hide all child elements
|
43 |
-
td.children('*').hide();
|
44 |
-
// display the form
|
45 |
-
$(r).appendTo(td);
|
46 |
-
}
|
47 |
-
}
|
48 |
-
);
|
49 |
-
return false;
|
50 |
-
},
|
51 |
-
save: function(link) {
|
52 |
-
var params, td, id, t = this;
|
53 |
-
// get group id
|
54 |
-
id = t.getId(link);
|
55 |
-
// get container
|
56 |
-
td = $(link).parents('td');
|
57 |
-
td.find('.ad-group-ads-form .spinner').show();
|
58 |
-
params = {
|
59 |
-
action: 'advads-ad-group-ads-form-save',
|
60 |
-
group_id: id,
|
61 |
-
fields: ''
|
62 |
-
};
|
63 |
-
params.fields = td.find(':input').serialize();
|
64 |
-
// make ajax request
|
65 |
-
$.post(ajaxurl, params, function(r) {
|
66 |
-
td.find('.ad-group-ads-form .spinner').hide();
|
67 |
-
if (r) {
|
68 |
-
t.revert(); // show normal table
|
69 |
-
|
70 |
-
$.each(r, function(key, value){
|
71 |
-
// search the field with the ad weight and change the value
|
72 |
-
td.find('.ad-weight-' + key).html(value);
|
73 |
-
})
|
74 |
-
}
|
75 |
-
|
76 |
-
}, "json"
|
77 |
-
);
|
78 |
-
return false;
|
79 |
-
},
|
80 |
-
// remove edit form and display the other elements again
|
81 |
-
revert: function() {
|
82 |
-
var td = $('table.widefat .ad-group-ads-form').parents('td');
|
83 |
-
if (td) {
|
84 |
-
$('table.widefat .spinner').hide();
|
85 |
-
td.find('.ad-group-ads-form').remove();
|
86 |
-
td.find('*').show();
|
87 |
-
}
|
88 |
-
|
89 |
-
return false;
|
90 |
-
},
|
91 |
-
// get the id of the group from the link clicked
|
92 |
-
getId: function(link) {
|
93 |
-
groupid = $(link).parents('td').find('.ad-group-id').val();
|
94 |
-
return parseInt(groupid);
|
95 |
-
;
|
96 |
-
}
|
97 |
-
};
|
98 |
-
$(document).ready(function() {
|
99 |
-
inlineEditAdGroupAds.init();
|
100 |
-
});
|
101 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-advanced-ads-admin.php
CHANGED
@@ -14,6 +14,7 @@
|
|
14 |
* Plugin class. This class should ideally be used to work with the
|
15 |
* administrative side of the WordPress site.
|
16 |
*
|
|
|
17 |
*
|
18 |
* @package Advanced_Ads_Admin
|
19 |
* @author Thomas Maier <thomas.maier@webgilde.com>
|
@@ -67,7 +68,14 @@ class Advanced_Ads_Admin {
|
|
67 |
* @since 1.0.0
|
68 |
*/
|
69 |
private function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
|
|
71 |
/*
|
72 |
* Call $plugin_slug from public plugin class.
|
73 |
*
|
@@ -123,7 +131,6 @@ class Advanced_Ads_Admin {
|
|
123 |
// set 1 column layout on overview page as user and page option
|
124 |
add_filter( 'screen_layout_columns', array('AdvAds_Overview_Widgets_Callbacks', 'one_column_overview_page') );
|
125 |
add_filter( 'get_user_option_screen_layout_toplevel_page_advanced', array( 'AdvAds_Overview_Widgets_Callbacks', 'one_column_overview_page_user') );
|
126 |
-
|
127 |
}
|
128 |
|
129 |
/**
|
@@ -271,7 +278,7 @@ class Advanced_Ads_Admin {
|
|
271 |
$success = __( 'Placements updated', ADVADS_SLUG );
|
272 |
}
|
273 |
$placement_types = Advads_Ad_Placements::get_placement_types();
|
274 |
-
$placements = Advanced_Ads::get_ad_placements_array();
|
275 |
// load ads and groups for select field
|
276 |
|
277 |
// display view
|
@@ -288,9 +295,9 @@ class Advanced_Ads_Admin {
|
|
288 |
$plugin = Advanced_Ads::get_instance();
|
289 |
$plugin_options = $plugin->options();
|
290 |
$ads_by_conditions = $plugin->get_ads_by_conditions_array();
|
291 |
-
$ad_placements = Advanced_Ads::get_ad_placements_array();
|
292 |
|
293 |
-
|
294 |
}
|
295 |
|
296 |
/**
|
@@ -358,16 +365,15 @@ class Advanced_Ads_Admin {
|
|
358 |
$tag = false;
|
359 |
}
|
360 |
|
361 |
-
|
362 |
break;
|
363 |
|
364 |
default :
|
365 |
$title = $tax->labels->name;
|
366 |
-
|
367 |
-
|
368 |
-
$wp_list_table = _get_list_table('WP_Terms_List_Table');
|
369 |
// load template
|
370 |
-
|
371 |
}
|
372 |
}
|
373 |
|
@@ -416,7 +422,7 @@ class Advanced_Ads_Admin {
|
|
416 |
}
|
417 |
$ad = new Advads_Ad( $post->ID );
|
418 |
|
419 |
-
|
420 |
}
|
421 |
|
422 |
/**
|
@@ -462,7 +468,7 @@ class Advanced_Ads_Admin {
|
|
462 |
|
463 |
$enabled = ( ! empty($ad->expiry_date)) ? 1 : 0;
|
464 |
|
465 |
-
|
466 |
}
|
467 |
|
468 |
/**
|
@@ -498,7 +504,7 @@ class Advanced_Ads_Admin {
|
|
498 |
return; }
|
499 |
$view = plugin_dir_path( __FILE__ ) . 'views/' . $view;
|
500 |
if ( is_file( $view ) ) {
|
501 |
-
|
502 |
}
|
503 |
}
|
504 |
|
@@ -991,7 +997,7 @@ class Advanced_Ads_Admin {
|
|
991 |
);
|
992 |
|
993 |
// get number of ads
|
994 |
-
$recent_ads = Advanced_Ads::get_ads();
|
995 |
echo '<p>';
|
996 |
printf(__( '%d ads – <a href="%s">manage</a> - <a href="%s">new</a>', ADVADS_SLUG ),
|
997 |
count( $recent_ads ),
|
14 |
* Plugin class. This class should ideally be used to work with the
|
15 |
* administrative side of the WordPress site.
|
16 |
*
|
17 |
+
* +TODO fix relative paths
|
18 |
*
|
19 |
* @package Advanced_Ads_Admin
|
20 |
* @author Thomas Maier <thomas.maier@webgilde.com>
|
68 |
* @since 1.0.0
|
69 |
*/
|
70 |
private function __construct() {
|
71 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
72 |
+
new Advads_Ad_Ajax_Callbacks;
|
73 |
+
} else {
|
74 |
+
add_action( 'plugins_loaded', array( $this, 'wp_plugins_loaded' ) );
|
75 |
+
}
|
76 |
+
}
|
77 |
|
78 |
+
public function wp_plugins_loaded() {
|
79 |
/*
|
80 |
* Call $plugin_slug from public plugin class.
|
81 |
*
|
131 |
// set 1 column layout on overview page as user and page option
|
132 |
add_filter( 'screen_layout_columns', array('AdvAds_Overview_Widgets_Callbacks', 'one_column_overview_page') );
|
133 |
add_filter( 'get_user_option_screen_layout_toplevel_page_advanced', array( 'AdvAds_Overview_Widgets_Callbacks', 'one_column_overview_page_user') );
|
|
|
134 |
}
|
135 |
|
136 |
/**
|
278 |
$success = __( 'Placements updated', ADVADS_SLUG );
|
279 |
}
|
280 |
$placement_types = Advads_Ad_Placements::get_placement_types();
|
281 |
+
$placements = Advanced_Ads::get_ad_placements_array(); // -TODO use model
|
282 |
// load ads and groups for select field
|
283 |
|
284 |
// display view
|
295 |
$plugin = Advanced_Ads::get_instance();
|
296 |
$plugin_options = $plugin->options();
|
297 |
$ads_by_conditions = $plugin->get_ads_by_conditions_array();
|
298 |
+
$ad_placements = Advanced_Ads::get_ad_placements_array(); // -TODO use model
|
299 |
|
300 |
+
include( 'views/debug.php' );
|
301 |
}
|
302 |
|
303 |
/**
|
365 |
$tag = false;
|
366 |
}
|
367 |
|
368 |
+
include( 'views/ad-group-edit.php' );
|
369 |
break;
|
370 |
|
371 |
default :
|
372 |
$title = $tax->labels->name;
|
373 |
+
$wp_list_table = _get_list_table('WP_Terms_List_Table');
|
374 |
+
|
|
|
375 |
// load template
|
376 |
+
include( 'views/ad-group.php' );
|
377 |
}
|
378 |
}
|
379 |
|
422 |
}
|
423 |
$ad = new Advads_Ad( $post->ID );
|
424 |
|
425 |
+
include('views/ad_info.php');
|
426 |
}
|
427 |
|
428 |
/**
|
468 |
|
469 |
$enabled = ( ! empty($ad->expiry_date)) ? 1 : 0;
|
470 |
|
471 |
+
include(plugin_dir_path( __FILE__ ) . 'views/ad-submitbox-meta.php');
|
472 |
}
|
473 |
|
474 |
/**
|
504 |
return; }
|
505 |
$view = plugin_dir_path( __FILE__ ) . 'views/' . $view;
|
506 |
if ( is_file( $view ) ) {
|
507 |
+
include( $view );
|
508 |
}
|
509 |
}
|
510 |
|
997 |
);
|
998 |
|
999 |
// get number of ads
|
1000 |
+
$recent_ads = Advanced_Ads::get_instance()->get_model()->get_ads();
|
1001 |
echo '<p>';
|
1002 |
printf(__( '%d ads – <a href="%s">manage</a> - <a href="%s">new</a>', ADVADS_SLUG ),
|
1003 |
count( $recent_ads ),
|
admin/includes/class-overview-widgets.php
CHANGED
@@ -66,15 +66,16 @@ class AdvAds_Overview_Widgets_Callbacks {
|
|
66 |
*/
|
67 |
public static function render_ad_widget(){
|
68 |
|
69 |
-
$
|
|
|
70 |
|
71 |
?><p class="description"><?php _e( 'Ads are the smallest unit, containing the content or a single ad to be displayed.', ADVADS_SLUG ); ?></p>
|
72 |
-
|
73 |
printf(__( '<a href="%s">Manage</a> them or <a href="%s">create</a> a new one', ADVADS_SLUG ),
|
74 |
'edit.php?post_type='. Advanced_Ads::POST_TYPE_SLUG,
|
75 |
'post-new.php?post_type='. Advanced_Ads::POST_TYPE_SLUG);
|
76 |
?>
|
77 |
-
|
78 |
|
79 |
// get next steps
|
80 |
self::render_next_steps( $recent_ads );
|
@@ -84,8 +85,9 @@ class AdvAds_Overview_Widgets_Callbacks {
|
|
84 |
* render next-steps
|
85 |
*/
|
86 |
private static function render_next_steps($recent_ads = array()){
|
87 |
-
$
|
88 |
-
$
|
|
|
89 |
|
90 |
$next_steps = array();
|
91 |
|
66 |
*/
|
67 |
public static function render_ad_widget(){
|
68 |
|
69 |
+
$model = Advanced_Ads::get_instance()->get_model();
|
70 |
+
$recent_ads = $model->get_ads();
|
71 |
|
72 |
?><p class="description"><?php _e( 'Ads are the smallest unit, containing the content or a single ad to be displayed.', ADVADS_SLUG ); ?></p>
|
73 |
+
<p><?php printf( __( 'You have published %d ads.', ADVADS_SLUG ), count( $recent_ads ) );?></p><p><?php
|
74 |
printf(__( '<a href="%s">Manage</a> them or <a href="%s">create</a> a new one', ADVADS_SLUG ),
|
75 |
'edit.php?post_type='. Advanced_Ads::POST_TYPE_SLUG,
|
76 |
'post-new.php?post_type='. Advanced_Ads::POST_TYPE_SLUG);
|
77 |
?>
|
78 |
+
</p><?php
|
79 |
|
80 |
// get next steps
|
81 |
self::render_next_steps( $recent_ads );
|
85 |
* render next-steps
|
86 |
*/
|
87 |
private static function render_next_steps($recent_ads = array()){
|
88 |
+
$model = Advanced_Ads::get_instance()->get_model();
|
89 |
+
$groups = $model->get_ad_groups();
|
90 |
+
$placements = $model->get_ad_placements_array();
|
91 |
|
92 |
$next_steps = array();
|
93 |
|
admin/includes/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
admin/views/ad-display-metabox.php
CHANGED
@@ -23,12 +23,13 @@ jQuery(document).ready(function() {
|
|
23 |
<li><?php printf( __( 'Learn more about display conditions from the <a href="%s" target="_blank">manual</a>.', ADVADS_SLUG ), 'http://wpadvancedads.com/advancedads/manual/display-conditions/' ); ?></li>
|
24 |
</ul>
|
25 |
<?php
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
32 |
<?php
|
33 |
if ( is_array( $_condition['callback'] ) && method_exists( $_condition['callback'][0], $_condition['callback'][1] ) ) {
|
34 |
call_user_func( array($_condition['callback'][0], $_condition['callback'][1]), $ad ); // works also in php below 5.3
|
@@ -82,4 +83,4 @@ jQuery(document).ready(function() {
|
|
82 |
<?php endif; ?>
|
83 |
</div>
|
84 |
<?php
|
85 |
-
endif;
|
23 |
<li><?php printf( __( 'Learn more about display conditions from the <a href="%s" target="_blank">manual</a>.', ADVADS_SLUG ), 'http://wpadvancedads.com/advancedads/manual/display-conditions/' ); ?></li>
|
24 |
</ul>
|
25 |
<?php
|
26 |
+
// -TODO use model
|
27 |
+
$advanced_ads_ad_conditions = Advanced_Ads::get_ad_conditions();
|
28 |
+
if (is_array($advanced_ads_ad_conditions)) :
|
29 |
+
foreach ($advanced_ads_ad_conditions as $_key => $_condition) :
|
30 |
+
if (!isset($_condition['callback']))
|
31 |
+
continue;
|
32 |
+
?><div class="advanced-ad-display-condition">
|
33 |
<?php
|
34 |
if ( is_array( $_condition['callback'] ) && method_exists( $_condition['callback'][0], $_condition['callback'][1] ) ) {
|
35 |
call_user_func( array($_condition['callback'][0], $_condition['callback'][1]), $ad ); // works also in php below 5.3
|
83 |
<?php endif; ?>
|
84 |
</div>
|
85 |
<?php
|
86 |
+
endif;
|
advanced-ads.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
* Plugin Name: Advanced Ads
|
13 |
* Plugin URI: http://wpadvancedads.com
|
14 |
* Description: Manage and optimize your ads in WordPress
|
15 |
-
* Version: 1.
|
16 |
* Author: Thomas Maier
|
17 |
* Author URI: http://webgilde.com
|
18 |
* Text Domain: advanced-ads
|
@@ -39,62 +39,26 @@ define( 'ADVADS_BASE_DIR', dirname( plugin_basename( __FILE__ ) ) ); // director
|
|
39 |
define( 'ADVADS_SLUG', 'advanced-ads' );
|
40 |
|
41 |
/*----------------------------------------------------------------------------*
|
42 |
-
* Autoloading
|
43 |
*----------------------------------------------------------------------------*/
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
49 |
|
50 |
/*----------------------------------------------------------------------------*
|
51 |
-
* Public-Facing Functionality
|
52 |
*----------------------------------------------------------------------------*/
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
* When the plugin is deleted, the uninstall.php file is loaded.
|
57 |
-
*
|
58 |
-
*/
|
59 |
-
register_activation_hook( __FILE__, array( 'Advanced_Ads', 'activate' ) );
|
60 |
-
register_deactivation_hook( __FILE__, array( 'Advanced_Ads', 'deactivate' ) );
|
61 |
-
|
62 |
-
add_action( 'plugins_loaded', array( 'Advanced_Ads', 'get_instance' ) );
|
63 |
|
64 |
/*----------------------------------------------------------------------------*
|
65 |
* Dashboard and Administrative Functionality
|
66 |
*----------------------------------------------------------------------------*/
|
67 |
|
68 |
-
if (
|
69 |
-
|
70 |
-
}
|
71 |
-
// load ad conditions array
|
72 |
-
require_once ADVADS_BASE_PATH . 'includes/array_ad_conditions.php';
|
73 |
-
|
74 |
-
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
|
75 |
-
// register all classes with callbacks and hooks here
|
76 |
-
require_once ADVADS_BASE_PATH . 'admin/class-advanced-ads-admin.php';
|
77 |
-
require_once ADVADS_BASE_PATH . 'admin/includes/class-overview-widgets.php';
|
78 |
-
require_once ADVADS_BASE_PATH . 'admin/includes/class-notices.php';
|
79 |
-
|
80 |
-
add_action( 'plugins_loaded', array( 'Advanced_Ads_Admin', 'get_instance' ) );
|
81 |
-
}
|
82 |
-
|
83 |
-
// load public functions
|
84 |
-
require_once ADVADS_BASE_PATH . 'public/functions.php';
|
85 |
-
|
86 |
-
// load widget
|
87 |
-
require_once ADVADS_BASE_PATH . 'classes/widget.php';
|
88 |
-
function advads_widget_init() {
|
89 |
-
register_widget( 'Advads_Widget' );
|
90 |
-
}
|
91 |
-
|
92 |
-
add_action( 'widgets_init', 'advads_widget_init' );
|
93 |
-
|
94 |
-
// Load advads extensions
|
95 |
-
require_once ADVADS_BASE_PATH . 'modules/gadsense/main.php';
|
96 |
-
|
97 |
-
// load modules, if they exist
|
98 |
-
if ( file_exists( ADVADS_BASE_PATH . 'modules/pro/advads_pro.php' ) ){
|
99 |
-
require_once ADVADS_BASE_PATH . 'modules/pro/advads_pro.php';
|
100 |
}
|
12 |
* Plugin Name: Advanced Ads
|
13 |
* Plugin URI: http://wpadvancedads.com
|
14 |
* Description: Manage and optimize your ads in WordPress
|
15 |
+
* Version: 1.5.0
|
16 |
* Author: Thomas Maier
|
17 |
* Author URI: http://webgilde.com
|
18 |
* Text Domain: advanced-ads
|
39 |
define( 'ADVADS_SLUG', 'advanced-ads' );
|
40 |
|
41 |
/*----------------------------------------------------------------------------*
|
42 |
+
* Autoloading, modules and functions
|
43 |
*----------------------------------------------------------------------------*/
|
44 |
+
|
45 |
+
// load public functions (might be used by modules, other plugins or theme)
|
46 |
+
require_once ADVADS_BASE_PATH . 'includes/functions.php';
|
47 |
+
require_once ADVADS_BASE_PATH . 'includes/load_modules.php';
|
48 |
+
|
49 |
+
Advanced_Ads_ModuleLoader::getLoader(); // enable autoloading
|
50 |
|
51 |
/*----------------------------------------------------------------------------*
|
52 |
+
* Public-Facing and Core Functionality
|
53 |
*----------------------------------------------------------------------------*/
|
54 |
|
55 |
+
Advanced_Ads::get_instance();
|
56 |
+
Advanced_Ads_ModuleLoader::loadModules( ADVADS_BASE_PATH . 'modules/' ); // enable modules, requires base class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
/*----------------------------------------------------------------------------*
|
59 |
* Dashboard and Administrative Functionality
|
60 |
*----------------------------------------------------------------------------*/
|
61 |
|
62 |
+
if ( is_admin() ) {
|
63 |
+
Advanced_Ads_Admin::get_instance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
classes/ad-ajax.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Provide public ajax interface.
|
5 |
+
*
|
6 |
+
* @since 1.5.0
|
7 |
+
*/
|
8 |
+
class Advanced_Ads_Ajax {
|
9 |
+
|
10 |
+
private function __construct()
|
11 |
+
{
|
12 |
+
add_action( 'wp_ajax_advads_ad_select', array( $this, 'advads_ajax_ad_select' ) );
|
13 |
+
add_action( 'wp_ajax_nopriv_advads_ad_select', array( $this, 'advads_ajax_ad_select' ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
private static $instance;
|
17 |
+
|
18 |
+
public static function get_instance()
|
19 |
+
{
|
20 |
+
if ( ! isset(self::$instance) ) {
|
21 |
+
self::$instance = new self;
|
22 |
+
}
|
23 |
+
|
24 |
+
return self::$instance;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Simple wp ajax interface for ad selection.
|
29 |
+
*
|
30 |
+
* Provides a single ad given ID and selection method.
|
31 |
+
*/
|
32 |
+
public function advads_ajax_ad_select() {
|
33 |
+
// set proper header
|
34 |
+
header( 'Content-Type: application/json; charset: utf-8' );
|
35 |
+
|
36 |
+
// init handlers
|
37 |
+
$selector = Advanced_Ads_Select::get_instance();
|
38 |
+
$methods = $selector->get_methods();
|
39 |
+
$method = isset( $_REQUEST['ad_method'] ) ? (string) $_REQUEST['ad_method'] : null;
|
40 |
+
$id = isset( $_REQUEST['ad_id'] ) ? (string) $_REQUEST['ad_id'] : null;
|
41 |
+
$arguments = isset( $_REQUEST['ad_args'] ) ? (array) $_REQUEST['ad_args'] : array();
|
42 |
+
|
43 |
+
$response = array();
|
44 |
+
if ( isset( $methods[ $method ] ) && isset( $id ) ) {
|
45 |
+
$content = $selector->get_ad_by_method( $id, $method, $arguments );
|
46 |
+
$response = array( 'status' => 'success', 'item' => $content, 'id' => $id, 'method' => $method );
|
47 |
+
} else {
|
48 |
+
// report error
|
49 |
+
$response = array( 'status' => 'error', 'message' => 'No valid ID or METHOD found.' );
|
50 |
+
}
|
51 |
+
|
52 |
+
echo json_encode( $response );
|
53 |
+
die();
|
54 |
+
}
|
55 |
+
}
|
classes/ad-model.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Advanced_Ads_Model {
|
4 |
+
|
5 |
+
/**
|
6 |
+
*
|
7 |
+
* @var wpdb
|
8 |
+
*/
|
9 |
+
protected $db;
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
protected $ad_conditions;
|
16 |
+
|
17 |
+
/**
|
18 |
+
*
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
protected $ad_placements;
|
22 |
+
|
23 |
+
public function __construct(wpdb $wpdb)
|
24 |
+
{
|
25 |
+
$this->db = $wpdb;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function get_ad_conditions()
|
33 |
+
{
|
34 |
+
if ( ! isset(self::$ad_conditions) ) {
|
35 |
+
$this->ad_conditions = include ADVADS_BASE_PATH . 'includes/array_ad_conditions.php';
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->ad_conditions;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Get all blog ids of blogs in the current network that are:
|
43 |
+
* - not archived
|
44 |
+
* - not spam
|
45 |
+
* - not deleted
|
46 |
+
*
|
47 |
+
* @since 1.0.0
|
48 |
+
* @return array|false The blog ids, false if no matches.
|
49 |
+
*/
|
50 |
+
public function get_blog_ids() {
|
51 |
+
// get an array of blog ids
|
52 |
+
$sql = "SELECT blog_id FROM $this->db->blogs WHERE archived = '0' AND spam = '0' AND deleted = '0'";
|
53 |
+
|
54 |
+
return $this->db->get_col( $sql );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* load all ads based on WP_Query conditions
|
59 |
+
*
|
60 |
+
* @since 1.1.0
|
61 |
+
* @param arr $args WP_Query arguments that are more specific that default
|
62 |
+
* @return arr $ads array with post objects
|
63 |
+
*/
|
64 |
+
public function get_ads($args = array()){
|
65 |
+
// add default WP_Query arguments
|
66 |
+
$args['post_type'] = Advanced_Ads::POST_TYPE_SLUG;
|
67 |
+
$args['posts_per_page'] = -1;
|
68 |
+
if ( empty($args['post_status']) ) { $args['post_status'] = 'publish'; }
|
69 |
+
$ads = new WP_Query( $args );
|
70 |
+
|
71 |
+
return $ads->posts;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* load all ad groups
|
76 |
+
*
|
77 |
+
* @since 1.1.0
|
78 |
+
* @param arr $args array with options
|
79 |
+
* @return arr $groups array with ad groups
|
80 |
+
* @link http://codex.wordpress.org/Function_Reference/get_terms
|
81 |
+
*/
|
82 |
+
public function get_ad_groups($args = array()){
|
83 |
+
$args['hide_empty'] = isset($args['hide_empty']) ? $args['hide_empty'] : false; // display groups without any ads
|
84 |
+
|
85 |
+
return get_terms( Advanced_Ads::AD_GROUP_TAXONOMY, $args );
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* get the array with ad placements
|
90 |
+
*
|
91 |
+
* @since 1.1.0
|
92 |
+
* @return arr $ad_placements
|
93 |
+
*/
|
94 |
+
public function get_ad_placements_array(){
|
95 |
+
|
96 |
+
if ( ! isset( $this->ad_placements ) ) {
|
97 |
+
$this->ad_placements = get_option( 'advads-ads-placements', array() );
|
98 |
+
|
99 |
+
// load default array if not saved yet
|
100 |
+
if ( ! is_array( $this->ad_placements ) ){
|
101 |
+
$this->ad_placements = array();
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
return $this->ad_placements;
|
106 |
+
}
|
107 |
+
}
|
classes/ad-select.php
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Abstracts ad selection.
|
5 |
+
*
|
6 |
+
* The class allows to modify 'methods' (named callbacks) to provide ads
|
7 |
+
* through `advanced-ads-ad-select-methods` filter.
|
8 |
+
* This can be used to replace default methods, wrap them or add new ones.
|
9 |
+
*
|
10 |
+
* Further allows to provide ad selection attributes
|
11 |
+
* through `advanced-ads-ad-select-args` filter to influence behaviour of the
|
12 |
+
* selection method.
|
13 |
+
* Default methods have a `override` attribute that allows to replace the
|
14 |
+
* content. This may be used to defer or skip ad codes dynamically.
|
15 |
+
*
|
16 |
+
* @since 1.5.0
|
17 |
+
*/
|
18 |
+
class Advanced_Ads_Select {
|
19 |
+
|
20 |
+
protected $methods;
|
21 |
+
|
22 |
+
private function __construct() {}
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @var Advanced_Ads_Select
|
27 |
+
*/
|
28 |
+
private static $instance;
|
29 |
+
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
* @return Advanced_Ads_Select
|
33 |
+
*/
|
34 |
+
public static function get_instance()
|
35 |
+
{
|
36 |
+
if ( ! isset(self::$instance) ) {
|
37 |
+
self::$instance = new self;
|
38 |
+
}
|
39 |
+
|
40 |
+
return self::$instance;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function get_methods()
|
48 |
+
{
|
49 |
+
if ( ! isset($this->methods) ) {
|
50 |
+
$methods = array(
|
51 |
+
'id' => array( $this, 'get_ad_by_id' ),
|
52 |
+
'group' => array( $this, 'get_ad_by_group' ),
|
53 |
+
'placement' => array( $this, 'get_ad_by_placement' ),
|
54 |
+
);
|
55 |
+
|
56 |
+
$this->methods = apply_filters( 'advanced-ads-ad-select-methods', $methods );
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this->methods;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Advanced ad selection methods should not directly rely on
|
64 |
+
* current environment factors.
|
65 |
+
* Prior to actual ad selection the meta is provided to allow for
|
66 |
+
* serialised, proxied or otherwise defered selection workflows.
|
67 |
+
*
|
68 |
+
* @return array
|
69 |
+
*/
|
70 |
+
public function get_ad_arguments( $method, $id, $args = array() )
|
71 |
+
{
|
72 |
+
$args = (array) $args;
|
73 |
+
|
74 |
+
if ( ! isset($args['method']) ) $args['method'] = $method;
|
75 |
+
if ( ! isset($args['id']) ) $args['id'] = $id;
|
76 |
+
|
77 |
+
// -TODO add hook: document, review existing use cases
|
78 |
+
$args = apply_filters( 'advanced-ads-ad-select-args', $args );
|
79 |
+
|
80 |
+
return $args;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function get_ad_by_method( $id, $method, $args = array() ) {
|
84 |
+
|
85 |
+
$methods = $this->get_methods();
|
86 |
+
if ( ! isset($methods[ $method ]) ) {
|
87 |
+
return ;
|
88 |
+
}
|
89 |
+
if ( ! advads_can_display_ads() ) {
|
90 |
+
return ;
|
91 |
+
}
|
92 |
+
$args = $this->get_ad_arguments( $method, $id, $args );
|
93 |
+
|
94 |
+
return call_user_func( $methods[ $method ], $args );
|
95 |
+
}
|
96 |
+
|
97 |
+
// internal
|
98 |
+
public function get_ad_by_id($args) {
|
99 |
+
if ( ! isset($args['id']) || $args['id'] == 0 ) {
|
100 |
+
return isset($args['override']) ? $args['override'] : null;
|
101 |
+
}
|
102 |
+
|
103 |
+
// get ad
|
104 |
+
$ad = new Advads_Ad( (int) $args['id'], $args );
|
105 |
+
|
106 |
+
// check conditions
|
107 |
+
if ( $ad->can_display() ) {
|
108 |
+
return $ad->output();
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
// internal
|
113 |
+
public function get_ad_by_group($args) {
|
114 |
+
if ( ! isset($args['id']) || $args['id'] == 0 ) {
|
115 |
+
return isset($args['override']) ? $args['override'] : null;
|
116 |
+
}
|
117 |
+
|
118 |
+
// get ad
|
119 |
+
$adgroup = new Advads_Ad_Group( (int) $args['id'] );
|
120 |
+
return $adgroup->output();
|
121 |
+
}
|
122 |
+
|
123 |
+
// internal
|
124 |
+
public function get_ad_by_placement($args) {
|
125 |
+
if ( ! isset($args['id']) || $args['id'] == '' ) {
|
126 |
+
return isset($args['override']) ? $args['override'] : null;
|
127 |
+
}
|
128 |
+
|
129 |
+
// get placement content
|
130 |
+
return Advads_Ad_Placements::output( $args['id'] );
|
131 |
+
}
|
132 |
+
}
|
classes/ad.php
CHANGED
@@ -93,7 +93,6 @@ class Advads_Ad {
|
|
93 |
* @param arr $args additional arguments
|
94 |
*/
|
95 |
public function __construct($id, $args = array()) {
|
96 |
-
global $advanced_ads_ad_conditions;
|
97 |
$id = absint( $id );
|
98 |
$this->id = $id;
|
99 |
$this->args = is_array( $args ) ? $args : array();
|
@@ -102,6 +101,8 @@ class Advads_Ad {
|
|
102 |
|
103 |
// dynamically add sanitize filters for condition types
|
104 |
$_types = array();
|
|
|
|
|
105 |
foreach ( $advanced_ads_ad_conditions as $_condition ) {
|
106 |
// add unique
|
107 |
$_types[$_condition['type']] = false;
|
@@ -618,8 +619,8 @@ class Advads_Ad {
|
|
618 |
// load ad type specific content filter
|
619 |
$output = $this->type_obj->prepare_output( $this );
|
620 |
|
621 |
-
|
622 |
-
|
623 |
|
624 |
// build wrapper around the ad
|
625 |
$output = $this->add_wrapper( $output );
|
@@ -960,5 +961,4 @@ class Advads_Ad {
|
|
960 |
private function create_wrapper_id(){
|
961 |
return 'advads-' . mt_rand();
|
962 |
}
|
963 |
-
|
964 |
}
|
93 |
* @param arr $args additional arguments
|
94 |
*/
|
95 |
public function __construct($id, $args = array()) {
|
|
|
96 |
$id = absint( $id );
|
97 |
$this->id = $id;
|
98 |
$this->args = is_array( $args ) ? $args : array();
|
101 |
|
102 |
// dynamically add sanitize filters for condition types
|
103 |
$_types = array();
|
104 |
+
// -TODO use model
|
105 |
+
$advanced_ads_ad_conditions = Advanced_Ads::get_ad_conditions();
|
106 |
foreach ( $advanced_ads_ad_conditions as $_condition ) {
|
107 |
// add unique
|
108 |
$_types[$_condition['type']] = false;
|
619 |
// load ad type specific content filter
|
620 |
$output = $this->type_obj->prepare_output( $this );
|
621 |
|
622 |
+
// filter to manipulate the output before the wrapper is added
|
623 |
+
$output = apply_filters( 'advanced-ads-output-inside-wrapper', $output, $this );
|
624 |
|
625 |
// build wrapper around the ad
|
626 |
$output = $this->add_wrapper( $output );
|
961 |
private function create_wrapper_id(){
|
962 |
return 'advads-' . mt_rand();
|
963 |
}
|
|
|
964 |
}
|
classes/ad_ajax_callbacks.php
CHANGED
@@ -20,6 +20,7 @@ class Advads_Ad_Ajax_Callbacks {
|
|
20 |
|
21 |
public function __construct() {
|
22 |
|
|
|
23 |
add_action( 'wp_ajax_load_content_editor', array( $this, 'load_content_editor' ) );
|
24 |
add_action( 'wp_ajax_load_ad_parameters_metabox', array( $this, 'load_ad_parameters_metabox' ) );
|
25 |
add_action( 'wp_ajax_advads-terms-search', array( $this, 'search_terms' ) );
|
20 |
|
21 |
public function __construct() {
|
22 |
|
23 |
+
// NOTE: admin only!
|
24 |
add_action( 'wp_ajax_load_content_editor', array( $this, 'load_content_editor' ) );
|
25 |
add_action( 'wp_ajax_load_ad_parameters_metabox', array( $this, 'load_ad_parameters_metabox' ) );
|
26 |
add_action( 'wp_ajax_advads-terms-search', array( $this, 'search_terms' ) );
|
classes/ad_group.php
CHANGED
@@ -90,7 +90,7 @@ class Advads_Ad_Group {
|
|
90 |
|
91 |
$this->taxonomy = Advanced_Ads::AD_GROUP_TAXONOMY;
|
92 |
|
93 |
-
|
94 |
if ( $group == null || is_wp_error($group) ) { return; }
|
95 |
|
96 |
$this->load( $group );
|
@@ -98,94 +98,96 @@ class Advads_Ad_Group {
|
|
98 |
|
99 |
/**
|
100 |
* load additional ad group properties
|
101 |
-
|
102 |
* @since 1.4.8
|
103 |
-
|
104 |
-
|
105 |
*/
|
106 |
private function load($group) {
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
|
113 |
-
|
114 |
}
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
|
|
|
|
189 |
|
190 |
/**
|
191 |
* return all ads from this group
|
@@ -315,7 +317,7 @@ class Advads_Ad_Group {
|
|
315 |
return array();
|
316 |
}
|
317 |
|
318 |
-
|
319 |
* save ad group information that are not included in terms or ad weight
|
320 |
*
|
321 |
* @since 1.4.8
|
@@ -323,15 +325,15 @@ class Advads_Ad_Group {
|
|
323 |
*/
|
324 |
public function save($args = array()) {
|
325 |
|
326 |
-
|
327 |
-
|
328 |
|
329 |
-
|
330 |
-
|
331 |
|
332 |
-
|
333 |
|
334 |
-
|
335 |
}
|
336 |
|
337 |
/**
|
90 |
|
91 |
$this->taxonomy = Advanced_Ads::AD_GROUP_TAXONOMY;
|
92 |
|
93 |
+
$group = get_term( $group, $this->taxonomy );
|
94 |
if ( $group == null || is_wp_error($group) ) { return; }
|
95 |
|
96 |
$this->load( $group );
|
98 |
|
99 |
/**
|
100 |
* load additional ad group properties
|
101 |
+
*
|
102 |
* @since 1.4.8
|
103 |
+
* @param int $id group id
|
104 |
+
* @param obj $group wp term object
|
105 |
*/
|
106 |
private function load($group) {
|
107 |
+
$this->id = $group->term_id;
|
108 |
+
$this->name = $group->name;
|
109 |
+
$this->slug = $group->slug;
|
110 |
+
$this->description = $group->description;
|
111 |
+
$this->post_type = Advanced_Ads::POST_TYPE_SLUG;
|
112 |
|
113 |
+
$this->load_additional_attributes();
|
114 |
}
|
115 |
|
116 |
+
/**
|
117 |
+
* load additional attributes for groups that are not part of the WP terms
|
118 |
+
*
|
119 |
+
* @since 1.4.8
|
120 |
+
*/
|
121 |
+
protected function load_additional_attributes(){
|
122 |
+
$all_groups = get_option( 'advads-ad-groups', array() );
|
123 |
+
|
124 |
+
if(isset($all_groups[$this->id]['type'])){
|
125 |
+
$this->type = $all_groups[$this->id]['type'];
|
126 |
+
}
|
127 |
+
|
128 |
+
// get ad count; default is 1
|
129 |
+
if(isset($all_groups[$this->id]['ad_count'])){
|
130 |
+
$this->ad_count = (int) $all_groups[$this->id]['ad_count'];
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* control the output of the group by type and amount of ads
|
136 |
+
*
|
137 |
+
* @since 1.4.8
|
138 |
+
* @return str $output output of ad(s) by ad
|
139 |
+
*/
|
140 |
+
public function output(){
|
141 |
+
|
142 |
+
if(!$this->id) return;
|
143 |
+
|
144 |
+
// load ads
|
145 |
+
$ads = $this->load_all_ads();
|
146 |
+
if ( $ads === array() ) { return; }
|
147 |
+
|
148 |
+
// get ad weights serving as an order here
|
149 |
+
$weights = $this->get_ad_weights();
|
150 |
+
asort($weights);
|
151 |
+
|
152 |
+
// if ads and weights don’t have the same keys, update weights array
|
153 |
+
if ( (count( $weights ) == 0 && count( $ads ) > 0) || count( $weights ) != count( $ads ) || array_diff_key( $weights, $ads ) != array()
|
154 |
+
|| array_diff_key( $ads, $weights ) != array() ) {
|
155 |
+
$this->update_ad_weights();
|
156 |
+
$weights = $this->ad_weights;
|
157 |
+
}
|
158 |
+
|
159 |
+
// order ads based on group type
|
160 |
+
switch($this->type){
|
161 |
+
case 'ordered' :
|
162 |
+
$ordered_ad_ids = array_keys($weights);
|
163 |
+
break;
|
164 |
+
default : // default
|
165 |
+
$ordered_ad_ids = $this->shuffle_ads($ads, $weights);
|
166 |
+
}
|
167 |
+
|
168 |
+
// load the ad output
|
169 |
+
$output = '';
|
170 |
+
$ads_displayed = 0;
|
171 |
+
foreach ( $ordered_ad_ids as $_ad_id ) {
|
172 |
+
// +TODO should use ad-selection interface to output actual ad
|
173 |
+
// .. might break context otherwise or cause hard to detect issues
|
174 |
+
// load the ad object
|
175 |
+
$ad = new Advads_Ad( $_ad_id );
|
176 |
+
if ( $ad->can_display() ) {
|
177 |
+
$output .= $ad->output();
|
178 |
+
$ads_displayed++;
|
179 |
+
if($ads_displayed === $this->ad_count) break;
|
180 |
+
}
|
181 |
+
// break the loop when maximum ads are reached
|
182 |
+
}
|
183 |
+
|
184 |
+
// add the group to the global output array
|
185 |
+
$advads = Advanced_Ads::get_instance();
|
186 |
+
$advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
|
187 |
+
|
188 |
+
// filter again, in case a developer wants to filter group output individually
|
189 |
+
return apply_filters( 'advanced-ads-group-output', $output, $this );
|
190 |
+
}
|
191 |
|
192 |
/**
|
193 |
* return all ads from this group
|
317 |
return array();
|
318 |
}
|
319 |
|
320 |
+
/**
|
321 |
* save ad group information that are not included in terms or ad weight
|
322 |
*
|
323 |
* @since 1.4.8
|
325 |
*/
|
326 |
public function save($args = array()) {
|
327 |
|
328 |
+
$defaults = array( 'type' => 'default', 'ad_count' => 1 );
|
329 |
+
$args = wp_parse_args($args, $defaults);
|
330 |
|
331 |
+
// get global ad group option
|
332 |
+
$groups = get_option( 'advads-ad-groups', array() );
|
333 |
|
334 |
+
$groups[$this->id] = $args;
|
335 |
|
336 |
+
update_option( 'advads-ad-groups', $groups );
|
337 |
}
|
338 |
|
339 |
/**
|
classes/ad_placements.php
CHANGED
@@ -63,7 +63,7 @@ class Advads_Ad_Placements {
|
|
63 |
* @return mixed true if saved; error message if not
|
64 |
*/
|
65 |
public static function save_new_placement($new_placement) {
|
66 |
-
// load placements
|
67 |
$placements = Advanced_Ads::get_ad_placements_array();
|
68 |
|
69 |
// escape slug as slug
|
@@ -102,7 +102,7 @@ class Advads_Ad_Placements {
|
|
102 |
*/
|
103 |
public static function save_placements($placement_items) {
|
104 |
|
105 |
-
// load placements
|
106 |
$placements = Advanced_Ads::get_ad_placements_array();
|
107 |
|
108 |
foreach ( $placement_items as $_placement_slug => $_placement ) {
|
@@ -136,15 +136,16 @@ class Advads_Ad_Placements {
|
|
136 |
*/
|
137 |
public static function items_for_select() {
|
138 |
$select = array();
|
|
|
139 |
|
140 |
// load all ad groups
|
141 |
-
$groups =
|
142 |
foreach ( $groups as $_group ) {
|
143 |
$select['groups']['group_' . $_group->term_id] = $_group->name;
|
144 |
}
|
145 |
|
146 |
// load all ads
|
147 |
-
$ads =
|
148 |
foreach ( $ads as $_ad ) {
|
149 |
$select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
|
150 |
}
|
@@ -203,18 +204,15 @@ class Advads_Ad_Placements {
|
|
203 |
$class = 'advads-' . $id;
|
204 |
$ad_args = array('output' => array('class' => array($class)));
|
205 |
}
|
206 |
-
return get_ad( $_item_id, $ad_args );
|
207 |
|
|
|
208 |
} elseif ( $_item[0] == 'group' ) {
|
209 |
// add the placement to the global output array
|
210 |
$advads = Advanced_Ads::get_instance();
|
211 |
$advads->current_ads[] = array('type' => 'placement', 'id' => $id, 'title' => $placements[$id]['name']);
|
212 |
|
213 |
-
return
|
214 |
-
|
215 |
}
|
216 |
-
} else {
|
217 |
-
return;
|
218 |
}
|
219 |
|
220 |
return;
|
@@ -275,7 +273,7 @@ class Advads_Ad_Placements {
|
|
275 |
}
|
276 |
|
277 |
if ( isset($insertAt) ) {
|
278 |
-
$ad_content = Advads_Ad_Placements::output($placement_id);
|
279 |
if ( $insertAt === false ) {
|
280 |
$content .= $ad_content; // fallback: end-of-content
|
281 |
} else {
|
63 |
* @return mixed true if saved; error message if not
|
64 |
*/
|
65 |
public static function save_new_placement($new_placement) {
|
66 |
+
// load placements // -TODO use model
|
67 |
$placements = Advanced_Ads::get_ad_placements_array();
|
68 |
|
69 |
// escape slug as slug
|
102 |
*/
|
103 |
public static function save_placements($placement_items) {
|
104 |
|
105 |
+
// load placements // -TODO use model
|
106 |
$placements = Advanced_Ads::get_ad_placements_array();
|
107 |
|
108 |
foreach ( $placement_items as $_placement_slug => $_placement ) {
|
136 |
*/
|
137 |
public static function items_for_select() {
|
138 |
$select = array();
|
139 |
+
$model = Advanced_Ads::get_instance()->get_model();
|
140 |
|
141 |
// load all ad groups
|
142 |
+
$groups = $model->get_ad_groups();
|
143 |
foreach ( $groups as $_group ) {
|
144 |
$select['groups']['group_' . $_group->term_id] = $_group->name;
|
145 |
}
|
146 |
|
147 |
// load all ads
|
148 |
+
$ads = $model->get_ads( array('orderby' => 'name', 'order' => 'ASC') );
|
149 |
foreach ( $ads as $_ad ) {
|
150 |
$select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
|
151 |
}
|
204 |
$class = 'advads-' . $id;
|
205 |
$ad_args = array('output' => array('class' => array($class)));
|
206 |
}
|
|
|
207 |
|
208 |
+
return Advanced_Ads_Select::get_instance()->get_ad_by_method( $_item_id, 'id', $ad_args );
|
209 |
} elseif ( $_item[0] == 'group' ) {
|
210 |
// add the placement to the global output array
|
211 |
$advads = Advanced_Ads::get_instance();
|
212 |
$advads->current_ads[] = array('type' => 'placement', 'id' => $id, 'title' => $placements[$id]['name']);
|
213 |
|
214 |
+
return Advanced_Ads_Select::get_instance()->get_ad_by_method( $_item_id, 'group' );
|
|
|
215 |
}
|
|
|
|
|
216 |
}
|
217 |
|
218 |
return;
|
273 |
}
|
274 |
|
275 |
if ( isset($insertAt) ) {
|
276 |
+
$ad_content = Advads_Ad_Placements::output( $placement_id );
|
277 |
if ( $insertAt === false ) {
|
278 |
$content .= $ad_content; // fallback: end-of-content
|
279 |
} else {
|
classes/plugin.php
ADDED
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Wordpress integration and definitions:
|
5 |
+
*
|
6 |
+
* - posttypes
|
7 |
+
* - taxonomy
|
8 |
+
* - textdomain
|
9 |
+
*
|
10 |
+
* @since 1.5.0
|
11 |
+
*/
|
12 |
+
class Advanced_Ads_Plugin {
|
13 |
+
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @var Advanced_Ads_Plugin
|
17 |
+
*/
|
18 |
+
protected static $instance;
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* @var Advanced_Ads_Model
|
23 |
+
*/
|
24 |
+
protected $model;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* plugin options
|
28 |
+
*
|
29 |
+
* @since 1.0.1
|
30 |
+
* @var array (if loaded)
|
31 |
+
*/
|
32 |
+
protected $options = false;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* interal plugin options – set by the plugin
|
36 |
+
*
|
37 |
+
* @since 1.4.5
|
38 |
+
* @var array (if loaded)
|
39 |
+
*/
|
40 |
+
protected $internal_options = false;
|
41 |
+
|
42 |
+
private function __construct() {
|
43 |
+
register_activation_hook( dirname( __FILE__ ), array( $this, 'activate' ) );
|
44 |
+
register_deactivation_hook( dirname( __FILE__ ), array( $this, 'deactivate' ) );
|
45 |
+
|
46 |
+
add_action( 'plugins_loaded', array( $this, 'wp_plugins_loaded' ) );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
*
|
51 |
+
* @return Advanced_Ads_Plugin
|
52 |
+
*/
|
53 |
+
public static function get_instance() {
|
54 |
+
// If the single instance hasn't been set, set it now.
|
55 |
+
if ( null === self::$instance ) {
|
56 |
+
self::$instance = new self;
|
57 |
+
}
|
58 |
+
|
59 |
+
return self::$instance;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @param Advanced_Ads_Model $model
|
65 |
+
*/
|
66 |
+
public function set_model(Advanced_Ads_Model $model) {
|
67 |
+
$this->model = $model;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function wp_plugins_loaded() {
|
71 |
+
// Load plugin text domain
|
72 |
+
$this->load_plugin_textdomain();
|
73 |
+
|
74 |
+
// activate plugin when new blog is added on multisites // -TODO this is admin-only
|
75 |
+
add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
|
76 |
+
|
77 |
+
// Load public-facing style sheet and JavaScript.
|
78 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
79 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
80 |
+
|
81 |
+
// add short codes
|
82 |
+
add_shortcode( 'the_ad', array( $this, 'shortcode_display_ad' ) );
|
83 |
+
add_shortcode( 'the_ad_group', array( $this, 'shortcode_display_ad_group' ) );
|
84 |
+
add_shortcode( 'the_ad_placement', array( $this, 'shortcode_display_ad_placement' ) );
|
85 |
+
|
86 |
+
// remove default ad group menu item // -TODO only for admin
|
87 |
+
add_action( 'admin_menu', array( $this, 'remove_taxonomy_menu_item' ) );
|
88 |
+
// load widgets
|
89 |
+
add_action( 'widgets_init', array( $this, 'advads_widget_init' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Register and enqueue public-facing style sheet.
|
94 |
+
*
|
95 |
+
* @since 1.0.0
|
96 |
+
*/
|
97 |
+
public function enqueue_styles() {
|
98 |
+
// wp_enqueue_style( $this->get_plugin_slug() . '-plugin-styles', plugins_url('assets/css/public.css', __FILE__), array(), Advanced_Ads::VERSION);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Return the plugin slug.
|
103 |
+
*
|
104 |
+
* @since 1.0.0
|
105 |
+
* @return Plugin slug variable.
|
106 |
+
*/
|
107 |
+
public function get_plugin_slug() {
|
108 |
+
return ADVADS_SLUG;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Register and enqueues public-facing JavaScript files.
|
113 |
+
*
|
114 |
+
* @since 1.0.0
|
115 |
+
*/
|
116 |
+
public function enqueue_scripts() {
|
117 |
+
// wp_enqueue_script( $this->get_plugin_slug() . '-plugin-script', plugins_url('assets/js/public.js', __FILE__), array('jquery'), Advanced_Ads::VERSION);
|
118 |
+
$options = $this->options();
|
119 |
+
if ( ! empty($options['advanced-js']) ){
|
120 |
+
wp_enqueue_script( $this->get_plugin_slug() . '-advanced-js', ADVADS_BASE_URL . 'assets/js/advanced.js', array( 'jquery' ), Advanced_Ads::VERSION );
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
public function advads_widget_init() {
|
125 |
+
register_widget( 'Advads_Widget' );
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Fired when a new site is activated with a WPMU environment.
|
130 |
+
*
|
131 |
+
* @since 1.0.0
|
132 |
+
* @param int $blog_id ID of the new blog.
|
133 |
+
*/
|
134 |
+
public function activate_new_site($blog_id) {
|
135 |
+
|
136 |
+
if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
|
140 |
+
switch_to_blog( $blog_id );
|
141 |
+
$this->single_activate();
|
142 |
+
restore_current_blog();
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Fired for each blog when the plugin is activated.
|
147 |
+
*
|
148 |
+
* @since 1.0.0
|
149 |
+
*/
|
150 |
+
protected function single_activate() {
|
151 |
+
$this->post_types_rewrite_flush();
|
152 |
+
// -TODO inform modules
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Fired for each blog when the plugin is deactivated.
|
157 |
+
*
|
158 |
+
* @since 1.0.0
|
159 |
+
*/
|
160 |
+
protected function single_deactivate() {
|
161 |
+
// -TODO inform modules
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Load the plugin text domain for translation.
|
166 |
+
*
|
167 |
+
* @since 1.0.0
|
168 |
+
*/
|
169 |
+
public function load_plugin_textdomain() {
|
170 |
+
// $locale = apply_filters('advanced-ads-plugin-locale', get_locale(), $domain);
|
171 |
+
load_plugin_textdomain( ADVADS_SLUG, false, ADVADS_BASE_DIR . '/languages' );
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Fired when the plugin is activated.
|
176 |
+
*
|
177 |
+
* @since 1.0.0
|
178 |
+
* @param boolean $network_wide True if WPMU superadmin uses
|
179 |
+
* "Network Activate" action, false if
|
180 |
+
* WPMU is disabled or plugin is
|
181 |
+
* activated on an individual blog.
|
182 |
+
*/
|
183 |
+
public function activate($network_wide) {
|
184 |
+
|
185 |
+
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
186 |
+
|
187 |
+
if ( $network_wide ) {
|
188 |
+
|
189 |
+
// Get all blog ids
|
190 |
+
$blog_ids = $this->model->get_blog_ids();
|
191 |
+
|
192 |
+
foreach ( $blog_ids as $blog_id ) {
|
193 |
+
|
194 |
+
switch_to_blog( $blog_id );
|
195 |
+
$this->single_activate();
|
196 |
+
}
|
197 |
+
|
198 |
+
restore_current_blog();
|
199 |
+
} else {
|
200 |
+
$this->single_activate();
|
201 |
+
}
|
202 |
+
} else {
|
203 |
+
$this->single_activate();
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Fired when the plugin is deactivated.
|
209 |
+
*
|
210 |
+
* @since 1.0.0
|
211 |
+
* @param boolean $network_wide
|
212 |
+
*
|
213 |
+
* True if WPMU superadmin uses
|
214 |
+
* "Network Deactivate" action, false if
|
215 |
+
* WPMU is disabled or plugin is
|
216 |
+
* deactivated on an individual blog.
|
217 |
+
*/
|
218 |
+
public function deactivate($network_wide) {
|
219 |
+
|
220 |
+
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
221 |
+
|
222 |
+
if ( $network_wide ) {
|
223 |
+
|
224 |
+
// Get all blog ids
|
225 |
+
$blog_ids = $this->model->get_blog_ids();
|
226 |
+
|
227 |
+
foreach ( $blog_ids as $blog_id ) {
|
228 |
+
|
229 |
+
switch_to_blog( $blog_id );
|
230 |
+
$this->single_deactivate();
|
231 |
+
}
|
232 |
+
|
233 |
+
restore_current_blog();
|
234 |
+
} else {
|
235 |
+
$this->single_deactivate();
|
236 |
+
}
|
237 |
+
} else {
|
238 |
+
$this->single_deactivate();
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* flush rewrites on plugin activation so permalinks for them work from the beginning on
|
244 |
+
*
|
245 |
+
* @since 1.0.0
|
246 |
+
* @link http://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation
|
247 |
+
*/
|
248 |
+
public function post_types_rewrite_flush(){
|
249 |
+
// load custom post type
|
250 |
+
Advanced_Ads::get_instance()->create_post_types();
|
251 |
+
// flush rewrite rules
|
252 |
+
flush_rewrite_rules();
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* remove WP tag edit page for the ad group taxonomy
|
257 |
+
* needed, because we can’t remove it with `show_ui` without also removing the meta box
|
258 |
+
*
|
259 |
+
* @since 1.0.0
|
260 |
+
*/
|
261 |
+
public function remove_taxonomy_menu_item() {
|
262 |
+
remove_submenu_page( 'edit.php?post_type=advanced_ads', 'edit-tags.php?taxonomy=advanced_ads_groups&post_type=advanced_ads' );
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* shortcode to include ad in frontend
|
267 |
+
*
|
268 |
+
* @since 1.0.0
|
269 |
+
* @param arr $atts
|
270 |
+
*/
|
271 |
+
public function shortcode_display_ad($atts){
|
272 |
+
$id = isset($atts['id']) ? (int) $atts['id'] : 0;
|
273 |
+
|
274 |
+
// use the public available function here
|
275 |
+
return get_ad( $id );
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* shortcode to include ad from an ad group in frontend
|
280 |
+
*
|
281 |
+
* @since 1.0.0
|
282 |
+
* @param arr $atts
|
283 |
+
*/
|
284 |
+
public function shortcode_display_ad_group($atts){
|
285 |
+
$id = isset($atts['id']) ? (int) $atts['id'] : 0;
|
286 |
+
|
287 |
+
// use the public available function here
|
288 |
+
return get_ad_group( $id );
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* shortcode to display content of an ad placement in frontend
|
293 |
+
*
|
294 |
+
* @since 1.1.0
|
295 |
+
* @param arr $atts
|
296 |
+
*/
|
297 |
+
public function shortcode_display_ad_placement($atts){
|
298 |
+
$id = isset($atts['id']) ? (string) $atts['id'] : '';
|
299 |
+
|
300 |
+
// use the public available function here
|
301 |
+
return get_ad_placement( $id );
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* return plugin options
|
306 |
+
* these are the options updated by the user
|
307 |
+
*
|
308 |
+
* @since 1.0.1
|
309 |
+
* @return array $options
|
310 |
+
* @todo parse default options
|
311 |
+
*/
|
312 |
+
public function options() {
|
313 |
+
if ( false === $this->options ){
|
314 |
+
$this->options = get_option( ADVADS_SLUG, array() );
|
315 |
+
}
|
316 |
+
|
317 |
+
return $this->options;
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* return internal plugin options
|
322 |
+
* these are options set by the plugin
|
323 |
+
*
|
324 |
+
* @since 1.0.1
|
325 |
+
* @return array $options
|
326 |
+
* @todo parse default options
|
327 |
+
*/
|
328 |
+
public function internal_options() {
|
329 |
+
if ( false === $this->internal_options ){
|
330 |
+
$this->internal_options = get_option( ADVADS_SLUG . '-internal', array() );
|
331 |
+
}
|
332 |
+
|
333 |
+
return $this->internal_options;
|
334 |
+
}
|
335 |
+
}
|
classes/widget.php
CHANGED
@@ -80,15 +80,16 @@ class Advads_Widget extends WP_Widget {
|
|
80 |
*/
|
81 |
static function items_for_select(){
|
82 |
$select = array();
|
|
|
83 |
|
84 |
// load all ads
|
85 |
-
$ads =
|
86 |
foreach ( $ads as $_ad ){
|
87 |
$select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
|
88 |
}
|
89 |
|
90 |
// load all ad groups
|
91 |
-
$groups =
|
92 |
foreach ( $groups as $_group ){
|
93 |
$select['groups']['group_' . $_group->term_id] = $_group->name;
|
94 |
}
|
80 |
*/
|
81 |
static function items_for_select(){
|
82 |
$select = array();
|
83 |
+
$model = Advanced_Ads::get_instance()->get_model();
|
84 |
|
85 |
// load all ads
|
86 |
+
$ads = $model->get_ads( array('orderby' => 'name', 'order' => 'ASC') );
|
87 |
foreach ( $ads as $_ad ){
|
88 |
$select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
|
89 |
}
|
90 |
|
91 |
// load all ad groups
|
92 |
+
$groups = $model->get_ad_groups();
|
93 |
foreach ( $groups as $_group ){
|
94 |
$select['groups']['group_' . $_group->term_id] = $_group->name;
|
95 |
}
|
composer.json
CHANGED
@@ -2,20 +2,40 @@
|
|
2 |
"name": "webgilde/advanced-ads",
|
3 |
"description": "Advanced Ads: Manage and optimize your ads in WordPress",
|
4 |
"keywords": ["wordpress", "ads", "plugin"],
|
5 |
-
"homepage": "http://webgilde.com",
|
6 |
-
"license": "GPL-2.0",
|
7 |
"authors": [
|
8 |
{
|
9 |
"name": "Thomas Maier",
|
10 |
"email": "thomas.maier@webgilde.com"
|
11 |
}
|
12 |
],
|
|
|
|
|
13 |
"type": "wordpress-plugin",
|
|
|
|
|
|
|
|
|
14 |
"require": {
|
15 |
-
"composer/installers": "~1.0"
|
|
|
16 |
},
|
17 |
"autoload": {
|
18 |
-
"classmap": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
},
|
20 |
"extra": {
|
21 |
"branch-alias": {
|
2 |
"name": "webgilde/advanced-ads",
|
3 |
"description": "Advanced Ads: Manage and optimize your ads in WordPress",
|
4 |
"keywords": ["wordpress", "ads", "plugin"],
|
|
|
|
|
5 |
"authors": [
|
6 |
{
|
7 |
"name": "Thomas Maier",
|
8 |
"email": "thomas.maier@webgilde.com"
|
9 |
}
|
10 |
],
|
11 |
+
"homepage": "https://wordpress.org/plugins/advanced-ads/",
|
12 |
+
"license": "GPL-2.0+",
|
13 |
"type": "wordpress-plugin",
|
14 |
+
"homepage": "http://webgilde.com",
|
15 |
+
"support": {
|
16 |
+
"forum": "https://wordpress.org/support/plugin/advanced-ads"
|
17 |
+
},
|
18 |
"require": {
|
19 |
+
"composer/installers": "~1.0",
|
20 |
+
"xrstf/composer-php52": "^1.0.17"
|
21 |
},
|
22 |
"autoload": {
|
23 |
+
"classmap": [
|
24 |
+
"admin/",
|
25 |
+
"classes/",
|
26 |
+
"public/"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
"scripts": {
|
30 |
+
"post-install-cmd": [
|
31 |
+
"xrstf\\Composer52\\Generator::onPostInstallCmd"
|
32 |
+
],
|
33 |
+
"post-update-cmd": [
|
34 |
+
"xrstf\\Composer52\\Generator::onPostInstallCmd"
|
35 |
+
],
|
36 |
+
"post-autoload-dump": [
|
37 |
+
"xrstf\\Composer52\\Generator::onPostInstallCmd"
|
38 |
+
]
|
39 |
},
|
40 |
"extra": {
|
41 |
"branch-alias": {
|
composer.lock
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_readme": [
|
3 |
+
"This file locks the dependencies of your project to a known state",
|
4 |
+
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
+
"This file is @generated automatically"
|
6 |
+
],
|
7 |
+
"hash": "3b9b697387fc7c29267bd78c973707f0",
|
8 |
+
"packages": [
|
9 |
+
{
|
10 |
+
"name": "composer/installers",
|
11 |
+
"version": "v1.0.21",
|
12 |
+
"source": {
|
13 |
+
"type": "git",
|
14 |
+
"url": "https://github.com/composer/installers.git",
|
15 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"
|
16 |
+
},
|
17 |
+
"dist": {
|
18 |
+
"type": "zip",
|
19 |
+
"url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
20 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
21 |
+
"shasum": ""
|
22 |
+
},
|
23 |
+
"replace": {
|
24 |
+
"roundcube/plugin-installer": "*",
|
25 |
+
"shama/baton": "*"
|
26 |
+
},
|
27 |
+
"require-dev": {
|
28 |
+
"composer/composer": "1.0.*@dev",
|
29 |
+
"phpunit/phpunit": "4.1.*"
|
30 |
+
},
|
31 |
+
"type": "composer-installer",
|
32 |
+
"extra": {
|
33 |
+
"class": "Composer\\Installers\\Installer",
|
34 |
+
"branch-alias": {
|
35 |
+
"dev-master": "1.0-dev"
|
36 |
+
}
|
37 |
+
},
|
38 |
+
"autoload": {
|
39 |
+
"psr-0": {
|
40 |
+
"Composer\\Installers\\": "src/"
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"notification-url": "https://packagist.org/downloads/",
|
44 |
+
"license": [
|
45 |
+
"MIT"
|
46 |
+
],
|
47 |
+
"authors": [
|
48 |
+
{
|
49 |
+
"name": "Kyle Robinson Young",
|
50 |
+
"email": "kyle@dontkry.com",
|
51 |
+
"homepage": "https://github.com/shama"
|
52 |
+
}
|
53 |
+
],
|
54 |
+
"description": "A multi-framework Composer library installer",
|
55 |
+
"homepage": "http://composer.github.com/installers/",
|
56 |
+
"keywords": [
|
57 |
+
"Craft",
|
58 |
+
"Dolibarr",
|
59 |
+
"Hurad",
|
60 |
+
"MODX Evo",
|
61 |
+
"OXID",
|
62 |
+
"SMF",
|
63 |
+
"Thelia",
|
64 |
+
"WolfCMS",
|
65 |
+
"agl",
|
66 |
+
"aimeos",
|
67 |
+
"annotatecms",
|
68 |
+
"bitrix",
|
69 |
+
"cakephp",
|
70 |
+
"chef",
|
71 |
+
"codeigniter",
|
72 |
+
"concrete5",
|
73 |
+
"croogo",
|
74 |
+
"dokuwiki",
|
75 |
+
"drupal",
|
76 |
+
"elgg",
|
77 |
+
"fuelphp",
|
78 |
+
"grav",
|
79 |
+
"installer",
|
80 |
+
"joomla",
|
81 |
+
"kohana",
|
82 |
+
"laravel",
|
83 |
+
"lithium",
|
84 |
+
"magento",
|
85 |
+
"mako",
|
86 |
+
"mediawiki",
|
87 |
+
"modulework",
|
88 |
+
"moodle",
|
89 |
+
"phpbb",
|
90 |
+
"piwik",
|
91 |
+
"ppi",
|
92 |
+
"puppet",
|
93 |
+
"roundcube",
|
94 |
+
"shopware",
|
95 |
+
"silverstripe",
|
96 |
+
"symfony",
|
97 |
+
"typo3",
|
98 |
+
"wordpress",
|
99 |
+
"zend",
|
100 |
+
"zikula"
|
101 |
+
],
|
102 |
+
"time": "2015-02-18 17:17:01"
|
103 |
+
},
|
104 |
+
{
|
105 |
+
"name": "xrstf/composer-php52",
|
106 |
+
"version": "v1.0.17",
|
107 |
+
"source": {
|
108 |
+
"type": "hg",
|
109 |
+
"url": "https://bitbucket.org/xrstf/composer-php52",
|
110 |
+
"reference": "70b853668d6c3f97b63dafcfaeebb622bf08fd30"
|
111 |
+
},
|
112 |
+
"dist": {
|
113 |
+
"type": "zip",
|
114 |
+
"url": "https://bitbucket.org/xrstf/composer-php52/get/70b853668d6c3f97b63dafcfaeebb622bf08fd30.zip",
|
115 |
+
"reference": "70b853668d6c3f97b63dafcfaeebb622bf08fd30",
|
116 |
+
"shasum": ""
|
117 |
+
},
|
118 |
+
"type": "library",
|
119 |
+
"extra": {
|
120 |
+
"branch-alias": {
|
121 |
+
"dev-default": "1.x-dev"
|
122 |
+
}
|
123 |
+
},
|
124 |
+
"autoload": {
|
125 |
+
"psr-0": {
|
126 |
+
"xrstf\\Composer52": "lib/"
|
127 |
+
}
|
128 |
+
},
|
129 |
+
"notification-url": "https://packagist.org/downloads/",
|
130 |
+
"license": [
|
131 |
+
"MIT"
|
132 |
+
],
|
133 |
+
"homepage": "http://www.xrstf.de/",
|
134 |
+
"time": "2015-02-01 14:28:15"
|
135 |
+
}
|
136 |
+
],
|
137 |
+
"packages-dev": [],
|
138 |
+
"aliases": [],
|
139 |
+
"minimum-stability": "stable",
|
140 |
+
"stability-flags": [],
|
141 |
+
"prefer-stable": false,
|
142 |
+
"prefer-lowest": false,
|
143 |
+
"platform": [],
|
144 |
+
"platform-dev": []
|
145 |
+
}
|
includes/array_ad_conditions.php
CHANGED
@@ -20,6 +20,11 @@
|
|
20 |
*
|
21 |
*/
|
22 |
|
|
|
|
|
|
|
|
|
|
|
23 |
$advanced_ads_slug = Advanced_Ads::get_instance()->get_plugin_slug();
|
24 |
|
25 |
$advanced_ads_ad_conditions = array(
|
@@ -90,4 +95,4 @@ $advanced_ads_ad_conditions = array(
|
|
90 |
)
|
91 |
);
|
92 |
|
93 |
-
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
+
// avoid direct execution
|
24 |
+
if ( ! class_exists( 'Advanced_Ads', false ) ) {
|
25 |
+
die();
|
26 |
+
}
|
27 |
+
|
28 |
$advanced_ads_slug = Advanced_Ads::get_instance()->get_plugin_slug();
|
29 |
|
30 |
$advanced_ads_ad_conditions = array(
|
95 |
)
|
96 |
);
|
97 |
|
98 |
+
return apply_filters( 'advanced-ads-conditions', $advanced_ads_ad_conditions );
|
includes/autoloader.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* autoloader
|
5 |
-
*
|
6 |
-
* currently all classes of real objects (e.g. ads) can be found in /classes on the plugins root directory
|
7 |
-
* all classes have the "Advads_" prefix to prevent any conflicts with other plugins
|
8 |
-
* but filenames don’t use "advads" and are written in lower case
|
9 |
-
* e.g. Advads_Ad is in file classes/ad.php
|
10 |
-
*
|
11 |
-
* to be able to change this structure later, I use an autoloader here
|
12 |
-
*/
|
13 |
-
class Advads_Autoloader {
|
14 |
-
|
15 |
-
public static function load($classname) {
|
16 |
-
// to lower case
|
17 |
-
$classname = strtolower( $classname );
|
18 |
-
|
19 |
-
// strip "advads_" prefix
|
20 |
-
$classname = str_replace( 'advads_', '', $classname );
|
21 |
-
|
22 |
-
$filepath = ADVADS_BASE_PATH . 'classes' . DIRECTORY_SEPARATOR . $classname . '.php';
|
23 |
-
|
24 |
-
if ( file_exists( $filepath ) ) {
|
25 |
-
require_once $filepath;
|
26 |
-
} else {
|
27 |
-
return false;
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{public → includes}/functions.php
RENAMED
@@ -12,17 +12,7 @@
|
|
12 |
* @param arr $args additional arguments
|
13 |
*/
|
14 |
function get_ad($id = 0, $args = array()){
|
15 |
-
|
16 |
-
if ( empty($id) ) { return; }
|
17 |
-
|
18 |
-
if(!advads_can_display_ads()) return;
|
19 |
-
|
20 |
-
// get ad
|
21 |
-
$ad = new Advads_Ad( $id, $args );
|
22 |
-
|
23 |
-
// check conditions
|
24 |
-
if ( $ad->can_display() ) {
|
25 |
-
return $ad->output(); }
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -33,9 +23,7 @@ function get_ad($id = 0, $args = array()){
|
|
33 |
* @param arr $args additional arguments
|
34 |
*/
|
35 |
function the_ad($id = 0, $args = array()){
|
36 |
-
|
37 |
echo get_ad( $id, $args );
|
38 |
-
|
39 |
}
|
40 |
|
41 |
/**
|
@@ -46,14 +34,7 @@ function the_ad($id = 0, $args = array()){
|
|
46 |
*
|
47 |
*/
|
48 |
function get_ad_group($id = 0){
|
49 |
-
|
50 |
-
if ( empty($id) ) { return; }
|
51 |
-
|
52 |
-
if(!advads_can_display_ads()) return;
|
53 |
-
|
54 |
-
// get ad
|
55 |
-
$adgroup = new Advads_Ad_Group( $id );
|
56 |
-
return $adgroup->output();
|
57 |
}
|
58 |
|
59 |
/**
|
@@ -63,9 +44,7 @@ function get_ad_group($id = 0){
|
|
63 |
* @param int $id id of the ad (post)
|
64 |
*/
|
65 |
function the_ad_group($id = 0){
|
66 |
-
|
67 |
echo get_ad_group( $id );
|
68 |
-
|
69 |
}
|
70 |
|
71 |
/**
|
@@ -76,13 +55,7 @@ function the_ad_group($id = 0){
|
|
76 |
*
|
77 |
*/
|
78 |
function get_ad_placement($id = ''){
|
79 |
-
|
80 |
-
|
81 |
-
if(!advads_can_display_ads()) return;
|
82 |
-
|
83 |
-
// get placement content
|
84 |
-
$output = Advads_Ad_Placements::output( $id );
|
85 |
-
return $output;
|
86 |
}
|
87 |
|
88 |
/**
|
@@ -92,9 +65,7 @@ function get_ad_placement($id = ''){
|
|
92 |
* @param string $id slug of the ad placement
|
93 |
*/
|
94 |
function the_ad_placement($id = ''){
|
95 |
-
|
96 |
echo get_ad_placement( $id );
|
97 |
-
|
98 |
}
|
99 |
|
100 |
/**
|
@@ -105,4 +76,4 @@ function the_ad_placement($id = ''){
|
|
105 |
*/
|
106 |
function advads_can_display_ads(){
|
107 |
return Advanced_Ads::get_instance()->can_display_ads();
|
108 |
-
}
|
12 |
* @param arr $args additional arguments
|
13 |
*/
|
14 |
function get_ad($id = 0, $args = array()){
|
15 |
+
return Advanced_Ads_Select::get_instance()->get_ad_by_method( $id, 'id', $args );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
/**
|
23 |
* @param arr $args additional arguments
|
24 |
*/
|
25 |
function the_ad($id = 0, $args = array()){
|
|
|
26 |
echo get_ad( $id, $args );
|
|
|
27 |
}
|
28 |
|
29 |
/**
|
34 |
*
|
35 |
*/
|
36 |
function get_ad_group($id = 0){
|
37 |
+
return Advanced_Ads_Select::get_instance()->get_ad_by_method( $id, 'group' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
/**
|
44 |
* @param int $id id of the ad (post)
|
45 |
*/
|
46 |
function the_ad_group($id = 0){
|
|
|
47 |
echo get_ad_group( $id );
|
|
|
48 |
}
|
49 |
|
50 |
/**
|
55 |
*
|
56 |
*/
|
57 |
function get_ad_placement($id = ''){
|
58 |
+
return Advanced_Ads_Select::get_instance()->get_ad_by_method( $id, 'placement' );
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
/**
|
65 |
* @param string $id slug of the ad placement
|
66 |
*/
|
67 |
function the_ad_placement($id = ''){
|
|
|
68 |
echo get_ad_placement( $id );
|
|
|
69 |
}
|
70 |
|
71 |
/**
|
76 |
*/
|
77 |
function advads_can_display_ads(){
|
78 |
return Advanced_Ads::get_instance()->can_display_ads();
|
79 |
+
}
|
includes/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
includes/load_modules.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class Advanced_Ads_ModuleLoader {
|
4 |
+
|
5 |
+
protected static $loader;
|
6 |
+
protected static $textdomains = array();
|
7 |
+
protected static $modules = array();
|
8 |
+
|
9 |
+
public static function getLoader()
|
10 |
+
{
|
11 |
+
if ( null === self::$loader ) {
|
12 |
+
self::$loader = require_once ADVADS_BASE_PATH . 'vendor/autoload_52.php';
|
13 |
+
}
|
14 |
+
|
15 |
+
return self::$loader;
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Module loader options:
|
20 |
+
* - array 'disabled': Pretty name by (module) dirname
|
21 |
+
*
|
22 |
+
* @param string $path path to modules
|
23 |
+
* @param array $options module loader options
|
24 |
+
*/
|
25 |
+
public static function loadModules($path, $options = array()) {
|
26 |
+
$loader = self::getLoader();
|
27 |
+
|
28 |
+
$disabledModules = isset($options['disabled']) ? (array) $options['disabled'] : array();
|
29 |
+
|
30 |
+
// iterate modules
|
31 |
+
foreach ( glob( $path . '*/main.php' ) as $module ) {
|
32 |
+
$modulePath = dirname( $module );
|
33 |
+
$moduleName = basename( $modulePath );
|
34 |
+
|
35 |
+
// skip if disabled
|
36 |
+
if ( isset( $disabledModules[$moduleName] ) ) {
|
37 |
+
continue ;
|
38 |
+
}
|
39 |
+
|
40 |
+
self::$modules[$moduleName] = $modulePath;
|
41 |
+
if ( file_exists( $modulePath . '/config.php' ) ) {
|
42 |
+
$config = require $modulePath . '/config.php';
|
43 |
+
// append autoload classmap
|
44 |
+
if ( isset($config['classmap']) && is_array( $config['classmap'] ) ) {
|
45 |
+
$loader->addClassmap( $config['classmap'] );
|
46 |
+
}
|
47 |
+
// append textdomain
|
48 |
+
if ( isset($config['textdomain']) && $config['textdomain'] ) {
|
49 |
+
self::$textdomains[$config['textdomain']] = "modules/$moduleName/languages";
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
// register textdomains if non-empty
|
55 |
+
if ( self::$textdomains !== array() ) {
|
56 |
+
add_action( 'plugins_loaded', array( 'Advanced_Ads_ModuleLoader', 'load_module_textdomains') );
|
57 |
+
}
|
58 |
+
|
59 |
+
// load modules
|
60 |
+
foreach ( self::$modules as $name => $path ) {
|
61 |
+
require_once $path . '/main.php';
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
public static function load_module_textdomains() {
|
66 |
+
foreach ( self::$textdomains as $slug => $rel_path ) {
|
67 |
+
load_plugin_textdomain( ADVADS_SLUG, false, ADVADS_BASE_DIR . '/languages' );
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
languages/plugin-name.pot
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
# Copyright (C) 2013 Thomas Maier, webgilde.com
|
2 |
-
# This file is distributed under the same license as the Advanced_Ads package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: TODO 1.0.0\n"
|
6 |
-
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/plugin-name\n"
|
7 |
-
"POT-Creation-Date: 2013-05-10 11:23:19+00:00\n"
|
8 |
-
"PO-Revision-Date: 2013-05-10 10:37-0500\n"
|
9 |
-
"Last-Translator: FULL NAME <email@example.com>\n"
|
10 |
-
"Language-Team: LANGUAGE <translations@example.com >\n"
|
11 |
-
"MIME-Version: 1.0\n"
|
12 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
-
"Content-Transfer-Encoding: 8bit\n"
|
14 |
-
"X-Generator: Poedit 1.5.7\n"
|
15 |
-
"X-Poedit-KeywordsList: __;_e;_n;_x;esc_html_e;esc_html__;esc_attr_e;"
|
16 |
-
"esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2\n"
|
17 |
-
"X-Poedit-Basepath: ../\n"
|
18 |
-
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
19 |
-
"X-Poedit-SearchPath-0: .\n"
|
20 |
-
|
21 |
-
#: class-plugin-name-admin.php:170
|
22 |
-
msgid "Page Title"
|
23 |
-
msgstr ""
|
24 |
-
|
25 |
-
#: class-plugin-name-admin.php:171
|
26 |
-
msgid "Menu Text"
|
27 |
-
msgstr ""
|
28 |
-
|
29 |
-
#: class-plugin-name-admin.php:197
|
30 |
-
msgid "Settings"
|
31 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modules/gadsense/admin/class-gadsense-admin.php
CHANGED
@@ -1,173 +1,164 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
add_action( 'admin_print_scripts', array($this, 'print_scripts') );
|
21 |
-
add_action( 'admin_init', array($this, 'init') );
|
22 |
-
add_filter( 'advanced-ads-list-ad-size', array($this, 'ad_details_column'), 10, 2 );
|
23 |
}
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
|
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
('post-new.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type) ||
|
37 |
-
('post.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type && isset($_GET['action']) && 'edit' == $_GET['action'])
|
38 |
-
) {
|
39 |
-
$db = Gadsense_Data::get_instance();
|
40 |
-
$pub_id = $db->get_adsense_id();
|
41 |
-
?>
|
42 |
-
<script type="text/javascript">
|
43 |
-
var gadsenseData = {
|
44 |
-
pubId : '<?php echo $pub_id; ?>',
|
45 |
-
msg : {
|
46 |
-
unknownAd : '<?php esc_attr_e( "The ad details couldn't be retrieved from the ad code", ADVADS_SLUG ); ?>',
|
47 |
-
pubIdMismatch : '<?php _e( 'Warning : The AdSense account from this code does not match the one set with the Advanced Ads Plugin. This ad might cause troubles when used in the front end.', ADVADS_SLUG ); ?>',
|
48 |
-
missingPubId : '<?php _e( 'Warning : You have not yet entered an AdSense account ID. The plugin won’t work without that', ADVADS_SLUG ); ?>',
|
49 |
-
}
|
50 |
-
};
|
51 |
-
</script>
|
52 |
-
<?php
|
53 |
-
}
|
54 |
}
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
$css = 'error';
|
69 |
-
} else {
|
70 |
-
// success
|
71 |
-
$msg = __( 'Data updated', ADVADS_SLUG );
|
72 |
-
$css = 'updated';
|
73 |
-
}
|
74 |
-
$this->notice = array(
|
75 |
-
'msg' => $msg,
|
76 |
-
'class' => $css,
|
77 |
-
);
|
78 |
-
setcookie( 'gadsense_admin_notice', null, -1 );
|
79 |
}
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
|
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
}
|
99 |
}
|
100 |
-
|
101 |
-
// redirect
|
102 |
-
wp_redirect( $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] );
|
103 |
-
die();
|
104 |
}
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
138 |
}
|
|
|
139 |
|
140 |
-
|
141 |
|
142 |
-
|
143 |
-
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
}
|
152 |
-
if ( ! isset($value['version']) ) {
|
153 |
-
$value['version'] = null; }
|
154 |
-
wp_enqueue_style( $handle, $value['path'], $value['dep'], $value['version'] );
|
155 |
}
|
|
|
|
|
|
|
156 |
}
|
157 |
}
|
|
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
}
|
163 |
-
return self::$instance;
|
164 |
-
}
|
165 |
-
|
166 |
-
public function settings_form() {
|
167 |
-
require GADSENSE_BASE_PATH . 'admin/views/admin-page.php';
|
168 |
}
|
|
|
|
|
169 |
|
|
|
|
|
170 |
}
|
171 |
|
172 |
-
Gadsense_Admin::get_instance();
|
173 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Gadsense_Admin {
|
4 |
+
|
5 |
+
private $data;
|
6 |
+
private $nonce;
|
7 |
+
private static $instance = null;
|
8 |
+
protected $notice = null;
|
9 |
+
|
10 |
+
private function __construct() {
|
11 |
+
$this->data = Gadsense_Data::get_instance();
|
12 |
+
add_action( 'advanced-ads-additional-settings-form', array($this, 'settings_form') );
|
13 |
+
add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts') );
|
14 |
+
add_action( 'admin_print_scripts', array($this, 'print_scripts') );
|
15 |
+
add_action( 'admin_init', array($this, 'init') );
|
16 |
+
add_filter( 'advanced-ads-list-ad-size', array($this, 'ad_details_column'), 10, 2 );
|
17 |
+
}
|
18 |
|
19 |
+
public function ad_details_column($size, $the_ad) {
|
20 |
+
if ( 'adsense' == $the_ad->type ) {
|
21 |
+
$content = json_decode( $the_ad->content );
|
22 |
+
if ( 'responsive' == $content->unitType ) { $size = __( 'Responsive', ADVADS_SLUG ); }
|
|
|
|
|
|
|
23 |
}
|
24 |
+
return $size;
|
25 |
+
}
|
26 |
|
27 |
+
public function print_scripts() {
|
28 |
+
global $pagenow, $post_type;
|
29 |
+
if (
|
30 |
+
('post-new.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type) ||
|
31 |
+
('post.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type && isset($_GET['action']) && 'edit' == $_GET['action'])
|
32 |
+
) {
|
33 |
+
$db = Gadsense_Data::get_instance();
|
34 |
+
$pub_id = $db->get_adsense_id();
|
35 |
+
?>
|
36 |
+
<script type="text/javascript">
|
37 |
+
var gadsenseData = {
|
38 |
+
pubId : '<?php echo $pub_id; ?>',
|
39 |
+
msg : {
|
40 |
+
unknownAd : '<?php esc_attr_e( "The ad details couldn't be retrieved from the ad code", ADVADS_SLUG ); ?>',
|
41 |
+
pubIdMismatch : '<?php _e( 'Warning : The AdSense account from this code does not match the one set with the Advanced Ads Plugin. This ad might cause troubles when used in the front end.', ADVADS_SLUG ); ?>',
|
42 |
+
missingPubId : '<?php _e( 'Warning : You have not yet entered an AdSense account ID. The plugin won’t work without that', ADVADS_SLUG ); ?>',
|
43 |
+
}
|
44 |
+
};
|
45 |
+
</script>
|
46 |
+
<?php
|
47 |
}
|
48 |
+
}
|
49 |
|
50 |
+
public function init() {
|
51 |
+
if ( isset($_POST['gadsense-nonce']) ) {
|
52 |
+
$this->form_treatment();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
+
$this->nonce = wp_create_nonce( 'gadsense_nonce' );
|
55 |
+
|
56 |
+
// admin notices
|
57 |
+
if ( isset($_COOKIE['gadsense_admin_notice']) ) {
|
58 |
+
// passing the actual message by cookie would enable an injection
|
59 |
+
if ( $_COOKIE['gadsense_admin_notice'] > 0 ) {
|
60 |
+
// error
|
61 |
+
$msg = __( 'The Publisher ID has an incorrect format. (must start with "pub-")', ADVADS_SLUG );
|
62 |
+
$css = 'error';
|
63 |
+
} else {
|
64 |
+
// success
|
65 |
+
$msg = __( 'Data updated', ADVADS_SLUG );
|
66 |
+
$css = 'updated';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
+
$this->notice = array(
|
69 |
+
'msg' => $msg,
|
70 |
+
'class' => $css,
|
71 |
+
);
|
72 |
+
setcookie( 'gadsense_admin_notice', null, -1 );
|
73 |
}
|
74 |
+
}
|
75 |
|
76 |
+
public function form_treatment() {
|
77 |
+
if ( 1 === wp_verify_nonce( $_POST['gadsense-nonce'], 'gadsense_nonce' ) ) {
|
78 |
+
switch ( $_POST['gadsense-form-name'] ) {
|
79 |
+
case 'cred-form' :
|
80 |
+
$id = strtolower( trim( wp_unslash( $_POST['adsense-id'] ) ) );
|
81 |
+
$limit = (isset($_POST['limit-per-page']))? true : false;
|
82 |
+
$isError = false;
|
83 |
+
if ( 0 === strpos( $id, 'pub-' ) ) {
|
84 |
+
$this->data->set_adsense_id( $id );
|
85 |
+
$this->data->set_limit_per_page( $limit );
|
86 |
+
} else {
|
87 |
+
$isError = true;
|
88 |
+
}
|
89 |
+
setcookie( 'gadsense_admin_notice', (string) (int) $isError, time() + 900 ); // only display for 15 minutes
|
90 |
+
break;
|
91 |
+
default :
|
|
|
92 |
}
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
+
// redirect
|
96 |
+
wp_redirect( $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] );
|
97 |
+
die();
|
98 |
+
}
|
99 |
+
|
100 |
+
public function enqueue_scripts() {
|
101 |
+
global $gadsense_globals, $pagenow, $post_type;
|
102 |
+
$screen = get_current_screen();
|
103 |
+
$plugin = Advanced_Ads_Admin::get_instance();
|
104 |
+
if (
|
105 |
+
('post-new.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type) ||
|
106 |
+
('post.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type && isset($_GET['action']) && 'edit' == $_GET['action'])
|
107 |
+
) {
|
108 |
+
$default_script = array(
|
109 |
+
'path' => GADSENSE_BASE_URL . 'admin/assets/js/new-ad.js',
|
110 |
+
'dep' => array('jquery'),
|
111 |
+
'version' => null,
|
112 |
+
);
|
113 |
+
|
114 |
+
$scripts = array(
|
115 |
+
'gadsense-new-ad' => $default_script,
|
116 |
+
);
|
117 |
+
|
118 |
+
// Allow modifications of script files to enqueue
|
119 |
+
$scripts = apply_filters( 'advanced-ads-gadsense-ad-param-script', $scripts );
|
120 |
+
|
121 |
+
foreach ( $scripts as $handle => $value ) {
|
122 |
+
if ( empty($handle) ) {
|
123 |
+
continue;
|
124 |
+
}
|
125 |
+
if ( ! empty($handle) && empty($value) ) {
|
126 |
+
// Allow inclusion of WordPress's built-in script like jQuery
|
127 |
+
wp_enqueue_script( $handle );
|
128 |
+
} else {
|
129 |
+
if ( ! isset($value['version']) ) { $value['version'] = null; }
|
130 |
+
wp_enqueue_script( $handle, $value['path'], $value['dep'], $value['version'] );
|
131 |
}
|
132 |
+
}
|
133 |
|
134 |
+
$styles = array();
|
135 |
|
136 |
+
// Allow modifications of default style files to enqueue
|
137 |
+
$styles = apply_filters( 'advanced-ads-gadsense-ad-param-style', $styles );
|
138 |
|
139 |
+
foreach ( $styles as $handle => $value ) {
|
140 |
+
if ( ! isset($value['path']) ||
|
141 |
+
! isset($value['dep']) ||
|
142 |
+
empty($handle)
|
143 |
+
) {
|
144 |
+
continue;
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
+
if ( ! isset($value['version']) ) {
|
147 |
+
$value['version'] = null; }
|
148 |
+
wp_enqueue_style( $handle, $value['path'], $value['dep'], $value['version'] );
|
149 |
}
|
150 |
}
|
151 |
+
}
|
152 |
|
153 |
+
public static function get_instance() {
|
154 |
+
if ( null == self::$instance ) {
|
155 |
+
self::$instance = new self;
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
+
return self::$instance;
|
158 |
+
}
|
159 |
|
160 |
+
public function settings_form() {
|
161 |
+
require GADSENSE_BASE_PATH . 'admin/views/admin-page.php';
|
162 |
}
|
163 |
|
|
|
164 |
}
|
modules/gadsense/config.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// module configuration
|
4 |
+
|
5 |
+
$path = dirname( __FILE__ );
|
6 |
+
|
7 |
+
return array(
|
8 |
+
'classmap' => array(
|
9 |
+
'Advads_Ad_Type_Adsense' => $path . '/includes/class-ad-type-adsense.php',
|
10 |
+
'Gadsense_Data' => $path . '/includes/class-gadsense-data.php',
|
11 |
+
'Gadsense_Admin' => $path . '/admin/class-gadsense-admin.php',
|
12 |
+
),
|
13 |
+
'textdomain' => null,
|
14 |
+
);
|
modules/gadsense/main.php
CHANGED
@@ -1,32 +1,28 @@
|
|
1 |
<?php
|
2 |
-
if ( ! defined( 'WPINC' ) ) {
|
3 |
-
die;
|
4 |
-
}
|
5 |
-
|
6 |
-
define( 'GADSENSE_BASE_PATH', plugin_dir_path( __FILE__ ) );
|
7 |
-
define( 'GADSENSE_BASE_URL', plugins_url( basename( ADVADS_BASE_PATH ) . '/modules/' . basename( GADSENSE_BASE_PATH ) . '/' ) );
|
8 |
-
define( 'GADSENSE_OPT_NAME', 'gadsense_options' );
|
9 |
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
|
13 |
-
/**
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
function advads_add_ad_type_adsense($types) {
|
19 |
-
|
20 |
-
|
21 |
-
}
|
22 |
|
23 |
-
function gadsense_date_time($time) {
|
24 |
-
|
25 |
-
}
|
26 |
|
27 |
-
Gadsense_Data::get_instance();
|
28 |
-
add_filter( 'advanced-ads-ad-types', 'advads_add_ad_type_adsense' );
|
29 |
|
30 |
-
if ( ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX) && is_admin() ) {
|
31 |
-
|
|
|
32 |
}
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
if ( class_exists( 'Advanced_Ads', false ) ) {
|
4 |
+
define( 'GADSENSE_BASE_PATH', plugin_dir_path( __FILE__ ) );
|
5 |
+
define( 'GADSENSE_BASE_URL', plugins_url( basename( ADVADS_BASE_PATH ) . '/modules/' . basename( GADSENSE_BASE_PATH ) . '/' ) );
|
6 |
+
define( 'GADSENSE_OPT_NAME', 'gadsense_options' );
|
7 |
|
8 |
+
/**
|
9 |
+
* initialize ad type and add it to the plugins ad types
|
10 |
+
*
|
11 |
+
* "content" key must match the id
|
12 |
+
*/
|
13 |
+
function advads_add_ad_type_adsense($types) {
|
14 |
+
$types['adsense'] = new Advads_Ad_Type_Adsense();
|
15 |
+
return $types;
|
16 |
+
}
|
17 |
|
18 |
+
function gadsense_date_time($time) {
|
19 |
+
return date_i18n( get_option( 'date_format' ), $time ) . __( ' at ', ADVADS_SLUG ) . date_i18n( get_option( 'time_format' ), $time );
|
20 |
+
}
|
21 |
|
22 |
+
Gadsense_Data::get_instance();
|
23 |
+
add_filter( 'advanced-ads-ad-types', 'advads_add_ad_type_adsense' );
|
24 |
|
25 |
+
if ( ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX) && is_admin() ) {
|
26 |
+
Gadsense_Admin::get_instance();
|
27 |
+
}
|
28 |
}
|
public/class-advanced-ads.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @author Thomas Maier <thomas.maier@webgilde.com>
|
8 |
* @license GPL-2.0+
|
9 |
* @link http://webgilde.com
|
10 |
-
* @copyright 2013-
|
11 |
*/
|
12 |
|
13 |
/**
|
@@ -25,7 +25,7 @@ class Advanced_Ads {
|
|
25 |
* @var string
|
26 |
*/
|
27 |
|
28 |
-
const VERSION = '1.
|
29 |
|
30 |
/**
|
31 |
* post type slug
|
@@ -43,25 +43,13 @@ class Advanced_Ads {
|
|
43 |
*/
|
44 |
const AD_GROUP_TAXONOMY = 'advanced_ads_groups';
|
45 |
|
46 |
-
/**
|
47 |
-
* general plugin slug
|
48 |
-
*
|
49 |
-
* DEPRECATED: The variable name is used as the text domain when internationalizing strings
|
50 |
-
* of text. Its value should match the Text Domain file header in the main
|
51 |
-
* plugin file.
|
52 |
-
*
|
53 |
-
* @since 1.0.0
|
54 |
-
* @var string
|
55 |
-
*/
|
56 |
-
protected $plugin_slug = 'advanced-ads';
|
57 |
-
|
58 |
/**
|
59 |
* Instance of this class.
|
60 |
*
|
61 |
* @since 1.0.0
|
62 |
* @var object
|
63 |
*/
|
64 |
-
|
65 |
|
66 |
/**
|
67 |
* array with ads currently delivered in the frontend
|
@@ -89,56 +77,97 @@ class Advanced_Ads {
|
|
89 |
*/
|
90 |
protected $internal_options = false;
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
|
100 |
/**
|
101 |
-
* Initialize the plugin by setting localization and loading public scripts
|
102 |
-
* and styles.
|
103 |
*
|
104 |
-
* @
|
105 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
private function __construct() {
|
|
|
|
|
|
|
107 |
|
108 |
-
|
|
|
109 |
|
110 |
-
//
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
-
//
|
117 |
-
|
118 |
-
|
|
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
register_activation_hook( __FILE__, array($this,'post_types_rewrite_flush') );
|
123 |
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
// setup default ad types
|
135 |
-
add_filter( 'advanced-ads-ad-types', array($this, 'setup_default_ad_types') );
|
136 |
|
137 |
// register hooks and filters for auto ad injection
|
138 |
-
|
139 |
-
add_action( 'wp_footer', array($this, 'inject_footer'), 20 );
|
140 |
-
$content_injection_priority = (isset($options['content-injection-priority'])) ? absint( $options['content-injection-priority'] ) : 100;
|
141 |
-
add_filter( 'the_content', array($this, 'inject_content'), $content_injection_priority );
|
142 |
}
|
143 |
|
144 |
/**
|
@@ -146,13 +175,46 @@ class Advanced_Ads {
|
|
146 |
*
|
147 |
* @since 1.0.0
|
148 |
*/
|
149 |
-
public function
|
150 |
// load ad post types
|
151 |
$this->create_post_types();
|
152 |
// set ad types array
|
153 |
$this->set_ad_types();
|
154 |
}
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
/**
|
157 |
* set global constant that prevents ads from being displayed on the current page view
|
158 |
*
|
@@ -165,7 +227,7 @@ class Advanced_Ads {
|
|
165 |
// don't set the constant if already defined
|
166 |
if ( defined( 'ADVADS_ADS_DISABLED' ) ) { return; }
|
167 |
|
168 |
-
$options = $this->options();
|
169 |
|
170 |
// check if ads are disabled completely
|
171 |
if ( ! empty($options['disabled-ads']['all']) ){
|
@@ -204,302 +266,228 @@ class Advanced_Ads {
|
|
204 |
/**
|
205 |
* Return the plugin slug.
|
206 |
*
|
207 |
-
* @since
|
208 |
-
* @return
|
209 |
*/
|
210 |
public function get_plugin_slug() {
|
211 |
-
return $this->
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
-
*
|
|
|
|
|
216 |
*
|
217 |
-
* @since
|
218 |
-
* @return
|
|
|
219 |
*/
|
220 |
-
public
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
225 |
}
|
226 |
|
227 |
-
return
|
228 |
}
|
229 |
|
230 |
/**
|
231 |
-
*
|
|
|
|
|
232 |
*
|
233 |
-
* @since 1.0.0
|
234 |
-
* @param boolean $network_wide True if WPMU superadmin uses
|
235 |
-
* "Network Activate" action, false if
|
236 |
-
* WPMU is disabled or plugin is
|
237 |
-
* activated on an individual blog.
|
238 |
*/
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
if ( $network_wide ) {
|
244 |
-
|
245 |
-
// Get all blog ids
|
246 |
-
$blog_ids = self::get_blog_ids();
|
247 |
-
|
248 |
-
foreach ( $blog_ids as $blog_id ) {
|
249 |
-
|
250 |
-
switch_to_blog( $blog_id );
|
251 |
-
self::single_activate();
|
252 |
-
}
|
253 |
-
|
254 |
-
restore_current_blog();
|
255 |
-
} else {
|
256 |
-
self::single_activate();
|
257 |
-
}
|
258 |
-
} else {
|
259 |
-
self::single_activate();
|
260 |
-
}
|
261 |
}
|
262 |
|
263 |
/**
|
264 |
-
*
|
265 |
-
*
|
266 |
-
* @since 1.0.0
|
267 |
-
* @param boolean $network_wide
|
268 |
*
|
269 |
-
*
|
270 |
-
*
|
271 |
-
* WPMU is disabled or plugin is
|
272 |
-
* deactivated on an individual blog.
|
273 |
*/
|
274 |
-
public
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
// Get all blog ids
|
281 |
-
$blog_ids = self::get_blog_ids();
|
282 |
-
|
283 |
-
foreach ( $blog_ids as $blog_id ) {
|
284 |
-
|
285 |
-
switch_to_blog( $blog_id );
|
286 |
-
self::single_deactivate();
|
287 |
-
}
|
288 |
-
|
289 |
-
restore_current_blog();
|
290 |
} else {
|
291 |
-
|
|
|
292 |
}
|
293 |
-
} else {
|
294 |
-
self::single_deactivate();
|
295 |
}
|
296 |
}
|
297 |
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
* @since 1.0.0
|
302 |
-
* @param int $blog_id ID of the new blog.
|
303 |
-
*/
|
304 |
-
public function activate_new_site($blog_id) {
|
305 |
-
|
306 |
-
if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
|
307 |
-
return;
|
308 |
-
}
|
309 |
-
|
310 |
-
switch_to_blog( $blog_id );
|
311 |
-
self::single_activate();
|
312 |
-
restore_current_blog();
|
313 |
}
|
314 |
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
* - not spam
|
319 |
-
* - not deleted
|
320 |
-
*
|
321 |
-
* @since 1.0.0
|
322 |
-
* @return array|false The blog ids, false if no matches.
|
323 |
-
*/
|
324 |
-
private static function get_blog_ids() {
|
325 |
-
|
326 |
-
global $wpdb;
|
327 |
-
|
328 |
-
// get an array of blog ids
|
329 |
-
$sql = "SELECT blog_id FROM $wpdb->blogs
|
330 |
-
WHERE archived = '0' AND spam = '0'
|
331 |
-
AND deleted = '0'";
|
332 |
-
|
333 |
-
return $wpdb->get_col( $sql );
|
334 |
}
|
335 |
|
336 |
/**
|
337 |
-
*
|
338 |
*
|
339 |
-
* @since
|
340 |
*/
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
343 |
}
|
344 |
|
345 |
/**
|
346 |
-
*
|
347 |
*
|
348 |
-
* @since
|
349 |
*/
|
350 |
-
|
351 |
-
|
|
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
|
354 |
/**
|
355 |
-
*
|
|
|
356 |
*
|
357 |
-
* @since
|
|
|
358 |
*/
|
359 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
|
361 |
-
|
362 |
-
load_plugin_textdomain( ADVADS_SLUG, false, ADVADS_BASE_DIR . '/languages' );
|
363 |
}
|
364 |
|
365 |
/**
|
366 |
-
*
|
367 |
*
|
368 |
-
* @
|
|
|
|
|
|
|
369 |
*/
|
370 |
-
|
371 |
-
|
372 |
}
|
373 |
|
374 |
/**
|
375 |
-
*
|
376 |
*
|
377 |
-
* @
|
|
|
|
|
|
|
|
|
378 |
*/
|
379 |
-
|
380 |
-
|
381 |
-
$options = $this->options();
|
382 |
-
if ( ! empty($options['advanced-js']) ){
|
383 |
-
wp_enqueue_script( $this->plugin_slug . '-advanced-js', plugins_url( 'assets/js/advanced.js', __FILE__ ), array('jquery'), self::VERSION );
|
384 |
-
}
|
385 |
}
|
386 |
|
387 |
/**
|
388 |
-
*
|
389 |
-
*
|
390 |
-
* name => publically readable name
|
391 |
-
* description => publically readable description
|
392 |
-
* editor => kind of editor: text (normal text field), content (WP content field), none (no content field)
|
393 |
-
* will display text field, if left empty
|
394 |
*
|
395 |
-
* @since 1.
|
|
|
|
|
396 |
*/
|
397 |
-
public function
|
398 |
-
|
399 |
-
/**
|
400 |
-
* load default ad type files
|
401 |
-
* custom ad types can also be loaded in your own plugin or functions.php
|
402 |
-
*/
|
403 |
-
$types = array();
|
404 |
-
|
405 |
-
/**
|
406 |
-
* developers can add new ad types using this filter
|
407 |
-
* see classes/ad-type-content.php for an example for an ad type and usage of this filter
|
408 |
-
*/
|
409 |
-
$this->ad_types = apply_filters( 'advanced-ads-ad-types', $types );
|
410 |
}
|
411 |
|
412 |
/**
|
413 |
-
* add plain and content ad types to the default ads of the plugin using a filter
|
414 |
-
*
|
415 |
-
* @since 1.0.0
|
416 |
*
|
|
|
|
|
417 |
*/
|
418 |
-
function
|
419 |
-
|
420 |
-
$types['content'] = new Advads_Ad_Type_Content(); /* rich content editor */
|
421 |
-
return $types;
|
422 |
}
|
423 |
|
424 |
/**
|
425 |
-
*
|
426 |
-
* = list possible ads for each condition
|
427 |
*
|
428 |
-
* @since 1.
|
429 |
-
* @return
|
430 |
-
* @todo
|
431 |
*/
|
432 |
-
public function
|
433 |
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
$ads_by_conditions = array();
|
438 |
}
|
439 |
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
/**
|
444 |
-
* get the array with ad placements
|
445 |
-
*
|
446 |
-
* @since 1.1.0
|
447 |
-
* @return arr $ad_placements
|
448 |
-
*/
|
449 |
-
static public function get_ad_placements_array(){
|
450 |
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
$ad_placements = array();
|
455 |
}
|
456 |
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
* shortcode to include ad in frontend
|
462 |
-
*
|
463 |
-
* @since 1.0.0
|
464 |
-
* @param arr $atts
|
465 |
-
*/
|
466 |
-
public function shortcode_display_ad($atts){
|
467 |
-
extract( shortcode_atts( array(
|
468 |
-
'id' => 0,
|
469 |
-
), $atts ) );
|
470 |
|
471 |
-
|
472 |
-
return get_ad( $id );
|
473 |
}
|
474 |
|
475 |
/**
|
476 |
-
*
|
477 |
*
|
478 |
-
* @since 1.
|
479 |
-
* @
|
480 |
*/
|
481 |
-
public function
|
482 |
-
|
483 |
-
|
484 |
-
|
|
|
485 |
|
486 |
-
|
487 |
-
|
488 |
-
}
|
489 |
|
490 |
-
|
491 |
-
|
492 |
-
*
|
493 |
-
* @since 1.1.0
|
494 |
-
* @param arr $atts
|
495 |
-
*/
|
496 |
-
public function shortcode_display_ad_placement($atts){
|
497 |
-
extract( shortcode_atts( array(
|
498 |
-
'id' => '',
|
499 |
-
), $atts ) );
|
500 |
|
501 |
-
|
502 |
-
return get_ad_placement( $id );
|
503 |
}
|
504 |
|
505 |
/**
|
@@ -508,20 +496,20 @@ class Advanced_Ads {
|
|
508 |
* @since 1.0.0
|
509 |
*/
|
510 |
public function create_post_types() {
|
511 |
-
if ( did_action( 'init' )
|
512 |
return;
|
513 |
}
|
514 |
|
515 |
// register ad group taxonomy
|
516 |
-
if ( ! taxonomy_exists(
|
517 |
$post_type_params = $this->get_group_taxonomy_params();
|
518 |
-
register_taxonomy(
|
519 |
}
|
520 |
|
521 |
// register ad post type
|
522 |
-
if ( ! post_type_exists(
|
523 |
$post_type_params = $this->get_post_type_params();
|
524 |
-
register_post_type(
|
525 |
}
|
526 |
}
|
527 |
|
@@ -586,229 +574,18 @@ class Advanced_Ads {
|
|
586 |
|
587 |
$post_type_params = array(
|
588 |
'labels' => $labels,
|
589 |
-
'singular_label' => __( 'Ad', ADVADS_SLUG ),
|
590 |
'public' => false,
|
591 |
'show_ui' => true,
|
592 |
'show_in_menu' => false,
|
593 |
'hierarchical' => false,
|
594 |
'capability_type' => 'page',
|
595 |
'has_archive' => false,
|
596 |
-
'rewrite' => array('slug' => ADVADS_SLUG),
|
597 |
'query_var' => true,
|
598 |
-
'supports' => array('title'),
|
599 |
-
'taxonomies' => array(
|
600 |
);
|
601 |
|
602 |
return apply_filters( 'advanced-ads-post-type-params', $post_type_params );
|
603 |
}
|
604 |
-
|
605 |
-
/**
|
606 |
-
* remove WP tag edit page for the ad group taxonomy
|
607 |
-
* needed, because we can’t remove it with `show_ui` without also removing the meta box
|
608 |
-
*
|
609 |
-
* @since 1.0.0
|
610 |
-
*/
|
611 |
-
public function remove_taxonomy_menu_item() {
|
612 |
-
remove_submenu_page( 'edit.php?post_type=advanced_ads', 'edit-tags.php?taxonomy=advanced_ads_groups&post_type=advanced_ads' );
|
613 |
-
}
|
614 |
-
|
615 |
-
/**
|
616 |
-
* flush rewrites on plugin activation so permalinks for them work from the beginning on
|
617 |
-
*
|
618 |
-
* @since 1.0.0
|
619 |
-
* @link http://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation
|
620 |
-
*/
|
621 |
-
public function post_types_rewrite_flush(){
|
622 |
-
// load custom post type
|
623 |
-
$this->create_post_types();
|
624 |
-
// flush rewrite rules
|
625 |
-
flush_rewrite_rules();
|
626 |
-
}
|
627 |
-
|
628 |
-
/**
|
629 |
-
* log error messages when debug is enabled
|
630 |
-
*
|
631 |
-
* @since 1.0.0
|
632 |
-
* @link http://www.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/
|
633 |
-
*/
|
634 |
-
public function log($message) {
|
635 |
-
if ( WP_DEBUG === true ) {
|
636 |
-
if ( is_array( $message ) || is_object( $message ) ) {
|
637 |
-
error_log( 'Advanced Ads Error following:', ADVADS_SLUG );
|
638 |
-
error_log( print_r( $message, true ) );
|
639 |
-
} else {
|
640 |
-
$message = sprintf( __( 'Advanced Ads Error: %s', ADVADS_SLUG ), $message );
|
641 |
-
error_log( $message );
|
642 |
-
}
|
643 |
-
}
|
644 |
-
}
|
645 |
-
|
646 |
-
/**
|
647 |
-
* return plugin options
|
648 |
-
* these are the options updated by the user
|
649 |
-
*
|
650 |
-
* @since 1.0.1
|
651 |
-
* @return arr $options
|
652 |
-
* @todo parse default options
|
653 |
-
*/
|
654 |
-
public function options(){
|
655 |
-
if ( $this->options === false ){
|
656 |
-
$this->options = get_option( ADVADS_SLUG, array() );
|
657 |
-
}
|
658 |
-
|
659 |
-
return $this->options;
|
660 |
-
}
|
661 |
-
|
662 |
-
/**
|
663 |
-
* return internal plugin options
|
664 |
-
* these are options set by the plugin
|
665 |
-
*
|
666 |
-
* @since 1.0.1
|
667 |
-
* @return arr $options
|
668 |
-
* @todo parse default options
|
669 |
-
*/
|
670 |
-
public function internal_options(){
|
671 |
-
if ( $this->internal_options === false ){
|
672 |
-
$this->internal_options = get_option( ADVADS_SLUG . '-internal', array() );
|
673 |
-
}
|
674 |
-
|
675 |
-
return $this->internal_options;
|
676 |
-
}
|
677 |
-
|
678 |
-
/**
|
679 |
-
* injected ad into header
|
680 |
-
*
|
681 |
-
* @since 1.1.0
|
682 |
-
*/
|
683 |
-
public function inject_header(){
|
684 |
-
$placements = get_option( 'advads-ads-placements', array() );
|
685 |
-
foreach ( $placements as $_placement_id => $_placement ){
|
686 |
-
if ( isset($_placement['type']) && $_placement['type'] == 'header' ){
|
687 |
-
echo Advads_Ad_Placements::output( $_placement_id );
|
688 |
-
}
|
689 |
-
}
|
690 |
-
}
|
691 |
-
|
692 |
-
/**
|
693 |
-
* injected ads into footer
|
694 |
-
*
|
695 |
-
* @since 1.1.0
|
696 |
-
*/
|
697 |
-
public function inject_footer(){
|
698 |
-
$placements = get_option( 'advads-ads-placements', array() );
|
699 |
-
foreach ( $placements as $_placement_id => $_placement ){
|
700 |
-
if ( isset($_placement['type']) && $_placement['type'] == 'footer' ){
|
701 |
-
echo Advads_Ad_Placements::output( $_placement_id );
|
702 |
-
}
|
703 |
-
}
|
704 |
-
}
|
705 |
-
|
706 |
-
/**
|
707 |
-
* injected ad into content (before and after)
|
708 |
-
* displays ALL ads
|
709 |
-
*
|
710 |
-
* @since 1.1.0
|
711 |
-
* @param str $content post content
|
712 |
-
*/
|
713 |
-
public function inject_content($content = ''){
|
714 |
-
// run only on single pages of public post types
|
715 |
-
$public_post_types = get_post_types( array('public' => true, 'publicly_queryable' => true), 'names', 'or' );
|
716 |
-
|
717 |
-
if ( ! is_singular( $public_post_types ) ) { return $content; }
|
718 |
-
|
719 |
-
$placements = get_option( 'advads-ads-placements', array() );
|
720 |
-
foreach ( $placements as $_placement_id => $_placement ){
|
721 |
-
if ( empty($_placement['item']) ) { continue; }
|
722 |
-
|
723 |
-
if ( isset($_placement['type']) && $_placement['type'] == 'post_top' ){
|
724 |
-
$content = Advads_Ad_Placements::output( $_placement_id ) . $content;
|
725 |
-
}
|
726 |
-
if ( isset($_placement['type']) && $_placement['type'] == 'post_bottom' ){
|
727 |
-
$content .= Advads_Ad_Placements::output( $_placement_id );
|
728 |
-
}
|
729 |
-
if ( isset($_placement['type']) && $_placement['type'] == 'post_content' ){
|
730 |
-
$content = Advads_Ad_Placements::inject_in_content( $_placement_id, $_placement['options'], $content );
|
731 |
-
}
|
732 |
-
}
|
733 |
-
|
734 |
-
return $content;
|
735 |
-
}
|
736 |
-
|
737 |
-
/**
|
738 |
-
* load all ads based on WP_Query conditions
|
739 |
-
*
|
740 |
-
* @since 1.1.0
|
741 |
-
* @param arr $args WP_Query arguments that are more specific that default
|
742 |
-
* @return arr $ads array with post objects
|
743 |
-
*/
|
744 |
-
static function get_ads($args = array()){
|
745 |
-
// add default WP_Query arguments
|
746 |
-
$args['post_type'] = self::POST_TYPE_SLUG;
|
747 |
-
$args['posts_per_page'] = -1;
|
748 |
-
if ( empty($args['post_status']) ) { $args['post_status'] = 'publish'; }
|
749 |
-
|
750 |
-
$ads = new WP_Query( $args );
|
751 |
-
return $ads->posts;
|
752 |
-
}
|
753 |
-
|
754 |
-
/**
|
755 |
-
* load all ad groups
|
756 |
-
*
|
757 |
-
* @since 1.1.0
|
758 |
-
* @param arr $args array with options
|
759 |
-
* @return arr $groups array with ad groups
|
760 |
-
* @link http://codex.wordpress.org/Function_Reference/get_terms
|
761 |
-
*/
|
762 |
-
static function get_ad_groups($args = array()){
|
763 |
-
$args['hide_empty'] = isset($args['hide_empty']) ? $args['hide_empty'] : false; // display groups without any ads
|
764 |
-
|
765 |
-
return get_terms( Advanced_Ads::AD_GROUP_TAXONOMY, $args );
|
766 |
-
}
|
767 |
-
|
768 |
-
/**
|
769 |
-
* general check if ads can be displayed for the whole page impression
|
770 |
-
*
|
771 |
-
* @since 1.4.9
|
772 |
-
* @return bool true, if ads can be displayed
|
773 |
-
* @todo move this to set_disabled_constant()
|
774 |
-
*/
|
775 |
-
public function can_display_ads(){
|
776 |
-
|
777 |
-
// check global constant if ads are enabled or disabled
|
778 |
-
if ( defined( 'ADVADS_ADS_DISABLED' ) ) { return false; }
|
779 |
-
|
780 |
-
$options = $this->options();
|
781 |
-
$see_ads_capability = ( ! empty($options['hide-for-user-role'])) ? $options['hide-for-user-role'] : 0;
|
782 |
-
|
783 |
-
// check if user is logged in and if so if users with his rights can see ads
|
784 |
-
if ( is_user_logged_in() && $see_ads_capability && current_user_can( $see_ads_capability ) ) {
|
785 |
-
return false;
|
786 |
-
}
|
787 |
-
|
788 |
-
// check bots if option is enabled
|
789 |
-
if(isset($options['block-bots']) && $options['block-bots'] && $this->is_bot()) return false;
|
790 |
-
|
791 |
-
return true;
|
792 |
-
}
|
793 |
-
|
794 |
-
/**
|
795 |
-
* check if the current user agent is given or a bot
|
796 |
-
*
|
797 |
-
* @since 1.4.9
|
798 |
-
* @return bool true if the current user agent is empty or a bot
|
799 |
-
*/
|
800 |
-
public function is_bot(){
|
801 |
-
$bots = apply_filters('advanced-ads-bots', $this->bots);
|
802 |
-
$bots = implode('|', $bots);
|
803 |
-
$bots = preg_replace('@[^-_;/|\][ a-z0-9]@i', '', $bots);
|
804 |
-
$regex = "@$bots@i";
|
805 |
-
|
806 |
-
if(isset($_SERVER['HTTP_USER_AGENT'])) {
|
807 |
-
$agent = $_SERVER['HTTP_USER_AGENT'];
|
808 |
-
|
809 |
-
return preg_match($regex, $agent) === 1;
|
810 |
-
}
|
811 |
-
|
812 |
-
return true;
|
813 |
-
}
|
814 |
}
|
7 |
* @author Thomas Maier <thomas.maier@webgilde.com>
|
8 |
* @license GPL-2.0+
|
9 |
* @link http://webgilde.com
|
10 |
+
* @copyright 2013-2015 Thomas Maier, webgilde GmbH
|
11 |
*/
|
12 |
|
13 |
/**
|
25 |
* @var string
|
26 |
*/
|
27 |
|
28 |
+
const VERSION = '1.5.0';
|
29 |
|
30 |
/**
|
31 |
* post type slug
|
43 |
*/
|
44 |
const AD_GROUP_TAXONOMY = 'advanced_ads_groups';
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
/**
|
47 |
* Instance of this class.
|
48 |
*
|
49 |
* @since 1.0.0
|
50 |
* @var object
|
51 |
*/
|
52 |
+
private static $instance = null;
|
53 |
|
54 |
/**
|
55 |
* array with ads currently delivered in the frontend
|
77 |
*/
|
78 |
protected $internal_options = false;
|
79 |
|
80 |
+
/**
|
81 |
+
* list of bots and crawlers to exclude from ad impressions
|
82 |
+
*
|
83 |
+
* @since 1.4.9
|
84 |
+
* @var array list of bots
|
85 |
+
*/
|
86 |
+
protected $bots = array('008','ABACHOBot','Accoona-AI-Agent','AddSugarSpiderBot','ADmantX','AhrefsBot','alexa','AnyApexBot','appie','Apple-PubSub','Arachmo','Ask Jeeves','avira.com','B-l-i-t-z-B-O-T','Baiduspider','BecomeBot','BeslistBot','BillyBobBot','Bimbot','Bingbot','BLEXBot','BlitzBOT','boitho.com-dc','boitho.com-robot','bot','btbot','CatchBot','Cerberian Drtrs','Charlotte','ConveraCrawler','cosmos','Covario IDS','crawler','CrystalSemanticsBot','curl','DataparkSearch','DiamondBot','Discobot','Dotbot','EmeraldShield.com WebBot','envolk[ITS]spider','EsperanzaBot','Exabot','expo9','facebookexternalhit','FAST Enterprise Crawler','FAST-WebCrawler','FDSE robot','Feedfetcher-Google','FindLinks','Firefly','froogle','FurlBot','FyberSpider','g2crawler','Gaisbot','GalaxyBot','genieBot','Genieo','Gigabot','Girafabot','Googlebot','Googlebot-Image','GrapeshotCrawler','GurujiBot','HappyFunBot','heritrix','hl_ftien_spider','Holmes','htdig','https://developers.google.com','ia_archiver','iaskspider','iCCrawler','ichiro','igdeSpyder','InfoSeek','inktomi','IRLbot','IssueCrawler','Jaxified Bot','Jyxobot','KoepaBot','Kraken','L.webis','LapozzBot','Larbin','LDSpider','LexxeBot','Linguee','Bot','LinkWalker','lmspider','looksmart','lwp-trivial','mabontland','magpie-crawler','Mail.RU_Bot','MaxPointCrawler','Mediapartners-Google','MJ12bot','Mnogosearch','mogimogi','MojeekBot','Moreoverbot','Morning Paper','msnbot','MSRBot','MVAClient','mxbot','NationalDirectory','NetResearchServer','NetSeer Crawler','NewsGator','NG-Search','nicebot','noxtrumbot','Nusearch','Spider','Nutch crawler','NutchCVS','Nymesis','obot','oegp','omgilibot','OmniExplorer_Bot','OOZBOT','Orbiter','PageBitesHyperBot','Peew','polybot','Pompos','PostPost','proximic','Psbot','PycURL','Qseero','rabaz','Radian6','RAMPyBot','Rankivabot','RufusBot','SandCrawler','savetheworldheritage','SBIder','Scooter','ScoutJet','Scrubby','SearchSight','Seekbot','semanticdiscovery','Sensis','Web Crawler','SEOChat::Bot','SeznamBot','Shim-Crawler','ShopWiki','Shoula robot','silk','Sitebot','Snappy','sogou spider','Sogou web spider','Sosospider','Spade','Speedy Spider','Sqworm','StackRambler','suggybot','SurveyBot','SynooBot','TechnoratiSnoop','TECNOSEEK','Teoma','TerrawizBot','TheSuBot','Thumbnail.CZ','robot','TinEye','truwoGPS','TurnitinBot','TweetedTimes Bot','TwengaBot','updated','URL_Spider_SQL','Urlfilebot','Vagabondo','VoilaBot','voltron','Vortex','voyager','VYU2','WebAlta Crawler','WebBug','webcollage','WebFindBot','WebIndex','Websquash.com','WeSEE:Ads','wf84','Wget','WoFindeIch Robot','WomlpeFactory','WordPress','Xaldon_WebSpider','yacy','Yahoo! Slurp','Yahoo! Slurp China','YahooSeeker','YahooSeeker-Testing','YandexBot','YandexImages','Yasaklibot','Yeti','YodaoBot','yoogliFetchAgent','YoudaoBot','Zao','Zealbot','zspider','ZyBorg');
|
87 |
|
88 |
/**
|
|
|
|
|
89 |
*
|
90 |
+
* @var Advanced_Ads_Model
|
91 |
*/
|
92 |
+
protected $model;
|
93 |
+
|
94 |
+
/**
|
95 |
+
*
|
96 |
+
* @var Advanced_Ads_Plugin
|
97 |
+
*/
|
98 |
+
protected $plugin;
|
99 |
+
|
100 |
+
/**
|
101 |
+
*
|
102 |
+
* @var Advanced_Ads_Select
|
103 |
+
*/
|
104 |
+
protected $ad_selector;
|
105 |
+
|
106 |
private function __construct() {
|
107 |
+
$this->plugin = Advanced_Ads_Plugin::get_instance();
|
108 |
+
$this->plugin->set_model($this->get_model());
|
109 |
+
$this->ad_selector = Advanced_Ads_Select::get_instance();
|
110 |
|
111 |
+
// initialize plugin specific functions
|
112 |
+
add_action( 'init', array( $this, 'wp_init' ) );
|
113 |
|
114 |
+
// only when not doing ajax
|
115 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
116 |
+
Advanced_Ads_Ajax::get_instance();
|
117 |
+
} else {
|
118 |
+
add_action( 'plugins_loaded', array( $this, 'wp_plugins_loaded' ) );
|
119 |
+
}
|
120 |
+
}
|
121 |
|
122 |
+
/**
|
123 |
+
* Return an instance of this class.
|
124 |
+
*
|
125 |
+
* @since 1.0.0
|
126 |
+
* @return Advanced_Ads A single instance of this class.
|
127 |
+
*/
|
128 |
+
public static function get_instance() {
|
129 |
|
130 |
+
// If the single instance hasn't been set, set it now.
|
131 |
+
if ( null === self::$instance ) {
|
132 |
+
self::$instance = new self;
|
133 |
+
}
|
134 |
|
135 |
+
return self::$instance;
|
136 |
+
}
|
|
|
137 |
|
138 |
+
/**
|
139 |
+
*
|
140 |
+
* @return Advanced_Ads_Model
|
141 |
+
*/
|
142 |
+
public function get_model() {
|
143 |
+
|
144 |
+
global $wpdb;
|
145 |
+
|
146 |
+
if ( ! isset($this->model) ) {
|
147 |
+
$this->model = new Advanced_Ads_Model( $wpdb );
|
148 |
+
}
|
149 |
|
150 |
+
return $this->model;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Initialize the plugin by setting localization and loading public scripts
|
155 |
+
* and styles.
|
156 |
+
*
|
157 |
+
* @since 1.0.0
|
158 |
+
*/
|
159 |
+
public function wp_plugins_loaded()
|
160 |
+
{
|
161 |
+
$options = $this->plugin->options();
|
162 |
+
|
163 |
+
// register hook for global constants
|
164 |
+
add_action( 'wp', array( $this, 'set_disabled_constant' ) );
|
165 |
|
166 |
// setup default ad types
|
167 |
+
add_filter( 'advanced-ads-ad-types', array( $this, 'setup_default_ad_types' ), 5 );
|
168 |
|
169 |
// register hooks and filters for auto ad injection
|
170 |
+
$this->init_injection( $options );
|
|
|
|
|
|
|
171 |
}
|
172 |
|
173 |
/**
|
175 |
*
|
176 |
* @since 1.0.0
|
177 |
*/
|
178 |
+
public function wp_init(){
|
179 |
// load ad post types
|
180 |
$this->create_post_types();
|
181 |
// set ad types array
|
182 |
$this->set_ad_types();
|
183 |
}
|
184 |
|
185 |
+
/**
|
186 |
+
* define ad types with their options
|
187 |
+
*
|
188 |
+
* name => publically readable name
|
189 |
+
* description => publically readable description
|
190 |
+
* editor => kind of editor: text (normal text field), content (WP content field), none (no content field)
|
191 |
+
* will display text field, if left empty
|
192 |
+
*
|
193 |
+
* @since 1.0.0
|
194 |
+
*/
|
195 |
+
public function set_ad_types() {
|
196 |
+
|
197 |
+
/**
|
198 |
+
* load default ad type files
|
199 |
+
* custom ad types can also be loaded in your own plugin or functions.php
|
200 |
+
*/
|
201 |
+
$types = array();
|
202 |
+
|
203 |
+
/**
|
204 |
+
* developers can add new ad types using this filter
|
205 |
+
* see classes/ad-type-content.php for an example for an ad type and usage of this filter
|
206 |
+
*/
|
207 |
+
$this->ad_types = apply_filters( 'advanced-ads-ad-types', $types );
|
208 |
+
}
|
209 |
+
|
210 |
+
public function init_injection($options) {
|
211 |
+
// -TODO abstract
|
212 |
+
add_action( 'wp_head', array( $this, 'inject_header' ), 20 );
|
213 |
+
add_action( 'wp_footer', array( $this, 'inject_footer' ), 20 );
|
214 |
+
$content_injection_priority = isset( $options['content-injection-priority'] ) ? absint( $options['content-injection-priority'] ) : 100;
|
215 |
+
add_filter( 'the_content', array( $this, 'inject_content' ), $content_injection_priority );
|
216 |
+
}
|
217 |
+
|
218 |
/**
|
219 |
* set global constant that prevents ads from being displayed on the current page view
|
220 |
*
|
227 |
// don't set the constant if already defined
|
228 |
if ( defined( 'ADVADS_ADS_DISABLED' ) ) { return; }
|
229 |
|
230 |
+
$options = $this->plugin->options();
|
231 |
|
232 |
// check if ads are disabled completely
|
233 |
if ( ! empty($options['disabled-ads']['all']) ){
|
266 |
/**
|
267 |
* Return the plugin slug.
|
268 |
*
|
269 |
+
* @since 1.0.0
|
270 |
+
* @return Plugin slug variable.
|
271 |
*/
|
272 |
public function get_plugin_slug() {
|
273 |
+
return $this->plugin->get_plugin_slug();
|
274 |
}
|
275 |
|
276 |
/**
|
277 |
+
* get an array with all ads by conditions
|
278 |
+
* = list possible ads for each condition
|
279 |
+
* TODO is this a duplication of Advanced_Ads_Model::get_ad_conditions() ??
|
280 |
*
|
281 |
+
* @since 1.0.0
|
282 |
+
* @return arr $ads_by_conditions
|
283 |
+
* @todo make static
|
284 |
*/
|
285 |
+
public function get_ads_by_conditions_array(){
|
286 |
|
287 |
+
$ads_by_conditions = get_option( 'advads-ads-by-conditions', array() );
|
288 |
+
// load default array if no conditions saved yet
|
289 |
+
if ( ! is_array( $ads_by_conditions ) ){
|
290 |
+
$ads_by_conditions = array();
|
291 |
}
|
292 |
|
293 |
+
return $ads_by_conditions;
|
294 |
}
|
295 |
|
296 |
/**
|
297 |
+
* add plain and content ad types to the default ads of the plugin using a filter
|
298 |
+
*
|
299 |
+
* @since 1.0.0
|
300 |
*
|
|
|
|
|
|
|
|
|
|
|
301 |
*/
|
302 |
+
function setup_default_ad_types($types){
|
303 |
+
$types['plain'] = new Advads_Ad_Type_Plain(); /* plain text and php code */
|
304 |
+
$types['content'] = new Advads_Ad_Type_Content(); /* rich content editor */
|
305 |
+
return $types;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
}
|
307 |
|
308 |
/**
|
309 |
+
* log error messages when debug is enabled
|
|
|
|
|
|
|
310 |
*
|
311 |
+
* @since 1.0.0
|
312 |
+
* @link http://www.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/
|
|
|
|
|
313 |
*/
|
314 |
+
public function log($message) {
|
315 |
+
if ( true === WP_DEBUG ) {
|
316 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
317 |
+
error_log( 'Advanced Ads Error following:', ADVADS_SLUG );
|
318 |
+
error_log( print_r( $message, true ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
} else {
|
320 |
+
$message = sprintf( __( 'Advanced Ads Error: %s', ADVADS_SLUG ), $message );
|
321 |
+
error_log( $message );
|
322 |
}
|
|
|
|
|
323 |
}
|
324 |
}
|
325 |
|
326 |
+
// compat method
|
327 |
+
public function options() {
|
328 |
+
return $this->plugin->options();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
}
|
330 |
|
331 |
+
// compat method
|
332 |
+
public function internal_options() {
|
333 |
+
return $this->plugin->internal_options();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
}
|
335 |
|
336 |
/**
|
337 |
+
* injected ad into header
|
338 |
*
|
339 |
+
* @since 1.1.0
|
340 |
*/
|
341 |
+
public function inject_header(){
|
342 |
+
$placements = get_option( 'advads-ads-placements', array() );
|
343 |
+
foreach ( $placements as $_placement_id => $_placement ){
|
344 |
+
if ( isset($_placement['type']) && 'header' == $_placement['type'] ){
|
345 |
+
echo Advads_Ad_Placements::output( $_placement_id );
|
346 |
+
}
|
347 |
+
}
|
348 |
}
|
349 |
|
350 |
/**
|
351 |
+
* injected ads into footer
|
352 |
*
|
353 |
+
* @since 1.1.0
|
354 |
*/
|
355 |
+
public function inject_footer(){
|
356 |
+
$placements = get_option( 'advads-ads-placements', array() );
|
357 |
+
foreach ( $placements as $_placement_id => $_placement ){
|
358 |
+
if ( isset($_placement['type']) && 'footer' == $_placement['type'] ){
|
359 |
+
echo Advads_Ad_Placements::output( $_placement_id );
|
360 |
+
}
|
361 |
+
}
|
362 |
}
|
363 |
|
364 |
/**
|
365 |
+
* injected ad into content (before and after)
|
366 |
+
* displays ALL ads
|
367 |
*
|
368 |
+
* @since 1.1.0
|
369 |
+
* @param str $content post content
|
370 |
*/
|
371 |
+
public function inject_content($content = ''){
|
372 |
+
// run only on single pages of public post types
|
373 |
+
$public_post_types = get_post_types( array( 'public' => true, 'publicly_queryable' => true ), 'names', 'or' );
|
374 |
+
|
375 |
+
if ( ! is_singular( $public_post_types ) ) { return $content; }
|
376 |
+
|
377 |
+
$placements = get_option( 'advads-ads-placements', array() );
|
378 |
+
foreach ( $placements as $_placement_id => $_placement ){
|
379 |
+
if ( empty($_placement['item']) || ! isset($_placement['type']) ) { continue; }
|
380 |
+
|
381 |
+
switch ( $_placement['type'] ) {
|
382 |
+
case 'post_top':
|
383 |
+
$content = Advads_Ad_Placements::output( $_placement_id ) . $content;
|
384 |
+
break;
|
385 |
+
case 'post_bottom':
|
386 |
+
$content .= Advads_Ad_Placements::output( $_placement_id );
|
387 |
+
break;
|
388 |
+
case 'post_content':
|
389 |
+
$content = Advads_Ad_Placements::inject_in_content( $_placement_id, $_placement['options'], $content );
|
390 |
+
break;
|
391 |
+
}
|
392 |
+
}
|
393 |
|
394 |
+
return $content;
|
|
|
395 |
}
|
396 |
|
397 |
/**
|
398 |
+
* load all ads based on WP_Query conditions
|
399 |
*
|
400 |
+
* @deprecated 1.4.8 use model class
|
401 |
+
* @since 1.1.0
|
402 |
+
* @param arr $args WP_Query arguments that are more specific that default
|
403 |
+
* @return arr $ads array with post objects
|
404 |
*/
|
405 |
+
static function get_ads($args = array()){
|
406 |
+
return self::get_instance()->get_model()->get_ads($args);
|
407 |
}
|
408 |
|
409 |
/**
|
410 |
+
* load all ad groups
|
411 |
*
|
412 |
+
* @deprecated 1.4.8 use model class
|
413 |
+
* @since 1.1.0
|
414 |
+
* @param arr $args array with options
|
415 |
+
* @return arr $groups array with ad groups
|
416 |
+
* @link http://codex.wordpress.org/Function_Reference/get_terms
|
417 |
*/
|
418 |
+
static function get_ad_groups($args = array()){
|
419 |
+
return self::get_instance()->get_model()->get_ad_groups($args);
|
|
|
|
|
|
|
|
|
420 |
}
|
421 |
|
422 |
/**
|
423 |
+
* get the array with ad placements
|
|
|
|
|
|
|
|
|
|
|
424 |
*
|
425 |
+
* @since 1.1.0
|
426 |
+
* @deprecated 1.4.8 use model
|
427 |
+
* @return arr $ad_placements
|
428 |
*/
|
429 |
+
static public function get_ad_placements_array(){
|
430 |
+
return self::get_instance()->get_model()->get_ad_placements_array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
}
|
432 |
|
433 |
/**
|
|
|
|
|
|
|
434 |
*
|
435 |
+
* @deprecated 1.4.8 use model
|
436 |
+
* @return array
|
437 |
*/
|
438 |
+
public static function get_ad_conditions() {
|
439 |
+
return self::get_instance()->get_model()->get_ad_conditions();
|
|
|
|
|
440 |
}
|
441 |
|
442 |
/**
|
443 |
+
* general check if ads can be displayed for the whole page impression
|
|
|
444 |
*
|
445 |
+
* @since 1.4.9
|
446 |
+
* @return bool true, if ads can be displayed
|
447 |
+
* @todo move this to set_disabled_constant()
|
448 |
*/
|
449 |
+
public function can_display_ads(){
|
450 |
|
451 |
+
// check global constant if ads are enabled or disabled
|
452 |
+
if ( defined( 'ADVADS_ADS_DISABLED' ) ) {
|
453 |
+
return false;
|
|
|
454 |
}
|
455 |
|
456 |
+
$options = $this->options();
|
457 |
+
$see_ads_capability = isset($options['hide-for-user-role']) && $options['hide-for-user-role'] != '' ? $options['hide-for-user-role'] : false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
|
459 |
+
// check if user is logged in and if so if users with his rights can see ads
|
460 |
+
if ( $see_ads_capability && is_user_logged_in() && current_user_can( $see_ads_capability ) ) {
|
461 |
+
return false;
|
|
|
462 |
}
|
463 |
|
464 |
+
// check bots if option is enabled
|
465 |
+
if( isset($options['block-bots']) && $options['block-bots'] && $this->is_bot() ) {
|
466 |
+
return false;
|
467 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
|
469 |
+
return true;
|
|
|
470 |
}
|
471 |
|
472 |
/**
|
473 |
+
* check if the current user agent is given or a bot
|
474 |
*
|
475 |
+
* @since 1.4.9
|
476 |
+
* @return bool true if the current user agent is empty or a bot
|
477 |
*/
|
478 |
+
public function is_bot(){
|
479 |
+
$bots = apply_filters('advanced-ads-bots', $this->bots);
|
480 |
+
$bots = implode('|', $bots);
|
481 |
+
$bots = preg_replace('@[^-_;/|\][ a-z0-9]@i', '', $bots);
|
482 |
+
$regex = "@$bots@i";
|
483 |
|
484 |
+
if(isset($_SERVER['HTTP_USER_AGENT'])) {
|
485 |
+
$agent = $_SERVER['HTTP_USER_AGENT'];
|
|
|
486 |
|
487 |
+
return preg_match($regex, $agent) === 1;
|
488 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
|
490 |
+
return true;
|
|
|
491 |
}
|
492 |
|
493 |
/**
|
496 |
* @since 1.0.0
|
497 |
*/
|
498 |
public function create_post_types() {
|
499 |
+
if ( 1 !== did_action( 'init' ) ) {
|
500 |
return;
|
501 |
}
|
502 |
|
503 |
// register ad group taxonomy
|
504 |
+
if ( ! taxonomy_exists( Advanced_Ads::AD_GROUP_TAXONOMY ) ){
|
505 |
$post_type_params = $this->get_group_taxonomy_params();
|
506 |
+
register_taxonomy( Advanced_Ads::AD_GROUP_TAXONOMY, array( Advanced_Ads::POST_TYPE_SLUG ), $post_type_params );
|
507 |
}
|
508 |
|
509 |
// register ad post type
|
510 |
+
if ( ! post_type_exists( Advanced_Ads::POST_TYPE_SLUG ) ) {
|
511 |
$post_type_params = $this->get_post_type_params();
|
512 |
+
register_post_type( Advanced_Ads::POST_TYPE_SLUG, $post_type_params );
|
513 |
}
|
514 |
}
|
515 |
|
574 |
|
575 |
$post_type_params = array(
|
576 |
'labels' => $labels,
|
|
|
577 |
'public' => false,
|
578 |
'show_ui' => true,
|
579 |
'show_in_menu' => false,
|
580 |
'hierarchical' => false,
|
581 |
'capability_type' => 'page',
|
582 |
'has_archive' => false,
|
583 |
+
'rewrite' => array( 'slug' => ADVADS_SLUG ),
|
584 |
'query_var' => true,
|
585 |
+
'supports' => array( 'title' ),
|
586 |
+
'taxonomies' => array( Advanced_Ads::AD_GROUP_TAXONOMY )
|
587 |
);
|
588 |
|
589 |
return apply_filters( 'advanced-ads-post-type-params', $post_type_params );
|
590 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: webzunft
|
|
3 |
Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RRRCEBGN3UT2
|
4 |
Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
|
5 |
Requires at least: WP 3.5, PHP 5.3
|
6 |
-
Tested up to: 4.2
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -174,6 +174,21 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
|
|
174 |
|
175 |
== Changelog ==
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
= 1.4.9 =
|
178 |
|
179 |
* added option to hide ads from crawlers and other bots (option is disabled by default)
|
@@ -254,127 +269,6 @@ Need ad analytics and impression tracking? Try the [tracking add-on](http://wpad
|
|
254 |
* load pro module, if exists
|
255 |
* updated German translation
|
256 |
|
257 |
-
= 1.3.18 =
|
258 |
-
|
259 |
-
* removed wrapper for header injection placement
|
260 |
-
* removed deprecated code used for ad based content injections
|
261 |
-
* ordered ads by title in ads list
|
262 |
-
* removed broken pagination from ad groups list. now, all ad groups are displayed
|
263 |
-
* order ad groups by name when no other order is specified
|
264 |
-
* fixed search for ad groups in ad groups list
|
265 |
-
* PHP is not automatically allowed for new plain text ad codes anymore
|
266 |
-
* add an internal description and notes to your ads
|
267 |
-
|
268 |
-
= 1.3.17 =
|
269 |
-
|
270 |
-
* allow ad injection in all public post types now
|
271 |
-
* added Portuguese translation, props to [brunobarros](https://wordpress.org/support/profile/brunobarros)
|
272 |
-
* added advanced js file into repository
|
273 |
-
|
274 |
-
= 1.3.16 =
|
275 |
-
|
276 |
-
* fixed minor issue in admin js
|
277 |
-
* fixed expiry date showing up on other post types too
|
278 |
-
|
279 |
-
= 1.3.15 =
|
280 |
-
|
281 |
-
* COOL: added expiry date for ads, see the [manual](http://wpadvancedads.com/advancedads/manual/start-expiry-date/)
|
282 |
-
* removed limit on ads loaded for one group, props to [brunobarros](https://wordpress.org/support/topic/bug-without-posts_per_page)
|
283 |
-
* updated German translation
|
284 |
-
|
285 |
-
= 1.3.14 =
|
286 |
-
|
287 |
-
* fixed ad wrapper class for [Advanced Ads Layer add-on](http://wpadvancedads.com/layer-ads/)
|
288 |
-
|
289 |
-
= 1.3.13 =
|
290 |
-
|
291 |
-
* fixed ad wrapper options disappearing for placements
|
292 |
-
|
293 |
-
= 1.3.12 =
|
294 |
-
|
295 |
-
* limited number of terms on ad edit screen to 200, introduced _advanced-ads-admin-max-terms_ filter
|
296 |
-
* wrapped placement ads in a container with a unique id and a class to target them with css and js
|
297 |
-
* added dashboard widget with plugin version and news about ad optimization
|
298 |
-
|
299 |
-
Good to know: [What you didn’t know about the AdSense Program Policies](http://webgilde.com/en/adsense-program-policies/).
|
300 |
-
|
301 |
-
= 1.3.11 =
|
302 |
-
|
303 |
-
* COOL: disable ads completely, on 404 pages or for non-singular pages with a single click
|
304 |
-
* renamed hooks starting with _advads_ to _advanced-ads_ for better names consistency
|
305 |
-
* ordered ads by ad title not by date in placement and widget ad select list
|
306 |
-
|
307 |
-
Good to know: AdSense does not allow ads on 404 pages, so if you use AdSense a lot, be sure to check this new option on your settings page.
|
308 |
-
|
309 |
-
= 1.3.10 =
|
310 |
-
|
311 |
-
* COOL: disable all ads on individual single pages
|
312 |
-
* fixed saving some ad conditions to global array
|
313 |
-
* fixed minor issue with empty ad condition
|
314 |
-
* updated translation files
|
315 |
-
* updated German translation
|
316 |
-
|
317 |
-
Developers might want to take a look at the [Codex](http://wpadvancedads.com/advancedads/codex/). I am currently updating the cool stuff in there.
|
318 |
-
|
319 |
-
= 1.3.9 =
|
320 |
-
|
321 |
-
* disabled empty css file in frontend
|
322 |
-
* removed older changelog from readme
|
323 |
-
* fixed saving new ad conditions type "other" into global array
|
324 |
-
|
325 |
-
= 1.3.8 =
|
326 |
-
|
327 |
-
* fixed empty content placements still being parsed
|
328 |
-
* fixed missing or double tags created by content placements
|
329 |
-
|
330 |
-
= 1.3.7 =
|
331 |
-
|
332 |
-
* fixed bug with display conditions not working for custom post types and taxonomies
|
333 |
-
* minor fix in ad injection
|
334 |
-
|
335 |
-
= 1.3.6 =
|
336 |
-
|
337 |
-
* COOL: inject ads into content before or after specific paragraphs or headlines
|
338 |
-
* Updated translation files, German translation
|
339 |
-
|
340 |
-
= 1.3.5 =
|
341 |
-
|
342 |
-
* hotfix: fix the use of shortcodes within ads
|
343 |
-
|
344 |
-
= 1.3.4 =
|
345 |
-
|
346 |
-
* hotfix: display ads for placements when no ad group exists
|
347 |
-
|
348 |
-
= 1.3.3 =
|
349 |
-
|
350 |
-
* added column with ad details
|
351 |
-
* removed the date column from ad list
|
352 |
-
* fixed saving and retrieving of settings
|
353 |
-
* changed the dashboard icon
|
354 |
-
* renamed admin images so they won’t get blocked by ad blockers
|
355 |
-
|
356 |
-
* ACTION REQUIRED: please check and resave settings (_Advanced Ads > Settings_)
|
357 |
-
|
358 |
-
= 1.3.2 =
|
359 |
-
|
360 |
-
* hotfix: prevent infinite loops (ads within ads…) for rich content ads
|
361 |
-
|
362 |
-
= 1.3.1 =
|
363 |
-
|
364 |
-
* COOL: new ad type: rich media and formatable content – it’s like editing a normal post
|
365 |
-
* parse ad content as post content; this allows the use of shortcodes
|
366 |
-
* increased priority of content filter to reduce the risk of `wpautop` not being run yet
|
367 |
-
* finished German translation
|
368 |
-
|
369 |
-
= 1.3 =
|
370 |
-
|
371 |
-
* COOL: layout options for ads, e.g. to set floating and margins (see the [manual](http://wpadvancedads.com/advancedads/manual/optimizing-the-ad-layout/))
|
372 |
-
* list ad groups before ads when selecting them for a placement
|
373 |
-
* fixed error when removing an ad that is still in a group
|
374 |
-
* fixed possible translation issue
|
375 |
-
* added partial German translation
|
376 |
-
* added Italien translation (thanks to sangkavr)
|
377 |
-
|
378 |
[Changelog Archive](http://wpadvancedads.com/advancedads/codex/changelog-archive/)
|
379 |
|
380 |
== Upgrade Notice ==
|
3 |
Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RRRCEBGN3UT2
|
4 |
Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
|
5 |
Requires at least: WP 3.5, PHP 5.3
|
6 |
+
Tested up to: 4.2
|
7 |
+
Stable tag: 1.5.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
174 |
|
175 |
== Changelog ==
|
176 |
|
177 |
+
= 1.5.0 =
|
178 |
+
|
179 |
+
* major changes in the code base to support upcoming features
|
180 |
+
* PLEASE TEST and report any bugs
|
181 |
+
|
182 |
+
* further interface cleanup
|
183 |
+
* fully implemented autoloading
|
184 |
+
* added composer definitions
|
185 |
+
* hook modules deep into ad selection and display
|
186 |
+
* autoload modules (for base plugin and add-ons)
|
187 |
+
* added `advanced-ads-ad-select-args` filter to modify ad selection arguments
|
188 |
+
* added `advanced-ads-ad-select-methods` filter to append or override ad code selection methods
|
189 |
+
* standardise and autoload modules
|
190 |
+
* add AJAX handler
|
191 |
+
|
192 |
= 1.4.9 =
|
193 |
|
194 |
* added option to hide ads from crawlers and other bots (option is disabled by default)
|
269 |
* load pro module, if exists
|
270 |
* updated German translation
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
[Changelog Archive](http://wpadvancedads.com/advancedads/codex/changelog-archive/)
|
273 |
|
274 |
== Upgrade Notice ==
|
vendor/autoload.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload.php @generated by Composer
|
4 |
+
|
5 |
+
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
+
|
7 |
+
return ComposerAutoloaderInitd24de3c06687d3cf4aad0b15c83747be::getLoader();
|
vendor/autoload_52.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_52.php generated by xrstf/composer-php52
|
4 |
+
|
5 |
+
require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
|
6 |
+
|
7 |
+
return ComposerAutoloaderInit6da0d23f97720fc3d9b3fe2d5b2527cb::getLoader();
|
vendor/composer/ClassLoader.php
ADDED
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of Composer.
|
5 |
+
*
|
6 |
+
* (c) Nils Adermann <naderman@naderman.de>
|
7 |
+
* Jordi Boggiano <j.boggiano@seld.be>
|
8 |
+
*
|
9 |
+
* For the full copyright and license information, please view the LICENSE
|
10 |
+
* file that was distributed with this source code.
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Composer\Autoload;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* ClassLoader implements a PSR-0 class loader
|
17 |
+
*
|
18 |
+
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
19 |
+
*
|
20 |
+
* $loader = new \Composer\Autoload\ClassLoader();
|
21 |
+
*
|
22 |
+
* // register classes with namespaces
|
23 |
+
* $loader->add('Symfony\Component', __DIR__.'/component');
|
24 |
+
* $loader->add('Symfony', __DIR__.'/framework');
|
25 |
+
*
|
26 |
+
* // activate the autoloader
|
27 |
+
* $loader->register();
|
28 |
+
*
|
29 |
+
* // to enable searching the include path (eg. for PEAR packages)
|
30 |
+
* $loader->setUseIncludePath(true);
|
31 |
+
*
|
32 |
+
* In this example, if you try to use a class in the Symfony\Component
|
33 |
+
* namespace or one of its children (Symfony\Component\Console for instance),
|
34 |
+
* the autoloader will first look for the class under the component/
|
35 |
+
* directory, and it will then fallback to the framework/ directory if not
|
36 |
+
* found before giving up.
|
37 |
+
*
|
38 |
+
* This class is loosely based on the Symfony UniversalClassLoader.
|
39 |
+
*
|
40 |
+
* @author Fabien Potencier <fabien@symfony.com>
|
41 |
+
* @author Jordi Boggiano <j.boggiano@seld.be>
|
42 |
+
*/
|
43 |
+
class ClassLoader
|
44 |
+
{
|
45 |
+
// PSR-4
|
46 |
+
private $prefixLengthsPsr4 = array();
|
47 |
+
private $prefixDirsPsr4 = array();
|
48 |
+
private $fallbackDirsPsr4 = array();
|
49 |
+
|
50 |
+
// PSR-0
|
51 |
+
private $prefixesPsr0 = array();
|
52 |
+
private $fallbackDirsPsr0 = array();
|
53 |
+
|
54 |
+
private $useIncludePath = false;
|
55 |
+
private $classMap = array();
|
56 |
+
|
57 |
+
private $classMapAuthoritative = false;
|
58 |
+
|
59 |
+
public function getPrefixes()
|
60 |
+
{
|
61 |
+
if (!empty($this->prefixesPsr0)) {
|
62 |
+
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
63 |
+
}
|
64 |
+
|
65 |
+
return array();
|
66 |
+
}
|
67 |
+
|
68 |
+
public function getPrefixesPsr4()
|
69 |
+
{
|
70 |
+
return $this->prefixDirsPsr4;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function getFallbackDirs()
|
74 |
+
{
|
75 |
+
return $this->fallbackDirsPsr0;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getFallbackDirsPsr4()
|
79 |
+
{
|
80 |
+
return $this->fallbackDirsPsr4;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getClassMap()
|
84 |
+
{
|
85 |
+
return $this->classMap;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @param array $classMap Class to filename map
|
90 |
+
*/
|
91 |
+
public function addClassMap(array $classMap)
|
92 |
+
{
|
93 |
+
if ($this->classMap) {
|
94 |
+
$this->classMap = array_merge($this->classMap, $classMap);
|
95 |
+
} else {
|
96 |
+
$this->classMap = $classMap;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Registers a set of PSR-0 directories for a given prefix, either
|
102 |
+
* appending or prepending to the ones previously set for this prefix.
|
103 |
+
*
|
104 |
+
* @param string $prefix The prefix
|
105 |
+
* @param array|string $paths The PSR-0 root directories
|
106 |
+
* @param bool $prepend Whether to prepend the directories
|
107 |
+
*/
|
108 |
+
public function add($prefix, $paths, $prepend = false)
|
109 |
+
{
|
110 |
+
if (!$prefix) {
|
111 |
+
if ($prepend) {
|
112 |
+
$this->fallbackDirsPsr0 = array_merge(
|
113 |
+
(array) $paths,
|
114 |
+
$this->fallbackDirsPsr0
|
115 |
+
);
|
116 |
+
} else {
|
117 |
+
$this->fallbackDirsPsr0 = array_merge(
|
118 |
+
$this->fallbackDirsPsr0,
|
119 |
+
(array) $paths
|
120 |
+
);
|
121 |
+
}
|
122 |
+
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
$first = $prefix[0];
|
127 |
+
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
128 |
+
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
129 |
+
|
130 |
+
return;
|
131 |
+
}
|
132 |
+
if ($prepend) {
|
133 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
134 |
+
(array) $paths,
|
135 |
+
$this->prefixesPsr0[$first][$prefix]
|
136 |
+
);
|
137 |
+
} else {
|
138 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
139 |
+
$this->prefixesPsr0[$first][$prefix],
|
140 |
+
(array) $paths
|
141 |
+
);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Registers a set of PSR-4 directories for a given namespace, either
|
147 |
+
* appending or prepending to the ones previously set for this namespace.
|
148 |
+
*
|
149 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
150 |
+
* @param array|string $paths The PSR-0 base directories
|
151 |
+
* @param bool $prepend Whether to prepend the directories
|
152 |
+
*
|
153 |
+
* @throws \InvalidArgumentException
|
154 |
+
*/
|
155 |
+
public function addPsr4($prefix, $paths, $prepend = false)
|
156 |
+
{
|
157 |
+
if (!$prefix) {
|
158 |
+
// Register directories for the root namespace.
|
159 |
+
if ($prepend) {
|
160 |
+
$this->fallbackDirsPsr4 = array_merge(
|
161 |
+
(array) $paths,
|
162 |
+
$this->fallbackDirsPsr4
|
163 |
+
);
|
164 |
+
} else {
|
165 |
+
$this->fallbackDirsPsr4 = array_merge(
|
166 |
+
$this->fallbackDirsPsr4,
|
167 |
+
(array) $paths
|
168 |
+
);
|
169 |
+
}
|
170 |
+
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
171 |
+
// Register directories for a new namespace.
|
172 |
+
$length = strlen($prefix);
|
173 |
+
if ('\\' !== $prefix[$length - 1]) {
|
174 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
175 |
+
}
|
176 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
177 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
178 |
+
} elseif ($prepend) {
|
179 |
+
// Prepend directories for an already registered namespace.
|
180 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
181 |
+
(array) $paths,
|
182 |
+
$this->prefixDirsPsr4[$prefix]
|
183 |
+
);
|
184 |
+
} else {
|
185 |
+
// Append directories for an already registered namespace.
|
186 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
187 |
+
$this->prefixDirsPsr4[$prefix],
|
188 |
+
(array) $paths
|
189 |
+
);
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Registers a set of PSR-0 directories for a given prefix,
|
195 |
+
* replacing any others previously set for this prefix.
|
196 |
+
*
|
197 |
+
* @param string $prefix The prefix
|
198 |
+
* @param array|string $paths The PSR-0 base directories
|
199 |
+
*/
|
200 |
+
public function set($prefix, $paths)
|
201 |
+
{
|
202 |
+
if (!$prefix) {
|
203 |
+
$this->fallbackDirsPsr0 = (array) $paths;
|
204 |
+
} else {
|
205 |
+
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Registers a set of PSR-4 directories for a given namespace,
|
211 |
+
* replacing any others previously set for this namespace.
|
212 |
+
*
|
213 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
214 |
+
* @param array|string $paths The PSR-4 base directories
|
215 |
+
*
|
216 |
+
* @throws \InvalidArgumentException
|
217 |
+
*/
|
218 |
+
public function setPsr4($prefix, $paths)
|
219 |
+
{
|
220 |
+
if (!$prefix) {
|
221 |
+
$this->fallbackDirsPsr4 = (array) $paths;
|
222 |
+
} else {
|
223 |
+
$length = strlen($prefix);
|
224 |
+
if ('\\' !== $prefix[$length - 1]) {
|
225 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
226 |
+
}
|
227 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
228 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Turns on searching the include path for class files.
|
234 |
+
*
|
235 |
+
* @param bool $useIncludePath
|
236 |
+
*/
|
237 |
+
public function setUseIncludePath($useIncludePath)
|
238 |
+
{
|
239 |
+
$this->useIncludePath = $useIncludePath;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Can be used to check if the autoloader uses the include path to check
|
244 |
+
* for classes.
|
245 |
+
*
|
246 |
+
* @return bool
|
247 |
+
*/
|
248 |
+
public function getUseIncludePath()
|
249 |
+
{
|
250 |
+
return $this->useIncludePath;
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Turns off searching the prefix and fallback directories for classes
|
255 |
+
* that have not been registered with the class map.
|
256 |
+
*
|
257 |
+
* @param bool $classMapAuthoritative
|
258 |
+
*/
|
259 |
+
public function setClassMapAuthoritative($classMapAuthoritative)
|
260 |
+
{
|
261 |
+
$this->classMapAuthoritative = $classMapAuthoritative;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Should class lookup fail if not found in the current class map?
|
266 |
+
*
|
267 |
+
* @return bool
|
268 |
+
*/
|
269 |
+
public function isClassMapAuthoritative()
|
270 |
+
{
|
271 |
+
return $this->classMapAuthoritative;
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Registers this instance as an autoloader.
|
276 |
+
*
|
277 |
+
* @param bool $prepend Whether to prepend the autoloader or not
|
278 |
+
*/
|
279 |
+
public function register($prepend = false)
|
280 |
+
{
|
281 |
+
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Unregisters this instance as an autoloader.
|
286 |
+
*/
|
287 |
+
public function unregister()
|
288 |
+
{
|
289 |
+
spl_autoload_unregister(array($this, 'loadClass'));
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Loads the given class or interface.
|
294 |
+
*
|
295 |
+
* @param string $class The name of the class
|
296 |
+
* @return bool|null True if loaded, null otherwise
|
297 |
+
*/
|
298 |
+
public function loadClass($class)
|
299 |
+
{
|
300 |
+
if ($file = $this->findFile($class)) {
|
301 |
+
includeFile($file);
|
302 |
+
|
303 |
+
return true;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Finds the path to the file where the class is defined.
|
309 |
+
*
|
310 |
+
* @param string $class The name of the class
|
311 |
+
*
|
312 |
+
* @return string|false The path if found, false otherwise
|
313 |
+
*/
|
314 |
+
public function findFile($class)
|
315 |
+
{
|
316 |
+
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
317 |
+
if ('\\' == $class[0]) {
|
318 |
+
$class = substr($class, 1);
|
319 |
+
}
|
320 |
+
|
321 |
+
// class map lookup
|
322 |
+
if (isset($this->classMap[$class])) {
|
323 |
+
return $this->classMap[$class];
|
324 |
+
}
|
325 |
+
if ($this->classMapAuthoritative) {
|
326 |
+
return false;
|
327 |
+
}
|
328 |
+
|
329 |
+
$file = $this->findFileWithExtension($class, '.php');
|
330 |
+
|
331 |
+
// Search for Hack files if we are running on HHVM
|
332 |
+
if ($file === null && defined('HHVM_VERSION')) {
|
333 |
+
$file = $this->findFileWithExtension($class, '.hh');
|
334 |
+
}
|
335 |
+
|
336 |
+
if ($file === null) {
|
337 |
+
// Remember that this class does not exist.
|
338 |
+
return $this->classMap[$class] = false;
|
339 |
+
}
|
340 |
+
|
341 |
+
return $file;
|
342 |
+
}
|
343 |
+
|
344 |
+
private function findFileWithExtension($class, $ext)
|
345 |
+
{
|
346 |
+
// PSR-4 lookup
|
347 |
+
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
348 |
+
|
349 |
+
$first = $class[0];
|
350 |
+
if (isset($this->prefixLengthsPsr4[$first])) {
|
351 |
+
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
352 |
+
if (0 === strpos($class, $prefix)) {
|
353 |
+
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
354 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
355 |
+
return $file;
|
356 |
+
}
|
357 |
+
}
|
358 |
+
}
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
// PSR-4 fallback dirs
|
363 |
+
foreach ($this->fallbackDirsPsr4 as $dir) {
|
364 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
365 |
+
return $file;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
// PSR-0 lookup
|
370 |
+
if (false !== $pos = strrpos($class, '\\')) {
|
371 |
+
// namespaced class name
|
372 |
+
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
373 |
+
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
374 |
+
} else {
|
375 |
+
// PEAR-like class name
|
376 |
+
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
377 |
+
}
|
378 |
+
|
379 |
+
if (isset($this->prefixesPsr0[$first])) {
|
380 |
+
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
381 |
+
if (0 === strpos($class, $prefix)) {
|
382 |
+
foreach ($dirs as $dir) {
|
383 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
384 |
+
return $file;
|
385 |
+
}
|
386 |
+
}
|
387 |
+
}
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
// PSR-0 fallback dirs
|
392 |
+
foreach ($this->fallbackDirsPsr0 as $dir) {
|
393 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
394 |
+
return $file;
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
// PSR-0 include paths.
|
399 |
+
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
400 |
+
return $file;
|
401 |
+
}
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Scope isolated include.
|
407 |
+
*
|
408 |
+
* Prevents access to $this/self from included files.
|
409 |
+
*/
|
410 |
+
function includeFile($file)
|
411 |
+
{
|
412 |
+
include $file;
|
413 |
+
}
|
vendor/composer/ClassLoader52.php
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de
|
4 |
+
*
|
5 |
+
* This file is released under the terms of the MIT license. You can find the
|
6 |
+
* complete text in the attached LICENSE file or online at:
|
7 |
+
*
|
8 |
+
* http://www.opensource.org/licenses/mit-license.php
|
9 |
+
*
|
10 |
+
* --------------------------------------------------------------------------
|
11 |
+
*
|
12 |
+
* 99% of this is copied as-is from the original Composer source code and is
|
13 |
+
* released under MIT license as well. Copyright goes to:
|
14 |
+
*
|
15 |
+
* - Fabien Potencier <fabien@symfony.com>
|
16 |
+
* - Jordi Boggiano <j.boggiano@seld.be>
|
17 |
+
*/
|
18 |
+
|
19 |
+
class xrstf_Composer52_ClassLoader {
|
20 |
+
private $prefixes = array();
|
21 |
+
private $fallbackDirs = array();
|
22 |
+
private $useIncludePath = false;
|
23 |
+
private $classMap = array();
|
24 |
+
private $classMapAuthoratative = false;
|
25 |
+
private $allowUnderscore = false;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @param boolean $flag true to allow class names with a leading underscore, false to disable
|
29 |
+
*/
|
30 |
+
public function setAllowUnderscore($flag) {
|
31 |
+
$this->allowUnderscore = (boolean) $flag;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function getPrefixes() {
|
38 |
+
return $this->prefixes;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Turns off searching the prefix and fallback directories for classes
|
43 |
+
* that have not been registered with the class map.
|
44 |
+
*
|
45 |
+
* @param bool $classMapAuthoratative
|
46 |
+
*/
|
47 |
+
public function setClassMapAuthoritative($classMapAuthoratative) {
|
48 |
+
$this->classMapAuthoratative = $classMapAuthoratative;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Should class lookup fail if not found in the current class map?
|
53 |
+
*
|
54 |
+
* @return bool
|
55 |
+
*/
|
56 |
+
public function getClassMapAuthoratative() {
|
57 |
+
return $this->classMapAuthoratative;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function getFallbackDirs() {
|
64 |
+
return $this->fallbackDirs;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @return array
|
69 |
+
*/
|
70 |
+
public function getClassMap() {
|
71 |
+
return $this->classMap;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @param array $classMap class to filename map
|
76 |
+
*/
|
77 |
+
public function addClassMap(array $classMap) {
|
78 |
+
if ($this->classMap) {
|
79 |
+
$this->classMap = array_merge($this->classMap, $classMap);
|
80 |
+
}
|
81 |
+
else {
|
82 |
+
$this->classMap = $classMap;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Registers a set of classes, merging with any others previously set.
|
88 |
+
*
|
89 |
+
* @param string $prefix the classes prefix
|
90 |
+
* @param array|string $paths the location(s) of the classes
|
91 |
+
* @param bool $prepend prepend the location(s)
|
92 |
+
*/
|
93 |
+
public function add($prefix, $paths, $prepend = false) {
|
94 |
+
if (!$prefix) {
|
95 |
+
if ($prepend) {
|
96 |
+
$this->fallbackDirs = array_merge(
|
97 |
+
(array) $paths,
|
98 |
+
$this->fallbackDirs
|
99 |
+
);
|
100 |
+
}
|
101 |
+
else {
|
102 |
+
$this->fallbackDirs = array_merge(
|
103 |
+
$this->fallbackDirs,
|
104 |
+
(array) $paths
|
105 |
+
);
|
106 |
+
}
|
107 |
+
|
108 |
+
return;
|
109 |
+
}
|
110 |
+
|
111 |
+
if (!isset($this->prefixes[$prefix])) {
|
112 |
+
$this->prefixes[$prefix] = (array) $paths;
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
|
116 |
+
if ($prepend) {
|
117 |
+
$this->prefixes[$prefix] = array_merge(
|
118 |
+
(array) $paths,
|
119 |
+
$this->prefixes[$prefix]
|
120 |
+
);
|
121 |
+
}
|
122 |
+
else {
|
123 |
+
$this->prefixes[$prefix] = array_merge(
|
124 |
+
$this->prefixes[$prefix],
|
125 |
+
(array) $paths
|
126 |
+
);
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Registers a set of classes, replacing any others previously set.
|
132 |
+
*
|
133 |
+
* @param string $prefix the classes prefix
|
134 |
+
* @param array|string $paths the location(s) of the classes
|
135 |
+
*/
|
136 |
+
public function set($prefix, $paths) {
|
137 |
+
if (!$prefix) {
|
138 |
+
$this->fallbackDirs = (array) $paths;
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
$this->prefixes[$prefix] = (array) $paths;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Turns on searching the include path for class files.
|
147 |
+
*
|
148 |
+
* @param bool $useIncludePath
|
149 |
+
*/
|
150 |
+
public function setUseIncludePath($useIncludePath) {
|
151 |
+
$this->useIncludePath = $useIncludePath;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Can be used to check if the autoloader uses the include path to check
|
156 |
+
* for classes.
|
157 |
+
*
|
158 |
+
* @return bool
|
159 |
+
*/
|
160 |
+
public function getUseIncludePath() {
|
161 |
+
return $this->useIncludePath;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Registers this instance as an autoloader.
|
166 |
+
*/
|
167 |
+
public function register() {
|
168 |
+
spl_autoload_register(array($this, 'loadClass'), true);
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Unregisters this instance as an autoloader.
|
173 |
+
*/
|
174 |
+
public function unregister() {
|
175 |
+
spl_autoload_unregister(array($this, 'loadClass'));
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Loads the given class or interface.
|
180 |
+
*
|
181 |
+
* @param string $class the name of the class
|
182 |
+
* @return bool|null true, if loaded
|
183 |
+
*/
|
184 |
+
public function loadClass($class) {
|
185 |
+
if ($file = $this->findFile($class)) {
|
186 |
+
include $file;
|
187 |
+
return true;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Finds the path to the file where the class is defined.
|
193 |
+
*
|
194 |
+
* @param string $class the name of the class
|
195 |
+
* @return string|null the path, if found
|
196 |
+
*/
|
197 |
+
public function findFile($class) {
|
198 |
+
if ('\\' === $class[0]) {
|
199 |
+
$class = substr($class, 1);
|
200 |
+
}
|
201 |
+
|
202 |
+
if (isset($this->classMap[$class])) {
|
203 |
+
return $this->classMap[$class];
|
204 |
+
}
|
205 |
+
elseif ($this->classMapAuthoratative) {
|
206 |
+
return false;
|
207 |
+
}
|
208 |
+
|
209 |
+
$classPath = $this->getClassPath($class);
|
210 |
+
|
211 |
+
foreach ($this->prefixes as $prefix => $dirs) {
|
212 |
+
if (0 === strpos($class, $prefix)) {
|
213 |
+
foreach ($dirs as $dir) {
|
214 |
+
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
|
215 |
+
return $dir.DIRECTORY_SEPARATOR.$classPath;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
foreach ($this->fallbackDirs as $dir) {
|
222 |
+
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
|
223 |
+
return $dir.DIRECTORY_SEPARATOR.$classPath;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
if ($this->useIncludePath && $file = self::resolveIncludePath($classPath)) {
|
228 |
+
return $file;
|
229 |
+
}
|
230 |
+
|
231 |
+
return $this->classMap[$class] = false;
|
232 |
+
}
|
233 |
+
|
234 |
+
private function getClassPath($class) {
|
235 |
+
if (false !== $pos = strrpos($class, '\\')) {
|
236 |
+
// namespaced class name
|
237 |
+
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR;
|
238 |
+
$className = substr($class, $pos + 1);
|
239 |
+
}
|
240 |
+
else {
|
241 |
+
// PEAR-like class name
|
242 |
+
$classPath = null;
|
243 |
+
$className = $class;
|
244 |
+
}
|
245 |
+
|
246 |
+
$className = str_replace('_', DIRECTORY_SEPARATOR, $className);
|
247 |
+
|
248 |
+
// restore the prefix
|
249 |
+
if ($this->allowUnderscore && DIRECTORY_SEPARATOR === $className[0]) {
|
250 |
+
$className[0] = '_';
|
251 |
+
}
|
252 |
+
|
253 |
+
$classPath .= $className.'.php';
|
254 |
+
|
255 |
+
return $classPath;
|
256 |
+
}
|
257 |
+
|
258 |
+
public static function resolveIncludePath($classPath) {
|
259 |
+
$paths = explode(PATH_SEPARATOR, get_include_path());
|
260 |
+
|
261 |
+
foreach ($paths as $path) {
|
262 |
+
$path = rtrim($path, '/\\');
|
263 |
+
|
264 |
+
if ($file = file_exists($path.DIRECTORY_SEPARATOR.$file)) {
|
265 |
+
return $file;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
return false;
|
270 |
+
}
|
271 |
+
}
|
vendor/composer/autoload_classmap.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_classmap.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname($vendorDir);
|
7 |
+
|
8 |
+
return array(
|
9 |
+
'AdvAds_Admin_Notices' => $baseDir . '/admin/includes/class-notices.php',
|
10 |
+
'AdvAds_Display_Condition_Callbacks' => $baseDir . '/admin/includes/class-display-condition-callbacks.php',
|
11 |
+
'AdvAds_Groups_List' => $baseDir . '/admin/includes/class-ad-groups-list.php',
|
12 |
+
'AdvAds_List_Table' => $baseDir . '/admin/includes/class-list-table.php',
|
13 |
+
'AdvAds_Overview_Widgets_Callbacks' => $baseDir . '/admin/includes/class-overview-widgets.php',
|
14 |
+
'Advads_Ad' => $baseDir . '/classes/ad.php',
|
15 |
+
'Advads_Ad_Ajax_Callbacks' => $baseDir . '/classes/ad_ajax_callbacks.php',
|
16 |
+
'Advads_Ad_Group' => $baseDir . '/classes/ad_group.php',
|
17 |
+
'Advads_Ad_Placements' => $baseDir . '/classes/ad_placements.php',
|
18 |
+
'Advads_Ad_Type_Abstract' => $baseDir . '/classes/ad_type_abstract.php',
|
19 |
+
'Advads_Ad_Type_Content' => $baseDir . '/classes/ad_type_content.php',
|
20 |
+
'Advads_Ad_Type_Plain' => $baseDir . '/classes/ad_type_plain.php',
|
21 |
+
'Advads_Widget' => $baseDir . '/classes/widget.php',
|
22 |
+
'Advanced_Ads_Ajax' => $baseDir . '/classes/ad-ajax.php',
|
23 |
+
'Advanced_Ads_Model' => $baseDir . '/classes/ad-model.php',
|
24 |
+
'Advanced_Ads_Plugin' => $baseDir . '/classes/plugin.php',
|
25 |
+
'Advanced_Ads_Select' => $baseDir . '/classes/ad-select.php',
|
26 |
+
'Advanced_Ads' => $baseDir . '/public/class-advanced-ads.php',
|
27 |
+
'Advanced_Ads_Admin' => $baseDir . '/admin/class-advanced-ads-admin.php',
|
28 |
+
'Composer\\Installers\\AglInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AglInstaller.php',
|
29 |
+
'Composer\\Installers\\AimeosInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AimeosInstaller.php',
|
30 |
+
'Composer\\Installers\\AnnotateCmsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php',
|
31 |
+
'Composer\\Installers\\AsgardInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AsgardInstaller.php',
|
32 |
+
'Composer\\Installers\\BaseInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BaseInstaller.php',
|
33 |
+
'Composer\\Installers\\BitrixInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BitrixInstaller.php',
|
34 |
+
'Composer\\Installers\\CakePHPInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CakePHPInstaller.php',
|
35 |
+
'Composer\\Installers\\ChefInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ChefInstaller.php',
|
36 |
+
'Composer\\Installers\\ClanCatsFrameworkInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php',
|
37 |
+
'Composer\\Installers\\CodeIgniterInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php',
|
38 |
+
'Composer\\Installers\\Concrete5Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Concrete5Installer.php',
|
39 |
+
'Composer\\Installers\\CraftInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CraftInstaller.php',
|
40 |
+
'Composer\\Installers\\CroogoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CroogoInstaller.php',
|
41 |
+
'Composer\\Installers\\DokuWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DokuWikiInstaller.php',
|
42 |
+
'Composer\\Installers\\DolibarrInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DolibarrInstaller.php',
|
43 |
+
'Composer\\Installers\\DrupalInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DrupalInstaller.php',
|
44 |
+
'Composer\\Installers\\ElggInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ElggInstaller.php',
|
45 |
+
'Composer\\Installers\\FuelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/FuelInstaller.php',
|
46 |
+
'Composer\\Installers\\FuelphpInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/FuelphpInstaller.php',
|
47 |
+
'Composer\\Installers\\GravInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/GravInstaller.php',
|
48 |
+
'Composer\\Installers\\HuradInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/HuradInstaller.php',
|
49 |
+
'Composer\\Installers\\Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Installer.php',
|
50 |
+
'Composer\\Installers\\JoomlaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/JoomlaInstaller.php',
|
51 |
+
'Composer\\Installers\\KirbyInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KirbyInstaller.php',
|
52 |
+
'Composer\\Installers\\KohanaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KohanaInstaller.php',
|
53 |
+
'Composer\\Installers\\LaravelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LaravelInstaller.php',
|
54 |
+
'Composer\\Installers\\LithiumInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LithiumInstaller.php',
|
55 |
+
'Composer\\Installers\\MODULEWorkInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php',
|
56 |
+
'Composer\\Installers\\MODXEvoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MODXEvoInstaller.php',
|
57 |
+
'Composer\\Installers\\MagentoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MagentoInstaller.php',
|
58 |
+
'Composer\\Installers\\MakoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MakoInstaller.php',
|
59 |
+
'Composer\\Installers\\MediaWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MediaWikiInstaller.php',
|
60 |
+
'Composer\\Installers\\MicroweberInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MicroweberInstaller.php',
|
61 |
+
'Composer\\Installers\\MoodleInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MoodleInstaller.php',
|
62 |
+
'Composer\\Installers\\OctoberInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OctoberInstaller.php',
|
63 |
+
'Composer\\Installers\\OxidInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OxidInstaller.php',
|
64 |
+
'Composer\\Installers\\PPIInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PPIInstaller.php',
|
65 |
+
'Composer\\Installers\\PhpBBInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PhpBBInstaller.php',
|
66 |
+
'Composer\\Installers\\PimcoreInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PimcoreInstaller.php',
|
67 |
+
'Composer\\Installers\\PiwikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PiwikInstaller.php',
|
68 |
+
'Composer\\Installers\\PrestashopInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PrestashopInstaller.php',
|
69 |
+
'Composer\\Installers\\PuppetInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PuppetInstaller.php',
|
70 |
+
'Composer\\Installers\\RedaxoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RedaxoInstaller.php',
|
71 |
+
'Composer\\Installers\\RoundcubeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RoundcubeInstaller.php',
|
72 |
+
'Composer\\Installers\\SMFInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SMFInstaller.php',
|
73 |
+
'Composer\\Installers\\ShopwareInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ShopwareInstaller.php',
|
74 |
+
'Composer\\Installers\\SilverStripeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SilverStripeInstaller.php',
|
75 |
+
'Composer\\Installers\\Symfony1Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Symfony1Installer.php',
|
76 |
+
'Composer\\Installers\\TYPO3CmsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php',
|
77 |
+
'Composer\\Installers\\TYPO3FlowInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php',
|
78 |
+
'Composer\\Installers\\TheliaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TheliaInstaller.php',
|
79 |
+
'Composer\\Installers\\TuskInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TuskInstaller.php',
|
80 |
+
'Composer\\Installers\\WHMCSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WHMCSInstaller.php',
|
81 |
+
'Composer\\Installers\\WolfCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WolfCMSInstaller.php',
|
82 |
+
'Composer\\Installers\\WordPressInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WordPressInstaller.php',
|
83 |
+
'Composer\\Installers\\ZendInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZendInstaller.php',
|
84 |
+
'Composer\\Installers\\ZikulaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
|
85 |
+
'xrstf\\Composer52\\AutoloadGenerator' => $vendorDir . '/xrstf/composer-php52/lib/xrstf/Composer52/AutoloadGenerator.php',
|
86 |
+
'xrstf\\Composer52\\Generator' => $vendorDir . '/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php',
|
87 |
+
);
|
vendor/composer/autoload_namespaces.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_namespaces.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname($vendorDir);
|
7 |
+
|
8 |
+
return array(
|
9 |
+
'xrstf\\Composer52' => array($vendorDir . '/xrstf/composer-php52/lib'),
|
10 |
+
'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'),
|
11 |
+
);
|
vendor/composer/autoload_psr4.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_psr4.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname($vendorDir);
|
7 |
+
|
8 |
+
return array(
|
9 |
+
);
|
vendor/composer/autoload_real.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_real.php @generated by Composer
|
4 |
+
|
5 |
+
class ComposerAutoloaderInitd24de3c06687d3cf4aad0b15c83747be
|
6 |
+
{
|
7 |
+
private static $loader;
|
8 |
+
|
9 |
+
public static function loadClassLoader($class)
|
10 |
+
{
|
11 |
+
if ('Composer\Autoload\ClassLoader' === $class) {
|
12 |
+
require __DIR__ . '/ClassLoader.php';
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
public static function getLoader()
|
17 |
+
{
|
18 |
+
if (null !== self::$loader) {
|
19 |
+
return self::$loader;
|
20 |
+
}
|
21 |
+
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitd24de3c06687d3cf4aad0b15c83747be', 'loadClassLoader'), true, true);
|
23 |
+
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitd24de3c06687d3cf4aad0b15c83747be', 'loadClassLoader'));
|
25 |
+
|
26 |
+
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
+
foreach ($map as $namespace => $path) {
|
28 |
+
$loader->set($namespace, $path);
|
29 |
+
}
|
30 |
+
|
31 |
+
$map = require __DIR__ . '/autoload_psr4.php';
|
32 |
+
foreach ($map as $namespace => $path) {
|
33 |
+
$loader->setPsr4($namespace, $path);
|
34 |
+
}
|
35 |
+
|
36 |
+
$classMap = require __DIR__ . '/autoload_classmap.php';
|
37 |
+
if ($classMap) {
|
38 |
+
$loader->addClassMap($classMap);
|
39 |
+
}
|
40 |
+
|
41 |
+
$loader->register(true);
|
42 |
+
|
43 |
+
return $loader;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
function composerRequired24de3c06687d3cf4aad0b15c83747be($file)
|
48 |
+
{
|
49 |
+
require $file;
|
50 |
+
}
|
vendor/composer/autoload_real_52.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_real_52.php generated by xrstf/composer-php52
|
4 |
+
|
5 |
+
class ComposerAutoloaderInit6da0d23f97720fc3d9b3fe2d5b2527cb {
|
6 |
+
private static $loader;
|
7 |
+
|
8 |
+
public static function loadClassLoader($class) {
|
9 |
+
if ('xrstf_Composer52_ClassLoader' === $class) {
|
10 |
+
require dirname(__FILE__).'/ClassLoader52.php';
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return xrstf_Composer52_ClassLoader
|
16 |
+
*/
|
17 |
+
public static function getLoader() {
|
18 |
+
if (null !== self::$loader) {
|
19 |
+
return self::$loader;
|
20 |
+
}
|
21 |
+
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit6da0d23f97720fc3d9b3fe2d5b2527cb', 'loadClassLoader'), true /*, true */);
|
23 |
+
self::$loader = $loader = new xrstf_Composer52_ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit6da0d23f97720fc3d9b3fe2d5b2527cb', 'loadClassLoader'));
|
25 |
+
|
26 |
+
$vendorDir = dirname(dirname(__FILE__));
|
27 |
+
$baseDir = dirname($vendorDir);
|
28 |
+
$dir = dirname(__FILE__);
|
29 |
+
|
30 |
+
$map = require $dir.'/autoload_namespaces.php';
|
31 |
+
foreach ($map as $namespace => $path) {
|
32 |
+
$loader->add($namespace, $path);
|
33 |
+
}
|
34 |
+
|
35 |
+
$classMap = require $dir.'/autoload_classmap.php';
|
36 |
+
if ($classMap) {
|
37 |
+
$loader->addClassMap($classMap);
|
38 |
+
}
|
39 |
+
|
40 |
+
$loader->register(true);
|
41 |
+
|
42 |
+
return $loader;
|
43 |
+
}
|
44 |
+
}
|
vendor/composer/installed.json
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"name": "composer/installers",
|
4 |
+
"version": "v1.0.21",
|
5 |
+
"version_normalized": "1.0.21.0",
|
6 |
+
"source": {
|
7 |
+
"type": "git",
|
8 |
+
"url": "https://github.com/composer/installers.git",
|
9 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"
|
10 |
+
},
|
11 |
+
"dist": {
|
12 |
+
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
14 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
15 |
+
"shasum": ""
|
16 |
+
},
|
17 |
+
"replace": {
|
18 |
+
"roundcube/plugin-installer": "*",
|
19 |
+
"shama/baton": "*"
|
20 |
+
},
|
21 |
+
"require-dev": {
|
22 |
+
"composer/composer": "1.0.*@dev",
|
23 |
+
"phpunit/phpunit": "4.1.*"
|
24 |
+
},
|
25 |
+
"time": "2015-02-18 17:17:01",
|
26 |
+
"type": "composer-installer",
|
27 |
+
"extra": {
|
28 |
+
"class": "Composer\\Installers\\Installer",
|
29 |
+
"branch-alias": {
|
30 |
+
"dev-master": "1.0-dev"
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"installation-source": "dist",
|
34 |
+
"autoload": {
|
35 |
+
"psr-0": {
|
36 |
+
"Composer\\Installers\\": "src/"
|
37 |
+
}
|
38 |
+
},
|
39 |
+
"notification-url": "https://packagist.org/downloads/",
|
40 |
+
"license": [
|
41 |
+
"MIT"
|
42 |
+
],
|
43 |
+
"authors": [
|
44 |
+
{
|
45 |
+
"name": "Kyle Robinson Young",
|
46 |
+
"email": "kyle@dontkry.com",
|
47 |
+
"homepage": "https://github.com/shama"
|
48 |
+
}
|
49 |
+
],
|
50 |
+
"description": "A multi-framework Composer library installer",
|
51 |
+
"homepage": "http://composer.github.com/installers/",
|
52 |
+
"keywords": [
|
53 |
+
"Craft",
|
54 |
+
"Dolibarr",
|
55 |
+
"Hurad",
|
56 |
+
"MODX Evo",
|
57 |
+
"OXID",
|
58 |
+
"SMF",
|
59 |
+
"Thelia",
|
60 |
+
"WolfCMS",
|
61 |
+
"agl",
|
62 |
+
"aimeos",
|
63 |
+
"annotatecms",
|
64 |
+
"bitrix",
|
65 |
+
"cakephp",
|
66 |
+
"chef",
|
67 |
+
"codeigniter",
|
68 |
+
"concrete5",
|
69 |
+
"croogo",
|
70 |
+
"dokuwiki",
|
71 |
+
"drupal",
|
72 |
+
"elgg",
|
73 |
+
"fuelphp",
|
74 |
+
"grav",
|
75 |
+
"installer",
|
76 |
+
"joomla",
|
77 |
+
"kohana",
|
78 |
+
"laravel",
|
79 |
+
"lithium",
|
80 |
+
"magento",
|
81 |
+
"mako",
|
82 |
+
"mediawiki",
|
83 |
+
"modulework",
|
84 |
+
"moodle",
|
85 |
+
"phpbb",
|
86 |
+
"piwik",
|
87 |
+
"ppi",
|
88 |
+
"puppet",
|
89 |
+
"roundcube",
|
90 |
+
"shopware",
|
91 |
+
"silverstripe",
|
92 |
+
"symfony",
|
93 |
+
"typo3",
|
94 |
+
"wordpress",
|
95 |
+
"zend",
|
96 |
+
"zikula"
|
97 |
+
]
|
98 |
+
},
|
99 |
+
{
|
100 |
+
"name": "xrstf/composer-php52",
|
101 |
+
"version": "v1.0.17",
|
102 |
+
"version_normalized": "1.0.17.0",
|
103 |
+
"source": {
|
104 |
+
"type": "hg",
|
105 |
+
"url": "https://bitbucket.org/xrstf/composer-php52",
|
106 |
+
"reference": "70b853668d6c3f97b63dafcfaeebb622bf08fd30"
|
107 |
+
},
|
108 |
+
"dist": {
|
109 |
+
"type": "zip",
|
110 |
+
"url": "https://bitbucket.org/xrstf/composer-php52/get/70b853668d6c3f97b63dafcfaeebb622bf08fd30.zip",
|
111 |
+
"reference": "70b853668d6c3f97b63dafcfaeebb622bf08fd30",
|
112 |
+
"shasum": ""
|
113 |
+
},
|
114 |
+
"time": "2015-02-01 14:28:15",
|
115 |
+
"type": "library",
|
116 |
+
"extra": {
|
117 |
+
"branch-alias": {
|
118 |
+
"dev-default": "1.x-dev"
|
119 |
+
}
|
120 |
+
},
|
121 |
+
"installation-source": "dist",
|
122 |
+
"autoload": {
|
123 |
+
"psr-0": {
|
124 |
+
"xrstf\\Composer52": "lib/"
|
125 |
+
}
|
126 |
+
},
|
127 |
+
"notification-url": "https://packagist.org/downloads/",
|
128 |
+
"license": [
|
129 |
+
"MIT"
|
130 |
+
],
|
131 |
+
"homepage": "http://www.xrstf.de/"
|
132 |
+
}
|
133 |
+
]
|
vendor/composer/installers/.editorconfig
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
; top-most EditorConfig file
|
2 |
+
root = true
|
3 |
+
|
4 |
+
; Unix-style newlines
|
5 |
+
[*]
|
6 |
+
end_of_line = LF
|
7 |
+
|
8 |
+
[*.php]
|
9 |
+
indent_style = space
|
10 |
+
indent_size = 4
|
vendor/composer/installers/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
vendor/
|
2 |
+
composer.lock
|
3 |
+
.idea/
|
vendor/composer/installers/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
language: php
|
2 |
+
|
3 |
+
php:
|
4 |
+
- 5.3
|
5 |
+
- 5.4
|
6 |
+
- 5.5
|
7 |
+
- 5.6
|
8 |
+
- hhvm
|
9 |
+
|
10 |
+
before_script:
|
11 |
+
- curl -s http://getcomposer.org/installer | php -- --quiet
|
12 |
+
- php composer.phar install --dev
|
13 |
+
|
14 |
+
script: phpunit
|
vendor/composer/installers/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2012 Kyle Robinson Young
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
of this software and associated documentation files (the "Software"), to deal
|
5 |
+
in the Software without restriction, including without limitation the rights
|
6 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
+
copies of the Software, and to permit persons to whom the Software is furnished
|
8 |
+
to do so, subject to the following conditions:
|
9 |
+
|
10 |
+
The above copyright notice and this permission notice shall be included in all
|
11 |
+
copies or substantial portions of the Software.
|
12 |
+
|
13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
+
THE SOFTWARE.
|
vendor/composer/installers/README.md
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# A Multi-Framework [Composer](http://getcomposer.org) Library Installer
|
2 |
+
|
3 |
+
[![Build Status](http://img.shields.io/travis/composer/installers.svg)](http://travis-ci.org/composer/installers)
|
4 |
+
|
5 |
+
This is for PHP package authors to require in their `composer.json`. It will
|
6 |
+
install their package to the correct location based on the specified package
|
7 |
+
type.
|
8 |
+
|
9 |
+
The goal of `installers` is to be a simple package type to install path map.
|
10 |
+
Users can also customize the install path per package and package authors can
|
11 |
+
modify the package name upon installing.
|
12 |
+
|
13 |
+
`installers` isn't intended on replacing all custom installers. If your
|
14 |
+
package requires special installation handling then by all means, create a
|
15 |
+
custom installer to handle it.
|
16 |
+
|
17 |
+
**Natively Supported Frameworks**:
|
18 |
+
|
19 |
+
The following frameworks natively work with Composer and will be
|
20 |
+
installed to the default `vendor` directory. `composer/installers`
|
21 |
+
is not needed to install packages with these frameworks:
|
22 |
+
|
23 |
+
* Aura
|
24 |
+
* Symfony2
|
25 |
+
* Yii
|
26 |
+
* Yii2
|
27 |
+
|
28 |
+
**Current Supported Package Types**:
|
29 |
+
|
30 |
+
> Stable types are marked as **bold**, this means that installation paths
|
31 |
+
> for those type will not be changed. Any adjustment for those types would
|
32 |
+
> require creation of brand new type that will cover required changes.
|
33 |
+
|
34 |
+
| Framework | Types
|
35 |
+
| --------- | -----
|
36 |
+
| Aimeos | `aimeos-extension`
|
37 |
+
| Asgard | `asgard-module`<br>`asgard-theme`
|
38 |
+
| AGL | `agl-module`
|
39 |
+
| AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
|
40 |
+
| Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme`
|
41 |
+
| CakePHP 2+ | **`cakephp-plugin`**
|
42 |
+
| Chef | `chef-cookbook`<br>`chef-role`
|
43 |
+
| CCFramework | `ccframework-ship`<br>`ccframework-theme`
|
44 |
+
| CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module`
|
45 |
+
| concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update`
|
46 |
+
| Craft | `craft-plugin`
|
47 |
+
| Croogo | `croogo-plugin`<br>`croogo-theme`
|
48 |
+
| DokuWiki | `dokuwiki-plugin`<br>`dokuwiki-template`
|
49 |
+
| Dolibarr | `dolibarr-module`
|
50 |
+
| Drupal | <b>`drupal-module`<br>`drupal-theme`</b><br>`drupal-library`<br>`drupal-profile`<br>`drupal-drush`
|
51 |
+
| Elgg | `elgg-plugin`
|
52 |
+
| FuelPHP v1.x | `fuel-module`<br>`fuel-package`<br/>`fuel-theme`
|
53 |
+
| FuelPHP v2.x | `fuelphp-component`
|
54 |
+
| Grav | `grav-plugin`<br>`grav-theme`
|
55 |
+
| Hurad | `hurad-plugin`<br>`hurad-theme`
|
56 |
+
| Joomla | `joomla-component`<br>`joomla-module`<br>`joomla-template`<br>`joomla-plugin`<br>`joomla-library`
|
57 |
+
| Kirby | **`kirby-plugin`**
|
58 |
+
| Kohana | **`kohana-module`**
|
59 |
+
| Laravel | `laravel-library`
|
60 |
+
| Lithium | **`lithium-library`<br>`lithium-source`**
|
61 |
+
| Magento | `magento-library`<br>`magento-skin`<br>`magento-theme`
|
62 |
+
| Mako | `mako-package`
|
63 |
+
| MODX Evo | `modxevo-snippet`<br>`modxevo-plugin`<br>`modxevo-module`<br>`modxevo-template`<br>`modxevo-lib`
|
64 |
+
| MediaWiki | `mediawiki-extension`
|
65 |
+
| October | **`october-module`<br>`october-plugin`<br>`october-theme`**
|
66 |
+
| OXID | `oxid-module`<br>`oxid-theme`<br>`oxid-out`
|
67 |
+
| MODULEWork | `modulework-module`
|
68 |
+
| Moodle | `moodle-*` (Please [check source](https://raw.githubusercontent.com/composer/installers/master/src/Composer/Installers/MoodleInstaller.php) for all supported types)
|
69 |
+
| Piwik | `piwik-plugin`
|
70 |
+
| phpBB | `phpbb-extension`<br>`phpbb-style`<br>`phpbb-language`
|
71 |
+
| Pimcore | `pimcore-plugin`
|
72 |
+
| PPI | **`ppi-module`**
|
73 |
+
| Puppet | `puppet-module`
|
74 |
+
| REDAXO | `redaxo-addon`
|
75 |
+
| Roundcube | `roundcube-plugin`
|
76 |
+
| shopware | `shopware-backend-plugin`<br/>`shopware-core-plugin`<br/>`shopware-frontend-plugin`<br/>`shopware-theme`
|
77 |
+
| SilverStripe | `silverstripe-module`<br>`silverstripe-theme`
|
78 |
+
| SMF | `smf-module`<br>`smf-theme`
|
79 |
+
| symfony1 | **`symfony1-plugin`**
|
80 |
+
| Tusk | `tusk-task`<br>`tusk-command`<br>`tusk-asset`
|
81 |
+
| TYPO3 Flow | `typo3-flow-package`<br>`typo3-flow-framework`<br>`typo3-flow-plugin`<br>`typo3-flow-site`<br>`typo3-flow-boilerplate`<br>`typo3-flow-build`
|
82 |
+
| TYPO3 CMS | `typo3-cms-extension`
|
83 |
+
| Wolf CMS | `wolfcms-plugin`
|
84 |
+
| WordPress | <b>`wordpress-plugin`<br>`wordpress-theme`</b><br>`wordpress-muplugin`
|
85 |
+
| Zend | `zend-library`<br>`zend-extra`<br>`zend-module`
|
86 |
+
| Zikula | `zikula-module`<br>`zikula-theme`
|
87 |
+
| Prestashop | `prestashop-module`<br>`prestashop-theme`
|
88 |
+
|
89 |
+
## Example `composer.json` File
|
90 |
+
|
91 |
+
This is an example for a CakePHP plugin. The only important parts to set in your
|
92 |
+
composer.json file are `"type": "cakephp-plugin"` which describes what your
|
93 |
+
package is and `"require": { "composer/installers": "~1.0" }` which tells composer
|
94 |
+
to load the custom installers.
|
95 |
+
|
96 |
+
```json
|
97 |
+
{
|
98 |
+
"name": "you/ftp",
|
99 |
+
"type": "cakephp-plugin",
|
100 |
+
"require": {
|
101 |
+
"composer/installers": "~1.0"
|
102 |
+
}
|
103 |
+
}
|
104 |
+
```
|
105 |
+
|
106 |
+
This would install your package to the `Plugin/Ftp/` folder of a CakePHP app
|
107 |
+
when a user runs `php composer.phar install`.
|
108 |
+
|
109 |
+
So submit your packages to [packagist.org](http://packagist.org)!
|
110 |
+
|
111 |
+
## Custom Install Paths
|
112 |
+
|
113 |
+
If you are consuming a package that uses the `composer/installers` you can
|
114 |
+
override the install path with the following extra in your `composer.json`:
|
115 |
+
|
116 |
+
```json
|
117 |
+
{
|
118 |
+
"extra": {
|
119 |
+
"installer-paths": {
|
120 |
+
"your/custom/path/{$name}/": ["shama/ftp", "vendor/package"]
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
```
|
125 |
+
|
126 |
+
A package type can have a custom installation path with a `type:` prefix.
|
127 |
+
|
128 |
+
``` json
|
129 |
+
{
|
130 |
+
"extra": {
|
131 |
+
"installer-paths": {
|
132 |
+
"your/custom/path/{$name}/": ["type:wordpress-plugin"]
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
```
|
137 |
+
|
138 |
+
This would use your custom path for each of the listed packages. The available
|
139 |
+
variables to use in your paths are: `{$name}`, `{$vendor}`, `{$type}`.
|
140 |
+
|
141 |
+
## Custom Install Names
|
142 |
+
|
143 |
+
If you're a package author and need your package to be named differently when
|
144 |
+
installed consider using the `installer-name` extra.
|
145 |
+
|
146 |
+
For example you have a package named `shama/cakephp-ftp` with the type
|
147 |
+
`cakephp-plugin`. Installing with `composer/installers` would install to the
|
148 |
+
path `Plugin/CakephpFtp`. Due to the strict naming conventions, you as a
|
149 |
+
package author actually need the package to be named and installed to
|
150 |
+
`Plugin/Ftp`. Using the following config within your **package** `composer.json`
|
151 |
+
will allow this:
|
152 |
+
|
153 |
+
```json
|
154 |
+
{
|
155 |
+
"name": "shama/cakephp-ftp",
|
156 |
+
"type": "cakephp-plugin",
|
157 |
+
"extra": {
|
158 |
+
"installer-name": "Ftp"
|
159 |
+
}
|
160 |
+
}
|
161 |
+
```
|
162 |
+
|
163 |
+
Please note the name entered into `installer-name` will be the final and will
|
164 |
+
not be inflected.
|
165 |
+
|
166 |
+
## Contribute!
|
167 |
+
|
168 |
+
* [Fork and clone](https://help.github.com/articles/fork-a-repo).
|
169 |
+
* Run the command `php composer.phar install --dev` to install the dev
|
170 |
+
dependencies. See [Composer](https://github.com/composer/composer#installation--usage).
|
171 |
+
* Use the command `phpunit` to run the tests. See [PHPUnit](http://phpunit.de).
|
172 |
+
* Create a branch, commit, push and send us a
|
173 |
+
[pull request](https://help.github.com/articles/using-pull-requests).
|
174 |
+
|
175 |
+
To ensure a consistent code base, you should make sure the code follows the
|
176 |
+
[Coding Standards](http://symfony.com/doc/2.0/contributing/code/standards.html)
|
177 |
+
which we borrowed from Symfony.
|
178 |
+
|
179 |
+
If you would like to help, please take a look at the list of
|
180 |
+
[issues](https://github.com/composer/installers/issues).
|
181 |
+
|
182 |
+
### Should we allow dynamic package types or paths? No.
|
183 |
+
What are they? The ability for a package author to determine where a package
|
184 |
+
will be installed either through setting the path directly in their
|
185 |
+
`composer.json` or through a dynamic package type: `"type":
|
186 |
+
"framework-install-here"`.
|
187 |
+
|
188 |
+
It has been proposed many times. Even implemented once early on and then
|
189 |
+
removed. `installers` won't do this because it would allow a single package
|
190 |
+
author to wipe out entire folders without the user's consent. That user would
|
191 |
+
then come here to yell at us.
|
vendor/composer/installers/composer.json
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "composer/installers",
|
3 |
+
"type": "composer-installer",
|
4 |
+
"license": "MIT",
|
5 |
+
"description": "A multi-framework Composer library installer",
|
6 |
+
"keywords": [
|
7 |
+
"installer",
|
8 |
+
"Aimeos",
|
9 |
+
"AGL",
|
10 |
+
"AnnotateCms",
|
11 |
+
"Bitrix",
|
12 |
+
"CakePHP",
|
13 |
+
"Chef",
|
14 |
+
"CodeIgniter",
|
15 |
+
"concrete5",
|
16 |
+
"Craft",
|
17 |
+
"Croogo",
|
18 |
+
"DokuWiki",
|
19 |
+
"Dolibarr",
|
20 |
+
"Drupal",
|
21 |
+
"Elgg",
|
22 |
+
"FuelPHP",
|
23 |
+
"Grav",
|
24 |
+
"Hurad",
|
25 |
+
"Joomla",
|
26 |
+
"Kohana",
|
27 |
+
"Laravel",
|
28 |
+
"Lithium",
|
29 |
+
"Magento",
|
30 |
+
"Mako",
|
31 |
+
"MODX Evo",
|
32 |
+
"MediaWiki",
|
33 |
+
"OXID",
|
34 |
+
"MODULEWork",
|
35 |
+
"Moodle",
|
36 |
+
"Piwik",
|
37 |
+
"phpBB",
|
38 |
+
"PPI",
|
39 |
+
"Puppet",
|
40 |
+
"Roundcube",
|
41 |
+
"shopware",
|
42 |
+
"SilverStripe",
|
43 |
+
"SMF",
|
44 |
+
"symfony",
|
45 |
+
"Thelia",
|
46 |
+
"TYPO3",
|
47 |
+
"WolfCMS",
|
48 |
+
"WordPress",
|
49 |
+
"Zend",
|
50 |
+
"Zikula"
|
51 |
+
],
|
52 |
+
"homepage": "http://composer.github.com/installers/",
|
53 |
+
"authors": [
|
54 |
+
{
|
55 |
+
"name": "Kyle Robinson Young",
|
56 |
+
"email": "kyle@dontkry.com",
|
57 |
+
"homepage": "https://github.com/shama"
|
58 |
+
}
|
59 |
+
],
|
60 |
+
"autoload": {
|
61 |
+
"psr-0": { "Composer\\Installers\\": "src/" }
|
62 |
+
},
|
63 |
+
"extra": {
|
64 |
+
"class": "Composer\\Installers\\Installer",
|
65 |
+
"branch-alias": {
|
66 |
+
"dev-master": "1.0-dev"
|
67 |
+
}
|
68 |
+
},
|
69 |
+
"replace": {
|
70 |
+
"shama/baton": "*",
|
71 |
+
"roundcube/plugin-installer": "*"
|
72 |
+
},
|
73 |
+
"require-dev": {
|
74 |
+
"composer/composer": "1.0.*@dev",
|
75 |
+
"phpunit/phpunit": "4.1.*"
|
76 |
+
}
|
77 |
+
}
|
vendor/composer/installers/phpunit.xml.dist
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
|
3 |
+
<phpunit backupGlobals="false"
|
4 |
+
backupStaticAttributes="false"
|
5 |
+
colors="true"
|
6 |
+
convertErrorsToExceptions="true"
|
7 |
+
convertNoticesToExceptions="true"
|
8 |
+
convertWarningsToExceptions="true"
|
9 |
+
processIsolation="false"
|
10 |
+
stopOnFailure="false"
|
11 |
+
syntaxCheck="false"
|
12 |
+
bootstrap="tests/bootstrap.php"
|
13 |
+
>
|
14 |
+
<testsuites>
|
15 |
+
<testsuite name="Installers Test Suite">
|
16 |
+
<directory>tests/Composer/Installers</directory>
|
17 |
+
</testsuite>
|
18 |
+
</testsuites>
|
19 |
+
|
20 |
+
<filter>
|
21 |
+
<whitelist>
|
22 |
+
<directory>src/Composer/Installers</directory>
|
23 |
+
</whitelist>
|
24 |
+
</filter>
|
25 |
+
</phpunit>
|
vendor/composer/installers/src/Composer/Installers/AglInstaller.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class AglInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'More/{$name}/',
|
8 |
+
);
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Format package name to CamelCase
|
12 |
+
*/
|
13 |
+
public function inflectPackageVars($vars)
|
14 |
+
{
|
15 |
+
$vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) {
|
16 |
+
return strtoupper($matches[1]);
|
17 |
+
}, $vars['name']);
|
18 |
+
|
19 |
+
return $vars;
|
20 |
+
}
|
21 |
+
}
|
vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class AimeosInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'extension' => 'ext/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class AnnotateCmsInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'addons/modules/{$name}/',
|
8 |
+
'component' => 'addons/components/{$name}/',
|
9 |
+
'service' => 'addons/services/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class AsgardInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'Modules/{$name}/',
|
8 |
+
'theme' => 'Themes/{$name}/'
|
9 |
+
);
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Format package name.
|
13 |
+
*
|
14 |
+
* For package type asgard-module, cut off a trailing '-plugin' if present.
|
15 |
+
*
|
16 |
+
* For package type asgard-theme, cut off a trailing '-theme' if present.
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public function inflectPackageVars($vars)
|
20 |
+
{
|
21 |
+
if ($vars['type'] === 'asgard-module') {
|
22 |
+
return $this->inflectPluginVars($vars);
|
23 |
+
}
|
24 |
+
|
25 |
+
if ($vars['type'] === 'asgard-theme') {
|
26 |
+
return $this->inflectThemeVars($vars);
|
27 |
+
}
|
28 |
+
|
29 |
+
return $vars;
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function inflectPluginVars($vars)
|
33 |
+
{
|
34 |
+
$vars['name'] = ucfirst(preg_replace('/-module/', '', $vars['name']));
|
35 |
+
|
36 |
+
return $vars;
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function inflectThemeVars($vars)
|
40 |
+
{
|
41 |
+
$vars['name'] = ucfirst(preg_replace('/-theme$/', '', $vars['name']));
|
42 |
+
|
43 |
+
return $vars;
|
44 |
+
}
|
45 |
+
}
|
vendor/composer/installers/src/Composer/Installers/BaseInstaller.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
use Composer\Composer;
|
5 |
+
use Composer\Package\PackageInterface;
|
6 |
+
|
7 |
+
abstract class BaseInstaller
|
8 |
+
{
|
9 |
+
protected $locations = array();
|
10 |
+
protected $composer;
|
11 |
+
protected $package;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Initializes base installer.
|
15 |
+
*
|
16 |
+
* @param PackageInterface $package
|
17 |
+
* @param Composer $composer
|
18 |
+
*/
|
19 |
+
public function __construct(PackageInterface $package = null, Composer $composer = null)
|
20 |
+
{
|
21 |
+
$this->composer = $composer;
|
22 |
+
$this->package = $package;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Return the install path based on package type.
|
27 |
+
*
|
28 |
+
* @param PackageInterface $package
|
29 |
+
* @param string $frameworkType
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getInstallPath(PackageInterface $package, $frameworkType = '')
|
33 |
+
{
|
34 |
+
$type = $this->package->getType();
|
35 |
+
|
36 |
+
$prettyName = $this->package->getPrettyName();
|
37 |
+
if (strpos($prettyName, '/') !== false) {
|
38 |
+
list($vendor, $name) = explode('/', $prettyName);
|
39 |
+
} else {
|
40 |
+
$vendor = '';
|
41 |
+
$name = $prettyName;
|
42 |
+
}
|
43 |
+
|
44 |
+
$availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));
|
45 |
+
|
46 |
+
$extra = $package->getExtra();
|
47 |
+
if (!empty($extra['installer-name'])) {
|
48 |
+
$availableVars['name'] = $extra['installer-name'];
|
49 |
+
}
|
50 |
+
|
51 |
+
if ($this->composer->getPackage()) {
|
52 |
+
$extra = $this->composer->getPackage()->getExtra();
|
53 |
+
if (!empty($extra['installer-paths'])) {
|
54 |
+
$customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
|
55 |
+
if ($customPath !== false) {
|
56 |
+
return $this->templatePath($customPath, $availableVars);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
$packageType = substr($type, strlen($frameworkType) + 1);
|
62 |
+
$locations = $this->getLocations();
|
63 |
+
if (!isset($locations[$packageType])) {
|
64 |
+
throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
|
65 |
+
}
|
66 |
+
|
67 |
+
return $this->templatePath($locations[$packageType], $availableVars);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* For an installer to override to modify the vars per installer.
|
72 |
+
*
|
73 |
+
* @param array $vars
|
74 |
+
* @return array
|
75 |
+
*/
|
76 |
+
public function inflectPackageVars($vars)
|
77 |
+
{
|
78 |
+
return $vars;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Gets the installer's locations
|
83 |
+
*
|
84 |
+
* @return array
|
85 |
+
*/
|
86 |
+
public function getLocations()
|
87 |
+
{
|
88 |
+
return $this->locations;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Replace vars in a path
|
93 |
+
*
|
94 |
+
* @param string $path
|
95 |
+
* @param array $vars
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
+
protected function templatePath($path, array $vars = array())
|
99 |
+
{
|
100 |
+
if (strpos($path, '{') !== false) {
|
101 |
+
extract($vars);
|
102 |
+
preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches);
|
103 |
+
if (!empty($matches[1])) {
|
104 |
+
foreach ($matches[1] as $var) {
|
105 |
+
$path = str_replace('{$' . $var . '}', $$var, $path);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
return $path;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Search through a passed paths array for a custom install path.
|
115 |
+
*
|
116 |
+
* @param array $paths
|
117 |
+
* @param string $name
|
118 |
+
* @param string $type
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
protected function mapCustomInstallPaths(array $paths, $name, $type)
|
122 |
+
{
|
123 |
+
foreach ($paths as $path => $names) {
|
124 |
+
if (in_array($name, $names) || in_array('type:' . $type, $names)) {
|
125 |
+
return $path;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
}
|
vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class BitrixInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'local/modules/{$name}/',
|
8 |
+
'component' => 'local/components/{$name}/',
|
9 |
+
'theme' => 'local/templates/{$name}/'
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
use Composer\DependencyResolver\Pool;
|
5 |
+
use Composer\Package\PackageInterface;
|
6 |
+
use Composer\Package\LinkConstraint\MultiConstraint;
|
7 |
+
use Composer\Package\LinkConstraint\VersionConstraint;
|
8 |
+
|
9 |
+
class CakePHPInstaller extends BaseInstaller
|
10 |
+
{
|
11 |
+
protected $locations = array(
|
12 |
+
'plugin' => 'Plugin/{$name}/',
|
13 |
+
);
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Format package name to CamelCase
|
17 |
+
*/
|
18 |
+
public function inflectPackageVars($vars)
|
19 |
+
{
|
20 |
+
if ($this->matchesCakeVersion('>=', '3.0.0')) {
|
21 |
+
return $vars;
|
22 |
+
}
|
23 |
+
|
24 |
+
$nameParts = explode('/', $vars['name']);
|
25 |
+
foreach ($nameParts as &$value) {
|
26 |
+
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
|
27 |
+
$value = str_replace(array('-', '_'), ' ', $value);
|
28 |
+
$value = str_replace(' ', '', ucwords($value));
|
29 |
+
}
|
30 |
+
$vars['name'] = implode('/', $nameParts);
|
31 |
+
|
32 |
+
return $vars;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Change the default plugin location when cakephp >= 3.0
|
37 |
+
*/
|
38 |
+
public function getLocations()
|
39 |
+
{
|
40 |
+
if ($this->matchesCakeVersion('>=', '3.0.0')) {
|
41 |
+
$this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
|
42 |
+
}
|
43 |
+
return $this->locations;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Check if CakePHP version matches against a version
|
48 |
+
*
|
49 |
+
* @param string $matcher
|
50 |
+
* @param string $version
|
51 |
+
* @return bool
|
52 |
+
*/
|
53 |
+
protected function matchesCakeVersion($matcher, $version)
|
54 |
+
{
|
55 |
+
$repositoryManager = $this->composer->getRepositoryManager();
|
56 |
+
if ($repositoryManager) {
|
57 |
+
$repos = $repositoryManager->getLocalRepository();
|
58 |
+
if (!$repos) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
$cake3 = new MultiConstraint(array(
|
62 |
+
new VersionConstraint($matcher, $version),
|
63 |
+
new VersionConstraint('!=', '9999999-dev'),
|
64 |
+
));
|
65 |
+
$pool = new Pool('dev');
|
66 |
+
$pool->addRepository($repos);
|
67 |
+
$packages = $pool->whatProvides('cakephp/cakephp');
|
68 |
+
foreach ($packages as $package) {
|
69 |
+
$installed = new VersionConstraint('=', $package->getVersion());
|
70 |
+
if ($cake3->matches($installed)) {
|
71 |
+
return true;
|
72 |
+
break;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
}
|
vendor/composer/installers/src/Composer/Installers/ChefInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class ChefInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'cookbook' => 'Chef/{$vendor}/{$name}/',
|
8 |
+
'role' => 'Chef/roles/{$name}/',
|
9 |
+
);
|
10 |
+
}
|
11 |
+
|
vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class ClanCatsFrameworkInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'ship' => 'CCF/orbit/{$name}/',
|
8 |
+
'theme' => 'CCF/app/themes/{$name}/',
|
9 |
+
);
|
10 |
+
}
|
vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class CodeIgniterInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'library' => 'application/libraries/{$name}/',
|
8 |
+
'third-party' => 'application/third_party/{$name}/',
|
9 |
+
'module' => 'application/modules/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class Concrete5Installer extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'block' => 'blocks/{$name}/',
|
8 |
+
'package' => 'packages/{$name}/',
|
9 |
+
'theme' => 'themes/{$name}/',
|
10 |
+
'update' => 'updates/{$name}/',
|
11 |
+
);
|
12 |
+
}
|
vendor/composer/installers/src/Composer/Installers/CraftInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class CraftInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'craft/plugins/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class CroogoInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'Plugin/{$name}/',
|
8 |
+
'theme' => 'View/Themed/{$name}/',
|
9 |
+
);
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Format package name to CamelCase
|
13 |
+
*/
|
14 |
+
public function inflectPackageVars($vars)
|
15 |
+
{
|
16 |
+
$vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name']));
|
17 |
+
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
18 |
+
|
19 |
+
return $vars;
|
20 |
+
}
|
21 |
+
}
|
vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class DokuWikiInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'lib/plugins/{$name}/',
|
8 |
+
'template' => 'lib/tpl/{$name}/',
|
9 |
+
);
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Format package name.
|
13 |
+
*
|
14 |
+
* For package type dokuwiki-plugin, cut off a trailing '-plugin',
|
15 |
+
* or leading dokuwiki_ if present.
|
16 |
+
*
|
17 |
+
* For package type dokuwiki-template, cut off a trailing '-template' if present.
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
public function inflectPackageVars($vars)
|
21 |
+
{
|
22 |
+
|
23 |
+
if ($vars['type'] === 'dokuwiki-plugin') {
|
24 |
+
return $this->inflectPluginVars($vars);
|
25 |
+
}
|
26 |
+
|
27 |
+
if ($vars['type'] === 'dokuwiki-template') {
|
28 |
+
return $this->inflectTemplateVars($vars);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $vars;
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function inflectPluginVars($vars)
|
35 |
+
{
|
36 |
+
$vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
|
37 |
+
$vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
|
38 |
+
|
39 |
+
return $vars;
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function inflectTemplateVars($vars)
|
43 |
+
{
|
44 |
+
$vars['name'] = preg_replace('/-template$/', '', $vars['name']);
|
45 |
+
$vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
|
46 |
+
|
47 |
+
return $vars;
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class DolibarrInstaller
|
6 |
+
*
|
7 |
+
* @package Composer\Installers
|
8 |
+
* @author Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
9 |
+
*/
|
10 |
+
class DolibarrInstaller extends BaseInstaller
|
11 |
+
{
|
12 |
+
//TODO: Add support for scripts and themes
|
13 |
+
protected $locations = array(
|
14 |
+
'module' => 'htdocs/custom/{$name}/',
|
15 |
+
);
|
16 |
+
}
|
vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class DrupalInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'core' => 'core/',
|
8 |
+
'module' => 'modules/{$name}/',
|
9 |
+
'theme' => 'themes/{$name}/',
|
10 |
+
'library' => 'libraries/{$name}/',
|
11 |
+
'profile' => 'profiles/{$name}/',
|
12 |
+
'drush' => 'drush/{$name}/',
|
13 |
+
);
|
14 |
+
}
|
vendor/composer/installers/src/Composer/Installers/ElggInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class ElggInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'mod/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/FuelInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class FuelInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'fuel/app/modules/{$name}/',
|
8 |
+
'package' => 'fuel/packages/{$name}/',
|
9 |
+
'theme' => 'fuel/app/themes/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class FuelphpInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'component' => 'components/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/GravInstaller.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class GravInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'user/plugins/{$name}/',
|
8 |
+
'theme' => 'user/themes/{$name}/',
|
9 |
+
);
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Format package name
|
13 |
+
*
|
14 |
+
* @param array $vars
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function inflectPackageVars($vars)
|
19 |
+
{
|
20 |
+
$restrictedWords = implode('|', array_keys($this->locations));
|
21 |
+
|
22 |
+
$vars['name'] = strtolower($vars['name']);
|
23 |
+
$vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
|
24 |
+
'$1',
|
25 |
+
$vars['name']
|
26 |
+
);
|
27 |
+
|
28 |
+
return $vars;
|
29 |
+
}
|
30 |
+
}
|
vendor/composer/installers/src/Composer/Installers/HuradInstaller.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class HuradInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'plugins/{$name}/',
|
8 |
+
'theme' => 'plugins/{$name}/',
|
9 |
+
);
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Format package name to CamelCase
|
13 |
+
*/
|
14 |
+
public function inflectPackageVars($vars)
|
15 |
+
{
|
16 |
+
$nameParts = explode('/', $vars['name']);
|
17 |
+
foreach ($nameParts as &$value) {
|
18 |
+
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
|
19 |
+
$value = str_replace(array('-', '_'), ' ', $value);
|
20 |
+
$value = str_replace(' ', '', ucwords($value));
|
21 |
+
}
|
22 |
+
$vars['name'] = implode('/', $nameParts);
|
23 |
+
return $vars;
|
24 |
+
}
|
25 |
+
}
|
vendor/composer/installers/src/Composer/Installers/Installer.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
use Composer\Installer\LibraryInstaller;
|
5 |
+
use Composer\Package\PackageInterface;
|
6 |
+
use Composer\Repository\InstalledRepositoryInterface;
|
7 |
+
|
8 |
+
class Installer extends LibraryInstaller
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Package types to installer class map
|
12 |
+
*
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
private $supportedTypes = array(
|
16 |
+
'aimeos' => 'AimeosInstaller',
|
17 |
+
'asgard' => 'AsgardInstaller',
|
18 |
+
'agl' => 'AglInstaller',
|
19 |
+
'annotatecms' => 'AnnotateCmsInstaller',
|
20 |
+
'bitrix' => 'BitrixInstaller',
|
21 |
+
'cakephp' => 'CakePHPInstaller',
|
22 |
+
'chef' => 'ChefInstaller',
|
23 |
+
'ccframework' => 'ClanCatsFrameworkInstaller',
|
24 |
+
'codeigniter' => 'CodeIgniterInstaller',
|
25 |
+
'concrete5' => 'Concrete5Installer',
|
26 |
+
'craft' => 'CraftInstaller',
|
27 |
+
'croogo' => 'CroogoInstaller',
|
28 |
+
'dokuwiki' => 'DokuWikiInstaller',
|
29 |
+
'dolibarr' => 'DolibarrInstaller',
|
30 |
+
'drupal' => 'DrupalInstaller',
|
31 |
+
'elgg' => 'ElggInstaller',
|
32 |
+
'fuel' => 'FuelInstaller',
|
33 |
+
'fuelphp' => 'FuelphpInstaller',
|
34 |
+
'grav' => 'GravInstaller',
|
35 |
+
'hurad' => 'HuradInstaller',
|
36 |
+
'joomla' => 'JoomlaInstaller',
|
37 |
+
'kirby' => 'KirbyInstaller',
|
38 |
+
'kohana' => 'KohanaInstaller',
|
39 |
+
'laravel' => 'LaravelInstaller',
|
40 |
+
'lithium' => 'LithiumInstaller',
|
41 |
+
'magento' => 'MagentoInstaller',
|
42 |
+
'mako' => 'MakoInstaller',
|
43 |
+
'mediawiki' => 'MediaWikiInstaller',
|
44 |
+
'microweber' => 'MicroweberInstaller',
|
45 |
+
'modulework' => 'MODULEWorkInstaller',
|
46 |
+
'modxevo' => 'MODXEvoInstaller',
|
47 |
+
'moodle' => 'MoodleInstaller',
|
48 |
+
'october' => 'OctoberInstaller',
|
49 |
+
'oxid' => 'OxidInstaller',
|
50 |
+
'phpbb' => 'PhpBBInstaller',
|
51 |
+
'pimcore' => 'PimcoreInstaller',
|
52 |
+
'piwik' => 'PiwikInstaller',
|
53 |
+
'ppi' => 'PPIInstaller',
|
54 |
+
'puppet' => 'PuppetInstaller',
|
55 |
+
'redaxo' => 'RedaxoInstaller',
|
56 |
+
'roundcube' => 'RoundcubeInstaller',
|
57 |
+
'shopware' => 'ShopwareInstaller',
|
58 |
+
'silverstripe' => 'SilverStripeInstaller',
|
59 |
+
'smf' => 'SMFInstaller',
|
60 |
+
'symfony1' => 'Symfony1Installer',
|
61 |
+
'thelia' => 'TheliaInstaller',
|
62 |
+
'tusk' => 'TuskInstaller',
|
63 |
+
'typo3-cms' => 'TYPO3CmsInstaller',
|
64 |
+
'typo3-flow' => 'TYPO3FlowInstaller',
|
65 |
+
'whmcs' => 'WHMCSInstaller',
|
66 |
+
'wolfcms' => 'WolfCMSInstaller',
|
67 |
+
'wordpress' => 'WordPressInstaller',
|
68 |
+
'zend' => 'ZendInstaller',
|
69 |
+
'zikula' => 'ZikulaInstaller',
|
70 |
+
'prestashop' => 'PrestashopInstaller',
|
71 |
+
);
|
72 |
+
|
73 |
+
/**
|
74 |
+
* {@inheritDoc}
|
75 |
+
*/
|
76 |
+
public function getInstallPath(PackageInterface $package)
|
77 |
+
{
|
78 |
+
$type = $package->getType();
|
79 |
+
$frameworkType = $this->findFrameworkType($type);
|
80 |
+
|
81 |
+
if ($frameworkType === false) {
|
82 |
+
throw new \InvalidArgumentException(
|
83 |
+
'Sorry the package type of this package is not yet supported.'
|
84 |
+
);
|
85 |
+
}
|
86 |
+
|
87 |
+
$class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
|
88 |
+
$installer = new $class($package, $this->composer);
|
89 |
+
|
90 |
+
return $installer->getInstallPath($package, $frameworkType);
|
91 |
+
}
|
92 |
+
|
93 |
+
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
|
94 |
+
{
|
95 |
+
if (!$repo->hasPackage($package)) {
|
96 |
+
throw new \InvalidArgumentException('Package is not installed: '.$package);
|
97 |
+
}
|
98 |
+
|
99 |
+
$repo->removePackage($package);
|
100 |
+
|
101 |
+
$installPath = $this->getInstallPath($package);
|
102 |
+
$this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>'));
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* {@inheritDoc}
|
107 |
+
*/
|
108 |
+
public function supports($packageType)
|
109 |
+
{
|
110 |
+
$frameworkType = $this->findFrameworkType($packageType);
|
111 |
+
|
112 |
+
if ($frameworkType === false) {
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
116 |
+
$locationPattern = $this->getLocationPattern($frameworkType);
|
117 |
+
|
118 |
+
return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Finds a supported framework type if it exists and returns it
|
123 |
+
*
|
124 |
+
* @param string $type
|
125 |
+
* @return string
|
126 |
+
*/
|
127 |
+
protected function findFrameworkType($type)
|
128 |
+
{
|
129 |
+
$frameworkType = false;
|
130 |
+
|
131 |
+
krsort($this->supportedTypes);
|
132 |
+
|
133 |
+
foreach ($this->supportedTypes as $key => $val) {
|
134 |
+
if ($key === substr($type, 0, strlen($key))) {
|
135 |
+
$frameworkType = substr($type, 0, strlen($key));
|
136 |
+
break;
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
return $frameworkType;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Get the second part of the regular expression to check for support of a
|
145 |
+
* package type
|
146 |
+
*
|
147 |
+
* @param string $frameworkType
|
148 |
+
* @return string
|
149 |
+
*/
|
150 |
+
protected function getLocationPattern($frameworkType)
|
151 |
+
{
|
152 |
+
$pattern = false;
|
153 |
+
if (!empty($this->supportedTypes[$frameworkType])) {
|
154 |
+
$frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
|
155 |
+
/** @var BaseInstaller $framework */
|
156 |
+
$framework = new $frameworkClass(null, $this->composer);
|
157 |
+
$locations = array_keys($framework->getLocations());
|
158 |
+
$pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
|
159 |
+
}
|
160 |
+
|
161 |
+
return $pattern ? : '(\w+)';
|
162 |
+
}
|
163 |
+
}
|
vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class JoomlaInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'component' => 'components/{$name}/',
|
8 |
+
'module' => 'modules/{$name}/',
|
9 |
+
'template' => 'templates/{$name}/',
|
10 |
+
'plugin' => 'plugins/{$name}/',
|
11 |
+
'library' => 'libraries/{$name}/',
|
12 |
+
);
|
13 |
+
|
14 |
+
// TODO: Add inflector for mod_ and com_ names
|
15 |
+
}
|
vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class KirbyInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'site/plugins/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class KohanaInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'modules/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class LaravelInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'library' => 'libraries/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class LithiumInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'library' => 'libraries/{$name}/',
|
8 |
+
'source' => 'libraries/_source/{$name}/',
|
9 |
+
);
|
10 |
+
}
|
vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class MODULEWorkInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'modules/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* An installer to handle MODX Evolution specifics when installing packages.
|
6 |
+
*/
|
7 |
+
class MODXEvoInstaller extends BaseInstaller
|
8 |
+
{
|
9 |
+
protected $locations = array(
|
10 |
+
'snippet' => 'assets/snippets/{$name}/',
|
11 |
+
'plugin' => 'assets/plugins/{$name}/',
|
12 |
+
'module' => 'assets/modules/{$name}/',
|
13 |
+
'template' => 'assets/templates/{$name}/',
|
14 |
+
'lib' => 'assets/lib/{$name}/'
|
15 |
+
);
|
16 |
+
}
|
vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class MagentoInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'theme' => 'app/design/frontend/{$name}/',
|
8 |
+
'skin' => 'skin/frontend/default/{$name}/',
|
9 |
+
'library' => 'lib/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/MakoInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class MakoInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'package' => 'app/packages/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class MediaWikiInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'extension' => 'extensions/{$name}/',
|
8 |
+
'skin' => 'skins/{$name}/',
|
9 |
+
);
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Format package name.
|
13 |
+
*
|
14 |
+
* For package type mediawiki-extension, cut off a trailing '-extension' if present and transform
|
15 |
+
* to CamelCase keeping existing uppercase chars.
|
16 |
+
*
|
17 |
+
* For package type mediawiki-skin, cut off a trailing '-skin' if present.
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
public function inflectPackageVars($vars)
|
21 |
+
{
|
22 |
+
|
23 |
+
if ($vars['type'] === 'mediawiki-extension') {
|
24 |
+
return $this->inflectExtensionVars($vars);
|
25 |
+
}
|
26 |
+
|
27 |
+
if ($vars['type'] === 'mediawiki-skin') {
|
28 |
+
return $this->inflectSkinVars($vars);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $vars;
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function inflectExtensionVars($vars)
|
35 |
+
{
|
36 |
+
$vars['name'] = preg_replace('/-extension$/', '', $vars['name']);
|
37 |
+
$vars['name'] = str_replace('-', ' ', $vars['name']);
|
38 |
+
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
39 |
+
|
40 |
+
return $vars;
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function inflectSkinVars($vars)
|
44 |
+
{
|
45 |
+
$vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
|
46 |
+
|
47 |
+
return $vars;
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class MicroweberInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'userfiles/modules/{$name}/',
|
8 |
+
'module-skin' => 'userfiles/modules/{$name}/templates/',
|
9 |
+
'template' => 'userfiles/templates/{$name}/',
|
10 |
+
'element' => 'userfiles/elements/{$name}/',
|
11 |
+
'vendor' => 'vendor/{$name}/',
|
12 |
+
'components' => 'components/{$name}/'
|
13 |
+
);
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Format package name.
|
17 |
+
*
|
18 |
+
* For package type microweber-module, cut off a trailing '-module' if present
|
19 |
+
*
|
20 |
+
* For package type microweber-template, cut off a trailing '-template' if present.
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
public function inflectPackageVars($vars)
|
24 |
+
{
|
25 |
+
if ($vars['type'] === 'microweber-template') {
|
26 |
+
return $this->inflectTemplateVars($vars);
|
27 |
+
}
|
28 |
+
if ($vars['type'] === 'microweber-templates') {
|
29 |
+
return $this->inflectTemplatesVars($vars);
|
30 |
+
}
|
31 |
+
if ($vars['type'] === 'microweber-core') {
|
32 |
+
return $this->inflectCoreVars($vars);
|
33 |
+
}
|
34 |
+
if ($vars['type'] === 'microweber-adapter') {
|
35 |
+
return $this->inflectCoreVars($vars);
|
36 |
+
}
|
37 |
+
if ($vars['type'] === 'microweber-module') {
|
38 |
+
return $this->inflectModuleVars($vars);
|
39 |
+
}
|
40 |
+
if ($vars['type'] === 'microweber-modules') {
|
41 |
+
return $this->inflectModulesVars($vars);
|
42 |
+
}
|
43 |
+
if ($vars['type'] === 'microweber-skin') {
|
44 |
+
return $this->inflectSkinVars($vars);
|
45 |
+
}
|
46 |
+
if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') {
|
47 |
+
return $this->inflectElementVars($vars);
|
48 |
+
}
|
49 |
+
|
50 |
+
return $vars;
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function inflectTemplateVars($vars)
|
54 |
+
{
|
55 |
+
$vars['name'] = preg_replace('/-template$/', '', $vars['name']);
|
56 |
+
$vars['name'] = preg_replace('/template-$/', '', $vars['name']);
|
57 |
+
|
58 |
+
return $vars;
|
59 |
+
}
|
60 |
+
|
61 |
+
protected function inflectTemplatesVars($vars)
|
62 |
+
{
|
63 |
+
$vars['name'] = preg_replace('/-templates$/', '', $vars['name']);
|
64 |
+
$vars['name'] = preg_replace('/templates-$/', '', $vars['name']);
|
65 |
+
|
66 |
+
return $vars;
|
67 |
+
}
|
68 |
+
|
69 |
+
protected function inflectCoreVars($vars)
|
70 |
+
{
|
71 |
+
$vars['name'] = preg_replace('/-providers$/', '', $vars['name']);
|
72 |
+
$vars['name'] = preg_replace('/-provider$/', '', $vars['name']);
|
73 |
+
$vars['name'] = preg_replace('/-adapter$/', '', $vars['name']);
|
74 |
+
|
75 |
+
return $vars;
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function inflectModuleVars($vars)
|
79 |
+
{
|
80 |
+
$vars['name'] = preg_replace('/-module$/', '', $vars['name']);
|
81 |
+
$vars['name'] = preg_replace('/module-$/', '', $vars['name']);
|
82 |
+
|
83 |
+
return $vars;
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function inflectModulesVars($vars)
|
87 |
+
{
|
88 |
+
$vars['name'] = preg_replace('/-modules$/', '', $vars['name']);
|
89 |
+
$vars['name'] = preg_replace('/modules-$/', '', $vars['name']);
|
90 |
+
|
91 |
+
return $vars;
|
92 |
+
}
|
93 |
+
|
94 |
+
protected function inflectSkinVars($vars)
|
95 |
+
{
|
96 |
+
$vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
|
97 |
+
$vars['name'] = preg_replace('/skin-$/', '', $vars['name']);
|
98 |
+
|
99 |
+
return $vars;
|
100 |
+
}
|
101 |
+
|
102 |
+
protected function inflectElementVars($vars)
|
103 |
+
{
|
104 |
+
$vars['name'] = preg_replace('/-elements$/', '', $vars['name']);
|
105 |
+
$vars['name'] = preg_replace('/elements-$/', '', $vars['name']);
|
106 |
+
$vars['name'] = preg_replace('/-element$/', '', $vars['name']);
|
107 |
+
$vars['name'] = preg_replace('/element-$/', '', $vars['name']);
|
108 |
+
|
109 |
+
return $vars;
|
110 |
+
}
|
111 |
+
}
|
vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class MoodleInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'mod' => 'mod/{$name}/',
|
8 |
+
'admin_report' => 'admin/report/{$name}/',
|
9 |
+
'tool' => 'admin/tool/{$name}/',
|
10 |
+
'assignment' => 'mod/assignment/type/{$name}/',
|
11 |
+
'assignsubmission' => 'mod/assign/submission/{$name}/',
|
12 |
+
'assignfeedback' => 'mod/assign/feedback/{$name}/',
|
13 |
+
'auth' => 'auth/{$name}/',
|
14 |
+
'availability' => 'availability/condition/{$name}/',
|
15 |
+
'block' => 'blocks/{$name}/',
|
16 |
+
'calendartype' => 'calendar/type/{$name}/',
|
17 |
+
'format' => 'course/format/{$name}/',
|
18 |
+
'coursereport' => 'course/report/{$name}/',
|
19 |
+
'datafield' => 'mod/data/field/{$name}/',
|
20 |
+
'datapreset' => 'mod/data/preset/{$name}/',
|
21 |
+
'editor' => 'lib/editor/{$name}/',
|
22 |
+
'enrol' => 'enrol/{$name}/',
|
23 |
+
'filter' => 'filter/{$name}/',
|
24 |
+
'gradeexport' => 'grade/export/{$name}/',
|
25 |
+
'gradeimport' => 'grade/import/{$name}/',
|
26 |
+
'gradereport' => 'grade/report/{$name}/',
|
27 |
+
'gradingform' => 'grade/grading/form/{$name}/',
|
28 |
+
'local' => 'local/{$name}/',
|
29 |
+
'message' => 'message/output/{$name}/',
|
30 |
+
'plagiarism' => 'plagiarism/{$name}/',
|
31 |
+
'portfolio' => 'portfolio/{$name}/',
|
32 |
+
'qbehaviour' => 'question/behaviour/{$name}/',
|
33 |
+
'qformat' => 'question/format/{$name}/',
|
34 |
+
'qtype' => 'question/type/{$name}/',
|
35 |
+
'quizaccess' => 'mod/quiz/accessrule/{$name}/',
|
36 |
+
'quiz' => 'mod/quiz/report/{$name}/',
|
37 |
+
'report' => 'report/{$name}/',
|
38 |
+
'repository' => 'repository/{$name}/',
|
39 |
+
'scormreport' => 'mod/scorm/report/{$name}/',
|
40 |
+
'theme' => 'theme/{$name}/',
|
41 |
+
'profilefield' => 'user/profile/field/{$name}/',
|
42 |
+
'webservice' => 'webservice/{$name}/',
|
43 |
+
'workshopallocation' => 'mod/workshop/allocation/{$name}/',
|
44 |
+
'workshopeval' => 'mod/workshop/eval/{$name}/',
|
45 |
+
'workshopform' => 'mod/workshop/form/{$name}/'
|
46 |
+
);
|
47 |
+
}
|
vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class OctoberInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'modules/{$name}/',
|
8 |
+
'plugin' => 'plugins/{$vendor}/{$name}/',
|
9 |
+
'theme' => 'themes/{$name}/'
|
10 |
+
);
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Format package name.
|
14 |
+
*
|
15 |
+
* For package type october-plugin, cut off a trailing '-plugin' if present.
|
16 |
+
*
|
17 |
+
* For package type october-theme, cut off a trailing '-theme' if present.
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
public function inflectPackageVars($vars)
|
21 |
+
{
|
22 |
+
if ($vars['type'] === 'october-plugin') {
|
23 |
+
return $this->inflectPluginVars($vars);
|
24 |
+
}
|
25 |
+
|
26 |
+
if ($vars['type'] === 'october-theme') {
|
27 |
+
return $this->inflectThemeVars($vars);
|
28 |
+
}
|
29 |
+
|
30 |
+
return $vars;
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function inflectPluginVars($vars)
|
34 |
+
{
|
35 |
+
$vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
|
36 |
+
|
37 |
+
return $vars;
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function inflectThemeVars($vars)
|
41 |
+
{
|
42 |
+
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
|
43 |
+
|
44 |
+
return $vars;
|
45 |
+
}
|
46 |
+
}
|
vendor/composer/installers/src/Composer/Installers/OxidInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class OxidInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'modules/{$name}/',
|
8 |
+
'theme' => 'application/views/{$name}/',
|
9 |
+
'out' => 'out/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/PPIInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class PPIInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'modules/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class PhpBBInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'extension' => 'ext/{$vendor}/{$name}/',
|
8 |
+
'language' => 'language/{$name}/',
|
9 |
+
'style' => 'styles/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class PimcoreInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'plugins/{$name}/',
|
8 |
+
);
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Format package name to CamelCase
|
12 |
+
*/
|
13 |
+
public function inflectPackageVars($vars)
|
14 |
+
{
|
15 |
+
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
|
16 |
+
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
|
17 |
+
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
18 |
+
|
19 |
+
return $vars;
|
20 |
+
}
|
21 |
+
}
|
vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class PiwikInstaller
|
6 |
+
*
|
7 |
+
* @package Composer\Installers
|
8 |
+
*/
|
9 |
+
class PiwikInstaller extends BaseInstaller
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* @var array
|
13 |
+
*/
|
14 |
+
protected $locations = array(
|
15 |
+
'plugin' => 'plugins/{$name}/',
|
16 |
+
);
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Format package name to CamelCase
|
20 |
+
* @param array $vars
|
21 |
+
*
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function inflectPackageVars($vars)
|
25 |
+
{
|
26 |
+
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
|
27 |
+
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
|
28 |
+
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
29 |
+
|
30 |
+
return $vars;
|
31 |
+
}
|
32 |
+
}
|
vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class PrestashopInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'modules/{$name}/',
|
8 |
+
'theme' => 'themes/{$name}/',
|
9 |
+
);
|
10 |
+
}
|
vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Composer\Installers;
|
4 |
+
|
5 |
+
class PuppetInstaller extends BaseInstaller
|
6 |
+
{
|
7 |
+
|
8 |
+
protected $locations = array(
|
9 |
+
'module' => 'modules/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class RedaxoInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'addon' => 'redaxo/include/addons/{$name}/',
|
8 |
+
'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/'
|
9 |
+
);
|
10 |
+
}
|
vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class RoundcubeInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'plugins/{$name}/',
|
8 |
+
);
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Lowercase name and changes the name to a underscores
|
12 |
+
*
|
13 |
+
* @param array $vars
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function inflectPackageVars($vars)
|
17 |
+
{
|
18 |
+
$vars['name'] = strtolower(str_replace('-', '_', $vars['name']));
|
19 |
+
|
20 |
+
return $vars;
|
21 |
+
}
|
22 |
+
}
|
vendor/composer/installers/src/Composer/Installers/SMFInstaller.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class SMFInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'Sources/{$name}/',
|
8 |
+
'theme' => 'Themes/{$name}/',
|
9 |
+
);
|
10 |
+
}
|
vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Plugin/theme installer for shopware
|
6 |
+
* @author Benjamin Boit
|
7 |
+
*/
|
8 |
+
class ShopwareInstaller extends BaseInstaller
|
9 |
+
{
|
10 |
+
protected $locations = array(
|
11 |
+
'backend-plugin' => 'engine/Shopware/Plugins/Local/Backend/{$name}/',
|
12 |
+
'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/',
|
13 |
+
'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/',
|
14 |
+
'theme' => 'templates/{$name}/'
|
15 |
+
);
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Transforms the names
|
19 |
+
* @param array $vars
|
20 |
+
* @return array
|
21 |
+
*/
|
22 |
+
public function inflectPackageVars($vars)
|
23 |
+
{
|
24 |
+
if ($vars['type'] === 'shopware-theme') {
|
25 |
+
return $this->correctThemeName($vars);
|
26 |
+
} else {
|
27 |
+
return $this->correctPluginName($vars);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Changes the name to a camelcased combination of vendor and name
|
33 |
+
* @param array $vars
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
private function correctPluginName($vars)
|
37 |
+
{
|
38 |
+
$camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
|
39 |
+
return strtoupper($matches[0][1]);
|
40 |
+
}, $vars['name']);
|
41 |
+
|
42 |
+
$vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName);
|
43 |
+
|
44 |
+
return $vars;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Changes the name to a underscore separated name
|
49 |
+
* @param array $vars
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
private function correctThemeName($vars)
|
53 |
+
{
|
54 |
+
$vars['name'] = str_replace('-', '_', $vars['name']);
|
55 |
+
|
56 |
+
return $vars;
|
57 |
+
}
|
58 |
+
}
|
vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
use Composer\Package\PackageInterface;
|
5 |
+
|
6 |
+
class SilverStripeInstaller extends BaseInstaller
|
7 |
+
{
|
8 |
+
protected $locations = array(
|
9 |
+
'module' => '{$name}/',
|
10 |
+
'theme' => 'themes/{$name}/',
|
11 |
+
);
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Return the install path based on package type.
|
15 |
+
*
|
16 |
+
* Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework
|
17 |
+
* must be installed to 'sapphire' and not 'framework' if the version is <3.0.0
|
18 |
+
*
|
19 |
+
* @param PackageInterface $package
|
20 |
+
* @param string $frameworkType
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getInstallPath(PackageInterface $package, $frameworkType = '')
|
24 |
+
{
|
25 |
+
if (
|
26 |
+
$package->getName() == 'silverstripe/framework'
|
27 |
+
&& preg_match('/^\d+\.\d+\.\d+/', $package->getVersion())
|
28 |
+
&& version_compare($package->getVersion(), '2.999.999') < 0
|
29 |
+
) {
|
30 |
+
return $this->templatePath($this->locations['module'], array('name' => 'sapphire'));
|
31 |
+
} else {
|
32 |
+
return parent::getInstallPath($package, $frameworkType);
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
+
}
|
vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Plugin installer for symfony 1.x
|
6 |
+
*
|
7 |
+
* @author Jérôme Tamarelle <jerome@tamarelle.net>
|
8 |
+
*/
|
9 |
+
class Symfony1Installer extends BaseInstaller
|
10 |
+
{
|
11 |
+
protected $locations = array(
|
12 |
+
'plugin' => 'plugins/{$name}/',
|
13 |
+
);
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Format package name to CamelCase
|
17 |
+
*/
|
18 |
+
public function inflectPackageVars($vars)
|
19 |
+
{
|
20 |
+
$vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) {
|
21 |
+
return strtoupper($matches[0][1]);
|
22 |
+
}, $vars['name']);
|
23 |
+
|
24 |
+
return $vars;
|
25 |
+
}
|
26 |
+
}
|
vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Extension installer for TYPO3 CMS
|
6 |
+
*
|
7 |
+
* @author Sascha Egerer <sascha.egerer@dkd.de>
|
8 |
+
*/
|
9 |
+
class TYPO3CmsInstaller extends BaseInstaller
|
10 |
+
{
|
11 |
+
protected $locations = array(
|
12 |
+
'extension' => 'typo3conf/ext/{$name}/',
|
13 |
+
);
|
14 |
+
}
|
vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* An installer to handle TYPO3 Flow specifics when installing packages.
|
6 |
+
*/
|
7 |
+
class TYPO3FlowInstaller extends BaseInstaller
|
8 |
+
{
|
9 |
+
protected $locations = array(
|
10 |
+
'package' => 'Packages/Application/{$name}/',
|
11 |
+
'framework' => 'Packages/Framework/{$name}/',
|
12 |
+
'plugin' => 'Packages/Plugins/{$name}/',
|
13 |
+
'site' => 'Packages/Sites/{$name}/',
|
14 |
+
'boilerplate' => 'Packages/Boilerplates/{$name}/',
|
15 |
+
'build' => 'Build/{$name}/',
|
16 |
+
);
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Modify the package name to be a TYPO3 Flow style key.
|
20 |
+
*
|
21 |
+
* @param array $vars
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function inflectPackageVars($vars)
|
25 |
+
{
|
26 |
+
$autoload = $this->package->getAutoload();
|
27 |
+
if (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) {
|
28 |
+
$namespace = key($autoload['psr-0']);
|
29 |
+
$vars['name'] = str_replace('\\', '.', $namespace);
|
30 |
+
}
|
31 |
+
if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) {
|
32 |
+
$namespace = key($autoload['psr-4']);
|
33 |
+
$vars['name'] = rtrim(str_replace('\\', '.', $namespace), '.');
|
34 |
+
}
|
35 |
+
|
36 |
+
return $vars;
|
37 |
+
}
|
38 |
+
}
|
vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class TheliaInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'local/modules/{$name}/',
|
8 |
+
'frontoffice-template' => 'templates/frontOffice/{$name}/',
|
9 |
+
'backoffice-template' => 'templates/backOffice/{$name}/',
|
10 |
+
'email-template' => 'templates/email/{$name}/',
|
11 |
+
);
|
12 |
+
}
|
vendor/composer/installers/src/Composer/Installers/TuskInstaller.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
/**
|
4 |
+
* Composer installer for 3rd party Tusk utilities
|
5 |
+
* @author Drew Ewing <drew@phenocode.com>
|
6 |
+
*/
|
7 |
+
class TuskInstaller extends BaseInstaller
|
8 |
+
{
|
9 |
+
protected $locations = array(
|
10 |
+
'task' => '.tusk/tasks/{$name}/',
|
11 |
+
'command' => '.tusk/commands/{$name}/',
|
12 |
+
'asset' => 'assets/tusk/{$name}/',
|
13 |
+
);
|
14 |
+
}
|
vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Composer\Installers;
|
4 |
+
|
5 |
+
class WHMCSInstaller extends BaseInstaller
|
6 |
+
{
|
7 |
+
protected $locations = array(
|
8 |
+
'gateway' => 'modules/gateways/{$name}/',
|
9 |
+
);
|
10 |
+
}
|
vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class WolfCMSInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'wolf/plugins/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class WordPressInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'plugin' => 'wp-content/plugins/{$name}/',
|
8 |
+
'theme' => 'wp-content/themes/{$name}/',
|
9 |
+
'muplugin' => 'wp-content/mu-plugins/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/ZendInstaller.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class ZendInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'library' => 'library/{$name}/',
|
8 |
+
'extra' => 'extras/library/{$name}/',
|
9 |
+
'module' => 'module/{$name}/',
|
10 |
+
);
|
11 |
+
}
|
vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class ZikulaInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'modules/{$vendor}-{$name}/',
|
8 |
+
'theme' => 'themes/{$vendor}-{$name}/'
|
9 |
+
);
|
10 |
+
}
|
vendor/composer/installers/src/bootstrap.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function includeIfExists($file)
|
3 |
+
{
|
4 |
+
if (file_exists($file)) {
|
5 |
+
return include $file;
|
6 |
+
}
|
7 |
+
}
|
8 |
+
if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) {
|
9 |
+
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
|
10 |
+
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
|
11 |
+
'php composer.phar install'.PHP_EOL);
|
12 |
+
}
|
13 |
+
return $loader;
|
vendor/composer/installers/tests/Composer/Installers/Test/AsgardInstallerTest.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Installers\AsgardInstaller;
|
5 |
+
use Composer\Package\Package;
|
6 |
+
use Composer\Composer;
|
7 |
+
|
8 |
+
class AsgardInstallerTest extends \PHPUnit_Framework_TestCase
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @var OctoberInstaller
|
12 |
+
*/
|
13 |
+
private $installer;
|
14 |
+
|
15 |
+
public function setUp()
|
16 |
+
{
|
17 |
+
$this->installer = new AsgardInstaller(
|
18 |
+
new Package('NyanCat', '4.2', '4.2'),
|
19 |
+
new Composer()
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @dataProvider packageNameInflectionProvider
|
25 |
+
*/
|
26 |
+
public function testInflectPackageVars($type, $name, $expected)
|
27 |
+
{
|
28 |
+
$this->assertEquals(
|
29 |
+
$this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)),
|
30 |
+
array('name' => $expected, 'type' => $type)
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function packageNameInflectionProvider()
|
35 |
+
{
|
36 |
+
return array(
|
37 |
+
array(
|
38 |
+
'asgard-module',
|
39 |
+
'asgard-module',
|
40 |
+
'Asgard'
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'asgard-module',
|
44 |
+
'blog',
|
45 |
+
'Blog'
|
46 |
+
),
|
47 |
+
// tests that exactly one '-theme' is cut off
|
48 |
+
array(
|
49 |
+
'asgard-theme',
|
50 |
+
'some-theme-theme',
|
51 |
+
'Some-theme',
|
52 |
+
),
|
53 |
+
// tests that names without '-theme' suffix stay valid
|
54 |
+
array(
|
55 |
+
'asgard-theme',
|
56 |
+
'someothertheme',
|
57 |
+
'Someothertheme',
|
58 |
+
),
|
59 |
+
);
|
60 |
+
}
|
61 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Installers\CakePHPInstaller;
|
5 |
+
use Composer\Repository\RepositoryManager;
|
6 |
+
use Composer\Repository\InstalledArrayRepository;
|
7 |
+
use Composer\Package\Package;
|
8 |
+
use Composer\Package\RootPackage;
|
9 |
+
use Composer\Package\Link;
|
10 |
+
use Composer\Package\Version\VersionParser;
|
11 |
+
use Composer\Composer;
|
12 |
+
use Composer\Config;
|
13 |
+
|
14 |
+
class CakePHPInstallerTest extends TestCase
|
15 |
+
{
|
16 |
+
private $composer;
|
17 |
+
private $io;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* setUp
|
21 |
+
*
|
22 |
+
* @return void
|
23 |
+
*/
|
24 |
+
public function setUp()
|
25 |
+
{
|
26 |
+
$this->package = new Package('CamelCased', '1.0', '1.0');
|
27 |
+
$this->io = $this->getMock('Composer\IO\PackageInterface');
|
28 |
+
$this->composer = new Composer();
|
29 |
+
$this->composer->setConfig(new Config(false));
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* testInflectPackageVars
|
34 |
+
*
|
35 |
+
* @return void
|
36 |
+
*/
|
37 |
+
public function testInflectPackageVars()
|
38 |
+
{
|
39 |
+
$installer = new CakePHPInstaller($this->package, $this->composer);
|
40 |
+
$result = $installer->inflectPackageVars(array('name' => 'CamelCased'));
|
41 |
+
$this->assertEquals($result, array('name' => 'CamelCased'));
|
42 |
+
|
43 |
+
$installer = new CakePHPInstaller($this->package, $this->composer);
|
44 |
+
$result = $installer->inflectPackageVars(array('name' => 'with-dash'));
|
45 |
+
$this->assertEquals($result, array('name' => 'WithDash'));
|
46 |
+
|
47 |
+
$installer = new CakePHPInstaller($this->package, $this->composer);
|
48 |
+
$result = $installer->inflectPackageVars(array('name' => 'with_underscore'));
|
49 |
+
$this->assertEquals($result, array('name' => 'WithUnderscore'));
|
50 |
+
|
51 |
+
$installer = new CakePHPInstaller($this->package, $this->composer);
|
52 |
+
$result = $installer->inflectPackageVars(array('name' => 'cake/acl'));
|
53 |
+
$this->assertEquals($result, array('name' => 'Cake/Acl'));
|
54 |
+
|
55 |
+
$installer = new CakePHPInstaller($this->package, $this->composer);
|
56 |
+
$result = $installer->inflectPackageVars(array('name' => 'cake/debug-kit'));
|
57 |
+
$this->assertEquals($result, array('name' => 'Cake/DebugKit'));
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Test getLocations returning appropriate values based on CakePHP version
|
62 |
+
*
|
63 |
+
*/
|
64 |
+
public function testGetLocations() {
|
65 |
+
$package = new RootPackage('CamelCased', '1.0', '1.0');
|
66 |
+
$composer = $this->composer;
|
67 |
+
$rm = new RepositoryManager(
|
68 |
+
$this->getMock('Composer\IO\IOInterface'),
|
69 |
+
$this->getMock('Composer\Config')
|
70 |
+
);
|
71 |
+
$composer->setRepositoryManager($rm);
|
72 |
+
$installer = new CakePHPInstaller($package, $composer);
|
73 |
+
|
74 |
+
// 2.0 < cakephp < 3.0
|
75 |
+
$this->setCakephpVersion($rm, '2.0.0');
|
76 |
+
$result = $installer->getLocations();
|
77 |
+
$this->assertContains('Plugin/', $result['plugin']);
|
78 |
+
|
79 |
+
$this->setCakephpVersion($rm, '2.5.9');
|
80 |
+
$result = $installer->getLocations();
|
81 |
+
$this->assertContains('Plugin/', $result['plugin']);
|
82 |
+
|
83 |
+
$this->setCakephpVersion($rm, '~2.5');
|
84 |
+
$result = $installer->getLocations();
|
85 |
+
$this->assertContains('Plugin/', $result['plugin']);
|
86 |
+
|
87 |
+
// special handling for 2.x versions when 3.x is still in development
|
88 |
+
$this->setCakephpVersion($rm, 'dev-master');
|
89 |
+
$result = $installer->getLocations();
|
90 |
+
$this->assertContains('Plugin/', $result['plugin']);
|
91 |
+
|
92 |
+
$this->setCakephpVersion($rm, '>=2.5');
|
93 |
+
$result = $installer->getLocations();
|
94 |
+
$this->assertContains('Plugin/', $result['plugin']);
|
95 |
+
|
96 |
+
// cakephp >= 3.0
|
97 |
+
$this->setCakephpVersion($rm, '3.0.*-dev');
|
98 |
+
$result = $installer->getLocations();
|
99 |
+
$this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']);
|
100 |
+
|
101 |
+
$this->setCakephpVersion($rm, '~8.8');
|
102 |
+
$result = $installer->getLocations();
|
103 |
+
$this->assertEquals('vendor/{$vendor}/{$name}/', $result['plugin']);
|
104 |
+
}
|
105 |
+
|
106 |
+
protected function setCakephpVersion($rm, $version) {
|
107 |
+
$parser = new VersionParser();
|
108 |
+
list(, $version) = explode(' ', $parser->parseConstraints($version));
|
109 |
+
$installed = new InstalledArrayRepository();
|
110 |
+
$package = new Package('cakephp/cakephp', $version, $version);
|
111 |
+
$installed->addPackage($package);
|
112 |
+
$rm->setLocalRepository($installed);
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Installers\DokuWikiInstaller;
|
5 |
+
use Composer\Package\Package;
|
6 |
+
use Composer\Composer;
|
7 |
+
|
8 |
+
class DokuWikiInstallerTest extends \PHPUnit_Framework_TestCase
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @var DokuWikiInstaller
|
12 |
+
*/
|
13 |
+
private $installer;
|
14 |
+
|
15 |
+
public function setUp()
|
16 |
+
{
|
17 |
+
$this->installer = new DokuWikiInstaller(
|
18 |
+
new Package('NyanCat', '4.2', '4.2'),
|
19 |
+
new Composer()
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @dataProvider packageNameInflectionProvider
|
25 |
+
*/
|
26 |
+
public function testInflectPackageVars($type, $name, $expected)
|
27 |
+
{
|
28 |
+
$this->assertEquals(
|
29 |
+
$this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)),
|
30 |
+
array('name' => $expected, 'type'=>$type)
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function packageNameInflectionProvider()
|
35 |
+
{
|
36 |
+
return array(
|
37 |
+
array(
|
38 |
+
'dokuwiki-plugin',
|
39 |
+
'dokuwiki-test-plugin',
|
40 |
+
'test',
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'dokuwiki-plugin',
|
44 |
+
'test-plugin',
|
45 |
+
'test',
|
46 |
+
),
|
47 |
+
array(
|
48 |
+
'dokuwiki-plugin',
|
49 |
+
'dokuwiki_test',
|
50 |
+
'test',
|
51 |
+
),
|
52 |
+
array(
|
53 |
+
'dokuwiki-plugin',
|
54 |
+
'test',
|
55 |
+
'test',
|
56 |
+
),
|
57 |
+
array(
|
58 |
+
'dokuwiki-plugin',
|
59 |
+
'test-template',
|
60 |
+
'test-template',
|
61 |
+
),
|
62 |
+
array(
|
63 |
+
'dokuwiki-template',
|
64 |
+
'dokuwiki-test-template',
|
65 |
+
'test',
|
66 |
+
),
|
67 |
+
array(
|
68 |
+
'dokuwiki-template',
|
69 |
+
'test-template',
|
70 |
+
'test',
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'dokuwiki-template',
|
74 |
+
'dokuwiki_test',
|
75 |
+
'test',
|
76 |
+
),
|
77 |
+
array(
|
78 |
+
'dokuwiki-template',
|
79 |
+
'test',
|
80 |
+
'test',
|
81 |
+
),
|
82 |
+
array(
|
83 |
+
'dokuwiki-template',
|
84 |
+
'test-plugin',
|
85 |
+
'test-plugin',
|
86 |
+
),
|
87 |
+
);
|
88 |
+
}
|
89 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Composer;
|
5 |
+
use Composer\Installers\GravInstaller;
|
6 |
+
|
7 |
+
class GravInstallerTest extends TestCase
|
8 |
+
{
|
9 |
+
/* @var \Composer\Composer */
|
10 |
+
protected $composer;
|
11 |
+
|
12 |
+
public function setUp()
|
13 |
+
{
|
14 |
+
$this->composer = new Composer();
|
15 |
+
}
|
16 |
+
|
17 |
+
public function testInflectPackageVars()
|
18 |
+
{
|
19 |
+
$package = $this->getPackage('vendor/name', '0.0.0');
|
20 |
+
$installer = new GravInstaller($package, $this->composer);
|
21 |
+
$packageVars = $this->getPackageVars($package);
|
22 |
+
|
23 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => 'test')));
|
24 |
+
$this->assertEquals('test', $result['name']);
|
25 |
+
|
26 |
+
foreach ($installer->getLocations() as $name => $location) {
|
27 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test")));
|
28 |
+
$this->assertEquals('test', $result['name']);
|
29 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-$name")));
|
30 |
+
$this->assertEquals('test', $result['name']);
|
31 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test-test")));
|
32 |
+
$this->assertEquals('test-test', $result['name']);
|
33 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-test-$name")));
|
34 |
+
$this->assertEquals('test-test', $result['name']);
|
35 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test")));
|
36 |
+
$this->assertEquals('test', $result['name']);
|
37 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-$name")));
|
38 |
+
$this->assertEquals('test', $result['name']);
|
39 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test-test")));
|
40 |
+
$this->assertEquals('test-test', $result['name']);
|
41 |
+
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-test-$name")));
|
42 |
+
$this->assertEquals('test-test', $result['name']);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param $package \Composer\Package\PackageInterface
|
48 |
+
*/
|
49 |
+
public function getPackageVars($package)
|
50 |
+
{
|
51 |
+
$type = $package->getType();
|
52 |
+
|
53 |
+
$prettyName = $package->getPrettyName();
|
54 |
+
if (strpos($prettyName, '/') !== false) {
|
55 |
+
list($vendor, $name) = explode('/', $prettyName);
|
56 |
+
} else {
|
57 |
+
$vendor = '';
|
58 |
+
$name = $prettyName;
|
59 |
+
}
|
60 |
+
|
61 |
+
return compact('name', 'vendor', 'type');
|
62 |
+
}
|
63 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php
ADDED
@@ -0,0 +1,422 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Installers\Installer;
|
5 |
+
use Composer\Util\Filesystem;
|
6 |
+
use Composer\Package\Package;
|
7 |
+
use Composer\Package\RootPackage;
|
8 |
+
use Composer\Composer;
|
9 |
+
use Composer\Config;
|
10 |
+
|
11 |
+
class InstallerTest extends TestCase
|
12 |
+
{
|
13 |
+
private $composer;
|
14 |
+
private $config;
|
15 |
+
private $vendorDir;
|
16 |
+
private $binDir;
|
17 |
+
private $dm;
|
18 |
+
private $repository;
|
19 |
+
private $io;
|
20 |
+
private $fs;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* setUp
|
24 |
+
*
|
25 |
+
* @return void
|
26 |
+
*/
|
27 |
+
public function setUp()
|
28 |
+
{
|
29 |
+
$this->fs = new Filesystem;
|
30 |
+
|
31 |
+
$this->composer = new Composer();
|
32 |
+
$this->config = new Config();
|
33 |
+
$this->composer->setConfig($this->config);
|
34 |
+
|
35 |
+
$this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor';
|
36 |
+
$this->ensureDirectoryExistsAndClear($this->vendorDir);
|
37 |
+
|
38 |
+
$this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin';
|
39 |
+
$this->ensureDirectoryExistsAndClear($this->binDir);
|
40 |
+
|
41 |
+
$this->config->merge(array(
|
42 |
+
'config' => array(
|
43 |
+
'vendor-dir' => $this->vendorDir,
|
44 |
+
'bin-dir' => $this->binDir,
|
45 |
+
),
|
46 |
+
));
|
47 |
+
|
48 |
+
$this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
49 |
+
->disableOriginalConstructor()
|
50 |
+
->getMock();
|
51 |
+
$this->composer->setDownloadManager($this->dm);
|
52 |
+
|
53 |
+
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
|
54 |
+
$this->io = $this->getMock('Composer\IO\IOInterface');
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* tearDown
|
59 |
+
*
|
60 |
+
* @return void
|
61 |
+
*/
|
62 |
+
public function tearDown()
|
63 |
+
{
|
64 |
+
$this->fs->removeDirectory($this->vendorDir);
|
65 |
+
$this->fs->removeDirectory($this->binDir);
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* testSupports
|
70 |
+
*
|
71 |
+
* @return void
|
72 |
+
*
|
73 |
+
* @dataProvider dataForTestSupport
|
74 |
+
*/
|
75 |
+
public function testSupports($type, $expected)
|
76 |
+
{
|
77 |
+
$installer = new Installer($this->io, $this->composer);
|
78 |
+
$this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type));
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* dataForTestSupport
|
83 |
+
*/
|
84 |
+
public function dataForTestSupport()
|
85 |
+
{
|
86 |
+
return array(
|
87 |
+
array('agl-module', true),
|
88 |
+
array('aimeos-extension', true),
|
89 |
+
array('annotatecms-module', true),
|
90 |
+
array('annotatecms-component', true),
|
91 |
+
array('annotatecms-service', true),
|
92 |
+
array('bitrix-module', true),
|
93 |
+
array('bitrix-component', true),
|
94 |
+
array('bitrix-theme', true),
|
95 |
+
array('cakephp', false),
|
96 |
+
array('cakephp-', false),
|
97 |
+
array('cakephp-app', false),
|
98 |
+
array('cakephp-plugin', true),
|
99 |
+
array('chef-cookbook', true),
|
100 |
+
array('chef-role', true),
|
101 |
+
array('codeigniter-app', false),
|
102 |
+
array('codeigniter-library', true),
|
103 |
+
array('codeigniter-third-party', true),
|
104 |
+
array('codeigniter-module', true),
|
105 |
+
array('concrete5-block', true),
|
106 |
+
array('concrete5-package', true),
|
107 |
+
array('concrete5-theme', true),
|
108 |
+
array('concrete5-update', true),
|
109 |
+
array('craft-plugin', true),
|
110 |
+
array('croogo-plugin', true),
|
111 |
+
array('croogo-theme', true),
|
112 |
+
array('dokuwiki-plugin', true),
|
113 |
+
array('dokuwiki-template', true),
|
114 |
+
array('drupal-module', true),
|
115 |
+
array('dolibarr-module', true),
|
116 |
+
array('elgg-plugin', true),
|
117 |
+
array('fuel-module', true),
|
118 |
+
array('fuel-package', true),
|
119 |
+
array('fuel-theme', true),
|
120 |
+
array('fuelphp-component', true),
|
121 |
+
array('hurad-plugin', true),
|
122 |
+
array('hurad-theme', true),
|
123 |
+
array('joomla-library', true),
|
124 |
+
array('kirby-plugin', true),
|
125 |
+
array('kohana-module', true),
|
126 |
+
array('laravel-library', true),
|
127 |
+
array('lithium-library', true),
|
128 |
+
array('magento-library', true),
|
129 |
+
array('mako-package', true),
|
130 |
+
array('modxevo-snippet', true),
|
131 |
+
array('modxevo-plugin', true),
|
132 |
+
array('modxevo-module', true),
|
133 |
+
array('modxevo-template', true),
|
134 |
+
array('modxevo-lib', true),
|
135 |
+
array('mediawiki-extension', true),
|
136 |
+
array('mediawiki-skin', true),
|
137 |
+
array('microweber-module', true),
|
138 |
+
array('modulework-module', true),
|
139 |
+
array('moodle-mod', true),
|
140 |
+
array('october-module', true),
|
141 |
+
array('october-plugin', true),
|
142 |
+
array('piwik-plugin', true),
|
143 |
+
array('phpbb-extension', true),
|
144 |
+
array('pimcore-plugin', true),
|
145 |
+
array('ppi-module', true),
|
146 |
+
array('prestashop-module', true),
|
147 |
+
array('prestashop-theme', true),
|
148 |
+
array('puppet-module', true),
|
149 |
+
array('redaxo-addon', true),
|
150 |
+
array('redaxo-bestyle-plugin', true),
|
151 |
+
array('roundcube-plugin', true),
|
152 |
+
array('shopware-backend-plugin', true),
|
153 |
+
array('shopware-core-plugin', true),
|
154 |
+
array('shopware-frontend-plugin', true),
|
155 |
+
array('shopware-theme', true),
|
156 |
+
array('silverstripe-module', true),
|
157 |
+
array('silverstripe-theme', true),
|
158 |
+
array('smf-module', true),
|
159 |
+
array('smf-theme', true),
|
160 |
+
array('symfony1-plugin', true),
|
161 |
+
array('thelia-module', true),
|
162 |
+
array('thelia-frontoffice-template', true),
|
163 |
+
array('thelia-backoffice-template', true),
|
164 |
+
array('thelia-email-template', true),
|
165 |
+
array('tusk-task', true),
|
166 |
+
array('tusk-asset', true),
|
167 |
+
array('typo3-flow-plugin', true),
|
168 |
+
array('typo3-cms-extension', true),
|
169 |
+
array('whmcs-gateway', true),
|
170 |
+
array('wolfcms-plugin', true),
|
171 |
+
array('wordpress-plugin', true),
|
172 |
+
array('wordpress-core', false),
|
173 |
+
array('zend-library', true),
|
174 |
+
array('zikula-module', true),
|
175 |
+
array('zikula-theme', true),
|
176 |
+
);
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* testInstallPath
|
181 |
+
*
|
182 |
+
* @dataProvider dataForTestInstallPath
|
183 |
+
*/
|
184 |
+
public function testInstallPath($type, $path, $name, $version = '1.0.0')
|
185 |
+
{
|
186 |
+
$installer = new Installer($this->io, $this->composer);
|
187 |
+
$package = new Package($name, $version, $version);
|
188 |
+
|
189 |
+
$package->setType($type);
|
190 |
+
$result = $installer->getInstallPath($package);
|
191 |
+
$this->assertEquals($path, $result);
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* dataFormTestInstallPath
|
196 |
+
*/
|
197 |
+
public function dataForTestInstallPath()
|
198 |
+
{
|
199 |
+
return array(
|
200 |
+
array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),
|
201 |
+
array('aimeos-extension', 'ext/ai-test/', 'author/ai-test'),
|
202 |
+
array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
|
203 |
+
array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
|
204 |
+
array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
|
205 |
+
array('bitrix-module', 'local/modules/my_module/', 'author/my_module'),
|
206 |
+
array('bitrix-component', 'local/components/my_component/', 'author/my_component'),
|
207 |
+
array('bitrix-theme', 'local/templates/my_theme/', 'author/my_theme'),
|
208 |
+
array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
|
209 |
+
array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),
|
210 |
+
array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),
|
211 |
+
array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
|
212 |
+
array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
|
213 |
+
array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'),
|
214 |
+
array('concrete5-package', 'packages/concrete5_package/', 'remo/concrete5_package'),
|
215 |
+
array('concrete5-theme', 'themes/concrete5_theme/', 'remo/concrete5_theme'),
|
216 |
+
array('concrete5-update', 'updates/concrete5/', 'concrete5/concrete5'),
|
217 |
+
array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'),
|
218 |
+
array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),
|
219 |
+
array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),
|
220 |
+
array('dokuwiki-plugin', 'lib/plugins/someplugin/', 'author/someplugin'),
|
221 |
+
array('dokuwiki-template', 'lib/tpl/sometemplate/', 'author/sometemplate'),
|
222 |
+
array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'),
|
223 |
+
array('drupal-module', 'modules/my_module/', 'shama/my_module'),
|
224 |
+
array('drupal-theme', 'themes/my_module/', 'shama/my_module'),
|
225 |
+
array('drupal-profile', 'profiles/my_module/', 'shama/my_module'),
|
226 |
+
array('drupal-drush', 'drush/my_module/', 'shama/my_module'),
|
227 |
+
array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'),
|
228 |
+
array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),
|
229 |
+
array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),
|
230 |
+
array('fuel-theme', 'fuel/app/themes/theme/', 'fuel/theme'),
|
231 |
+
array('fuelphp-component', 'components/demo/', 'fuelphp/demo'),
|
232 |
+
array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'),
|
233 |
+
array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'),
|
234 |
+
array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
|
235 |
+
array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'),
|
236 |
+
array('kohana-module', 'modules/my_package/', 'shama/my_package'),
|
237 |
+
array('laravel-library', 'libraries/my_package/', 'shama/my_package'),
|
238 |
+
array('lithium-library', 'libraries/li3_test/', 'user/li3_test'),
|
239 |
+
array('magento-library', 'lib/foo/', 'test/foo'),
|
240 |
+
array('modxevo-snippet', 'assets/snippets/my_snippet/', 'shama/my_snippet'),
|
241 |
+
array('modxevo-plugin', 'assets/plugins/my_plugin/', 'shama/my_plugin'),
|
242 |
+
array('modxevo-module', 'assets/modules/my_module/', 'shama/my_module'),
|
243 |
+
array('modxevo-template', 'assets/templates/my_template/', 'shama/my_template'),
|
244 |
+
array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'),
|
245 |
+
array('mako-package', 'app/packages/my_package/', 'shama/my_package'),
|
246 |
+
array('mediawiki-extension', 'extensions/APC/', 'author/APC'),
|
247 |
+
array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'),
|
248 |
+
array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'),
|
249 |
+
array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi'),
|
250 |
+
array('mediawiki-skin', 'skins/someskin/', 'author/someskin-skin'),
|
251 |
+
array('mediawiki-skin', 'skins/someskin/', 'author/someskin'),
|
252 |
+
array('microweber-module', 'userfiles/modules/my-thing/', 'author/my-thing-module'),
|
253 |
+
array('modulework-module', 'modules/my_package/', 'shama/my_package'),
|
254 |
+
array('moodle-mod', 'mod/my_package/', 'shama/my_package'),
|
255 |
+
array('october-module', 'modules/my_plugin/', 'shama/my_plugin'),
|
256 |
+
array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
|
257 |
+
array('october-theme', 'themes/my_theme/', 'shama/my_theme'),
|
258 |
+
array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
|
259 |
+
array('prestashop-module', 'modules/a-module/', 'vendor/a-module'),
|
260 |
+
array('prestashop-theme', 'themes/a-theme/', 'vendor/a-theme'),
|
261 |
+
array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
|
262 |
+
array('phpbb-style', 'styles/foo/', 'test/foo'),
|
263 |
+
array('phpbb-language', 'language/foo/', 'test/foo'),
|
264 |
+
array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'),
|
265 |
+
array('ppi-module', 'modules/foo/', 'test/foo'),
|
266 |
+
array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'),
|
267 |
+
array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'),
|
268 |
+
array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'),
|
269 |
+
array('roundcube-plugin', 'plugins/base/', 'test/base'),
|
270 |
+
array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'),
|
271 |
+
array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'),
|
272 |
+
array('shopware-core-plugin', 'engine/Shopware/Plugins/Local/Core/ShamaMyCorePlugin/', 'shama/my-core-plugin'),
|
273 |
+
array('shopware-frontend-plugin', 'engine/Shopware/Plugins/Local/Frontend/ShamaMyFrontendPlugin/', 'shama/my-frontend-plugin'),
|
274 |
+
array('shopware-theme', 'templates/my_theme/', 'shama/my-theme'),
|
275 |
+
array('silverstripe-module', 'my_module/', 'shama/my_module'),
|
276 |
+
array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'),
|
277 |
+
array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'),
|
278 |
+
array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),
|
279 |
+
array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),
|
280 |
+
array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
|
281 |
+
array('smf-module', 'Sources/my_module/', 'shama/my_module'),
|
282 |
+
array('smf-theme', 'Themes/my_theme/', 'shama/my_theme'),
|
283 |
+
array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
|
284 |
+
array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
|
285 |
+
array('thelia-module', 'local/modules/my_module/', 'shama/my_module'),
|
286 |
+
array('thelia-frontoffice-template', 'templates/frontOffice/my_template_fo/', 'shama/my_template_fo'),
|
287 |
+
array('thelia-backoffice-template', 'templates/backOffice/my_template_bo/', 'shama/my_template_bo'),
|
288 |
+
array('thelia-email-template', 'templates/email/my_template_email/', 'shama/my_template_email'),
|
289 |
+
array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'),
|
290 |
+
array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),
|
291 |
+
array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),
|
292 |
+
array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),
|
293 |
+
array('whmcs-gateway', 'modules/gateways/gateway_name/', 'vendor/gateway_name'),
|
294 |
+
array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'),
|
295 |
+
array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),
|
296 |
+
array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),
|
297 |
+
array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),
|
298 |
+
array('zikula-module', 'modules/my-test_module/', 'my/test_module'),
|
299 |
+
array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'),
|
300 |
+
);
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* testGetCakePHPInstallPathException
|
305 |
+
*
|
306 |
+
* @return void
|
307 |
+
*
|
308 |
+
* @expectedException \InvalidArgumentException
|
309 |
+
*/
|
310 |
+
public function testGetCakePHPInstallPathException()
|
311 |
+
{
|
312 |
+
$installer = new Installer($this->io, $this->composer);
|
313 |
+
$package = new Package('shama/ftp', '1.0.0', '1.0.0');
|
314 |
+
|
315 |
+
$package->setType('cakephp-whoops');
|
316 |
+
$result = $installer->getInstallPath($package);
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* testCustomInstallPath
|
321 |
+
*/
|
322 |
+
public function testCustomInstallPath()
|
323 |
+
{
|
324 |
+
$installer = new Installer($this->io, $this->composer);
|
325 |
+
$package = new Package('shama/ftp', '1.0.0', '1.0.0');
|
326 |
+
$package->setType('cakephp-plugin');
|
327 |
+
$consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
|
328 |
+
$this->composer->setPackage($consumerPackage);
|
329 |
+
$consumerPackage->setExtra(array(
|
330 |
+
'installer-paths' => array(
|
331 |
+
'my/custom/path/{$name}/' => array(
|
332 |
+
'shama/ftp',
|
333 |
+
'foo/bar',
|
334 |
+
),
|
335 |
+
),
|
336 |
+
));
|
337 |
+
$result = $installer->getInstallPath($package);
|
338 |
+
$this->assertEquals('my/custom/path/Ftp/', $result);
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* testCustomInstallerName
|
343 |
+
*/
|
344 |
+
public function testCustomInstallerName()
|
345 |
+
{
|
346 |
+
$installer = new Installer($this->io, $this->composer);
|
347 |
+
$package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0');
|
348 |
+
$package->setType('cakephp-plugin');
|
349 |
+
$package->setExtra(array(
|
350 |
+
'installer-name' => 'FTP',
|
351 |
+
));
|
352 |
+
$result = $installer->getInstallPath($package);
|
353 |
+
$this->assertEquals('Plugin/FTP/', $result);
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* testCustomTypePath
|
358 |
+
*/
|
359 |
+
public function testCustomTypePath()
|
360 |
+
{
|
361 |
+
$installer = new Installer($this->io, $this->composer);
|
362 |
+
$package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0');
|
363 |
+
$package->setType('wordpress-plugin');
|
364 |
+
$consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
|
365 |
+
$this->composer->setPackage($consumerPackage);
|
366 |
+
$consumerPackage->setExtra(array(
|
367 |
+
'installer-paths' => array(
|
368 |
+
'my/custom/path/{$name}/' => array(
|
369 |
+
'type:wordpress-plugin'
|
370 |
+
),
|
371 |
+
),
|
372 |
+
));
|
373 |
+
$result = $installer->getInstallPath($package);
|
374 |
+
$this->assertEquals('my/custom/path/my_plugin/', $result);
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* testNoVendorName
|
379 |
+
*/
|
380 |
+
public function testNoVendorName()
|
381 |
+
{
|
382 |
+
$installer = new Installer($this->io, $this->composer);
|
383 |
+
$package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0');
|
384 |
+
|
385 |
+
$package->setType('symfony1-plugin');
|
386 |
+
$result = $installer->getInstallPath($package);
|
387 |
+
$this->assertEquals('plugins/sfPhpunitPlugin/', $result);
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* testTypo3Inflection
|
392 |
+
*/
|
393 |
+
public function testTypo3Inflection()
|
394 |
+
{
|
395 |
+
$installer = new Installer($this->io, $this->composer);
|
396 |
+
$package = new Package('typo3/fluid', '1.0.0', '1.0.0');
|
397 |
+
|
398 |
+
$package->setAutoload(array(
|
399 |
+
'psr-0' => array(
|
400 |
+
'TYPO3\\Fluid' => 'Classes',
|
401 |
+
),
|
402 |
+
));
|
403 |
+
|
404 |
+
$package->setType('typo3-flow-package');
|
405 |
+
$result = $installer->getInstallPath($package);
|
406 |
+
$this->assertEquals('Packages/Application/TYPO3.Fluid/', $result);
|
407 |
+
}
|
408 |
+
|
409 |
+
public function testUninstallAndDeletePackageFromLocalRepo()
|
410 |
+
{
|
411 |
+
$package = new Package('foo', '1.0.0', '1.0.0');
|
412 |
+
|
413 |
+
$installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer));
|
414 |
+
$installer->expects($this->once())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo'));
|
415 |
+
|
416 |
+
$repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
|
417 |
+
$repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true));
|
418 |
+
$repo->expects($this->once())->method('removePackage')->with($package);
|
419 |
+
|
420 |
+
$installer->uninstall($repo, $package);
|
421 |
+
}
|
422 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Installers\MediaWikiInstaller;
|
5 |
+
use Composer\Package\Package;
|
6 |
+
use Composer\Composer;
|
7 |
+
|
8 |
+
class MediaWikiInstallerTest extends \PHPUnit_Framework_TestCase
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @var MediaWikiInstaller
|
12 |
+
*/
|
13 |
+
private $installer;
|
14 |
+
|
15 |
+
public function setUp()
|
16 |
+
{
|
17 |
+
$this->installer = new MediaWikiInstaller(
|
18 |
+
new Package('NyanCat', '4.2', '4.2'),
|
19 |
+
new Composer()
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @dataProvider packageNameInflectionProvider
|
25 |
+
*/
|
26 |
+
public function testInflectPackageVars($type, $name, $expected)
|
27 |
+
{
|
28 |
+
$this->assertEquals(
|
29 |
+
$this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)),
|
30 |
+
array('name' => $expected, 'type'=>$type)
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function packageNameInflectionProvider()
|
35 |
+
{
|
36 |
+
return array(
|
37 |
+
array(
|
38 |
+
'mediawiki-extension',
|
39 |
+
'sub-page-list',
|
40 |
+
'SubPageList',
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'mediawiki-extension',
|
44 |
+
'sub-page-list-extension',
|
45 |
+
'SubPageList',
|
46 |
+
),
|
47 |
+
array(
|
48 |
+
'mediawiki-extension',
|
49 |
+
'semantic-mediawiki',
|
50 |
+
'SemanticMediawiki',
|
51 |
+
),
|
52 |
+
// tests that exactly one '-skin' is cut off, and that skins do not get ucwords treatment like extensions
|
53 |
+
array(
|
54 |
+
'mediawiki-skin',
|
55 |
+
'some-skin-skin',
|
56 |
+
'some-skin',
|
57 |
+
),
|
58 |
+
// tests that names without '-skin' suffix stay valid
|
59 |
+
array(
|
60 |
+
'mediawiki-skin',
|
61 |
+
'someotherskin',
|
62 |
+
'someotherskin',
|
63 |
+
),
|
64 |
+
);
|
65 |
+
}
|
66 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Installers\OctoberInstaller;
|
5 |
+
use Composer\Package\Package;
|
6 |
+
use Composer\Composer;
|
7 |
+
|
8 |
+
class OctoberInstallerTest extends \PHPUnit_Framework_TestCase
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @var OctoberInstaller
|
12 |
+
*/
|
13 |
+
private $installer;
|
14 |
+
|
15 |
+
public function setUp()
|
16 |
+
{
|
17 |
+
$this->installer = new OctoberInstaller(
|
18 |
+
new Package('NyanCat', '4.2', '4.2'),
|
19 |
+
new Composer()
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @dataProvider packageNameInflectionProvider
|
25 |
+
*/
|
26 |
+
public function testInflectPackageVars($type, $name, $expected)
|
27 |
+
{
|
28 |
+
$this->assertEquals(
|
29 |
+
$this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)),
|
30 |
+
array('name' => $expected, 'type' => $type)
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function packageNameInflectionProvider()
|
35 |
+
{
|
36 |
+
return array(
|
37 |
+
array(
|
38 |
+
'october-plugin',
|
39 |
+
'subpagelist',
|
40 |
+
'subpagelist',
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'october-plugin',
|
44 |
+
'subpagelist-plugin',
|
45 |
+
'subpagelist',
|
46 |
+
),
|
47 |
+
array(
|
48 |
+
'october-plugin',
|
49 |
+
'semanticoctober',
|
50 |
+
'semanticoctober',
|
51 |
+
),
|
52 |
+
// tests that exactly one '-theme' is cut off
|
53 |
+
array(
|
54 |
+
'october-theme',
|
55 |
+
'some-theme-theme',
|
56 |
+
'some-theme',
|
57 |
+
),
|
58 |
+
// tests that names without '-theme' suffix stay valid
|
59 |
+
array(
|
60 |
+
'october-theme',
|
61 |
+
'someothertheme',
|
62 |
+
'someothertheme',
|
63 |
+
),
|
64 |
+
);
|
65 |
+
}
|
66 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Installers\PimcoreInstaller;
|
5 |
+
use Composer\Package\Package;
|
6 |
+
use Composer\Composer;
|
7 |
+
|
8 |
+
class PimcoreInstallerTest extends TestCase
|
9 |
+
{
|
10 |
+
private $composer;
|
11 |
+
private $io;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* setUp
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
public function setUp()
|
19 |
+
{
|
20 |
+
$this->package = new Package('CamelCased', '1.0', '1.0');
|
21 |
+
$this->io = $this->getMock('Composer\IO\PackageInterface');
|
22 |
+
$this->composer = new Composer();
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* testInflectPackageVars
|
27 |
+
*
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
public function testInflectPackageVars()
|
31 |
+
{
|
32 |
+
$installer = new PimcoreInstaller($this->package, $this->composer);
|
33 |
+
$result = $installer->inflectPackageVars(array('name' => 'CamelCased'));
|
34 |
+
$this->assertEquals($result, array('name' => 'CamelCased'));
|
35 |
+
|
36 |
+
$installer = new PimcoreInstaller($this->package, $this->composer);
|
37 |
+
$result = $installer->inflectPackageVars(array('name' => 'with-dash'));
|
38 |
+
$this->assertEquals($result, array('name' => 'WithDash'));
|
39 |
+
|
40 |
+
$installer = new PimcoreInstaller($this->package, $this->composer);
|
41 |
+
$result = $installer->inflectPackageVars(array('name' => 'with_underscore'));
|
42 |
+
$this->assertEquals($result, array('name' => 'WithUnderscore'));
|
43 |
+
}
|
44 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers\Test;
|
3 |
+
|
4 |
+
use Composer\Composer;
|
5 |
+
use Composer\Installers\PiwikInstaller;
|
6 |
+
use Composer\Package\Package;
|
7 |
+
use Composer\Package\PackageInterface;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class PiwikInstallerTest
|
11 |
+
*
|
12 |
+
* @package Composer\Installers\Test
|
13 |
+
*/
|
14 |
+
class PiwikInstallerTest extends TestCase
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* @varComposer
|
18 |
+
*/
|
19 |
+
private $composer;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var PackageInterface
|
23 |
+
*/
|
24 |
+
private $io;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @var Package
|
28 |
+
*/
|
29 |
+
private $package;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* setUp
|
33 |
+
*
|
34 |
+
* @return void
|
35 |
+
*/
|
36 |
+
public function setUp()
|
37 |
+
{
|
38 |
+
$this->package = new Package('VisitSummary', '1.0', '1.0');
|
39 |
+
$this->io = $this->getMock('Composer\IO\PackageInterface');
|
40 |
+
$this->composer = new Composer();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* testInflectPackageVars
|
45 |
+
*
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
public function testInflectPackageVars()
|
49 |
+
{
|
50 |
+
$installer = new PiwikInstaller($this->package, $this->composer);
|
51 |
+
$result = $installer->inflectPackageVars(array('name' => 'VisitSummary'));
|
52 |
+
$this->assertEquals($result, array('name' => 'VisitSummary'));
|
53 |
+
|
54 |
+
$installer = new PiwikInstaller($this->package, $this->composer);
|
55 |
+
$result = $installer->inflectPackageVars(array('name' => 'visit-summary'));
|
56 |
+
$this->assertEquals($result, array('name' => 'VisitSummary'));
|
57 |
+
|
58 |
+
$installer = new PiwikInstaller($this->package, $this->composer);
|
59 |
+
$result = $installer->inflectPackageVars(array('name' => 'visit_summary'));
|
60 |
+
$this->assertEquals($result, array('name' => 'VisitSummary'));
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of Composer.
|
5 |
+
*
|
6 |
+
* (c) Nils Adermann <naderman@naderman.de>
|
7 |
+
* Jordi Boggiano <j.boggiano@seld.be>
|
8 |
+
*
|
9 |
+
* For the full copyright and license information, please view the LICENSE
|
10 |
+
* file that was distributed with this source code.
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Composer\Installers\Test;
|
14 |
+
|
15 |
+
use Composer\Package\Version\VersionParser;
|
16 |
+
use Composer\Package\Package;
|
17 |
+
use Composer\Package\AliasPackage;
|
18 |
+
use Composer\Package\LinkConstraint\VersionConstraint;
|
19 |
+
use Composer\Util\Filesystem;
|
20 |
+
|
21 |
+
abstract class TestCase extends \PHPUnit_Framework_TestCase
|
22 |
+
{
|
23 |
+
private static $parser;
|
24 |
+
|
25 |
+
protected static function getVersionParser()
|
26 |
+
{
|
27 |
+
if (!self::$parser) {
|
28 |
+
self::$parser = new VersionParser();
|
29 |
+
}
|
30 |
+
|
31 |
+
return self::$parser;
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function getVersionConstraint($operator, $version)
|
35 |
+
{
|
36 |
+
return new VersionConstraint(
|
37 |
+
$operator,
|
38 |
+
self::getVersionParser()->normalize($version)
|
39 |
+
);
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function getPackage($name, $version)
|
43 |
+
{
|
44 |
+
$normVersion = self::getVersionParser()->normalize($version);
|
45 |
+
|
46 |
+
return new Package($name, $normVersion, $version);
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function getAliasPackage($package, $version)
|
50 |
+
{
|
51 |
+
$normVersion = self::getVersionParser()->normalize($version);
|
52 |
+
|
53 |
+
return new AliasPackage($package, $normVersion, $version);
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function ensureDirectoryExistsAndClear($directory)
|
57 |
+
{
|
58 |
+
$fs = new Filesystem();
|
59 |
+
if (is_dir($directory)) {
|
60 |
+
$fs->removeDirectory($directory);
|
61 |
+
}
|
62 |
+
mkdir($directory, 0777, true);
|
63 |
+
}
|
64 |
+
}
|
vendor/composer/installers/tests/bootstrap.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$loader = require __DIR__ . '/../src/bootstrap.php';
|
4 |
+
$loader->add('Composer\Installers\Test', __DIR__);
|
vendor/xrstf/composer-php52/.hg_archival.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
repo: 0d0ceaca3a0500b3f45b41b79c6ac4f396dc4b13
|
2 |
+
node: 70b853668d6c3f97b63dafcfaeebb622bf08fd30
|
3 |
+
branch: default
|
4 |
+
tag: v1.0.17
|
vendor/xrstf/composer-php52/.hgtags
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1328b37f36994039e0482272bfea90825f9b8d4c v1.0.0
|
2 |
+
8ed634e8a47ed96c8c6e7ef3bffb73e69c181f4b v1.0.1
|
3 |
+
8490d268ce216557f2ba82298c8dc7a8233d1c51 v1.0.2
|
4 |
+
e719a1afd817bc0c260750d40e871d4a8ea312f2 v1.0.3
|
5 |
+
c139ce4683b3f0269ff017a0dc30f964ec165156 v1.0.4
|
6 |
+
b8d4df7f5d4441c30bb35c4ab0eea7e7a2710cd4 v1.0.5
|
7 |
+
05d33685ec9a85742d4f1634dcdd2bb8da74f626 v1.0.6
|
8 |
+
a1377306c6e40426e3913f46cf5019c9e2497164 v1.0.7
|
9 |
+
77cc535bc7441dacdbc10be7720c44c47b9cc2a2 v1.0.8
|
10 |
+
b4e44b96b96762d08366196f7f9013e26c8d610d v1.0.9
|
11 |
+
9b04ae051405d81c85dcb3a307b503a1471ee4fb v1.0.10
|
12 |
+
c0b2cd0685c3a35297e3392b3a9df3c51c287740 v1.0.11
|
13 |
+
1d534d45cf037b5f2f83c04043851b5f0f478975 v1.0.12
|
14 |
+
eabb654da4d9200180037805cf348c20caf775c2 v1.0.13
|
15 |
+
8cc8f6ceddf527eafd0cd7b4cb274bef39d27a92 v1.0.14
|
16 |
+
b69d211ed4885e3c16282b01b7548226c7b50657 v1.0.15
|
17 |
+
b80de08b940ea59789646fa20d841fbdd72d72f0 v1.0.16
|
vendor/xrstf/composer-php52/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2013 Christoph Mewes
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
of this software and associated documentation files (the "Software"), to deal
|
5 |
+
in the Software without restriction, including without limitation the rights
|
6 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
+
copies of the Software, and to permit persons to whom the Software is furnished
|
8 |
+
to do so, subject to the following conditions:
|
9 |
+
|
10 |
+
The above copyright notice and this permission notice shall be included in all
|
11 |
+
copies or substantial portions of the Software.
|
12 |
+
|
13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
+
THE SOFTWARE.
|
vendor/xrstf/composer-php52/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PHP 5.2 Autoloading for Composer
|
2 |
+
================================
|
3 |
+
|
4 |
+
This package provides an easy way to get a PHP 5.2 compatible autoloader out of Composer. The generated autoloader is fully compatible to the original and is written into separate files, each ending with `_52.php`.
|
5 |
+
|
6 |
+
Usage
|
7 |
+
-----
|
8 |
+
|
9 |
+
In your project's `composer.json`, add the following lines:
|
10 |
+
|
11 |
+
:::json
|
12 |
+
{
|
13 |
+
"require": {
|
14 |
+
"xrstf/composer-php52": "1.*"
|
15 |
+
},
|
16 |
+
"scripts": {
|
17 |
+
"post-install-cmd": [
|
18 |
+
"xrstf\\Composer52\\Generator::onPostInstallCmd"
|
19 |
+
],
|
20 |
+
"post-update-cmd": [
|
21 |
+
"xrstf\\Composer52\\Generator::onPostInstallCmd"
|
22 |
+
],
|
23 |
+
"post-autoload-dump": [
|
24 |
+
"xrstf\\Composer52\\Generator::onPostInstallCmd"
|
25 |
+
]
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
After the next update/install, you will have a `vendor/autoload_52.php` file, that you can simply include and use in PHP 5.2 projects.
|
vendor/xrstf/composer-php52/composer.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "xrstf/composer-php52",
|
3 |
+
"license": "MIT",
|
4 |
+
"homepage": "http://www.xrstf.de/",
|
5 |
+
"support": {
|
6 |
+
"source": "https://bitbucket.org/xrstf/composer-php52",
|
7 |
+
"issues": "https://bitbucket.org/xrstf/composer-php52/issues"
|
8 |
+
},
|
9 |
+
"autoload": {
|
10 |
+
"psr-0": {
|
11 |
+
"xrstf\\Composer52": "lib/"
|
12 |
+
}
|
13 |
+
},
|
14 |
+
"scripts": {
|
15 |
+
"post-install-cmd": [
|
16 |
+
"xrstf\\Composer52\\Generator::onPostInstallCmd"
|
17 |
+
],
|
18 |
+
"post-update-cmd": [
|
19 |
+
"xrstf\\Composer52\\Generator::onPostInstallCmd"
|
20 |
+
]
|
21 |
+
},
|
22 |
+
"extra": {
|
23 |
+
"branch-alias": {
|
24 |
+
"dev-default": "1.x-dev"
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
vendor/xrstf/composer-php52/lib/xrstf/Composer52/AutoloadGenerator.php
ADDED
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de
|
4 |
+
*
|
5 |
+
* This file is released under the terms of the MIT license. You can find the
|
6 |
+
* complete text in the attached LICENSE file or online at:
|
7 |
+
*
|
8 |
+
* http://www.opensource.org/licenses/mit-license.php
|
9 |
+
*
|
10 |
+
* --------------------------------------------------------------------------
|
11 |
+
*
|
12 |
+
* 99% of this is copied as-is from the original Composer source code and is
|
13 |
+
* released under MIT license as well. Copyright goes to:
|
14 |
+
*
|
15 |
+
* - Igor Wiedler <igor@wiedler.ch>
|
16 |
+
* - Jordi Boggiano <j.boggiano@seld.be>
|
17 |
+
*/
|
18 |
+
|
19 |
+
namespace xrstf\Composer52;
|
20 |
+
|
21 |
+
use Composer\Autoload\AutoloadGenerator as BaseGenerator;
|
22 |
+
use Composer\Autoload\ClassMapGenerator;
|
23 |
+
use Composer\Config;
|
24 |
+
use Composer\Installer\InstallationManager;
|
25 |
+
use Composer\Package\AliasPackage;
|
26 |
+
use Composer\Package\PackageInterface;
|
27 |
+
use Composer\Repository\InstalledRepositoryInterface;
|
28 |
+
use Composer\Util\Filesystem;
|
29 |
+
|
30 |
+
class AutoloadGenerator extends BaseGenerator {
|
31 |
+
public function __construct() {
|
32 |
+
// do nothing (but keep this constructor so we can build an instance without the need for an event dispatcher)
|
33 |
+
}
|
34 |
+
|
35 |
+
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '') {
|
36 |
+
$filesystem = new Filesystem();
|
37 |
+
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
|
38 |
+
|
39 |
+
$cwd = getcwd();
|
40 |
+
$basePath = $filesystem->normalizePath($cwd);
|
41 |
+
$vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
|
42 |
+
$targetDir = $vendorPath.'/'.$targetDir;
|
43 |
+
$filesystem->ensureDirectoryExists($targetDir);
|
44 |
+
|
45 |
+
$useGlobalIncludePath = (bool) $config->get('use-include-path');
|
46 |
+
$prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
|
47 |
+
$classMapAuthoritative = $config->get('classmap-authoritative');
|
48 |
+
|
49 |
+
$vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
|
50 |
+
$vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
|
51 |
+
|
52 |
+
$appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
|
53 |
+
$appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
|
54 |
+
|
55 |
+
// add 5.2 compat
|
56 |
+
$vendorPathCode = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
|
57 |
+
$vendorPathToTargetDirCode = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathToTargetDirCode);
|
58 |
+
|
59 |
+
$packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages());
|
60 |
+
$autoloads = $this->parseAutoloads($packageMap, $mainPackage);
|
61 |
+
|
62 |
+
// add custom psr-0 autoloading if the root package has a target dir
|
63 |
+
$targetDirLoader = null;
|
64 |
+
$mainAutoload = $mainPackage->getAutoload();
|
65 |
+
if ($mainPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
|
66 |
+
$levels = count(explode('/', $filesystem->normalizePath($mainPackage->getTargetDir())));
|
67 |
+
$prefixes = implode(', ', array_map(function ($prefix) {
|
68 |
+
return var_export($prefix, true);
|
69 |
+
}, array_keys($mainAutoload['psr-0'])));
|
70 |
+
|
71 |
+
$baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
|
72 |
+
|
73 |
+
$targetDirLoader = <<<EOF
|
74 |
+
|
75 |
+
public static function autoload(\$class) {
|
76 |
+
\$dir = $baseDirFromTargetDirCode.'/';
|
77 |
+
\$prefixes = array($prefixes);
|
78 |
+
|
79 |
+
foreach (\$prefixes as \$prefix) {
|
80 |
+
if (0 !== strpos(\$class, \$prefix)) {
|
81 |
+
continue;
|
82 |
+
}
|
83 |
+
|
84 |
+
\$path = explode(DIRECTORY_SEPARATOR, self::getClassPath(\$class));
|
85 |
+
\$path = \$dir.implode('/', array_slice(\$path, $levels));
|
86 |
+
|
87 |
+
if (!\$path = self::resolveIncludePath(\$path)) {
|
88 |
+
return false;
|
89 |
+
}
|
90 |
+
|
91 |
+
require \$path;
|
92 |
+
return true;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
EOF;
|
97 |
+
}
|
98 |
+
|
99 |
+
$filesCode = "";
|
100 |
+
$autoloads['files'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['files']));
|
101 |
+
foreach ($autoloads['files'] as $functionFile) {
|
102 |
+
// don't include file if it is using PHP 5.3+ syntax
|
103 |
+
// https://bitbucket.org/xrstf/composer-php52/issue/4
|
104 |
+
if ($this->isPHP53($functionFile)) {
|
105 |
+
$filesCode .= '// require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile)."; // disabled because of PHP 5.3 syntax\n";
|
106 |
+
}
|
107 |
+
else {
|
108 |
+
$filesCode .= ' require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).";\n";
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
if (!$suffix) {
|
113 |
+
$suffix = md5(uniqid('', true));
|
114 |
+
}
|
115 |
+
|
116 |
+
$includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode);
|
117 |
+
|
118 |
+
file_put_contents($vendorPath.'/autoload_52.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
|
119 |
+
file_put_contents($targetDir.'/autoload_real_52.php', $this->getAutoloadRealFile(true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $classMapAuthoritative));
|
120 |
+
|
121 |
+
// use stream_copy_to_stream instead of copy
|
122 |
+
// to work around https://bugs.php.net/bug.php?id=64634
|
123 |
+
$sourceLoader = fopen(__DIR__.'/ClassLoader.php', 'r');
|
124 |
+
$targetLoader = fopen($targetDir.'/ClassLoader52.php', 'w+');
|
125 |
+
stream_copy_to_stream($sourceLoader, $targetLoader);
|
126 |
+
fclose($sourceLoader);
|
127 |
+
fclose($targetLoader);
|
128 |
+
unset($sourceLoader, $targetLoader);
|
129 |
+
}
|
130 |
+
|
131 |
+
protected function isPHP53($file) {
|
132 |
+
$tokens = token_get_all(file_get_contents($file));
|
133 |
+
$php53 = array(T_DIR, T_GOTO, T_NAMESPACE, T_NS_C, T_NS_SEPARATOR, T_USE);
|
134 |
+
|
135 |
+
// PHP 5.4+
|
136 |
+
if (defined('T_TRAIT')) {
|
137 |
+
$php53[] = T_TRAIT;
|
138 |
+
$php53[] = T_TRAIT_C;
|
139 |
+
$php53[] = T_TRAIT_C;
|
140 |
+
}
|
141 |
+
|
142 |
+
// PHP 5.5+
|
143 |
+
if (defined('T_FINALLY')) {
|
144 |
+
$php53[] = T_FINALLY;
|
145 |
+
$php53[] = T_YIELD;
|
146 |
+
}
|
147 |
+
|
148 |
+
foreach ($tokens as $token) {
|
149 |
+
if (is_array($token) && in_array($token[0], $php53)) {
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode) {
|
158 |
+
$includePaths = array();
|
159 |
+
|
160 |
+
foreach ($packageMap as $item) {
|
161 |
+
list($package, $installPath) = $item;
|
162 |
+
|
163 |
+
if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
|
164 |
+
$installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
|
165 |
+
}
|
166 |
+
|
167 |
+
foreach ($package->getIncludePaths() as $includePath) {
|
168 |
+
$includePath = trim($includePath, '/');
|
169 |
+
$includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
if (!$includePaths) {
|
174 |
+
return;
|
175 |
+
}
|
176 |
+
|
177 |
+
$includePathsFile = <<<EOF
|
178 |
+
<?php
|
179 |
+
|
180 |
+
// include_paths_52.php generated by xrstf/composer-php52
|
181 |
+
|
182 |
+
\$vendorDir = $vendorPathCode;
|
183 |
+
\$baseDir = $appBaseDirCode;
|
184 |
+
|
185 |
+
return array(
|
186 |
+
|
187 |
+
EOF;
|
188 |
+
|
189 |
+
foreach ($includePaths as $path) {
|
190 |
+
$includePathsFile .= "\t" . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
|
191 |
+
}
|
192 |
+
|
193 |
+
return $includePathsFile . ");\n";
|
194 |
+
}
|
195 |
+
|
196 |
+
protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix) {
|
197 |
+
return <<<AUTOLOAD
|
198 |
+
<?php
|
199 |
+
|
200 |
+
// autoload_52.php generated by xrstf/composer-php52
|
201 |
+
|
202 |
+
require_once $vendorPathToTargetDirCode.'/autoload_real_52.php';
|
203 |
+
|
204 |
+
return ComposerAutoloaderInit$suffix::getLoader();
|
205 |
+
|
206 |
+
AUTOLOAD;
|
207 |
+
}
|
208 |
+
|
209 |
+
protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $classMapAuthoritative) {
|
210 |
+
// TODO the class ComposerAutoloaderInit should be revert to a closure
|
211 |
+
// when APC has been fixed:
|
212 |
+
// - https://github.com/composer/composer/issues/959
|
213 |
+
// - https://bugs.php.net/bug.php?id=52144
|
214 |
+
// - https://bugs.php.net/bug.php?id=61576
|
215 |
+
// - https://bugs.php.net/bug.php?id=59298
|
216 |
+
|
217 |
+
if ($filesCode) {
|
218 |
+
$filesCode = "\n\n".rtrim($filesCode);
|
219 |
+
}
|
220 |
+
|
221 |
+
$file = <<<HEADER
|
222 |
+
<?php
|
223 |
+
|
224 |
+
// autoload_real_52.php generated by xrstf/composer-php52
|
225 |
+
|
226 |
+
class ComposerAutoloaderInit$suffix {
|
227 |
+
private static \$loader;
|
228 |
+
|
229 |
+
public static function loadClassLoader(\$class) {
|
230 |
+
if ('xrstf_Composer52_ClassLoader' === \$class) {
|
231 |
+
require dirname(__FILE__).'/ClassLoader52.php';
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* @return xrstf_Composer52_ClassLoader
|
237 |
+
*/
|
238 |
+
public static function getLoader() {
|
239 |
+
if (null !== self::\$loader) {
|
240 |
+
return self::\$loader;
|
241 |
+
}
|
242 |
+
|
243 |
+
spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true /*, true */);
|
244 |
+
self::\$loader = \$loader = new xrstf_Composer52_ClassLoader();
|
245 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
|
246 |
+
|
247 |
+
\$vendorDir = $vendorPathCode;
|
248 |
+
\$baseDir = $appBaseDirCode;
|
249 |
+
\$dir = dirname(__FILE__);
|
250 |
+
|
251 |
+
|
252 |
+
HEADER;
|
253 |
+
|
254 |
+
if ($useIncludePath) {
|
255 |
+
$file .= <<<'INCLUDE_PATH'
|
256 |
+
$includePaths = require $dir.'/include_paths.php';
|
257 |
+
array_push($includePaths, get_include_path());
|
258 |
+
set_include_path(implode(PATH_SEPARATOR, $includePaths));
|
259 |
+
|
260 |
+
|
261 |
+
INCLUDE_PATH;
|
262 |
+
}
|
263 |
+
|
264 |
+
$file .= <<<'PSR0'
|
265 |
+
$map = require $dir.'/autoload_namespaces.php';
|
266 |
+
foreach ($map as $namespace => $path) {
|
267 |
+
$loader->add($namespace, $path);
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
PSR0;
|
272 |
+
|
273 |
+
if ($useClassMap) {
|
274 |
+
$file .= <<<'CLASSMAP'
|
275 |
+
$classMap = require $dir.'/autoload_classmap.php';
|
276 |
+
if ($classMap) {
|
277 |
+
$loader->addClassMap($classMap);
|
278 |
+
}
|
279 |
+
|
280 |
+
|
281 |
+
CLASSMAP;
|
282 |
+
}
|
283 |
+
|
284 |
+
if ($classMapAuthoritative) {
|
285 |
+
$file .= <<<'CLASSMAPAUTHORITATIVE'
|
286 |
+
$loader->setClassMapAuthoritative(true);
|
287 |
+
|
288 |
+
CLASSMAPAUTHORITATIVE;
|
289 |
+
}
|
290 |
+
|
291 |
+
if ($useGlobalIncludePath) {
|
292 |
+
$file .= <<<'INCLUDEPATH'
|
293 |
+
$loader->setUseIncludePath(true);
|
294 |
+
|
295 |
+
|
296 |
+
INCLUDEPATH;
|
297 |
+
}
|
298 |
+
|
299 |
+
if ($targetDirLoader) {
|
300 |
+
$file .= <<<REGISTER_AUTOLOAD
|
301 |
+
spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true);
|
302 |
+
|
303 |
+
|
304 |
+
REGISTER_AUTOLOAD;
|
305 |
+
|
306 |
+
}
|
307 |
+
|
308 |
+
$file .= <<<METHOD_FOOTER
|
309 |
+
\$loader->register($prependAutoloader);{$filesCode}
|
310 |
+
|
311 |
+
return \$loader;
|
312 |
+
}
|
313 |
+
|
314 |
+
METHOD_FOOTER;
|
315 |
+
|
316 |
+
$file .= $targetDirLoader;
|
317 |
+
|
318 |
+
return $file . <<<FOOTER
|
319 |
+
}
|
320 |
+
|
321 |
+
FOOTER;
|
322 |
+
|
323 |
+
}
|
324 |
+
}
|
vendor/xrstf/composer-php52/lib/xrstf/Composer52/ClassLoader.php
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de
|
4 |
+
*
|
5 |
+
* This file is released under the terms of the MIT license. You can find the
|
6 |
+
* complete text in the attached LICENSE file or online at:
|
7 |
+
*
|
8 |
+
* http://www.opensource.org/licenses/mit-license.php
|
9 |
+
*
|
10 |
+
* --------------------------------------------------------------------------
|
11 |
+
*
|
12 |
+
* 99% of this is copied as-is from the original Composer source code and is
|
13 |
+
* released under MIT license as well. Copyright goes to:
|
14 |
+
*
|
15 |
+
* - Fabien Potencier <fabien@symfony.com>
|
16 |
+
* - Jordi Boggiano <j.boggiano@seld.be>
|
17 |
+
*/
|
18 |
+
|
19 |
+
class xrstf_Composer52_ClassLoader {
|
20 |
+
private $prefixes = array();
|
21 |
+
private $fallbackDirs = array();
|
22 |
+
private $useIncludePath = false;
|
23 |
+
private $classMap = array();
|
24 |
+
private $classMapAuthoratative = false;
|
25 |
+
private $allowUnderscore = false;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @param boolean $flag true to allow class names with a leading underscore, false to disable
|
29 |
+
*/
|
30 |
+
public function setAllowUnderscore($flag) {
|
31 |
+
$this->allowUnderscore = (boolean) $flag;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function getPrefixes() {
|
38 |
+
return $this->prefixes;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Turns off searching the prefix and fallback directories for classes
|
43 |
+
* that have not been registered with the class map.
|
44 |
+
*
|
45 |
+
* @param bool $classMapAuthoratative
|
46 |
+
*/
|
47 |
+
public function setClassMapAuthoritative($classMapAuthoratative) {
|
48 |
+
$this->classMapAuthoratative = $classMapAuthoratative;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Should class lookup fail if not found in the current class map?
|
53 |
+
*
|
54 |
+
* @return bool
|
55 |
+
*/
|
56 |
+
public function getClassMapAuthoratative() {
|
57 |
+
return $this->classMapAuthoratative;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function getFallbackDirs() {
|
64 |
+
return $this->fallbackDirs;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @return array
|
69 |
+
*/
|
70 |
+
public function getClassMap() {
|
71 |
+
return $this->classMap;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @param array $classMap class to filename map
|
76 |
+
*/
|
77 |
+
public function addClassMap(array $classMap) {
|
78 |
+
if ($this->classMap) {
|
79 |
+
$this->classMap = array_merge($this->classMap, $classMap);
|
80 |
+
}
|
81 |
+
else {
|
82 |
+
$this->classMap = $classMap;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Registers a set of classes, merging with any others previously set.
|
88 |
+
*
|
89 |
+
* @param string $prefix the classes prefix
|
90 |
+
* @param array|string $paths the location(s) of the classes
|
91 |
+
* @param bool $prepend prepend the location(s)
|
92 |
+
*/
|
93 |
+
public function add($prefix, $paths, $prepend = false) {
|
94 |
+
if (!$prefix) {
|
95 |
+
if ($prepend) {
|
96 |
+
$this->fallbackDirs = array_merge(
|
97 |
+
(array) $paths,
|
98 |
+
$this->fallbackDirs
|
99 |
+
);
|
100 |
+
}
|
101 |
+
else {
|
102 |
+
$this->fallbackDirs = array_merge(
|
103 |
+
$this->fallbackDirs,
|
104 |
+
(array) $paths
|
105 |
+
);
|
106 |
+
}
|
107 |
+
|
108 |
+
return;
|
109 |
+
}
|
110 |
+
|
111 |
+
if (!isset($this->prefixes[$prefix])) {
|
112 |
+
$this->prefixes[$prefix] = (array) $paths;
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
|
116 |
+
if ($prepend) {
|
117 |
+
$this->prefixes[$prefix] = array_merge(
|
118 |
+
(array) $paths,
|
119 |
+
$this->prefixes[$prefix]
|
120 |
+
);
|
121 |
+
}
|
122 |
+
else {
|
123 |
+
$this->prefixes[$prefix] = array_merge(
|
124 |
+
$this->prefixes[$prefix],
|
125 |
+
(array) $paths
|
126 |
+
);
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Registers a set of classes, replacing any others previously set.
|
132 |
+
*
|
133 |
+
* @param string $prefix the classes prefix
|
134 |
+
* @param array|string $paths the location(s) of the classes
|
135 |
+
*/
|
136 |
+
public function set($prefix, $paths) {
|
137 |
+
if (!$prefix) {
|
138 |
+
$this->fallbackDirs = (array) $paths;
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
$this->prefixes[$prefix] = (array) $paths;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Turns on searching the include path for class files.
|
147 |
+
*
|
148 |
+
* @param bool $useIncludePath
|
149 |
+
*/
|
150 |
+
public function setUseIncludePath($useIncludePath) {
|
151 |
+
$this->useIncludePath = $useIncludePath;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Can be used to check if the autoloader uses the include path to check
|
156 |
+
* for classes.
|
157 |
+
*
|
158 |
+
* @return bool
|
159 |
+
*/
|
160 |
+
public function getUseIncludePath() {
|
161 |
+
return $this->useIncludePath;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Registers this instance as an autoloader.
|
166 |
+
*/
|
167 |
+
public function register() {
|
168 |
+
spl_autoload_register(array($this, 'loadClass'), true);
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Unregisters this instance as an autoloader.
|
173 |
+
*/
|
174 |
+
public function unregister() {
|
175 |
+
spl_autoload_unregister(array($this, 'loadClass'));
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Loads the given class or interface.
|
180 |
+
*
|
181 |
+
* @param string $class the name of the class
|
182 |
+
* @return bool|null true, if loaded
|
183 |
+
*/
|
184 |
+
public function loadClass($class) {
|
185 |
+
if ($file = $this->findFile($class)) {
|
186 |
+
include $file;
|
187 |
+
return true;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Finds the path to the file where the class is defined.
|
193 |
+
*
|
194 |
+
* @param string $class the name of the class
|
195 |
+
* @return string|null the path, if found
|
196 |
+
*/
|
197 |
+
public function findFile($class) {
|
198 |
+
if ('\\' === $class[0]) {
|
199 |
+
$class = substr($class, 1);
|
200 |
+
}
|
201 |
+
|
202 |
+
if (isset($this->classMap[$class])) {
|
203 |
+
return $this->classMap[$class];
|
204 |
+
}
|
205 |
+
elseif ($this->classMapAuthoratative) {
|
206 |
+
return false;
|
207 |
+
}
|
208 |
+
|
209 |
+
$classPath = $this->getClassPath($class);
|
210 |
+
|
211 |
+
foreach ($this->prefixes as $prefix => $dirs) {
|
212 |
+
if (0 === strpos($class, $prefix)) {
|
213 |
+
foreach ($dirs as $dir) {
|
214 |
+
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
|
215 |
+
return $dir.DIRECTORY_SEPARATOR.$classPath;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
foreach ($this->fallbackDirs as $dir) {
|
222 |
+
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
|
223 |
+
return $dir.DIRECTORY_SEPARATOR.$classPath;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
if ($this->useIncludePath && $file = self::resolveIncludePath($classPath)) {
|
228 |
+
return $file;
|
229 |
+
}
|
230 |
+
|
231 |
+
return $this->classMap[$class] = false;
|
232 |
+
}
|
233 |
+
|
234 |
+
private function getClassPath($class) {
|
235 |
+
if (false !== $pos = strrpos($class, '\\')) {
|
236 |
+
// namespaced class name
|
237 |
+
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR;
|
238 |
+
$className = substr($class, $pos + 1);
|
239 |
+
}
|
240 |
+
else {
|
241 |
+
// PEAR-like class name
|
242 |
+
$classPath = null;
|
243 |
+
$className = $class;
|
244 |
+
}
|
245 |
+
|
246 |
+
$className = str_replace('_', DIRECTORY_SEPARATOR, $className);
|
247 |
+
|
248 |
+
// restore the prefix
|
249 |
+
if ($this->allowUnderscore && DIRECTORY_SEPARATOR === $className[0]) {
|
250 |
+
$className[0] = '_';
|
251 |
+
}
|
252 |
+
|
253 |
+
$classPath .= $className.'.php';
|
254 |
+
|
255 |
+
return $classPath;
|
256 |
+
}
|
257 |
+
|
258 |
+
public static function resolveIncludePath($classPath) {
|
259 |
+
$paths = explode(PATH_SEPARATOR, get_include_path());
|
260 |
+
|
261 |
+
foreach ($paths as $path) {
|
262 |
+
$path = rtrim($path, '/\\');
|
263 |
+
|
264 |
+
if ($file = file_exists($path.DIRECTORY_SEPARATOR.$file)) {
|
265 |
+
return $file;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
return false;
|
270 |
+
}
|
271 |
+
}
|
vendor/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de
|
4 |
+
*
|
5 |
+
* This file is released under the terms of the MIT license. You can find the
|
6 |
+
* complete text in the attached LICENSE file or online at:
|
7 |
+
*
|
8 |
+
* http://www.opensource.org/licenses/mit-license.php
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace xrstf\Composer52;
|
12 |
+
|
13 |
+
use Composer\Repository\CompositeRepository;
|
14 |
+
use Composer\Script\Event;
|
15 |
+
|
16 |
+
class Generator {
|
17 |
+
public static function onPostInstallCmd(Event $event) {
|
18 |
+
$composer = $event->getComposer();
|
19 |
+
$installationManager = $composer->getInstallationManager();
|
20 |
+
$repoManager = $composer->getRepositoryManager();
|
21 |
+
$localRepo = $repoManager->getLocalRepository();
|
22 |
+
$package = $composer->getPackage();
|
23 |
+
$config = $composer->getConfig();
|
24 |
+
|
25 |
+
// We can't gain access to the Command's input object, so we have to look
|
26 |
+
// for -o / --optimize-autoloader ourselves. Sadly, neither getopt() works
|
27 |
+
// (always returns an empty array), nor does Symfony's Console Input, as
|
28 |
+
// it expects a full definition of the current command line and we can't
|
29 |
+
// provide that.
|
30 |
+
|
31 |
+
// $def = new InputDefinition(array(new InputOption('optimize', 'o', InputOption::VALUE_NONE)));
|
32 |
+
// $input = new ArgvInput(null, $def);
|
33 |
+
// var_dump($input->hasOption('o')); // "Too many arguments"
|
34 |
+
|
35 |
+
// $options = getopt('o', array('optimize-autoloader')); // always array()
|
36 |
+
// $optimize = !empty($options);
|
37 |
+
|
38 |
+
$args = $_SERVER['argv'];
|
39 |
+
$optimize = in_array('-o', $args) || in_array('-o', $args);
|
40 |
+
|
41 |
+
$generator = new AutoloadGenerator();
|
42 |
+
$generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
|
43 |
+
}
|
44 |
+
}
|