You are here

function _service_links_match_path in Service links 7.2

Same name and namespace in other branches
  1. 6.2 service_links.module \_service_links_match_path()

Match the current path with the list or the code inserted in the configuration page.

1 call to _service_links_match_path()
service_links_show in ./service_links.module
Check if the service links should be displayed for the content type, for category or one of the other selected options.

File

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

Code

function _service_links_match_path() {
  static $page_match;
  if (isset($page_match)) {
    return $page_match;
  }
  $pages = variable_get('service_links_page_match_for_node', '');
  $visibility = variable_get('service_links_visibility_for_node', SERVICE_LINKS_VISIBILITY_NOT_LISTED);
  if (!empty($pages)) {

    // Convert path to lowercase. This allows comparison of the same path
    // with different case. Ex: /Page, /page, /PAGE.
    $pages = drupal_strtolower($pages);
    if ($visibility < SERVICE_LINKS_VISIBILITY_PHP) {
      $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));

      // Compare with the internal and path alias (if any).
      $page_match = drupal_match_path($path, $pages);
      if ($path != $_GET['q']) {
        $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
      }

      // When $visibility has a value of 0, the links are displayed on
      // all pages except those listed in $pages. When set to 1, it
      // is displayed only on those pages listed in $pages.
      $page_match = !($visibility xor $page_match);
    }
    elseif (module_exists('php')) {
      $page_match = php_eval($pages);
    }
    else {
      $page_match = FALSE;
    }
  }
  else {
    $page_match = TRUE;
  }
  return $page_match;
}