You are here

function jquery_social_stream_block_content in jQuery social stream 8

Same name and namespace in other branches
  1. 8.2 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 26
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';
  $config = \Drupal::config('jquery_social_stream.settings');

  // Google+ API key.
  $conf['feeds']['google']['api_key'] = $config
    ->get('google_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,
    '#attached' => array(
      'js' => array(),
    ),
  );
  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/jquery.social.stream.wall.js',
      '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/jquery.social.stream.min.js',
    'type' => 'file',
  );

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

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