You are here

function instagram_feeds_block_get_config in Instagram Feeds 7

Returns the configuration for the requested block delta.

Parameters

string $delta: string The delta that uniquely identifies the block in the block system. If not specified, the default configuration will be returned.

Return value

array An associative array of configuration options.

3 calls to instagram_feeds_block_get_config()
instagram_feeds_block_info in ./instagram_feeds.module
Implements hook_block_info().
instagram_feeds_block_view in ./instagram_feeds.module
Implements hook_block_view().
instagram_feeds_urls_from_feed in ./instagram_feeds.module
Creates an array of feeds urls from Instagram Feed.

File

./instagram_feeds.module, line 717

Code

function instagram_feeds_block_get_config($delta = NULL) {
  $config = array(
    'delta' => $delta,
    'admin_title' => '',
    'status' => 0,
    'columns' => 1,
  );
  if ($delta) {
    $configs =& drupal_static(__FUNCTION__);
    if (isset($configs[$delta])) {
      $config = $configs[$delta];
    }
    else {

      // Get the block configuration options.
      $node = node_load($config['delta']);
      if ($node) {
        $config['admin_title'] = $node->title;
        $config['status'] = $node->status;
        $config['favorites'] = $node->field_instf_favorites[LANGUAGE_NONE][0]['value'];
        if (isset($node->field_instf_hash_tags[LANGUAGE_NONE]) && count($node->field_instf_hash_tags[LANGUAGE_NONE])) {
          foreach ($node->field_instf_hash_tags[LANGUAGE_NONE] as $term) {
            $config['tags'][] = $term['tid'];
          }
        }
        else {
          $config['tags'] = array(
            'all',
          );
        }
        if (isset($node->field_instf_user[LANGUAGE_NONE]) && count($node->field_instf_user[LANGUAGE_NONE])) {
          foreach ($node->field_instf_user[LANGUAGE_NONE] as $term) {
            $config['users'][] = $term['tid'];
          }
        }
        else {
          $config['users'] = array();
        }
        $config['rows'] = $node->field_instf_rows[LANGUAGE_NONE][0]['value'];
        $config['columns'] = $node->field_instf_columns[LANGUAGE_NONE][0]['value'];
        $config['thumb_size'] = $node->field_instf_thumb_size[LANGUAGE_NONE][0]['value'];
        $config['border']['width'] = $node->field_instf_border_width[LANGUAGE_NONE][0]['value'];
        $config['border']['color'] = '#' == $node->field_instf_color[LANGUAGE_NONE][0]['rgb'] ? 'rgba(0,0,0,0)' : $node->field_instf_color[LANGUAGE_NONE][0]['rgb'];
        $config['font']['size'] = $node->field_instf_font_size[LANGUAGE_NONE][0]['value'];
        $config['font']['color'] = $node->field_instf_font_color[LANGUAGE_NONE][0]['rgb'];
        switch ($node->field_instf_font_family[LANGUAGE_NONE][0]['value']) {
          case 'georgia':
            $font_family = 'Georgia, serif';
            break;
          case 'tahoma':
            $font_family = 'Tahoma, Geneva, sans-serif';
            break;
          case 'serif':
            $font_family = '"Times New Roman", Times, serif';
            break;
          case 'sans-serif':
            $font_family = 'Arial, Helvetica, sans-serif';
            break;
          default:
            $font_family = 'inherit';
            break;
        }
        $config['font']['family'] = $font_family;
        $config['popup_info'] = array();
        if ($node->field_instf_display_on_popup) {
          foreach ($node->field_instf_display_on_popup[LANGUAGE_NONE] as $element) {
            $config['popup_info'][] = '[' . $element['value'] . ']';
          }
        }
      }
      $configs[$delta] = $config;
    }
  }
  return $config;
}