You are here

function webform_localization_synchronizable_properties in Webform Localization 7

Same name and namespace in other branches
  1. 7.4 includes/webform_localization.component.sync.inc \webform_localization_synchronizable_properties()

Get synchronizable properties for a webform component

Parameters

array $component: A webform component.

boolean $clear_cache: A flag to force a database reading in case that properties are cached.

Return value

An array with synchronizable properties.

3 calls to webform_localization_synchronizable_properties()
webform_localization_component_sync in includes/webform_localization.component.sync.inc
Synchronize the changed component with it's translations versions.
webform_localization_form_webform_component_edit_form_alter in ./webform_localization.module
Implements hook_form_FORM_ID_alter().
_webform_localization_webform_component_edit_form_submit in ./webform_localization.module
Handle specific localization options in Webform Component Edit Form.

File

includes/webform_localization.component.sync.inc, line 97
Webform Localization Component Sync Functions.

Code

function webform_localization_synchronizable_properties($component, $clear_cache = FALSE) {
  static $webform_component_localization_options = array();
  $nid = $component['nid'];
  $cid = $component['cid'];
  if ($clear_cache || !isset($webform_component_localization_options[$nid][$cid])) {

    // Select webform localization options that match this node ID.
    $options = db_select('webform_component_localization')
      ->fields('webform_component_localization')
      ->condition('nid', $nid, '=')
      ->condition('cid', $cid, '=')
      ->execute()
      ->fetchObject();
    if (!$options) {
      $synchronizable = _webform_localization_default_properties($component);
      $webform_component_localization_options[$nid][$cid] = $synchronizable;
    }
    else {
      $synchronizable = array();
      $synchronizable['standar_values'] = unserialize($options->standar_properties);
      $synchronizable['extra_values'] = unserialize($options->extra_properties);
      $synchronizable['extra'] = $synchronizable['extra_values'];
      foreach ($synchronizable['extra'] as $k => $value) {
        $synchronizable['extra'][$k] = $k;
      }
      $synchronizable['standar'] = $synchronizable['standar_values'];
      foreach ($synchronizable['standar'] as $k => $value) {
        $synchronizable['standar'][$k] = $k;
      }
    }
  }
  else {
    $synchronizable = $webform_component_localization_options[$nid][$cid];
  }
  return $synchronizable;
}