Convert over to using loadCSSFile and loadJavascriptFile. Fixed an issue where SMF wouldn't like the SSI hook because we do not technically load any functions.
jdarwood007

jdarwood007 commited on 2016-10-22 19:13:27
Showing 6 changed files, with 21 additions and 20 deletions.


Signed-off-by: jdarwood007 <unmonitored+github@sleepycode.com>
... ...
@@ -264,7 +264,7 @@ $hooks = array();
264 264
 // Other
265 265
 	$hooks[] = array(
266 266
 		'hook' => 'integrate_SSI',
267
-		'function' => false,
267
+		'function' => 'ssi_shd_called',
268 268
 		'file' => '$sourcedir/sd_source/SimpleDesk-SSI.php',
269 269
 		'perm' => true,
270 270
 	);
... ...
@@ -53,10 +53,10 @@ function shd_admin_main()
53 53
 	shd_load_plugin_langfiles('hdadmin');
54 54
 
55 55
 	// Load some extra CSS
56
-	$context['html_headers'] .= '
57
-	<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/css/helpdesk_admin.css?' . $context['shd_css_version'] . '" />
58
-	<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/css/helpdesk.css?' . $context['shd_css_version'] . '" />
59
-	<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/helpdesk_admin.js?' . $context['shd_scripts_version'] . '"></script>';
56
+	loadCSSFile('helpdesk_admin.css', array('minimize' => false, 'seed' => $context['shd_css_version']), 'helpdesk_admin');
57
+	loadCSSFile('helpdesk.css', array('minimize' => false, 'seed' => $context['shd_css_version']), 'helpdesk');
58
+	loadJavascriptFile('helpdesk_admin.js', array('defer' => false, 'minimize' => false), 'helpdesk_admin');
59
+
60 60
 	$context['page_title'] = $txt['shd_admin_title'];
61 61
 
62 62
 	// We need this for later
... ...
@@ -36,6 +36,15 @@
36 36
 if (!defined('SMF'))
37 37
 	die('Hacking attempt...');
38 38
 
39
+/**
40
+ *	Makes SMF hook system happy that it has a function to call for SSI.
41
+ *	@since 2.1
42
+*/
43
+function ssi_shd_called()
44
+{
45
+	return true;
46
+}
47
+
39 48
 /**
40 49
  *	Gets a list of the tickets currently open that are a given user's (subject to ticket visibility).
41 50
  *
... ...
@@ -288,21 +288,14 @@ function shd_main()
288 288
 	$context['items_per_page'] = 10;
289 289
 	$context['start'] = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
290 290
 
291
-	// Load the custom CSS.
292
-	if (empty($context['html_headers']))
293
-		$context['html_headers'] = '';
291
+	loadCSSFile('helpdesk.css', array('minimize' => false, 'seed' => $context['shd_css_version']), 'helpdesk');
292
+	loadJavascriptFile('helpdesk.js', array('defer' => false, 'minimize' => false), 'helpdesk');
294 293
 
295
-	$context['html_headers'] .= '
296
-	<link rel="stylesheet" type="text/css" href="' . (file_exists($settings['theme_dir'] . '/css/helpdesk.css') ? $settings['theme_url'] . '/css/helpdesk.css' : $settings['default_theme_url'] . '/css/helpdesk.css') . '?' . $context['shd_css_version'] . '" />
297
-	<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/helpdesk.js?' .$context['shd_scripts_version'] . '"></script>';
298
-
299
-	// A custom css?
294
+	// Custom settings?
300 295
 	if (file_exists($settings['default_theme_url'] . '/css/helpdesk_custom.css'))
301
-		$context['html_headers'] .= '
302
-	<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/css/helpdesk_custom.css?' . $context['shd_css_version'] . '" />';
296
+		loadCSSFile('helpdesk_def_custom.css', array('minimize' => false, 'seed' => $context['shd_css_version'], 'default_theme' => true), 'helpdesk_def_custom');
303 297
 	if (file_exists($settings['theme_dir'] . '/css/helpdesk_custom.css'))
304
-		$context['html_headers'] .= '
305
-	<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/css/helpdesk_custom.css?' . $context['shd_css_version'] . '" />';
298
+		loadCSSFile('helpdesk_custom.css', array('minimize' => false, 'seed' => $context['shd_css_version']), 'helpdesk_custom');
306 299
 
307 300
 	// Int hooks - after we basically set everything up (so it's manipulatable by the hook, but before we do the last bits of finalisation)
308 301
 	call_integration_hook('shd_hook_helpdesk', array(&$subactions));
... ...
@@ -1717,8 +1717,7 @@ function shd_main_menu(&$menu_buttons)
1717 1717
 		return;
1718 1718
 
1719 1719
     // Load some extra CSS
1720
-    $context['html_headers'] .= '
1721
-    <link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/css/helpdesk_icons.css?' . $context['shd_css_version'] . '" />';
1720
+	loadCSSFile('helpdesk_icons.css', array('minimize' => empty($context['shd_developer_mode']), 'seed' => $context['shd_css_version']), 'helpdesk_icons');
1722 1721
 
1723 1722
 	// Stuff we'll always do in SD if active
1724 1723
 	$helpdesk_admin = $context['user']['is_admin'] || shd_allowed_to('admin_helpdesk', 0);
... ...
@@ -189,7 +189,7 @@ $hooks = array();
189 189
 // Other
190 190
 	$hooks[] = array(
191 191
 		'hook' => 'integrate_SSI',
192
-		'function' => false,
192
+		'function' => 'ssi_shd_called',
193 193
 		'file' => '$sourcedir/sd_source/SimpleDesk-SSI.php',
194 194
 	);
195 195
 
196 196