system.inc in OM Tools 8
Same filename and directory in other branches
System Utility
File
tools/system/system.incView source
<?php
/**
* @file
* System Utility
*/
/**
* OM Tools System Utility Settings
*
*/
function om_system(&$form) {
drupal_add_js(drupal_get_path('module', 'om_tools') . '/tools/system/js/system.js', 'file');
$maxsizes = '1600, 1440, 1280, 1120, 960, 800, 640, 480';
$theme_path = path_to_theme();
$form['system_forms'] = array(
'#type' => 'fieldset',
'#title' => t('System Forms'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Reset Node Form
if (variable_get('om_tools_mediaqueries_reset', 0)) {
variable_set('om_tools_mediaqueries_maxsizes', $maxsizes);
variable_set('om_tools_mediaqueries_reset', 0);
}
// Media Queries Form
$form['system_forms']['mediaqueries_form'] = array(
'#type' => 'fieldset',
'#title' => t('Media Queries'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['system_forms']['mediaqueries_form']['mediaqueries_switch'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Media Queries'),
'#default_value' => variable_get('om_tools_mediaqueries_switch', 0),
'#description' => t(''),
);
$form['system_forms']['mediaqueries_form']['mediaqueries'] = array(
'#type' => 'fieldset',
'#attributes' => array(
'id' => 'om-group-mediaqueries-settings',
),
'#title' => t('Media Queries Stylesheet Settings for desktop, tablet, mobile devices.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Add all desired maximum widths, separated by comma, ex. 960, 800. Then create the stylesheets, ex style960.css, style.800.css, each stylesheet will then be activated depending on the size of browser\'s viewport.'),
);
$form['system_forms']['mediaqueries_form']['mediaqueries']['mediaqueries_maxsizes'] = array(
'#type' => 'textarea',
'#title' => t('Add all max-width for this site.'),
'#default_value' => variable_get('om_tools_mediaqueries_maxsizes', $maxsizes),
'#rows' => 5,
'#description' => t('Standard sizes: 1600, 1440, 1280, 1120, 960, 800, 640, 480'),
);
$form['system_forms']['mediaqueries_form']['mediaqueries']['mediaqueries_path'] = array(
'#type' => 'textfield',
'#title' => t('Stylesheets path'),
'#default_value' => variable_get('om_tools_mediaqueries_path', $theme_path),
'#width' => 30,
'#description' => t('Where do your media stylesheets located? ex. sites/default/themes/mytheme/css'),
);
$form['system_forms']['mediaqueries_form']['mediaqueries_reset'] = array(
'#type' => 'checkbox',
'#title' => t('Reset to default values.'),
'#default_value' => variable_get('om_tools_mediaqueries_reset', 0),
'#description' => t(''),
);
return $form;
}
/**
* Override or insert om variables into the templates.
*/
function om_system_preprocess_html(&$vars) {
if (variable_get('om_tools_mediaqueries_switch', 0)) {
/**
* Mediaqueries
* http://plugins.jquery.com/project/MediaQueries
*
* - rename jquery.mediaqueries.js to mediaqueries.js
*
*/
drupal_add_js(drupal_get_path('module', 'om_tools') . '/contrib/mediaqueries.js', 'file');
}
}
/**
* Override or insert om variables into the templates.
*/
function om_system_process_html(&$vars) {
if (variable_get('om_tools_mediaqueries_switch', 0)) {
$maxsizes = '1600, 1440, 1280, 1120, 960, 800, 640, 480';
$theme_path = path_to_theme();
$theme_path_default = variable_get('om_tools_mediaqueries_path', $theme_path);
$styles = explode(',', variable_get('om_tools_mediaqueries_maxsizes', $maxsizes));
foreach ($styles as $key => $style) {
if (is_numeric($style)) {
$vars['styles'] .= '<link rel="stylesheet" type="text/css" href="' . base_path() . $theme_path_default . '/style' . trim($style) . '.css" media="only screen and (max-width: ' . $style . 'px)" />';
}
}
//dsm($vars);
}
}
Functions
Name | Description |
---|---|
om_system | OM Tools System Utility Settings |
om_system_preprocess_html | Override or insert om variables into the templates. |
om_system_process_html | Override or insert om variables into the templates. |