You are here

function dynamic_background_blog_dynamic_background_css in Dynamic Background 6

Same name and namespace in other branches
  1. 7.2 modules/dynamic_background_blog/dynamic_background_blog.module \dynamic_background_blog_dynamic_background_css()
  2. 7 modules/dynamic_background_blog/dynamic_background_blog.module \dynamic_background_blog_dynamic_background_css()

Implements hook_dynamic_background_css().

File

modules/dynamic_background_blog/dynamic_background_blog.module, line 142

Code

function dynamic_background_blog_dynamic_background_css($vars) {
  $uid = NULL;

  // There are two ways to detecte the different parts of a blog. The path
  // /blog/%uid_optional of the node type blog. First we look at the node type,
  // then the path.
  if (isset($vars['node']) && $vars['node']->type == 'blog') {
    $uid = $vars['node']->uid;
  }
  else {

    // Try to find the uid by using path.
    $parts = split('/', $_GET['q']);
    if (count($parts) >= 2 && $parts[0] == DYNAMIC_BACKGROUND_BLOG_PATH && is_numeric($parts[1])) {

      // Test that the 2nd part is an interger (meight be a user id).
      $uid = (int) $parts[1];
    }
  }

  // Load imagecache settings.
  $imagecache = variable_get('dynamic_background_blog_imagecache', FALSE);

  // If user id was found, try to load blog background image if one is definded.
  if (!is_null($uid)) {

    // Get selected image id for current blog.
    $image_id = dynamic_background_blog_get_image_id($uid);
    if (!is_null($image_id)) {

      // Get global backgrounds.
      $backgrounds = variable_get('dynamic_background_images', array());
      if (isset($backgrounds[$image_id]['default'])) {
        return array(
          'image' => $backgrounds[$image_id]['default'],
          'configuration' => variable_get('dynamic_background_blog_css', array()),
          'imagecache' => $imagecache ? $imagecache['present'] : FALSE,
          'weight' => 230,
        );
      }
    }
  }
}