i18n_boxes.module in Boxes translation 7
Same filename and directory in other branches
Provides a new boxes plugin for translatable blocks.
File
i18n_boxes.moduleView source
<?php
/**
* @file
* Provides a new boxes plugin for translatable blocks.
*/
/**
* Tag for localizable block, cannot be any language.
*/
define('I18N_BOXES_LOCALIZE', '__LOCALIZE__');
/**
* Implements hook_ctools_plugin_api().
*/
function i18n_boxes_ctools_plugin_api($module, $api) {
if ($module == 'boxes' && $api == 'plugins') {
return array(
'version' => 1,
);
}
}
/**
* Implements hook_ctools_plugin_plugins().
*/
function i18n_boxes_ctools_plugin_type() {
return array(
'plugins' => array(
'cache' => TRUE,
'use hooks' => TRUE,
'classes' => array(
'handler',
),
),
);
}
/**
* Implements hook_boxes_plugins().
*/
function i18n_boxes_boxes_plugins() {
$info = array();
$path = drupal_get_path('module', 'i18n_boxes') . '/plugins/boxes';
$info['i18n'] = array(
'title' => 'Box (translatable)',
'handler' => array(
'parent' => 'boxes_simple',
'class' => 'boxes_i18n',
'file' => 'boxes_i18n.inc',
'path' => $path,
),
);
return $info;
}
/**
* Implements hook_form_alter().
*/
function i18n_boxes_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'block_admin_configure' || $form_id == 'block_box_form' || $form_id == 'block_add_block_form') {
// Hide the Multilingual fieldset from i18nblocks to avoid confusion.
if (module_exists('i18n_blocks')) {
$form['i18n']['#access'] = FALSE;
}
}
}
/**
* Implements hook_i18n_string_info().
*/
function i18n_boxes_i18n_string_info() {
$groups['boxes'] = array(
'title' => t('Boxes'),
'description' => t('Translatable boxes: title and body.'),
'format' => TRUE,
// This group has strings with format.
'list' => TRUE,
);
return $groups;
}
/**
* Refresh all strings.
*/
function i18n_boxes_i18n_string_refresh() {
$boxes = boxes_box_load();
if (!empty($boxes)) {
foreach ($boxes as $delta => $box) {
if ($box->plugin_key == 'i18n') {
$box
->locale_refresh();
}
}
}
return TRUE;
// Meaning it completed with no issues.
}
Functions
Name | Description |
---|---|
i18n_boxes_boxes_plugins | Implements hook_boxes_plugins(). |
i18n_boxes_ctools_plugin_api | Implements hook_ctools_plugin_api(). |
i18n_boxes_ctools_plugin_type | Implements hook_ctools_plugin_plugins(). |
i18n_boxes_form_alter | Implements hook_form_alter(). |
i18n_boxes_i18n_string_info | Implements hook_i18n_string_info(). |
i18n_boxes_i18n_string_refresh | Refresh all strings. |
Constants
Name | Description |
---|---|
I18N_BOXES_LOCALIZE | Tag for localizable block, cannot be any language. |