load.inc

  1. cis7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc
  2. cle7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc
  3. ecd7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc
  4. elmsmedia7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc
  5. harmony7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc
  6. icor7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc
  7. meedjum_blog7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc
  8. mooc7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc

Provides frequently used functions that load something, ususally CSS or JS files, or that provide assistance to those loaders.

Functions

Namesort descending Description
at_load_conditional_styles Load Sub-theme IE Stylesheets. Wrapper function for drupal_add_css() that makes use the 'browser' option to load stylesheets for Internet Explorer.
at_load_custom_css Load custom css file.
at_load_debuggers Load debugging helper files.
at_load_extensions_css Load Extension Settings CSS.
at_load_failure Set messages if files are not found
at_load_fonts Load Fonts
at_load_google_fonts Google Font loader. Adaptivetheme can load websafe fonts, Google fonts, custom font stacks and integrate with @font-your-face module. All can be configured in the "Fonts" theme settings. Here we only need to load Google webfonts. Websafe and…
at_load_layout_css Conditionally load stylesheets to set the layout.
at_load_layout_js_settings Add js settings for the layout type and media query
at_load_menu_toggle Return JS and CSS for the Menu Toggle for mobile.
at_load_polyfills Load Polyfill Scripts Conditional scripts are returned to the preprocess function - in AT Core that means adaptivetheme_preprocess_html() and adaptivetheme_preprocess_maintenance_page(). There are two sources for conditional scripts - the subtheme…
at_load_responsive_css Load Responsive Styles.
at_load_subtheme_conditional_styles Build arrays of conditional styles to load Sub-themes can declare conditional stylesheets in the info file, we need to get this info file data and process it.
at_load_subtheme_responsive_styles Load Sub-theme Responsive Stylesheets. Wrapper function for drupal_add_css() that takes advantage of Drupals's CSS aggregation logic to trick Drupal into always loading responsive stylesheets in link elements.
at_load_subtheme_script Load scripts from the sub-theme Wrapper function for drupal_add_js(). In the core theme this is only used to load media_queries.js if the Responsive JavaScript plugin is enabled in theme settings. You can call this in your subtheme.
at_theme_conditional_script Return a themed script. Since Drupal 7 does not (yet) support the 'browser' option in drupal_add_js() Adaptivetheme provides a way to load scripts inside conditional comments. This function wraps a file in script elements and returns a string.
load_subtheme_ie_styles
load_subtheme_media_queries

File

