Newer
Older
<?php
/*
* @todo
*/
function alpha_theme_settings_general(&$form, &$form_state) {
$theme = $form_state['build_info']['args'][0];
$scales = alpha_scale_options(1, 10, 0.5);
$optional = alpha_css_options($theme);
$responsive = alpha_css_options($theme, TRUE);
$form['alpha_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => -10,
'#prefix' => t('<h3>Layout configuration</h3>'),
);
$form['alpha_settings']['layout'] = array(
'#type' => 'fieldset',
'#title' => t('Grid settings'),
);
$form['alpha_settings']['layout']['alpha_grid'] = array(
'#type' => 'select',
'#description' => t('Select the grid system that you want to use for this layout.'),
'#title' => t('Grid system'),
'#default_value' => $settings['grid'],
$form['alpha_settings']['layout']['alpha_responsive'] = array(
'#type' => 'checkbox',
'#description' => t('<p>The responsive layout allows the grid to resize based on the size of the users device. This incorporates mobile first design, so the default behavior is to show the simplest (stacked) version of the layout, and for devices that meet certain display criteria (width), new CSS and grid sizing will be applied.</p><p class="marker">The fluid grid doesn\'t support this feature.</p>'),
'#default_value' => $settings['responsive']['enabled'],
);
$form['alpha_settings']['layout']['responsive_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Responsive grid settings'),
':input[name="alpha_responsive"]' => array('checked' => TRUE),
'narrow' => array(
'description' => t('The narrow grid is designed to work well for tablets in a portrait viewing mode.'),
'media' => 'all',
),
'normal' => array(
'description' => t('The normal grid is designed to work well for tablets in a landscape viewing mode and most web browsers.'),
'media' => 'all',
),
'wide' => array(
'description' => t('The wide grid is designed to work well for users with a lot of screen real estate. However, this may not look well in a single sidebar layout. Design considerations must be made when using this layout.'),
'media' => 'all',
),
foreach ($options as $type => $item) {
$form['alpha_settings']['layout']['responsive_settings']['alpha_responsive_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Enable @type grid', array('@type' => $type)),
'#description' => $item['description'],
'#default_value' => $settings['responsive'][$type]['enabled'],
);
$form['alpha_settings']['layout']['responsive_settings']['alpha_responsive_' . $type . '_media'] = array(
'#type' => 'textfield',
'#title' => t('Media'),
'#description' => t('The @media tag that you want to use for the @type grid.', array('@type' => $type)),
'#default_value' => $settings['responsive'][$type]['media'],
'#states' => array(
'visible' => array(
':input[name="alpha_responsive_' . $type . '"]' => array('checked' => TRUE),
),
),
);
if (!empty($optional)) {
$form['alpha_settings']['layout']['responsive_settings']['styles_' . $type] = array(
'#type' => 'fieldset',
'#title' => t('Optional styles'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#states' => array(
'visible' => array(
':input[name="alpha_responsive_' . $type . '"]' => array('checked' => TRUE),
),
),
);
$form['alpha_settings']['layout']['responsive_settings']['styles_' . $type]['alpha_responsive_' . $type . '_css'] = array(
'#type' => 'checkboxes',
'#options' => $responsive,
'#responsive' => TRUE,
'#default_value' => array_keys($settings['responsive'][$type]['css']),
'#element_validate' => array('alpha_theme_settings_css_validate'),
);
}
}
$form['alpha_settings']['layout']['responsive_settings']['alpha_viewport'] = array(
'#title' => t('Allow customizing viewport meta properties on iOS and Android devices'),
'#description' => t('By default, most mobile browsers choose their own way to handle page rendering by using the viewport meta tag. iOS and Android are "capable" of displaying full size websites by simply scaling down the view. However, when using a truly mobile version of your theme, you will / may want to customize these settings. You can find more information about this in the <a href="http://alpha.developmentgeeks.com">Omega documentation</a>.'),
'#default_value' => $settings['viewport']['enabled'],
$form['alpha_settings']['layout']['responsive_settings']['viewport_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Viewport settings'),
':input[name="alpha_viewport"]' => array('checked' => TRUE),
':input[name="alpha_responsive"]' => array('checked' => TRUE),
$form['alpha_settings']['layout']['responsive_settings']['viewport_settings']['alpha_viewport_initial_scale'] = array(
'#type' => 'select',
'#title' => t('Initial scale'),
'#default_value' => $settings['viewport']['initial'],
'#options' => $scales,
'#description' => t('The initial scaling of the page. This should almost always be set to 1.0.'),
);
$form['alpha_settings']['layout']['responsive_settings']['viewport_settings']['alpha_viewport_min_scale'] = array(
'#type' => 'select',
'#title' => t('Minimum scale'),
'#default_value' => $settings['viewport']['min'],
'#options' => $scales,
'#description' => t('The minimum scaling of the site. This should usually be the same as your <em>Initial scale</em> setting.'),
);
$form['alpha_settings']['layout']['responsive_settings']['viewport_settings']['alpha_viewport_max_scale'] = array(
'#type' => 'select',
'#title' => t('Maximum scale'),
'#default_value' => $settings['viewport']['max'],
'#options' => $scales,
'#description' => t('The maximum scaling of the site. This can be any value between 1 and 10, but should not be too big if you want to preserve your mobile look and feel.'),
);
$form['alpha_settings']['layout']['responsive_settings']['viewport_settings']['alpha_viewport_user_scaleable'] = array(
'#type' => 'checkbox',
'#title' => t('Scalable by user'),
'#description' => t('<p>Determine if a user can resize the screen. This is usually accomplished via multi-touch gestures on iOS and Android devices. If your mobile theme is very customized and presented with good typography and graphics for a reduced mobile size, it is recommended to leave this setting unchecked. If it is left unchecked, the min-scale and max-scale properties will be ignored.</p><p class="marker">HTC Android devices do NOT (currently) respect the viewport meta tag for <em>user-scalable</em>. It will render at the appropriate <em>initial-scale</em> set above, but a user can still zoom in/out.</p>'),
'#default_value' => $settings['viewport']['user'],
if (!empty($optional)) {
$form['alpha_settings']['styles'] = array(
'#type' => 'fieldset',
'#title' => t('Toggle styles'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['alpha_settings']['styles']['alpha_css'] = array(
'#type' => 'checkboxes',
'#options' => $optional,
'#responsive' => FALSE,
'#default_value' => array_keys($settings['css']),
'#element_validate' => array('alpha_theme_settings_css_validate'),
);
}
$form['alpha_settings']['overlay'] = array(
'#type' => 'fieldset',
'#title' => t('Debugging'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['alpha_settings']['overlay']['alpha_debug_block_toggle'] = array(
'#type' => 'checkbox',
'#title' => t('Enable the debugging (placeholder) blocks for theme development.'),
'#default_value' => $settings['debug']['block'],
);
$form['alpha_settings']['overlay']['alpha_debug_grid_toggle'] = array(
'#type' => 'checkbox',
'#title' => t('Enable grid overlay for selected roles.'),
'#default_value' => $settings['debug']['grid'],
$form['alpha_settings']['overlay']['alpha_debug_grid_load'] = array(
'#type' => 'checkbox',
'#title' => t('Turn on grid overlay on page load by default.'),
'#default_value' => $settings['debug']['auto'],
);
$form['alpha_settings']['overlay']['alpha_debug_grid_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Roles that may use the grid overlay / debugging tool.'),
'#default_value' => $settings['debug']['roles'],
'#options' => array_map('check_plain', user_roles()),
);
foreach (array('theme_settings', 'logo', 'favicon') as $element) {
$form['alpha_settings'][$element] = $form[$element];
unset($form[$element], $form['alpha_settings'][$element]['#description'], $form['alpha_settings'][$element]['#attributes']);
}
}
/*
* @todo
*/
function alpha_theme_settings_css_validate(&$element, &$form_state) {
$theme = $form_state['build_info']['args'][0];
$value = array();
$info = alpha_css($theme, $element['#responsive']);