You are here

function spaces_customtext_feature_strings in Spaces 7.3

Same name and namespace in other branches
  1. 6.3 spaces_customtext/spaces_customtext.admin.inc \spaces_customtext_feature_strings()
  2. 7 spaces_customtext/spaces_customtext.admin.inc \spaces_customtext_feature_strings()

Retrieve strings related to the given feature.

1 call to spaces_customtext_feature_strings()
spaces_customtext_settings_form in spaces_customtext/spaces_customtext.admin.inc
System settings form for custom text strings.

File

spaces_customtext/spaces_customtext.admin.inc, line 74

Code

function spaces_customtext_feature_strings($feature) {
  global $language;
  $langcode = $language->language;
  $features = spaces_features(spaces_get_space() ? spaces_get_space()->type : 'site');
  $strings = array();
  if (isset($features[$feature])) {

    // We want to get the original string values for any object retrieval we
    // do, so use a fake language code temporarily. Note that any
    // retrieval must clear any caches (static or db) that may have t()'d
    // the original source string.
    $language->language = 'spaces_customtext';
    $feature = $features[$feature];

    // Feature name.
    $strings[] = $feature->info['name'];

    // Node types.
    if ($map = features_get_component_map('node')) {
      foreach ($map as $node_type => $component_features) {
        if (in_array($feature->name, $component_features)) {
          node_types_clear();
          $strings[] = node_type_get_name($node_type);
        }
      }
    }

    // Views.
    if ($map = features_get_component_map('views')) {
      foreach ($map as $view_name => $component_features) {
        if (in_array($feature->name, $component_features) && ($view = views_get_view($view_name, TRUE))) {
          foreach (array_keys($view->display) as $display_id) {
            $view
              ->set_display($display_id);
            $strings[] = $view->display_handler
              ->get_option('title');
          }
          $view
            ->destroy();
        }
      }
    }

    // hook_menu().
    if (module_hook($feature->name, 'menu')) {
      $items = module_invoke($feature->name, 'menu');
      foreach ($items as $path => $item) {

        // Don't pollute options with administrative page strings.
        if (isset($item['title']) && strpos($path, 'features/') === FALSE && strpos($path, 'admin/') === FALSE) {
          $strings[] = $item['title'];
        }
      }
    }

    // Localize the original strings. This will use translations of the
    // original strings if available.
    $localized = array();
    foreach ($strings as $string) {
      $localized[] = module_exists('locale') ? locale($string, $langcode) : $string;
    }

    // Put the actual language code back.
    $language->language = $langcode;
  }
  return $strings;
}