Commit 89971a9f authored by merlinofchaos's avatar merlinofchaos
Browse files

More yched cleanup

parent 88bde8e4
...@@ -180,28 +180,38 @@ function views_invalidate_cache() { ...@@ -180,28 +180,38 @@ function views_invalidate_cache() {
* the $view object than is in the database, and this isn't necessarily * the $view object than is in the database, and this isn't necessarily
* set when a view is constructed externally. * set when a view is constructed externally.
*/ */
function _views_sanitize_view(&$view) { function views_sanitize_view(&$view) {
_views_check_arrays($view); // so reference works. _views_check_arrays($view); // so reference works.
foreach ($view->field as $i => $field) { foreach ($view->field as $i => $field) {
if (!isset($view->field[$i]['id'])) {
$view->field[$i]['id'] = $view->field[$i]['fullname'] = "$field[tablename].$field[field]"; $view->field[$i]['id'] = $view->field[$i]['fullname'] = "$field[tablename].$field[field]";
$view->field[$i]['queryname'] = "$field[tablename]_$field[field]"; $view->field[$i]['queryname'] = "$field[tablename]_$field[field]";
} }
}
foreach ($view->filter as $i => $filter) { foreach ($view->filter as $i => $filter) {
if (!isset($view->filter[$i]['id'])) {
$view->filter[$i]['id'] = $view->filter[$i]['field'] = "$filter[tablename].$filter[field]"; $view->filter[$i]['id'] = $view->filter[$i]['field'] = "$filter[tablename].$filter[field]";
} }
}
foreach ($view->exposed_filter as $i => $exposed_filter) { foreach ($view->exposed_filter as $i => $exposed_filter) {
if (!isset($view->exposed_filter[$i]['id'])) {
$view->exposed_filter[$i]['id'] = $view->exposed_filter[$i]['field'] = "$exposed_filter[tablename].$exposed_filter[field]"; $view->exposed_filter[$i]['id'] = $view->exposed_filter[$i]['field'] = "$exposed_filter[tablename].$exposed_filter[field]";
} }
}
foreach ($view->sort as $i => $sort) { foreach ($view->sort as $i => $sort) {
if (!isset($view->sort[$i]['id'])) {
$view->sort[$i]['id'] = $view->sort[$i]['field'] = "$sort[tablename].$sort[field]"; $view->sort[$i]['id'] = $view->sort[$i]['field'] = "$sort[tablename].$sort[field]";
} }
}
foreach ($view->argument as $i => $argument) { foreach ($view->argument as $i => $argument) {
if (!isset($view->argument[$i]['id'])) {
$view->argument[$i]['id'] = $view->argument[$i]['type']; $view->argument[$i]['id'] = $view->argument[$i]['type'];
} }
}
} }
/** /**
...@@ -226,7 +236,7 @@ function _views_get_default_views() { ...@@ -226,7 +236,7 @@ function _views_get_default_views() {
$views_default_views = array(); $views_default_views = array();
foreach ($views as $i => $view) { foreach ($views as $i => $view) {
if (!is_array($view->requires) || !array_diff($view->requires, $tables)) { if (!is_array($view->requires) || !array_diff($view->requires, $tables)) {
_views_sanitize_view($view); views_sanitize_view($view);
$views_default_views[$i] = $view; $views_default_views[$i] = $view;
} }
} }
......
...@@ -351,7 +351,7 @@ function views_import_view_submit($formid, $form) { ...@@ -351,7 +351,7 @@ function views_import_view_submit($formid, $form) {
$tables = array_keys(_views_get_tables()); $tables = array_keys(_views_get_tables());
if ($view) { if ($view) {
if (!is_array($view->requires) || !array_diff($view->requires, $tables)) { if (!is_array($view->requires) || !array_diff($view->requires, $tables)) {
_views_sanitize_view($view); views_sanitize_view($view);
drupal_set_title(t('Add a View')); drupal_set_title(t('Add a View'));
$output = _views_view_form($view, NULL); $output = _views_view_form($view, NULL);
print theme('page', $output); print theme('page', $output);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment