Index: views.module =================================================================== --- views.module (Revision 6447) +++ views.module (Arbeitskopie) @@ -1343,3 +1343,32 @@ return $value; } + +function views_shorten_alias($key, $value, &$replacements) { + if (is_string($value) && strlen($value) > 64) { + $replacements[$value] = views_find_short_alias($value); + } + if (is_string($key) && strlen($key) > 64) { + $replacements[$key] = views_find_short_alias($key); + } +} + +function views_find_short_alias($alias) { + static $counter = 0; + $arr = explode('_', $alias); + $short_alias = array_shift($arr); + foreach ($arr as $idx => $val) { + if (strlen(($new_short_alias = $short_alias . '_' . $val)) <= 60) { + $short_alias = $new_short_alias; + } + else { + $short_alias .= '_' . $counter++; + break; + } + } + return $short_alias; +} + +function views_sort_by_length($key1, $key2) { + return strlen($key2) > strlen($key1); +} Index: includes/view.inc =================================================================== --- includes/view.inc (Revision 6447) +++ includes/view.inc (Arbeitskopie) @@ -720,6 +720,10 @@ $items = array(); if ($query) { $replacements = module_invoke_all('views_query_substitutions', $this); + array_walk_recursive($this->query->tables, 'views_shorten_alias', &$replacements); + array_walk_recursive($this->query->fields, 'views_shorten_alias', &$replacements); + uksort(&$replacements, 'views_sort_by_length'); + $inv_replacements = array_flip($replacements); $query = str_replace(array_keys($replacements), $replacements, $query); $count_query = 'SELECT COUNT(*) FROM (' . str_replace(array_keys($replacements), $replacements, $count_query) . ') count_alias'; @@ -777,6 +781,12 @@ $this->result = array(); while ($item = db_fetch_object($result)) { + foreach ($item as $key => $value) { + if (isset($inv_replacements[$key])) { + $item->$inv_replacements[$key] = $value; + unset($item->$key); + } + } $this->result[] = $item; }