sites/all/themes/ulmus/adaptivetheme/at_core/inc/load.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provides frequently used functions that load something, ususally CSS or JS
  5. * files, or that provide assistance to those loaders.
  6. */
  7. /**
  8. * Set messages if files are not found
  9. *
  10. * Adaptivetheme makes heavy use of generated CSS files, if one or more are not
  11. * found we set a message warning the user, and dump an error in watchdog.
  12. *
  13. * @param $filepath, path to the missing file.
  14. * @param $theme_name, the active theme.
  15. */
  16. function at_load_failure($filepath, $theme_name) {
  17. $message = t('<p>One or more CSS files were not found or does not exist: <em>!files_list</em>. Did you delete any files or change a file name? You may need to save the theme settings or check all files names are correct in your theme. Please view the <a href="!docs_link" target="_blank">online documentation</a>.</p>', array('!files_list' => $filepath, '!docs_link' => 'http://adaptivethemes.com/documentation/file-generation-system'));
  18. if (!empty($filepath)) {
  19. watchdog($theme_name, 'CSS file missing or not found @filename', array('@filename' => $filepath), WATCHDOG_ERROR);
  20. if (user_is_logged_in()) {
  21. drupal_set_message($message, 'warning');
  22. }
  23. }
  24. }
  25. /**
  26. * Conditionally load stylesheets to set the layout.
  27. *
  28. * Each time you save the theme settings AT builds 3 layout stylesheets:
  29. * 1. themeName.default.layout.css
  30. * 2. themeName.responsive.layout.css
  31. * 3. themeName.lt-ie9.layout.css
  32. *
  33. * Now we need to load them, but only under certain conditions:
  34. * a. Is the default layout the standard layout?
  35. * b. Is the responsive capability disabled?
  36. *
  37. * If either a or b equate to TRUE, then we are NOT doing mobile first.
  38. * If a is FALSE then this is mobile first.
  39. * If b is FALSE then we are doing responsive design.
  40. *
  41. * @param $path
  42. * @param $theme_name
  43. */
  44. function at_load_layout_css($path, $theme_name) {
  45. // Get the info file data
  46. $info = at_get_info($theme_name);
  47. // Set a boolean to test which IE stylesheet to load.
  48. $load_ie8_css = TRUE;
  49. // Load the default layout if Standard layout is default or responsive styles are disabled
  50. if (at_get_setting('global_default_layout', $theme_name) === 'standard-layout' || at_get_setting('disable_responsive_styles', $theme_name) === 1) {
  51. $file = $theme_name . '.default.layout.css';
  52. $filepath = $path . '/' . $file;
  53. if (file_exists($filepath)) {
  54. drupal_add_css($filepath, array(
  55. 'preprocess' => TRUE,
  56. 'group' => CSS_THEME,
  57. 'media' => 'screen',
  58. 'every_page' => TRUE,
  59. )
  60. );
  61. }
  62. else {
  63. at_load_failure($filepath, $theme_name);
  64. }
  65. }
  66. // Next - check if we need to load the responsive layout
  67. if (at_get_setting('disable_responsive_styles', $theme_name) === 0) {
  68. // Responsiveness is not disabled, load the responsive layout
  69. $filepath = $path . '/' . $theme_name . '.responsive.layout.css';
  70. $media_query = 'only screen'; // keyword "only" hide this from unsupporting user agents
  71. at_load_subtheme_responsive_styles($filepath, $media_query, $theme_name, $weight = 0);
  72. // The lt-ie9.layout.css stylesheet loads under specific conditions:
  73. // 1. Responsive capabilities are ON
  74. // 2. Mobile first is ON
  75. // 3. Respond.js is OFF
  76. if (at_get_setting('global_default_layout', $theme_name) !== 'standard-layout') {
  77. if (at_get_setting('load_respondjs', $theme_name) === 0) {
  78. $load_ie8_css = FALSE;
  79. $filepath = $path . '/' . $theme_name . '.lt-ie9.layout.css';
  80. $ie_style['media'] = 'screen';
  81. $ie_style['condition'] = 'lt IE 9';
  82. at_load_conditional_styles($filepath, $ie_style, $theme_name);
  83. }
  84. }
  85. }
  86. // The lt-ie8.layout.css file loads under the exact opposite conditions to the
  87. // lt-ie9 file. In other words, when lt-ie9 is loading, this is not, when it
  88. // isn't, this loads. This file only ever holds panels layout overrides for
  89. // legacy IE browsers and is disabled by default in theme settings.
  90. if ($load_ie8_css == TRUE) {
  91. if (at_get_setting('load_ltie8css', $theme_name) === 1) {
  92. $filepath = $path . '/' . $theme_name . '.lt-ie8.layout.css';
  93. $ie_style['media'] = 'screen';
  94. $ie_style['condition'] = 'lt IE 8';
  95. at_load_conditional_styles($filepath, $ie_style, $theme_name);
  96. }
  97. }
  98. }
  99. /**
  100. * Load Responsive Styles.
  101. *
  102. * AT has two modes - Production and Development. Depending on the mode it
  103. * will load different files. Production mode assume you have finished CSS
  104. * development and will not need to update styles in the responsive
  105. * stylesheets, if you do you will need to re-save the theme settings at
  106. * least once to re-write your $theme_name.responsive.styles.css file which
  107. * is in public files.
  108. *
  109. * @param $path
  110. * @param $theme_name
  111. */
  112. function at_load_responsive_css($path, $theme_name) {
  113. // Set the mode, when CSS is aggregated by Drupal Production mode is TRUE
  114. $mode = variable_get('preprocess_css', '') == 1 ? TRUE : FALSE;
  115. // Development Mode
  116. // These files are for "design style" only, the layout is handled
  117. // seperately.
  118. //
  119. // We only load these files if:
  120. // - 1: We're not in production mode
  121. // - 2: Responsiveness is not disabled
  122. //
  123. // When in production mode these files are aggregated into one file
  124. // and loaded using at_load_subtheme_responsive_styles().
  125. //
  126. // You can disable responsive capability using the theme settings - look under
  127. // the Global settings. Do not delete or alter this - use the theme setting!
  128. if ($mode == FALSE) {
  129. // Build a keyed array of CSS file-names as key, and media query as value.
  130. // The file names must match the files in your themes CSS directory, if
  131. // you change them you must update to match.
  132. $files = array(
  133. // Maintian backwards compatibility with older themes that use smartphone
  134. 'responsive.smartphone.portrait' => at_get_setting('smalltouch_portrait_media_query', $theme_name) ? at_get_setting('smalltouch_portrait_media_query', $theme_name) : at_get_setting('smartphone_portrait_media_query', $theme_name),
  135. 'responsive.smartphone.landscape' => at_get_setting('smalltouch_landscape_media_query', $theme_name) ? at_get_setting('smalltouch_landscape_media_query', $theme_name) : at_get_setting('smartphone_landscape_media_query', $theme_name),
  136. // Standard files for the 7.x-3.2 and beyond
  137. 'responsive.smalltouch.portrait' => at_get_setting('smalltouch_portrait_media_query', $theme_name),
  138. 'responsive.smalltouch.landscape' => at_get_setting('smalltouch_landscape_media_query', $theme_name),
  139. 'responsive.tablet.portrait' => at_get_setting('tablet_portrait_media_query', $theme_name),
  140. 'responsive.tablet.landscape' => at_get_setting('tablet_landscape_media_query', $theme_name),
  141. 'responsive.desktop' => at_get_setting('bigscreen_media_query', $theme_name),
  142. );
  143. // Add the custom responsive stylesheet if enabled
  144. if (at_get_setting('enable_custom_media_queries', $theme_name) === 1) {
  145. $item = array('responsive.custom' => 'only screen');
  146. $files = array_merge($item, $files);
  147. }
  148. // Loop over the files array and load each CSS file.
  149. // at_load_subtheme_responsive_styles() takes three parameters:
  150. // - $css_file - the name of the css file
  151. // - $media_query - the media query from theme settings
  152. // - $theme_name - to generate the path-to-theme for drupal_add_css()
  153. foreach ($files as $key => $value) {
  154. $filepath = drupal_get_path('theme', $theme_name) . '/css/' . $key . '.css';
  155. $media_query = $value;
  156. at_load_subtheme_responsive_styles($filepath, $media_query, $theme_name, $weight = 100);
  157. }
  158. }
  159. // Production Mode
  160. // In Production mode we only load one file for our design styles.
  161. // We use a media query to prevent non media query browsers from downloading it.
  162. // The embedded media queries in this file take precedence always.
  163. elseif ($mode == TRUE) {
  164. $filepath = $path . '/' . $theme_name . '.responsive.styles.css';
  165. $media_query = 'only screen'; // keyword "only" should hide this from older user agents
  166. at_load_subtheme_responsive_styles($filepath, $media_query, $theme_name, $weight = 100);
  167. }
  168. }
  169. /**
  170. * Load Extension Settings CSS.
  171. *
  172. * @param $theme_name
  173. */
  174. function at_load_extensions_css($theme_name) {
  175. global $path_to_at_core;
  176. $settings_css = array();
  177. // Heading settings
  178. if (at_get_setting('enable_heading_settings', $theme_name) === 1) {
  179. $settings_css[] = 'at.settings.style.headings.css';
  180. }
  181. // Image alignment settings
  182. if (at_get_setting('enable_image_settings', $theme_name) === 1) {
  183. $settings_css[] = 'at.settings.style.image.css';
  184. }
  185. // Float block settings
  186. if (at_get_setting('enable_float_region_blocks', $theme_name) === 1) {
  187. $settings_css[] = 'at.settings.style.floatblocks.css';
  188. }
  189. // Login block settings
  190. if (at_get_setting('horizontal_login_block_enable', $theme_name) === 'on') {
  191. if (at_get_setting('horizontal_login_block', $theme_name) === 1) {
  192. $settings_css[] = 'at.settings.style.login.css';
  193. }
  194. }
  195. if (!empty($settings_css)) {
  196. foreach ($settings_css as $css_file) {
  197. $filepath = $path_to_at_core . '/css/' . $css_file;
  198. drupal_add_css($filepath, array(
  199. 'preprocess' => TRUE,
  200. 'group' => CSS_THEME,
  201. 'media' => 'screen',
  202. 'every_page' => TRUE,
  203. 'weight' => -100,
  204. )
  205. );
  206. }
  207. }
  208. else {
  209. $settings_css = NULL;
  210. }
  211. }
  212. /**
  213. * Load Fonts
  214. *
  215. * @param $path
  216. * @param $theme_name
  217. */
  218. function at_load_fonts($path, $theme_name) {
  219. // Google fonts
  220. $google_font_string = &drupal_static(__FUNCTION__, array());
  221. if (empty($google_font_string)) {
  222. $google_font_string = at_load_google_fonts($theme_name);
  223. }
  224. if (!empty($google_font_string)) {
  225. drupal_add_css($google_font_string, array(
  226. 'group' => CSS_THEME,
  227. 'type' => 'external',
  228. 'weight' => -100,
  229. )
  230. );
  231. }
  232. // Load the fonts CSS from public files
  233. $filepath = $path . '/' . $theme_name . '.fonts.css';
  234. if (file_exists($filepath)) {
  235. drupal_add_css($filepath, array(
  236. 'preprocess' => TRUE,
  237. 'group' => CSS_THEME,
  238. 'media' => 'screen',
  239. 'every_page' => TRUE,
  240. )
  241. );
  242. }
  243. else {
  244. at_load_failure($filepath, $theme_name);
  245. }
  246. }
  247. /**
  248. * Load custom css file.
  249. *
  250. * @param $path
  251. * @param $theme_name
  252. */
  253. function at_load_custom_css($path, $theme_name) {
  254. $filepath = $path . '/' . $theme_name . '.custom.css';
  255. if (file_exists($filepath)) {
  256. drupal_add_css($filepath, array(
  257. 'preprocess' => TRUE,
  258. 'group' => CSS_THEME,
  259. 'weight' => 1000,
  260. 'media' => 'screen',
  261. 'every_page' => TRUE,
  262. )
  263. );
  264. }
  265. else {
  266. at_load_failure($filepath, $theme_name);
  267. }
  268. }
  269. /**
  270. * Load Polyfill Scripts
  271. * Conditional scripts are returned to the preprocess function - in AT Core that
  272. * means adaptivetheme_preprocess_html() and adaptivetheme_preprocess_maintenance_page().
  273. * There are two sources for conditional scripts - the subtheme info file and
  274. * AT Core itself can load html5.js and respond.js.
  275. * Unconditional scripts (those not printed within an IE conditioanl comment)
  276. * load directly via drupal_add_js in this function, while the conditional scripts
  277. * are returned as an array to preprocess, then rendered in process. This is done
  278. * to allow themers to manipulate the data structure in preprocess if they feel
  279. * the need to.
  280. *
  281. * @param $theme_name
  282. */
  283. function at_load_polyfills($theme_name) {
  284. global $path_to_at_core;
  285. // Get the info file data
  286. $info = at_get_info($theme_name);
  287. // Build an array of polyfilling scripts
  288. $polyfills = &drupal_static('adaptivetheme_preprocess_html_polyfills_array');
  289. if (empty($polyfills)) {
  290. $theme_path = drupal_get_path('theme', $theme_name);
  291. $polyfills_array = array();
  292. // Info file loaded conditional scripts
  293. if (array_key_exists('ie_scripts', $info)) {
  294. foreach ($info['ie_scripts'] as $condition => $ie_scripts_path) {
  295. foreach ($ie_scripts_path as $key => $value) {
  296. $filepath = $theme_path . '/' . $value;
  297. $polyfills_array['ie'][$condition][] = at_theme_conditional_script($filepath);
  298. }
  299. }
  300. }
  301. // AT Core Conditional Scripts
  302. if (at_get_setting('load_html5js') === 1) {
  303. $polyfills_array['ie']['lt IE 9'][] = at_theme_conditional_script($path_to_at_core . '/scripts/html5.js');
  304. }
  305. if (at_get_setting('load_respondjs') === 1) {
  306. $polyfills_array['ie']['lt IE 9'][] = at_theme_conditional_script($path_to_at_core . '/scripts/respond.js');
  307. }
  308. // AT Core Un-conditional Scripts
  309. if (at_get_setting('load_scalefixjs') === 1) {
  310. $polyfills_array['all'][] = 'scripts/scalefix.js';
  311. }
  312. if (at_get_setting('load_onmediaqueryjs') === 1) {
  313. $polyfills_array['all'][] = 'scripts/onmediaquery.js';
  314. }
  315. if (at_get_setting('load_matchmediajs') === 1) {
  316. $polyfills_array['all'][] = 'scripts/matchMedia.js';
  317. $polyfills_array['all'][] = 'scripts/matchMedia.addListener.js';
  318. }
  319. // Load Polyfills
  320. if (!empty($polyfills_array)) {
  321. // Default query string for cache control finger printing
  322. $query_string = variable_get('css_js_query_string', '0');
  323. // "all" - no conditional comment needed, use drupal_add_js()
  324. if (isset($polyfills_array['all'])) {
  325. foreach ($polyfills_array['all'] as $script) {
  326. drupal_add_js($path_to_at_core . '/' . $script, array(
  327. 'type' => 'file',
  328. 'scope' => 'header',
  329. 'group' => JS_THEME,
  330. 'preprocess' => TRUE,
  331. 'cache' => TRUE,
  332. )
  333. );
  334. }
  335. }
  336. // IE conditional scripts, we need some semblance of structered data...
  337. if (isset($polyfills_array['ie'])) {
  338. $polyfills = array();
  339. foreach ($polyfills_array['ie'] as $conditional_comment => $scripts) {
  340. $ie_script = array(
  341. '#type' => 'markup',
  342. '#markup' => implode("\n", $scripts),
  343. '#prefix' => "<!--[if " . $conditional_comment . "]>\n",
  344. '#suffix' => "\n<![endif]-->\n",
  345. );
  346. $polyfills[$conditional_comment] = $ie_script;
  347. }
  348. }
  349. }
  350. else {
  351. $polyfills = '';
  352. }
  353. }
  354. return $polyfills;
  355. }
  356. /**
  357. * Load debugging helper files.
  358. *
  359. * @param $theme_name
  360. */
  361. function at_load_debuggers($theme_name) {
  362. global $path_to_at_core;
  363. // Do some debugging/development stuff
  364. if (at_get_setting('expose_regions', $theme_name) === 1) {
  365. drupal_add_css($path_to_at_core . '/css/debug-regions.css');
  366. }
  367. if (at_get_setting('load_all_panels', $theme_name) === 1) {
  368. drupal_add_css($path_to_at_core . '/css/debug-panels.css', array(
  369. 'preprocess' => FALSE,
  370. 'group' => CSS_THEME,
  371. 'media' => 'screen',
  372. 'every_page' => FALSE,
  373. 'weight' => 2000,
  374. )
  375. );
  376. }
  377. // Load window size bookmarklet
  378. if (at_get_setting('show_window_size', $theme_name) === 1) {
  379. drupal_add_js($path_to_at_core . '/scripts/window-size.js', array(
  380. 'type' => 'file',
  381. 'scope' => 'footer',
  382. 'group' => JS_THEME,
  383. 'preprocess' => TRUE,
  384. 'cache' => TRUE,
  385. )
  386. );
  387. drupal_add_css($path_to_at_core . '/css/debug-windowsize.css', array(
  388. 'preprocess' => FALSE,
  389. 'group' => CSS_THEME,
  390. 'media' => 'screen',
  391. 'every_page' => FALSE,
  392. 'weight' => 2000,
  393. )
  394. );
  395. }
  396. }
  397. /**
  398. * Load Sub-theme Responsive Stylesheets.
  399. * Wrapper function for drupal_add_css() that takes advantage of Drupals's
  400. * CSS aggregation logic to trick Drupal into always loading responsive
  401. * stylesheets in link elements.
  402. *
  403. * This is almost always called from adaptivetheme_preprocess_html(), only in
  404. * a rare instance might this be called from a sub-theme (to load additional
  405. * responsive stylesheets).
  406. *
  407. * @param $filepath, path to the CSS file.
  408. * @param $media_query, the media query from theme settings.
  409. * @param $theme_name, the active theme.
  410. * @param $weight, optional.
  411. */
  412. function at_load_subtheme_responsive_styles($filepath, $media_query, $theme_name, $weight = 0) {
  413. if (file_exists($filepath)) {
  414. drupal_add_css($filepath, array(
  415. 'preprocess' => variable_get('preprocess_css', '') == 1 ? TRUE : FALSE,
  416. 'group' => CSS_THEME,
  417. 'media' => $media_query,
  418. 'every_page' => TRUE,
  419. 'weight' => $weight,
  420. )
  421. );
  422. }
  423. }
  424. /**
  425. * Build arrays of conditional styles to load
  426. * Sub-themes can declare conditional stylesheets in the info file, we need to
  427. * get this info file data and process it.
  428. *
  429. * @param $theme_name, the active theme.
  430. */
  431. function at_load_subtheme_conditional_styles($theme_name) {
  432. $info = &drupal_static(__FUNCTION__, array());
  433. if (empty($info)) {
  434. // Get the info file data
  435. $info = at_get_info($theme_name);
  436. // General IE stylesheets from the info file
  437. if (array_key_exists('ie_stylesheets', $info)) {
  438. $ie_style = '';
  439. foreach ($info['ie_stylesheets'] as $media => $stylesheets) {
  440. // Set default value for media in case the themer forgets, all is an
  441. // "assumed" value and not printed in the output.
  442. if (is_numeric($media)) {
  443. $media = 'all';
  444. }
  445. foreach ($stylesheets as $condition => $file) {
  446. foreach($file as $ie_styles_path) {
  447. $ie_style['media'] = $media;
  448. $ie_style['condition'] = $condition;
  449. $ie_style['path'] = $ie_styles_path;
  450. $filepath = drupal_get_path('theme', $theme_name) . '/' . $ie_style['path'];
  451. at_load_conditional_styles($filepath, $ie_style, $theme_name);
  452. }
  453. }
  454. }
  455. }
  456. }
  457. }
  458. /**
  459. * Load Sub-theme IE Stylesheets.
  460. * Wrapper function for drupal_add_css() that makes use the 'browser' option
  461. * to load stylesheets for Internet Explorer.
  462. *
  463. * @param $filepath, path to the file.
  464. * @param $ie_style, an arry containing the media attribute value and the IE
  465. * conditional comment.
  466. * @param $theme_name, the active theme.
  467. * @param $weight, optional.
  468. */
  469. function at_load_conditional_styles($filepath, $ie_style, $theme_name, $weight = 0) {
  470. if (file_exists($filepath)) {
  471. drupal_add_css($filepath, array(
  472. 'group' => CSS_THEME,
  473. 'browsers' => array(
  474. 'IE' => $ie_style['condition'],
  475. '!IE' => FALSE,
  476. ),
  477. 'media' => $ie_style['media'],
  478. 'preprocess' => TRUE,
  479. 'weight' => $weight,
  480. )
  481. );
  482. }
  483. else {
  484. at_load_failure($filepath, $theme_name);
  485. }
  486. }
  487. /**
  488. * Load scripts from the sub-theme
  489. * Wrapper function for drupal_add_js(). In the core theme this is only used to
  490. * load media_queries.js if the Responsive JavaScript plugin is enabled in theme
  491. * settings. You can call this in your subtheme.
  492. *
  493. * @param $filepath, path to the file.
  494. * @param $theme_name, the active theme.
  495. * @param $scope, header or footer.
  496. * @param $weight, optional.
  497. */
  498. function at_load_subtheme_script($filepath, $theme_name, $scope, $weight = NULL) {
  499. $filepath = drupal_get_path('theme', $theme_name) . '/' . $filepath;
  500. if (file_exists($filepath)) {
  501. drupal_add_js($filepath, array(
  502. 'type' => 'file',
  503. 'scope' => $scope,
  504. 'group' => JS_THEME,
  505. 'weight' => $weight,
  506. 'preprocess' => TRUE,
  507. 'cache' => TRUE,
  508. )
  509. );
  510. }
  511. }
  512. /**
  513. * Return a themed script.
  514. * Since Drupal 7 does not (yet) support the 'browser' option in drupal_add_js()
  515. * Adaptivetheme provides a way to load scripts inside conditional comments.
  516. * This function wraps a file in script elements and returns a string.
  517. *
  518. * @param $filepath, path to the file.
  519. */
  520. function at_theme_conditional_script($filepath) {
  521. $script = '';
  522. // We need the default query string for cache control finger printing
  523. $query_string = variable_get('css_js_query_string', '0');
  524. if (file_exists($filepath)) {
  525. $file = file_create_url($filepath);
  526. $script = '<script src="' . $file . '?' . $query_string . '"></script>';
  527. }
  528. return $script;
  529. }
  530. /**
  531. * Google Font loader.
  532. * Adaptivetheme can load websafe fonts, Google fonts, custom font stacks and
  533. * integrate with @font-your-face module. All can be configured in the "Fonts"
  534. * theme settings. Here we only need to load Google webfonts. Websafe and custom
  535. * fonts are stored in a generated CSS file (in public files) and
  536. * @font-your-face module takes care of loading its own fonts.
  537. *
  538. * @param $theme_name
  539. */
  540. function at_load_google_fonts($theme_name) {
  541. $google_font_string = &drupal_static(__FUNCTION__, array());
  542. if (empty($google_font_string)) {
  543. $used_fonts = array();
  544. $font_elements = font_elements();
  545. $charsets = google_font_charsets();
  546. $styles = google_font_styles();
  547. $used_styles = array();
  548. $used_charsets = array();
  549. foreach ($font_elements as $key => $value) {
  550. $setting = $value['setting'];
  551. if (at_get_setting($setting . '_type', $theme_name) === 'gwf') {
  552. $used_settings[] = $setting . '_gwf';
  553. $font_name = at_get_setting($setting . '_gwf', $theme_name);
  554. $used_font = str_replace(' ', '+', $font_name);
  555. $used_fonts[] = $used_font;
  556. }
  557. }
  558. if (!empty($used_fonts)) {
  559. $used_fonts = array_unique($used_fonts);
  560. $google_fonts = implode('|', $used_fonts);
  561. foreach ($used_settings as $used_setting) {
  562. // Styles
  563. if (at_get_setting($used_setting . '_add_styles', $theme_name) === 1) {
  564. foreach ($styles as $styles_key => $styles_value) {
  565. if (at_get_setting($used_setting . '_add_styles_' . $styles_key, $theme_name)) {
  566. $used_styles[] = $styles_key;
  567. }
  568. }
  569. }
  570. // Charsets
  571. if (at_get_setting($used_setting . '_add_charsets', $theme_name) === 1) {
  572. foreach ($charsets as $charset_key => $charset_value) {
  573. if (at_get_setting($used_setting . '_add_charsets_' . $charset_key, $theme_name)) {
  574. $used_charsets[] = $charset_key;
  575. }
  576. }
  577. }
  578. }
  579. if (!empty($used_styles)) {
  580. $styles_array = array_unique($used_styles);
  581. $google_styles = ':' . implode(',', $styles_array);
  582. }
  583. else {
  584. $google_styles = '';
  585. }
  586. if (!empty($used_charsets)) {
  587. $charset_array = array_unique($used_charsets);
  588. $google_charsets = '&subset=' . implode(',', $charset_array);
  589. }
  590. else {
  591. $google_charsets = '';
  592. }
  593. // Build the final string
  594. $google_font_string = '//fonts.googleapis.com/css?family=' . $google_fonts . $google_styles . $google_charsets;
  595. }
  596. }
  597. return $google_font_string;
  598. }
  599. /**
  600. * Add js settings for the layout type and media query
  601. */
  602. function at_load_layout_js_settings($theme_name) {
  603. $breakpoints = array(
  604. 'bigscreen',
  605. 'tablet_landscape',
  606. 'tablet_portrait',
  607. 'smalltouch_landscape',
  608. 'smalltouch_portrait',
  609. );
  610. $cfg = array();
  611. foreach ($breakpoints as $breakpoint) {
  612. $layout = at_get_setting($breakpoint . '_layout', $theme_name);
  613. $media_query = at_get_setting($breakpoint . '_media_query', $theme_name);
  614. if ($layout) {
  615. $layout = str_replace('_', '-', $layout);
  616. $cfg[$theme_name]['layout_settings'][$breakpoint] = $layout;
  617. }
  618. if ($media_query) {
  619. check_plain($media_query);
  620. $cfg[$theme_name]['media_query_settings'][$breakpoint] = $media_query;
  621. }
  622. }
  623. drupal_add_js(array('adaptivetheme' => $cfg), 'setting');
  624. }
  625. /**
  626. * Return JS and CSS for the Menu Toggle for mobile.
  627. */
  628. function at_load_menu_toggle($path, $theme_name) {
  629. // Add JS settings for each enabled option (breakpoint)
  630. $menu_toggle_settings = array(
  631. 'menu_toggle_tablet_portrait',
  632. 'menu_toggle_tablet_landscape',
  633. );
  634. $cfg = array();
  635. foreach ($menu_toggle_settings as $toggle_setting) {
  636. $setting = at_get_setting($toggle_setting, $theme_name);
  637. if ($setting == 1) {
  638. $cfg[$theme_name]['menu_toggle_settings'][$toggle_setting] = 'true';
  639. }
  640. else {
  641. $cfg[$theme_name]['menu_toggle_settings'][$toggle_setting] = 'false';
  642. }
  643. }
  644. drupal_add_js(array('adaptivetheme' => $cfg), 'setting');
  645. $path_to_at_core = drupal_get_path('theme', 'adaptivetheme');
  646. // Load additional plugins
  647. drupal_add_js($path_to_at_core . '/scripts/outside-events.js', array(
  648. 'type' => 'file',
  649. 'scope' => 'header',
  650. 'group' => JS_THEME,
  651. 'weight'=> 999,
  652. 'preprocess' => TRUE,
  653. 'cache' => TRUE,
  654. )
  655. );
  656. // Load the JS file
  657. drupal_add_js($path_to_at_core . '/scripts/menu-toggle.js', array(
  658. 'type' => 'file',
  659. 'scope' => 'header',
  660. 'group' => JS_THEME,
  661. 'weight'=> 999,
  662. 'preprocess' => TRUE,
  663. 'cache' => TRUE,
  664. )
  665. );
  666. // Load the generated CSS
  667. $filepath = $path . '/' . $theme_name . '.menutoggle.css';
  668. if (file_exists($filepath)) {
  669. drupal_add_css($filepath, array(
  670. 'preprocess' => TRUE,
  671. 'group' => CSS_THEME,
  672. 'media' => 'all',
  673. 'every_page' => TRUE,
  674. 'weight' => 99,
  675. )
  676. );
  677. }
  678. }
  679. //
  680. // Functions to maintain 7.x-2.x backward compatibility,
  681. // DO NOT use these for 7.x-3.x or greater.
  682. // Note to self - do not namespace these, that will certainly break existing sites.
  683. //
  684. // Load sub-theme media queries, 7.x-2.x backward compatibility
  685. function load_subtheme_media_queries($files, $theme_name) {
  686. $path_to_theme = drupal_get_path('theme', $theme_name);
  687. foreach ($files as $file) {
  688. $filepath = $path_to_theme . '/css/' . $file;
  689. if (file_exists($filepath)) {
  690. drupal_add_css($filepath, array(
  691. 'preprocess' => variable_get('preprocess_css', '') == 1 ? TRUE : FALSE,
  692. 'group' => CSS_THEME,
  693. 'media' => 'all',
  694. 'every_page' => TRUE,
  695. 'weight' => 99,
  696. )
  697. );
  698. }
  699. else {
  700. at_load_failure($filepath, $theme_name);
  701. }
  702. }
  703. }
  704. // Load subtheme IE stylesheets, 7.x-2.x backward compatibility
  705. function load_subtheme_ie_styles($files, $theme_name) {
  706. $path_to_theme = drupal_get_path('theme', $theme_name);
  707. foreach ($files as $key => $value) {
  708. $filepath = $path_to_theme . '/css/' . $value;
  709. if (file_exists($filepath)) {
  710. drupal_add_css($filepath, array(
  711. 'group' => CSS_THEME,
  712. 'browsers' => array(
  713. 'IE' => $key,
  714. '!IE' => FALSE,
  715. ),
  716. 'media' => 'screen',
  717. 'preprocess' => TRUE,
  718. )
  719. );
  720. }
  721. else {
  722. at_load_failure($filepath, $theme_name);
  723. }
  724. }
  725. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.