You are here

function service_links_expand_path in Service links 7.2

Same name and namespace in other branches
  1. 6.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.

11 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_configure in ./service_links.module
Implements hook_block_configure().
service_links_service_links_content_type_edit_form in plugins/content_types/service_links.inc
The form to add or edit a service_links as content.
service_links_sprites_validate in plugins/service_links_sprites.module

... See full list

File

./service_links.module, line 996
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];
  }
}