You are here

function _draggableviews_get_order_path in DraggableViews 7.2

Get the path to the order view.

Parameters

$view: The view object.

Return value

The path of the page or FALSE if there isn't one.

1 call to _draggableviews_get_order_path()
draggableviews_contextual_links_view_alter in ./draggableviews.module
Implements hook_contextual_links_view_alter().

File

./draggableviews.module, line 524

Code

function _draggableviews_get_order_path($view, $include_self = TRUE) {
  $path = FALSE;
  if ($order_view = _draggableviews_load_order_view($view, $include_self)) {
    if (isset($order_view->display[$order_view->current_display]->display_options['path'])) {
      $path = $order_view->display[$order_view->current_display]->display_options['path'];
    }
  }
  elseif ($include_self) {
    if (isset($view->display[$view->current_display]->display_options['path'])) {
      $path = $view->display[$view->current_display]->display_options['path'];
    }
  }
  else {
    return FALSE;
  }

  // If page expects arguments, we provide arguments set to current view.
  $args = $view->args;
  if (strpos($path, '%') !== FALSE && !empty($args)) {
    $new_path_array = array();
    foreach (explode('/', $path) as $path_part) {
      if (strpos($path_part, '%') !== FALSE) {
        $new_path_array[] = !empty($args) ? array_shift($args) : '';
      }
      else {
        $new_path_array[] = $path_part;
      }
    }
    $path = implode('/', $new_path_array);
  }

  // If page path doesn't have % in the path or we still have some argument
  // remain, simply append them to the end of the path.
  if (!empty($args)) {
    $path .= '/' . implode('/', $args);
  }
  return $path;
}