You are here

function data_ui_get_default_path in Data 7

Same name and namespace in other branches
  1. 6 data_ui/data_ui.module \data_ui_get_default_path()

Creates the default path for a data table.

3 calls to data_ui_get_default_path()
data_ui_manage in data_ui/data_ui.admin.inc
Main page for data table management.
data_ui_view in data_ui/data_ui.admin.inc
List all tables for viewing content.
data_ui_views_default_views in data_ui/data_ui.views_default.inc
Implements hook_views_default_views().

File

data_ui/data_ui.module, line 274
Hooks and API functions for Data UI module.

Code

function data_ui_get_default_path($name) {
  if ($table = data_get_table($name)) {

    // Check whether this can be a Views base table.
    $table_schema = $table
      ->get('table_schema');
    if (isset($table_schema['primary key'])) {
      return 'admin/content/data/view/' . $name;
    }

    // Check whether there is a data mananged table to the left.
    // @todo: go all the way to the left.
    $path = '';
    $meta = $table
      ->get('meta');
    if (isset($meta['join']) && is_array($meta['join']) && !empty($meta['join'])) {
      $left_table_name = key($meta['join']);
      if ($left_table = data_get_table($left_table_name)) {
        $path .= $left_table_name . '/';
      }
      return 'admin/content/data/view/' . $path . $name;
    }
  }
  return '';
}