Skip to content

Instantly share code, notes, and snippets.

@vdchristelle
Created September 9, 2013 07:52
Show Gist options
  • Select an option

  • Save vdchristelle/6492631 to your computer and use it in GitHub Desktop.

Select an option

Save vdchristelle/6492631 to your computer and use it in GitHub Desktop.
A fix for translation of labels in webforms. Just enable the god damn thing and your labels will be translated. Special thanks to Thierry Beeckmans! We are greatfull dude!
The Fixes module fixes all kinda stuff :)
1. Taxlangfix
2. A fix for translation of labels in webforms.
Just enable the god damn thing and your labemls will be translated.
Special thanks to Thierry Beeckmans! We are greatfull dude!
name = "Fixes"
description = "Module adds several fixes to your Drupal."
core = "7.x"
package = Fix
php = "5.2.4"
version = "7.x-1.0"
project = "custom"
dependencies[] = "views"
dependencies[] = "taxonomy"
;dependencies[] = "views_ui"
;features[ctools][] = "ds:ds:1"
;features[ctools][] = "linkit:linkit_profiles:1"
;features[ctools][] = "strongarm:strongarm:1"
;features[ctools][] = "views:views_default:3.0"
;features[ds_field_settings][] = "field_collection_item|field_slide|banner_large"
;features[ds_field_settings][] = "field_collection_item|field_slide|banner_small"
;features[ds_layout_settings][] = "node|slider|default"
;features[ds_view_modes][] = "banner_large"
;features[ds_view_modes][] = "banner_small"
;features[field][] = "field_collection_item-field_slide-field_banner_image"
;features[field][] = "field_collection_item-field_slide-field_banner_title"
;features[field][] = "node-slider-field_slide"
;features[image][] = "960_large"
;features[image][] = "960_small"
;features[linkit_profiles][] = "default"
;features[node][] = "slider"
;features[variable][] = "ds_extras_field_template"
;features[variable][] = "ds_extras_fields_extra"
;features[variable][] = "ds_extras_fields_extra_list"
;features[variable][] = "ds_extras_switch_view_mode"
;features[variable][] = "field_bundle_settings_field_collection_item__field_slide"
;features[variable][] = "menu_options_slider"
;features[variable][] = "menu_parent_slider"
;features[variable][] = "node_options_slider"
;features[variable][] = "node_preview_slider"
;features[variable][] = "node_submitted_slider"
;features[views_view][] = "banner"
<?php
/**
* @file
* Custom code for your dupal 7 site
*/
/**
* Implements hook_help().
*/
function fixes_help($path, $arg) {
switch ($path) {
case 'admin/help#fixes':
//$output = file_get_contents(drupal_get_path('module', 'the_aim_custom') . '/README.txt');
//return nl2br($output);
return t('<h1>A fix for translation of labels in webforms.</h1>
<p>Just enable the god damn thing and your labemls will be translated.</p>
<p>Special thanks to Thierry Beeckmans! We are greatfull dude!</p>
');
}
}
/**
* Implements hook_admin function
* ADD CONFIG PAGE TO YOUR MODULE
*/
function fixes_admin() {
$form = array();
$form['fixes_options'] = array(
'#type' => 'textarea',
'#title' => t('Overview'),
//'#default_value' => variable_get('fixes_options'),
//'#selected' => variable_get('fixes_options', 3),
//'#size' => 1,
//'#maxlength' => 2,
'#description' => t("Choose which fixes you would like to use"),
'#required' => FALSE,
);
return system_settings_form($form);
}
/**
* Implements hook_menu function
* ADDS CONFIG PAGE TO YOUR MODULE
*/
function fixes_menu() {
$items = array();
$items['admin/settings/fixes'] = array(
'title' => 'Fixes module settings',
'description' => 'Please turn on the options you would like to see fixed',
'page callback' => 'drupal_get_form',
'page arguments' => array('fixes_admin'),
'access arguments' => array('administer fixes settings'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Implements hook_webform_form_alter
* FIX WEBFORM TRANSLATION OF LABELS
*/
function fixes_webform_form_alter(&$form, &$form_state, $form_id) {
// variable_set("the_aim_webform_selection", array());
if(the_aim_webform_verify($form_id)) {
fixes_custom_webform_localize($form);
}
if($form_id == 'mail_node_form') {
drupal_add_css(drupal_get_path('module', 'the_aim_webform') . '/the_aim_webform.css');
drupal_add_js(drupal_get_path('module', 'the_aim_webform') . '/the_aim_webform.js');
}
if (isset($form['#node']) && $form['#node']->type == 'webform' && isset($form['#id']) && $form['#id'] != 'webform-components-form' && $form['#id'] != 'webform-node-form') {
// dsm($form);
$form['#submit'][] = "the_aim_webform_sendmail";
// $form['#submit'][] = "the_aim_webform_confirmation";
}
}
function fixes_custom_webform_localize(&$form_item) {
if(isset($form_item['#type'])) {
if ($form_item['#type'] === 'form') {
if((bool)count($elements = @element_children($form_item['submitted']))) {
foreach ($elements as $element) {
fixes_custom_webform_localize($form_item['submitted'][$element]);
}
}
} elseif($form_item['#type'] === 'fieldset') {
if((bool)count($elements = @element_children($form_item))) {
foreach ($elements as $element) {
fixes_custom_webform_localize($form_item[$element]);
}
}
}
}
if(isset($form_item['#options'])) {
foreach ($form_item['#options'] as $key => $option) {
$form_item['#options'][$key] = t($option);
}
}
if(isset($form_item['#title'])) {
if(!is_null($form_item['#title'])) $form_item['#title'] = t($form_item['#title']);
}
if(isset($form_item['#description'])) {
if(!is_null($form_item['#description'])) $form_item['#description'] = t($form_item['#description']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment