You are here

function _pages_restriction_get_translated_path in Pages Restriction Access 7

Rule to get the next page path translated for multilingual sites.

Parameters

string $path: String current URL Path that users access.

Return value

string Return the next page path translated.

2 calls to _pages_restriction_get_translated_path()
pages_restriction_page_alter in ./pages_restriction.module
Implements hook_page_alter().
_pages_restriction_set_next_page_path in includes/pages_restriction.helpers.inc
Update page on cache so it can be retrieved later.

File

includes/pages_restriction.helpers.inc, line 136
Contains the helpers functions for the Pages Restriction.

Code

function _pages_restriction_get_translated_path($path) {
  $translated_path = preg_replace('"/"', '', url(current_path(), array(
    'relative' => TRUE,
  )), 1, $count);
  if ($path == $translated_path) {
    return $translated_path;
  }
  $rules = explode(PHP_EOL, variable_get('pages_restriction_rules'));
  foreach ($rules as $rule) {
    $pages = explode("|", $rule);
    foreach ($pages as $page) {
      $page = preg_replace('/\\/%/', '', $page);
      if ($translated_path == $page) {
        $translated_path = $pages[0];
        break;
      }
    }
  }
  return $translated_path;
}