path_admin_overview
- Versions
- 6 – 7
path_admin_overview($keys = NULL)
Return a listing of all defined URL aliases.
When filter key passed, perform a standard search on the given key, and return the list of matching URL aliases.
Code
modules/path/path.admin.inc, line 14
<?php
function path_admin_overview($keys = NULL) {
// Add the filter form above the overview table.
$build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys);
// Enable language column if locale is enabled or if we have any alias with language
$alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE language <> :language', 0, 1, array(':language' => ''))->fetchField();
$multilanguage = (module_exists('locale') || $alias_exists);
$header = array(
array('data' => t('Alias'), 'field' => 'alias', 'sort' => 'asc'),
array('data' => t('System'), 'field' => 'source'),
array('data' => t('Operations'), 'colspan' => '2')
);
if ($multilanguage) {
array_splice($header, 2, 0, array(array('data' => t('Language'), 'field' => 'language')));
}
$query = db_select('url_alias')->extend('PagerDefault')->extend('TableSort');
if ($keys) {
// Replace wildcards with PDO wildcards.
$query->condition('alias', '%' . preg_replace('!\*+!', '%', $keys) . '%', 'LIKE');
}
$result = $query
->fields('url_alias')
->orderByHeader($header)
->limit(50)
->execute();
$rows = array();
$destination = drupal_get_destination();
foreach ($result as $data) {
$row = array(
'data' => array(
l($data->alias, $data->source),
l($data->source, $data->source, array('alias' => TRUE)),
l(t('edit'), "admin/config/search/path/edit/$data->pid", array('query' => $destination)),
l(t('delete'), "admin/config/search/path/delete/$data->pid", array('query' => $destination)),
),
);
// If the system path maps to a different URL alias, highlight this table
// row to let the user know of old aliases.
if ($data->alias != drupal_get_path_alias($data->source, $data->language)) {
$row['class'] = array('warning');
}
if ($multilanguage) {
array_splice($row['data'], 2, 0, module_invoke('locale', 'language_name', $data->language));
}
$rows[] = $row;
}
if (empty($rows)) {
$empty_message = $keys ? t('No URL aliases found.') : t('No URL aliases available. <a href="@link">Add alias</a>.', array('@link' => url('admin/config/search/path/add'))) ;
$rows[] = array(array('data' => $empty_message, 'colspan' => ($multilanguage ? 5 : 4)));
}
$build['path_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows
);
$build['path_pager'] = array('#theme' => 'pager');
return $build;
}
?>Login or register to post comments 