array( 'name' => t('Variables'), 'description' => t('Override any Drupal variable for this virtual site.'), ), ); } function virtual_site_variables_feature_form($context) { $form = array(); if ($context['variables'] && file_exists($context['variables'])) { $context['variables'] = file_get_contents($context['variables']); } $form['variables'] = array( '#type' => 'textarea', '#title' => t('Variable(s) to override'), '#description' => t('Enter variables using a syntax similar to !INI files.', array('!INI' => l(t('INI'), 'http://en.wikipedia.org/wiki/INI_file', array('attributes' => array('target' => '_blank'))))), '#default_value' => $context['variables'], ); return $form; } function virtual_site_variables_feature_submit($form, $form_state) { if ($form_state['values']['variables']) { if ($form['#item']) { $directory = file_directory_path().'/sites'; file_check_directory($directory, FILE_CREATE_DIRECTORY); $file = file_save_data($form_state['values']['variables'], $directory.'/'.$form['#item']->sid.'.variables.info', FILE_EXISTS_REPLACE); if ($file) { return array('variables' => $file); } else { form_set_error('variables', t('Could not create file containing variables.')); } } else { form_set_error('variables', t('You need to create the site first before overriding variables.')); } } } function virtual_site_variables_feature($context) { global $conf; if ($context['variables'] && file_exists($context['variables'])) { $context['variables'] = drupal_parse_info_file($context['variables']); foreach ($context['variables'] as $name => $value) { $conf[$name] = $value; } } } ?>