View source
<?php
function commerce_kickstart_image_default_styles() {
$styles = array();
$styles['frontpage_block'] = array(
'name' => 'frontpage_block',
'effects' => array(
1 => array(
'label' => 'Scale and crop',
'help' => 'Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.',
'effect callback' => 'image_scale_and_crop_effect',
'dimensions callback' => 'image_resize_dimensions',
'form callback' => 'image_resize_form',
'summary theme' => 'image_resize_summary',
'module' => 'image',
'name' => 'image_scale_and_crop',
'data' => array(
'width' => '270',
'height' => '305',
),
'weight' => '1',
),
),
);
return $styles;
}
function commerce_kickstart_form_install_configure_form_alter(&$form, $form_state) {
if (drupal_is_cli()) {
return;
}
$form['site_information']['site_name']['#title'] = 'Store name';
$form['site_information']['site_mail']['#title'] = 'Store email address';
$form['site_information']['site_name']['#default_value'] = st('Commerce Kickstart');
$form['server_settings']['site_default_country']['#default_value'] = 'US';
$form['admin_account']['account']['name']['#default_value'] = 'admin';
$form['admin_account']['account']['pass']['#value'] = 'admin';
$form['update_notifications']['#access'] = FALSE;
$form['admin_account']['account']['commerce_kickstart_name'] = array(
'#type' => 'item',
'#title' => st('Username'),
'#markup' => 'admin',
);
$form['admin_account']['account']['commerce_kickstart_password'] = array(
'#type' => 'item',
'#title' => st('Password'),
'#markup' => 'admin',
);
$form['admin_account']['account']['commerce_kickstart_informations'] = array(
'#markup' => '<p>' . t('This information will be emailed to the store email address.') . '</p>',
);
$form['admin_account']['override_account_informations'] = array(
'#type' => 'checkbox',
'#title' => t('Change my username and password.'),
);
$form['admin_account']['setup_account'] = array(
'#type' => 'container',
'#parents' => array(
'admin_account',
),
'#states' => array(
'invisible' => array(
'input[name="override_account_informations"]' => array(
'checked' => FALSE,
),
),
),
);
$form['admin_account']['setup_account']['account']['name'] = $form['admin_account']['account']['name'];
$form['admin_account']['setup_account']['account']['pass'] = $form['admin_account']['account']['pass'];
$form['admin_account']['setup_account']['account']['pass']['#value'] = array(
'pass1' => 'admin',
'pass2' => 'admin',
);
$form['admin_account']['account']['name']['#access'] = FALSE;
$form['admin_account']['account']['pass']['#type'] = 'hidden';
$form['admin_account']['account']['mail']['#access'] = FALSE;
array_unshift($form['#validate'], 'commerce_kickstart_custom_setting');
}
function commerce_kickstart_custom_setting(&$form, &$form_state) {
$form_state['values']['account']['mail'] = $form_state['values']['site_mail'];
if ($form_state['values']['override_account_informations'] == TRUE) {
if ($form_state['input']['pass']['pass1'] == $form_state['input']['pass']['pass2']) {
$form_state['values']['account']['name'] = $form_state['values']['name'];
$form_state['values']['account']['pass'] = $form_state['input']['pass']['pass1'];
}
else {
form_set_error('pass', st('The specified passwords do not match.'));
}
}
}
function commerce_kickstart_system_info_alter(&$info, $file, $type) {
if (variable_get('install_task') != 'done') {
return;
}
$install_demo_store = variable_get('commerce_kickstart_demo_store', FALSE);
if ($install_demo_store) {
$hide_modules = array(
'commerce_kickstart_lite_product',
);
}
else {
$hide_modules = array(
'commerce_kickstart_product',
);
}
if ($type == 'module' && in_array($file->name, $hide_modules)) {
$info['hidden'] = TRUE;
}
}
function commerce_kickstart_crumbs_get_info() {
$crumbs = array(
'crumbs.home_title' => 0,
);
foreach (module_implements('commerce_kickstart_crumb_info') as $module) {
foreach (module_invoke($module, 'commerce_kickstart_crumb_info') as $crumb) {
if (is_array($crumb)) {
$crumbs += $crumb;
}
else {
$crumbs[$crumb] = count($crumbs);
}
}
}
$crumbs['*'] = count($crumbs);
asort($crumbs);
return $crumbs;
}
function commerce_kickstart_rebuild_feature($module) {
$feature = features_load_feature($module, TRUE);
$items[$module] = array_keys($feature->info['features']);
features_include_defaults(NULL, TRUE);
_features_restore('enable', $items);
features_include(TRUE);
$all_components = array_keys(features_get_components());
foreach ($items as $module => $components) {
$items[$module] = array_intersect($all_components, $components);
}
_features_restore('rebuild', $items);
}
function commerce_kickstart_features_api_alter(&$components) {
if (isset($components['field_base'])) {
$components['field_base']['duplicates'] = FEATURES_DUPLICATES_ALLOWED;
}
}
function commerce_kickstart_field_default_field_bases_alter(&$fields) {
if (module_exists('features_override')) {
$possible_alters = commerce_kickstart_get_fields_default_alters();
drupal_alter('field_default_fields_alter', $possible_alters);
foreach ($possible_alters as $identifier => $field_default) {
$field_name = $field_default['field_name'];
if (!isset($field_default['field_base']) || !isset($fields[$field_name])) {
continue;
}
$fields[$field_name] = drupal_array_merge_deep($fields[$field_name], $field_default['field_base']);
}
}
}
function commerce_kickstart_field_default_field_instances_alter(&$fields) {
if (module_exists('features_override')) {
$possible_alters = commerce_kickstart_get_fields_default_alters();
drupal_alter('field_default_fields', $possible_alters);
foreach ($possible_alters as $identifier => $field_default) {
if (!isset($field_default['field_instance']) || !isset($fields[$identifier])) {
continue;
}
$fields[$identifier] = drupal_array_merge_deep($fields[$identifier], $field_default['field_instance']);
}
}
}
function commerce_kickstart_get_fields_default_alters() {
$cache = drupal_static(__FUNCTION__, array());
if (empty($cache)) {
module_load_include('inc', 'features', 'features.export');
features_include();
features_include_defaults('field_instance');
$default_hook = features_get_default_hooks('field_instance');
foreach (array_keys(features_get_features()) as $module) {
if (module_hook($module, $default_hook)) {
$cache = array_merge($cache, call_user_func("{$module}_{$default_hook}"));
}
}
}
return $cache;
}