You are here

function service_links_expand_path in Service links 6.2

Same name and namespace in other branches
  1. 7.2 service_links.module \service_links_expand_path()

Expand the path around a filename depending from the context.

Parameters

$filename: If NULL the function return only the path with trailing slash.

$context: Define what path should consider this function.

$default: Concerning the image path is useful define a default path if the alternative is not set up.

Return value

A string with the full filename or the path.

10 calls to service_links_expand_path()
service_links_admin_services in ./service_links.admin.inc
Menu callback administration settings for services links list.
service_links_admin_settings in ./service_links.admin.inc
Menu callback administration settings for general options.
service_links_block in ./service_links.module
Implementation of hook_block().
service_links_sprites_validate in plugins/service_links_sprites.module
theme_service_links_build_link in ./service_links.theme.inc
Build a single link following the style rules.

... See full list

File

./service_links.module, line 952
Adds social network links to the content.

Code

function service_links_expand_path($filename = NULL, $context = 'icons', $default = 'preset') {
  static $sl_paths;
  static $sl_checkpath;
  if (strpos($filename, '/') !== FALSE) {
    return $filename;
  }
  if (!isset($sl_paths)) {
    $sl_paths['base'] = drupal_get_path('module', 'service_links');
    $sl_paths += array(
      'preset' => $sl_paths['base'] . '/images',
      'javascript' => $sl_paths['base'] . '/js',
      'css' => $sl_paths['base'] . '/css',
    );
    $sl_checkpath = array(
      'preset' => FALSE,
      'javascript' => FALSE,
      'css' => FALSE,
    );
  }
  if (!isset($sl_paths[$context])) {
    $sl_paths[$context] = variable_get("service_links_path_{$context}", '');
    if (empty($sl_paths[$context])) {
      $sl_paths[$context] = $sl_paths[$default];
    }
    $sl_checkpath[$context] = variable_get("service_links_check_{$context}", FALSE);
  }
  if (isset($filename)) {
    if ($sl_checkpath[$context]) {
      if (file_exists($sl_paths[$context] . '/' . $filename)) {
        return $sl_paths[$context] . '/' . $filename;
      }
      else {
        return $sl_paths[$default] . '/' . $filename;
      }
    }
    else {
      return $sl_paths[$context] . '/' . $filename;
    }
  }
  else {
    return $sl_paths[$context];
  }
}