function table_trash_preprocess_html in Table Trash 7
Implements hook_preprocess_page().
File
- ./
table_trash.module, line 72 - table_trash.module
Code
function table_trash_preprocess_html($variables) {
ctools_include('export');
$decorations = ctools_export_crud_load_all('table_trash');
$path = current_path();
$path_alias = drupal_get_path_alias($path);
$settings = array();
foreach ($decorations as $decoration) {
if (isset($decorations->disabled) && $decorations->disabled == TRUE) {
continue;
}
if (!empty($decoration->data['selectors'])) {
$selectors = $decoration->data['selectors'];
if (drupal_match_path($path, $selectors['included_pages']) || drupal_match_path($path_alias, $selectors['included_pages'])) {
if (!drupal_match_path($path, $selectors['excluded_pages']) && !drupal_match_path($path_alias, $selectors['excluded_pages'])) {
$selector = key($decoration->data['decoration_json']);
$settings[$selector] = $decoration->data['decoration_json'][$selector];
// @see http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-dont-forget-the-viewport-meta-tag
// It's ok to call this more than once
table_trash_add_html_head();
// @TODO Can we insert <thead> for <table>s that do not have it?
}
}
}
}
if ($settings) {
$global_settings = variable_get('table_trash_global_settings');
drupal_add_js(drupal_get_path('module', 'table_trash') . "/js/table_trash.js");
drupal_add_js(array(
'table_trash' => $settings,
), array(
'type' => 'setting',
));
if ($global_settings['use_table_trash_css']) {
drupal_add_css(drupal_get_path('module', 'table_trash') . "/css/table_trash.css");
}
// Load the library based on the chosen loading method.
switch ($global_settings['load_from']) {
case 'module':
$library = libraries_load('datatables');
if (!empty($library['error'])) {
drupal_set_message($library['error message'], 'warning');
}
if ($global_settings['use_datatables_css']) {
drupal_add_css(drupal_get_path('module', 'table_trash') . "/library/DataTables/datatables.min.css");
}
break;
case 'cdn':
drupal_add_js(TT_DATATABLES_JS, 'external');
if ($global_settings['use_datatables_css']) {
drupal_add_css(TT_DATATABLES_CSS, 'external');
}
break;
case 'alternate':
drupal_add_js($global_settings['alternate_cdn_js'], 'external');
if ($global_settings['use_datatables_css']) {
drupal_add_css($global_settings['alternate_cdn_css'], 'external');
}
break;
}
}
}