You are here

function jquery_social_stream_block_content in jQuery social stream 8.2

Same name and namespace in other branches
  1. 8 jquery_social_stream.module \jquery_social_stream_block_content()
  2. 7.2 jquery_social_stream.module \jquery_social_stream_block_content()
  3. 7 jquery_social_stream.module \jquery_social_stream_block_content()

Returns content of feed block.

1 call to jquery_social_stream_block_content()
JquerySocialStreamBlock::build in src/Plugin/Block/JquerySocialStreamBlock.php
Builds and returns the renderable array for this block plugin.

File

./jquery_social_stream.module, line 27
Code for the Campaign social media module.

Code

function jquery_social_stream_block_content($conf, $content = '') {
  global $base_path;
  $block = array();
  $content_id = $conf['id'];
  unset($conf['id']);
  $header = $conf['header'];
  unset($conf['header']);
  $footer = $conf['footer'];
  unset($conf['footer']);
  if (isset($conf['general']) && is_array($conf['general'])) {
    $conf += $conf['general'];
  }
  unset($conf['general']);

  // Twitter callback path.
  $conf['feeds']['twitter']['url'] = $base_path . 'js/jquery_social_stream/twitter';

  // Facebook callback path.
  $conf['feeds']['facebook']['url'] = $base_path . 'js/jquery_social_stream/facebook';
  $config = \Drupal::config('jquery_social_stream.settings');

  // Google+ API key.
  $conf['feeds']['google']['api_key'] = $config
    ->get('google_key');

  // YouTube API key.
  $conf['feeds']['youtube']['api_key'] = $config
    ->get('youtube_key');

  // Instagram API info.
  $conf['feeds']['instagram']['accessToken'] = $config
    ->get('instagram_access_token');
  $conf['feeds']['instagram']['redirectUrl'] = $config
    ->get('instagram_redirect_url');
  $conf['feeds']['instagram']['clientId'] = $config
    ->get('instagram_client_id');
  if (!empty($conf['wall'])) {
    $conf['theme'] = 'dark_1';
    $conf['rotate'] = array(
      'delay' => 0,
    );
  }
  if ($conf['theme'] != '_custom') {
    $styles = jquery_social_stream_styles();
    $style = $styles[$conf['theme']];
    $conf['iconPath'] = $GLOBALS['base_path'] . $style['iconPath'];
    $conf['imagePath'] = $GLOBALS['base_path'] . $style['imagePath'];
    $css = $style['css'];
    foreach ($style['classes'] as $key => $val) {
      $conf[$key] = $val;
    }
  }
  $block['subject'] = '';
  $block['content'] = array(
    '#theme' => 'jquery_social_stream',
    '#content_id' => $content_id,
    '#content' => $content,
    '#header' => $header,
    '#footer' => $footer,
    '#settings' => $conf,
    '#attached' => array(
      'js' => array(),
    ),
  );
  $js_filenames = jquery_social_stream_js_filenames();
  if (empty($conf['wall'])) {
    if (isset($css)) {
      $block['content']['#attached']['css'] = array(
        $css,
      );
    }
  }
  else {

    // Plugin wall js.
    $block['content']['#attached']['js'][] = array(
      'data' => libraries_get_path('jquery-social-stream') . '/js/' . $js_filenames['wall'],
      'type' => 'file',
    );
    $block['content']['#attached']['css'] = array(
      libraries_get_path('jquery-social-stream') . '/css/dcsns_wall.css',
    );
  }

  // Plugin stream js.
  $block['content']['#attached']['js'][] = array(
    'data' => libraries_get_path('jquery-social-stream') . '/js/' . $js_filenames['stream'],
    'type' => 'file',
  );

  // Module's js.
  $block['content']['#attached']['js'][] = array(
    'data' => drupal_get_path('module', 'jquery_social_stream') . '/jquery_social_stream.js',
    'type' => 'file',
  );

  // Module's css.
  $block['content']['#attached']['css'][] = drupal_get_path('module', 'jquery_social_stream') . '/jquery_social_stream.css';

  // Settings.
  $block['content']['#attached']['js'][] = array(
    'data' => array(
      'jQuerySocialStream' => array(
        $content_id => $conf,
      ),
    ),
    'type' => 'setting',
  );
  return $block;
}