Permalink
Browse files

fix(admin): Allow plugins to extend js/admin but deprecate it

The view js/admin was replaced in 2.0 but this was never mentioned in the
plugin upgrade guide. We're supporting it for better BC.

Fixes #9238
  • Loading branch information...
mrclay committed Dec 17, 2015
1 parent ea4c7fe commit a5c2abdf9669db75a4d080e274c0fe78851a7cf8
Showing with 23 additions and 0 deletions.
  1. +1 −0 docs/guides/upgrading.rst
  2. +22 −0 engine/lib/admin.php
@@ -199,6 +199,7 @@ We dropped support for and/or removed the following views:
* input/datepicker (Use input/date instead)
* input/pulldown (Use input/select instead)
* invitefriends/formitems
+ * js/admin (Use AMD and ``elgg_require_js`` instead of extending JS views)
* js/initialise_elgg (Use AMD and ``elgg_require_js`` instead of extending JS views)
* members/nav
* metatags (Use the 'head', 'page' plugin hook instead)
View
@@ -345,6 +345,19 @@ function _elgg_admin_init() {
elgg_register_page_handler('robots.txt', '_elgg_robots_page_handler');
}
+/**
+ * Setup after plugins are initialized
+ *
+ * @access private
+ * @return void
+ */
+function _elgg_admin_ready() {
+ // if a plugin has extended the deprecated admin.js view, register it for simplecache loading.
+ if (elgg_view_exists('admin.js')) {
+ elgg_register_simplecache_view('admin.js');
+ }
+}
+
/**
* Handles any set up required for administration pages
*
@@ -505,6 +518,14 @@ function _elgg_admin_page_handler($page) {
elgg_unregister_css('elgg');
elgg_require_js('elgg/admin');
+
+ // if a plugin has extended the deprecated admin.js view, add it to the page
+ if (elgg_view_exists('admin.js')) {
+ elgg_deprecated_notice("The view admin.js (AKA js/admin) is deprecated", "2.0");
+ elgg_register_js('elgg.deprecated.admin', elgg_get_simplecache_url('admin.js'));
+ elgg_load_js('elgg.deprecated.admin');
+ }
+
elgg_load_js('jquery.jeditable');
// default to dashboard
@@ -717,4 +738,5 @@ function _elgg_add_admin_widgets($event, $type, $user) {
return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
$events->registerHandler('init', 'system', '_elgg_admin_init');
+ $events->registerHandler('ready', 'system', '_elgg_admin_ready');
};

0 comments on commit a5c2abd

Please sign in to comment.